-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to support tensorflow JS types? #334
Comments
Could you provide steps to reproduce? I tried to import |
I can now reproduce the issue with It seems that this option is problematic, no externs are generated with it. There may be other issues coming into play here, such as the one regarding external module referencing other npm packages for type declaration. However, in order to investigate it, we first need a setup that works with |
Update on this: as I understand solving the following problems consists of resolving the issue.
"external": {
"@tensorflow/tfjs": "tf",
"@tensorflow/tfjs-backend-cpu": "tf_backend_cpu",
"@tensorflow/tfjs-backend-webgl": "tf_backend_webgl",
"@tensorflow/tfjs-converter": "tf_converter",
"@tensorflow/tfjs-core": "tfjs_core",
"@tensorflow/tfjs-data": "tfjs_data",
"@tensorflow/tfjs-layers": "tsjf_layers"
} which is tedious and counterintuitive.
So I am looking for a solution in between two of these; I'm currently researching if it is possible to get package/file lists which depends on certain package's type declaration file via typescript API. |
Note: Typescript 4.1 may introduce some option which may significantly reduce the issue and may render above consideration unnecessary. |
Sorry for the delay! Re:
It's also possible to compile things without The typescript can be correctly compiled, but TSCC still emits the error: In the meantime, I have managed to get my app working using regular TSC + Rollup + Terser, but I'd love to get the closure compiler working at some point! |
to determine a set of files to pass to tsickle. Also implements a tranasformer that rewrites goog.requireType calls to module-dts to global variable aliases. For more information: see the respective file comments. This partly addresses #334.
Hi, finally the version which compiles with tensorflowjs is published. Please try with I've noticed that your repro repo https://github.com/MorganR/tensorflow-tscc contains an invalid closure compiler option |
This is awesome! Thank you so much. I can definitely get some things working now. Two issues I'm still running into:
|
Thank you for your follow ups. I'm aware of the issue 2, I think it is something to be fixed from tsickle. Despite of this issue, as I understand closure compiler mostly backs off for property names appearing in externs, so it is mostly fine. That said, I've tracked down a cause and will file an issue report in the tsickle repository. Regarding the first issue, it is another issue with tsickle's externs generation. For example currently it does not generate externs for |
Relevant issues: angular/tsickle#1202, angular/tsickle#1203 |
Hello, I'm trying to use TSCC to compile typescript code that depends on Tensorflow JS. TFJS has nice type declaration files in its NPM package, and these are structured like this:
To use this in my code, I have an import:
import * as tf from '@tensorflow/tfjs';
My tsconfig.json includes all the typescript .d.ts files, eg:
My tscc.spec.json looks like this:
However, when I try to compile this with TSCC, I get this error:
Module name node_modules._tensorflow.tfjs_core.dist.base.d was not provided as a closure compilation source
I've tried enabling
persistArtifacts
to look at the intermediate output, and the only tensorflow output I see isnode_modules/@tensorflow/tfjs/dist/index.js
, which just contains:Shouldn't there be an externs.js file somewhere with the type information? How can I resolve this issue?
The text was updated successfully, but these errors were encountered: