Skip to content

Commit 027c207

Browse files
authored
Fix #110 Type Definition Error (#111)
* Add test to reproduce the issue * And fix the issue. * Prepare release
1 parent 1f40486 commit 027c207

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ In other words, it's fine to run it on one image, it's suboptimal to run it on a
214214

215215
## Version history
216216

217+
### 2.0.5
218+
Fix `TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.`.
219+
217220
### 2.0.4
218221
Typescript type definitions.
219222

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface CropOptions {
2222
ruleOfThirds?: boolean;
2323
debug?: boolean;
2424
}
25-
const smartcrop: {
25+
declare const smartcrop: {
2626
crop(image: CanvasImageSource, options: CropOptions): Promise<CropResult>;
2727
};
28-
export default smartcrop;
28+
export default smartcrop;

package-lock.json

Lines changed: 26 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smartcrop",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"description": "Content aware image cropping.",
55
"homepage": "https://github.com/jwagner/smartcrop.js",
66
"author": "Jonas Wagner <[email protected]> (http://29a.ch/)",
@@ -10,6 +10,7 @@
1010
"index.d.ts"
1111
],
1212
"devDependencies": {
13+
"@types/webgl2": "^0.0.6",
1314
"benchmark": "^2.1.4",
1415
"chai": "^4.2.0",
1516
"eslint": "^7.30.0",
@@ -35,7 +36,7 @@
3536
},
3637
"scripts": {
3738
"start": "grunt",
38-
"test": "karma start karma.conf.js",
39+
"test": "karma start karma.conf.js && npx tsc -noEmit test/types.ts",
3940
"lint": "eslint smartcrop.js test examples/slideshow.js examples/testbed.js examples/testsuite.js examples/smartcrop-debug.js"
4041
}
4142
}

test/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import SmartCrop from '..';
2+
3+
console.log(SmartCrop.crop);

0 commit comments

Comments
 (0)