fix(47417): allow undefined type to be added to JSDoc types (#47449)

This commit is contained in:
Oleksandr T
2022-01-16 23:44:07 +02:00
committed by GitHub
parent c71ff4dcdf
commit febfd442cd
6 changed files with 173 additions and 34 deletions

View File

@@ -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
})

View File

@@ -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
})

View File

@@ -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
})

View File

@@ -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;
}`
});