microsoft / microsoft/TypeScript

Issues with `isolatedDeclarations` and the associated fixes in editor

Aperta
#58,426 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: flag: isolatedDeclarations
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

isolatedDeclarations, quickfix, lag, editor, VSCode, 5.5

🕗 Version & Regression Information
  • This is specific to new 5.5 features
⏯ Playground Link

No response

💻 Code

_

🙁 Actual behavior

I've been testing out isolatedDeclarations in VSCode Insiders on WSL and wanted to collect a few of the issues I noticed in general, especially with some of the associated quick fixes as discussed with @jakebailey in the TS Discord.

  1. The most egregious issue I encountered was a huge lag spike when calculating quick fixes for isolatedDeclarations, even for simple types.

Here you can see I can hover this.to?.traverseApply which is trivially inferred as a simple type from the base class. But then after I hover outValidator and it has to generate a quick fix, it's like it gets stuck recalculating it:

https://github.com/microsoft/TypeScript/assets/10645823/88f3dbed-a99f-459e-92d7-fe47dea0f3fe

  1. I also notice when I'm annotating a value with an isolated declarations error, sometimes auto import suggestions can take several seconds to pop up, so it seems like a general performance issue with some of these fixes.

More broadly, I also notice the total check time for ArkType's repo has increased from 7.5 seconds in 5.4 to 9.5 seconds in 5.5, so there may be some underlying change to e.g. calculate additional predicates, but these fixes associated with isolatedDelcarations seem to be particularly problematic.

Another pattern I noticed was lots of inline imports when applying a quick-fix which is rarely desirable. It would be great if by default (e.g. if there are no naming conflicts), the import would be added to the top of the file and the type would be referenced as normal:

https://github.com/microsoft/TypeScript/assets/10645823/6c5c1c43-25e9-421e-868d-7abad2109db6

  1. I use the pattern type SomeType<parameter = SomeDefault> frequently, and I notice whenever a quickfix is applied it adds the parameter even if it's the default.

This wouldn't be a huge deal, but since if SomeDefault is a type, it will also be expanded out to its structural form and potentially inline-imported, it can add a ton of visual clutter (sometimes an order of magnitude more than the type itself).

  1. I don't understand well most of the underlying rules but I think my biggest wish for isolatedDeclarations is more constants like those strings initialized as class props or stuff like this could somehow not require duplicating the entire object structure at a type-level to replicate what typeof someConstant could do in the past:

image

If that's fundamentally in conflict with the goals of --isolatedDeclarations, feel free to disregard, it just feels frustrating to have no way to derive the type and value from a single source without repeating them anymore even for simple cases.

Sorry for the haphazard format of this issue. I'm very excited about this feature as some of these kinks are ironed out I think the fixes will also add a lot of value, I just wanted to make sure there was a record of these things, particularly since Jake requested I submit something.

🙂 Expected behavior

_

Additional information about the issue

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il ritardo segnalato del quick-fix di isolatedDeclarations e degli auto-import ritardati in VSCode Insiders, utilizzando il repository ArkType e il confronto tra TypeScript 5.4/5.5 descritto qui. Analizza separatamente il comportamento del quick-fix dell’editor, gli import inline e i parametri generici predefiniti; il completamento non è chiaro perché l’issue combina diverse segnalazioni senza un singolo comportamento previsto o un test denominato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript, vscode
Ambito
compilers, developer-experience, performance, tooling
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
20/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.