JSDoc support for object literal fields
When inside a definition file (eg jquery.d.ts) and hovering over an interface member which has been JSDoc'd then intellisense is presented to the user in Visual Studio.
However, when in a different file which is making use of those definitions the same rich interface intellisense is not presented. Just the type and name - none of the JSDoc stuff flows through.
It would be good if it did.
Migrated from http://typescript.codeplex.com/workitem/2463
It seems this is related to getting JSDoc for contextually-typed object literals. This should likely work just as you'd expect.
Pretty sure that this issue is what I'm hitting with this type of code:
const someFunc = () => {
return {
/** This JSDoc comment doesn't leave the function */
one: "1",
/** Neither does this */
two: "2"
}
}
const a = someFunc()
a.one
// ^?
type A = ReturnType<typeof someFunc>
// ^?
Both
I realize now that the // ^? doesn't show JSDoc anyway, so the repro is useless 🍡
@johnnyreilly do you remember what this was about? I would imagine this:
interface Foo {
/**
* Hallo this is JSDoc
*/
yadda(): void
}
let x: Foo = {
yadda() {
}
}
which seems to be fixed.
@orta if I hover on that in the playground, that seems to work.
Wow - this an old issue! I do vaguely remember raising it - but not more than that. The way intellisense is powered in Visual Studio has radically changed now I understand. I should say I haven't used VS in about four years though. Apologies
:wave: Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.
Comment by @orta
:warning: Assertions:
(property) one: stringtype A = { one: string; two: string; }
Historical Information
| Version | Reproduction Outputs |
|---|---|
| 4.2.2, 4.3.2, 4.4.2, 4.5.2, 4.6.2 |
:warning: Assertions:
|
@DanielRosenwasser @johnnyreilly I've tried a couple of things in VS Code and all basic cases seem to work just fine nowadays. It's probably best to close this issue as it was most likely fixed along the way.
Just looking at old issues; given nobody knows what this is about anymore and everyone keeps trying things and they work, it's probably better to report new things when we find them, yeah.
I raised this and I have no memory of doing so. It was 2014 - there's a lot of water under the bridge since then. I support this decision 🫡