-
Notifications
You must be signed in to change notification settings - Fork 2
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
exported terms typed to a type alias do not reference type index entry #41
Comments
I made some progress. I understand now that we can get to the type reference from a variable declaration. But I don't know where to go from here to get back to the type alias declaration node. I guess what we want is a function that given a variable declaration returns the type declaration that it references. Asking for help here https://stackoverflow.com/questions/64745962/use-typescript-compiler-api-to-get-the-type-alias-declaration-node-from-a-type-r. |
Heya @dsherret, if you happen to have time/be interested in this, your opinion/ideas would be most welcome! |
Answered here. Annoyingly, the ts compiler interns these types for performance reasons so that |
Thanks @dsherret! It seems what Tydoc should do right now then is when a type is "interned" warn the developer of the situation, briefly explaining the limitation. Detecting this would be a matter:
This is quite specific. But its a base we could expand with more cases over time. Another solution is that given the type reference name, we could manually search the AST for its source, traversing until a declaration is found. In the same case it would be a type declaration in the same lexical block. In a complex case it might be a type import etc. When to trigger this behaviour would be the same trigger as when to attempt the warning. This approach might have performance consequences. I'm not sure how complex it would be to implement. @dsherret shared some interesting links in his StackOverflow answer:
Looking at the TS issue it seems that there are a number of interned-type cases:
Note this list was from 2018, could be outdated now! |
Left a comment on the TS issue: microsoft/TypeScript#28197 (comment) |
The
foo
named export (term level) should use a type index reference.The text was updated successfully, but these errors were encountered: