You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This (ab)uses the django system-check framework to generate typed stubs for all components it found in the current project.
Of course, this is just a proof of concept, but given
<!-- cotton/card.html --><c-varsname="" /><p>
Hello {{ name }}
</p>
Since the stubs are generated into the django_cotton/__init__.pyi they get picked up automatically by language servers. You then get hints, as to which variables a component supports and errors, when you pass in variables that aren't declared on the components.
Of course, there are many things to discuss and improvements I could imagine. Anyways, I'd love to get your input on the idea.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Now that an official
render_componenthas landed in django-cotton, there might be a chance to improve DX quite a bit by auto-generating stubs.I implemented a quick prototype of what I mean:
This (ab)uses the django system-check framework to generate typed stubs for all components it found in the current project.
Of course, this is just a proof of concept, but given
and
the following stub file is created:
Since the stubs are generated into the
django_cotton/__init__.pyithey get picked up automatically by language servers. You then get hints, as to which variables a component supports and errors, when you pass in variables that aren't declared on the components.Of course, there are many things to discuss and improvements I could imagine. Anyways, I'd love to get your input on the idea.
Beta Was this translation helpful? Give feedback.
All reactions