S
SolidJS•4mo ago
1604

How to consume SolidJS in a TS 4 project?

SolidJS is compiled with TS ~5.7.2. I have a project using TS 4.5.5 and am running into issues compiling:
../../node_modules/solid-js/types/reactive/signal.d.ts(108,20): error TS1139: Type parameter declaration expected.
../../node_modules/solid-js/types/reactive/signal.d.ts(108,20): error TS1139: Type parameter declaration expected.
Line 108 of signal.d.ts is using the in out keyword which TS 4 does not support:
export type Setter<in out T> = {
export type Setter<in out T> = {
8 Replies
bigmistqke
bigmistqke•4mo ago
maybe skipLibCheck: true in tsconfig?
1604
1604OP•4mo ago
Looks like I already had it enabled Thanks for the suggestion, @bigmistqke
bigmistqke
bigmistqke•4mo ago
you are welcome 1604! still causing issues?
1604
1604OP•4mo ago
Yes, indeed. My main issue is we have this build system - Node 12.7 - Webpack 4 - TS 4.5.5 and we are trying to use SolidJS 1.9.3. If we update TS, we need to update Node, and if we update Node, we need to update to Webpack 5. So 'm looking for a way to use SolidJS without such a big build system upgrade
bigmistqke
bigmistqke•4mo ago
🤔 mm interesting. According to chatgpt it's because it fails with the parsing of the .d.ts file. Are you running node 12.7 on the server or only building on the client? EOL of node 12.7 was in 2022, could be dangerous if u still run it on the server, regarding security and the like. If you are only running it client side: I would patch the in out out of the declaration. in out has to do with variance, so types might behave slightly different. If you are also running it on the server: maybe worth it to upgrade node and upgrade the other ones too in the process.
1604
1604OP•4mo ago
Thanks, @bigmistqke. Just using Node.js for client-side / internal tooling to build SPAs. This is very helpful. I wrote my own TS 5 to TS 4 "downleveler" script since the OSS ones on npm seem to be broken and that allowed me to compile so far, but babel-solid-plugin breaks because it uses Node.js features newer than 12.7. I also patched that, but then solid-js imports seroval-plugins inline which had some incompatible TS 5 / Node.js code (can't remember which). I was not able to "mock" that module in my webpack config, so I ran into a dead end. It also seemed like too many Band-aids were reuqired to make my build system work, and it doesn't seem sustainaible long-term. TLDR: It seems possible to continue to "monkey patch" or hack the incompatible modules to work with my build system, but it seems equal work to upgrade my build system to newer Node / TS / Webpack.
bigmistqke
bigmistqke•4mo ago
lol 🤣 sounds painful how is solid with webpack? i have only used w vite
1604
1604OP•4mo ago
Haven't tried yet

Did you find this page helpful?