microsoft / microsoft/TypeScript
API: make 'isExternalOrCommonJsModule' public
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Suggestion
🔍 Search Terms
isExternalOrCommonJsModule, commonJsModuleIndicator
✅ 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
Make the existing utility function ts.isExternalOrCommonJsModule public by moving it from utilities.ts to utilitiesPublic.ts
📃 Motivating Example
TypeScript treats commonJS modules similar to external modules. But currently there's no way for an API user to know whether TypeScript considers a file as commonJS module. SourceFile#commonJsModuleIndicator is not exposed in the public API and there's no ts.isCommonJsModule as pendant to ts.isExternalModule.
💻 Use Cases
My current use case is to determine whether a file (or top-level declaration inside of it) contributes to the global scope. Currently I can only handle external modules, which doesn't match what TypeScript does internally.
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 leggendo isExternalOrCommonJsModule in utilities.ts e le esportazioni pubbliche in utilitiesPublic.ts. Verifica come vengono esposte utilità pubbliche correlate come isExternalModule ed esegui i test pertinenti della Compiler API; il lavoro è completato quando l'utilità è disponibile pubblicamente senza modificare il comportamento di runtime esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- api, compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100