gregberge / loadable-components

The recommended Code Splitting library for React ✂️✨
https://loadable-components.com
MIT License
7.66k stars 380 forks source link

lazy typescript definition missing options argument: Expected 1 argument, but got 2 #958

Open viveleroi opened 1 year ago

viveleroi commented 1 year ago

🐛 Bug Report

I've switched a loadable code to lazy so that I can use react suspense, per your website docs.

While everything still works, typescript is throwing an error that lazy only accepts one argument.

Error: Expected 1 argument, but got 2

To Reproduce

const Component = lazy(
  () =>
    pMinDelay(
      import(`./modules/${module.folderName}/${submodule.folderName}/${submodule.folderName}.tsx`),
      200
    ),
  {
    resolveComponent: components => components[submodule.componentName]
  }
)

Expected behavior

No typescript errors.

Run npx envinfo --system --binaries --npmPackages @loadable/component,@loadable/server,@loadable/webpack-plugin,@loadable/babel-plugin --markdown --clipboard

Paste the results here:

## System:
 - OS: Windows 10 10.0.22000
 - CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
 - Memory: 14.79 GB / 31.73 GB
## Binaries:
 - Node: 18.9.1 - C:\Program Files\nodejs\node.EXE
 - Yarn: 3.3.1 - C:\Program Files\nodejs\yarn.CMD
 - npm: 8.19.1 - C:\Program Files\nodejs\npm.CMD
## npmPackages:
 - @loadable/component: ^5.15.3 => 5.15.3 
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

viveleroi commented 1 year ago

Not stale, needs to be addressed