Skip to content

feat: support export type * and export type * as Ns re-exports (TypeScript 5.0)#360

Draft
marionebl wants to merge 1 commit into
tree-sitter:masterfrom
marionebl:feat/export-type-star
Draft

feat: support export type * and export type * as Ns re-exports (TypeScript 5.0)#360
marionebl wants to merge 1 commit into
tree-sitter:masterfrom
marionebl:feat/export-type-star

Conversation

@marionebl

Copy link
Copy Markdown

Summary

TypeScript 5.0 added type-only star re-exports as the type-level counterpart to the existing export * from '…' forms:

export type * from './types';
export type * as Types from './types';

These were previously parsed as ERROR nodes, causing downstream tools (e.g. file-scopr) to report spurious parse errors on real-world TypeScript monorepos (trpc, radix-ui, react-router, etc.).

Changes

common/define-grammar.js — two new alternatives in the TypeScript export_statement override:

seq('export', 'type', '*', $._from_clause, $._semicolon),
seq('export', 'type', $.namespace_export, $._from_clause, $._semicolon),

test/corpus/declarations.txt — two new corpus test cases:

  • Export type star
  • Export type star as namespace

Test results

114 tests: 114 passed, 0 failed

Reference

TypeScript 5.0 added the ability to write type-only star re-exports:

    export type * from './types';
    export type * as Types from './types';

These are the type-level equivalents of the existing
`export * from '…'` and `export * as Ns from '…'` forms already
handled by the JavaScript base grammar.

Add two new alternatives to the TypeScript `export_statement` override:
- `export type * <from-clause>`
- `export type <namespace_export> <from-clause>`

Add two corpus test cases in `test/corpus/declarations.txt`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant