From 8f9f2d2138df8f09aca7084cfd4110401c2fe881 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 22 May 2026 18:24:06 +0200 Subject: [PATCH] Added test for declare module in typescript --- .../lib-common/src/scopeSupportFacets/javascript.ts | 2 +- .../lib-common/src/scopeSupportFacets/typescript.ts | 1 + .../typescript.core/statement/statement.misc.scope | 10 ++++++++++ resources/queries/javascript.core.scm | 2 +- resources/queries/typescript.core.scm | 4 +++- 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 resources/fixtures/scopes/typescript.core/statement/statement.misc.scope diff --git a/packages/lib-common/src/scopeSupportFacets/javascript.ts b/packages/lib-common/src/scopeSupportFacets/javascript.ts index af95dabf6a..2c8e6aa800 100644 --- a/packages/lib-common/src/scopeSupportFacets/javascript.ts +++ b/packages/lib-common/src/scopeSupportFacets/javascript.ts @@ -261,7 +261,6 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "branch.loop.iteration": notApplicable, // Miscellaneous - "statement.misc": notApplicable, environment: notApplicable, selector: notApplicable, unit: notApplicable, @@ -352,5 +351,6 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { "argument.actual.enum.iteration": notApplicable, // Miscellaneous + "statement.misc": notApplicable, "statement.package": notApplicable, }; diff --git a/packages/lib-common/src/scopeSupportFacets/typescript.ts b/packages/lib-common/src/scopeSupportFacets/typescript.ts index f8fc52d8d7..3d4ab8d7d4 100644 --- a/packages/lib-common/src/scopeSupportFacets/typescript.ts +++ b/packages/lib-common/src/scopeSupportFacets/typescript.ts @@ -54,6 +54,7 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.interface": supported, "statement.typeAlias": supported, "statement.method.interface": supported, + "statement.misc": supported, "value.typeAlias": supported, "value.field.enum": supported, diff --git a/resources/fixtures/scopes/typescript.core/statement/statement.misc.scope b/resources/fixtures/scopes/typescript.core/statement/statement.misc.scope new file mode 100644 index 0000000000..7c2d706185 --- /dev/null +++ b/resources/fixtures/scopes/typescript.core/statement/statement.misc.scope @@ -0,0 +1,10 @@ +declare module "foo" {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:23 + >-----------------------< +0| declare module "foo" {} + +[Insertion delimiter] = "\n" diff --git a/resources/queries/javascript.core.scm b/resources/queries/javascript.core.scm index 4447116649..6eb95cf6d7 100644 --- a/resources/queries/javascript.core.scm +++ b/resources/queries/javascript.core.scm @@ -36,7 +36,7 @@ ;; This is disabled since we want the whole statement and not just the block ;; (statement_block) ] @statement - (#not-parent-type? @statement export_statement) + (#not-parent-type? @statement export_statement ambient_declaration) ) ( diff --git a/resources/queries/typescript.core.scm b/resources/queries/typescript.core.scm index 4ac50c74fa..c762b0e4a7 100644 --- a/resources/queries/typescript.core.scm +++ b/resources/queries/typescript.core.scm @@ -2,6 +2,8 @@ ;; `javascript.jsx.scm`, and tree-sitter would complain because those node ;; types are not defined in the typescript grammar. +;; https://github.com/tree-sitter/tree-sitter-typescript/blob/4ad3010c91d700026d036b5230e2d99ba94ae8a4/typescript/src/grammar.json + ;; import javascript.core.scm ;;!! class Foo { bar(); } @@ -514,7 +516,7 @@ (module) (type_alias_declaration) ] @statement - (#not-parent-type? @statement export_statement) + (#not-parent-type? @statement export_statement ambient_declaration) ) ;; Statements with optional trailing `;`