You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceFunInterface{<R,P>(params: P): R;}letfun: FunInterface;letp="123";fun<number>("123");// should be equivalent with `fun<number, typeof p>(p)`// should be equivalent with `fun<number, string>(p)`
one more thing, Generics by default
functionname(p){returnp}// should be equivalent with// function name<P>(p:P){// return p// }constaName=name("someName")// type of aName is stringconstaNumber=name(123)// type of aNumber is number
Examples
functiondeal<Aextendsunknown[],E>(event: E){return{
event,fun:(fn:(...args:A))=>{eventBus.on(event,fn);}}}consteventName="notify"asSomeEventType;deal<[number]>(eventName);// should be equivalent with `fun<[number], typeof eventName>(eventName );`// should be equivalent with `fun<[number], SomeEventType>(eventName );`
one more thing, Generics by default
functionname<Aextendsunknown[],BextendsSomeType>(p1,a:A,p2:AKindType,b: B){return{p1,a,p2,b}}// should be equivalent with// function name<A extends unknown[], B extends SomeType,T>(p1:T, a:A, p2:AKindType, b: B){// return {p1,a,p2,b}// }
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.)
Search Terms
infer of selective types
Suggestion
infer of selective types
Use Cases
one more thing, Generics by default
Examples
one more thing, Generics by default
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: