9b1ba8f1e3
* Fix react-jsx spread children invalid emit * Update Baselines and/or Applied Lint Fixes * Change childrenLength parameter -> isStaticChildren Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
//// [tsxSpreadChildrenInvalidType.tsx]
|
|
declare module JSX {
|
|
interface Element { }
|
|
interface IntrinsicElements {
|
|
[s: string]: any;
|
|
}
|
|
}
|
|
declare var React: any;
|
|
|
|
interface TodoProp {
|
|
id: number;
|
|
todo: string;
|
|
}
|
|
interface TodoListProps {
|
|
todos: TodoProp[];
|
|
}
|
|
function Todo(prop: { key: number, todo: string }) {
|
|
return <div>{prop.key.toString() + prop.todo}</div>;
|
|
}
|
|
function TodoList({ todos }: TodoListProps) {
|
|
return <div>
|
|
{...<Todo key={todos[0].id} todo={todos[0].todo} />}
|
|
</div>;
|
|
}
|
|
function TodoListNoError({ todos }: TodoListProps) {
|
|
// any is not checked
|
|
return <div>
|
|
{...(<Todo key={todos[0].id} todo={todos[0].todo} /> as any)}
|
|
</div>;
|
|
}
|
|
let x: TodoListProps;
|
|
<TodoList {...x}/>
|
|
|
|
|
|
//// [tsxSpreadChildrenInvalidType.js]
|
|
var __assign = (this && this.__assign) || function () {
|
|
__assign = Object.assign || function(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
};
|
|
function Todo(prop) {
|
|
return React.createElement("div", null, prop.key.toString() + prop.todo);
|
|
}
|
|
function TodoList(_a) {
|
|
var todos = _a.todos;
|
|
return React.createElement.apply(React, __spreadArray(["div", null], React.createElement(Todo, { key: todos[0].id, todo: todos[0].todo }), false));
|
|
}
|
|
function TodoListNoError(_a) {
|
|
var todos = _a.todos;
|
|
// any is not checked
|
|
return React.createElement.apply(React, __spreadArray(["div", null], React.createElement(Todo, { key: todos[0].id, todo: todos[0].todo }), false));
|
|
}
|
|
var x;
|
|
React.createElement(TodoList, __assign({}, x));
|