microsoft/TypeScript · error · Error

No Project.

Error message

No Project.

What it means

Thrown via Errors.ThrowNoProject() (utilitiesPublic.ts:59), a shared `never`-returning helper invoked across editorServices.ts:1853, scriptInfo.ts:578/581/622, and several Session handlers (session.ts:2146/2159/2171/2622/2905/3330). It signals that a request needs an active Project for a file/script and none could be resolved — either no project owns the file or all candidate projects were unloaded.

Source

Thrown at src/server/utilitiesPublic.ts:59

    Perf = "Perf",
}

export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
    return {
        projectName: project.getProjectName(),
        fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]),
        compilerOptions: project.getCompilationSettings(),
        typeAcquisition,
        unresolvedImports,
        projectRootPath: project.getCurrentDirectory() as Path,
        cachePath,
        kind: "discover",
    };
}

export namespace Errors {
    export function ThrowNoProject(): never {
        throw new Error("No Project.");
    }
    export function ThrowProjectLanguageServiceDisabled(): never {
        throw new Error("The project's language service is disabled.");
    }
    export function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never {
        throw new Error(`Project '${project.getProjectName()}' does not contain document '${fileName}'`);
    }
}

export type NormalizedPath = string & { __normalizedPathTag: any; };

export function toNormalizedPath(fileName: string): NormalizedPath {
    return normalizePath(fileName) as NormalizedPath;
}

export function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path {
    const f = isRootedDiskPath(normalizedPath) ? normalizedPath : getNormalizedAbsolutePath(normalizedPath, currentDirectory);
    return getCanonicalFileName(f) as Path;

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Open the file's project before issuing requests: send projectOpen/open with the tsconfig or open the file via the `open` command so the ProjectService loads an owning project.
  2. Confirm the file path is inside a configured project root (and matches the tsconfig include/includePath).
  3. Inspect tsserver logs for project-load failures (tsconfig errors, parse errors) that left the file orphaned, and fix the root cause.
  4. Restart tsserver if the project was unloaded by a transient error.
  5. On the client, retry after the `projectLoadingFinish` event rather than racing ahead.

Example fix

// before — request issued for an unopened file
client.send({ command: 'quickinfo', arguments: { file: '/proj/a.ts', line: 1, offset: 1 } });
// throws: No Project.

// after — open the file first so a project is loaded
client.send({ command: 'open', arguments: { file: '/proj/a.ts', fileContent: '' } });
await waitForEvent('projectLoadingFinish');
client.send({ command: 'quickinfo', arguments: { file: '/proj/a.ts', line: 1, offset: 1 } });
Defensive patterns

Strategy: validation

Validate before calling

// Verify a project is loaded for the file before issuing the request.
function ensureProjectForFile(projectService: ProjectService, fileName: string): Project {
  const project = projectService.getDefaultProjectForFile(fileName as NormalizedPath)
    || projectService.getLoadingProjectForFile(fileName as NormalizedPath);
  if (!project) throw new Error(`No project loaded for ${fileName}. Open the file/project first.`);
  return project;
}

Type guard

function fileHasProject(projectService: ProjectService, fileName: string): boolean {
  return !!projectService.getDefaultProjectForFile(fileName as NormalizedPath)
      || !!projectService.getLoadingProjectForFile(fileName as NormalizedPath);
}

Prevention

When it happens

Trigger: A protocol request (e.g. geterr, completions, definition) is dispatched for a file that has not been opened in any configured project, or whose project was closed by the ProjectService. The session handler calls getProject(...) / ScriptInfo.containingProjects paths that bottom out at ThrowNoProject.

Common situations: Editor sends a request before opening the project / tsconfig; the file is outside any project root; the project was unloaded due to a tsconfig error; orphaned script info after a project reload; client race during project reload.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/07c66343428ecc44. Report an issue: GitHub.