You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gen-tm: scope an import default-binding named like a modifier keyword (fixes TS #950)
`import type from "x"` is a DEFAULT import whose binding is named `type`
(tsc: isTypeOnly=false) — so `type` is a variable, not the type-only
modifier. Monogram used to mis-fire its type-alias declaration region on
the `type <name>` shape (`type from`, with `from` a valid alias name).
Derive an `import-default-binding` rule: `import <ident>(?=\s*(?:from|,))`
-> the ident is `variable.other.readwrite`. Everything is read from the
grammar — the `import` keyword (scope keyword.control.import) and the
`from` connector (keyword.control.from); the disambiguator is the
grammar's own shape (a default binding precedes the connector, whereas
the `type` MODIFIER precedes the clause ident). Leftmost-match beats the
`type <name>` declaration region (one token to its right).
Emitted ONLY when a declaration keyword is also non-reserved (can legally
stand in the binding slot — TS `type`/`interface`), so plain JS (whose
`function`/`class` are reserved) emits nothing and stays byte-identical.
This also correctly scopes every default binding now (`import foo from`).
Disproves the earlier "agnostic ceiling" framing. TS ledger 25->26/27
(only-official 0); agnostic 8/8, test-issues 349/0, highlight-bench
per-snippet 84.1->85.0%, tsx 56/56; JS/HTML/Vue/JSX byte-identical.
|[#891](https://github.com/microsoft/TypeScript-TmLanguage/issues/891) — `from` as an ordinary variable is not a keyword | ✓ | · |
69
69
|[#814](https://github.com/microsoft/TypeScript-TmLanguage/issues/814) — `a instanceof B & c` keeps the operand a value, not a type | ✓ | · |
70
-
|[#950](https://github.com/microsoft/TypeScript-TmLanguage/issues/950) — default import named `type` — the binding is a variable, not the `type` keyword |·| · |
70
+
|[#950](https://github.com/microsoft/TypeScript-TmLanguage/issues/950) — default import named `type` — the binding is a variable, not the `type` keyword |✓| · |
71
71
|[#1058](https://github.com/microsoft/TypeScript-TmLanguage/issues/1058) — `import defer` should scope `defer` as a keyword | · | · |
72
72
73
73
<details><summary>… and 9 more both grammars already handle (✓ / ✓)</summary>
0 commit comments