logoalt Hacker News

culilast Monday at 5:56 AM1 replyview on HN

typedefs are indeed automatically exported but that doesn't mean collisions can happen. You would still have to explicitly import a type

Regardless, I hardly consider that a "missing basic capability"

I don't know what you mean about types for classes being "poor". Types for classes work exactly the same way


Replies

apatheticonionlast Monday at 6:04 AM

You cannot replicate `import type { x } from './foo'` without also re-exporting that import - which causes collisions.

The alternative is to do an inline `const foo = /** @type {import('./foo').x} */ ({})` however this gets messy, repetitive and it's difficult to use algebraic types (e.g. `Event & { detail: string }`)