UNPKG

sortier

Version:
28 lines (27 loc) 1.17 kB
"use strict"; // Mostly taken from Prettier.io - Credit where credit is due! Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = parse; const tslib_1 = require("tslib"); // @ts-expect-error: Flow is a competitor to typescript soo it wont have typescript types const flow_parser_1 = tslib_1.__importDefault(require("flow-parser")); const parser_utils_js_1 = require("../../utilities/parser-utils.js"); function parse(text /*, parsers, opts*/) { const ast = flow_parser_1.default.parse(text, { esproposal_class_instance_fields: true, esproposal_class_static_fields: true, esproposal_decorators: true, esproposal_export_star_as: true, esproposal_nullish_coalescing: true, esproposal_optional_chaining: true, }); if (ast.errors.length > 0) { const loc = ast.errors[0].loc; throw (0, parser_utils_js_1.createError)(ast.errors[0].message, { end: { column: loc.end.column + 1, line: loc.end.line }, start: { column: loc.start.column + 1, line: loc.start.line }, }); } (0, parser_utils_js_1.includeShebang)(text, ast); return ast; }