You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Valibot with TypeScript in a project targeting Node.js it is currently either necessary to set 'skipLibCheck' to true or to include the 'DOM' lib.
As a result Valibot could be used without setting 'skipLibCheck' or adding the 'DOM' lib. And on top of that file() would be unusable when using Valibot with Node.js as expected.
Please let me know if you like the solution above. I would be happy to create a PR for it.
The text was updated successfully, but these errors were encountered:
Thank you for creating this issue. Why is enabling skipLibCheck or adding 'DOM' a problem for you? Unfortunately, File is not the only API we use. Other types such as TextEncoder and Blob would cause similar problems.
We only use Web APIs that are supported across different runtimes. Strange that this still causes problems at the type level.
It might be padentic but I don't like adding the 'DOM' lib when developing something only meant for Node.js. I think it kind of defeats the purpose of using TypeScript as it adds type definitions for things which aren't available on Node.js like File. When using it TypeScript will signal everything is fine and can't help to prevent runtime errors.
I just double checked that 'skipLibCheck' has a similar effect. It happily lets you use file() and just marks the result as any instead of File. It makes all of Valibot's validation silently go away.
File should be available in Node.js >=v20 according to MDN.
It might be padentic but I don't like adding the 'DOM' lib when developing something only meant for Node.js. I think it kind of defeats the purpose of using TypeScript...
I agree! This is not a good solution.
I just double checked that 'skipLibCheck' has a similar effect. It happily lets you use file() and just marks the result as any instead of File. It makes all of Valibot's validation silently go away.
Is this solution okay? At least I haven't had any problems with it so far.
When using Valibot with TypeScript in a project targeting Node.js it is currently either necessary to set
'skipLibCheck'
totrue
or to include the'DOM'
lib.This is the error I ran into:
What about wrapping the usage of
File
with a type helper to ensure it compiles successfully? I think something like this should work:As a result Valibot could be used without setting
'skipLibCheck'
or adding the'DOM'
lib. And on top of thatfile()
would be unusable when using Valibot with Node.js as expected.Please let me know if you like the solution above. I would be happy to create a PR for it.
The text was updated successfully, but these errors were encountered: