forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid the double-symbol trick for enums
Nameless jsdoc typedefs have their exportedness controlled by the exportedness of the location they pull their name from. Fixes microsoft#33575.
- Loading branch information
1 parent
bae111f
commit 22cb2e6
Showing
6 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/exportedEnumTypeAndValue.symbols
This file contains 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/conformance/jsdoc/def.js === | ||
/** @enum {number} */ | ||
const MyEnum = { | ||
>MyEnum : Symbol(MyEnum, Decl(def.js, 1, 5), Decl(def.js, 0, 4)) | ||
|
||
a: 1, | ||
>a : Symbol(a, Decl(def.js, 1, 16)) | ||
|
||
b: 2 | ||
>b : Symbol(b, Decl(def.js, 2, 7)) | ||
|
||
}; | ||
export default MyEnum; | ||
>MyEnum : Symbol(MyEnum, Decl(def.js, 1, 5), Decl(def.js, 0, 4)) | ||
|
||
=== tests/cases/conformance/jsdoc/use.js === | ||
import MyEnum from "./def"; | ||
>MyEnum : Symbol(MyEnum, Decl(use.js, 0, 6)) | ||
|
||
/** @type {MyEnum} */ | ||
const v = MyEnum.b; | ||
>v : Symbol(v, Decl(use.js, 3, 5)) | ||
>MyEnum.b : Symbol(b, Decl(def.js, 2, 7)) | ||
>MyEnum : Symbol(MyEnum, Decl(use.js, 0, 6)) | ||
>b : Symbol(b, Decl(def.js, 2, 7)) | ||
|
This file contains 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,29 @@ | ||
=== tests/cases/conformance/jsdoc/def.js === | ||
/** @enum {number} */ | ||
const MyEnum = { | ||
>MyEnum : { a: number; b: number; } | ||
>{ a: 1, b: 2} : { a: number; b: number; } | ||
|
||
a: 1, | ||
>a : number | ||
>1 : 1 | ||
|
||
b: 2 | ||
>b : number | ||
>2 : 2 | ||
|
||
}; | ||
export default MyEnum; | ||
>MyEnum : number | ||
|
||
=== tests/cases/conformance/jsdoc/use.js === | ||
import MyEnum from "./def"; | ||
>MyEnum : { a: number; b: number; } | ||
|
||
/** @type {MyEnum} */ | ||
const v = MyEnum.b; | ||
>v : number | ||
>MyEnum.b : number | ||
>MyEnum : { a: number; b: number; } | ||
>b : number | ||
|
This file contains 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
This file contains 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,17 @@ | ||
// @noEmit: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
|
||
// @Filename: def.js | ||
/** @enum {number} */ | ||
const MyEnum = { | ||
a: 1, | ||
b: 2 | ||
}; | ||
export default MyEnum; | ||
|
||
// @Filename: use.js | ||
import MyEnum from "./def"; | ||
|
||
/** @type {MyEnum} */ | ||
const v = MyEnum.b; |
This file contains 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