Skip to main content

parse_source

Function parse_source 

Source
pub fn parse_source(
    src: &str,
    source_map: &Lrc<SourceMap>,
    filename: &str,
) -> Result<Module>
Expand description

Parse TypeScript, JavaScript, JSX, or TSX source code into an AST module

Automatically detects file type based on extension and uses appropriate parser configuration.

Supported file types:

  • .ts, .mts, .cts - TypeScript
  • .tsx, .mtsx, .ctsx - TypeScript with JSX
  • .js, .mjs, .cjs - JavaScript
  • .jsx, .mjsx, .cjsx - JavaScript with JSX

Returns an error if parse errors occur.