-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
UnactionableThere isn't something we can do with this issueThere isn't something we can do with this issue
Description
Search Terms
Suggestion
i don't know what is better name for ITSOverwriteThisFunction
interface Function2 extends Function
{
bind<T extends any, F extends (...args: any[]) => any>(this: F, thisArg: T, ...argArray: any[]): ITSOverwriteThisFunction<T, F>;
}
export type ITSOverwriteThisFunction<T extends any, F extends (...args: any[]) => any> =
(this: T, ...args: Parameters<F>) => ReturnType<F>
Use Cases
- we can now let
fn.bind
, know who isthis
problem: current typescript not support overload function, so this has limit
Examples
this examples looks so stupid, but i don't know how to make look better
export interface t4 extends Function2
{
(): string
}
export declare let t5: t4
export let t6 = t5.bind([] as string[])
t6 = function ()
{
this.includes('') // => this is string[]
return ''
}
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Metadata
Metadata
Assignees
Labels
UnactionableThere isn't something we can do with this issueThere isn't something we can do with this issue