esrap 1.3.1 → 1.3.3
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/package.json +3 -3
- package/src/handlers.js +12 -1
- package/src/index.js +2 -3
- package/types/index.d.ts +4 -2
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esrap",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Parse in reverse",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"types": "./types/index.d.ts",
|
|
21
21
|
"devDependencies": {
|
|
22
|
+
"@typescript-eslint/types": "^8.2.0",
|
|
22
23
|
"@vitest/ui": "^2.1.1",
|
|
23
24
|
"acorn": "^8.11.3",
|
|
24
25
|
"acorn-typescript": "^1.4.13",
|
|
@@ -37,8 +38,7 @@
|
|
|
37
38
|
},
|
|
38
39
|
"license": "MIT",
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@jridgewell/sourcemap-codec": "^1.4.15"
|
|
41
|
-
"@typescript-eslint/types": "^8.2.0"
|
|
41
|
+
"@jridgewell/sourcemap-codec": "^1.4.15"
|
|
42
42
|
},
|
|
43
43
|
"packageManager": "pnpm@9.8.0"
|
|
44
44
|
}
|
package/src/handlers.js
CHANGED
|
@@ -556,6 +556,12 @@ function handle_type_annotation(node, state) {
|
|
|
556
556
|
state.commands.push(' : ');
|
|
557
557
|
handle_type_annotation(node.falseType, state);
|
|
558
558
|
break;
|
|
559
|
+
case 'TSIndexedAccessType':
|
|
560
|
+
handle_type_annotation(node.objectType, state);
|
|
561
|
+
state.commands.push('[');
|
|
562
|
+
handle_type_annotation(node.indexType, state);
|
|
563
|
+
state.commands.push(']');
|
|
564
|
+
break;
|
|
559
565
|
default:
|
|
560
566
|
throw new Error(`Not implemented type annotation ${node.type}`);
|
|
561
567
|
}
|
|
@@ -934,7 +940,12 @@ const handlers = {
|
|
|
934
940
|
},
|
|
935
941
|
|
|
936
942
|
ExportAllDeclaration(node, state) {
|
|
937
|
-
state.commands.push('export *
|
|
943
|
+
state.commands.push('export * ');
|
|
944
|
+
if (node.exported) {
|
|
945
|
+
state.commands.push('as ');
|
|
946
|
+
handle(node.exported, state);
|
|
947
|
+
}
|
|
948
|
+
state.commands.push(' from ');
|
|
938
949
|
handle(node.source, state);
|
|
939
950
|
state.commands.push(';');
|
|
940
951
|
},
|
package/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {{ type: string, [key: string]: any }} node
|
|
21
21
|
* @param {PrintOptions} opts
|
|
22
22
|
* @returns {{ code: string, map: any }} // TODO
|
|
23
23
|
*/
|
|
@@ -25,7 +25,6 @@ export function print(node, opts = {}) {
|
|
|
25
25
|
if (Array.isArray(node)) {
|
|
26
26
|
return print(
|
|
27
27
|
{
|
|
28
|
-
//@ts-expect-error
|
|
29
28
|
type: 'Program',
|
|
30
29
|
body: node,
|
|
31
30
|
sourceType: 'module'
|
|
@@ -41,7 +40,7 @@ export function print(node, opts = {}) {
|
|
|
41
40
|
multiline: false
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
handle(node, state);
|
|
43
|
+
handle(/** @type {TSESTree.Node} */ (node), state);
|
|
45
44
|
|
|
46
45
|
/** @typedef {[number, number, number, number]} Segment */
|
|
47
46
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
declare module 'esrap' {
|
|
2
|
-
import type { TSESTree } from '@typescript-eslint/types';
|
|
3
2
|
export interface PrintOptions {
|
|
4
3
|
sourceMapSource?: string;
|
|
5
4
|
sourceMapContent?: string;
|
|
@@ -8,7 +7,10 @@ declare module 'esrap' {
|
|
|
8
7
|
/**
|
|
9
8
|
* @returns // TODO
|
|
10
9
|
*/
|
|
11
|
-
export function print(node:
|
|
10
|
+
export function print(node: {
|
|
11
|
+
type: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}, opts?: PrintOptions): {
|
|
12
14
|
code: string;
|
|
13
15
|
map: any;
|
|
14
16
|
};
|