yuku-parser 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/index.d.ts +641 -372
- package/index.js +3 -3
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ import { parse } from "yuku-parser";
|
|
|
15
15
|
|
|
16
16
|
const result = parse("const x = 1 + 2;");
|
|
17
17
|
|
|
18
|
-
console.log(result.program);
|
|
19
|
-
console.log(result.comments);
|
|
18
|
+
console.log(result.program); // ESTree / TypeScript-ESTree Program node
|
|
19
|
+
console.log(result.comments); // all comments
|
|
20
20
|
console.log(result.diagnostics); // errors and warnings
|
|
21
21
|
```
|
|
22
22
|
|
|
@@ -76,16 +76,18 @@ const result = parse(source, {
|
|
|
76
76
|
sourceType: "module",
|
|
77
77
|
lang: "jsx",
|
|
78
78
|
preserveParens: true,
|
|
79
|
+
allowReturnOutsideFunction: false,
|
|
79
80
|
semanticErrors: false,
|
|
80
81
|
});
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
| Option
|
|
84
|
-
|
|
85
|
-
| `sourceType`
|
|
86
|
-
| `lang`
|
|
87
|
-
| `preserveParens` | `true`, `false`
|
|
88
|
-
| `
|
|
84
|
+
| Option | Values | Default | Description |
|
|
85
|
+
| ---------------- | ----------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| `sourceType` | `"module"`, `"script"` | `"module"` | Module mode enables `import`/`export`, `import.meta`, top-level `await`, and strict mode. |
|
|
87
|
+
| `lang` | `"js"`, `"ts"`, `"jsx"`, `"tsx"`, `"dts"` | `"js"` | Language variant controls which syntax extensions are enabled. |
|
|
88
|
+
| `preserveParens` | `true`, `false` | `true` | Keep `ParenthesizedExpression` nodes in the AST. When false, parentheses are stripped and only the inner expression is kept. |
|
|
89
|
+
| `allowReturnOutsideFunction` | `true`, `false` | `false` | Allow `return` statements outside of functions, at the top level. |
|
|
90
|
+
| `semanticErrors` | `true`, `false` | `false` | Run semantic analysis and report semantic errors alongside syntax errors. |
|
|
89
91
|
|
|
90
92
|
## Result
|
|
91
93
|
|