Typescript prop errors
See original GitHub issueRunning into some type issues but a basic button that has props passed through
I’m using the default next.js typescript configuration
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
React component throwing TypeScript error for function ...
The first param to Component type is props type , and you have not defined it, therefore the error. Define a interface,
Read more >Error Boundaries - React TypeScript Cheatsheets
Option 1: Using react-error-boundary. ... class ErrorBoundary extends Component<Props, State> { public state: State = { hasError: false } ...
Read more >Typescript suddenly started to error on missing props for many ...
It failed with an error regarding missing props on many Drei components. I'm fairly sure that I didn't change anything else and these...
Read more >React & TypeScript
You will get the following TypeScript error. Property 'name' is missing in type '{}' but required in type 'Props'.
Read more >Documentation - JSX - TypeScript
As the name suggests, the component is defined as a JavaScript function where its first argument is a props object. TS enforces that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Using
type
instead of aninterface
worksThis appears to be an issue with newer versions of Typescript (4.5+) - I’m not seeing this error on 4.3.2. TS 4.5 has a new feature, “Template String Types as Discriminants”, so it’s now parsing this:
In a smarter way. Unfortunately, for those of us using interfaces, those aren’t working because interfaces cannot extend records with templated keys. Immediate solutions are:
TransientProps
Solutions for the lib:
TransientProps
to: (adding that| string
to the key)