News for hackers. Stuff that matters.
Re:TypeScript’s quirks: How inconsistencies make the languag... by potatoz2 on Friday January 31, 2020 @09:53PM (#22208295)
The correct use is to remove the `age` property in this case: if you're not keeping a reference to the object or that property and the called function cannot use it, why have it in the first place?
Re:TypeScript’s quirks: How inconsistencies make the languag... by alexcole on Friday January 31, 2020 @11:33PM (#22208687)
That’s not always true. If you are going to print the object to the console or send it in a network request it’s possible that the additional property is important.
Re:TypeScript’s quirks: How inconsistencies make the languag... by wvenable on Friday January 31, 2020 @11:56PM (#22208782)
But then it should be in the type signature of the object. TypeScript is signalling this as an error because it's a literal passed directly to the function and that property (theoretically) can never be used because it wasn't declared.