Skip to content

Commit 429ef92

Browse files
Added test for declare module in typescript (#3280)
1 parent 2ffae7a commit 429ef92

5 files changed

Lines changed: 16 additions & 3 deletions

File tree

packages/lib-common/src/scopeSupportFacets/javascript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = {
261261
"branch.loop.iteration": notApplicable,
262262

263263
// Miscellaneous
264-
"statement.misc": notApplicable,
265264
environment: notApplicable,
266265
selector: notApplicable,
267266
unit: notApplicable,
@@ -352,5 +351,6 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = {
352351
"argument.actual.enum.iteration": notApplicable,
353352

354353
// Miscellaneous
354+
"statement.misc": notApplicable,
355355
"statement.package": notApplicable,
356356
};

packages/lib-common/src/scopeSupportFacets/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = {
5454
"statement.iteration.interface": supported,
5555
"statement.typeAlias": supported,
5656
"statement.method.interface": supported,
57+
"statement.misc": supported,
5758

5859
"value.typeAlias": supported,
5960
"value.field.enum": supported,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare module "foo" {}
2+
---
3+
4+
[Content] =
5+
[Removal] =
6+
[Domain] = 0:0-0:23
7+
>-----------------------<
8+
0| declare module "foo" {}
9+
10+
[Insertion delimiter] = "\n"

resources/queries/javascript.core.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
;; This is disabled since we want the whole statement and not just the block
3737
;; (statement_block)
3838
] @statement
39-
(#not-parent-type? @statement export_statement)
39+
(#not-parent-type? @statement export_statement ambient_declaration)
4040
)
4141

4242
(

resources/queries/typescript.core.scm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
;; `javascript.jsx.scm`, and tree-sitter would complain because those node
33
;; types are not defined in the typescript grammar.
44

5+
;; https://github.com/tree-sitter/tree-sitter-typescript/blob/4ad3010c91d700026d036b5230e2d99ba94ae8a4/typescript/src/grammar.json
6+
57
;; import javascript.core.scm
68

79
;;!! class Foo { bar(); }
@@ -514,7 +516,7 @@
514516
(module)
515517
(type_alias_declaration)
516518
] @statement
517-
(#not-parent-type? @statement export_statement)
519+
(#not-parent-type? @statement export_statement ambient_declaration)
518520
)
519521

520522
;; Statements with optional trailing `;`

0 commit comments

Comments
 (0)