microsoft / microsoft/TypeScript
Preserve computed property in `--isolatedDeclarations` emit
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
🔍 Search Terms
isolated declarations, computed properties
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Now that #60052 allows for (some) computed properties in in .d.ts files I think the next step is for --isolatedDeclaration to be updated to not error and to emit the computed properties. Opening this issue if helpful to track this work.
I believe the previous plan (#58800) to introduce a new syntactic marker is no longer required.
Related issues: #58533 #60818 #61068
📃 Motivating Example
export const prop: unique symbol = Symbol();
export class MyClass {
[prop] = () => Math.random();
}
@isolatedDeclarations: false
export declare const prop: unique symbol;
export declare class MyClass {
[prop]: () => number;
}
@isolatedDeclarations: true (current 🙁)
ts(9038) Computed property names on class or object literals cannot be inferred with --isolatedDeclarations.
export declare const prop: unique symbol;
export declare class MyClass {
}
@isolatedDeclarations: true (future 🚀 )
No error and same emit as @isolatedDeclarations: false
export declare const prop: unique symbol;
export declare class MyClass {
[prop]: () => number;
}
💻 Use Cases
The primary use case is enabling isolated declarations at scale on large codebases that make heavy use of computed properties.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l'esempio motivante con --isolatedDeclarations e esamina le issue correlate #60052, #58800, #58533, #60818 e #61068. Traccia la gestione esistente delle dichiarazioni isolate per le proprietà calcolate; il lavoro è completo quando non viene emessa alcuna diagnostica e il declaration emit conserva [prop] con il tipo di ritorno number della funzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100