-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use local symbol rather then target symbol for tracking reused refere…
…nces (#59493)
- Loading branch information
1 parent
5270c59
commit 51093ed
Showing
15 changed files
with
324 additions
and
26 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
88 changes: 88 additions & 0 deletions
88
tests/baselines/reference/declarationEmitEnumReferenceViaImportEquals.js
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,88 @@ | ||
//// [tests/cases/compiler/declarationEmitEnumReferenceViaImportEquals.ts] //// | ||
|
||
//// [translation.ts] | ||
export interface Translation { | ||
translationKey: Translation.TranslationKeyEnum; | ||
} | ||
|
||
export namespace Translation { | ||
export type TranslationKeyEnum = 'translation1' | 'translation2'; | ||
export const TranslationKeyEnum = { | ||
Translation1: 'translation1' as TranslationKeyEnum, | ||
Translation2: 'translation2' as TranslationKeyEnum, | ||
} | ||
} | ||
|
||
|
||
//// [test.ts] | ||
import { Translation } from "./translation"; | ||
import TranslationKeyEnum = Translation.TranslationKeyEnum; | ||
|
||
export class Test { | ||
TranslationKeyEnum = TranslationKeyEnum; | ||
print() { | ||
console.log(TranslationKeyEnum.Translation1); | ||
} | ||
} | ||
|
||
//// [index.ts] | ||
import { Test } from "./test"; | ||
new Test().print(); | ||
|
||
//// [translation.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Translation = void 0; | ||
var Translation; | ||
(function (Translation) { | ||
Translation.TranslationKeyEnum = { | ||
Translation1: 'translation1', | ||
Translation2: 'translation2', | ||
}; | ||
})(Translation || (exports.Translation = Translation = {})); | ||
//// [test.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Test = void 0; | ||
var translation_1 = require("./translation"); | ||
var TranslationKeyEnum = translation_1.Translation.TranslationKeyEnum; | ||
var Test = /** @class */ (function () { | ||
function Test() { | ||
this.TranslationKeyEnum = TranslationKeyEnum; | ||
} | ||
Test.prototype.print = function () { | ||
console.log(TranslationKeyEnum.Translation1); | ||
}; | ||
return Test; | ||
}()); | ||
exports.Test = Test; | ||
//// [index.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var test_1 = require("./test"); | ||
new test_1.Test().print(); | ||
|
||
|
||
//// [translation.d.ts] | ||
export interface Translation { | ||
translationKey: Translation.TranslationKeyEnum; | ||
} | ||
export declare namespace Translation { | ||
type TranslationKeyEnum = 'translation1' | 'translation2'; | ||
const TranslationKeyEnum: { | ||
Translation1: TranslationKeyEnum; | ||
Translation2: TranslationKeyEnum; | ||
}; | ||
} | ||
//// [test.d.ts] | ||
import { Translation } from "./translation"; | ||
import TranslationKeyEnum = Translation.TranslationKeyEnum; | ||
export declare class Test { | ||
TranslationKeyEnum: { | ||
Translation1: TranslationKeyEnum; | ||
Translation2: TranslationKeyEnum; | ||
}; | ||
print(): void; | ||
} | ||
//// [index.d.ts] | ||
export {}; |
70 changes: 70 additions & 0 deletions
70
tests/baselines/reference/declarationEmitEnumReferenceViaImportEquals.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,70 @@ | ||
//// [tests/cases/compiler/declarationEmitEnumReferenceViaImportEquals.ts] //// | ||
|
||
=== translation.ts === | ||
export interface Translation { | ||
>Translation : Symbol(Translation, Decl(translation.ts, 0, 0), Decl(translation.ts, 2, 1)) | ||
|
||
translationKey: Translation.TranslationKeyEnum; | ||
>translationKey : Symbol(Translation.translationKey, Decl(translation.ts, 0, 30)) | ||
>Translation : Symbol(Translation, Decl(translation.ts, 0, 0), Decl(translation.ts, 2, 1)) | ||
>TranslationKeyEnum : Symbol(Translation.TranslationKeyEnum, Decl(translation.ts, 4, 30), Decl(translation.ts, 6, 14)) | ||
} | ||
|
||
export namespace Translation { | ||
>Translation : Symbol(Translation, Decl(translation.ts, 0, 0), Decl(translation.ts, 2, 1)) | ||
|
||
export type TranslationKeyEnum = 'translation1' | 'translation2'; | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(translation.ts, 4, 30), Decl(translation.ts, 6, 14)) | ||
|
||
export const TranslationKeyEnum = { | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(translation.ts, 4, 30), Decl(translation.ts, 6, 14)) | ||
|
||
Translation1: 'translation1' as TranslationKeyEnum, | ||
>Translation1 : Symbol(Translation1, Decl(translation.ts, 6, 37)) | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(translation.ts, 4, 30), Decl(translation.ts, 6, 14)) | ||
|
||
Translation2: 'translation2' as TranslationKeyEnum, | ||
>Translation2 : Symbol(Translation2, Decl(translation.ts, 7, 55)) | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(translation.ts, 4, 30), Decl(translation.ts, 6, 14)) | ||
} | ||
} | ||
|
||
|
||
=== test.ts === | ||
import { Translation } from "./translation"; | ||
>Translation : Symbol(Translation, Decl(test.ts, 0, 8)) | ||
|
||
import TranslationKeyEnum = Translation.TranslationKeyEnum; | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(test.ts, 0, 44)) | ||
>Translation : Symbol(Translation, Decl(test.ts, 0, 8)) | ||
>TranslationKeyEnum : Symbol(Translation.TranslationKeyEnum, Decl(translation.ts, 4, 30), Decl(translation.ts, 6, 14)) | ||
|
||
export class Test { | ||
>Test : Symbol(Test, Decl(test.ts, 1, 59)) | ||
|
||
TranslationKeyEnum = TranslationKeyEnum; | ||
>TranslationKeyEnum : Symbol(Test.TranslationKeyEnum, Decl(test.ts, 3, 19)) | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(test.ts, 0, 44)) | ||
|
||
print() { | ||
>print : Symbol(Test.print, Decl(test.ts, 4, 42)) | ||
|
||
console.log(TranslationKeyEnum.Translation1); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>TranslationKeyEnum.Translation1 : Symbol(Translation1, Decl(translation.ts, 6, 37)) | ||
>TranslationKeyEnum : Symbol(TranslationKeyEnum, Decl(test.ts, 0, 44)) | ||
>Translation1 : Symbol(Translation1, Decl(translation.ts, 6, 37)) | ||
} | ||
} | ||
|
||
=== index.ts === | ||
import { Test } from "./test"; | ||
>Test : Symbol(Test, Decl(index.ts, 0, 8)) | ||
|
||
new Test().print(); | ||
>new Test().print : Symbol(Test.print, Decl(test.ts, 4, 42)) | ||
>Test : Symbol(Test, Decl(index.ts, 0, 8)) | ||
>print : Symbol(Test.print, Decl(test.ts, 4, 42)) | ||
|
106 changes: 106 additions & 0 deletions
106
tests/baselines/reference/declarationEmitEnumReferenceViaImportEquals.types
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,106 @@ | ||
//// [tests/cases/compiler/declarationEmitEnumReferenceViaImportEquals.ts] //// | ||
|
||
=== translation.ts === | ||
export interface Translation { | ||
translationKey: Translation.TranslationKeyEnum; | ||
>translationKey : Translation.TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>Translation : any | ||
> : ^^^ | ||
} | ||
|
||
export namespace Translation { | ||
>Translation : typeof Translation | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
export type TranslationKeyEnum = 'translation1' | 'translation2'; | ||
>TranslationKeyEnum : TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
export const TranslationKeyEnum = { | ||
>TranslationKeyEnum : { Translation1: TranslationKeyEnum; Translation2: TranslationKeyEnum; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^ | ||
>{ Translation1: 'translation1' as TranslationKeyEnum, Translation2: 'translation2' as TranslationKeyEnum, } : { Translation1: TranslationKeyEnum; Translation2: TranslationKeyEnum; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^ | ||
|
||
Translation1: 'translation1' as TranslationKeyEnum, | ||
>Translation1 : TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>'translation1' as TranslationKeyEnum : TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>'translation1' : "translation1" | ||
> : ^^^^^^^^^^^^^^ | ||
|
||
Translation2: 'translation2' as TranslationKeyEnum, | ||
>Translation2 : TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>'translation2' as TranslationKeyEnum : TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>'translation2' : "translation2" | ||
> : ^^^^^^^^^^^^^^ | ||
} | ||
} | ||
|
||
|
||
=== test.ts === | ||
import { Translation } from "./translation"; | ||
>Translation : typeof Translation | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
import TranslationKeyEnum = Translation.TranslationKeyEnum; | ||
>TranslationKeyEnum : { Translation1: TranslationKeyEnum; Translation2: TranslationKeyEnum; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^ | ||
>Translation : Translation | ||
> : ^^^^^^^^^^^ | ||
>TranslationKeyEnum : Translation.TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
export class Test { | ||
>Test : Test | ||
> : ^^^^ | ||
|
||
TranslationKeyEnum = TranslationKeyEnum; | ||
>TranslationKeyEnum : { Translation1: TranslationKeyEnum; Translation2: TranslationKeyEnum; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^ | ||
>TranslationKeyEnum : { Translation1: TranslationKeyEnum; Translation2: TranslationKeyEnum; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^ | ||
|
||
print() { | ||
>print : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
console.log(TranslationKeyEnum.Translation1); | ||
>console.log(TranslationKeyEnum.Translation1) : void | ||
> : ^^^^ | ||
>console.log : (...data: any[]) => void | ||
> : ^^^^ ^^ ^^^^^ | ||
>console : Console | ||
> : ^^^^^^^ | ||
>log : (...data: any[]) => void | ||
> : ^^^^ ^^ ^^^^^ | ||
>TranslationKeyEnum.Translation1 : Translation.TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>TranslationKeyEnum : { Translation1: TranslationKeyEnum; Translation2: TranslationKeyEnum; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^ | ||
>Translation1 : Translation.TranslationKeyEnum | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
} | ||
} | ||
|
||
=== index.ts === | ||
import { Test } from "./test"; | ||
>Test : typeof Test | ||
> : ^^^^^^^^^^^ | ||
|
||
new Test().print(); | ||
>new Test().print() : void | ||
> : ^^^^ | ||
>new Test().print : () => void | ||
> : ^^^^^^^^^^ | ||
>new Test() : Test | ||
> : ^^^^ | ||
>Test : typeof Test | ||
> : ^^^^^^^^^^^ | ||
>print : () => void | ||
> : ^^^^^^^^^^ | ||
|
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
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
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
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
Oops, something went wrong.