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

[gatsby-link] typescript types collide with @types/react #22754

Closed
JustFly1984 opened this issue Apr 2, 2020 · 7 comments · Fixed by #22770
Closed

[gatsby-link] typescript types collide with @types/react #22754

JustFly1984 opened this issue Apr 2, 2020 · 7 comments · Fixed by #22770
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@JustFly1984
Copy link

JustFly1984 commented Apr 2, 2020

Got this error in attempt to update

node_modules/gatsby-link/index.d.ts:4:18 - error TS2430: Interface 'GatsbyLinkProps<TState>' incorrectly extends interface 'LinkProps<TState>'.
  Types of property 'innerRef' are incompatible.
    Type 'Function | undefined' is not assignable to type '((instance: HTMLAnchorElement | null) => void) | RefObject<HTMLAnchorElement> | null | undefined'.
      Type 'Function' is not assignable to type '((instance: HTMLAnchorElement | null) => void) | RefObject<HTMLAnchorElement> | null | undefined'.
        Property 'current' is missing in type 'Function' but required in type 'RefObject<HTMLAnchorElement>'.

4 export interface GatsbyLinkProps<TState> extends LinkProps<TState> {
                   ~~~~~~~~~~~~~~~

  node_modules/@types/react/index.d.ts:88:18
    88         readonly current: T | null;
                        ~~~~~~~
    'current' is declared here.

gatsby info:

  System:
    OS: macOS 10.15.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.12.0 - ~/.nvm/versions/node/v13.12.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v13.12.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 80.0.3987.149
    Firefox: 74.0
    Safari: 13.1
  npmPackages:
    gatsby: 2.20.10 => 2.20.10
    gatsby-plugin-manifest: 2.3.3 => 2.3.3
    gatsby-plugin-no-sourcemaps: 2.2.0 => 2.2.0
    gatsby-plugin-offline: 3.1.2 => 3.1.2
    gatsby-plugin-purgecss: 5.0.0 => 5.0.0
    gatsby-plugin-react-helmet: 3.2.1 => 3.2.1
    gatsby-plugin-robots-txt: 1.5.0 => 1.5.0
    gatsby-plugin-root-import: 2.0.5 => 2.0.5
    gatsby-plugin-sitemap: 2.3.1 => 2.3.1
    gatsby-plugin-typescript: 2.3.1 => 2.3.1
    gatsby-plugin-webpack-bundle-analyzer: 1.0.5 => 1.0.5
  npmGlobalPackages:
    gatsby: 2.20.10

typescript 3.8.3

@JustFly1984 JustFly1984 added the type: bug An issue or pull request relating to a bug in Gatsby label Apr 2, 2020
@JustFly1984 JustFly1984 changed the title [gatsby-link] typescript types with @types/react [gatsby-link] typescript types collide with @types/react Apr 2, 2020
@JustFly1984
Copy link
Author

attaching the list of all currently existing typescript errors #22070

@JustFly1984
Copy link
Author

JustFly1984 commented Apr 2, 2020

doesnt work actyually!!!
found a temporary fix:

adding in package.json next lines

"resolutions": {
    "@types/reach__router": "1.2.6"
}

As I see types was updated in gatsby-link@2.3.1, but current version of @types/reach__router is 1.3.3, which also gives a conflict with @types/react

@JustFly1984
Copy link
Author

sorry, last fix does not work anymore, cos { useLocation } does not exist on @types/reach__router@1.2.6, so I'm kind of stuck, can't run clean yarn.lock anymore, cos build fails.

@pieh
Copy link
Contributor

pieh commented Apr 2, 2020

Are you able to share your project or at least tsconfig? I tried to reproduce this and other TS problems ( #22706 ), but I just couldn't

@alessbell
Copy link

I just started seeing the exact same error as reported in this issue, repo is here.

@pieh
Copy link
Contributor

pieh commented Apr 2, 2020

Thanks @alessbell! I was able to reproduce and seems like my proposed fix in #22706 (comment) will do the trick

@pieh
Copy link
Contributor

pieh commented Apr 3, 2020

This should be fixed in gatsby@2.20.11 / gatsby-link@2.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants