nx
nx copied to clipboard
Stories with typescript should type the variable directly instead of using `as` cast
- [X] I'd be willing to implement this feature (contributing guide)
Description
When using component-story generator with typescript, it uses "casting" (as) instead of typing the object directly. Some projects have eslint rules flagging casts as warnings or errors and then they need to disable warnings in nx generated files or rewrite them.
Motivation
Typecasting with as is not type-safe since the user must "be sure" they do the right thing and the compiler can't really help.
Suggested Implementation
Instead of
export default {
component: Test,
title: 'Test',
} as ComponentMeta<typeof Test>;
use
const story: ComponentMeta<typeof Test> = {
component: Test,
title: 'Test',
};
export default story;
Hi there @Fuco1 ! Thanks for the feature request! I see you're willing to implement this feature? Do you want to give this a shot, and reach out to me if you need any support in the process?
@mandarini sure thing! Any legalese that needs to be handled?
As far as I see this should just amount to change of the template.
I think so too @Fuco1 ! Do you want to start working on it (fork nx, start a new branch, create a draft PR), and I can take a look and we can take it step by step? Thank you so much!!!
I took it up, no worries @Fuco1 !
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.