mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix crash on erroneous enum member merged with exported type alias (#36429)
This commit is contained in:
parent
368db997ed
commit
9ef9bb04f1
@ -29266,6 +29266,7 @@ namespace ts {
|
||||
: DeclarationSpaces.ExportNamespace;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
return DeclarationSpaces.ExportType | DeclarationSpaces.ExportValue;
|
||||
case SyntaxKind.SourceFile:
|
||||
return DeclarationSpaces.ExportType | DeclarationSpaces.ExportValue | DeclarationSpaces.ExportNamespace;
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
tests/cases/compiler/alias.ts(3,1): error TS2440: Import declaration conflicts with local declaration of 'EnumA'.
|
||||
tests/cases/compiler/alias.ts(3,8): error TS2395: Individual declarations in merged declaration 'EnumA' must be all exported or all local.
|
||||
tests/cases/compiler/alias.ts(5,13): error TS2395: Individual declarations in merged declaration 'EnumA' must be all exported or all local.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enum.ts (0 errors) ====
|
||||
export enum Enum {
|
||||
A,
|
||||
B
|
||||
}
|
||||
==== tests/cases/compiler/alias.ts (3 errors) ====
|
||||
import {Enum} from "./enum";
|
||||
|
||||
import EnumA = Enum.A;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2440: Import declaration conflicts with local declaration of 'EnumA'.
|
||||
~~~~~
|
||||
!!! error TS2395: Individual declarations in merged declaration 'EnumA' must be all exported or all local.
|
||||
|
||||
export type EnumA = [string] | [string, number];
|
||||
~~~~~
|
||||
!!! error TS2395: Individual declarations in merged declaration 'EnumA' must be all exported or all local.
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
//// [tests/cases/compiler/importedEnumMemberMergedWithExportedAliasIsError.ts] ////
|
||||
|
||||
//// [enum.ts]
|
||||
export enum Enum {
|
||||
A,
|
||||
B
|
||||
}
|
||||
//// [alias.ts]
|
||||
import {Enum} from "./enum";
|
||||
|
||||
import EnumA = Enum.A;
|
||||
|
||||
export type EnumA = [string] | [string, number];
|
||||
|
||||
|
||||
//// [enum.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var Enum;
|
||||
(function (Enum) {
|
||||
Enum[Enum["A"] = 0] = "A";
|
||||
Enum[Enum["B"] = 1] = "B";
|
||||
})(Enum = exports.Enum || (exports.Enum = {}));
|
||||
//// [alias.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/enum.ts ===
|
||||
export enum Enum {
|
||||
>Enum : Symbol(Enum, Decl(enum.ts, 0, 0))
|
||||
|
||||
A,
|
||||
>A : Symbol(Enum.A, Decl(enum.ts, 0, 18))
|
||||
|
||||
B
|
||||
>B : Symbol(Enum.B, Decl(enum.ts, 1, 6))
|
||||
}
|
||||
=== tests/cases/compiler/alias.ts ===
|
||||
import {Enum} from "./enum";
|
||||
>Enum : Symbol(Enum, Decl(alias.ts, 0, 8))
|
||||
|
||||
import EnumA = Enum.A;
|
||||
>EnumA : Symbol(EnumA, Decl(alias.ts, 0, 28), Decl(alias.ts, 2, 22))
|
||||
>Enum : Symbol(Enum, Decl(alias.ts, 0, 8))
|
||||
>A : Symbol(Enum.A, Decl(enum.ts, 0, 18))
|
||||
|
||||
export type EnumA = [string] | [string, number];
|
||||
>EnumA : Symbol(EnumA, Decl(alias.ts, 2, 22))
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/enum.ts ===
|
||||
export enum Enum {
|
||||
>Enum : Enum
|
||||
|
||||
A,
|
||||
>A : Enum.A
|
||||
|
||||
B
|
||||
>B : Enum.B
|
||||
}
|
||||
=== tests/cases/compiler/alias.ts ===
|
||||
import {Enum} from "./enum";
|
||||
>Enum : typeof Enum
|
||||
|
||||
import EnumA = Enum.A;
|
||||
>EnumA : Enum.A
|
||||
>Enum : Enum
|
||||
>A : Enum.A
|
||||
|
||||
export type EnumA = [string] | [string, number];
|
||||
>EnumA : import("tests/cases/compiler/alias").EnumA
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
// @filename: enum.ts
|
||||
export enum Enum {
|
||||
A,
|
||||
B
|
||||
}
|
||||
// @filename: alias.ts
|
||||
import {Enum} from "./enum";
|
||||
|
||||
import EnumA = Enum.A;
|
||||
|
||||
export type EnumA = [string] | [string, number];
|
||||
Loading…
x
Reference in New Issue
Block a user