Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back typedef property expansion #25784

Open
mjbvz opened this issue Jul 18, 2018 · 13 comments
Open

Bring back typedef property expansion #25784

mjbvz opened this issue Jul 18, 2018 · 13 comments
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jul 18, 2018

From @zavr-1 on July 18, 2018 20:25

In the newer version, I can only see the type of an argument which is an object, compared to how it was expanded in the previous versions.

test3

It was actually very useful to see all properties on hover which served as a documentation.

test4

I think if you hide the details of the type, you should also provide means to expand its properties via a UI, or provide a setting for it.

Copied from original issue: microsoft/vscode#54609

@mjbvz
Copy link
Contributor Author

mjbvz commented Jul 18, 2018

@zavr-1 do you see the @param properties if you scroll the hover?

@mjbvz mjbvz self-assigned this Jul 18, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jul 18, 2018

@mjbvz maybe we need a way for ppl to "expand" a type alias declaration in the quick info.. are there any experiences like that in VSCode that we can model after?

@mhegazy mhegazy added the Suggestion An idea for TypeScript label Jul 18, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jul 18, 2018

Yes, I think I misunderstood this specific issue but having a way to expand types dynamically in hover would be very helpful. We have no concept of this in VS Code currently. Visual Studio might though

@mhegazy
Copy link
Contributor

mhegazy commented Jul 19, 2018

VS does not either. i think eclipse does.

@zavr-1
Copy link

zavr-1 commented Jul 20, 2018

@mhegazy @mjbvz
I can achieve this expansion by writing

/** @type {DoneStatus} */
var ns = {
}

/**
 * @typedef {{ status: Status,  m(n: number): void }} DoneStatus
 * @typedef {{
  hello: 'world'
}} Status */

test

However, there is no way to provide a description of a property for auto-complete hints

test

Therefore, the quickest solution before providing expansion of types is to allow writing JSDoc where a type is specified both with {{ ... }} to allow for expanded properties in preview, and has @prop for description of properties in the auto-complete.

/**
 * @typedef {{ status: Status,  m(n: number): void }} DoneStatus
 * @prop {Status} status The status
 * @typedef {{
  hello: 'world'
}} Status */

(Note the additional @prop in the typedef).

@zavr-1
Copy link

zavr-1 commented Jul 20, 2018

@weswigham I don't think that your change from here which is the point of this topic will be reverted, but is it possible to at least implement the suggestion in the post above ^? thanks.

@weswigham
Copy link
Member

@zavr-1 That PR brought JSDoc into the same style of printout that we used for TS, but the core issue is that when a type is aliased within quickinfo, there's no way to inspect what's "inside the alias" right at that point, as it were. Hence @mhegazy and @mjbvz 's remarks on new UI to enable that in vscode/VS. We've talked about it in the past - it seems generally useful for inspecting large type hierarchies.

@zavr-1
Copy link

zavr-1 commented Jul 20, 2018

@weswigham OK but why is it possible to inspect what's inside using

@typedef {{ prop: TypeB }} TypeA

but not

@typedef {Object} TypeA
@prop {TybeB} prop

What I'm saying OK fine I get the point of aliases for large type hierarchies, but could you not allow me to write {{ prop: TypeB }} AND define a property under @typedef so it's visible in the preview? Because then it's best of both worlds -- I can define a type to be shown as an alias only, or I can define it as expanded one. Currently, I can do these both things, but I can't describe a property for preview if I use {{ prop: TypeB }} notation.

At the moment, it's either:

Forcing nested properties, but no description in auto-complete

/**
 * @typedef {{ prop: TypeB }} TypeA
 * @prop {TypeB} prop A test Prop
 * @typedef {string} TypeB
 */

test

test

Type alias, with description in auto-complete

/**
 * @typedef {Object} TypeA
 * @prop {TypeB} prop A test Prop
 * @typedef {string} TypeB
 */

test

test

@AoDev
Copy link

AoDev commented Oct 19, 2020

Hi, I created a similar issue that was closed for duplicate. (#41096 )
Here the last comment is from 2 years ago and there is another related task (#38040)

I'd like a quick update on where we are with this.

@rgembalik
Copy link

I'd love to see this happen as internal typedefs are usually quite important in terms of their structure. A quick set of ideas to please both people who need it and people who prefer the simplified view:

  1. Have an option in the settings to select behavior
  2. Have a link-like button in the hint popup "Expand types"/"Collapse types"
  3. Allow clicking on the type name to expand it or bring its own pop-up
  4. All of the above?

@brillout
Copy link

brillout commented Oct 6, 2023

Related feature request: #56010.

@Mng12345
Copy link

Is there any progress?

@aiday-mar
Copy link
Contributor

In relation to this, recently we have merged into VS Code a proposed API for expanding and contracting hovers (see PR here microsoft/vscode#210472), so if the TypeScript server adopts quick info expansion, we could implement this in VS Code too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

9 participants