gorgeous-minister-41131
08/19/2021, 8:59 PMgreat-sunset-355
08/20/2021, 3:23 AMdicts
because IDEs are not able to introspect the data structures to give you hints.
In JS/TS you have Objects that only look like a python dict
.
So in JS/TS Obj = { prop: 'value' }
in python is
class Obj:
def __init__(self, prop):
self.prop = prop
Obj(prop='value')
In this case IDEs can tell you that Obj
expects prop
.
but if your object accepts the only dict
class Obj:
def __init__(self, arg_dict):
self.prop = arg_dict['prop']
Obj(arg_dict={"prop": 'value'})
There isn't a way for IDE to tell you what shape or keys are required.
So this leads to KeyError
on execution time Obj(arg_dict={"not_expected": 'value'})
- which is expensive due to mental overhead and developer time.
That's why TS feels a little bit more naturalfamous-leather-94346
08/20/2021, 6:00 AMgorgeous-minister-41131
08/24/2021, 10:22 PM*Args()
constructor convention since it does provide that introspection which can be valuable to developers who are new to things, especially k8s spec, and don't quite understand what the dict form should look like etc.IngressRuleArgs
or something, and I have to manually import it or something, but all-in-all the intellisense and autocomplete mostly work, and without the special Args objects, this would not be possible...