Skip to content
Advertisement

Typescript – Type X is missing the following properties from type X

The following code doesn’t work:

JavaScript

I get a type error from Typescript, which is:

JavaScript

It looks like the Screen type is incompatible with itself? How is this possible? I’m using Node 14.15 and my dependency versions are:

JavaScript

Why doesn’t this pass type checking?

Advertisement

Answer

When you see this sort of error it’s almost always because you have two types from two different packages which just so happen to share the same name. Here you have a function which returns a type blessed.Widgets.Screen and you are assigning it to the type Screen which is included in the global namespace by the typescript DOM typings.

Since your Screen is the one from “blessed” rather than the one from the DOM, you need to import the type definition from the blessed package.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement