diff --git a/package-lock.json b/package-lock.json index d900ac83..f39e505e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "@typescript-eslint/parser": "^5.37.0", "babel-eslint": "^10.1.0", "babel-loader": "^9.1.2", + "check-dts": "^0.7.2", "core-js": "^3.25.2", "dox": "^1.0.0", "eslint": "^8.23.1", @@ -4646,6 +4647,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/unist": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz", + "integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==", + "dev": true + }, "node_modules/@types/ws": { "version": "8.5.4", "dev": true, @@ -6475,6 +6482,27 @@ "dev": true, "license": "MIT" }, + "node_modules/check-dts": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/check-dts/-/check-dts-0.7.2.tgz", + "integrity": "sha512-ZflsEhv7SXlgNECrNIw1WmMJZ1787KtS62anWknLPI+k9g9OY2eA/UfT+Tsb0i0eWLUZHtFfznrNtGlQJrGaKw==", + "dev": true, + "dependencies": { + "fast-glob": "^3.2.12", + "nanospinner": "^1.1.0", + "picocolors": "^1.0.0", + "vfile-location": "^4.1.0" + }, + "bin": { + "check-dts": "bin.js" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "typescript": ">=4.0.0" + } + }, "node_modules/chokidar": { "version": "3.5.3", "dev": true, @@ -13598,6 +13626,15 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/nanospinner": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/nanospinner/-/nanospinner-1.1.0.tgz", + "integrity": "sha512-yFvNYMig4AthKYfHFl1sLj7B2nkHL4lzdig4osvl9/LdGbXwrdFRoqBS98gsEsOakr0yH+r5NZ/1Y9gdVB8trA==", + "dev": true, + "dependencies": { + "picocolors": "^1.0.0" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "dev": true, @@ -18815,6 +18852,19 @@ "node": ">=8" } }, + "node_modules/unist-util-stringify-position": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.3.tgz", + "integrity": "sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/universalify": { "version": "2.0.0", "dev": true, @@ -18949,6 +18999,73 @@ "node": ">=0.10.48" } }, + "node_modules/vfile": { + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.7.tgz", + "integrity": "sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "is-buffer": "^2.0.0", + "unist-util-stringify-position": "^3.0.0", + "vfile-message": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-location": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.1.0.tgz", + "integrity": "sha512-YF23YMyASIIJXpktBa4vIGLJ5Gs88UB/XePgqPmTa7cDA+JeO3yclbpheQYCHjVHBn/yePzrXuygIL+xbvRYHw==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "vfile": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.4.tgz", + "integrity": "sha512-fa0Z6P8HUrQN4BZaX05SIVXic+7kE3b05PWAtPuYP9QLHsLKYR7/AlLW3NtOrpXRLeawpDLMsVkmk5DG0NXgWw==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile/node_modules/is-buffer": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", + "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "engines": { + "node": ">=4" + } + }, "node_modules/void-elements": { "version": "2.0.1", "dev": true, diff --git a/package.json b/package.json index 863ef044..7f81b750 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "build:site": "cp dist/function-plot.js site/js/function-plot.js", "start": "webpack-dev-server", "docs": "typedoc --excludeExternals --externalPattern \"**/node_modules/**\" --out site/docs src/index.ts", - "test": "jest" + "test": "jest", + "test:types": "check-dts test/** src/**" }, "files": [ "/dist" @@ -67,6 +68,7 @@ "@typescript-eslint/parser": "^5.37.0", "babel-eslint": "^10.1.0", "babel-loader": "^9.1.2", + "check-dts": "^0.7.2", "core-js": "^3.25.2", "dox": "^1.0.0", "eslint": "^8.23.1", diff --git a/src/types.ts b/src/types.ts index 1a0921a5..dd00723c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -149,7 +149,7 @@ export interface FunctionPlotDatum { * - interval: uses the interval arithmetic sampler to render a disjoint set of rectangles * - scatter: dotted line */ - graphType?: 'polyline' | 'interval' | 'scatter' + graphType?: 'polyline' | 'interval' | 'scatter' | 'text' /** * The type of function to render diff --git a/test/types.ts b/test/types.ts new file mode 100644 index 00000000..f3304a35 --- /dev/null +++ b/test/types.ts @@ -0,0 +1,21 @@ +// test with `npx check-dts` +import functionPlot from '../src/' + +functionPlot({ + target: '#playground', + data: [ + { + graphType: 'text', + location: [1, 1], + text: 'hello world' + }, + { + graphType: 'text', + location: [-1, -1], + text: 'foo bar', + attr: { + 'text-anchor': 'end' + } + } + ] +})