Skip to content

Conversation

@kpdonn
Copy link
Contributor

@kpdonn kpdonn commented Apr 24, 2018

This PR makes it so type aliases that are not exported are still able to be displayed by quickinfo for the file they are local to. Example:

import 'something'
type Alias<K> = {
  property1: K
}
var a: Alias<string>

Quickinfo for a previously displayed {property1: string} because Alias<K> was not exported, but will display Alias<string> with this PR.

Fixes #13095
Also partially but not entirely addresses #18754

@HerringtonDarkholme
Copy link
Contributor

This will greatly help library author to give a good hover experience! Thanks!

@kpdonn
Copy link
Contributor Author

kpdonn commented Apr 24, 2018

@HerringtonDarkholme Thanks, but just so you know this might not help as much as you are hoping if you are referring to giving users of your libraries a good hover experience. This PR only changes the behavior in the specific case of quick info in the same file as a type alias that isn't exported.

So users of a library still won't see the library's type aliases in quick info unless they explicitly import the aliases in each file they want it to work in.

I'm interested in that use case also though and just opened #23642 as an idea for how type aliases could appear in quick info across files without requiring them to be explicitly imported.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 24, 2018

@weswigham can you please review

}
if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope ||
isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, !!(context.flags & NodeBuilderFlags.UseLocalAliases)))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by the declaration emitter, in addition to quick info and signature help, and I don't see any checks actually accounting for the enclosing declaration context, which worries me. Additionally, given that we have a UseAliasDefinedOutsideCurrentScope flag, I'm led to believe that one would believe that this should be the default behavior! However that may have to wait for #23351 though, which may, incidentally, subsume this. Will have to test.

@typescript-bot
Copy link
Collaborator

Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it.

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants