Skip to content

Commit

Permalink
fix: add missing constructor to TS type definitions
Browse files Browse the repository at this point in the history
TS with Node16 or NodeNext module target expect explicit constructo
to allow new Foo() without syntax error.

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
  • Loading branch information
Jérôme Benoit committed Jan 2, 2024
1 parent 8453d82 commit 0f1d5d7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bi-map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export default class BiMap<K, V> implements Iterable<[K, V]> {
size: number;
inverse: InverseMap<V, K>;

// Constructor
constructor();

// Methods
clear(): void;
set(key: K, value: V): this;
Expand Down
3 changes: 3 additions & 0 deletions kd-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default class KDTree<V> {
size: number;
visited: number;

// Constructor
private constructor(dimensions: number, build: any);

// Methods
nearestNeighbor(point: Array<number>): V;
kNearestNeighbors(k: number, point: Array<number>): Array<V>;
Expand Down
5 changes: 4 additions & 1 deletion linked-list.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default class LinkedList<T> implements Iterable<T> {
// Members
size: number;

// Constructor
constructor();

// Methods
clear(): void;
first(): T | undefined;
Expand All @@ -26,4 +29,4 @@ export default class LinkedList<T> implements Iterable<T> {

// Statics
static from<I>(iterable: Iterable<I> | {[key: string]: I}): LinkedList<I>;
}
}
2 changes: 1 addition & 1 deletion multi-map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ interface MultiMapConstructor {
}

declare const MultiMap: MultiMapConstructor;
export default MultiMap;
export default MultiMap;
3 changes: 3 additions & 0 deletions multi-set.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default class MultiSet<K> implements Iterable<K> {
dimension: number;
size: number;

// Constructor
constructor();

// Methods
clear(): void;
add(key: K, count?: number): this;
Expand Down
3 changes: 3 additions & 0 deletions queue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default class Queue<T> implements Iterable<T> {
// Members
size: number;

// Constructor
constructor();

// Methods
clear(): void;
enqueue(item: T): number;
Expand Down
3 changes: 3 additions & 0 deletions stack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default class Stack<T> implements Iterable<T> {
// Members
size: number;

// Constructor
constructor();

// Methods
clear(): void;
push(item: T): number;
Expand Down

0 comments on commit 0f1d5d7

Please sign in to comment.