I am getting a typescript error from the following code:
if (this.$route?.query?.domainName) {
this.setDomain(this.$route.query.domainName);
}
The above code throws the following error:
Typescript - Argument of type 'string | (string | null)[]' is not assignable to parameter of type 'string'
if (this.$route?.query?.domainName) {
this.setDomain(this.$route.query.domainName);
^
}
My setDomain function just accepts a parameter of type string like so:
setDomain(domain: string) {
this.domainName = domain;
}
I don't understand how the parameter could ever be null as I am checking the object property exists using the nested ? after the object properties in the if statement. Why would it be throwing this error?