Skip to content

Commit

Permalink
Add docs for disallowAmbiguousJSXLike (#2585)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Oct 29, 2021
1 parent 1df715e commit 2ff76bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/parser.md
Expand Up @@ -253,6 +253,7 @@ You should enable these features only if you are using an older version.
| Version | Changes |
| --- | --- |
| `7.14.0` | Added `dts` for `typescript` plugin |
| `7.16.0` | Added `disallowAmbiguousJSXLike` for `typescript` plugin |
</details>

> NOTE: When a plugin is specified multiple times, only the first options are considered.
Expand Down Expand Up @@ -305,6 +306,8 @@ You should enable these features only if you are using an older version.
- `typescript`
- `dts` (`boolean`, default `false`)
This option will enable parsing within a TypeScript ambient context, where certain syntax have different rules (like `.d.ts` files and inside `declare module` blocks). Please see https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html and https://basarat.gitbook.io/typescript/type-system/intro for more information about ambient contexts.
- `disallowAmbiguousJSXLike` (`boolean`, default `false`)
Even when the `jsx` plugin is not enabled, this option disallows using syntax that would be ambiguous with JSX (`<X> y` type assertions and `<X>() => {}` type arguments). It matches the `tsc` behavior when parsing `.mts` and `.mjs` files.

### Error codes

Expand Down
8 changes: 8 additions & 0 deletions docs/plugin-transform-typescript.md
Expand Up @@ -87,6 +87,14 @@ class A {

Enables compilation of TypeScript namespaces.

### `disallowAmbiguousJSXLike`

`boolean`, defaults to `false`

Added in: `v7.16.0`

Even when JSX parsing is not enabled, this option disallows using syntax that would be ambiguous with JSX (`<X> y` type assertions and `<X>() => {}` type arguments). It matches the `tsc` behavior when parsing `.mts` and `.mjs` files.

### `isTSX`

`boolean`, defaults to `false`
Expand Down
10 changes: 9 additions & 1 deletion docs/preset-typescript.md
Expand Up @@ -77,7 +77,7 @@ Replace the function used when compiling JSX fragment expressions. This is so th

`boolean`, defaults to `false`

Indicates that every file should be parsed as TS or TSX (depending on the `isTSX` option).
Indicates that every file should be parsed as TS, TSX, or as TS without JSX ambiguities (depending on the `isTSX` and `disallowAmbiguousJSXLike` options).

### `allowNamespaces`

Expand Down Expand Up @@ -106,6 +106,14 @@ class A {
}
```

### `disallowAmbiguousJSXLike`

`boolean`, defaults to `true` for `.mts` and `.cts` files and to `false` otherwise.

Added in: `v7.16.0`

Even when JSX parsing is not enabled, this option disallows using syntax that would be ambiguous with JSX (`<X> y` type assertions and `<X>() => {}` type arguments). It matches the `tsc` behavior when parsing `.mts` and `.mjs` files.

### `onlyRemoveTypeImports`

`boolean`, defaults to `false`
Expand Down

0 comments on commit 2ff76bc

Please sign in to comment.