microsoft / microsoft/TypeScript
Allow merging enums with undefined
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔍 Search Terms
enum merge undefined
✅ 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
It can sometimes be useful to augment the types for a module to indicate that an exported enum is optional. There's no way I can find in TypeScript to do that right now. "Enum declarations can only merge with namespace or other enum declarations."
📃 Motivating Example
For example API consumers may need to support versions of a package that don't include a recently added enum.
How about allowing a ? before the { for an enum?
declare module 'typescript' {
enum JSDocParsingMode? {}
}
💻 Use Cases
In typescript-eslint we want to always treat ts.JSDocParsingMode as optional. It was added in a more recent version of TypeScript than our backwards compatibility extends. But there's no way to mark it as | undefined.
Even if we do remember to always ts.JSDocParsingMode?.ParseAll and so on, doing so violates https://typescript-eslint.io/rules/no-unnecessary-condition.
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
Non vengono indicati file, test o punti di ingresso specifici. Inizia esaminando come vengono unite le dichiarazioni di enum e come viene verificata dai tipi l’estensione del modulo alla base della richiesta. Il lavoro sarà completato quando esisterà un modo supportato per contrassegnare l’enum esportato come opzionale, preservando i vincoli di compatibilità e di runtime indicati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100