Files
tsgo/testdata/baselines/reference/compiler/infiniteRecursionDestructuringLoop.errors.txt

46 lines
2.5 KiB
Plaintext

infiniteRecursionDestructuringLoop.ts(11,17): error TS7022: 'children' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
infiniteRecursionDestructuringLoop.ts(11,27): error TS7022: 'index' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
infiniteRecursionDestructuringLoop.ts(27,17): error TS7022: 'children' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
infiniteRecursionDestructuringLoop.ts(27,27): error TS7022: 'index' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
==== infiniteRecursionDestructuringLoop.ts (4 errors) ====
// Repro from https://github.com/microsoft/TypeScript/issues/63192
interface Node {
children?: readonly Node[];
index?: number;
}
function IterateNodes(data: { node: Node }) {
let node: Node | undefined = data.node;
while (node) {
const { children, index = -1 } = node;
~~~~~~~~
!!! error TS7022: 'children' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
~~~~~
!!! error TS7022: 'index' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
const activeNode: Node | undefined = index != -1 && children ? children[index] : undefined;
node = activeNode;
}
}
// Simplified repro
interface MyNode {
children: MyNode[];
index?: number;
}
function f(init: MyNode) {
let node: MyNode | undefined = init;
while (node) {
const { children, index = 0 } = node;
~~~~~~~~
!!! error TS7022: 'children' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
~~~~~
!!! error TS7022: 'index' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
node = children[index];
}
}