there’s a bug in the latest SST. when I try to dep...
# help
s
there’s a bug in the latest SST. when I try to deploy, I get this:
Copy code
lambda/billing/libs/update-subscription.ts:80:25 - error TS2571: Object is of type 'unknown'.

80   const cognitoUserId = response?.data?.updateSubscription?.user_id;
VS Code shows no problem with this line. earlier versions of SST are also ok with it
f
Hey Sam, which version did u upgrade from?
s
0.43.3
hang on. this may be a side effect of something else 🤔
ok, there’s a TS config issue here for some reason. so.. I have TS 4.4.3 installed. I’m trying to set
useUnknownInCatchVariables
to true (https://www.typescriptlang.org/tsconfig#useUnknownInCatchVariables), but when I try to deploy, I get:
Copy code
tsconfig.json:24:5 - error TS5023: Unknown compiler option 'useUnknownInCatchVariables'.

24     "useUnknownInCatchVariables": true,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
is SST using a different version of TS under the hood?
hmm. fresh install of an SST project shows TS 4.4.3. @thdxr any ideas on this one?
t
Is it possible that this error is coming from esbuild?
s
hard to tell. how would I check?
does esbuild validate tsconfig.json files?
t
when does this error happen
is it while building the function code?
s
happens upon start or deploy. right at the “Running type checker” step
yarn build --stage dev
in a fresh SST project with the
useUnknownInCatchVariables
works fine. hmmmm
t
yeah I just tried it on my project and now issues
can you confirm version
cat node_modules/typescript/package.json
s
4.4.3
this makes no sense 😖
lemme wipe node_modules & reinstall deps
t
can you also run this in your root folder
find . -wholename "*/typescript/package.json"
s
reinstall didn’t work. the result of that find:
Copy code
./node_modules/@serverless-stack/resources/node_modules/typescript/package.json
./node_modules/@serverless-stack/cli/node_modules/typescript/package.json
./node_modules/typescript/package.json
aha. 4.3.5 in @serverless-cli
oh wait..
I know exactly why. I had issues when I upgraded SST so I downgraded. and TS probably went with it
eh, that didn’t help either. shoot
and SST’s version still shows as 4.3.5
this config option wasn’t introduced till 4.4
t
got it that's probably the issue, you can force it to use 4.4 using yarn resolution
I did this back in the day 😄 but will upgrade typescript soon
s
is it possible to have SST include typescript as a peer dependency, and have that typescript inclusion in the template that gets created when you do
yarn create serverless-stack
? that way the developer has more control over it?
t
I made the same suggestion in that thread I linked haha
cc @Jay @Frank this falls into a similar category as jest - setting up things via templating vs hiding it through sst
s
I dunno if I did this right. this goes in the root
package.json
, right?
Copy code
"resolutions": {
    "@serverless-stack/**/typescript": "4.4.3"
  },
t
yeah I believe so
s
still yells at me about
useUnknownInCatchVariables
😞
there’s still a weird mismatch between the TS errors I see in VS Code and what SST lets me build. I see errors in VS Code, but SST doesn’t care and it passes the type checking phase
t
Can you run that find command again?
it should have gotten rid of the multiple packages. Also I'm opening a PR for the ts upgrade right now, just need to wait for it to pass CI
s
sure. looks like the same results:
Copy code
./node_modules/@serverless-stack/resources/node_modules/typescript/package.json
./node_modules/@serverless-stack/cli/node_modules/typescript/package.json
./node_modules/typescript/package.json
so yeah.. the version mismatch is probably the issue with both the config error, as well as VS Code showing errors that SST misses