leafac / caxa

📦 Package Node.js applications into executable binaries 📦
https://npm.im/caxa
699 stars 34 forks source link

Typescript 4.4 incompatibility #36

Closed rnreekez closed 3 years ago

rnreekez commented 3 years ago

Hi, just a heads up. Since caxa requires execution of the prepare npm script as part of install, there are now errors being thrown at installation. This one a little tough too because I work exclusively on a mac and i've only encountered this on Windows boxes.

$ yarn install --frozen-lockfile
yarn install v1.22.11
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ tsc
Error: src/index.ts(329,27): error TS2571: Object is of type 'unknown'.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Process completed with exit code 1.

I ran into this on my own project and I believe it boils down to whether or not the workspace is leveraging Typescript 4.4.

Snippet throwing compile error: https://github.com/leafac/caxa/blob/main/source/index.ts#L317-L319 Change introduced with TS 4.4

If i'm not mistaken this is now the default behavior if your tsconfig file is set to "strict".

I'm thinking you'll either want to pin the version of typescript or go ahead and add the type check within the snippet.

leafac commented 3 years ago

Thanks for the investigation. Yet, I don’t think I understand exactly what’s going on: Are you running into this issue when trying to use caxa in your project, or when trying to build caxa from source?

If you’re trying to use caxa in your project, then you shouldn’t have to run tsc on the caxa folder, because the npm package already includes the compiled JavaScript.

If you’re trying to build caxa from source, then the version of TypeScript is locked. Could it be that yarn is getting a different version than npm would?

In any case, you make a good point that moving forward, when I get around to updating to TypeScript 4.4, we’ll want to put a type annotation on the catch block.

rnreekez commented 3 years ago

Wow sorry for the delay. Yes you are correct, my mistake. I was actually running this from a forked version which did not have the build published via NPM. I'll go ahead and close this since it looks like you have typescript 4.4 on your radar, the compiler will surface these for you. Thanks for the project!