We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default infer type from usage codefix provide too widened type, most of the time because it also infers possible types from argument usages:
Worst case example:
// @filename: foo.ts type Options = { port?: number, host?: string, https?: boolean, key?: string, } type Data = string | number | boolean | undefined | null; declare function computeThings(data?: Data | Options) declare function computeThings(data?: Data, options?: Options) export { computeThings }
// @filename: bar.ts import { computeThings } from './foo' // infer type code fix here let data let condition = true if (condition) { data = 'John' } else { data = 123 } computeThings(data)
Expected:
let data: string | number | undefined
Actual:
let data: string | number | boolean | { port?: number | undefined; host?: string | undefined; https?: boolean | undefined; key?: string | undefined } | null | undefined
I've personally seen this in function which options has 100x more properties.
Real world example:
let replaceRanges/*: vscode.Range[] | vscode.Position[] | undefined*/ /* but gives more verbose variant */ if (replaceAlgorithm === 'just-replace') { replaceRanges = rangesToReplace } else if (useNewVscodeInsertHack) { replaceRanges = editor.selections.map(selection => selection.start.translate(undefined, -snippet.sequence.length)) } await editor.insertSnippet( new vscode.SnippetString(body), replaceRanges, )
We will be provide additional codefix below current one with this fixed behavior, just like we provide additional extract to function refactorings.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Default infer type from usage codefix provide too widened type, most of the time because it also infers possible types from argument usages:
Worst case example:
Expected:
Actual:
I've personally seen this in function which options has 100x more properties.
Real world example:
We will be provide additional codefix below current one with this fixed behavior, just like we provide additional extract to function refactorings.
The text was updated successfully, but these errors were encountered: