-
|
Here is an example from the documentation of how to use references: If I want to enable runtime type checking like this: I'm getting following typescript errors: Do you have any idea how to resolve this issue? |
Beta Was this translation helpful? Give feedback.
Answered by
mvladic
Feb 26, 2023
Replies: 2 comments
-
|
That's because there's a cyclic dependency between the TodoList type and the todoRef type // add the return type here to fix the dependency
resolve(ref): Todo | undefined {
const todoList = findParent<TodoList>(
ref,
// add this to disable the eslint warning
// eslint-disable-next-line @typescript-eslint/no-use-before-define
(n) => n instanceof TodoList
);
if (!todoList) return undefined;
return todoList.list.find((todo: Todo) => todo.id === ref.id);
}, |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thanks, I added an explicit type annotation for |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mvladic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Thanks, I added an explicit type annotation for
todoRefwhich solved the problem: