MCPcopy
hub / github.com/facebook/react / parseInput

Function parseInput

compiler/apps/playground/components/Editor/EditorImpl.tsx:43–61  ·  view source on GitHub ↗
(
  input: string,
  language: 'flow' | 'typescript',
)

Source from the content-addressed store, hash-verified

41import {transformFromAstSync} from '@babel/core';
42
43function parseInput(
44 input: string,
45 language: 'flow' | 'typescript',
46): ParseResult<t.File> {
47 // Extract the first line to quickly check for custom test directives
48 if (language === 'flow') {
49 return HermesParser.parse(input, {
50 babel: true,
51 flow: 'all',
52 sourceType: 'module',
53 enableExperimentalComponentSyntax: true,
54 });
55 } else {
56 return babelParse(input, {
57 plugins: ['typescript', 'jsx'],
58 sourceType: 'module',
59 }) as ParseResult<t.File>;
60 }
61}
62
63function invokeCompiler(
64 source: string,

Callers 1

invokeCompilerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected