Closed palises closed 12 months ago
try this:
import type { EChartsOption } from 'echarts';
const options = {
xAxis: {
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
type: 'category'
},
yAxis: {
type: 'value'
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'bar'
}
]
} satisfies EChartsOption;
I've installed the library and copy/pasted the code and I get the following typescript error:
[{ "resource": "/Users/pablo/Desktop/Coding Projects/SvelteKit Weekly/src/routes/chart/+page.svelte", "owner": "_generated_diagnostic_collection_name_#0", "code": "2322", "severity": 8, "message": "Type '{ xAxis: { data: string[]; type: string; }; yAxis: { type: string; }; series: { data: number[]; type: string; }[]; }' is not assignable to type 'EChartsOption'.\n Types of property 'xAxis' are incompatible.\n Type '{ data: string[]; type: string; }' is not assignable to type 'XAXisOption | XAXisOption[] | undefined'.\n Type '{ data: string[]; type: string; }' is not assignable to type '(ValueAxisBaseOption & { gridIndex?: number | undefined; gridId?: string | undefined; position?: CartesianAxisPosition | undefined; offset?: number | undefined; categorySortInfo?: OrdinalSortInfo | undefined; } & { ...; }) | ... 4 more ... | XAXisOption[]'.\n Type '{ data: string[]; type: string; }' is not assignable to type 'CategoryAxisBaseOption & { gridIndex?: number | undefined; gridId?: string | undefined; position?: CartesianAxisPosition | undefined; offset?: number | undefined; categorySortInfo?: OrdinalSortInfo | undefined; } & { ...; }'.\n Type '{ data: string[]; type: string; }' is not assignable to type 'CategoryAxisBaseOption'.\n Types of property 'type' are incompatible.\n Type 'string' is not assignable to type '\"category\"'.", "source": "ts", "startLineNumber": 22, "startColumn": 10, "endLineNumber": 22, "endColumn": 17 }]
Is there anything I'm doing wrong or has something changed since svelte-echarts was last updated?