You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TSX: Property does not exist on type 'JSX.IntrinsicElements' #15449
test.tsx(11,22): error TS2339: Property 'heyo' does not exist on type 'JSX.IntrinsicElements'.
test.tsx(11,31): error TS2339: Property 'heyo' does not exist on type 'JSX.IntrinsicElements'.
For anyone else who might find this issue as a solution to custom tags in the future. In addition to Matt Haggard (@iffy) and Ryan Cavanaugh (@RyanCavanaugh) global namespace solution, you can declare your custom element type like this:
import * as React from 'react';
declare global {
namespace JSX {
interface IntrinsicElements {
'my-html-custom-tag': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}
In order to get better type/property checking and code completion on your custom tags
Reacted by Matt Haggard, Nathaniel H, Robbert Halff and elpik
@TheAfterman Can you help me modify your solution to work with components such as <Button/> from the antd library? (https://ant.design/components/button/#API) It says that
<Button>Hello world!</Button> will be rendered into <button><span>Hello world!</span></button>, and all the properties which are not listed above will be transferred to the <button> tag.
but the typings don't support additional tags for this component so I get this error Property 'title' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<{ children?: ReactNode; }> & Re...'
Activity
luca-moser commentedon Apr 28, 2017
TypeScript Version: 2.3.1
Same error here, my React components are suddenly all "wrong":
error:
iffy commentedon Apr 28, 2017
Luca Moser (@luca-moser) what version of TypeScript was it last working on?
iffy commentedon Apr 28, 2017
Okay, I found out how to fix this. Instead of putting the
declareline in the.tsxfile, I have two files:The command:
tsc --jsx react --module "amd" --target es2017 test.tsx test.d.tssucceeds.RyanCavanaugh commentedon Apr 28, 2017
You can also put that second block inside
declare global { namespace JSX { ... ... ... } }instead of its own filekherock commentedon May 1, 2017
Luca Moser (@luca-moser) your issue isn't really the same. Yours is a bug in TS and will be fixed with #13288. In the meantime you should stay on 2.2.
stereobooster commentedon Feb 20, 2018
I get
Not sure where to report this. Solution
SamihIsHis commentedon May 2, 2018
For anyone else who might find this issue as a solution to custom tags in the future. In addition to Matt Haggard (@iffy) and Ryan Cavanaugh (@RyanCavanaugh) global namespace solution, you can declare your custom element type like this:
In order to get better type/property checking and code completion on your custom tags
ackvf commentedon May 4, 2018
@TheAfterman Can you help me modify your solution to work with components such as
<Button/>from the antd library? (https://ant.design/components/button/#API) It says thatbut the typings don't support additional tags for this component so I get this error
Property 'title' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<{ children?: ReactNode; }> & Re...'