Skip to content

Commit d020329

Browse files
committed
Fix forEachChild to include withClause for ModuleDeclaration
The test harness validates that all child nodes are visited by forEachChild in the correct order (by position in the source code). We added withClause to ModuleDeclaration but: 1. Forgot to update the forEachChild visitor in parser.ts to include it 2. Had it in the wrong order - withClause comes BEFORE body in the syntax The syntax is: declare module "name" with { ... } { ... } So the order is: modifiers → name → withClause → body This commit adds withClause to forEachChild in the correct position.
1 parent edc1a1f commit d020329

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ const forEachChildTable: ForEachChildTable = {
923923
[SyntaxKind.ModuleDeclaration]: function forEachChildInModuleDeclaration<T>(node: ModuleDeclaration, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
924924
return visitNodes(cbNode, cbNodes, node.modifiers) ||
925925
visitNode(cbNode, node.name) ||
926+
visitNode(cbNode, node.withClause) ||
926927
visitNode(cbNode, node.body);
927928
},
928929
[SyntaxKind.ImportEqualsDeclaration]: function forEachChildInImportEqualsDeclaration<T>(node: ImportEqualsDeclaration, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {

tests/baselines/reference/ambientModuleWithImportAttributes.types

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
declare module "*.css" with { type: "css" } {
66
>"*.css" : typeof import("*.css")
77
> : ^^^^^^^^^^^^^^^^^^^^^^
8+
>type : any
9+
> : ^^^
810

911
const stylesheet: CSSStyleSheet;
1012
>stylesheet : CSSStyleSheet
@@ -18,6 +20,8 @@ declare module "*.css" with { type: "css" } {
1820
declare module "*.json" with { type: "json" } {
1921
>"*.json" : typeof import("*.json")
2022
> : ^^^^^^^^^^^^^^^^^^^^^^^
23+
>type : any
24+
> : ^^^
2125

2226
const data: any;
2327
>data : any
@@ -32,6 +36,8 @@ declare module "*.json" with { type: "json" } {
3236
declare module "my-module" with { type: "custom" } {
3337
>"my-module" : typeof import("my-module")
3438
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
39+
>type : any
40+
> : ^^^
3541

3642
export function foo(): void;
3743
>foo : () => void
@@ -46,6 +52,10 @@ declare module "my-module" with { type: "custom" } {
4652
declare module "multi-attr" with { type: "json", integrity: "sha384-..." } {
4753
>"multi-attr" : typeof import("multi-attr")
4854
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
55+
>type : any
56+
> : ^^^
57+
>integrity : any
58+
> : ^^^
4959

5060
export const value: number;
5161
>value : number

tests/baselines/reference/ambientModuleWithImportAttributesDiagnostics.types

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
declare module "*.css" with { type: "css" } {
66
>"*.css" : typeof import("*.css")
77
> : ^^^^^^^^^^^^^^^^^^^^^^
8+
>type : any
9+
> : ^^^
810

911
const stylesheet: CSSStyleSheet;
1012
>stylesheet : CSSStyleSheet
@@ -18,6 +20,8 @@ declare module "*.css" with { type: "css" } {
1820
declare module "*.json" with { type: "json" } {
1921
>"*.json" : typeof import("*.json")
2022
> : ^^^^^^^^^^^^^^^^^^^^^^^
23+
>type : any
24+
> : ^^^
2125

2226
const data: any;
2327
>data : any

tests/baselines/reference/ambientModuleWithImportAttributesSemantics.types

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
declare module "*.css" with { type: "css" } {
66
>"*.css" : typeof import("*.css")
77
> : ^^^^^^^^^^^^^^^^^^^^^^
8+
>type : any
9+
> : ^^^
810

911
const stylesheet: CSSStyleSheet;
1012
>stylesheet : CSSStyleSheet
@@ -19,6 +21,8 @@ declare module "*.css" with { type: "css" } {
1921
declare module "*.json" with { type: "json" } {
2022
>"*.json" : typeof import("*.json")
2123
> : ^^^^^^^^^^^^^^^^^^^^^^^
24+
>type : any
25+
> : ^^^
2226

2327
const data: any;
2428
>data : any
@@ -47,6 +51,10 @@ declare module "*.txt" {
4751
declare module "*.wasm" with { type: "module", version: "1" } {
4852
>"*.wasm" : typeof import("*.wasm")
4953
> : ^^^^^^^^^^^^^^^^^^^^^^^
54+
>type : any
55+
> : ^^^
56+
>version : any
57+
> : ^^^
5058

5159
const module: WebAssembly.Module;
5260
>module : WebAssembly.Module

0 commit comments

Comments
 (0)