Repository navigation
Fix crash on erroneous enum member merged with exported type alias #36429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Wesley Wigham (weswigham)
merged 1 commit into
microsoft:master
from
weswigham:fix-enum-member-merge-crash
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/importedEnumMemberMergedWithExportedAliasIsError.errors.txt
This file contains hidden or 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,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. | ||
|
|
||
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/importedEnumMemberMergedWithExportedAliasIsError.js
This file contains hidden or 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 @@ | ||
| //// [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; |
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/importedEnumMemberMergedWithExportedAliasIsError.symbols
This file contains hidden or 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,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)) | ||
|
|
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/importedEnumMemberMergedWithExportedAliasIsError.types
This file contains hidden or 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,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 | ||
|
|
11 changes: 11 additions & 0 deletions
11
tests/cases/compiler/importedEnumMemberMergedWithExportedAliasIsError.ts
This file contains hidden or 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,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]; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)