Skip to content
DevOps AI ToolKit
Newsletter
All guides
AI for Pulumi By James Joyner IV · · 8 min read Last reviewed Jul 2026

Pulumi Error: 'preview failed' TypeScript Type Error — Compile Fix

Quick answer

Fix Pulumi 'preview failed' caused by a TypeScript type error (TS2xxx) during pulumi preview: bad Input/Output types, tsconfig, and ts-node compilation issues.

  • #pulumi
  • #iac
  • #troubleshooting
  • #errors
Free toolkit

Stuck on this Pulumi error? Get the free incident triage checklist

A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.

Exact Error Message

Previewing update (dev):

     Type                 Name          Plan       Info
 +   pulumi:pulumi:Stack  my-app-dev               1 error

Diagnostics:
  pulumi:pulumi:Stack (my-app-dev):
    error: TypeScript compilation failed: index.ts(24,41): error TS2345:
      Argument of type 'Output<string>' is not assignable to parameter of type 'string'.

error: preview failed

The key line is the TSxxxx code (TS2345, TS2322, TS2554, etc.) with a file and line number. preview failed is Pulumi reporting that your program never compiled, so no plan could be produced.

What It Means

For TypeScript projects, Pulumi runs your program through ts-node (or a precompiled build) before it can compute a preview. When the TypeScript compiler rejects the code, Pulumi never gets a valid program to evaluate, so pulumi preview and pulumi up both stop with preview failed and echo the compiler diagnostic.

This is an ordinary TypeScript compile error surfaced through Pulumi. The most common cause is mixing Pulumi’s Input/Output wrapper types with plain values — for example passing an Output<string> where a string is required. Fixing the type error fixes the preview.

Common Causes

  • Passing an Output<T> (or Input<T>) directly where a bare T is expected instead of unwrapping it with .apply() or pulumi.interpolate.
  • A wrong or missing type on a resource argument (TS2345/TS2322 assignability errors).
  • Calling a function with the wrong number/shape of arguments (TS2554).
  • strict / strictNullChecks in tsconfig.json flagging possibly-undefined config values.
  • Out-of-date @pulumi/* packages whose type definitions no longer match your code.
  • A tsconfig.json that Pulumi cannot find or that excludes your entry file.

Diagnostic Commands

Reproduce the compile error directly with the TypeScript compiler for the clearest output:

npx tsc --noEmit -p tsconfig.json

Confirm which entry file and tsconfig Pulumi uses:

cat Pulumi.yaml
cat tsconfig.json

Check installed Pulumi SDK versions against what your code expects:

npm ls @pulumi/pulumi @pulumi/aws

Re-run the preview to confirm the exact diagnostic and line:

pulumi preview

Step-by-Step Resolution

  1. Read the TSxxxx code and file:line from the diagnostic — that pinpoints the exact expression Pulumi could not compile.

  2. Unwrap Outputs instead of passing them as raw values. This is the number-one cause. Use pulumi.interpolate for strings or .apply() for transformations:

// Bad: bucket.id is Output<string>, not string
const url = "https://" + bucket.id; // TS2345 / produces "[object Object]"

// Good: build the string as an Output
const url = pulumi.interpolate`https://${bucket.id}`;

// Or transform explicitly
const upper = bucket.id.apply(id => id.toUpperCase());
  1. Fix argument shape/type mismatches by checking the resource’s type definition. For possibly-undefined config, provide a default or require:
const config = new pulumi.Config();
const size = config.require("instanceSize"); // string, not string | undefined
  1. Align SDK versions if the type defs drifted. Update the Pulumi packages together:
npm install @pulumi/pulumi@latest @pulumi/aws@latest
  1. Verify the fix compiles cleanly before running Pulumi again:
npx tsc --noEmit -p tsconfig.json
  1. Re-run the preview and confirm a plan is produced:
pulumi preview

When an assignability error is hard to read, paste the offending line and the compiler message into a prompt from the Pulumi prompt library to have the Input/Output unwrapping explained.

Prevention

  • Never concatenate or template Outputs as if they were strings — reach for pulumi.interpolate and .apply() by default.
  • Run tsc --noEmit in CI (and a pre-commit hook) so type errors fail before they reach pulumi up.
  • Keep @pulumi/* packages upgraded together so type definitions stay consistent with the runtime.
  • Enable editor TypeScript checking so Input/Output mismatches surface while you write, not during preview.
  • Keep tsconfig.json strict on; the errors it raises are exactly the ones that would otherwise break preview.
  • error: Running program '...' failed with an unhandled exception — a runtime error after compilation, not a type error.
  • Cannot find module '@pulumi/aws' — a missing dependency rather than a type mismatch.
  • failed to load language plugin nodejs — the Node language host itself could not start.
  • TypeError: Cannot read properties of undefined — a JavaScript runtime error surfaced during evaluation.

Frequently Asked Questions

Why does Pulumi compile my TypeScript at all? Pulumi runs your program to build the resource graph; for TypeScript it invokes ts-node, so any compile error stops the run before a plan exists.

What does Output<string> is not assignable to string mean? You passed a Pulumi Output where a plain value was required — wrap it with pulumi.interpolate or .apply() so the value is resolved as an Output.

Can I skip type checking to get past the error? You can precompile or loosen tsconfig, but that just hides real bugs; fixing the type is faster and safer than disabling the check.

Does pulumi up have the same problem? Yes — up runs the same preview first, so it fails identically until the TypeScript compiles. For more TypeScript patterns, see the Pulumi guides.

Free download · 368-page PDF

Fixed it? Get 500 Pulumi & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Did this fix your issue?

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.