Skip to content

Stories with typescript should type the variable directly instead of using as cast #12125

@Fuco1

Description

@Fuco1

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;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions