Some tsconfig.json options are unintentionally overridden which can result in non-obvious TS compiler errors #4829
Labels
kind/enhancement
Improvements or new features
language/javascript
resolution/fixed
This issue was fixed
We use ts-node when running Node.js Pulumi programs and policy packs.
pulumi/sdk/nodejs/cmd/run/run.ts
Lines 146 to 164 in 2513709
The same code is duplicated for policy packs here (consolidating is tracked by pulumi/pulumi-policy#48).
We provide some reasonable default values for when
tsconfig.json
doesn't exist. Unfortunately, the way this is written causes the specified defaults to override any values set in the actualtsconfig.json
file. So iftarget
is set toes2016
intsconfig.json
, the value that ends up being used ises6
.This can lead to non-obvious TypeScript compiler errors, such as
error TS2339: Property 'includes' does not exist on type 'string[]'
, which would work if targetinges2016
, but doesn't work when targetinges6
(when@types/node
is not installed). (A workaround in this particular case would be to include@types/node
as a dependency. Or setlib
to bees2016
so that TS will use the ES2016 type declaration library, even though its codegen is targeting ES6).We should fix this to only set the default values when
tsconfig.json
doesn't exist. (For compatibility, we may actually want to loadtsconfig.json
and set these default values if they aren't defined intsconfig.json
.)Also, related to pulumi/templates#116. As part of fixing this, we should update the default
target
toes2018
, which has broad support in Node 10+ (all the versions of Node we support).The text was updated successfully, but these errors were encountered: