Skip to content

Commit 61711e1

Browse files
committed
fix(61258): handle const enum references when renaming namespaces
1 parent 1cd8e20 commit 61711e1

17 files changed

+90
-1
lines changed

src/services/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ export function getMeaningFromDeclaration(node: Node): SemanticMeaning {
449449
if (isAmbientModule(node as ModuleDeclaration)) {
450450
return SemanticMeaning.Namespace | SemanticMeaning.Value;
451451
}
452-
else if (getModuleInstanceState(node as ModuleDeclaration) === ModuleInstanceState.Instantiated) {
452+
else if (getModuleInstanceState(node as ModuleDeclaration) !== ModuleInstanceState.NonInstantiated) {
453453
return SemanticMeaning.Namespace | SemanticMeaning.Value;
454454
}
455455
else {

tests/baselines/reference/constEnumMergingWithValues1.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ function foo() {}
66
> : ^^^^^^^^^^
77

88
module foo {
9+
>foo : typeof foo
10+
> : ^^^^^^^^^^
11+
912
const enum E { X }
1013
>E : E
1114
> : ^

tests/baselines/reference/constEnumMergingWithValues2.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class foo {}
66
> : ^^^
77

88
module foo {
9+
>foo : typeof foo
10+
> : ^^^^^^^^^^
11+
912
const enum E { X }
1013
>E : E
1114
> : ^

tests/baselines/reference/constEnumMergingWithValues3.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ enum foo { A }
88
> : ^^^^^
99

1010
module foo {
11+
>foo : typeof foo
12+
> : ^^^^^^^^^^
13+
1114
const enum E { X }
1215
>E : E
1316
> : ^

tests/baselines/reference/constEnumMergingWithValues4.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
=== m1.ts ===
44
module foo {
5+
>foo : typeof foo
6+
> : ^^^^^^^^^^
7+
58
const enum E { X }
69
>E : E
710
> : ^

tests/baselines/reference/constEnumMergingWithValues5.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
=== m1.ts ===
44
module foo {
5+
>foo : typeof foo
6+
> : ^^^^^^^^^^
7+
58
const enum E { X }
69
>E : E
710
> : ^

tests/baselines/reference/constEnumOnlyModuleMerging.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module Outer {
1313
}
1414

1515
module Outer {
16+
>Outer : typeof Outer
17+
> : ^^^^^^^^^^^^
18+
1619
export const enum A { X }
1720
>A : A
1821
> : ^

tests/baselines/reference/constEnums.types

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,17 @@ const enum Comments {
329329
}
330330

331331
module A {
332+
>A : typeof A
333+
> : ^^^^^^^^
334+
332335
export module B {
336+
>B : typeof B
337+
> : ^^^^^^^^
338+
333339
export module C {
340+
>C : typeof C
341+
> : ^^^^^^^^
342+
334343
export const enum E {
335344
>E : E
336345
> : ^
@@ -372,8 +381,17 @@ module A {
372381
}
373382

374383
module A {
384+
>A : typeof A
385+
> : ^^^^^^^^
386+
375387
export module B {
388+
>B : typeof B
389+
> : ^^^^^^^^
390+
376391
export module C {
392+
>C : typeof C
393+
> : ^^^^^^^^
394+
377395
export const enum E {
378396
>E : E
379397
> : ^
@@ -435,8 +453,17 @@ module A {
435453
}
436454

437455
module A1 {
456+
>A1 : typeof A1
457+
> : ^^^^^^^^^
458+
438459
export module B {
460+
>B : typeof B
461+
> : ^^^^^^^^
462+
439463
export module C {
464+
>C : typeof C
465+
> : ^^^^^^^^
466+
440467
export const enum E {
441468
>E : E
442469
> : ^
@@ -466,6 +493,9 @@ module A2 {
466493
> : ^^^^^^^^
467494

468495
export module C {
496+
>C : typeof C
497+
> : ^^^^^^^^
498+
469499
export const enum E {
470500
>E : E
471501
> : ^

tests/baselines/reference/emitClassMergedWithConstNamespaceNotElided.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
=== enum.d.ts ===
44
export namespace Clone {
5+
>Clone : typeof Clone
6+
> : ^^^^^^^^^^^^
7+
58
const enum LOCAL {
69
>LOCAL : LOCAL
710
> : ^^^^^

tests/baselines/reference/enumAssignmentCompat3.types

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ namespace Cd {
9797
}
9898
}
9999
namespace Const {
100+
>Const : typeof Const
101+
> : ^^^^^^^^^^^^
102+
100103
export const enum E {
101104
>E : E
102105
> : ^

0 commit comments

Comments
 (0)