Files
oxc-project__oxc/tasks/coverage/misc/fail/import-sync-expression.js
camc314 e184f74d11 fix(parser): improve invalid import property access diagnostic (#22693)
This improves the parser diagnostic for invalid `import.<property>` access.

Previously, invalid properties like `import.sync("baz")` were reported as if only `import.meta` were valid, which is misleading now that `import.source()` and `import.defer()` are also supported.

Before:

```text
  × The only valid meta property for import is import.meta
    ╭─[index.ts]
 37 │
 38 │ import.foo();
      ──────────
 39 │
    ╰────
```

After:

```text
  × The only valid property accesses on import are `import.meta`, `import.source()`, and `import.defer()`
    ╭─[index.ts]
 37 │
 38 │ import.foo();
      ──────────
 39 │
    ╰────
```

Also adds a coverage fixture for the `import.sync("baz")` case and updates the parser coverage snapshots.
2026-05-25 09:58:50 +00:00

2 lines
30 B
JavaScript

const x = import.sync("baz");