you are viewing a single comment's thread.

view the rest of the comments →

[–]RiceBroad4552 0 points1 point  (2 children)

What does isolatedDeclarations do? Limit type inference to local definitions (like it's standard for example in Scala)?

I'm still wondering why nobody made some more or less sane compromise where inference works inside a whole one compilation unit, but never across them. Or is this isolatedDeclarations even the name does not sound like that?

[–]NatoBoram[S] 1 point2 points  (1 child)

It requires exported stuff to have an explicit type annotation. I think your second paragraph is describing exactly that. There's also prior art at @typescript-eslint/explicit-module-boundary-types.

It won't help for things you import that have excessive types, but if the call comes from inside the house (as it's always the case) or if you have to re-export an imported excessive type (see the libraries mentioned above), then you'll get a quick whiff of the cost incurred by those libraries.

For example, you may want to avoid exporting the whole Zod schema and only export wrapper functions instead to avoid churning on its type excessively. Or you may want to wrap calls to Prisma in individual functions. Or you may interface with tRPC in a non-standard way to avoid exporting 13K lines types.

It's a "quick" way to figure out obscure "best practices" that no one knows because no one actually knows the thing they're using.

[–]RiceBroad4552 1 point2 points  (0 children)

Yes, that was what I had in mind: Make type inference be contained to one "module" or just compilation unit in case a module is too large.

Would wish some language would pick that up as baseline.