* 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
29 lines
551 B
TypeScript
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")`,
|
|
});
|
|
|
|
|