-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design Meeting Notes, 3/24/2023 #53500
Comments
To expand/clarify where we are on Overall, the scenario is obviously very compelling. Having this invariant enables a ton of very good optimizations that advanced build chains can take advantage of, and possibly opens up new doors for TS itself too. The success of the Where it gets a lot hazier very quickly is that, as noted in the PR description, there are a lot of little dials and switches where a .d.ts-emitter (hereafter DTE) with a little bit of extra smarts could save a lot of small annoyances; this is confirmed by the Google feedback where just allowing a gentle inference of We could start with a sort of zero-smarts But the problem is, in all likelihood, the DTE that will be operating in these scenarios isn't ours. It's someone else's. While the semantics of emit under So if the ecosystem blooms here and there are three or four syntax-only DTEs, plus maybe one by us, which supported semantics set does But why would TS be the one enforcing those semantics in the first place? The DTE itself can tell if it's encountering a scenario it can't handle, and can presumably issue errors when it encounters them.. It'd be a little unfortunate to not have those errors directly integrated into TS for the purposes of language service reporting, but it's not the end of the world -- already we have things like lint rules which provide external syntactic errors. And the whole point of It's a little confusing but it feels like the right outcome here, in terms of enabling a textured ecosystem of solutions, might be to simply do nothing and let whatever syntactic DTEs exist enforce their own rules. But we've also seen many times that solutions of the form "Let the community do X task which is syntactic and possibly very bespoke" have not really worked out in practice in a lot of cases. So we'd like to do something to encourage this pattern but it's not super clear what, yet. More thinking to come. |
There's a funny sort of interaction now that I reread the notes. I called out "What is the type of every React component? This is one of those problems that is maybe less technical and more about community guidelines. Something we should try to help change in the long-term. |
😆 |
Here's my perspective as the author of esbuild: I believe this feature would be a lot more work for me (both initially and ongoing) if TypeScript ended up not adding Having I get the point about cases like |
Thanks, Evan. That matches my understanding of the landscape too. There is a core ecosystem coordination problem to solve, where individual participants would be taking a risk if they tried to implement this feature alone. Whereas if we can iterate together towards an acceptable DX, the ideal solution is for TypeScript to act as the reference for the DTE specification and provide conformance tests. That is the easiest path towards adoption. Here's some responses to other points raised earlier. Let's reuse Ryan's abbreviation DTE to mean a First-class TS errors vs external errors
Type-driven enforcement of the rules by the TS checker can provide better DX by freeing up per-file DTEs to be more optimistic about the kind of declarations they emit. For example consider the following snippet: let o = new SomeClass() In most cases the above can be safely transformed to the following declaration: let o: SomeClass; But without the type information about Additionally, TS having built-in error generation also means we can have high-quality type-driven quick-fixes to resolve these errors on the user's behalf. This seems important for DX. Bundling
swc is interested in both according to Donny. However declaration bundling seems fully orthogonal to Isolated Declarations because any tool is already free to bundle today using the results of tsc's declaration emit. Parallelism
Right. Our primary motivation for this feature is to enable project-level parallelism. In our case we use monorepo tooling that spins up multiple processes that each run
Small Correction
Declaration Maps
Agreed. We will add that to the emitter and to the conformance tests to ensure all ecosystem DTE implementations do a good job of this. One vs Two Emitters
The new emitter was created separately only for ease of iteration and prototyping. Let's keep it separate for now whilst we agree on the high-level feature decision points. The final location is a TS decision and we will be very happy to migrate it into the existing emitter when that is desired. The existing emitter only needs two additional components to make that work: the non-type-checked emit resolver and possibly a simplified binder. |
--isolatedDeclarations
#53463
.d.ts
files) because there is no need to check against the implementation.--isolatedDeclarations
ensures that your files could be emitted that way./** @internal */
emitDeclarationOnly
to produce.d.ts
files--build
mode?.d.ts
is older than the input files.noEmit
? You need build-mode checking, but not emit..tsbuildinfo
?transpileModule
.export const x = 10
- that's an error without a type.JSX.Element
?The text was updated successfully, but these errors were encountered: