@@ -52,33 +52,34 @@ import {VFileMessage} from 'vfile-message'
52
52
/**
53
53
* @param {Value } value
54
54
* Serialized JavaScript to parse.
55
- * @param {Options } [options={}]
55
+ * @param {Options | null | undefined } [options={}]
56
56
* Configuration (optional).
57
57
* @returns {Program }
58
58
* Program node (as esast).
59
59
*/
60
- export function fromJs ( value , options = { } ) {
60
+ export function fromJs ( value , options ) {
61
+ const options_ = options || { }
61
62
/** @type {ParserClass } */
62
63
let parser = Parser
63
64
/** @type {Array<Comment> } */
64
65
const comments = [ ]
65
66
/** @type {Program } */
66
67
let tree
67
68
68
- if ( options . plugins ) {
69
- parser = parser . extend ( ...options . plugins )
69
+ if ( options_ . plugins ) {
70
+ parser = parser . extend ( ...options_ . plugins )
70
71
}
71
72
72
73
try {
73
74
// @ts -expect-error: Acorn looks enough like estree.
74
75
tree = parser . parse ( value , {
75
- ecmaVersion : options . version || 'latest' ,
76
- sourceType : options . module ? 'module' : 'script' ,
77
- allowReturnOutsideFunction : options . allowReturnOutsideFunction ,
78
- allowImportExportEverywhere : options . allowImportExportEverywhere ,
79
- allowAwaitOutsideFunction : options . allowAwaitOutsideFunction ,
80
- allowHashBang : options . allowHashBang ,
81
- allowSuperOutsideMethod : options . allowSuperOutsideMethod ,
76
+ ecmaVersion : options_ . version || 'latest' ,
77
+ sourceType : options_ . module ? 'module' : 'script' ,
78
+ allowReturnOutsideFunction : options_ . allowReturnOutsideFunction ,
79
+ allowImportExportEverywhere : options_ . allowImportExportEverywhere ,
80
+ allowAwaitOutsideFunction : options_ . allowAwaitOutsideFunction ,
81
+ allowHashBang : options_ . allowHashBang ,
82
+ allowSuperOutsideMethod : options_ . allowSuperOutsideMethod ,
82
83
locations : true ,
83
84
onComment : comments
84
85
} )
0 commit comments