mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
//// [tests/cases/conformance/jsx/tsxAttributeResolution14.tsx] ////
|
|
|
|
//// [react.d.ts]
|
|
declare namespace JSX {
|
|
interface Element { }
|
|
interface IntrinsicElements {
|
|
div: any;
|
|
}
|
|
interface ElementAttributesProperty { prop: any }
|
|
}
|
|
|
|
//// [file.tsx]
|
|
interface IProps {
|
|
primaryText: string,
|
|
[propName: string]: string | number
|
|
}
|
|
|
|
function VerticalNavMenuItem(prop: IProps) {
|
|
return <div>props.primaryText</div>
|
|
}
|
|
|
|
function VerticalNav() {
|
|
return (
|
|
<div>
|
|
<VerticalNavMenuItem primaryText={2} /> // error
|
|
<VerticalNavMenuItem justRandomProp={2} primaryText={"hello"} /> // ok
|
|
<VerticalNavMenuItem justRandomProp1={true} primaryText={"hello"} /> // error
|
|
</div>
|
|
)
|
|
}
|
|
|
|
//// [file.jsx]
|
|
"use strict";
|
|
function VerticalNavMenuItem(prop) {
|
|
return <div>props.primaryText</div>;
|
|
}
|
|
function VerticalNav() {
|
|
return (<div>
|
|
<VerticalNavMenuItem primaryText={2}/> // error
|
|
// error
|
|
<VerticalNavMenuItem justRandomProp={2} primaryText={"hello"}/> // ok
|
|
// ok
|
|
<VerticalNavMenuItem justRandomProp1={true} primaryText={"hello"}/> // error
|
|
// error
|
|
</div>);
|
|
}
|