From 027c207e58b969f741e845d24ad888ba3279bb8e Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 1 Sep 2021 20:01:37 +0200 Subject: [PATCH] Fix #110 Type Definition Error (#111) * Add test to reproduce the issue * And fix the issue. * Prepare release --- README.md | 3 +++ index.d.ts | 4 ++-- package-lock.json | 35 ++++++++++++++++++++++++++--------- package.json | 5 +++-- test/types.ts | 3 +++ 5 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 test/types.ts diff --git a/README.md b/README.md index 1fdc0a6..4d79383 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,9 @@ In other words, it's fine to run it on one image, it's suboptimal to run it on a ## Version history +### 2.0.5 +Fix `TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.`. + ### 2.0.4 Typescript type definitions. diff --git a/index.d.ts b/index.d.ts index 5f6176e..56a8f7a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -22,7 +22,7 @@ export interface CropOptions { ruleOfThirds?: boolean; debug?: boolean; } -const smartcrop: { +declare const smartcrop: { crop(image: CanvasImageSource, options: CropOptions): Promise; }; -export default smartcrop; +export default smartcrop; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 98afa83..7ff8853 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,14 @@ { "name": "smartcrop", - "version": "2.0.3", + "version": "2.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "2.0.3", + "version": "2.0.4", "license": "MIT", "devDependencies": { + "@types/webgl2": "^0.0.6", "benchmark": "^2.1.4", "chai": "^4.2.0", "eslint": "^7.30.0", @@ -175,6 +176,13 @@ "yarn": ">= 1.3.2" } }, + "node_modules/@tensorflow/tfjs-core/node_modules/@types/webgl2": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.4.tgz", + "integrity": "sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/cacheable-request": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz", @@ -284,10 +292,11 @@ "dev": true }, "node_modules/@types/webgl2": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.4.tgz", - "integrity": "sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==", - "dev": true + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.6.tgz", + "integrity": "sha512-50GQhDVTq/herLMiqSQkdtRu+d5q/cWHn4VvKJtrj4DJAjo1MNkWYa2MA41BaBO1q1HgsUjuQvEOk0QHvlnAaQ==", + "dev": true, + "license": "MIT" }, "node_modules/@types/which": { "version": "1.3.2", @@ -8428,6 +8437,14 @@ "@types/webgl2": "0.0.4", "node-fetch": "~2.1.2", "seedrandom": "2.4.3" + }, + "dependencies": { + "@types/webgl2": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.4.tgz", + "integrity": "sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==", + "dev": true + } } }, "@types/cacheable-request": { @@ -8539,9 +8556,9 @@ "dev": true }, "@types/webgl2": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.4.tgz", - "integrity": "sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==", + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@types/webgl2/-/webgl2-0.0.6.tgz", + "integrity": "sha512-50GQhDVTq/herLMiqSQkdtRu+d5q/cWHn4VvKJtrj4DJAjo1MNkWYa2MA41BaBO1q1HgsUjuQvEOk0QHvlnAaQ==", "dev": true }, "@types/which": { diff --git a/package.json b/package.json index f00f484..53ac753 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smartcrop", - "version": "2.0.4", + "version": "2.0.5", "description": "Content aware image cropping.", "homepage": "https://github.com/jwagner/smartcrop.js", "author": "Jonas Wagner (http://29a.ch/)", @@ -10,6 +10,7 @@ "index.d.ts" ], "devDependencies": { + "@types/webgl2": "^0.0.6", "benchmark": "^2.1.4", "chai": "^4.2.0", "eslint": "^7.30.0", @@ -35,7 +36,7 @@ }, "scripts": { "start": "grunt", - "test": "karma start karma.conf.js", + "test": "karma start karma.conf.js && npx tsc -noEmit test/types.ts", "lint": "eslint smartcrop.js test examples/slideshow.js examples/testbed.js examples/testsuite.js examples/smartcrop-debug.js" } } \ No newline at end of file diff --git a/test/types.ts b/test/types.ts new file mode 100644 index 0000000..0f85d89 --- /dev/null +++ b/test/types.ts @@ -0,0 +1,3 @@ +import SmartCrop from '..'; + +console.log(SmartCrop.crop); \ No newline at end of file