TypeScript/tests/cases/fourslash/codeFixInferFromUsageConstructor.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

28 lines
582 B
TypeScript

/// <reference path='fourslash.ts' />
// @strictNullChecks: true
////class TokenType {
//// label;
//// token;
//// constructor([|label, token? |]) {
//// this.label = label;
//// this.token = token || "N/A";
//// }
////}
////new TokenType("HI");
verify.codeFix({
description: "Infer parameter types from usage",
index: 2,
newFileContent:
`class TokenType {
label;
token;
constructor(label: string, token?: string | undefined ) {
this.label = label;
this.token = token || "N/A";
}
}
new TokenType("HI");`,
});