Having to somewhat definitely choose to treat None as null or undefined seems not ideal in the long term.
Plus Python using None for functions not returning anything is not even compatible.
What about some explicit sentinel enums the user can give to py2ts.generate_ts for the TS types without Python counterparts such as unknown, void and undefined, in order to fluently makes them corresponds to the logic of the inspection flow.
This way one could for example do the following without having to treat special cases before calling py2ts.generate_ts:
def function(arg):
...
type_hints = get_type_hints(function)
arg_type_hint = type_hints.get('arg', py2ts.enums.unknown)
arg_ts_type = py2ts.generate_ts(arg_type_hint)
return_type_hint = type_hints.get('return', py2ts.enums.void)
return_ts_type = py2ts.generate_ts(return_type_hint)
Having to somewhat definitely choose to treat
Noneasnullorundefinedseems not ideal in the long term.Plus Python using
Nonefor functions not returning anything is not even compatible.What about some explicit sentinel enums the user can give to
py2ts.generate_tsfor the TS types without Python counterparts such asunknown,voidandundefined, in order to fluently makes them corresponds to the logic of the inspection flow.This way one could for example do the following without having to treat special cases before calling
py2ts.generate_ts: