bio-dts 0.1.2 → 0.2.0
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/lib/post-transform.js +1 -3
- package/lib/pre-transform.js +1 -3
- package/lib/util.js +16 -3
- package/package.json +2 -2
package/lib/post-transform.js
CHANGED
package/lib/pre-transform.js
CHANGED
package/lib/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse as recastParse } from 'recast';
|
|
1
|
+
import { parse as recastParse, print as recastPrint } from 'recast';
|
|
2
2
|
import { Path as PathConstructor } from 'ast-types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -13,6 +13,13 @@ import * as typescriptDtsParser from './parsers/typescript-dts.js';
|
|
|
13
13
|
|
|
14
14
|
const DBG = /match/.test(process?.env?.LOG_DEBUG);
|
|
15
15
|
|
|
16
|
+
const formatOptions = {
|
|
17
|
+
useTabs: false,
|
|
18
|
+
reuseWhitespace: false,
|
|
19
|
+
tabWidth: 2,
|
|
20
|
+
quote: 'single'
|
|
21
|
+
};
|
|
22
|
+
|
|
16
23
|
/**
|
|
17
24
|
* Return numeric or string keys of the given object.
|
|
18
25
|
*
|
|
@@ -51,16 +58,22 @@ export function hasProperty(obj, property) {
|
|
|
51
58
|
*/
|
|
52
59
|
export function parse(code) {
|
|
53
60
|
return recastParse(code, {
|
|
54
|
-
parser: typescriptParser
|
|
61
|
+
parser: typescriptParser,
|
|
62
|
+
...formatOptions
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
export function parseDts(code) {
|
|
59
67
|
return recastParse(code, {
|
|
60
|
-
parser: typescriptDtsParser
|
|
68
|
+
parser: typescriptDtsParser,
|
|
69
|
+
...formatOptions
|
|
61
70
|
});
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
export function print(node) {
|
|
74
|
+
return recastPrint(node, formatOptions);
|
|
75
|
+
}
|
|
76
|
+
|
|
64
77
|
/**
|
|
65
78
|
* @param {any} node
|
|
66
79
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bio-dts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Generate sane and clean types from JavaScript sources",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"all": "npm run lint && npm run test && npm run test:dts",
|
|
10
10
|
"lint": "eslint .",
|
|
11
11
|
"test": "mocha test",
|
|
12
|
-
"test:dts": "node bin/
|
|
12
|
+
"test:dts": "node bin/cmd.js --outDir dist -r test/fixtures"
|
|
13
13
|
},
|
|
14
14
|
"author": "Nico Rehwaldt",
|
|
15
15
|
"license": "MIT",
|