Subject: Typescript Version / Custom Runtime Issue...
# typescript
t
Subject: Typescript Version / Custom Runtime Issue Hello! I’m attempting to use
zod
in a magic function but am running into this error:
Copy code
TSError: ⨯ Unable to compile TypeScript:
    src/index.ts(286,14): error TS2589: Type instantiation is excessively deep and possibly infinite.
It appears to be due to the bundled typescript that comes with Pulumi being incompatible with the latest version of zod. I’ve attempted to disable the built-in typescript runtime by adding the following to
Pulumi.yaml
Copy code
runtime:
  name: nodejs
  options:
    typescript: false
But now when I run
pulumi up
I get
Copy code
import * as pulumi from '@pulumi/pulumi'
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
Any ideas as to how I can get around this? I’ve tried 1. creating a new typescript config with
npx tsc --init
and that doesn’t seem to help. 2. Setting
"type": "module"
in
package.json
3. modifying the
target
,
esModuleInterop
, and a few other things. a. (trying anything haha) 4. Searching through the Pulumi a. Slack Logs b. Github Issues c. Source Code Any help would be greatly appreciated. Thank you!
w
I'm scratching my head a bit with this too. I'm not able to offer a solution, I'm afraid. You've already tried the approaches I would reach for (I wish I were a better TS developer but I'm afraid I'm more of a Gopher and Rustacean!) I mostly came here to say that we're tracking the root cause of your issue here and I really want to deliver a solution before Pulumi v4.0. It's just a matter of carving out time.
❤️ 1
t
Thank you so much for looking at this! I appreciate the information and will monitor the PR! Have a wonderful day!
o
@thousands-hairdresser-72380 if you're using Node >8 you can set overrides like so in your package.json: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides If you're using Yarn, there's a similar block you can declare called resolutions: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/#toc-how-to-use-it
Either of those should allow you to override TypeScript to any version you like. We can't make TypeScript a peer dependency in our SDK yet for fear of breaking downstream users, but we might be able to explore updating our templates or some other option with overrides or resolutions.
t
Thank you so much for the information! I’ll try it out!