You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[api] Paths not resolved relative to tsconfigΒ #64842
import{API}from"typescript/unstable/sync"import{createFileSystem}from"typescript/unstable/fs"constprojectDir="/project";constapi=newAPI({cwd: "/somewhere-else"});// 1. Parse compiler options relative to the project directory.const{ options }=api.parseJsonConfigFileContent({compilerOptions: {module: "esnext",moduleResolution: "bundler",noEmit: true,types: [],paths: {lib: ["./types/lib.d.ts"]},},},{configDirectory: projectDir},);// 2. Create a program with those parsed options.constsnapshot=api.createSnapshot({createPrograms: [{rootFiles: [`${projectDir}/main.ts`],compilerOptions: options}],fileSystem: createFileSystem([[`${projectDir}/main.ts`,`import { x } from "lib";\nexport const y: number = x;\n`],[`${projectDir}/types/lib.d.ts`,`export declare const x: number;\n`],]),});constdiagnostics=snapshot.operation.createdPrograms[0].getSemanticDiagnostics([`${projectDir}/main.ts`]).flat();api.close();console.log(` ${diagnostics.length ? diagnostics.map((d)=>`error TS${d.code}: ${d.text}`).join("\n ") : "OK: 'lib' resolved to /project/types/lib.d.ts"}`);
π Actual behavior
The paths in tsconfig are resolved relative to the API cwd not the tsconfig.json path. This means we get error TS2307: Cannot find module 'lib' or its corresponding type declarations.
π Expected behavior
paths are resolved relative to the tsconfig as before 7.1.0-dev.20261002.1.
As far as I can tell we can't change the cwd once we start the API so if we reuse the same API instance for multiple projects we can't just set cwd to the tsconfig path as we open a new projects.
Activity
[-][api][/-][+][api] Paths not resolved relative to tsconfig[/+]