Skip to content

Commit 47de55a

Browse files
committed
Remove remaining unused imports and values
1 parent a9aefe4 commit 47de55a

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

src/deprecatedCompat/deprecations.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import {
2-
hasProperty,
32
UnionToIntersection,
43
Version,
54
} from "./_namespaces/ts";
6-
import {
7-
deprecate,
8-
} from "./deprecate";
95

106
/** @internal */
117
export interface DeprecationOptions {
@@ -37,9 +33,6 @@ export interface DeprecationOptions {
3733
*/
3834
export type OverloadDefinitions = { readonly [P in number]: (...args: any[]) => any; };
3935

40-
/** A function that returns the ordinal of the overload that matches the provided arguments */
41-
type OverloadBinder<T extends OverloadDefinitions> = (args: OverloadParameters<T>) => OverloadKeys<T> | undefined;
42-
4336
/**
4437
* Extracts the ordinals from an set of overload definitions.
4538
*
@@ -79,43 +72,6 @@ export type OverloadBinders<T extends OverloadDefinitions> = { [P in OverloadKey
7972
*/
8073
export type OverloadDeprecations<T extends OverloadDefinitions> = { [P in OverloadKeys<T>]?: DeprecationOptions; };
8174

82-
/** @internal */
83-
function createOverload<T extends OverloadDefinitions>(name: string, overloads: T, binder: OverloadBinders<T>, deprecations?: OverloadDeprecations<T>) {
84-
Object.defineProperty(call, "name", { ...Object.getOwnPropertyDescriptor(call, "name"), value: name });
85-
86-
if (deprecations) {
87-
for (const key of Object.keys(deprecations)) {
88-
const index = +key as (keyof T & number);
89-
if (!isNaN(index) && hasProperty(overloads, `${index}`)) {
90-
overloads[index] = deprecate(overloads[index], { ...deprecations[index], name });
91-
}
92-
}
93-
}
94-
95-
const bind = createBinder(overloads, binder);
96-
return call as OverloadFunction<T>;
97-
98-
function call(...args: OverloadParameters<T>) {
99-
const index = bind(args);
100-
const fn = index !== undefined ? overloads[index] : undefined;
101-
if (typeof fn === "function") {
102-
return fn(...args);
103-
}
104-
throw new TypeError("Invalid arguments");
105-
}
106-
}
107-
108-
function createBinder<T extends OverloadDefinitions>(overloads: T, binder: OverloadBinders<T>): OverloadBinder<T> {
109-
return args => {
110-
for (let i = 0; hasProperty(overloads, `${i}`) && hasProperty(binder, `${i}`); i++) {
111-
const fn = binder[i];
112-
if (fn(args)) {
113-
return i as OverloadKeys<T>;
114-
}
115-
}
116-
};
117-
}
118-
11975
/** @internal */
12076
export interface OverloadBuilder {
12177
overload<T extends OverloadDefinitions>(overloads: T): BindableOverloadBuilder<T>;
@@ -135,20 +91,3 @@ export interface FinishableOverloadBuilder<T extends OverloadDefinitions> {
13591
export interface BoundOverloadBuilder<T extends OverloadDefinitions> extends FinishableOverloadBuilder<T> {
13692
deprecate(deprecations: OverloadDeprecations<T>): FinishableOverloadBuilder<T>;
13793
}
138-
139-
// NOTE: We only use this "builder" because we don't infer correctly when calling `createOverload` directly in < TS 4.7,
140-
// but lib is currently at TS 4.4. We can switch to directly calling `createOverload` when we update LKG in main.
141-
142-
/** @internal */
143-
function buildOverload(name: string): OverloadBuilder {
144-
return {
145-
overload: overloads => ({
146-
bind: binder => ({
147-
finish: () => createOverload(name, overloads, binder),
148-
deprecate: deprecations => ({
149-
finish: () => createOverload(name, overloads, binder, deprecations),
150-
}),
151-
}),
152-
}),
153-
};
154-
}

0 commit comments

Comments
 (0)