microsoft / microsoft/TypeScript
`eval?.()` is now an indirect eval
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bereitgestellte Playground-Beispiel in einer aktuellen JavaScript-Laufzeitumgebung zu kompilieren und auszuführen, und vergleiche dann das ausgegebene JavaScript mit dem gemeldeten globalen-vs.-lokalen Ergebnis. Der Payload nennt keine Quelldateien oder Tests. Finde daher den Compiler-Pfad, der Ausdrücke mit optionalen Aufrufen verarbeitet, und füge eine Abdeckung hinzu, die das erwartete Verhalten von indirektem eval zeigt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100