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.

Compilation errors with TypeScript 3.5

See original GitHub issue

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version: @tensorflow/tfjs-node 1.1.2

Browser version: NodeJS 11.4.0

TypeScript version: 3.5.1

(Does not seem to happen in 3.4)

Describe the problem or feature request

Can’t compile my application that uses TFJS.

node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:588:18 - error TS2430: Interface 'NumericTensor<R>' incorrectly extends interface 'Tensor<R>'.
  Types of property 'data' are incompatible.
    Type '() => Promise<TypedArray>' is not assignable to type '<D extends "string" | "float32" | "int32" | "bool" | "complex64" = NumericDataType>() => Promise<DataTypeMap[D]>'.
      Type 'Promise<TypedArray>' is not assignable to type 'Promise<DataTypeMap[D]>'.
        Type 'TypedArray' is not assignable to type 'DataTypeMap[D]'.
          Type 'Uint8Array' is not assignable to type 'DataTypeMap[D]'.
            Type 'Uint8Array' is not assignable to type 'string[] & Float32Array & Int32Array & Uint8Array'.
              Type 'Uint8Array' is missing the following properties from type 'string[]': pop, push, concat, shift, and 3 more.

588 export interface NumericTensor<R extends Rank = Rank> extends Tensor<R> {
                     ~~~~~~~~~~~~~

node_modules/@tensorflow/tfjs-core/dist/tensor.d.ts:593:18 - error TS2430: Interface 'StringTensor<R>' incorrectly extends interface 'Tensor<R>'.
  Types of property 'data' are incompatible.
    Type '() => Promise<string[]>' is not assignable to type '<D extends "string" | "float32" | "int32" | "bool" | "complex64" = NumericDataType>() => Promise<DataTypeMap[D]>'.
      Type 'Promise<string[]>' is not assignable to type 'Promise<DataTypeMap[D]>'.
        Type 'string[]' is not assignable to type 'DataTypeMap[D]'.
          Type 'string[]' is not assignable to type 'string[] & Float32Array & Int32Array & Uint8Array'.
            Type 'string[]' is missing the following properties from type 'Float32Array': BYTES_PER_ELEMENT, buffer, byteLength, byteOffset, and 3 more.

593 export interface StringTensor<R extends Rank = Rank> extends Tensor<R> {
                     ~~~~~~~~~~~~


Found 2 errors.

Code to reproduce the bug / link to feature request

I’ve already had to disable strict and strictNullChecks to get it to compile, otherwise I get even more errors. This is what is left:

tsconfig.json

{
  "compilerOptions": {
    "alwaysStrict": true,
    "charset": "utf8",
    "declaration": true,
    "experimentalDecorators": true,
    "inlineSourceMap": true,
    "inlineSources": true,
    "lib": [
      "dom",
      "es2016",
      "es2017.object",
      "es2017.string"
    ],
    "module": "CommonJS",
    "noEmitOnError": false,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "resolveJsonModule": true,
    "strict": false,
    "strictNullChecks": false,
    "esModuleInterop": true,
    "strictPropertyInitialization": false,
    "stripInternal": true,
    "target": "ES2018"
  },
  "include": [
    "**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
tafsiricommented, Jun 3, 2019

@rix0rrr Try adding the skipLibCheck: true to your tsconfig. Then you can set your original desired options in tsconfig.

0reactions
caisqcommented, Jun 7, 2019

Oops ~ sorry for the false alarm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing TypeScript 3.5 - Microsoft Developer Blogs
This guide will show you how to fix Typescript compile errors in Javascript project that recently added Typescript support via a tsconfig.json.
Read more >
The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 ...
I was getting this problem in my Angular 9 as well, but with different version numbers. ERROR in The Angular Compiler requires TypeScript...
Read more >
ts-loader - npm
Failing the build on TypeScript compilation error. The build should fail on TypeScript compilation errors as of webpack 2. If for some reason...
Read more >
Documentation - TypeScript 3.9
The above no longer errors. If you've been stuck on older versions of TypeScript due to issues around Promise s, we encourage you...
Read more >
The Angular Compiler requires TypeScript 3 4 0 and 3 5 0 but ...
I'm getting the following error when I do npm run build: The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.3 was found...
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