Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic type 'UIEvent<T>' requires between 0 and 1 type arguments. #4174

Closed
luciancaetano opened this issue Jun 11, 2020 · 6 comments
Closed

Comments

@luciancaetano
Copy link

luciancaetano commented Jun 11, 2020

Environment

  • Package version(s):
    "@blueprintjs/core": "^3.28.2"
    "@blueprintjs/icons": "^3.18.1"
    "react": "^16.13.1"
  • Operating System: Linux
  • Browser name and version: Google Chrome 83.0

Actual behavior

Outdated types

ERROR in [at-loader] ./node_modules/@blueprintjs/core/lib/esm/components/divider/divider.d.ts:258:28
TS2707: Generic type 'UIEvent' requires between 0 and 1 type arguments.

ERROR in [at-loader] ./node_modules/@blueprintjs/core/lib/esm/components/divider/divider.d.ts:259:35
TS2707: Generic type 'UIEvent' requires between 0 and 1 type arguments.

@adidahiya
Copy link
Contributor

@luciancaetano what version of typescript and @types/react do you have installed?

@luciancaetano
Copy link
Author

luciancaetano commented Jun 11, 2020

@adidahiya I am using the default version automatically installed when I run the npm install command 16.9.11

@adidahiya
Copy link
Contributor

And which version of typescript?

If you can demonstrate the issue with a code sandbox (as linked in the issue template), it helps me debug issues much faster.

@Seiyial
Copy link

Seiyial commented Jun 13, 2020

Hi @adidahiya,

I'm facing this issue after bumping my react and react-dom @types versions, as well as typescript version.

Here's a codesandbox showing the dependencies list, but I'm not sure if it shows typescript type errors that we're experiencing...
https://codesandbox.io/s/focused-resonance-147bg?file=/package.json

Environment

  • Package version(s):
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-scripts": "3.0.1",
    "@blueprintjs/core": "3.28.2",
    "@blueprintjs/datetime": "3.18.2",
    "@blueprintjs/icons": "3.18.1",
    "@blueprintjs/select": "3.13.3"

    "typescript": "3.9.5",
    "@types/react": "16.9.19",
    "@types/react-dom": "16.9.8"

  • tsconfig.json:

    {
      "compilerOptions": {
          "outDir": "./dist/",
          "sourceMap": true,
          "strict": true,
          "noImplicitReturns": true,
          "noImplicitAny": true,
          "module": "es6",
          "moduleResolution": "node",
          "allowSyntheticDefaultImports": true,
          "target": "es5",
          "allowJs": true,
          "jsx": "react",
          "baseUrl": "src/",
          "suppressExcessPropertyErrors": false
        },
        "include": [
          "./src/**/*",
          "./.eslintrc.js",
          "*.js"
        ],
     }
  • Operating System: Linux

  • Browser name and version: Google Chrome 83.0

Upon building, typescript returns the same errors as mentioned above:

ERROR in /redacted/MyProject/node_modules/@blueprintjs/core/lib/esm/components/divider/divider.d.ts(258,28):
TS2707: Generic type 'UIEvent<T>' requires between 0 and 1 type arguments.
ERROR in /redacted/MyProject/node_modules/@blueprintjs/core/lib/esm/components/divider/divider.d.ts(259,35):
TS2707: Generic type 'UIEvent<T>' requires between 0 and 1 type arguments.
Version: typescript 3.9.5
Time: 19426 ms

TL;DR: I think it happens because there are changes in (or before) @types/react 16.9.19 that caused a typing mismatch when it is used with @blueprintjs/core 3.28.2. Details below

Tracing and solution(s)

(note: in these pictures, the breadcrumbs (x > y > z) show the files being referred to)

The error seems to occur in MyProject/node_modules/@blueprintjs/core3.28.2/lib/esm/components/divider/divider.d.ts:

image

If I "Go To Definition" of UIEvent...

My VSCode says this file is MyProject/node_modules/@types/react16.9.19/index.d.ts. It seems to me that in @types/react 16.9.19, UIEvent only needs the HTMLElement as the type parameter, and repeating UIEvent as above is not needed anymore.

By changing the typing of onScroll and onScrollCapture to remove the additional UIEvent, the type error for my app's build is fixed.

MyProject/node_modules/@blueprintjs/core/lib/esm/components/divider/divider.d.ts

Sorry if I should have been following a certain template or if it's possible to have provided a more extensive demo in codesandbox.

@benritteraptiv
Copy link

I've started seeing this exact issue as well. Did a clean reinstall recently and it started popping up.

"@blueprintjs/core": "3.17.1",
"@blueprintjs/datetime": "3.11.0",
"@blueprintjs/docs-theme": "^3.4.0",
"@blueprintjs/icons": "3.9.1",
"@blueprintjs/select": "3.8.0",

"react": "16.8.6",
"react-dom": "16.8.6",
"@types/react": "16.8.23",
"@types/react-dom": "16.8.5",
"typescript": "3.8.3",

@adidahiya
Copy link
Contributor

Can you all try upgrading to the latest @types/react, or at a minimum the version which is installed in this repo (16.9.35)? There may have been a breaking change in the types. If so, that's an unfortunate unintended break in our API, but a little hard to avoid and I think these kinds of breaks will continue happening every now and then. My best advice is to stay up to date on the latest @types/react version.

mteichtahl added a commit to aws/aws-northstar that referenced this issue Feb 17, 2021
(palantir/blueprint#4174)

"@types/react": "^17.0.2"
"@types/react-dom": "^17.0.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants