TypeScript/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts
Nathan Shively-Sanders 052a3d9d73 Infer void from expr statement usage, not calls
This makes inferences a lot better.
2019-09-05 16:16:35 -07:00

39 lines
692 B
TypeScript

/// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: important.js
////function foo([|a, m, x|]) {
//// a.b.c;
////
//// var numeric = 0;
//// numeric = m.n();
////
//// x.y.z
//// x.y.z.push(0);
//// return x.y.z
////}
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`/**
* @param {{ b: { c: void; }; }} a
* @param {{ n: () => number; }} m
* @param {{ y: { z: number[]; }; }} x
*/
function foo(a, m, x) {
a.b.c;
var numeric = 0;
numeric = m.n();
x.y.z
x.y.z.push(0);
return x.y.z
}`,
});