- Add
parseLangTypes
option to enable skipping plugin for non-Flow files
- Support
React.RefSetter
translation and remove support for incorrectReact.Ref
translation.
- Allow trailing comma after rest param in component declaration
- Allow trailing comma after rest param for component types
- Don't allow newline after async in method proper
- Fixed an issue that caused an error when trying to print a
Program
with an emptybody
array and a docblock comment.
- Added support for
as
expressions in parent classes likeclass A extends (Foo as Bar)
.
- Adopted one-sided type guards in predicate functions (
implies x is T
)
- Added
reactRuntimeTarget
config option (defaulting to'18'
) that when set to'19'
no longer adds the forwardRef wrapper as React 19 treats refs on function components as regular props.
- Allow
context.modifyInPlace
API to modify the Program node. Previously, this relied uponcontext.replaceNode
internally which meant modifications to the Program node itself were not possible.
- Added support for parsing member expressions in parent classes like
class A extends Foo.Bar
and type casts such asclass A extends (Foo: Bar)
. - Added support for the
StringPrefix
andStringSuffix
Flow types, turning them into a TS string literal type. For example,StringPrefix<foo>
is turned intofoo${string}
andStringPrefix<foo, T> is turned into foo${T}
. - Added support for inexact tuple types in TS by spreading an array of unknown (mixed) to the end of the array. This will allow for additional arbitrary elements in the tuple.
- Fixed analysis of mapped types' scopes
- Added support for printing inexact tuple type annotations
[...]
- Added support for printing Flow Enums with bigint members
- Added support for printing the one-sided variant of type guards
implies x is T
- Added support for translating
React.AbstractComponent
with 3 type arguments into TS. The third type argument containing render type information will be ignored.
- Added support for
as const
expressions - Added support for inexact tuple type annotations
[...]
- Added support for parsing Flow Enums with bigint members
- Added support for a one-sided variant to type guards
implies x is T
- Scope analysis support for typeof nodes with type arguments
- Support for use in beta releases of Babel 8
- Added support for newer unreleased Flow syntax
- Bug fixes in preparation of new feature rollout
- Scope analysis support for
DeclareNamespace
nodes
$ReadOnlyMap
and$ReadOnlySet
have been updated to expect two type arguments instead of one, aligning with the flow API.
- Retain more type annotations when lowering to babel AST.
- Update codegen to output type guards instead of
%checks
- handle Literal properties in flow-to-flowdef conversion
- Do not apply the plugin for TS files
- Include JSX closing elements in scope/bindings references
- Fix type of
typeAnnotation
property ofAsExpression
- Ensure types cast to in
AsExpression
s are considered as referenced
- Fix an issue with preserving comments of optional chaining nodes
- Add support for
AsExpression
s in Flow to Flow def
- Patch prettier#15514, fixing edge case of
AsExpression
printing
- Parse
AsExpressions
in Flow. - Fix
ObjectTypeMappedTypeProperty
babel lowering to output valid code.
- Update internal version of prettier to version
3.0.3
.
- Improve types of
DestructuringObjectPropertyWithShorthandStaticName
,ExportNamedDeclarationWithSpecifiers
,ObjectTypeAnnotation
andBigIntLiteral
.
- Major refactor of hermes parser babel support infra to allow safer/easier transforms and more closely match babel output.
- Correct
FunctionExpression
property range. - Correct
DeclareEnum
babel output to correctly wrap theTypeAnnotationType
in aTypeAnnotation
. - Upgrade to latest
emscripten
(3.1.44 from 3.1.3).
- Correctly handle converting identifier references via
typeof identifier
. - Support conditional types, type guards,
infer
, mapped object types,$ReadOnlyMap
and$ReadOnlySet
.
- Update internal version of prettier to version
3.0.2
.
- Ensure
ExportNamespaceSpecifier
has location information.
- Update
prettier-plugin-hermes-parser
peer dependency version.
- Correctly convert
MethodDefinition
toClassPrivateMethod
whenbabel: true
is set and the key isPrivateName
.
- Ensure the prettier
print
cache key is unique even if there is more than one instance ofhermes-transform
. - Add peer dependency on
prettier-plugin-hermes-parser
.
- Remove support for now removed
$Shape
and$Partial
Flow utilities. - Add support for tuple labeled and spread elements.
- Support translating
React.ElementProps
from Flow to TS. - Support
ExportAllDeclaration
in TS translation.
- Added support for Flow's new type guards
- The previous release did not build properly for release. This release fixes the issue.
- The previous release did not build properly for release. This release fixes the issue.
- Strip TS only
tsModifiers
property fromPropertyDefinition
nodes - Fix issue with
ConditionalTypeAnnotation
not being correctly stripped withbabel: true
mode.
- Switched the printer to always use
prettier-plugin-hermes-parser
to ensure it can support the latest Flow syntax.
- Switched the printer to always use
prettier-plugin-hermes-parser
to ensure it can support the latest Flow syntax.
- Patched issue in prettier that caused infinite recursion when printing array produced by
hermes-transform
.- See prettier/prettier#14963 for upstream patch.
- Created new package which creates a Hermes parser plugin for Babel. This plugin switches Babel to use
hermes-parser
instead of the@babel/parser
. Since Hermes parser uses C++ compiled to WASM it is significantly faster and provides full syntax support for Flow.
- Lazy load the plugin so it does not effect performance if its included but not used.
- Strip Flow parser from embedded prettier v3 bundle to improve plugin initialization time.
- Fix
process.exitCode
being overridden when initializing WASM. - Add support fo parsing type parameter bounds separated by
extends
keyword in Flow.
- Add support for Prettier v3.
- Add support for Flow AST nodes as parsed by
hermes-parser@0.12.0
.
- Add support for Flow AST nodes as parsed by
hermes-parser@0.12.0
.
- Add support for Flow AST nodes as parsed by
hermes-parser@0.12.0
.
- Created
prettier-plugin-hermes-parser
package. This is a plugin for Prettier to enable the use of Hermes parser. It supports Prettier v3 and v2 but always prints via the latest prettier v3 printing logic, to enable full support for all Hermes parser features.
- Fix dependency versions.
- Update Flow AST representation for
typeof
types.TypeofTypeAnnotation
now can haveQualifiedTypeofIdentifier
andIdentifiers
as arguments directly. - Add support for parsing
TupleTypeSpreadElement
andTupleTypeLabeledElement
in Flow. DeclareVariable
in Flow now has akind
property, which can bevar
,let
, orconst
.- Add support for parsing
DeclareEnum
in Flow. - Add support for parsing type arguments in
JSXElement
in Flow. - Fixes typo in parsed TypeScript
TSConditionalType
nodes. ThefalseTYpe
property has been renamed tofalseType
. - Add support for parsing
keyof
types in Flow. - Add support for parsing
ConditionalTypeAnnotation
in Flow. - Add support for parsing
InferTypeAnnotation
in Flow. - Add support for parsing
ObjectTypeMappedTypeProperty
in Flow. - Add support for parsing
TypePredicate
in Flow.
- Add support for Flow AST nodes as parsed by
hermes-parser@0.11.0
. - Exports
makeCommentOwnLine
function which makes added comments print on their own line. - Add support for corrected
MemberExpression
representation withoptional
property fromhermes-estree@0.11.0
.
- Add support for Flow AST nodes as parsed by
hermes-parser@0.11.0
.
- Add support for Flow AST nodes as parsed by
hermes-parser@0.11.0
. - Fix
MemberExpression
to properly exposeoptional
property in Flow.
- Add handling for updated
typeof
type representation. - Add handling for
DeclareVariable
withkind
property. - Add handling for
DeclareEnum
. - Adds error recovery for unsupported Flow syntax in TypeScript translation. Instead of exiting, most errors will now be printed as comments in the output TypeScript code with appropriate type fallbacks.
- Add handling for Flow
typeof
imports. - Improve scope resolution of
React
imports. - Add
React.ElementConfig
handling. - Add
React.Key
handling. - Add
React.Ref
handling. - Add
React.Component
handling. - Add
React.ElementType
handling. - Add
React.ChildrenArray
handling. - Improve
React.ComponentType
handling. - Improve
React.AbstractComponent
handling.
- Remove unlisted dependency on the
hermes-eslint
package as this caused module not found errors if you only installed thehermes-parser
package.
- Support global React type annotations, e.g.
React$Node
. - Support
export default
of global type annotations. - Fix issue with older version of prettier incorrectly printing TS value import statements.
- Add
hermes-eslint
as explict dependency.
- Add
SimpleTransform
API. This API is designed similar to theSimpleTraversal
API but allows mutating the AST while traversing enabling the use of recursive transforms. Thehermes-transform
package by contrast only allows mutations at the end which is much easier to reason about but limits what can be achieved. - Add support for
BigIntTypeAnnotation
parsing, e.g.type T = bigint;
. - Prevent docblock directives from being able to crash the parser.
- Add
stopTraversal
andskipTraversal
API's.stopTraversal
will abort the traversal all together where asskipTraversal
will continue traversal but not traverse into the current node's child nodes. - Export
MaybeDetachedNode
type andasDetachedNode
function. - Fix
ChainExpression
andObjectTypeProperty
node printing. - Export new
parse
,print
API's in addition to thetransform
API. Theparse
API will call thehermes-parser
as well as prepare the AST for transform, by running comment attachment and setting docblock properties. Theprint
API creates source text from the AST viaprettier
, it also does all work necessary to prepare the AST for prettier, for example reattaching the docblock as a simple comment. - Stop the docblock from being attached to the first statement. It is now only accessible via the
docblock
property onProgram
. This ensures the docblock comment is not duplicated if the first statement is moved. - Add
Program
node generator, e.g.t.Program({...})
. This allows full AST's to be created.
- Fix incorrect reference created by a JSX namespace name.
- Fix JSX above the React import not correctly marking React as used.
- Mark function variables as used if they have multiple defs and the declaration is exported.
- Improve AST Flow types.
- Add
isExpression
andisStatement
predicate functions.
- Created
flow-api-translator
package. This allows translating Flow code into either Flow definitions or TS definitions along with generating the non typed runtime code. This is designed to help library authors using Flow to more easily support the use of their code in TS or Flow codebases.
- Fix unnecessary newlines being added during printing.
- Fix handling of arrays with nullable elements in
shallowCloneArray
(like an array's.elements
property). - Add
modifyNodeInPlace
API for directly modifying a node with an implicit clone. - Improve infra so that explicit cloning is mostly unnecessary.
- Most of the API will automatically shallow-clone any node that's passed in.
- The APIs still exist should you want to explicitly clone to control the depth, etc.
- Add handling for FBT's
fbs
tags in scope analysis. - Add handling for function type
this
param in scope analysis.
- Improve types for private brand checks (
#priv in this
) - Add explicitly typed
parent
for nodes with small sets of known parent types