mypy, type hint: Union[float, int] -> is there a Number type?

Use float only, as int is implied in that type: def my_func(number: float): PEP 484 Type Hints specifically states that: Rather than requiring that users write import numbers and then use numbers.Float etc., this PEP proposes a straightforward shortcut that is almost as effective: when an argument is annotated as having type float, an argument … Read more

Typescript: How can I make entries in an ES6 Map based on an object key/value type

Here’s the closest I can imagine getting, although I still don’t understand why we don’t just use plain objects to begin with: type ObjectToEntries<O extends object> = { [K in keyof O]: [K, O[K]] }[keyof O] interface ObjectMap<O extends object> { forEach(callbackfn: <K extends keyof O>( value: O[K], key: K, map: ObjectMap<O> ) => void, … Read more