Skip to content

Commit

Permalink
Add namespace to the import test
Browse files Browse the repository at this point in the history
  • Loading branch information
valerybugakov committed Oct 28, 2022
1 parent 88c7e7d commit af4bb95
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions snapshots/input/syntax/src/import.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ts from 'typescript'
import * as namespace from './namespace'
import { Class } from './class'
import { Enum } from './enum'
import { newFunction } from './function'
Expand All @@ -10,7 +10,7 @@ export function useEverything(): string {
renamedInterface().methodSignature('a') +
Enum[Enum.A] +
newFunction() +
ts.SyntaxKind.ArrayType
namespace.a.value
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
18 changes: 9 additions & 9 deletions snapshots/output/syntax/src/import.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as ts from 'typescript'
import * as namespace from './namespace'
// definition syntax 1.0.0 src/`import.ts`/
//documentation ```ts\nmodule "import.ts"\n```
// ^^ reference typescript 4.8.4 lib/`typescript.d.ts`/ts/
// ^^^^^^^^^^^^ reference typescript 4.8.4 lib/`typescript.d.ts`/
// ^^^^^^^^^ 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`/
Expand Down Expand Up @@ -33,10 +33,10 @@
// ^ reference syntax 1.0.0 src/`enum.ts`/Enum#A.
newFunction() +
// ^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/newFunction().
ts.SyntaxKind.ArrayType
// ^^ reference typescript 4.8.4 lib/`typescript.d.ts`/ts/
// ^^^^^^^^^^ reference typescript 4.8.4 lib/`typescript.d.ts`/ts/SyntaxKind#
// ^^^^^^^^^ reference typescript 4.8.4 lib/`typescript.d.ts`/ts/SyntaxKind#ArrayType.
namespace.a.value
// ^^^^^^^^^ reference local 0
// ^ reference syntax 1.0.0 src/`namespace.ts`/a/
// ^^^^^ reference syntax 1.0.0 src/`namespace.ts`/a/value.
)
}

Expand All @@ -51,9 +51,9 @@
return import('./function').then(c => c.newFunction())
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/
// ^^^^ reference typescript 4.8.4 lib/`lib.es5.d.ts`/Promise#then().
// ^ definition local 3
// ^ definition local 4
// documentation ```ts\n(parameter) c: typeof import("/src/function")\n```
// ^ reference local 3
// ^ reference local 4
// ^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/newFunction().
}

21 changes: 0 additions & 21 deletions snapshots/output/syntax/src/namespace.d.ts

This file was deleted.

24 changes: 24 additions & 0 deletions snapshots/output/syntax/src/namespace.ts
Original file line number Diff line number Diff line change
@@ -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```
}

6 changes: 1 addition & 5 deletions src/FileIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,7 @@ export class FileIndexer {
return this.cached(node, this.scipSymbol(node.parent))
}

if (
ts.isImportSpecifier(node) ||
ts.isImportClause(node) ||
ts.isNamespaceImport(node)
) {
if (ts.isImportSpecifier(node) || ts.isImportClause(node)) {
const tpe = this.checker.getTypeAtLocation(node)
for (const declaration of tpe.symbol?.declarations || []) {
return this.scipSymbol(declaration)
Expand Down

0 comments on commit af4bb95

Please sign in to comment.