From c6e02087c82c022f45c515e48cac9ce517967198 Mon Sep 17 00:00:00 2001 From: Michal Pemcak Date: Tue, 15 Jul 2025 17:39:24 +0200 Subject: [PATCH] Fixed types generation --- .gitignore | 1 - package.json | 5 +++-- src/index.d.ts | 28 ++++++++++++++++++++++++++++ tsconfig.json | 4 +++- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/index.d.ts diff --git a/.gitignore b/.gitignore index 0f1cebe..c2658d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules/ -src/index.js diff --git a/package.json b/package.json index 61b94bc..25258b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@meteolab/uchart", "publishConfig": { "access": "public" }, - "version": "1.0.3", + "version": "1.0.5", "description": "Lightweight charting library for the browser and Node.js", "license": "MIT", "repository": { @@ -15,6 +15,7 @@ "module": "./dist/uchart.js", "types": "./dist/uchart.d.ts", "sideEffects": false, + "outDir": "./dist", "exports": { ".": { "types": "./dist/uchart.d.ts", @@ -25,7 +26,7 @@ "scripts": { "clean": "rm -rf dist", "build:js": "esbuild src/index.ts --bundle --minify --format=esm --outfile=dist/uchart.js", - "build:types": "tsc -p tsconfig.json", + "build:types": "tsc --declaration --emitDeclarationOnly", "build": "npm run clean && npm run build:js && npm run build:types", "prepublishOnly": "npm run build", "serve": "npx http-server . -c-1 --gzip" diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..60bb2a8 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,28 @@ +export type ChartSeries = { + data: [number, number][]; + strokeColor?: string; +}; +export declare function drawChart(ctx: CanvasRenderingContext2D, seriesList: ChartSeries[], opts: { + width: number; + height: number; + min?: number; + max?: number; + showYAxis?: boolean; + yTicks?: number; + backgroundColor?: string; + cursorX?: number | null; +}): void; +export declare function createChartElement(seriesList: ChartSeries[], opts: { + width?: number; + height?: number; + min?: number; + max?: number; + showYAxis?: boolean; + yTicks?: number; + backgroundColor?: string; +}): { + element: HTMLDivElement; + setSeries(series: ChartSeries[]): void; + setOptions(o: Partial): void; + destroy(): void; +}; diff --git a/tsconfig.json b/tsconfig.json index fd5a37e..728bbe9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,13 @@ "compilerOptions": { "target": "ES6", "module": "ES6", + "declaration": true, "moduleResolution": "node", "esModuleInterop": true, "resolveJsonModule": true, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "outDir": "./dist" }, "include": ["src"] }