pulumi/pulumi · error · Error
Cannot determine resource type: source file not found for de
Error message
Cannot determine resource type: source file not found for declaration of '${symbol.name}' for ${this.formatErrorContext(context)} What it means
The analyzer calls `declaration.getSourceFile()` to locate the file containing the resource class. If the TypeScript AST returns no source file for the declaration (rare, e.g. synthesized declarations or transient symbols from transformed programs), the implementation path cannot be computed and it throws naming the symbol.
Source
Thrown at sdk/nodejs/provider/experimental/analyzer.ts:976
const symbol = type.getSymbol();
if (!symbol) {
throw new Error(
`Cannot determine resource type: source (symbol) not found for type '${this.checker.typeToString(type)}' for ${this.formatErrorContext(context)}`,
);
}
// Try to find the declaration of the class
const declaration = symbol.declarations?.[0];
if (!declaration) {
throw new Error(
`Cannot determine resource type: source (declaration) not found for symbol '${symbol.name}' for ${this.formatErrorContext(context)}`,
);
}
// Find its declaration source file.
const sourceFile = declaration.getSourceFile();
if (!sourceFile) {
throw new Error(
`Cannot determine resource type: source file not found for declaration of '${symbol.name}' for ${this.formatErrorContext(context)}`,
);
}
// Find the actual implementation file - use the TypeScript file directly if it's not a .d.ts file
let implPath = sourceFile.fileName;
if (implPath.endsWith(".d.ts")) {
// For declaration files, look for the corresponding .js file
implPath = implPath.replace(/\.d\.ts$/, ".js");
}
if (!ts.sys.fileExists(implPath)) {
throw new Error(
`Cannot determine resource type: source file not found at '${implPath}' for '${symbol.name}' for ${this.formatErrorContext(context)}`,
);
}
// Load the module.View on GitHub (pinned to 793f7b2e16)
Solutions
- Ensure the resource class is declared in a real `.ts` file included in the program's root files.
- Remove or bypass custom transformers/virtual modules for the provider package being analyzed.
- Check the tsconfig `include`/`rootDir` settings so the class's file is part of the analyzed program.
Example fix
// before (virtual module declared by a plugin)
declare module "virtual:resource" { export class Widget {} }
// after (real file)
// src/widget.ts
export class Widget extends pulumi.ComponentResource {} Defensive patterns
Strategy: validation
Validate before calling
// Check the declaration is anchored to a real source file:
const decl = symbol.declarations?.[0];
if (!decl?.getSourceFile?.() || decl.getSourceFile().fileName.includes("virtual")) {
throw new Error("resource class must be declared in a real on-disk .ts file");
} Type guard
function hasRealSourceFile(decl: ts.Declaration | undefined): boolean {
const f = decl?.getSourceFile?.();
return !!f && !f.fileName.startsWith("typescript/lib") && ts.sys.fileExists(f.fileName);
} Try / catch
try {
resolveResourceType(propType);
} catch (e) {
if (String(e.message).includes("source file not found for declaration")) {
console.error(`${e.message} — move the class into a real .ts file in the analyzed program`);
} else { throw e; }
} Prevention
- Do not declare resources inside virtual modules or transformer-generated code.
- Keep resource classes in ordinary `.ts` files included by tsconfig.
- Avoid running the analyzer inside in-memory/transformed TS programs.
- Keep the provider package's program plain `tsc` output.
When it happens
Trigger: Analyzing types whose declarations originate from synthesized/virtual source files — e.g. types produced by TS transformers, in-memory programs, or declarations injected by bundler plugins rather than real files on disk.
Common situations: Build pipelines using custom TypeScript transformers or virtual module plugins; analyzing inside tools that create program instances from memory rather than disk.
Related errors
- Cannot determine resource type: source (symbol) not found fo
- Cannot determine resource type: source (declaration) not fou
- invalid empty stack name
- refusing to remove stack because it still contains resources
- a stack named %s already exists
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/057d5efa66326426.
Report an issue: GitHub.