microsoft / microsoft/TypeScript
Import assignment should work with esnext targets
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
import assignment
Suggestion
#22321 was closed by a bot that thought the issue was addressed, but it wasn't.
Import assignment should work with esnext targets
Use Cases
JS modules loaders for Node might not support importing CJS with import statements, so you would use require to import them. But we'd still like to bring in their types. This is what import assignment is designed for, it's just disallowed with esnext targets.
Examples
This:
import * as m from './a-module.js';
import cjs = require('some-cjs');
should emit:
import * as m from './a-module.js';
const cjs = require('some-cjs');
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. new expression-level syntax)
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 o test. Inizia tracciando la gestione delle assegnazioni di importazione di TypeScript per i target esnext, quindi confronta l'output attuale con l'esempio dell'issue; il lavoro è completato quando l'assegnazione emette una dichiarazione basata su require preservando l'import esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, 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
- 30/100