mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
PR Feedback, add enums to exceptions
This commit is contained in:
parent
d8aa469a7d
commit
0115d68877
@ -1067,9 +1067,15 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
for (let id in lookupTable) {
|
||||
if (id !== "export=" && lookupTable[id].exportsWithDuplicate.length && !(id in symbols)) { // It's not an error if the file with multiple export *'s with duplicate names exports a member with that name itself
|
||||
// It's not an error if the file with multiple export *'s with duplicate names exports a member with that name itself
|
||||
if (id !== "export=" && lookupTable[id].exportsWithDuplicate.length && !(id in symbols)) {
|
||||
for (let node of lookupTable[id].exportsWithDuplicate) {
|
||||
diagnostics.add(createDiagnosticForNode(node, Diagnostics.An_export_Asterisk_from_0_declaration_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id));
|
||||
diagnostics.add(createDiagnosticForNode(
|
||||
node,
|
||||
Diagnostics.An_export_Asterisk_from_0_declaration_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity,
|
||||
lookupTable[id].specifierText,
|
||||
id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13722,7 +13728,7 @@ namespace ts {
|
||||
|
||||
function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) {
|
||||
let moduleSymbol = getSymbolOfNode(node);
|
||||
let links: SymbolLinks = getSymbolLinks(moduleSymbol);
|
||||
let links = getSymbolLinks(moduleSymbol);
|
||||
if (!links.exportsChecked) {
|
||||
let exportEqualsSymbol = moduleSymbol.exports["export="];
|
||||
if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
|
||||
@ -13732,9 +13738,11 @@ namespace ts {
|
||||
let exports = getExportsOfModule(moduleSymbol); // Checks for export * conflicts
|
||||
for (let id in exports) {
|
||||
if (id === "__export") continue;
|
||||
if (!(exports[id].flags & SymbolFlags.Namespace || exports[id].flags & SymbolFlags.Interface) && exports[id].declarations.length > 1) { // 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, and interfaces)
|
||||
let exportedSymbol = exports[id];
|
||||
// 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, enums, and interfaces)
|
||||
if (!(exportedSymbol.flags & SymbolFlags.Namespace || exportedSymbol.flags & SymbolFlags.Interface || exportedSymbol.flags & SymbolFlags.Enum) && exportedSymbol.declarations.length > 1) {
|
||||
let exportedDeclarations: Declaration[] = [];
|
||||
for (let declaration of exports[id].declarations) {
|
||||
for (let declaration of exportedSymbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.FunctionDeclaration) {
|
||||
if (!(declaration as FunctionDeclaration).body) {
|
||||
continue;
|
||||
|
||||
@ -16,7 +16,7 @@ tests/cases/compiler/moduleDuplicateIdentifiers.ts(24,14): error TS2300: Duplica
|
||||
_brand1: any;
|
||||
}
|
||||
|
||||
export interface Bar {
|
||||
export interface Bar { // Shouldn't error
|
||||
_brand2: any;
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ tests/cases/compiler/moduleDuplicateIdentifiers.ts(24,14): error TS2300: Duplica
|
||||
export var member1 = 2;
|
||||
}
|
||||
|
||||
export namespace FooBar {
|
||||
export namespace FooBar { // Shouldn't error
|
||||
export var member2 = 42;
|
||||
}
|
||||
|
||||
@ -34,11 +34,22 @@ tests/cases/compiler/moduleDuplicateIdentifiers.ts(24,14): error TS2300: Duplica
|
||||
member1 = 2;
|
||||
}
|
||||
|
||||
export class Kettle {
|
||||
export class Kettle { // Should error
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Kettle'.
|
||||
member2 = 42;
|
||||
}
|
||||
|
||||
export var Pot = 2;
|
||||
Pot = 42; // Shouldn't error
|
||||
Pot = 42; // Shouldn't error
|
||||
|
||||
export enum Utensils {
|
||||
Spoon,
|
||||
Fork,
|
||||
Knife
|
||||
}
|
||||
|
||||
export enum Utensils { // Shouldn't error
|
||||
Spork = 3
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ export interface Bar {
|
||||
_brand1: any;
|
||||
}
|
||||
|
||||
export interface Bar {
|
||||
export interface Bar { // Shouldn't error
|
||||
_brand2: any;
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ export namespace FooBar {
|
||||
export var member1 = 2;
|
||||
}
|
||||
|
||||
export namespace FooBar {
|
||||
export namespace FooBar { // Shouldn't error
|
||||
export var member2 = 42;
|
||||
}
|
||||
|
||||
@ -22,12 +22,23 @@ export class Kettle {
|
||||
member1 = 2;
|
||||
}
|
||||
|
||||
export class Kettle {
|
||||
export class Kettle { // Should error
|
||||
member2 = 42;
|
||||
}
|
||||
|
||||
export var Pot = 2;
|
||||
Pot = 42; // Shouldn't error
|
||||
Pot = 42; // Shouldn't error
|
||||
|
||||
export enum Utensils {
|
||||
Spoon,
|
||||
Fork,
|
||||
Knife
|
||||
}
|
||||
|
||||
export enum Utensils { // Shouldn't error
|
||||
Spork = 3
|
||||
}
|
||||
|
||||
|
||||
//// [moduleDuplicateIdentifiers.js]
|
||||
exports.Foo = 2;
|
||||
@ -56,3 +67,13 @@ var Kettle = (function () {
|
||||
exports.Kettle = Kettle;
|
||||
exports.Pot = 2;
|
||||
exports.Pot = 42; // Shouldn't error
|
||||
(function (Utensils) {
|
||||
Utensils[Utensils["Spoon"] = 0] = "Spoon";
|
||||
Utensils[Utensils["Fork"] = 1] = "Fork";
|
||||
Utensils[Utensils["Knife"] = 2] = "Knife";
|
||||
})(exports.Utensils || (exports.Utensils = {}));
|
||||
var Utensils = exports.Utensils;
|
||||
(function (Utensils) {
|
||||
Utensils[Utensils["Spork"] = 3] = "Spork";
|
||||
})(exports.Utensils || (exports.Utensils = {}));
|
||||
var Utensils = exports.Utensils;
|
||||
|
||||
@ -6,7 +6,7 @@ export interface Bar {
|
||||
_brand1: any;
|
||||
}
|
||||
|
||||
export interface Bar {
|
||||
export interface Bar { // Shouldn't error
|
||||
_brand2: any;
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ export namespace FooBar {
|
||||
export var member1 = 2;
|
||||
}
|
||||
|
||||
export namespace FooBar {
|
||||
export namespace FooBar { // Shouldn't error
|
||||
export var member2 = 42;
|
||||
}
|
||||
|
||||
@ -22,9 +22,19 @@ export class Kettle {
|
||||
member1 = 2;
|
||||
}
|
||||
|
||||
export class Kettle {
|
||||
export class Kettle { // Should error
|
||||
member2 = 42;
|
||||
}
|
||||
|
||||
export var Pot = 2;
|
||||
Pot = 42; // Shouldn't error
|
||||
Pot = 42; // Shouldn't error
|
||||
|
||||
export enum Utensils {
|
||||
Spoon,
|
||||
Fork,
|
||||
Knife
|
||||
}
|
||||
|
||||
export enum Utensils { // Shouldn't error
|
||||
Spork = 3
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user