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:
Oleksandr T
2022-11-07 21:35:08 +02:00
committed by GitHub
parent eac566b8c3
commit fa4b49d541
6 changed files with 110 additions and 8 deletions

View 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; }) { }
}`,
});

View 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; }) { }
}`,
});

View 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; }; }) { }
}`,
});