DEV Community

Discussion on: How to setup GatsbyJS starter with Typescript, ESLint, Prettier

Collapse
 
wbali profile image
Balázs

Add "noImplicitAny": false to your tsconfig file, inside compilerOptions.

Collapse
 
attkinsonjakob profile image
Jakob Attkinson

This would just disable the notification, not fix the actual problem. Is this correct?

Thread Thread
 
wbali profile image
Balázs • Edited

Sorry, yes. The TypeScript way is to set a type (or any) for your props like so:
type DataProps = { siteTitle: string }
const SomeComponent: React.FC<DataProps> = ({ siteTitle } => { ... }

Edit: For pages you should also use Gatsby's PageProps:
const SomePage: React.FC<PageProps<DataProps>> = ({ data, path }) => (
<>
<h1>{data.siteTitle}</h1>
<span>current page path {path}</span>
</>
)