- 
                Notifications
    You must be signed in to change notification settings 
- Fork 656
Description
Marko Version: 6.0.50
Details
As described in the docs for <style>:
If the
<style>tag has a Tag Variable, it leverages CSS Modules to expose its classes as an object.
In my usage, I've found this works at build/runtime, but I see TypeScript type errors (at least in VSCode) when accessing those properties. For instance, in this snippet from the documented example:
<style/styles>
  .foo {
    border: 1px solid red;
  }
</style>
<div class=styles.foo/>
//                ^ Property 'foo' does not exist on type '() => HTMLStyleElement'Expected Behavior
Ideally: since <style> as a Tag Variable is compiled as a CSS module, it would be very nice if the specific exports were exposed in generated types.
Pragmatically: it makes sense that the <style> Tag Variable's type could be expressed as Record<string, string> (perhaps as an intersection with () => HTMLStyleElement?).
Actual Behavior
As above, accessing properties on the <style>'s Tag Variable produces TypeScript type errors.
(Well, to be pedantic… since the variable is typed as a function, accessing a function's properties does not produce type-level errors. I haven't checked the runtime behavior for that, but I could imagine…!)
Possible Fix
I'll open a PR shortly!
Additional Info
Your Environment
- Environment name and version (e.g. Chrome 39, node.js 5.4): N/A. More applicable: I observe the issue in VSCode
- Operating System and version (desktop or mobile): N/A
- Link to your project: I actually don't have one yet! I just started playing with Marko this morning. 😅 But I see the same issue in this repo, i.e. this fixture.
Steps to Reproduce
- Create a Marko template with <style>as a Tag Variable (or use the fixture linked above)
- Open the template in an editor configured to check TypeScript types in Marko
Stack Trace
N/A