TypeScript/tests/cases/fourslash/codeFixInferFromUsage_all.ts
Andy 424dba1d69
codeFixInferFromUsage: Avoid duplicate fix for variable declaration (#24169)
* codeFixInferFromUsage: Avoid duplicate fix for variable declaration

* Include VariableDeclaration initializer as a candidate type
2018-05-16 12:28:27 -07:00

38 lines
580 B
TypeScript

/// <reference path='fourslash.ts' />
// @noImplicitAny: true
// @strictNullChecks: true
////function f(x, y) {
//// x += 0;
//// y += "";
////}
////
////function g(z) {
//// return z * 2;
////}
////
////let x = null;
////function h() {
//// if (!x) x = 2;
////}
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent:
`function f(x: number, y: string) {
x += 0;
y += "";
}
function g(z: number) {
return z * 2;
}
let x: number | null = null;
function h() {
if (!x) x = 2;
}`,
});