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

Preserve resolution-mode as-written too #57867

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4183,10 +4183,10 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri

function writeDirectives(kind: "path" | "types" | "lib", directives: readonly FileReference[]) {
for (const directive of directives) {
const preserve = directive.preserve ? `preserve="true" ` : "";
const resolutionMode = directive.resolutionMode && directive.resolutionMode !== currentSourceFile?.impliedNodeFormat
const resolutionMode = directive.resolutionMode
? `resolution-mode="${directive.resolutionMode === ModuleKind.ESNext ? "import" : "require"}" `
: "";
const preserve = directive.preserve ? `preserve="true" ` : "";
writeComment(`/// <reference ${kind}="${directive.fileName}" ${resolutionMode}${preserve}/>`);
writeLine();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

//// [index.d.ts]
/// <reference types="pkg" resolution-mode="import" preserve="true" />
/// <reference types="pkg" preserve="true" />
/// <reference types="pkg" resolution-mode="require" preserve="true" />
export interface LocalInterface extends ImportInterface, RequireInterface {
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

//// [index.d.ts]
/// <reference types="pkg" resolution-mode="import" preserve="true" />
/// <reference types="pkg" preserve="true" />
/// <reference types="pkg" resolution-mode="require" preserve="true" />
export interface LocalInterface extends ImportInterface, RequireInterface {
}