Skip to content

🤔 [ISSUE] - eazychart-[react | vue]- Color scale type safeguard #109

Open
@marrouchi

Description

@marrouchi

Description

We need a type safe-guard for the certain shapes that would be included under the color scale context provider. Shapes like Segments or Area do not support non ordinal scale. So we need to find a solution in the future on how to make the developer aware of that while coding recipes.

We already tried to use a type safe guard (instanceof / contructor.name) but it lead to some issues in deployments (see #107 root cause for this issue is well detailed here : https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript

The OrdinalScale class extends the AstractScale class and when we perform an "instanceof", in storybook preview :

const scale = new ScaleOrdinal( ... );
console.log(scale instanceof ScaleOrdinal); // prints false
console.log(scale instanceof AbstractScale); // prints true 

This seems to be an issue if when the compilation target is ES3 or ES5, but the wierd thing is that the configured target we have is ESNEXT. "Storybook" relies on Babel and does not account apparently for that config.

We did remove the type safeguard for the moment so that we would think of a better way to handle this in the future : #108

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions