Repository navigation
Likely to cause new Flow errors:
voidfollows TypeScript semantics by default and is distinct fromundefined.experimental.ts_voidonly acceptstrue. Runflow codemod migrate-to-ts-voidto help migrate existing code.- Two instantiations of an object type with an index signature are now compared by their index signatures, which can surface errors that were missed.
- Refinements of component and hook props, and other read-only unions, now look into type alias and
Valuesmembers; this can surface errors that were missed. - Exponential-spread errors no longer name the same union operand twice. An error for a spread with a maybe-typed operand can be reported at another operand, as it is for the explicit union.
- Spreads,
Readonly,Partial, React configs and object rest no longer drop the members of a union or intersection that contains another one, which can surface missed errors. - A generic or opaque value passed for a
T | null | voidparameter is narrowed as for?T:Tno longer takes in thenullandvoidof its bound or supertype. - Spread arguments of calls are now contextually typed by the params they fill, like plain arguments, so array literals and callbacks in spread position keep their precision and no longer need annotations. A spread argument can now report the errors the same expression gets as a plain argument.
newof a class whose TypeScript declaration declares a constructor now gives the instance instead ofany- A type
import("m").Xread from another file is no longeranywhenXis a type or has type arguments, and is the instance type whenXis a class, also a class merged with a namespace. - A class extending an intersection, such as tsc's mixin output, now inherits from what its construct signatures return, with the whole intersection as its statics.
- A call can leave out the argument for a trailing element of a fixed-length tuple rest param that accepts
undefined, likeg()forg(...args: [x: void]). Too few or too many arguments for such a rest param are reported as for params (requires another argument,extra-arg) instead ofinvalid-tuple-arity.
New Features:
- Library declare-module blocks will now go through declaration merging.
Notable bug fixes:
- Props can narrow the event of a React event handler they inherit, as in TypeScript.
- Recursive type aliases whose type arguments grow as object, intersection or template literal types no longer hit the recursion limit or overflow the stack.
- Fixed stale errors and a crash after rechecks where a change reaches checked files through node_modules, or a file's imports stop resolving
- Fixed stale duplicate module provider errors after a new provider takes over a Haste module
- Fixed missing and stale package.json parse errors after rechecks
- Values of an opaque type's lower bound now flow into the opaque type after an operation narrows it, when they fit the narrowed type.
- Under
experimental.ts_void, a function that returns no value in one branch of a conditional no longer drops the annotation hint of the other branch. - Refinements, such as sentinel property checks,
inandtypeof, now narrow an opaque type's upper bound and keep the opaque type, as they do for a type parameter. - A type parameter that a call gives no evidence for no longer mentions the other type parameters of the signature in its inferred type.
- When library files declare overloads of the same interface method, the overloads of the one merged later, such as a
[libs]file over a builtin, are tried first. - A library in
[libs]can override a declaration of a bundled.d.tsbuiltin, as it can for the other builtins. - Builtin overloads are tried in TypeScript's order, and Flow's fallback overloads, such as
toSpliced<S>, after TypeScript's. - Changing a file in an import cycle of two files rechecks the files that depend on the cycle
- A
nullorundefinedargument for aT | null | voidparameter givesTanemptybound, as for?T. - Implicit instantiation no longer infers
null | voidfrom aT | null | voidvalue whoseTis not inferred yet. - An element passed to a prop of type
(renders T) | nullinfers its type arguments fromT, as for?renders Tor an optional prop. - With
experimental.normalize_intersections, an intersection of unions withnullandvoidmembers is normalized as one of maybe types is. - An interface in a
declare namespacecan extend another member through the namespace's name without the namespace becomingany - Rechecks no longer miss errors in the dependents of a file whose
requireswitches between modules that a library declares. - Overloaded generic methods declared in TypeScript are compared with their type parameters erased, as in TypeScript.
Omitand other object type utilities no longer give an interface's index signature value to props declared elsewhere on itsextendschain, e.g. an inheritedonFocuswhen the interface has a[key: `data-${string}`]signature.- Error messages no longer print
?for a type with many overloads of a method. - Fixed a crash on a mapped type whose keys refer to the mapped type
- Implicit instantiation infers type arguments through a conditional type whose check type indexes a type parameter, e.g. Lexical's
Klass<T> - A type parameter of a TypeScript-declared generic that no part of a call reaches takes its default or bound, as in TypeScript, instead of being reported as underconstrained.
- Exported mapped types and
keyofover intersection keys such asstring & {}no longer fail signature verification - A conditional type kept abstract over a type parameter now sees the type parameter narrowed by the extends type in its true branch
keyofand mapped types over a class declared in a.d.tsfile now include its methods and inherited members.typeof M.Xandtypeof import("m").Xread a value thatMexports withexport type, as in TypeScript.newon aClassofReadonly<I>,Partial<I>or another sliced interface with aconstructormethod no longer reports thatconstructoris missing.thisin the type parameter bound of adeclare classmethod no longer errors withillegal-this.- A tuple type can end with a spread of a type parameter bounded by a union or intersection of arrays, or of an undecided conditional type whose branches are arrays
- In a tuple type written in TypeScript, spreads of arrays followed by other spreads of arrays or optional elements become one rest element, as in TypeScript
- Read-write elements of TypeScript tuples, including tuple types with spreads, are now compared covariantly, as in TypeScript.
- Class and interface declarations accept getters and setters with computed keys, such as
get [Symbol.toStringTag]() - Fixed a stack overflow on recursive conditional types that stay undecided over a type parameter, like the path types of
react-hook-form - A computed key in a type can name a value imported with
import type, as in TypeScript - Recursive type aliases whose type arguments grow as spread tuple types no longer overflow the stack
export default <name>inside a librarydeclare module, as written in TypeScript.d.tsfiles, now declares the module's default export.- A type parameter bounded by
keyof Tcan index an object keyed bykeyof T, such asRecord<keyof T, V>, whenThas no object bound - An error about an argument from a spread whose type is written in another file is reported at the call instead of in that file.
- Fixed stack overflows and recursion limit errors on property lookups through classes whose base reaches the class itself.
typeofand keys in types read the value of an export that is both a type and a value throughimport type, as in TypeScript- A homomorphic mapped type over an intersection with an array or tuple member, such as a type parameter bounded by
Iterable<unknown> & ReadonlyArray<unknown>, no longer errors - A call of a TypeScript generic under the hint of an enclosing generic call, such as
useState(() => f()), gives a type parameter that nothing reaches its default or bound, as in TypeScript. - Fixed the constructor and member precedence of a class extending a mixin applied to a class, and restored the error codes for classes extending other intersections.
Misc:
- Errors about the keys of an intersection name the union of its keys.
IDE:
- Hover on a type alias looks through aliases of other aliases, and Go to Definition on a qualified type, like
M.Xwithimport * as MorReact.Node, goes to the member's declaration instead of staying on the reference or going to a global with the same name - Hover and error messages print a type declared in a library
declare namespaceunder its qualified name, likeReact.MixedElementorIntl.NumberFormatOptions - Fixed autocomplete, go-to-definition and hover for members of a class extending an intersection or another value with construct signatures.
Library Definitions:
Iterator,IterableandIterableIteratornow defaultTReturnandTNexttoany, as in TypeScript.IteratorObjectnow defaultsTReturnandTNexttounknown, as in TypeScript.- Built-in iterators (arrays, maps, sets, strings, enum
members()) returnundefinedwhen done, as in TypeScript withstrict. - Add the
react/jsx-runtimeandreact/jsx-dev-runtimemodules and React'sFunctionComponentElementandDetailedReactHTMLElementtypes from@types/react