arktypeio / arktype

TypeScript's 1:1 validator, optimized from editor to runtime
https://arktype.io
MIT License
3.82k stars 55 forks source link

Type ['instanceof', TimeStub] as Infer<TimeStub> is undefined #916

Closed mmailaender closed 5 months ago

mmailaender commented 6 months ago

Report a bug

@ssalbdivad I have created a reproduction of yesterday's undefined problem Discord Discussion.

image

🧩 Context

🧑‍💻 Repro

https://github.com/mmailaender/svelte5/blob/arktype/src/lib/type.d.ts

GitPod: https://gitpod.io/?autostart=true#https://github.com/mmailaender/svelte5/blob/arktype/src/lib/type.d.ts

ssalbdivad commented 5 months ago

There are a couple problems:

  1. this is defined in a .d.ts file. If you have skipLibCheck enabled (which you should), your tsconfig will not apply to these files and they will not be checked for errors.
  2. (1) obfuscates issues like Infer not having been imported and const statements not being legal in .d.ts .

This is quite an unfortunate footgun TS built into the language when really what most people want is not to check files from node_modules. In general I'd recommend against using .d.ts files at all in your source. There's not really ever a good reason to use them instead of a standard .ts file and they create lots of problems.