-
Notifications
You must be signed in to change notification settings - Fork 13.3k
autocompletion failing in 3.7.1-rc #34825
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: 3.7.1-rc
Search Terms:
Code
export type GeMethodsForType<T, G extends string> = { [K in keyof T]:
T[K] extends () => any ? { name: K, group: G, } : T[K] extends (s: infer U) => any ? { name: K, group: G, payload: U } : never }[keyof T];
class Sample {
count = 0;
books: { name: string, year: number }[] = []
increment() {
this.count++
this.count++
}
addBook(book: Sample["books"][0]) {
this.books.push(book)
}
}
export declare function testIt<T, G extends string>(): (input: any, method: GeMethodsForType<T, G>) => any
const t = testIt<Sample, "Sample">()
const i = 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
Looks like its getting confused when some properties doesn't contain payload property in this case increment method , if i change GeMethodsForType to
export type GeMethodsForType<T, G extends string> = { [K in keyof T]:
T[K] extends () => any ? { name: K, group: G, payload?:undefined} : T[K] extends (s: infer U) => any ? { name: K, group: G, payload: U } : never }[keyof T]; // payload added empty arg methodsnow autocompletion working fine in 3.7.1-rc :s
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue