Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
file2.ts(4,16): error TS2671: Cannot augment module './file1' because it resolves to a non-module entity.
file3.ts(3,8): error TS2503: Cannot find namespace 'x'.


==== file3.ts (1 errors) ====
import x = require("./file1");
import "./file2";
let a: x.A; // should not work
~
!!! error TS2503: Cannot find namespace 'x'.
==== file1.ts (0 errors) ====
function foo() {}
export = foo;

==== file2.ts (1 errors) ====
import x = require("./file1");

// should error since './file1' does not have namespace meaning
declare module "./file1" {
~~~~~~~~~
!!! error TS2671: Cannot augment module './file1' because it resolves to a non-module entity.
interface A { a }
}

12 changes: 10 additions & 2 deletions tsc/testdata/baselines/reference/compiler/augmentExportEquals2.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ declare module "./file1" {
interface A { a }
}

//// [file3.ts]

//// [file3.ts]
import x = require("./file1");
import "./file2";
let a: x.A; // should not work

//// [file1.js]
"use strict";
function foo() { }
module.exports = foo;
//// [file2.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//// [file3.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./file2");
let a; // should not work
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
//// [tests/cases/compiler/augmentExportEquals2.ts] ////

=== file3.ts ===

import x = require("./file1");
>x : Symbol(x, Decl(file3.ts, 0, 0))

import "./file2";
let a: x.A; // should not work
=== file3.ts ===
>a : Symbol(a, Decl(file3.ts, 2, 3))
>x : Symbol(x)
>A : Symbol(x.A)

=== file1.ts ===
function foo() {}
>foo : Symbol(foo, Decl(file1.ts, 0, 0))

export = foo;
>foo : Symbol(foo, Decl(file1.ts, 0, 0))

=== file2.ts ===
import x = require("./file1");
>x : Symbol(x, Decl(file2.ts, 0, 0))

// should error since './file1' does not have namespace meaning
declare module "./file1" {
>"./file1" : Symbol("./file1", Decl(file2.ts, 0, 30))

interface A { a }
>A : Symbol(A, Decl(file2.ts, 3, 26))
>a : Symbol(A.a, Decl(file2.ts, 4, 17))
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
//// [tests/cases/compiler/augmentExportEquals2.ts] ////

=== file3.ts ===

import x = require("./file1");
>x : () => void

import "./file2";
let a: x.A; // should not work
=== file3.ts ===
>a : x.A
>x : any

=== file1.ts ===
function foo() {}
>foo : () => void

export = foo;
>foo : () => void

=== file2.ts ===
import x = require("./file1");
>x : () => void

// should error since './file1' does not have namespace meaning
declare module "./file1" {
>"./file1" : any

interface A { a }
>a : any
}

1 change: 0 additions & 1 deletion tsc/testdata/tests/cases/compiler/augmentExportEquals2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ declare module "./file1" {
interface A { a }
}

// @filename: file3.ts
// @filename: file3.ts
import x = require("./file1");
import "./file2";
Expand Down