News for hackers. Stuff that matters.
Re:Node.js adds experimental support for TypeScript by LordKeren on Friday July 26, 2024 @09:44AM (#41078612)
While it’s not common (from the source code I’ve reviewed over the years), some people make a new type with a name and use that in the definition:

```

from typing import NewType

# Create a new type for some_prime SomePrime = NewType('SomePrime', int)

def process_prime(value: SomePrime) -> int: return value ```

However, this isn’t nearly as common as simply using a more descriptive argument name like “prime_number : int”

One of the big advantages to type hinting in Python is that it feeds the IDE a lot of information to increase auto-complete functionality, so you want to avoid things like p:”prime number”

Re:Node.js adds experimental support for TypeScript by pansa2 on Friday July 26, 2024 @11:57AM (#41079668)
> One of the big advantages to type hinting in Python is that it feeds the IDE a lot of information to increase auto-complete functionality

Yeah, until this discussion I thought the main benefit of type hints was earlier detection of bugs via static checking. Now though, I'm getting the impression that the bigger benefit is enabling IDE features such as autocomplete.

That helps me understand better why I haven't found type hints as useful as others seem to - I don't use an IDE. My use of Python is limited to small scripts which I write in a simple text editor.

Re:Node.js adds experimental support for TypeScript by LordKeren on Friday July 26, 2024 @12:36PM (#41079990)
There’s a fair argument to make that better IDE autocomplete does prevent many type-related issues even before a static type checker is run