Major Changes
-
d7a39af: Refactored
resolveComponentDefinition
utility.- Renamed to
findComponentDefinition
- Removed named export
isComponentDefinition
- The utility now does a lot more than previously, check out the commit to see
the changes in detail.
- Renamed to
-
e956802: Remove match utility.
The utility can be replaced by babel helpers and is not needed anymore. Also
using explicit checks likepath.isMemberExpression()
is better for type
safety and catching potential bugs. -
5215bab: Removed support for the
@extends React.Component
annotation on
react class components.Instead you can use the new
@component
annotation. -
80e4c74: Renamed and migrated built-in resolvers to classes.
-
findAllComponentDefinitions
was renamed toFindAllDefinitionsResolver
and is now a class.-const resolver = builtinResolvers.findAllComponentDefinitions +const resolver = new builtinResolvers.FindAllDefinitionsResolver()
-
findAllExportedComponentDefinitions
was renamed to
FindExportedDefinitionsResolver
and is now a class.-const resolver = builtinResolvers.findAllExportedComponentDefinitions +const resolver = new builtinResolvers.FindExportedDefinitionsResolver()
-
findExportedComponentDefinition
was removed. Use
FindExportedDefinitionsResolver
with thelimit
option instead.This is still the default resolver.
-const resolver = builtinResolvers.findExportedComponentDefinition +const resolver = new builtinResolvers.FindExportedDefinitionsResolver({ limit: 1 })
-
Minor Changes
-
80e4c74: Add the new ChainResolver which allows multiple resolvers to be
chained.import { builtinResolvers } from 'react-docgen'; const { ChainResolver } = builtinResolvers; const resolver = new ChainResolver([resolver1, resolver2], { chainingLogic: ChainResolver.Logic.ALL, // or ChainResolver.Logic.FIRST_FOUND, });
-
80e4c74: Allow resolvers to be classes in addition to functions.
import type { ResolverClass, ResolverFunction } from 'react-docgen'; // This was the only option until now const functionResolver: ResolverFunction = (file: FileState) => { //needs to return array of found components }; // This is the new class resolver class MyResolver implements ResolverClass { resolve(file: FileState) { //needs to return array of found components } } const classResolver = new MyResolver();
-
5215bab: Added a new resolver that finds annotated components. This resolver
is also enabled by default.To use this feature simply annotated a component with
@component
.// @component class MyComponent {}
Patch Changes
- 8fe3dbf: Fix crash when using TypeScript mapped types
- ea25b16: Handle cyclic references in PropTypes
shape()
andexact()
methods. - 1aa0249: Handle
typeof import('...')
andtypeof MyType.property
correctly
in TypeScript - 050313d: Correctly add LICENSE file to published packages
- f6e4fe7: Update dependency strip-indent to v4