TypeScript/tests/cases/fourslash/codeFixInferFromUsageConstructorFunctionJS.ts
Nathan Shively-Sanders ea8ccc2ce4
In JS, constructor functions infer from call+construct (#28353)
* constructor functions infer from call+construct

Also fix an incorrect combining of inferences for rest parameters: the
inferred types will be arrays in the body of the function and the
arguments from outside the function will be the element type.

* All functions infer from call+construct contexts
2018-11-16 09:51:07 -08:00

29 lines
551 B
TypeScript

/// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: test.js
////function TokenType([|label, token |]) {
//// this.label = label;
//// this.token = token || "N/A";
////};
////new TokenType("HI")
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`/**
* @param {string} label
* @param {string} [token]
*/
function TokenType(label, token ) {
this.label = label;
this.token = token || "N/A";
};
new TokenType("HI")`,
});