TypeScript/tests/cases/fourslash/codeFixInferFromUsageMemberJS.ts
Nathan Shively-Sanders dcc27ebaf2
@link support, second try (#43312)
* Revert "Revert "Editor support for link tag (#41877)" (#43302)"

This reverts commit 451d4354b9.

* Fix parsing @link at end of comment

* Parse comments as string when no @link occurs

* fix lint
2021-03-22 16:39:35 -07:00

43 lines
1 KiB
TypeScript

/// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @strictNullChecks: true
// @Filename: important.js
////class C {
//// constructor() {
//// /** this is fine */
//// this.p = undefined;
//// this.q = undefined
//// }
//// method() {
//// this.p.push(1)
//// this.q.push(1);
//// }
////}
// Note: Should be number[] | undefined, but inference currently privileges assignments
// over usage (even when the only result is undefined) and infers only undefined.
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent:
`class C {
constructor() {
/**
* this is fine
* @type {number[] | undefined}
*/
this.p = undefined;
/**
* @type {number[] | undefined}
*/
this.q = undefined
}
method() {
this.p.push(1)
this.q.push(1);
}
}`});