`import type { Provider } from '@pulumi/aws'` seem...
# typescript
i
import type { Provider } from '@pulumi/aws'
seems like it doesn’t work. Easy workaround though (just use
aws.Provider
instead through a regular import). but I’m curious to know why it doesn’t work?
l
What version of typescript are you using? This feature is new to 3.8.
i
I’m using 4.7.4
l
Ah, it's a class, not a type. So you just want
import { Provider } from '@pulumi/aws'
i
Oh you’re right, it is a class - but
import type { Class } from 'pkg'
should also work as long as
Class
is only used as a type in the importing module
I might try to debug more later on and see if I can get to the bottom of it
Copy code
import * as aws from '@pulumi/aws'
import type { Region } from '@pulumi/aws'
and here is the exact error:
Copy code
TSError: ⨯ Unable to compile TypeScript:
    src/platformapi/index.ts(2,13): error TS1005: '=' expected.
    src/platformapi/index.ts(2,29): error TS1005: ';' expected.
    src/platformapi/index.ts(2,15): error TS2304: Cannot find name 'Region'.
    src/platformapi/index.ts(2,24): error TS2304: Cannot find name 'from'.
    src/platformapi/index.ts(9,36): error TS2304: Cannot find name 'Region'.
My gut feeling is that the pulumi CLI bundles a specific version of Typescript compiler into it, and uses that, instead of the
typescript
module I have installed in my project
l
Have you seen the section at the bottom of the Javascript page? https://www.pulumi.com/docs/intro/languages/javascript/#disabling-built-in-typescript-support
🙌 1
i
Oh very nice, that’s fixed it (as in, I am now seeing a different error message hehe). Thanks @narrow-author-62348 🥳
👍 1
m
Hey - did you make much progress against this?
I've discovered exactly this - pulumi comes bundled with ts 3.8.something and it doesn't do everything I need it to
or specifically, everything that graphql needs it to
l
If you disable built-in TS support and specify your own, you can work around this.
m
So like webpack it down to a js file and then pulumi up that?
🥲
l
No, just turn off the built-in typescript support and specify your own versions. You'll use ts-node, no need to tsc or anything. It's all in the linked page, at the bottom.
There's never any webpack for node, is there? No need for that...