TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

JSDoc support for object literal fields

Open johnnyreilly opened this issue 11 years ago • 8 comments

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

johnnyreilly avatar Jul 29 '14 04:07 johnnyreilly

It seems this is related to getting JSDoc for contextually-typed object literals. This should likely work just as you'd expect.

sophiajt avatar Jul 31 '14 22:07 sophiajt

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

Workbench Repro

orta avatar Jan 04 '21 11:01 orta

I realize now that the // ^? doesn't show JSDoc anyway, so the repro is useless 🍡

orta avatar Jan 05 '21 17:01 orta

@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.

DanielRosenwasser avatar Feb 23 '21 08:02 DanielRosenwasser

@orta if I hover on that in the playground, that seems to work.

DanielRosenwasser avatar Feb 23 '21 08:02 DanielRosenwasser

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

johnnyreilly avatar Feb 23 '21 13:02 johnnyreilly

: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: string
  • type 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:

  • (property) one: string
  • type A = { one: string; two: string; }

typescript-bot avatar Apr 14 '22 00:04 typescript-bot

@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.

Andarist avatar Dec 16 '22 13:12 Andarist

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.

jakebailey avatar Jul 09 '23 18:07 jakebailey

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 🫡

johnnyreilly avatar Jul 09 '23 20:07 johnnyreilly