Skip to content

Releases: benjamn/ast-types

Release v0.16.3

Choose a tag to compare

@benjamn benjamn released this 30 Aug 20:26
fa58247

Syntax support

This release registers fields that current parsers (Babel, and Oxc as normalized by recast's proposed Oxc integration) emit but ast-types did not define, so visitors traverse the subtrees and deep checks accept the nodes:

  • TaggedTemplateExpression.typeParameters and TSTypeQuery.typeParameters, for TypeScript instantiation expressions (f<T> as a value, typeof f<T>).
  • JSXOpeningElement.typeParameters, for explicit JSX type arguments (<Component<T> />).
  • ArrayPattern.typeAnnotation and AssignmentPattern.typeAnnotation (shared Flow/TS definitions).
  • ArrayPattern.optional, ObjectPattern.optional and AssignmentPattern.optional.
  • ClassDeclaration.decorators and ClassExpression.decorators.
  • TSImportType.options, for import attributes in import(...) types.
  • VariableDeclaration.kind now allows "using" and "await using" (explicit resource management).

Each addition is covered by tests that parse the actual syntax with @babel/parser and deep-assert the resulting Program, plus builder tests for node shapes @babel/parser cannot produce directly.

Full changelog: v0.16.2...v0.16.3

Release v0.16.2

Choose a tag to compare

@benjamn benjamn released this 30 Aug 18:59
be46d3f

The first release on the latest dist-tag since 0.14.2 in September 2020. Everything from 0.15.0 and 0.16.x was published under next, so npm install ast-types has been resolving to a five-year-old build; it now resolves here. Consumers on a ^0.16.1 range, which is most of them by download volume, were already on this line and pick this up as an ordinary patch.

Published from GitHub Actions with npm trusted publishing, so it carries a provenance attestation and no npm token was involved. Verify with npm audit signatures.

Released first as 0.16.2-rc.0 under next, which was checked against recast's full suite: 734 passing and a clean tsc 5.9.3 build, identical to the same suite on 0.16.1.

Syntax support

  • CallExpression, NewExpression and OptionalCallExpression now carry typeParameters (TypeScript type arguments such as f<T>()), and the visitor traverses them. Contributed by @phryneas in #954; fixes #343 and facebook/jscodeshift#389.
  • export type * from "mod" and export type * as ns from "mod" (TypeScript 5.0) are supported. ExportAllDeclaration and ExportNamedDeclaration gain an exportKind field ("value" | "type", default "value"), mirroring ImportDeclaration.importKind.
  • ExportNamedDeclaration.specifiers now accepts ExportNamespaceSpecifier, ExportDefaultSpecifier and ExportBatchSpecifier, matching Babel's representation of export * as ns from "mod".
  • ExportNamespaceSpecifier.exported may be a string Literal, per ES2022 arbitrary module namespace names (export * as "ns" from "mod").
  • ExportNamedDeclaration.declaration now defaults to null, so Babel ASTs that omit the property for specifier-only exports validate.

Fixes

  • lib/main.d.ts no longer imports Type, NodePath and builders under the same names as the values it declares, which TypeScript 5.4 and later reject under isolatedModules (TS2865). The fix uses only plain aliased imports, so no currently supported TypeScript version loses support. As a side effect, Type and NodePath imported from the package are now usable as generic types (Type<T>, NodePath<N>). Fixes #948; builds on #950 by @snowystinger.
  • The test suite type-checks a consumer of the published declarations under TypeScript 4.4, the pinned TypeScript, and TypeScript 5.x, all with isolatedModules, so declaration-file regressions fail in CI.

Type changes to be aware of

Runtime behavior and builder signatures are unchanged; the changes above only widen what is accepted. Two generated TypeScript types are wider than before, which can affect code that narrowed on the old type:

  • Code that reads specifier.local on every element of ExportNamedDeclaration.specifiers needs a namedTypes.ExportSpecifier.check(specifier) guard.
  • Code that reads exported.name on an ExportNamespaceSpecifier needs to check for Identifier first.

Testing and infrastructure

  • @babel/parser (a dev dependency) moves from 7.20.5 to 7.29.8, which also updates the Babel fixture corpus the tests validate against, and the harness now honors sourceType from fixture options.json files.
  • Test-only dependencies updated: glob 10, rimraf 5, mocha 11, ts-node, @types/mocha, @types/esprima.
  • CI runs again for the first time since 2022, on Node.js 18, 20, 22 and 24, including a check that src/gen/ is up to date with src/def/.

Documentation

  • The README's git:// clone instruction (a protocol GitHub disabled in 2022), its link into the untracked lib/ directory, and its list of definition modules, which named a file that does not exist and was missing es2016 through es2022, are all corrected. It now has a TypeScript section, which it never had despite the package shipping its own declarations since 0.15.

Full changelog: v0.16.1...v0.16.2

Pre-release version 0.16.2-rc.0

Pre-release

Choose a tag to compare

@benjamn benjamn released this 30 Aug 18:46
c9df55e

A release candidate for 0.16.2, published under the next dist-tag. Install it with npm install ast-types@0.16.2-rc.0. The latest tag is unchanged.

This is the first release published from GitHub Actions with npm trusted publishing, so it carries a provenance attestation and no npm token was involved.

Syntax support

  • CallExpression, NewExpression and OptionalCallExpression now carry typeParameters (TypeScript type arguments such as f<T>()), and the visitor traverses them. Contributed by @phryneas in #954; fixes #343 and facebook/jscodeshift#389.
  • export type * from "mod" and export type * as ns from "mod" (TypeScript 5.0) are supported. ExportAllDeclaration and ExportNamedDeclaration gain an exportKind field ("value" | "type", default "value"), mirroring ImportDeclaration.importKind.
  • ExportNamedDeclaration.specifiers now accepts ExportNamespaceSpecifier, ExportDefaultSpecifier and ExportBatchSpecifier, matching Babel's representation of export * as ns from "mod".
  • ExportNamespaceSpecifier.exported may be a string Literal, per ES2022 arbitrary module namespace names (export * as "ns" from "mod").
  • ExportNamedDeclaration.declaration now defaults to null, so Babel ASTs that omit the property for specifier-only exports validate.

Fixes

  • lib/main.d.ts no longer imports Type, NodePath and builders under the same names as the values it declares, which TypeScript 5.4 and later reject under isolatedModules (TS2865). The fix uses only plain aliased imports, so no currently supported TypeScript version loses support. As a side effect, Type and NodePath imported from the package are now usable as generic types (Type<T>, NodePath<N>). Fixes #948; builds on #950 by @snowystinger.
  • The test suite type-checks a consumer of the published declarations under TypeScript 4.4, the pinned TypeScript, and TypeScript 5.x, all with isolatedModules, so declaration-file regressions fail in CI.

Type changes to be aware of

Runtime behavior and builder signatures are unchanged; the changes above only widen what is accepted. Two generated TypeScript types are wider than before, which can affect code that narrowed on the old type:

  • Code that reads specifier.local on every element of ExportNamedDeclaration.specifiers needs a namedTypes.ExportSpecifier.check(specifier) guard.
  • Code that reads exported.name on an ExportNamespaceSpecifier needs to check for Identifier first.

Testing and infrastructure

  • @babel/parser (a dev dependency) moves from 7.20.5 to 7.29.8, which also updates the Babel fixture corpus the tests validate against, and the harness now honors sourceType from fixture options.json files.
  • Test-only dependencies updated: glob 10, rimraf 5, mocha 11, ts-node, @types/mocha, @types/esprima.
  • CI runs again for the first time since 2022, on Node.js 18, 20, 22 and 24, including a check that src/gen/ is up to date with src/def/.

Documentation

  • The README's git:// clone instruction (a protocol GitHub disabled in 2022), its link into the untracked lib/ directory, and its list of definition modules, which named a file that does not exist and was missing es2016 through es2022, are all corrected. It now has a TypeScript section, which it never had despite the package shipping its own declarations since 0.15.

Full changelog: v0.16.1...v0.16.2-rc.0