forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
import =
in module augmentations (microsoft#57704)
- Loading branch information
1 parent
6f64642
commit 5d545aa
Showing
9 changed files
with
167 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/importAliasInModuleAugmentation.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
importAliasInModuleAugmentation.ts(12,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. | ||
importAliasInModuleAugmentation.ts(12,24): error TS2307: Cannot find module 'fs' or its corresponding type declarations. | ||
|
||
|
||
==== importAliasInModuleAugmentation.ts (2 errors) ==== | ||
export { } | ||
|
||
namespace A { | ||
export const y = 34; | ||
export interface y { s: string } | ||
} | ||
|
||
declare global { | ||
export import x = A.y; | ||
|
||
// Should still error | ||
import f = require("fs"); | ||
~~~~~~ | ||
!!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. | ||
~~~~ | ||
!!! error TS2307: Cannot find module 'fs' or its corresponding type declarations. | ||
} | ||
|
||
const m: number = x; | ||
let s: x = { s: "" }; | ||
void s.s; |
31 changes: 31 additions & 0 deletions
31
tests/baselines/reference/importAliasInModuleAugmentation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//// [tests/cases/compiler/importAliasInModuleAugmentation.ts] //// | ||
|
||
//// [importAliasInModuleAugmentation.ts] | ||
export { } | ||
|
||
namespace A { | ||
export const y = 34; | ||
export interface y { s: string } | ||
} | ||
|
||
declare global { | ||
export import x = A.y; | ||
|
||
// Should still error | ||
import f = require("fs"); | ||
} | ||
|
||
const m: number = x; | ||
let s: x = { s: "" }; | ||
void s.s; | ||
|
||
//// [importAliasInModuleAugmentation.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var A; | ||
(function (A) { | ||
A.y = 34; | ||
})(A || (A = {})); | ||
var m = x; | ||
var s = { s: "" }; | ||
void s.s; |
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/importAliasInModuleAugmentation.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//// [tests/cases/compiler/importAliasInModuleAugmentation.ts] //// | ||
|
||
=== importAliasInModuleAugmentation.ts === | ||
export { } | ||
|
||
namespace A { | ||
>A : Symbol(A, Decl(importAliasInModuleAugmentation.ts, 0, 10)) | ||
|
||
export const y = 34; | ||
>y : Symbol(y, Decl(importAliasInModuleAugmentation.ts, 3, 16), Decl(importAliasInModuleAugmentation.ts, 3, 24)) | ||
|
||
export interface y { s: string } | ||
>y : Symbol(y, Decl(importAliasInModuleAugmentation.ts, 3, 16), Decl(importAliasInModuleAugmentation.ts, 3, 24)) | ||
>s : Symbol(y.s, Decl(importAliasInModuleAugmentation.ts, 4, 24)) | ||
} | ||
|
||
declare global { | ||
>global : Symbol(global, Decl(importAliasInModuleAugmentation.ts, 5, 1)) | ||
|
||
export import x = A.y; | ||
>x : Symbol(x, Decl(importAliasInModuleAugmentation.ts, 7, 16)) | ||
>A : Symbol(A, Decl(importAliasInModuleAugmentation.ts, 0, 10)) | ||
>y : Symbol(x, Decl(importAliasInModuleAugmentation.ts, 3, 16), Decl(importAliasInModuleAugmentation.ts, 3, 24)) | ||
|
||
// Should still error | ||
import f = require("fs"); | ||
>f : Symbol(f, Decl(importAliasInModuleAugmentation.ts, 8, 26)) | ||
} | ||
|
||
const m: number = x; | ||
>m : Symbol(m, Decl(importAliasInModuleAugmentation.ts, 14, 5)) | ||
>x : Symbol(x, Decl(importAliasInModuleAugmentation.ts, 7, 16)) | ||
|
||
let s: x = { s: "" }; | ||
>s : Symbol(s, Decl(importAliasInModuleAugmentation.ts, 15, 3)) | ||
>x : Symbol(x, Decl(importAliasInModuleAugmentation.ts, 7, 16)) | ||
>s : Symbol(s, Decl(importAliasInModuleAugmentation.ts, 15, 12)) | ||
|
||
void s.s; | ||
>s.s : Symbol(x.s, Decl(importAliasInModuleAugmentation.ts, 4, 24)) | ||
>s : Symbol(s, Decl(importAliasInModuleAugmentation.ts, 15, 3)) | ||
>s : Symbol(x.s, Decl(importAliasInModuleAugmentation.ts, 4, 24)) | ||
|
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/importAliasInModuleAugmentation.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//// [tests/cases/compiler/importAliasInModuleAugmentation.ts] //// | ||
|
||
=== importAliasInModuleAugmentation.ts === | ||
export { } | ||
|
||
namespace A { | ||
>A : typeof A | ||
|
||
export const y = 34; | ||
>y : 34 | ||
>34 : 34 | ||
|
||
export interface y { s: string } | ||
>s : string | ||
} | ||
|
||
declare global { | ||
>global : typeof global | ||
|
||
export import x = A.y; | ||
>x : 34 | ||
>A : typeof A | ||
>y : x | ||
|
||
// Should still error | ||
import f = require("fs"); | ||
>f : any | ||
} | ||
|
||
const m: number = x; | ||
>m : number | ||
>x : 34 | ||
|
||
let s: x = { s: "" }; | ||
>s : x | ||
>{ s: "" } : { s: string; } | ||
>s : string | ||
>"" : "" | ||
|
||
void s.s; | ||
>void s.s : undefined | ||
>s.s : string | ||
>s : x | ||
>s : string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
tests/baselines/reference/newNamesInGlobalAugmentations1.errors.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export { } | ||
|
||
namespace A { | ||
export const y = 34; | ||
export interface y { s: string } | ||
} | ||
|
||
declare global { | ||
export import x = A.y; | ||
|
||
// Should still error | ||
import f = require("fs"); | ||
} | ||
|
||
const m: number = x; | ||
let s: x = { s: "" }; | ||
void s.s; |