/
githubmirror
/
react-native
Обзор
Документация
Войти
/
githubmirror
/
react-native
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/react-native-codegen/src/parsers/flow/parseFlowAndThrowErrors.js
42 строки
960 B
Sam Zhou
Replace `hermes-{parser,eslint}` with `flow-{parser,eslint}` in OSS projects (#57772)
31 июл 2026, 04:23
31 июл 2026, 04:23
e6fd1a3
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict * @format */ 'use strict'; import type {Program as ESTreeProgram} from 'flow-estree'; const flowParser = require('flow-parser'); function parseFlowAndThrowErrors( code: string, options: Readonly<{filename?: ?string}> = {}, ): ESTreeProgram { let ast; try { ast = flowParser.parse(code, { // Produce an ESTree-compliant AST babel: false, // Parse Flow without a pragma flow: 'all', reactRuntimeTarget: '19', ...(options.filename != null ? {sourceFilename: options.filename} : {}), }); } catch (e) { if (options.filename != null) { e.message = `Syntax error in ${options.filename}: ${e.message}`; } throw e; } return ast; } module.exports = { parseFlowAndThrowErrors, };