Answer the question
In order to leave comments, you need to log in
Argument of type '"test"' is not assignable to parameter of type 'never'?
export interface IAuth {
roles: string[];
}
@Module({namespaced: true})
export default class Auth extends VuexModule implements IAuth {
roles = [];
public get addRole(role: string): void {
this.roles.push('test')
export default class Auth extends VuexModule implements IAuth {
roles: string[] = [];
Answer the question
In order to leave comments, you need to log in
Initially, type inference determines whether a field belongs roles = [];
to a type, never[]
which does not lead to an error associated with the implementation of the interface, since the never type is a subtype of all types in typescript. In simple words, in your case, the usual upcasting occurs. If this behavior were different then subtypes would not be compatible with their supertypes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question