Skip to content

Property 'to' does not exist on type gatsby-link, Typescript #3525

Closed
@Nikki1993

Description

@Nikki1993

Description

Using Typescript with Gatsby, get an error on Link component file:

severity: 'Error'
message: 'Property 'to' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<GatsbyLink> & Readonly<{ children?: ReactNode; }> ...'.'
source: 'ts'

Environment

Gatsby version: 1.9.153
Node.js version: 9.4.0
Operating System: Solus (Linux)

File contents (if changed):

gatsby-config.js:

module.exports = {
  siteMetadata: {
    title: 'MyAwesomeTitle',
  },
  plugins: ['gatsby-plugin-react-helmet', 'gatsby-plugin-typescript'],
};

package.json:

{
  "name": "gatsby-starter-default",
  "description": "Gatsby default starter",
  "version": "1.0.0",
  "author": "Nick",
  "dependencies": {
    "gatsby": "^1.9.153",
    "gatsby-link": "^1.6.34",
    "gatsby-plugin-react-helmet": "^2.0.3",
    "gatsby-plugin-typescript": "^1.4.12",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-helmet": "^5.2.0",
    "styled-components": "^2.4.0"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "main": "n/a",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@types/react": "^16.0.34",
    "@types/react-helmet": "^5.0.3",
    "eslint": "^4.15.0",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.5.1",
    "prettier": "^1.10.2",
    "tslint-react": "^3.4.0"
  }
}

gatsby-node.js: not changed
gatsby-browser.js: not changed
gatsby-ssr.js: not changed

Actual result

TSLint gives an error
'Property 'to' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<GatsbyLink> & Readonly<{ children?: ReactNode; }> ...'.'

Expected behavior

Property 'to' should exist on Link component.

Steps to reproduce

1. Instal typescript and gatsby typescript plugin

2. Import Link component in any file import Link from 'gatsby-link

3. Use 'to' property on link <Link to="/">Go back to the homepage</Link>

4. Get an error from tslint (in my case I used VSCode) about 'to' property

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions