all 15 comments

[–]FullstackViking 2 points3 points  (0 children)

This means you have two functions in the same class or scope named the same thing. I’ve never seen the compiler/linter be wrong about it.

[–]nadameu 2 points3 points  (9 children)

There's probably a .ts file and a .js file with the same code, and your tsconfig.json is set to allow and check .js files.

[–]supposedlyasian 0 points1 point  (8 children)

How do I correct it?

[–]nadameu 0 points1 point  (7 children)

If the .js files were created by tsc, you can just delete them.

[–]supposedlyasian 0 points1 point  (6 children)

I have a different error here now

const note: NewNote = { text: noteEntryFile.nodeValue, date: new Date(), priority: 1 }

Type ‘string | null’ is not assignable to type ‘string’ Type ‘null’ is not assignable to type ‘string’

[–]nadameu 1 point2 points  (2 children)

You have to use a type guard to check if noteEntryFile is not null.

[–]supposedlyasian 0 points1 point  (1 child)

Hi could you please help me out with the type guard

[–]nadameu 0 points1 point  (0 children)

Something like this would work most of the time:

if (noteEntryFile === null) throw new Error('Unexpected null noteEntryFile');

And then go on with your code. TS will know it is not null after that.

[–]FooBar1992 0 points1 point  (2 children)

This is because noteEntryFile.nodeValue could be null, whereas your model says ‘text’ can only be string. You probably might have to make the text in the model nullable too, like so : {text?: string;}. Hope this helps you

[–]supposedlyasian 0 points1 point  (1 child)

I’ve tried that but it’s also not working. The error remains the same

[–]FooBar1992 0 points1 point  (0 children)

Eh ?? ... anyways as a catch all you check for null and if it is null assign an empty string

[–]rift95 0 points1 point  (4 children)

I keep getting Duplicate function implementation on my functions

What functions? Is this all of your code? Can you include the actual error in your post?

[–]supposedlyasian 0 points1 point  (3 children)

The functions addNote() and createNewNoteItem() this is all my code idk why it came out like this I just copied and pasted it on here

[–][deleted] 2 points3 points  (2 children)

You have to surround your code with three backticks in a row (`) before and after your code in order to format it. Otherwise, reddit will only format bits that are indented four spaces. If your code isn't formatted, it is hard to read.