microsoft / microsoft/TypeScript
Expose more node checking / type guard API functions for developers
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Suggestion
🔍 Search Terms
type guard internal api functions tsutils ts-api-utils
✅ Viability Checklist
My suggestion meets these guidelines:
- 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 feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
The typescript package contains many node checking / type guard API functions for developers (isAccessor, isArrayBindingPattern, etc.). Many of them are exported for public use. Some are not. Could we expose many more of them?
A bit of history: the tsutils package has existed for many years to fill in those missing type guards & other API pieces. It hasn't been maintained in a couple of years so I'm filling out a successor, ts-api-utils with a lot of help from @RebeccaStevens. We're now discussing which parts of the TypeScript API -internal and public- the package should provide.
📃 Motivating Example
Two categories of @internal functions come to mind:
/src/compiler/factory/nodeTests.tscontains 21:isCommaToken,isExclamationToken,isQuestionToken, etc.- See https://github.com/JoshuaKGoldberg/ts-api-utils/pull/50: there are quite a few functions within TypeScript that aren't exported but would be useful:
isExpression,isExpressionNode,isUnaryExpression, etc.
💻 Use Cases
Developers writing logic to work with the TypeScript AST often want these functions as they're handy utilities. Many of them exist in tsutils for that reason.
import * as ts from "typescript";
import * as tsutils from "tsutils";
declare const node: ts.Node;
tsutils.isExpression(node);
Request: which of those internal / not-exported functions would you be open to a PR exposing to the public?
Related:
- #23719
- #50694
- #52473
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 con src/compiler/factory/nodeTests.ts e le funzioni referenziate in ts-api-utils PR #50. Esamina le issue correlate #23719, #50694 e #52473, insieme alla discussione, per identificare quali guard interni o non esportati hanno l’approvazione per essere esposti pubblicamente. Il lavoro è completato quando sono stati definiti un ambito concordato e le modifiche corrispondenti all’API pubblica.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers, developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100