Skip to content

Commit

Permalink
fix: incorrect type reference directives can sometimes be produced wh…
Browse files Browse the repository at this point in the history
…en a type root is a relative path
  • Loading branch information
wessberg committed Aug 8, 2023
1 parent ac8889c commit 2fd4bda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export interface TypeReference {

export function getTypeReferenceModuleFromFileName({host, fileName}: GetTypeReferenceModuleFromFileNameOptions): TypeReference | undefined {
for (const typeRoot of host.getTypeRoots()) {
if (!fileName.includes(typeRoot)) continue;
const base = path.normalize(fileName.slice(typeRoot.length + 1));
const typeRootIndex = fileName.indexOf(typeRoot);
if (typeRootIndex < 0) continue;

const base = path.normalize(fileName.slice(typeRootIndex + typeRoot.length + 1));
const moduleSpecifier = base.includes("/") ? base.slice(0, base.indexOf("/")) : base;

if (typeModuleReferenceIsAllowed({host, moduleSpecifier})) {
Expand Down
6 changes: 2 additions & 4 deletions test/util/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ for (const [specifier, range] of Object.entries(devDependencies)) {

if (TS_OPTIONS_ENTRIES.size === 0) {
throw new Error(`The TS_VERSION environment variable matches none of the available TypeScript versions.
Filter: ${process.env.TS_VERSION}
Available TypeScript versions: ${[...TS_OPTIONS_ENTRIES.keys()].join(", ")}`);
Filter: ${process.env.TS_VERSION}`);
}

if (ROLLUP_OPTIONS_ENTRIES.size === 0) {
throw new Error(`The ROLLUP_VERSION environment variable matches none of the available Rollup versions.
Filter: ${process.env.ROLLUP_VERSION}
Available Rollup versions: ${[...ROLLUP_OPTIONS_ENTRIES.keys()].join(", ")}`);
Filter: ${process.env.ROLLUP_VERSION}`);
}

interface TestRunOptions {
Expand Down

0 comments on commit 2fd4bda

Please sign in to comment.