Closed
Description
Maybe we should support overloading based on the structure of a TypedDict. For example, this could be okay, even though it's currently considered overlapping:
from typing import overload
from mypy_extensions import TypedDict
A = TypedDict('A', {'x': int})
B = TypedDict('B', {'y': str})
@overload
def f(x: A) -> int: ...
@overload
def f(x: B) -> str: ...
def f(x): ...
a: A
b: B
f(a) # Should be int
f(b) # Should be str
However, some overloads should probably still be considered invalid as they overlap, such as if two TypedDicts have the same keys and some value types overlap. Another special case to consider is non-total TypedDicts.
Discussion here: #3612 (comment)