diff --git a/.changeset/brave-cases-obey.md b/.changeset/brave-cases-obey.md new file mode 100644 index 00000000000..1b74cded391 --- /dev/null +++ b/.changeset/brave-cases-obey.md @@ -0,0 +1,5 @@ +--- +'react-docgen': patch +--- + +Do not fail on new VoidPattern type diff --git a/packages/react-docgen/package.json b/packages/react-docgen/package.json index fb740e14e15..2c5d5786507 100644 --- a/packages/react-docgen/package.json +++ b/packages/react-docgen/package.json @@ -39,11 +39,11 @@ ], "license": "MIT", "dependencies": { - "@babel/core": "^7.18.9", - "@babel/traverse": "^7.18.9", - "@babel/types": "^7.18.9", - "@types/babel__core": "^7.18.0", - "@types/babel__traverse": "^7.18.0", + "@babel/core": "^7.28.0", + "@babel/traverse": "^7.28.0", + "@babel/types": "^7.28.2", + "@types/babel__core": "^7.20.5", + "@types/babel__traverse": "^7.20.7", "@types/doctrine": "^0.0.9", "@types/resolve": "^1.20.2", "doctrine": "^3.0.0", diff --git a/packages/react-docgen/src/utils/getParameterName.ts b/packages/react-docgen/src/utils/getParameterName.ts index 1107cbfe2cd..c619d02691a 100644 --- a/packages/react-docgen/src/utils/getParameterName.ts +++ b/packages/react-docgen/src/utils/getParameterName.ts @@ -1,22 +1,8 @@ import type { NodePath } from '@babel/traverse'; -import type { - ArrayPattern, - AssignmentPattern, - Identifier, - ObjectPattern, - RestElement, - TSParameterProperty, -} from '@babel/types'; +import type { FunctionParameter, TSParameterProperty } from '@babel/types'; import printValue from './printValue.js'; -type ParameterNodePath = NodePath< - | ArrayPattern - | AssignmentPattern - | Identifier - | ObjectPattern - | RestElement - | TSParameterProperty ->; +type ParameterNodePath = NodePath; export default function getParameterName( parameterPath: ParameterNodePath, @@ -36,10 +22,13 @@ export default function getParameterName( )}`; } else if (parameterPath.isTSParameterProperty()) { return getParameterName(parameterPath.get('parameter')); + // @ts-expect-error isVoidPattern is not yet in types + } else if (parameterPath.isVoidPattern()) { + return 'void'; } throw new TypeError( 'Parameter name must be one of Identifier, AssignmentPattern, ArrayPattern, ' + - `ObjectPattern or RestElement, instead got ${parameterPath.node.type}`, + `ObjectPattern, RestElement, or VoidPattern instead got ${parameterPath.node.type}`, ); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79df9c3ad11..b019df41a62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,19 +96,19 @@ importers: packages/react-docgen: dependencies: '@babel/core': - specifier: ^7.18.9 - version: 7.27.7 + specifier: ^7.28.0 + version: 7.28.0 '@babel/traverse': - specifier: ^7.18.9 - version: 7.27.7 + specifier: ^7.28.0 + version: 7.28.0 '@babel/types': - specifier: ^7.18.9 - version: 7.27.7 + specifier: ^7.28.2 + version: 7.28.2 '@types/babel__core': - specifier: ^7.18.0 + specifier: ^7.20.5 version: 7.20.5 '@types/babel__traverse': - specifier: ^7.18.0 + specifier: ^7.20.7 version: 7.20.7 '@types/doctrine': specifier: ^0.0.9 @@ -232,18 +232,26 @@ packages: resolution: {integrity: sha512-xgu/ySj2mTiUFmdE9yCMfBxLp4DHd5DwmbbD05YAuICfodYT3VvRxbrh81LGQ/8UpSdtMdfKMn3KouYDX59DGQ==} engines: {node: '>=6.9.0'} - '@babel/core@7.27.7': - resolution: {integrity: sha512-BU2f9tlKQ5CAthiMIgpzAh4eDTLWo1mqi9jqE2OxMG0E/OM199VJt2q8BztTxpnSW0i1ymdwLXRJnYzvDM5r2w==} + '@babel/core@7.28.0': + resolution: {integrity: sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==} engines: {node: '>=6.9.0'} '@babel/generator@7.27.5': resolution: {integrity: sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw==} engines: {node: '>=6.9.0'} + '@babel/generator@7.28.0': + resolution: {integrity: sha512-lJjzvrbEeWrhB4P3QBsH7tey117PjLZnDbLiQEKjQ/fNJTjuq4HSqgFA+UNSwZT8D7dxxbnuSBMsa1lrWzKlQg==} + engines: {node: '>=6.9.0'} + '@babel/helper-compilation-targets@7.27.2': resolution: {integrity: sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==} engines: {node: '>=6.9.0'} + '@babel/helper-globals@7.28.0': + resolution: {integrity: sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==} + engines: {node: '>=6.9.0'} + '@babel/helper-module-imports@7.27.1': resolution: {integrity: sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==} engines: {node: '>=6.9.0'} @@ -275,6 +283,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + '@babel/parser@7.28.0': + resolution: {integrity: sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==} + engines: {node: '>=6.0.0'} + hasBin: true + '@babel/runtime@7.27.6': resolution: {integrity: sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==} engines: {node: '>=6.9.0'} @@ -283,12 +296,12 @@ packages: resolution: {integrity: sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==} engines: {node: '>=6.9.0'} - '@babel/traverse@7.27.7': - resolution: {integrity: sha512-X6ZlfR/O/s5EQ/SnUSLzr+6kGnkg8HXGMzpgsMsrJVcfDtH1vIp6ctCN4eZ1LS5c0+te5Cb6Y514fASjMRJ1nw==} + '@babel/traverse@7.28.0': + resolution: {integrity: sha512-mGe7UK5wWyh0bKRfupsUchrQGqvDbZDbKJw+kcRGSmdHVYrv+ltd0pnpDTVpiTqnaBru9iEvA8pz8W46v0Amwg==} engines: {node: '>=6.9.0'} - '@babel/types@7.27.7': - resolution: {integrity: sha512-8OLQgDScAOHXnAz2cV+RfzzNMipuLVBz2biuAJFMV9bfkNf393je3VM8CLkjQodW5+iWsSJdSgSWT6rsZoXHPw==} + '@babel/types@7.28.2': + resolution: {integrity: sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==} engines: {node: '>=6.9.0'} '@bcoe/v8-coverage@0.2.3': @@ -814,6 +827,9 @@ packages: '@jridgewell/gen-mapping@0.3.11': resolution: {integrity: sha512-C512c1ytBTio4MrpWKlJpyFHT6+qfFL8SZ58zBzJ1OOzUEjHeF1BtjY2fH7n4x/g2OV/KiiMLAivOp1DXmiMMw==} + '@jridgewell/gen-mapping@0.3.12': + resolution: {integrity: sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==} + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -2871,10 +2887,6 @@ packages: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Glob versions prior to v9 are no longer supported - globals@11.12.0: - resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} - engines: {node: '>=4'} - globals@14.0.0: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} @@ -5241,18 +5253,18 @@ snapshots: '@babel/compat-data@7.27.7': {} - '@babel/core@7.27.7': + '@babel/core@7.28.0': dependencies: '@ampproject/remapping': 2.3.0 '@babel/code-frame': 7.27.1 - '@babel/generator': 7.27.5 + '@babel/generator': 7.28.0 '@babel/helper-compilation-targets': 7.27.2 - '@babel/helper-module-transforms': 7.27.3(@babel/core@7.27.7) + '@babel/helper-module-transforms': 7.27.3(@babel/core@7.28.0) '@babel/helpers': 7.27.6 - '@babel/parser': 7.27.7 + '@babel/parser': 7.28.0 '@babel/template': 7.27.2 - '@babel/traverse': 7.27.7 - '@babel/types': 7.27.7 + '@babel/traverse': 7.28.0 + '@babel/types': 7.28.2 convert-source-map: 2.0.0 debug: 4.4.1 gensync: 1.0.0-beta.2 @@ -5264,11 +5276,19 @@ snapshots: '@babel/generator@7.27.5': dependencies: '@babel/parser': 7.27.7 - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 '@jridgewell/gen-mapping': 0.3.11 '@jridgewell/trace-mapping': 0.3.28 jsesc: 3.1.0 + '@babel/generator@7.28.0': + dependencies: + '@babel/parser': 7.28.0 + '@babel/types': 7.28.2 + '@jridgewell/gen-mapping': 0.3.12 + '@jridgewell/trace-mapping': 0.3.28 + jsesc: 3.1.0 + '@babel/helper-compilation-targets@7.27.2': dependencies: '@babel/compat-data': 7.27.7 @@ -5277,19 +5297,21 @@ snapshots: lru-cache: 5.1.1 semver: 6.3.1 + '@babel/helper-globals@7.28.0': {} + '@babel/helper-module-imports@7.27.1': dependencies: - '@babel/traverse': 7.27.7 - '@babel/types': 7.27.7 + '@babel/traverse': 7.28.0 + '@babel/types': 7.28.2 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.27.3(@babel/core@7.27.7)': + '@babel/helper-module-transforms@7.27.3(@babel/core@7.28.0)': dependencies: - '@babel/core': 7.27.7 + '@babel/core': 7.28.0 '@babel/helper-module-imports': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 - '@babel/traverse': 7.27.7 + '@babel/traverse': 7.28.0 transitivePeerDependencies: - supports-color @@ -5302,33 +5324,37 @@ snapshots: '@babel/helpers@7.27.6': dependencies: '@babel/template': 7.27.2 - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 '@babel/parser@7.27.7': dependencies: - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 + + '@babel/parser@7.28.0': + dependencies: + '@babel/types': 7.28.2 '@babel/runtime@7.27.6': {} '@babel/template@7.27.2': dependencies: '@babel/code-frame': 7.27.1 - '@babel/parser': 7.27.7 - '@babel/types': 7.27.7 + '@babel/parser': 7.28.0 + '@babel/types': 7.28.2 - '@babel/traverse@7.27.7': + '@babel/traverse@7.28.0': dependencies: '@babel/code-frame': 7.27.1 - '@babel/generator': 7.27.5 - '@babel/parser': 7.27.7 + '@babel/generator': 7.28.0 + '@babel/helper-globals': 7.28.0 + '@babel/parser': 7.28.0 '@babel/template': 7.27.2 - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 debug: 4.4.1 - globals: 11.12.0 transitivePeerDependencies: - supports-color - '@babel/types@7.27.7': + '@babel/types@7.28.2': dependencies: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 @@ -5896,6 +5922,11 @@ snapshots: '@jridgewell/sourcemap-codec': 1.5.3 '@jridgewell/trace-mapping': 0.3.28 + '@jridgewell/gen-mapping@0.3.12': + dependencies: + '@jridgewell/sourcemap-codec': 1.5.3 + '@jridgewell/trace-mapping': 0.3.28 + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/sourcemap-codec@1.5.3': {} @@ -6337,23 +6368,23 @@ snapshots: '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.27.7 - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 '@types/babel__generator': 7.27.0 '@types/babel__template': 7.4.4 '@types/babel__traverse': 7.20.7 '@types/babel__generator@7.27.0': dependencies: - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 '@types/babel__template@7.4.4': dependencies: '@babel/parser': 7.27.7 - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 '@types/babel__traverse@7.20.7': dependencies: - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 '@types/chai@5.2.2': dependencies: @@ -7920,8 +7951,8 @@ snapshots: estree-to-babel@3.2.1: dependencies: - '@babel/traverse': 7.27.7 - '@babel/types': 7.27.7 + '@babel/traverse': 7.28.0 + '@babel/types': 7.28.2 c8: 7.14.0 transitivePeerDependencies: - supports-color @@ -8223,8 +8254,6 @@ snapshots: once: 1.4.0 path-is-absolute: 1.0.1 - globals@11.12.0: {} - globals@14.0.0: {} globals@15.15.0: {} @@ -8890,7 +8919,7 @@ snapshots: magicast@0.3.5: dependencies: '@babel/parser': 7.27.7 - '@babel/types': 7.27.7 + '@babel/types': 7.28.2 source-map-js: 1.2.1 make-dir@4.0.0: @@ -9996,7 +10025,7 @@ snapshots: react-docgen@5.4.3: dependencies: - '@babel/core': 7.27.7 + '@babel/core': 7.28.0 '@babel/generator': 7.27.5 '@babel/runtime': 7.27.6 ast-types: 0.14.2 @@ -10011,9 +10040,9 @@ snapshots: react-docgen@6.0.0: dependencies: - '@babel/core': 7.27.7 - '@babel/traverse': 7.27.7 - '@babel/types': 7.27.7 + '@babel/core': 7.28.0 + '@babel/traverse': 7.28.0 + '@babel/types': 7.28.2 '@types/babel__core': 7.20.5 '@types/babel__traverse': 7.20.7 '@types/doctrine': 0.0.5