Skip to content

react-docgen@7.0.0

Compare
Choose a tag to compare
@danez-bot danez-bot released this 19 Oct 15:05
· 442 commits to main since this release
de7b230

Major Changes

  • #846
    82154c3
    Thanks @danez! - getTypeFromReactComponent now
    returns an array of paths to types instead of just one. This can appear when
    multiple type definitions are found for a component, for example:

    const Component: React.FC<Props> = (props: { some: string }) => {};

    In this example both the Props definition as well as { some: string } are
    now found and used.

    Here is a simple diff to illustrate the change when using
    getTypeFromReactComponent:

    const type = getTypeFromReactComponent(path)
    
    -if (type) {
    +if (type.length > 0) {
        // do smth
    }
    
  • #848
    dda8915
    Thanks @danez! - Drop support for Node.js
    version 14.

    The minimum supported version is now 16.14.0

  • #846
    62e692f
    Thanks @danez! - resolveToValue will not resolve
    to ImportDeclaration anymore but instead to one of the possible specifiers
    (ImportSpecifier, ImportDefaultSpecifier or ImportNamespaceSpecifier).
    This gives better understanding to which specifier exactly resolveToValue
    did resolve a NodePath to.

    Here is a possible easy fix for this in a code snippet that uses
    resolveToValue

    const resolved = resolveToValue(path);
    
    -if (resolved.isImportDeclaration()) {
    +if (resolved.parentPath?.isImportDeclaration()) {
        // do smth
    }

Minor Changes

  • #862
    40ebb00
    Thanks @danez! - Support PropsWithoutRef,
    PropsWithRef and PropsWithChildren in TypeScript.

    Component props are now detected correctly when these builtin types are used,
    but they do currently not add any props to the documentation.

  • #846
    82154c3
    Thanks @danez! - Add support for React.FC in
    TypeScript.

Patch Changes

  • 6312f2f
    Thanks @renovate[bot]! - update
    dependency @types/doctrine to ^0.0.7

  • #846
    c01d1a0
    Thanks @danez! - Fix detection of react class
    components when super class is imported via named import.

  • #861
    74b6680
    Thanks @renovate! - update dependency
    @types/doctrine to ^0.0.8

  • #846
    0641700
    Thanks @danez! - Remove unnecessary call to
    resolveToValue when trying to find props type from react components.

  • #858
    3be404e
    Thanks @danez! - Fix detection of React.Children
    with ESM imports