-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Don't emit duplicate triple-slash directives when using API to print a .d.ts #40968
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
@typescript-bot perf test |
Heya @rbuckton, I've started to run the perf test suite on this PR at 14714bb. You can monitor the build here. Update: The results are in! |
@rbuckton Here they are:Comparison Report - master..40968
System
Hosts
Scenarios
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@DanielRosenwasser any issues with taking this for 4.1? It shouldn't affect any existing code since this is a very specific API-usage use case that was broken. |
It sounds acceptable and low-risk enough for the RC. |
We have a special case when we emit declaration files where we emit
/// <reference ...
directives stored on theSourceFile
as a result of declaration transforms as part of the call toemitTripleSlashDirectivesIfNeeded
. This was intended for when our compiler transforms a.ts
to a.d.ts
. However, if you use thecreatePrinter
API directly to print a raw.d.ts
file, we end up emitting the directives twice. Once from the call toemitTripleSlashDirectivesIfNeeded
, and again from a later call toemitLeadingComments
.This PR changes
emitLeadingComments
to elide/// <reference ...
directives from the top of a source file if that source file is a declaration file, which avoids the duplication.Fixes #36242