Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29257,6 +29257,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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it annoying how this message always comes up even when the two declarations don’t merge (without errors)... just feels like misleading noise. Not related to this PR, though, it happens in a lot of nonsense places (#36237)


export type EnumA = [string] | [string, number];
~~~~~
!!! error TS2395: Individual declarations in merged declaration 'EnumA' must be all exported or all local.

Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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))

Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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];