microsoft / microsoft/TypeScript
`eval?.()` is now an indirect eval
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Bug Report
There has apparently been a recent change to the behavior of eval?.() in all major JavaScript engines. It is now considered an indirect eval instead of a direct eval. This behavior was changed in July 2020. TypeScript is still compiling it as a direct eval and I didn't see an issue about this, so I created this issue.
More context: https://bugs.chromium.org/p/v8/issues/detail?id=10630
🔎 Search Terms
optional chain direct indirect eval scope
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
globalThis.a = "global";
(a => eval?.("console.log(a)"))("local");
🙁 Actual behavior
When compiled with TypeScript, this prints local instead. That matches the behavior of older JavaScript runtimes such as node v14 but doesn't match the latest JavaScript runtimes.
🙂 Expected behavior
This code now prints global when run in an up-to-date browser or in node v15, so it should print global when compiled with TypeScript as well.
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 compilando ed eseguendo l’esempio Playground fornito in un runtime JavaScript aggiornato, quindi confronta il JavaScript emesso con il risultato globale-versus-locale riportato. Il payload non indica file sorgente né test, quindi individua il percorso del compilatore che gestisce le espressioni di chiamata opzionale e aggiungi una copertura che mostri il comportamento previsto di indirect-eval.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100