Skip to content

getCompletionsAtPosition fails when importing module from definition #492

@RReverser

Description

@RReverser

Consider example from http://www.typescriptlang.org/Handbook#modules-pitfalls-of-modules:

myModules.d.ts:

// In a .d.ts file or .ts file that is not an external module:
declare module "SomeModule" {
    export function fn(): string;
}

myOtherModule.ts:

/// <reference path="myModules.d.ts" />
import m = require("SomeModule");

Current TypeScript master doesn't handle autocompletion in myOtherModule.ts since it fails when synchronizing host data, specifically calling

synchronizeHostData ->
createProgram ->
... ->
processImportedModules

which in order finds require("SomeModule") node and tries to call

findModuleSourceFile ->
findSourceFile ->
CompilerHost::getSourceFile

which fails due to assertion that sourceFile is found (which is not for the case of locally declared modules).

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions