mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
fix(47417): allow undefined type to be added to JSDoc types (#47449)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @strict: true
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
|
||||
////class Foo {
|
||||
//// /** @type {string} */
|
||||
//// a;
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: `Add 'undefined' type to property 'a'`,
|
||||
newFileContent:
|
||||
`class Foo {
|
||||
/** @type {string | undefined} */
|
||||
a;
|
||||
}`,
|
||||
index: 2
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @strict: true
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
////class Foo {
|
||||
//// /**
|
||||
//// * comment
|
||||
//// * @type {string}
|
||||
//// */
|
||||
//// a;
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: `Add 'undefined' type to property 'a'`,
|
||||
newFileContent:
|
||||
`class Foo {
|
||||
/**
|
||||
* comment
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
a;
|
||||
}`,
|
||||
index: 2
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @strict: true
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
////class Foo {
|
||||
//// /**
|
||||
//// * @type {string}
|
||||
//// */
|
||||
//// a;
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: `Add 'undefined' type to property 'a'`,
|
||||
newFileContent:
|
||||
`class Foo {
|
||||
/**
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
a;
|
||||
}`,
|
||||
index: 2
|
||||
})
|
||||
@@ -0,0 +1,46 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @strict: true
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
////class A {
|
||||
//// /**
|
||||
//// * comment
|
||||
//// * @type {string}
|
||||
//// */
|
||||
//// a;
|
||||
////}
|
||||
////class B {
|
||||
//// /** @type {string} */
|
||||
//// a;
|
||||
////}
|
||||
////class C {
|
||||
//// /**
|
||||
//// * @type {string}
|
||||
//// */
|
||||
//// a;
|
||||
////}
|
||||
|
||||
verify.codeFixAll({
|
||||
fixId: 'addMissingPropertyUndefinedType',
|
||||
fixAllDescription: "Add undefined type to all uninitialized properties",
|
||||
newFileContent:
|
||||
`class A {
|
||||
/**
|
||||
* comment
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
a;
|
||||
}
|
||||
class B {
|
||||
/** @type {string | undefined} */
|
||||
a;
|
||||
}
|
||||
class C {
|
||||
/**
|
||||
* @type {string | undefined}
|
||||
*/
|
||||
a;
|
||||
}`
|
||||
});
|
||||
Reference in New Issue
Block a user