TypeScript
TypeScript copied to clipboard
fix(51374): ts(80004): Quick fix... > Annotate with type from JSDoc :: object types
Fixes #51374
What is the behavior for something like this?
////class C {
//// /**
//// * @private
//// * @param {number} foo
//// * @param {Object} [bar]
//// * @param {String} bar.a
//// * @param {Object} [baz]
//// * @param {number} baz.c
//// */
//// m(foo, bar, baz) { }
////}
@DanielRosenwasser The result looks like this
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; }) { }
}
For future reference, I also checked that this works for nested JSDoc param tags, like so:
class E {
/**
* @private
* @param {Object} [bar]
* @param {Object} bar.a
* @param {String} [bar.a.b]
*/
m(bar) { }
}
But not sure if it warrants adding such a test, seems unlikely we'd regress on that.
@gabritto Thanks for the feedback and +1 use case. I've added a test to cover it.