fix: remove `geo.d.ts`

Use of Template Literal Types broke support for older LB4 projects.

Temporarily removing it would have minimal impact as:

1. It was only introduced in the last release
2. It was not usable as-is due to wrong export location

fixes: https://github.com/loopbackio/loopback-datasource-juggler/issues/1909

Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
This commit is contained in:
Rifa Achrinza 2022-02-22 17:07:10 +08:00
parent 74d429d52d
commit 2691470504
4 changed files with 1 additions and 150 deletions

1
index.d.ts vendored
View File

@ -34,4 +34,3 @@ export * from './types/observer-mixin';
export * from './types/validation-mixin'; export * from './types/validation-mixin';
export * from './types/inclusion-mixin'; export * from './types/inclusion-mixin';
export * from './types/connector'; export * from './types/connector';
export * from './types/geo';

View File

@ -1,25 +0,0 @@
import {GeoDistanceUnit, GeoPoint, filter, nearFilter} from '../geo';
let numberTypeGuard: number;
new GeoPoint(123, 456);
new GeoPoint('123', 456);
new GeoPoint(123, '456');
new GeoPoint('123', '456');
new GeoPoint([123, 456]);
new GeoPoint(['123', '456']);
new GeoPoint(['123', 456]);
new GeoPoint([123, '456']);
new GeoPoint({lat: 123, lng: 456});
new GeoPoint({lat: '123', lng: 456})
new GeoPoint({lat: 123, lng: '456'})
new GeoPoint({lat: '123', lng: '456'});
numberTypeGuard = GeoPoint.distanceBetwen([123, 456], [123, 456]);
numberTypeGuard = GeoPoint.distanceBetwen([123, 456], [123, 456], {type: GeoDistanceUnit.degrees});
const geoPoint = new GeoPoint(123, 456);
numberTypeGuard = geoPoint.distanceTo([123, 456])
numberTypeGuard = geoPoint.distanceTo([123, 456], {type: GeoDistanceUnit.degrees});

122
types/geo.d.ts vendored
View File

@ -1,122 +0,0 @@
import { Where } from "./query";
export function nearFilter(where: Where): false | GeoPointFilter[];
export function filter(rawResults: GeoPointRawResult[], filters: GeoPointFilter[]): GeoPointFilter;
export type GeoPointFilter = {
near: GeoPoint | ConstructorParameters<typeof GeoPoint>;
maxDistance: number;
minDistance: number;
unit: GeoDistanceUnit;
mongoKey: string;
key: string;
}
export type GeoPointRawResult = {
[key: string]: {
lat: number;
lng: number;
}
}
export class GeoPoint {
lat: number;
lng: number;
/**
*
* @example
* ```typescript
* new GeoPoint({
* lat: 145,
* lng: 96,
* });
* ```
*
* @example
* ```typescript
* new GeoPoint({
* lat: '145',
* lng: '96',
* });
* ```
*
* @param data
*/
constructor(data: {
lat: string | number,
lng: string | number,
})
/**
* @example
* ```typescript
* new GeoPoint('145,96');
* ```
*
* @example
* ```typescript
* new GeoPoint('145 , 96');
* ```
*
* @param data
*/
constructor(data: `${number},${number}`)
/**
* @example
* ```typescript
* new GeoPoint([145, 96]);
* ```
*
* @example
* ```typescript
* new GeoPoint(['145', '96']);
* ```
*
* @param data
*/
constructor(data: [string | number, string | number])
/**
* @example
* ```typescript
* new GeoPoint(145, 96);
* ```
*
* @example
* ```typescript
* new GeoPoint('145', '96');
* ```
*
* @param data
*/
constructor(lat: string | number, lng: string | number)
static distanceBetwen(
a: GeoPoint | ConstructorParameters<typeof GeoPoint>,
b: GeoPoint | ConstructorParameters<typeof GeoPoint>,
options?: GeoDistanceOptions,
): number;
distanceTo(
point: GeoPoint | ConstructorParameters<typeof GeoPoint>,
options?: GeoDistanceOptions,
): number;
toString(): `$${number},${number}`;
}
export type GeoDistanceOptions = {
type: GeoDistanceUnit;
}
export enum GeoDistanceUnit {
'kilometers',
'meters',
'miles',
'feet',
'radians',
'degrees',
}

3
types/types.d.ts vendored
View File

@ -1,5 +1,4 @@
import {DateString} from './date-string'; import {DateString} from './date-string';
import {GeoPoint} from './geo';
// @achrinza: The return value is a hack to inform TypeScript of function parameter mutations. // @achrinza: The return value is a hack to inform TypeScript of function parameter mutations.
// see: https://github.com/microsoft/TypeScript/issues/22865#issuecomment-725015710 // see: https://github.com/microsoft/TypeScript/issues/22865#issuecomment-725015710
@ -57,7 +56,7 @@ declare namespace registerModelTypes {
'Buffer': Buffer; 'Buffer': Buffer;
'Array': Array<unknown>; 'Array': Array<unknown>;
'Object': Object; 'Object': Object;
'GeoPoint': GeoPoint // 'GeoPoint': GeoPoint // Removed temporarily. See: https://github.com/loopbackio/loopback-datasource-juggler/issues/1909
}; };
registerType: (type: Type, names?: string[]) => void; registerType: (type: Type, names?: string[]) => void;
} }