address PR feedback
This commit is contained in:
parent
0e1c6e3c9a
commit
1e11a55781
|
@ -14289,8 +14289,9 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
grammarErrorOnFirstToken(node, Diagnostics.Exports_are_not_permitted_in_module_augmentations);
|
||||
grammarErrorOnFirstToken(node, Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
|
||||
break;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
if ((<ImportEqualsDeclaration>node).moduleReference.kind !== SyntaxKind.StringLiteral) {
|
||||
|
@ -14564,7 +14565,9 @@ namespace ts {
|
|||
const exportEqualsSymbol = moduleSymbol.exports["export="];
|
||||
if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
|
||||
const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
|
||||
error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
|
||||
if (!isTopLevelInExternalModuleAugmentation(declaration)) {
|
||||
error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
|
||||
}
|
||||
}
|
||||
// Checks for export * conflicts
|
||||
const exports = getExportsOfModule(moduleSymbol);
|
||||
|
|
|
@ -1783,7 +1783,7 @@
|
|||
"category": "Error",
|
||||
"code": 2663
|
||||
},
|
||||
"Exports are not permitted in module augmentations.": {
|
||||
"Exports and export assignments are not permitted in module augmentations.": {
|
||||
"category": "Error",
|
||||
"code": 2664
|
||||
},
|
||||
|
|
34
tests/baselines/reference/globalIsContextualKeyword.js
Normal file
34
tests/baselines/reference/globalIsContextualKeyword.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
//// [globalIsContextualKeyword.ts]
|
||||
function a() {
|
||||
let global = 1;
|
||||
}
|
||||
function b() {
|
||||
class global {}
|
||||
}
|
||||
|
||||
namespace global {
|
||||
}
|
||||
|
||||
function foo(global: number) {
|
||||
}
|
||||
|
||||
let obj = {
|
||||
global: "123"
|
||||
}
|
||||
|
||||
//// [globalIsContextualKeyword.js]
|
||||
function a() {
|
||||
var global = 1;
|
||||
}
|
||||
function b() {
|
||||
var global = (function () {
|
||||
function global() {
|
||||
}
|
||||
return global;
|
||||
}());
|
||||
}
|
||||
function foo(global) {
|
||||
}
|
||||
var obj = {
|
||||
global: "123"
|
||||
};
|
29
tests/baselines/reference/globalIsContextualKeyword.symbols
Normal file
29
tests/baselines/reference/globalIsContextualKeyword.symbols
Normal file
|
@ -0,0 +1,29 @@
|
|||
=== tests/cases/compiler/globalIsContextualKeyword.ts ===
|
||||
function a() {
|
||||
>a : Symbol(a, Decl(globalIsContextualKeyword.ts, 0, 0))
|
||||
|
||||
let global = 1;
|
||||
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 1, 7))
|
||||
}
|
||||
function b() {
|
||||
>b : Symbol(b, Decl(globalIsContextualKeyword.ts, 2, 1))
|
||||
|
||||
class global {}
|
||||
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 3, 14))
|
||||
}
|
||||
|
||||
namespace global {
|
||||
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 5, 1))
|
||||
}
|
||||
|
||||
function foo(global: number) {
|
||||
>foo : Symbol(foo, Decl(globalIsContextualKeyword.ts, 8, 1))
|
||||
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 10, 13))
|
||||
}
|
||||
|
||||
let obj = {
|
||||
>obj : Symbol(obj, Decl(globalIsContextualKeyword.ts, 13, 3))
|
||||
|
||||
global: "123"
|
||||
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 13, 11))
|
||||
}
|
32
tests/baselines/reference/globalIsContextualKeyword.types
Normal file
32
tests/baselines/reference/globalIsContextualKeyword.types
Normal file
|
@ -0,0 +1,32 @@
|
|||
=== tests/cases/compiler/globalIsContextualKeyword.ts ===
|
||||
function a() {
|
||||
>a : () => void
|
||||
|
||||
let global = 1;
|
||||
>global : number
|
||||
>1 : number
|
||||
}
|
||||
function b() {
|
||||
>b : () => void
|
||||
|
||||
class global {}
|
||||
>global : global
|
||||
}
|
||||
|
||||
namespace global {
|
||||
>global : any
|
||||
}
|
||||
|
||||
function foo(global: number) {
|
||||
>foo : (global: number) => void
|
||||
>global : number
|
||||
}
|
||||
|
||||
let obj = {
|
||||
>obj : { global: string; }
|
||||
>{ global: "123"} : { global: string; }
|
||||
|
||||
global: "123"
|
||||
>global : string
|
||||
>"123" : string
|
||||
}
|
|
@ -12,17 +12,18 @@ tests/cases/compiler/x.ts(18,5): error TS2665: Imports are not permitted in modu
|
|||
tests/cases/compiler/x.ts(18,26): error TS2307: Cannot find module './x0'.
|
||||
tests/cases/compiler/x.ts(19,5): error TS2665: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
|
||||
tests/cases/compiler/x.ts(19,21): error TS2307: Cannot find module './x0'.
|
||||
tests/cases/compiler/x.ts(20,5): error TS2664: Exports are not permitted in module augmentations.
|
||||
tests/cases/compiler/x.ts(20,5): error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
tests/cases/compiler/x.ts(20,19): error TS2307: Cannot find module './x0'.
|
||||
tests/cases/compiler/x.ts(21,5): error TS2664: Exports are not permitted in module augmentations.
|
||||
tests/cases/compiler/x.ts(21,5): error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
tests/cases/compiler/x.ts(21,21): error TS2307: Cannot find module './x0'.
|
||||
tests/cases/compiler/x.ts(25,5): error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
|
||||
|
||||
==== tests/cases/compiler/x0.ts (0 errors) ====
|
||||
|
||||
export let a = 1;
|
||||
|
||||
==== tests/cases/compiler/x.ts (18 errors) ====
|
||||
==== tests/cases/compiler/x.ts (19 errors) ====
|
||||
|
||||
namespace N1 {
|
||||
export let x = 1;
|
||||
|
@ -72,15 +73,21 @@ tests/cases/compiler/x.ts(21,21): error TS2307: Cannot find module './x0'.
|
|||
!!! error TS2307: Cannot find module './x0'.
|
||||
export * from "./x0";
|
||||
~~~~~~
|
||||
!!! error TS2664: Exports are not permitted in module augmentations.
|
||||
!!! error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
~~~~~~
|
||||
!!! error TS2307: Cannot find module './x0'.
|
||||
export {a} from "./x0";
|
||||
~~~~~~
|
||||
!!! error TS2664: Exports are not permitted in module augmentations.
|
||||
!!! error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
~~~~~~
|
||||
!!! error TS2307: Cannot find module './x0'.
|
||||
}
|
||||
|
||||
declare module "./test" {
|
||||
export = N1;
|
||||
~~~~~~
|
||||
!!! error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
}
|
||||
export {}
|
||||
|
||||
==== tests/cases/compiler/observable.ts (0 errors) ====
|
||||
|
@ -89,6 +96,9 @@ tests/cases/compiler/x.ts(21,21): error TS2307: Cannot find module './x0'.
|
|||
}
|
||||
export var x = 1;
|
||||
|
||||
==== tests/cases/compiler/test.ts (0 errors) ====
|
||||
export let b = 1;
|
||||
|
||||
==== tests/cases/compiler/main.ts (0 errors) ====
|
||||
import { Observable } from "./observable"
|
||||
import "./x";
|
||||
|
|
|
@ -27,6 +27,10 @@ declare module "./observable" {
|
|||
export * from "./x0";
|
||||
export {a} from "./x0";
|
||||
}
|
||||
|
||||
declare module "./test" {
|
||||
export = N1;
|
||||
}
|
||||
export {}
|
||||
|
||||
//// [observable.ts]
|
||||
|
@ -35,6 +39,9 @@ export declare class Observable<T> {
|
|||
}
|
||||
export var x = 1;
|
||||
|
||||
//// [test.ts]
|
||||
export let b = 1;
|
||||
|
||||
//// [main.ts]
|
||||
import { Observable } from "./observable"
|
||||
import "./x";
|
||||
|
@ -52,6 +59,9 @@ var N1;
|
|||
//// [observable.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
exports.b = 1;
|
||||
//// [main.js]
|
||||
"use strict";
|
||||
require("./x");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
tests/cases/compiler/f3.ts(11,5): error TS2665: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
|
||||
tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'.
|
||||
tests/cases/compiler/f3.ts(12,5): error TS2664: Exports are not permitted in module augmentations.
|
||||
tests/cases/compiler/f3.ts(12,5): error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
tests/cases/compiler/f3.ts(12,21): error TS2307: Cannot find module './f2'.
|
||||
tests/cases/compiler/f3.ts(13,12): error TS2663: Module augmentation cannot introduce new names in the top level scope.
|
||||
tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'I' is using private name 'N'.
|
||||
|
@ -37,7 +37,7 @@ tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on
|
|||
!!! error TS2307: Cannot find module './f2'.
|
||||
export {B} from "./f2";
|
||||
~~~~~~
|
||||
!!! error TS2664: Exports are not permitted in module augmentations.
|
||||
!!! error TS2664: Exports and export assignments are not permitted in module augmentations.
|
||||
~~~~~~
|
||||
!!! error TS2307: Cannot find module './f2'.
|
||||
import I = N.Ifc;
|
||||
|
|
16
tests/cases/compiler/globalIsContextualKeyword.ts
Normal file
16
tests/cases/compiler/globalIsContextualKeyword.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
function a() {
|
||||
let global = 1;
|
||||
}
|
||||
function b() {
|
||||
class global {}
|
||||
}
|
||||
|
||||
namespace global {
|
||||
}
|
||||
|
||||
function foo(global: number) {
|
||||
}
|
||||
|
||||
let obj = {
|
||||
global: "123"
|
||||
}
|
|
@ -26,6 +26,10 @@ declare module "./observable" {
|
|||
export * from "./x0";
|
||||
export {a} from "./x0";
|
||||
}
|
||||
|
||||
declare module "./test" {
|
||||
export = N1;
|
||||
}
|
||||
export {}
|
||||
|
||||
// @filename: observable.ts
|
||||
|
@ -34,6 +38,9 @@ export declare class Observable<T> {
|
|||
}
|
||||
export var x = 1;
|
||||
|
||||
// @filename: test.ts
|
||||
export let b = 1;
|
||||
|
||||
// @filename: main.ts
|
||||
import { Observable } from "./observable"
|
||||
import "./x";
|
||||
|
|
Loading…
Reference in a new issue