Skip to content

Commit b832853

Browse files
committed
fix missing export
1 parent 0005071 commit b832853

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

internal/transformers/declarations/transform.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,8 +1905,9 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp
19051905
modifierFlags := ast.ModifierFlagsAmbient
19061906
replacement := make([]*ast.Node, 0)
19071907

1908-
if ast.HasModifier(declaration, ast.ModifierFlagsExport) {
1909-
if ast.HasModifier(declaration, ast.ModifierFlagsDefault) {
1908+
flags := ast.GetCombinedModifierFlags(declaration)
1909+
if flags & ast.ModifierFlagsExport != 0 {
1910+
if flags & ast.ModifierFlagsDefault != 0 {
19101911
if n := tx.transformExpandoHost(name, declaration); n != nil {
19111912
replacement = append(replacement, n)
19121913
}

testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export declare const Point: {
4141
zero: () => Point;
4242
};
4343
export declare const Rect: <p extends Point>(a: p, b: p) => Rect<p>;
44-
declare namespace Point {
44+
export declare namespace Point {
4545
const zero: () => Point;
4646
}
4747

@@ -50,13 +50,11 @@ declare namespace Point {
5050

5151

5252
declarationEmitExpandoWithGenericConstraint.d.ts(1,18): error TS2451: Cannot redeclare block-scoped variable 'Point'.
53-
declarationEmitExpandoWithGenericConstraint.d.ts(9,22): error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
5453
declarationEmitExpandoWithGenericConstraint.d.ts(9,22): error TS2451: Cannot redeclare block-scoped variable 'Point'.
55-
declarationEmitExpandoWithGenericConstraint.d.ts(14,19): error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
56-
declarationEmitExpandoWithGenericConstraint.d.ts(14,19): error TS2451: Cannot redeclare block-scoped variable 'Point'.
54+
declarationEmitExpandoWithGenericConstraint.d.ts(14,26): error TS2451: Cannot redeclare block-scoped variable 'Point'.
5755

5856

59-
==== declarationEmitExpandoWithGenericConstraint.d.ts (5 errors) ====
57+
==== declarationEmitExpandoWithGenericConstraint.d.ts (3 errors) ====
6058
export interface Point {
6159
~~~~~
6260
!!! error TS2451: Cannot redeclare block-scoped variable 'Point'.
@@ -69,17 +67,13 @@ declarationEmitExpandoWithGenericConstraint.d.ts(14,19): error TS2451: Cannot re
6967
}
7068
export declare const Point: {
7169
~~~~~
72-
!!! error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
73-
~~~~~
7470
!!! error TS2451: Cannot redeclare block-scoped variable 'Point'.
7571
(x: number, y: number): Point;
7672
zero: () => Point;
7773
};
7874
export declare const Rect: <p extends Point>(a: p, b: p) => Rect<p>;
79-
declare namespace Point {
80-
~~~~~
81-
!!! error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
82-
~~~~~
75+
export declare namespace Point {
76+
~~~~~
8377
!!! error TS2451: Cannot redeclare block-scoped variable 'Point'.
8478
const zero: () => Point;
8579
}

testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js.diff

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
+ zero: () => Point;
99
};
1010
export declare const Rect: <p extends Point>(a: p, b: p) => Rect<p>;
11-
+declare namespace Point {
11+
+export declare namespace Point {
1212
+ const zero: () => Point;
1313
+}
1414
+
@@ -17,13 +17,11 @@
1717
+
1818
+
1919
+declarationEmitExpandoWithGenericConstraint.d.ts(1,18): error TS2451: Cannot redeclare block-scoped variable 'Point'.
20-
+declarationEmitExpandoWithGenericConstraint.d.ts(9,22): error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
2120
+declarationEmitExpandoWithGenericConstraint.d.ts(9,22): error TS2451: Cannot redeclare block-scoped variable 'Point'.
22-
+declarationEmitExpandoWithGenericConstraint.d.ts(14,19): error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
23-
+declarationEmitExpandoWithGenericConstraint.d.ts(14,19): error TS2451: Cannot redeclare block-scoped variable 'Point'.
21+
+declarationEmitExpandoWithGenericConstraint.d.ts(14,26): error TS2451: Cannot redeclare block-scoped variable 'Point'.
2422
+
2523
+
26-
+==== declarationEmitExpandoWithGenericConstraint.d.ts (5 errors) ====
24+
+==== declarationEmitExpandoWithGenericConstraint.d.ts (3 errors) ====
2725
+ export interface Point {
2826
+ ~~~~~
2927
+!!! error TS2451: Cannot redeclare block-scoped variable 'Point'.
@@ -36,17 +34,13 @@
3634
+ }
3735
+ export declare const Point: {
3836
+ ~~~~~
39-
+!!! error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
40-
+ ~~~~~
4137
+!!! error TS2451: Cannot redeclare block-scoped variable 'Point'.
4238
+ (x: number, y: number): Point;
4339
+ zero: () => Point;
4440
+ };
4541
+ export declare const Rect: <p extends Point>(a: p, b: p) => Rect<p>;
46-
+ declare namespace Point {
47-
+ ~~~~~
48-
+!!! error TS2395: Individual declarations in merged declaration 'Point' must be all exported or all local.
49-
+ ~~~~~
42+
+ export declare namespace Point {
43+
+ ~~~~~
5044
+!!! error TS2451: Cannot redeclare block-scoped variable 'Point'.
5145
+ const zero: () => Point;
5246
+ }

0 commit comments

Comments
 (0)