For clarity: relative imports work for the following...
root/
├── src/
│ ├── projA/
│ ├── projB/
│ └── projC/
└── dist/
├── projA/
├── projB/
└── projC/
projects/
├── projA/
│ ├── src/
│ └── dist/
├── projB/
│ ├── src/
│ └── dist/
└── projC/
├── src/
└── dist/
Parameterizing
TypedArrays#58573
We didn't get the chance to add the es2024 target
ArrayBuffergot new members thatSharedArrayBufferdoes not have.Previously,
SharedArrayBufferjust had two members apart frombyteLengthandslice, making them interchangeable.es2024 has new members for each of these.
ArrayBufferLikeis the best type to describe both.Why?
ArrayBuffer, and notSharedArrayBuffer,crypto.subtle.digestArrayBufferis not a transferable object.Makes it hard when you try to get the underlying buffer via
someUint8Array.buffer.What is the underlying idea of how these compose?
ArrayBufferis a non-indexable span of memory. You use an "ArrayBuffer view" to access the memory.SharedArrayBufferlooks like anArrayBufferbut operates over memory in a shared global heap and has has unordered but sequentially consistent writes.So the idea is to parameterize each of these views over the underlying buffer type.
Problems:
BuffersubtypesUint8Array.Buffergeneric - and to do that, we would have to start usingtypesVersionsbecause oldUInt8Arrayaren't generic.Buffer & WithArrayBufferLike<...>in the retun types ofsliceandsubarray.UInt8Arrayas generic with an option type parameter?thisin some cases.What if we fixed up stuff like
crypto.subtle.digestetc. to acceptSharedArrayBuffereven though they don't take those?Could say the underlying default should be
ArrayBuffer, notArrayBufferLike.ArrayBufferLikeand traditionally these have never had a noticeable difference.File Extension Rewriting,
--experimental-transform-types/--experimental-strip-types, and Multi-Project Builds#59767
Last week, we discussed rewriting relative file extensions. Had concerns, mainly around monorepo-style codebases.
In the meantime, we have a prototype PR.
Sample project
By default doesn't, work, but...
node --conditions typescript.Almost right, but it's not safe to publish TypeScript - if this
exportsmap was published to npm and run withnode --conditions typescript, resolution would fail within the published package.One way is to erase here - but no built-in tooling to do this.
@colinhacks suggested namespacing on a per-package basis for publishing.
moduleSuffixesfoo.ts.android.ts, but you also can't writefoo.ts.tsanyway.Now what if projects don't take advantage of workspaces and just do a direct relative import?
import { add as _add } from "../../lib/src/main.tsoutDirisdistbecause it needs to be rewritten to../../lib/dist/main.ts.You still can use relative imports - everything just needs to end up in the same output folder. This is, for example, how TypeScript's build works! So even we could do this.
For clarity: relative imports work for the following...
but relative imports do not work for the following.
Sample PR to arethetypeswrong that makes everything work with
--experimental-transform-types: Use --experimental-transform-types arethetypeswrong/arethetypeswrong.github.io#194--conditions.conditions- but you don't. TypeScript's project references are smart enough to map output files to input files.#internal/getProbableExports.jsto#internal/getProbableExports.What would all this look like without project references?
tsconfig.json?Should Node automatically have a condition?
Boilerplate-y to have to write
--conditions @my-namespace/sourceand@my-namespace/sourcethroughoutexports/imports, but probably worth the control.otherwise, we feel good about this. It's not 0-config throughout, but it feels like there is a story between the "I can start a Node server fast" and "I can break my projects apart into multiple pieces"/"I want to publish stuff to npm" that we feel good about.