Skip to content
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
5 changes: 5 additions & 0 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,11 @@ export function transformDeclarations(context: TransformationContext) {

function mapReferencesIntoArray(references: FileReference[], outputFilePath: string): (file: SourceFile) => void {
return file => {
if (exportedModulesFromDeclarationEmit?.includes(file.symbol)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not what this array was for, and the name confuses me (these aren’t exported from this file, they’re imported 🤔), but it appears to be exactly what I was going to add, so I opted not to duplicate it.

// Already have an import declaration resolving to this file
return;
}

let declFileName: string;
if (file.isDeclarationFile) { // Neither decl files or js should have their refs changed
declFileName = file.fileName;
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/declFileForExportedImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ var z = exports.b.x;
//// [declFileForExportedImport_0.d.ts]
export declare var x: number;
//// [declFileForExportedImport_1.d.ts]
/// <reference path="declFileForExportedImport_0.d.ts" />
export import a = require('./declFileForExportedImport_0');
export import b = a;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//// [tests/cases/compiler/declarationEmitRedundantTripleSlashModuleAugmentation.ts] ////

//// [index.d.ts]
declare module "foo" {
export interface Original {}
}

//// [augmentation.ts]
export interface FooOptions {}
declare module "foo" {
export interface Augmentation {}
}

//// [index.ts]
import { Original, Augmentation } from "foo";
import type { FooOptions } from "./augmentation";
export interface _ {
original: Original;
augmentation: Augmentation;
options: FooOptions;
}




//// [augmentation.d.ts]
export interface FooOptions {
}
declare module "foo" {
interface Augmentation {
}
}
//// [index.d.ts]
import { Original, Augmentation } from "foo";
import type { FooOptions } from "./augmentation";
export interface _ {
original: Original;
augmentation: Augmentation;
options: FooOptions;
}
3 changes: 0 additions & 3 deletions tests/baselines/reference/importDecl.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ export declare function foo(): d;
import m4 = require("./importDecl_require");
export declare function foo2(): m4.d;
//// [importDecl_1.d.ts]
/// <reference path="importDecl_require.d.ts" />
/// <reference path="importDecl_require1.d.ts" />
/// <reference path="importDecl_require2.d.ts" />
/// <reference path="importDecl_require3.d.ts" />
/// <reference path="importDecl_require4.d.ts" />
import m4 = require("./importDecl_require");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ export declare class B {
id: number;
}
//// [importDeclarationUsedAsTypeQuery_1.d.ts]
/// <reference path="importDeclarationUsedAsTypeQuery_require.d.ts" />
import a = require('./importDeclarationUsedAsTypeQuery_require');
export declare var x: typeof a;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @declaration: true
// @emitDeclarationOnly: true
// @noTypesAndSymbols: true
// @module: nodenext

// @Filename: /node_modules/foo/index.d.ts
declare module "foo" {
export interface Original {}
}

// @Filename: /augmentation.ts
export interface FooOptions {}
declare module "foo" {
export interface Augmentation {}
}

// @Filename: /index.ts
import { Original, Augmentation } from "foo";
import type { FooOptions } from "./augmentation";
export interface _ {
original: Original;
augmentation: Augmentation;
options: FooOptions;
}