mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-20 18:09:32 -05:00
fix(51374): ts(80004): Quick fix... > Annotate with type from JSDoc :: object types (#51378)
* fix(51374): transform JSDocTypeLiteral * add additional tests * add additional tests
This commit is contained in:
31
tests/cases/fourslash/annotateWithTypeFromJSDoc24.ts
Normal file
31
tests/cases/fourslash/annotateWithTypeFromJSDoc24.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
// @strict: true
|
||||
|
||||
////class C {
|
||||
//// /**
|
||||
//// * @private
|
||||
//// * @param {number} foo
|
||||
//// * @param {Object} [bar]
|
||||
//// * @param {String} bar.a
|
||||
//// * @param {Number} [bar.b]
|
||||
//// * @param bar.c
|
||||
//// */
|
||||
//// m(foo, bar) { }
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message,
|
||||
index: 2,
|
||||
newFileContent:
|
||||
`class C {
|
||||
/**
|
||||
* @private
|
||||
* @param {number} foo
|
||||
* @param {Object} [bar]
|
||||
* @param {String} bar.a
|
||||
* @param {Number} [bar.b]
|
||||
* @param bar.c
|
||||
*/
|
||||
m(foo: number, bar: { a: string; b?: number; c: any; }) { }
|
||||
}`,
|
||||
});
|
||||
31
tests/cases/fourslash/annotateWithTypeFromJSDoc25.ts
Normal file
31
tests/cases/fourslash/annotateWithTypeFromJSDoc25.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
// @strict: true
|
||||
|
||||
////class C {
|
||||
//// /**
|
||||
//// * @private
|
||||
//// * @param {number} foo
|
||||
//// * @param {Object} [bar]
|
||||
//// * @param {String} bar.a
|
||||
//// * @param {Object} [baz]
|
||||
//// * @param {number} baz.c
|
||||
//// */
|
||||
//// m(foo, bar, baz) { }
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message,
|
||||
index: 3,
|
||||
newFileContent:
|
||||
`class C {
|
||||
/**
|
||||
* @private
|
||||
* @param {number} foo
|
||||
* @param {Object} [bar]
|
||||
* @param {String} bar.a
|
||||
* @param {Object} [baz]
|
||||
* @param {number} baz.c
|
||||
*/
|
||||
m(foo: number, bar: { a: string; }, baz: { c: number; }) { }
|
||||
}`,
|
||||
});
|
||||
27
tests/cases/fourslash/annotateWithTypeFromJSDoc26.ts
Normal file
27
tests/cases/fourslash/annotateWithTypeFromJSDoc26.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
// @strict: true
|
||||
|
||||
////class C {
|
||||
//// /**
|
||||
//// * @private
|
||||
//// * @param {Object} [foo]
|
||||
//// * @param {Object} foo.a
|
||||
//// * @param {String} [foo.a.b]
|
||||
//// */
|
||||
//// m(foo) { }
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message,
|
||||
index: 1,
|
||||
newFileContent:
|
||||
`class C {
|
||||
/**
|
||||
* @private
|
||||
* @param {Object} [foo]
|
||||
* @param {Object} foo.a
|
||||
* @param {String} [foo.a.b]
|
||||
*/
|
||||
m(foo: { a: { b?: string; }; }) { }
|
||||
}`,
|
||||
});
|
||||
Reference in New Issue
Block a user