1

I have a function that requires to pass a Node or the window object. My types for this function are:

function myFunc(node: Node | window): void; 

However, when I run this, it complains:

'window' refers to a value, but is being used as a type here.

Well I cannot argue with that, but thats what I need. How do I solve this in typescript?

1 Answer 1

2

The type of window is Window:

function myFunc(node: Node | Window): void { } myFunc(window); 

Playground Link

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.