Skip to content

Commit ad033f6

Browse files
committed
fix expando prop type and keyword generated alias names
1 parent d567d73 commit ad033f6

File tree

43 files changed

+612
-606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+612
-606
lines changed

internal/transformers/declarations/transform.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,6 @@ func (tx *DeclarationTransformer) visitExpressionStatement(node *ast.ExpressionS
18361836

18371837
func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExpression) *ast.Node {
18381838
left := node.Left
1839-
right := node.Right
18401839

18411840
if ast.IsElementAccessExpression(left) {
18421841
return nil
@@ -1874,13 +1873,13 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp
18741873

18751874
saveDiag := tx.state.getSymbolAccessibilityDiagnostic
18761875
tx.state.getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(node.AsNode())
1877-
t := tx.resolver.CreateTypeOfExpression(tx.EmitContext(), right, synthesizedNamespace, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags|nodebuilder.InternalFlagsNoSyntacticPrinter, tx.tracker)
1876+
t := tx.resolver.CreateTypeOfExpression(tx.EmitContext(), left, synthesizedNamespace, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags|nodebuilder.InternalFlagsNoSyntacticPrinter, tx.tracker)
18781877
tx.state.getSymbolAccessibilityDiagnostic = saveDiag
18791878

18801879
nameToken := scanner.StringToToken(left.Name().Text())
18811880
isNonContextualKeywordName := ast.IsNonContextualKeyword(nameToken)
18821881

1883-
exportName := core.IfElse(isNonContextualKeywordName, tx.Factory().NewGeneratedNameForNode(left.Name()), tx.Factory().NewIdentifier(left.Name().Text()))
1882+
exportName := core.IfElse(isNonContextualKeywordName, tx.Factory().NewGeneratedNameForNode(left), tx.Factory().NewIdentifier(left.Name().Text()))
18841883
statements := []*ast.Statement{
18851884
tx.Factory().NewVariableStatement(
18861885
nil, /*modifiers*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ f.x = 2;
2121
declare function f(a: 0): 0;
2222
declare function f(a: 1): 1;
2323
declare namespace f {
24-
const x: 2;
24+
const x: number;
2525
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
declare function f(a: 1): 1;
66
declare namespace f {
77
- var x: number;
8-
+ const x: 2;
8+
+ const x: number;
99
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ baz.normal = false;
2626
//// [declarationEmitFunctionKeywordProp.d.ts]
2727
declare function foo(): void;
2828
declare namespace foo {
29-
const null_1: true;
30-
export { null_1 as null };
29+
const _a: boolean;
30+
export { _a as null };
3131
}
3232
declare function bar(): void;
3333
declare namespace bar {
34-
const async: true;
34+
const async: boolean;
3535
}
3636
declare namespace bar {
37-
const normal: false;
37+
const normal: boolean;
3838
}
3939
declare function baz(): void;
4040
declare namespace baz {
41-
const class_1: true;
42-
export { class_1 as class };
41+
const _b: boolean;
42+
export { _b as class };
4343
}
4444
declare namespace baz {
45-
const normal: false;
45+
const normal: boolean;
4646
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,26 @@
55
declare function foo(): void;
66
declare namespace foo {
77
- var _a: boolean;
8-
- export { _a as null };
9-
+ const null_1: true;
10-
+ export { null_1 as null };
8+
+ const _a: boolean;
9+
export { _a as null };
1110
}
1211
declare function bar(): void;
1312
declare namespace bar {
1413
- var async: boolean;
1514
- var normal: boolean;
16-
+ const async: true;
15+
+ const async: boolean;
1716
+}
1817
+declare namespace bar {
19-
+ const normal: false;
18+
+ const normal: boolean;
2019
}
2120
declare function baz(): void;
2221
declare namespace baz {
2322
- var _a: boolean;
2423
- export var normal: boolean;
2524
- export { _a as class };
26-
+ const class_1: true;
27-
+ export { class_1 as class };
25+
+ const _b: boolean;
26+
+ export { _b as class };
2827
+}
2928
+declare namespace baz {
30-
+ const normal: false;
29+
+ const normal: boolean;
3130
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ const a = foo[dashStrMem];
3737
//// [declarationEmitLateBoundAssignments.d.ts]
3838
export declare function foo(): void;
3939
export declare namespace foo {
40-
const bar: 12;
40+
const bar: number;
4141
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
export declare namespace foo {
77
- var bar: number;
88
- var strMemName: string;
9-
+ const bar: 12;
9+
+ const bar: number;
1010
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ const a = foo[dashStrMem];
2727
//// [file.d.ts]
2828
export declare function foo(): void;
2929
export declare namespace foo {
30-
const bar: 12;
30+
const bar: number;
3131
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
- let strMemName: string;
1111
+export declare function foo(): void;
1212
+export declare namespace foo {
13-
+ const bar: 12;
13+
+ const bar: number;
1414
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ if (Math.random()) {
4646
export declare function X(): void;
4747
export declare function Y(): void;
4848
export declare namespace Y {
49-
const test: "foo";
49+
const test: string;
5050
}

0 commit comments

Comments
 (0)