Hey everyone,
I’m building a Forge App and use the supported Typescript version which is not the latest. Though I also use Zod for validation also due to Typescript limitation not on the latest version.
The issue though is when I import a third-party library that is build on latest Typescript and Zod. Forge CLI fails to bundle it due to compatibility issues.
It seems that the Forge bundler is not using skipLibCheck: true to avoid type definitions from third-party libraries to interfere with the own Typescript version.
Normally bundlers strip out type definitions (.d.ts files) since they’re not runtime code. The issue seems that Forge’s bundler uses ts-loader which
type-checks during bundling, and it seems also to be configured without skipLibCheck: true. This causes failing code due to type errors in nested dependencies even though
those types wouldn’t be included in the final bundle.
This seems actually a Forge CLI configuration issue - the bundler shouldn’t be type-checking node_modules.
I’m open for any discussion about this.
Thanks in advance
1 Like
Hi Felix!
Can you share which library you’re using and what kind of issues does it get?
skipLibCheck will not completely skip the library code. If you are using the problematic library’s types in your code, those definitions will get checked and can error.
You’re also welcome to create your own tsconfig.json in the project directory and it will be applied to ts-loader. I noticed we don’t have an example of that in our templates, and raised a request to the appropriate team, but meanwhile this is what I’m using for my own TypeScript apps:
{
"compilerOptions": {
"module": "Node16",
"target": "es2017",
"sourceMap": true,
"moduleResolution": "Node16",
"esModuleInterop": true,
"lib": ["dom", "es2022"],
"types": ["node", "react"],
"baseUrl": "./",
"allowJs": true,
"jsx": "react",
"strict": true,
"skipLibCheck": true
},
"include": ["./src/**/*"]
}
Hope this helps!
2 Likes
Thanks @AlexeyKotlyarov , this helped a lot.
it seems like my remaining issue is the support of Zod 4’s type syntax which required Typescript 5.5+ which seems not supported by the bundler yet.
I feel your pain! Please vote on FRGE-1617 (Upgrade Typescript version used by bundler) if you haven’t yet to help us prioritise.
Appreciate it @AlexeyKotlyarov. I will vote on it mentioned topic. Also thanks for the explanation about the ts-loader.