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

Expose states from Stylable Typescript declaration file #2431

Open
tzachbon opened this issue Apr 7, 2022 · 2 comments
Open

Expose states from Stylable Typescript declaration file #2431

tzachbon opened this issue Apr 7, 2022 · 2 comments
Labels
feature New syntax feature or behavior integration Bundler, test-runner and node

Comments

@tzachbon
Copy link
Contributor

tzachbon commented Apr 7, 2022

Actual Behavior

Today if users want to declare some type as a State from the stylesheet, they will have to do twice this since the states are private.

For example -

.root {
    -st-states: myState(enum(a, b));
}
import { st, classes } from './my-style.st.css';

 // have to redeclare the type
type States = 'a' | 'b';

const myState: States = 'a';

st(classes.root, { myState })

Expected Behavior

import { st, classes, states } from './my-style.st.css';

const myState: states['myState'] = 'a';

st(classes.root, { myState })

Version

4.12.0

Relevant log output

No response

Additional Context

No response

@tzachbon tzachbon added bug Unexpected behavior or exception integration Bundler, test-runner and node labels Apr 7, 2022
@idoros
Copy link
Collaborator

idoros commented Apr 8, 2022

The states are not completely private, they are reflected in the st(classname, states) type. We can probably expose it as a direct type, but then why just expose the root, what about the rest of the classes?

@tzachbon
Copy link
Contributor Author

tzachbon commented Apr 8, 2022

The states are not completely private, they are reflected in the st(classname, states) type. We can probably expose it as a direct type, but then why just expose the root, what about the rest of the classes?

A more correct API would be:

type MyStates = states['root']['myState']

@idoros idoros added feature New syntax feature or behavior and removed bug Unexpected behavior or exception labels Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New syntax feature or behavior integration Bundler, test-runner and node
Projects
None yet
Development

No branches or pull requests

2 participants