diff --git a/snapshots/input/syntax/src/import.ts b/snapshots/input/syntax/src/import.ts index 89b74f72..5c60f68c 100644 --- a/snapshots/input/syntax/src/import.ts +++ b/snapshots/input/syntax/src/import.ts @@ -1,3 +1,4 @@ +import * as namespace from './namespace' import { Class } from './class' import { Enum } from './enum' import { newFunction } from './function' @@ -8,7 +9,8 @@ export function useEverything(): string { new Class('a').classProperty + renamedInterface().methodSignature('a') + Enum[Enum.A] + - newFunction() + newFunction() + + namespace.a.value ) } diff --git a/snapshots/input/syntax/src/namespace.d.ts b/snapshots/input/syntax/src/namespace.ts similarity index 63% rename from snapshots/input/syntax/src/namespace.d.ts rename to snapshots/input/syntax/src/namespace.ts index 1c20b655..ec76f09d 100644 --- a/snapshots/input/syntax/src/namespace.d.ts +++ b/snapshots/input/syntax/src/namespace.ts @@ -1,7 +1,8 @@ -declare namespace a { +export declare namespace a { function hello(): string interface Interface { hello: string } var i: Interface + export const value = 1 } diff --git a/snapshots/output/syntax/src/import.ts b/snapshots/output/syntax/src/import.ts index 833abcc5..5a796855 100644 --- a/snapshots/output/syntax/src/import.ts +++ b/snapshots/output/syntax/src/import.ts @@ -1,6 +1,9 @@ - import { Class } from './class' + import * as namespace from './namespace' // definition syntax 1.0.0 src/`import.ts`/ //documentation ```ts\nmodule "import.ts"\n``` +// ^^^^^^^^^ reference syntax 1.0.0 src/`namespace.ts`/ +// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`namespace.ts`/ + import { Class } from './class' // ^^^^^ reference syntax 1.0.0 src/`class.ts`/Class# // ^^^^^^^^^ reference syntax 1.0.0 src/`class.ts`/ import { Enum } from './enum' @@ -28,8 +31,12 @@ // ^^^^ reference syntax 1.0.0 src/`enum.ts`/Enum# // ^^^^ reference syntax 1.0.0 src/`enum.ts`/Enum# // ^ reference syntax 1.0.0 src/`enum.ts`/Enum#A. - newFunction() + newFunction() + // ^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/newFunction(). + namespace.a.value +// ^^^^^^^^^ reference syntax 1.0.0 src/`namespace.ts`/ +// ^ reference syntax 1.0.0 src/`namespace.ts`/a/ +// ^^^^^ reference syntax 1.0.0 src/`namespace.ts`/a/value. ) } diff --git a/snapshots/output/syntax/src/namespace.d.ts b/snapshots/output/syntax/src/namespace.d.ts deleted file mode 100644 index 7652ac14..00000000 --- a/snapshots/output/syntax/src/namespace.d.ts +++ /dev/null @@ -1,21 +0,0 @@ - declare namespace a { -// definition syntax 1.0.0 src/`namespace.d.ts`/ -//documentation ```ts\nmodule "namespace.d.ts"\n``` -// ^ definition syntax 1.0.0 src/`namespace.d.ts`/a/ -// documentation ```ts\na: typeof a\n``` - function hello(): string -// ^^^^^ definition syntax 1.0.0 src/`namespace.d.ts`/a/hello(). -// documentation ```ts\nfunction hello(): string\n``` - interface Interface { -// ^^^^^^^^^ definition syntax 1.0.0 src/`namespace.d.ts`/a/Interface# -// documentation ```ts\ninterface Interface\n``` - hello: string -// ^^^^^ definition syntax 1.0.0 src/`namespace.d.ts`/a/Interface#hello. -// documentation ```ts\n(property) hello: string\n``` - } - var i: Interface -// ^ definition syntax 1.0.0 src/`namespace.d.ts`/a/i. -// documentation ```ts\nvar i: Interface\n``` -// ^^^^^^^^^ reference syntax 1.0.0 src/`namespace.d.ts`/a/Interface# - } - diff --git a/snapshots/output/syntax/src/namespace.ts b/snapshots/output/syntax/src/namespace.ts new file mode 100644 index 00000000..43cc5e9d --- /dev/null +++ b/snapshots/output/syntax/src/namespace.ts @@ -0,0 +1,24 @@ + export declare namespace a { +// definition syntax 1.0.0 src/`namespace.ts`/ +//documentation ```ts\nmodule "namespace.ts"\n``` +// ^ definition syntax 1.0.0 src/`namespace.ts`/a/ +// documentation ```ts\na: typeof a\n``` + function hello(): string +// ^^^^^ definition syntax 1.0.0 src/`namespace.ts`/a/hello(). +// documentation ```ts\nfunction hello(): string\n``` + interface Interface { +// ^^^^^^^^^ definition syntax 1.0.0 src/`namespace.ts`/a/Interface# +// documentation ```ts\ninterface Interface\n``` + hello: string +// ^^^^^ definition syntax 1.0.0 src/`namespace.ts`/a/Interface#hello. +// documentation ```ts\n(property) hello: string\n``` + } + var i: Interface +// ^ definition syntax 1.0.0 src/`namespace.ts`/a/i. +// documentation ```ts\nvar i: Interface\n``` +// ^^^^^^^^^ reference syntax 1.0.0 src/`namespace.ts`/a/Interface# + export const value = 1 +// ^^^^^ definition syntax 1.0.0 src/`namespace.ts`/a/value. +// documentation ```ts\nvar value: 1\n``` + } + diff --git a/src/FileIndexer.ts b/src/FileIndexer.ts index 27f6a52b..6013c518 100644 --- a/src/FileIndexer.ts +++ b/src/FileIndexer.ts @@ -389,7 +389,11 @@ export class FileIndexer { return this.cached(node, this.scipSymbol(node.parent)) } - if (ts.isImportSpecifier(node) || ts.isImportClause(node)) { + if ( + ts.isImportSpecifier(node) || + ts.isImportClause(node) || + ts.isNamespaceImport(node) + ) { const tpe = this.checker.getTypeAtLocation(node) for (const declaration of tpe.symbol?.declarations || []) { return this.scipSymbol(declaration)