Type 'string' is not assignable to type' never'.

problem description

this error was reported when I was working on the project today. I don"t know much about Ts at the beginning. Please advise
Type "string" is not assignable to type" never"

.

the environmental background of the problems and what methods you have tried

about the scenario of using ant pro to write charts

related codes

/ / Please paste the code text below (do not replace the code with pictures)

for (let I = 0; I < 20; I + = 1) {
visitData.push ({

)
x: moment(new Date(beginDay + (1000 * 60 * 60 * 24 * i))).format("YYYY-MM-DD"),
y: Math.floor(Math.random() * 100) + 10,

});
}

what result do you expect? What is the error message actually seen?

I want to solve this error Type "string" is not assignable to type" never"

Apr.16,2022

The

never type is a subtype of any type and can be assigned to any type; however, no type is a subtype of never or can be assigned to a never type (except never itself). Even any cannot be assigned to never.

you assign a value of type String to a variable of type Never.


solved the problem by setting it to: any

Menu