|
12 | 12 | * When a typed array, must be UTF-8. |
13 | 13 | * |
14 | 14 | * @typedef AcornErrorFields |
| 15 | + * Extra fields in acorn errors. |
15 | 16 | * @property {number} pos |
| 17 | + * Index. |
16 | 18 | * @property {Position} loc |
| 19 | + * Acorn position. |
17 | 20 | * |
18 | 21 | * @typedef {Error & AcornErrorFields} AcornError |
| 22 | + * Acorn error. |
19 | 23 | * |
20 | 24 | * @callback Plugin |
21 | 25 | * Acorn plugin. |
|
25 | 29 | * Resulting parser class. |
26 | 30 | * |
27 | 31 | * @typedef {2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 'latest'} Version |
| 32 | + * JavaScript version. |
| 33 | + * |
| 34 | + * `'latest'` is equivalent to the latest supported year. |
28 | 35 | * |
29 | 36 | * @typedef Options |
30 | | - * Configuration (optional). |
| 37 | + * Configuration. |
31 | 38 | * @property {Version | null | undefined} [version='latest'] |
32 | | - * JavaScript version (year between 2015 and 2022 or `'latest'`). |
| 39 | + * JavaScript version (year between 2015 and 2023 or `'latest'`, |
| 40 | + * default: `'latest'`). |
33 | 41 | * |
34 | | - * When a number, must be a year in the range `2015` and `2022` (both |
| 42 | + * When a number, must be a year in the range `2015` and `2023` (both |
35 | 43 | * including). |
36 | 44 | * `'latest'` is the same as passing the latest supported year. |
37 | 45 | * |
38 | 46 | * > ☢️ **Danger**: `'latest'` is a sliding thing, you could consider it as |
39 | 47 | * > breaking semver. |
40 | 48 | * > Pass an actual year to lock that down. |
41 | 49 | * @property {boolean | null | undefined} [module=false] |
42 | | - * Whether this is a module (ESM) or a script. |
| 50 | + * Whether this is a module (ESM) or a script (default: `false`). |
43 | 51 | * @property {boolean | null | undefined} [allowReturnOutsideFunction=false] |
44 | | - * Whether a return statement is allowed in the top scope. |
| 52 | + * Whether a return statement is allowed in the top scope (default: `false`). |
45 | 53 | * @property {boolean | null | undefined} [allowImportExportEverywhere=false] |
46 | | - * Whether import/export statements are allowed in the every scope. |
| 54 | + * Whether import/export statements are allowed in the every scope (default: |
| 55 | + * `false`). |
47 | 56 | * @property {boolean | null | undefined} [allowAwaitOutsideFunction] |
48 | | - * Whether `await` is allowed in the top scope. |
49 | | - * Defaults to `version >= 2022`. |
| 57 | + * Whether `await` is allowed in the top scope (default: `version >= 2022`). |
50 | 58 | * @property {boolean | null | undefined} [allowSuperOutsideMethod=false] |
51 | | - * Whether `super` is allowed outside methods. |
| 59 | + * Whether `super` is allowed outside methods (default: `false`). |
52 | 60 | * @property {boolean | null | undefined} [allowHashBang=false] |
53 | | - * Whether a shell hasbang is allowed. |
| 61 | + * Whether a shell hasbang is allowed (default: `false`). |
54 | 62 | * @property {Array<Plugin> | null | undefined} [plugins=[]] |
55 | | - * List of acorn plugins. |
56 | | - * |
57 | | - * Examples are `acorn-jsx` and `acorn-stage3`. |
| 63 | + * List of acorn plugins (default: `[]`); examples are `acorn-jsx` and |
| 64 | + * `acorn-stage3`. |
58 | 65 | */ |
59 | 66 |
|
60 | 67 | import {Parser} from 'acorn' |
@@ -127,6 +134,6 @@ export function fromJs(value, options) { |
127 | 134 |
|
128 | 135 | tree.comments = comments |
129 | 136 |
|
130 | | - // @ts-expect-error: similar enough. |
| 137 | + // @ts-expect-error: Program in, program out. |
131 | 138 | return fromEstree(tree) |
132 | 139 | } |
0 commit comments