Skip to content
Advertisement

TypeScript Argument of type ‘IAccount’ is not assignable to parameter of type ‘never’

I am getting the above error when using the following types:

JavaScript

I am trying to initialize an account in my JSON file inside of a class constructor:

JavaScript

I have tried to get this to work in multiple ways, I feel like I am missing something in the interface definitions.

Advertisement

Answer

You need to specify the type of accountsObj. Otherwise Typescript will not know the correct type and will asign { accounts: never[] } based on the assigned object to it.

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