question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Angular] auto-generated stories need to be cast to any

See original GitHub issue

Describe the bug I just tried the upcoming Storybook (6.0.0-rc.13) in an Angular project. After initialisation I head to fix all stories because the args access expressions where invalid.

To Reproduce Steps to reproduce the behavior: 0. create an Angular project in strict mode

  1. run npx sb@next init
  2. run npm run storybook

Expected behavior The standard storybook should be executable without manual type fixes.

Screenshots Screenshot 2020-07-22 at 16 26 42

Code snippets I had to tweak the stories with any casts:

export const Primary = Template.bind({}) as any;
Primary.args = {
    primary: true,
    label: 'Button',
};

System: Well… that was unexpected:

Environment Info:
(node:88453) UnhandledPromiseRejectionWarning: TypeError: e.filter is not a function

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aloifoliacommented, Jul 23, 2020

@gaetanmaisse Actually, I am using Angular 10.0.4.

I guess your E2E tests do not apply the strict mode for Angular. If you do not use strict mode (which entails stricter Typescript settings), you get inferences like these:

Screenshot 2020-07-23 at 09 37 19

So, the story objects are inferred as any and, consequently, args can be assigned without problems.

In strict mode (npx -p @angular/cli ng new projectname --strict), however, the types are inferred more precisely:

Screenshot 2020-07-23 at 09 41 13

I just updated the first thread message to reflect this constraint.

0reactions
shilmancommented, Aug 9, 2020

This was fixed in #11825 closing!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto Increment user id for the Array of User Input using ...
you can try something like this. But in the real world the ID should be generated server side i.e. from the DB itself...
Read more >
Generate Angular Unit Test Automatically | by Allen Kim
Generate the first unit test automatically ... There is no reason not to automate copying, pasting, and modifying the test codes for each...
Read more >
Set up Storybook for Angular Projects - Nx
You first need to set up Storybook for your Nx workspace, if you haven't already. You can read the Storybook plugin overview guide...
Read more >
How to set CellStyle with Auto Generated Columns? - Telerik
I tried in code behind but couldn't find what to cast the object ... as Style worked and no I can't use Implicit...
Read more >
Angular Data Grid Overview and Configuration - Infragistics
If you use autoGenerate columns the data keys must be identical. Angular Grid Data Binding. Before going any further with the grid we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found