Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript errors occur when taking variables in modifiers that are also used as compound modifiers #2949

Open
JaredMaione opened this issue Oct 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JaredMaione
Copy link

JaredMaione commented Oct 3, 2024

🐛 Bug Report

If we have a stencil like the following:
const stencil = createStencil({
     vars: {
        var1: ''
    },
    base: ({var1}) => ({
        // base styles here including usage of var1
    }),
    modifiers: {
        modifier1: {
            true: ({var1}) => ({
                 // any other applicable constant options for the modifier would be present here
                backgroundColor: var1
            })
        },
        modifier2: {
            true: {
                // modifier2 styles here
            }
        }
    },
    compound: [
        {
            modifiers: {modifier1: 'true', modifier2: 'true'},
                styles: {
                    // compound modifier styles
                }
        }
    ]
});

We get type errors in the compound section: TS2322: Type string is not assignable to type boolean | undefined. The expected type comes from property modifier1 which is declared here on type...

Additionally, when using the stencil, we see TS2322: Type boolean is not assignable to type string.

It is functionally working fine, it's just a typing issue.

To Reproduce

An example stencil can be set up like the above

Expected Behavior

There should not be type errors in this scenario

Actual Results

TS gives errors in the stencil definition as well as when trying to use it

Browser (if applicable)

N/A

@JaredMaione JaredMaione added the bug Something isn't working label Oct 3, 2024
@jaclynjessup jaclynjessup moved this to 🆕 New in Canvas Kit Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant