-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sveltekit typescript example does not work #1
Comments
It's the following two lines causing the issue:
It's not valid to do an import from The reason it's not valid is that the Probably |
@benmccann Nice catch! |
I've updated the
<script lang="ts">
import { BarChartSimple } from "@carbon/charts-svelte";
import type { BarChartOptions, ScaleTypes } from "@carbon/charts/interfaces";
const options: BarChartOptions = {
title: "Simple bar (discrete)",
height: "400px",
axes: {
left: { mapsTo: "value" },
bottom: { mapsTo: "group", scaleType: "labels" as ScaleTypes.LABELS },
},
};
</script>
<BarChartSimple
data={[
{ group: "Qty", value: 65000 },
{ group: "More", value: 29123 },
{ group: "Sold", value: 35213 },
{ group: "Restocking", value: 51213 },
{ group: "Misc", value: 16932 },
]}
{options}
/>
|
Commenting for posterity in case anyone stumbles upon this. I recently tried this again and the enums/interfaces seem to work perfectly (no more need for casting). From the sveltekit-typescript example: <script lang="ts">
import { BarChartSimple, ScaleTypes, type BarChartOptions } from "@carbon/charts-svelte";
const options: BarChartOptions = {
title: "Simple bar (discrete)",
height: "400px",
axes: {
left: { mapsTo: "value" },
bottom: { mapsTo: "group", scaleType: ScaleTypes.LABELS },
},
};
</script>
<BarChartSimple
data={[
{ group: "Qty", value: 65000 },
{ group: "More", value: 29123 },
{ group: "Sold", value: 35213 },
{ group: "Restocking", value: 51213 },
{ group: "Misc", value: 16932 },
]}
{options}
/>
|
To reproduce, clone this repo and then:
When I go to http://localhost:3000/ the console shows the following error a few times:
The browser also shows this error.
If I refresh the browser, the error goes away and the charts are showed correctly in the browser.
If I remove the
Basic
andEvents
imports and components fromindex.svelte
and leave only theDynamicImport
, there are no errors.The
sveltekit
example (without typescript) works fine, there are no errors.If this not related to this repo but more of a problem with the main library https://github.com/carbon-design-system/carbon-charts/tree/master/packages/svelte then I'm sorry for posting here and I can create the issue in that repo if you wish.
The text was updated successfully, but these errors were encountered: