CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--preset-stage-0

Deprecated Babel preset for stage 0 plugins that provides migration guidelines to explicit plugin configurations

80

1.21x
Overview
Eval results
Files

task.mdevals/scenario-8/

Feature-Flagged AST Summary

Build a small module that turns source text into a compact AST summary while conditionally enabling modern syntax support based on feature flags.

Capabilities

Feature-flagged parsing

  • Given const config = settings?.theme ?? "light"; export default config; with features ["optional-chains"], return topLevelTypes as ["VariableDeclaration", "ExportDefaultDeclaration"] and identifiers as ["config", "settings", "theme"], all in source order. @test

JSX support

  • Given const View = () => <section><h1>{title}</h1></section>; with features ["jsx"], include the JSX-bearing statement in topLevelTypes and list identifiers ["View", "title"], preserving first appearance order. @test

TypeScript support

  • Given interface User { id: number } const id: number = 1; with features ["typescript"], ignore type-only declarations in the summary so topLevelTypes is ["VariableDeclaration"] and identifiers is ["id"]. @test

Missing feature errors

  • When parsing code that needs a feature flag (e.g., JSX) but the flag is absent, throw a descriptive error mentioning the missing feature key. @test

Implementation

@generates

API

export type FeatureFlag = "optional-chains" | "jsx" | "typescript";

export interface ParseOptions {
  features?: FeatureFlag[];
  sourceType?: "module" | "script";
}

export interface AstSummary {
  topLevelTypes: string[];
  identifiers: string[];
}

export function buildAstSummary(code: string, options?: ParseOptions): AstSummary;

Identifiers should be reported in the order first encountered during parsing and should exclude any that are only present in type positions.

Dependencies { .dependencies }

@babel/parser { .dependency }

Parses JavaScript/TypeScript source text with configurable plugin flags.

Install with Tessl CLI

npx tessl i tessl/npm-babel--preset-stage-0

tile.json