I've tried to install typings:
npm install --save @type/tfjs
npm install --save @type/tenforflowjs
npm install --save @type/tensorflow
But it doesn't exist. On tensorflow js github repository I can see that it is developed using Typescript, but it seems they did not distribute definitions. If there is no definition distribution (I hope I am wrong), how can I use their github repository to obtain it and still benefit from their future releases?
Note that there is unfortunately no simple way to tell whether types are available in a library since type definitions can be exported in a variety of ways.
If you do npm install --save @tensorflow/tfjs
, you will see that there is a node_modules/@tensorflow/tfjs/dist/index.d.ts
. Additionally in the package.json
for the project, there is "types": "dist/index.d.ts"
.
That is to say types are available for this library.
If types are not included with the package, you can check DefinitelyTyped to see if there is a third party definition available at @types/{package}
. Otherwise you'll be on your own for strong typing.
to install tensorflow.js
run:
npm install --save @tensorflow/tfjs
to import to your *.ts
file do:
import * as tf from '@tensorflow/tfjs';
still troubles?
make sure
tsconfig.json
has"compilerOptions"
with"moduleResolution": "node"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With