question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile error in @tensorflow/tfjs-layers/dist/models.d.ts

See original GitHub issue

TensorFlow.js version

+-- @tensorflow/tfjs@0.10.3
| +-- @tensorflow/tfjs-core@0.8.4
| | `-- seedrandom@2.4.3
| `-- @tensorflow/tfjs-layers@0.5.3
`-- typescript@2.8.3

Browser version

N/A

Describe the problem or feature request

Cannot import @tensorflow/tfjs from TypeScript.

import * as tf from "@tensorflow/tfjs"
node_modules/@tensorflow/tfjs-layers/dist/models.d.ts:27:5 - error TS2416: Property 'build' in type 'Sequential' is not assignable to the same property in base type 'Model'.
  Type '(inputShape?: number[] | undefined) => void' is not assignable to type '(inputShape: number[] | number[][]) => void'.
    Types of parameters 'inputShape' and 'inputShape' are incompatible.
      Type 'number[] | number[][]' is not assignable to type 'number[] | undefined'.
        Type 'number[][]' is not assignable to type 'number[] | undefined'.
          Type 'number[][]' is not assignable to type 'number[]'.
            Type 'number[]' is not assignable to type 'number'.

27     build(inputShape?: Shape): void;
       ~~~~~

Code to reproduce the bug / link to feature request

https://github.com/mysticatea/tfjs-issue-ts

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
mysticateacommented, Apr 25, 2018

I found the compile error happens if I enabled "strictNullChecks": true build option.

The "strictNullChecks": true option is very useful option to prevent null dereference errors. It’s very inconvenient if I cannot use the option in all software that uses tensorflow.js.

1reaction
dsmilkovcommented, May 28, 2018

See https://stackoverflow.com/questions/40164034/typescript-strictnullchecks-with-limited-scope

In your project use the skipLibCheck option added in Typescript 2.0 to skip checking the *.d.ts files of your dependencies. This will also speed up compilation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TFJS throws TS2411 as error when importing using Typescript
However, I get the following error: node_modules/@tensorflow/tfjs-layers/dist/keras_format/types.d.ts:12:5 - error TS2411: Property 'config ...
Read more >
tensorflowjs module cann't be compiled correctly - Super User
when I compile the project ng serve , it always gets the errors as below: ... node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(29 ...
Read more >
tf in nodejs - Google Groups
One of examples errors I get after yarn start node_modules/@tensorflow/tfjs-core/dist/engine.d.ts(65,24): error TS2304: Cannot find name 'ImageData'.
Read more >
Setup | TensorFlow.js
Installation from NPM and using a build tool like Parcel, WebPack, or Rollup. If you are new to web development, or have never...
Read more >
Error TS1005: '>' expected. node_modules/@tensorflow/tfjs ...
node_modules/@tensorflow/tfjs-layers/dist/engine/training_utils.d.ts-angular.js. Search.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found