All of a sudden my react typescript project has started rejecting <span>
tags with
TS2339: Property <span> does not exist on type 'JSX.IntrinsicElements'
Every other tag is absolutely fine, but <span>
s any where in my .tsx
files throw this error.
Can anyone advise?
The error "Property does not exist on type 'JSX. IntrinsicElements'" occurs when a component's name starts with a lowercase letter. To solve the error, make sure to always start component names with a capital letter, install the types for React and restart your dev server.
Type Checking For React, intrinsic elements are emitted as strings ( React. createElement("div") ), whereas a component you've created is not ( React. createElement(MyComponent) ). The types of the attributes being passed in the JSX element should be looked up differently.
The error "JSX element type does not have any construct or call signatures" occurs when we try to pass an element or a react component as props to another component but type the prop incorrectly. To solve the error, use the React. ElementType type.
error TS2339: Property 'userLanguage' does not exist on type 'Navigator'. Solution: Check the error message for the correct file and line. Currently typescript does not have userLanguage as a property (tested with typescript up to 2.7.1), although it should already be fixed according to this issue.
To fix the error “TS2339: Property ‘x’ does not exist on type ‘Y’” with TypeScript, we should make sure the properties are listed in the interface that’s set as the type of the object. interface Images { main: string; [key: string]: string; } const getMainImageUrl = (images: Images): string => { return images.main; };
Property 'about-me' does not exist on type 'JSX.IntrinsicElements'. Remember: "item" is not valid in TypeScript, you must declare as "Item", UpperCase the first letter!
When compiled/transpiled through TypeScript it generates error TS2339: Property 'myclassvar' does not exist on type 'MyClass'. If the above code snippet is valid ES6 then TypeScript should not generate the error. The generated javascript it valid. It's just that the error scares the developers trying to use ES6 without typings.
I had the same problem but for me, it was the p
element.
The reason for the error was that I refactored a p
element to h3
for instance and VSCode changed also the type definition.
As you pointed out cleaning the node_modules and doing a fresh npm install
does the trick.
Just wanted to point out what could cause the problem.
Can anyone advise?
import * as React from 'react'
in your filenpm install @types/react
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With