Why tsx doesn't check attribute which has -
in name?
declare namespace JSX {
interface ElementAttributesProperty {
props:any; // specify the property name to use
}
}
class A{
props!:{p1:string}
}
const tsx = <A p1="" p-p2={1} p3=""></A>
p1, good, it has a string value.
p-p2, wrong, it's not defined in class's props, bug there is no ts error.
p3, good, it's not defined in class's props and thrown a ts error.
Why ts doesn't check p-p2?
Typescript skips type checks on attributes with hyphens in order to be more painless with data-
and aria-
attributes. At the time this was implemented into typescript template strings didn't exist, so i wonder if they would do it differently if they were implementing it today.
https://github.com/microsoft/TypeScript/issues/32447#issuecomment-512430295