News for hackers. Stuff that matters.
Re:A 'CSS reset' for TypeScript, improving types for common ... by Kiro on Friday March 03, 2023 @04:38AM (#35007583)
That sounds extremely cumbersome. Sometimes I just want to throw an any on something and call a method on it without having to deal with types. How would unknown help with that? I can't call a method on a variable with unknown type.
Re:A 'CSS reset' for TypeScript, improving types for common ... by haburka on Friday March 03, 2023 @04:48AM (#35007642)
You can use ‘as’ to cast unknown to any type. This is extra typing but it does signify to other developers that you’re calling a function on an unverified object, which I believe makes the code more maintainable in the long run.
Re:A 'CSS reset' for TypeScript, improving types for common ... by anentropic on Friday March 03, 2023 @10:07AM (#35010549)
Why bother using typescript then?
Re:A 'CSS reset' for TypeScript, improving types for common ... by Kiro on Friday March 03, 2023 @11:06AM (#35011377)
That 1% won't invalidate the remaining 99%.