TypeScript Version: 3.7.1-rc
Search Terms:
Code
exporttypeGeMethodsForType<T,Gextendsstring>={[KinkeyofT]:
T[K]extends()=>any ? {name: K,group: G,} : T[K]extends(s: infer U)=>any ? {name: K,group: G,payload: U} : never}[keyofT];classSample{count=0;books: {name: string,year: number}[]=[]increment(){this.count++this.count++}addBook(book: Sample["books"][0]){this.books.push(book)}}exportdeclarefunctiontestIt<T,Gextendsstring>(): (input: any,method: GeMethodsForType<T,G>)=>anyconstt=testIt<Sample,"Sample">()consti=t(null,{name: "addBook",group: "Sample",payload: {}})// auto completion for payloadExpected behavior:
Propeties of payload should come in autocompletion
Actual behavior:
No autocompletion
Playground Link:play ground nightly
Working fine in 3.7 beta and 3.6.x
play ground 3.7 beta
Looks like its getting confused when some properties doesn't contain payload property in this case increment method , if i change GeMethodsForType to
exporttypeGeMethodsForType<T,Gextendsstring>={[KinkeyofT]:
T[K]extends()=>any ? {name: K,group: G,payload?:undefined} : T[K]extends(s: infer U)=>any ? {name: K,group: G,payload: U} : never}[keyofT];// payload added empty arg methodsnow autocompletion working fine in 3.7.1-rc :s
TypeScript Version: 3.7.1-rc
Search Terms:
Code
Expected behavior:
Propeties of payload should come in autocompletion
Actual behavior:
No autocompletion
Playground Link:play ground nightly
Working fine in 3.7 beta and 3.6.x
play ground 3.7 beta
Looks like its getting confused when some properties doesn't contain
payloadproperty in this caseincrementmethod , if i change GeMethodsForType tonow autocompletion working fine in 3.7.1-rc :s