-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Arguably improve declaration emit in two ways: #48491
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
Conversation
…t written as a union with `undefined`
@typescript-bot perf test this |
Heya @andrewbranch, I've started to run the perf test suite on this PR at 0652347. You can monitor the build here. Update: The results are in! |
undefined
undefined
@andrewbranch Here they are:Comparison Report - main..48491
System
Hosts
Scenarios
Developer Information: |
@@ -1,7 +1,7 @@ | |||
=== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts === | |||
type T = { x : number } | |||
>T : Symbol(T, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 0)) | |||
>x : Symbol(x, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 10)) | |||
>x : Symbol(T.x, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I saw 100+ baselines changed, I thought I had done something horribly wrong, but... this seems like an improvement?
undefined
@@ -138,7 +138,7 @@ function test4( | |||
>x : number | |||
|
|||
arg4: ((a?: {x: number}, b?: {x: number}) => number) | ((a?: {y: number}) => number), | |||
>arg4 : ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((a?: { y: number; } | undefined) => number) | |||
>arg4 : ((a?: { x: number;}, b?: { x: number;}) => number) | ((a?: { y: number;}) => number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little annoying but I guess it’s a general problem with reusing type annotation nodes, not specific to this change 🤔
@typescript-bot perf test this |
Heya @andrewbranch, I've started to run the perf test suite on this PR at c95d76f. You can monitor the build here. Update: The results are in! |
@andrewbranch Here they are:Comparison Report - main..48491
System
Hosts
Scenarios
Developer Information: |
I’m a little concerned that this will substitute an equivalent type alias in declaration emit kind of randomly. Perhaps this should be applied in a more limited way, like only when the alternative is an ImportType? I feel like similar conversation came up when first discussing Smarter Type Alias Preservation in 4.1. |
undefined
.lookupSymbolChain
to avoid writing an ImportType for a type annotation when you could use a reference to a local type alias instead. This also changes a bunch of symbol baselines to add qualification of members of object type literals assigned to type aliases. The same kind of change appears in a few quick info tests, which makes the display of type alias members more similar to interface members.Fixes #47849
(I think the repro contains multiple unrelated bugs, but this fixes the one I discussed in the issue. Will check the other and open a new bug if needed.)
Note: Change (2) is enough to fix #47849 alone, so we can back (1) back out if people have objections, but personally I like that some unnecessary characters are dropped from type display.