Skip to content

Commit 2fde2d7

Browse files
author
Kevin Scott
committed
Bring back types by shimming a fix for typescript to work around importing tfjs
1 parent 2bf8ead commit 2fde2d7

File tree

8 files changed

+110040
-40
lines changed

8 files changed

+110040
-40
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ tslint.json
77
yarn.lock
88
rollup.config.js
99
config
10-
tests
10+
__tests__

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "ml-classifier",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "A machine learning engine for quickly training image classification models in your browser",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
77
"repository": "https://github.com/thekevinscott/ml-classifier",
88
"scripts": {
99
"clean": "rimraf dist/*",
1010
"watch": "npm run build -- --watch",
11-
"make": "npm run clean && rollup -c",
12-
"prepublish": "npm run build",
11+
"build": "npm run clean && rollup -c",
12+
"publish": "npm run build && npm publish",
1313
"test": "jest"
1414
},
1515
"keywords": [

rollup.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export default {
1010
},
1111
plugins: [
1212
typescript({
13+
tsconfig: 'tsconfig.json',
14+
verbosity: 1,
15+
exclude: [
16+
'*.d.ts',
17+
'**/*.d.ts',
18+
],
1319
}),
1420
],
1521
};

src/__mocks__/@tensorflow/tfjs.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export { DataType } from './types';
2424
class MLClassifier {
2525
// private pretrainedModel: typeof tf.model;
2626
private pretrainedModel: any;
27-
private model: tf.Sequential;
27+
// private model: tf.Sequential;
28+
private model: any;
2829
private callbacks: Function[] = [];
2930
private data: IData = {
3031
classes: {},
@@ -178,4 +179,5 @@ class MLClassifier {
178179
return await this.model.save(handlerOrURL || getDefaultDownloadHandler(this.data.classes));
179180
}
180181
}
182+
181183
export default MLClassifier;

tsconfig.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@
77
"lib": ["esnext", "dom"],
88
"sourceMap": true,
99
"allowJs": false,
10-
"declaration": false,
10+
"declaration": true,
1111
"moduleResolution": "node",
1212
"rootDir": "src",
1313
"forceConsistentCasingInFileNames": true,
1414
"noImplicitReturns": true,
1515
"noImplicitThis": true,
16+
"noUnusedLocals": true,
1617
"noImplicitAny": true,
1718
"strictNullChecks": true,
1819
"suppressImplicitAnyIndexErrors": true,
1920
"paths": {
2021
"*": [
2122
"src/*"
2223
]
23-
},
24-
"noUnusedLocals": true
24+
}
2525
},
2626
"include": [
2727
"src/**/*"
2828
],
2929
"exclude": [
30+
"__tests__",
31+
"__mocks__",
3032
"**/*.test.ts",
3133
"node_modules"
3234
]

typescript-working-module.js

Lines changed: 110009 additions & 0 deletions
Large diffs are not rendered by default.

yarn.lock

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,7 @@ [email protected]:
37223722
version "1.1.7"
37233723
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
37243724

3725-
resolve@^1.1.7, resolve@^1.3.2, resolve@^1.8.1:
3725+
resolve@^1.1.7, resolve@^1.3.2, resolve@^1.7.1:
37263726
version "1.8.1"
37273727
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
37283728
dependencies:
@@ -3744,16 +3744,16 @@ rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2:
37443744
dependencies:
37453745
glob "^7.0.5"
37463746

3747-
"rollup-plugin-typescript2@https://github.com/ezolenko/rollup-plugin-typescript2":
3748-
version "0.16.0"
3749-
resolved "https://github.com/ezolenko/rollup-plugin-typescript2#f0e466c89f288f5b7434a513370201ef9da56aff"
3747+
rollup-plugin-typescript2@^0.15.1:
3748+
version "0.15.1"
3749+
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.15.1.tgz#7b35d0eaa6ad5a54a253ed158a565b99d8f15372"
37503750
dependencies:
37513751
fs-extra "^5.0.0"
3752-
resolve "^1.8.1"
3753-
rollup-pluginutils "^2.3.0"
3754-
tslib "1.9.3"
3752+
resolve "^1.7.1"
3753+
rollup-pluginutils "^2.0.1"
3754+
tslib "1.9.2"
37553755

3756-
rollup-pluginutils@^2.3.0:
3756+
rollup-pluginutils@^2.0.1:
37573757
version "2.3.0"
37583758
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.0.tgz#478ace04bd7f6da2e724356ca798214884738fc4"
37593759
dependencies:
@@ -4194,7 +4194,11 @@ ts-loader@^2.3.7:
41944194
loader-utils "^1.0.2"
41954195
semver "^5.0.1"
41964196

4197-
[email protected], tslib@^1.8.0, tslib@^1.8.1:
4197+
4198+
version "1.9.2"
4199+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.2.tgz#8be0cc9a1f6dc7727c38deb16c2ebd1a2892988e"
4200+
4201+
tslib@^1.8.0, tslib@^1.8.1:
41984202
version "1.9.3"
41994203
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
42004204

0 commit comments

Comments
 (0)