mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
66 lines
1.2 KiB
TypeScript
66 lines
1.2 KiB
TypeScript
//// [tests/cases/conformance/jsx/tsxSpreadAttributesResolution5.tsx] ////
|
|
|
|
//// [file.tsx]
|
|
/// <reference path="/.lib/react.d.ts" />
|
|
|
|
import React = require('react');
|
|
|
|
interface PoisonedProp {
|
|
x: string;
|
|
y: 2;
|
|
}
|
|
|
|
class Poisoned extends React.Component<PoisonedProp, {}> {
|
|
render() {
|
|
return <div>Hello</div>;
|
|
}
|
|
}
|
|
|
|
let obj = {
|
|
x: "hello world",
|
|
y: 2
|
|
};
|
|
|
|
// Error as "obj" has type { x: string; y: number }
|
|
let p = <Poisoned {...obj} />;
|
|
|
|
class EmptyProp extends React.Component<{}, {}> {
|
|
render() {
|
|
return <div>Default hi</div>;
|
|
}
|
|
greeting: string;
|
|
}
|
|
|
|
let o = {
|
|
prop1: false
|
|
}
|
|
// Ok
|
|
let e = <EmptyProp {...o} />;
|
|
|
|
//// [file.jsx]
|
|
"use strict";
|
|
/// <reference path="/.lib/react.d.ts" />
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const React = require("react");
|
|
class Poisoned extends React.Component {
|
|
render() {
|
|
return <div>Hello</div>;
|
|
}
|
|
}
|
|
let obj = {
|
|
x: "hello world",
|
|
y: 2
|
|
};
|
|
// Error as "obj" has type { x: string; y: number }
|
|
let p = <Poisoned {...obj}/>;
|
|
class EmptyProp extends React.Component {
|
|
render() {
|
|
return <div>Default hi</div>;
|
|
}
|
|
}
|
|
let o = {
|
|
prop1: false
|
|
};
|
|
// Ok
|
|
let e = <EmptyProp {...o}/>;
|