Skip to content

Commit 2d7e0c8

Browse files
committed
Fix type of result
Previously an abstract unist node was used as the type of the return value. This changes that to an estree `Program`, which should improve tools using this project, even though some fields will exist that are not typed.
1 parent 67cf76f commit 2d7e0c8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* @typedef {import('estree-jsx').Program} Program
66
* @typedef {import('buffer').Buffer} Buffer
77
* @typedef {any extends Buffer ? never : Buffer} MaybeBuffer
8-
* This is the same as `Buffer` if node types are included, `never` otherwise.
9-
* @typedef {string|MaybeBuffer} Value
8+
* This is the same as `Buffer` if Node.js types are included, `never` otherwise.
9+
* @typedef {string | MaybeBuffer} Value
1010
*
1111
*
1212
* @typedef AcornErrorFields
@@ -22,7 +22,7 @@
2222
* @returns {ParserClass}
2323
* Resulting parser class.
2424
*
25-
* @typedef {2015|2016|2017|2018|2019|2020|2021|2022|'latest'} Version
25+
* @typedef {2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 'latest'} Version
2626
*
2727
* @typedef Options
2828
* Configuration (optional).
@@ -51,7 +51,11 @@ import {VFileMessage} from 'vfile-message'
5151

5252
/**
5353
* @param {Value} value
54+
* Serialized JavaScript to parse.
5455
* @param {Options} [options={}]
56+
* Configuration (optional).
57+
* @returns {Program}
58+
* Program node (as esast).
5559
*/
5660
export function fromJs(value, options = {}) {
5761
/** @type {ParserClass} */
@@ -95,5 +99,6 @@ export function fromJs(value, options = {}) {
9599

96100
tree.comments = comments
97101

102+
// @ts-expect-error: similar enough.
98103
return fromEstree(tree)
99104
}

0 commit comments

Comments
 (0)