TypeScript
TypeScript copied to clipboard
Design Meeting Notes, 8/3/2022
Granular Resolutions
https://github.com/microsoft/TypeScript/issues/50152
- Almost everyone using modules these days is using a resolution format called
node.- Even if you're not using Node.js - for example, bundlers such as Webpack and the like.
- Eventually, Node.js added new resolution rules.
- For example, the
exportsmap. - Webpack also supports features like these.
- For example, the
- When we added the
node16, people thought "oh cool, now I can use theexportsmap".- Yes, with a bunch of new restrictions.
- For example, explicit file extensions (e.g. everything must end in
.js,.mjs, or.cts).- Arguably not the worst, but definitely confusing if you're authoring in
.ts,.mts, or.cts.
- Arguably not the worst, but definitely confusing if you're authoring in
- For example, explicit file extensions (e.g. everything must end in
- But bundlers and the like don't adhere to those restrictions.
- Yes, with a bunch of new restrictions.
- Devs using bundlers really didn't like that restriction!
- What if we had something like
nodewith some of the overlays that bundlers and the like support.nodemode accurately models a subset of them, and Node.js versions older than 12.
- Can't support EVERY resolution mode out there. Maybe we can start with subsets and provide means to enable common features that are layered on top of them.
conventional/hybrid(?) - bundler modesnode16- you use Node.jsminimal- something like what bundlers use, maybe custom/internal build
- The logic that users don't like the Node.js restrictions so we should provide a mode that lets them take full advantage of their bundlers - is that good?
- Is this just something people have to get over?
- Zero bundlers enforce the same rules as Node.js.
- That means that the community has sort of spoken.
- Plus, people thinking "I'll write
.ts" for my extension" is another big confusion point. - Look at what docs and boilerplates do today.
- Could
conventionalhave features layered on top to build up thenode16mode? - Have to think about the split between library authors and app developers.
- Former probably want to use
node16, latter should useconventional. - But there's nuance - not every library on npm is intended to be used on Node.js (e.g. web, React Native, etc.)
- Former probably want to use
satisfies Operator
https://github.com/microsoft/TypeScript/issues/47920
- Contextually types an operand, makes sure the operand is assignable to the type.
- Don't want to lose the type of a literal, but want to make sure it conforms to some shape.
- Some nuance.
- Thought
- Was some concern around how
satisfiesplays with types as comments/type annotations proposal.- Isn't at conflict, per se - didn't want to give the appearance of "unstable" syntax.
- We shouldn't stop TypeScript innovation based on it - type annotations can incorporate as we learn as well.
.tscan always be a superset of JS with types anyway.
- So binary operator? No alternative?
as ~ Tas PLEasEas satisfiesas satisfied by<satisfies Foo>expr?
- Type operator that can only be used in
asassertions? (e.g.as (satisfies Foo))
- The infix no-line-terminator space is the only place we are willing to trample, and we do it mindfully. In 27 years since JS has existed, nobody has needed
satisfiesfor non-type purposes. There is a point where waiting speculatively in case that happens means you're just not shipping anything at all. - Drive for early in 4.9 release cycle, get feedback.
- Some nuance.
- Thought
🤣
That must have been a typo but I like it. It stays.
I think that was meant to be the description of why we went back and forth on what satisfies should do.