Title rewritten as: Property does not exist on type 'Registration': Error: Property does not exist on type 'Registration'.ts(2339)
P粉798010441
P粉798010441 2023-12-23 14:41:03
0
1
411

I am developing using JavaScript and Typescript. I have the following function to check if an array has duplicates, but I'm getting an error and not sure how to fix it. Below are the errors and code excerpts.

Error: Property 'toLocaleLowerCase' does not exist on type 'Registration'. ts(2339)

Registration.ts

export interface Registration {
   address: string;
   comment?: string;
   fullname?: string;
  }

JS file

const nameAlreadyExist = (name: any): void => {
    const nameExist = filteredRegistrationName.value.findIndex((registrationName) => 
       registrationName.fullname.toLocaleLowerCase() === name.toLocaleLowerCase());
 
    nameExist != -1 ? (existNameError.value = true) : (existNameError.value = false);
   };

Any insights would be greatly appreciated. Thanks!

P粉798010441
P粉798010441

reply all(1)
P粉863295057

That's exactly what it means - it doesn't exist in your registeredtype. toLocaleLowerCase() only exists on the string type - so unless you can map the Registration type to the string, it won't work. I see that Registration.fullname is a string, but it's also optional - meaning it could be undefined, which could also throw an error.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!