Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
fix: Triple-Slash Directive not resolve module correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Mar 25, 2020
1 parent f5a743c commit 175b021
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions typescript-deno-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ts_module from "typescript/lib/tsserverlibrary";
import { Logger } from "./logger";
import { ConfigurationManager, DenoPluginConfig } from "./configuration";
import { getDenoDts } from "../../core/deno";
import { ModuleResolver, ResolvedModule } from "../../core/module_resolver";
import { ModuleResolver } from "../../core/module_resolver";
import { CacheModule } from "../../core/deno_cache";
import { pathExistsSync, normalizeFilepath } from "../../core/util";
import { normalizeImportStatement } from "../../core/deno_normalize_import_statement";
Expand Down Expand Up @@ -162,15 +162,25 @@ export class DenoPlugin implements ts_module.server.PluginModule {
importMapsFilepath
);

const resolvedModules = resolver
.resolveModules(typeDirectiveNames)
.filter(v => v) as ResolvedModule[];
const resolvedModules = resolver.resolveModules(typeDirectiveNames);

return resolveTypeReferenceDirectives(
resolvedModules.map(v => v.module),
containingFile,
...rest
);
return resolvedModules
.map((v, i) => {
if (!v) {
return resolveTypeReferenceDirectives(
[typeDirectiveNames[i]],
containingFile,
...rest
)[0];
}
const target: ts_module.ResolvedTypeReferenceDirective = {
primary: true,
resolvedFileName: v.module
};

return target;
})
.filter(v => v);
};
}

Expand Down

0 comments on commit 175b021

Please sign in to comment.