error TS2304
See original GitHub issueTo get help from the community, we encourage using Stack Overflow and the tensorflow.js
tag.
TensorFlow.js version
"@tensorflow/tfjs-node": "^1.2.9",
Browser version
Google Chrome Version 77.0.3865.90 (Official Build) (64-bit)
Describe the problem or feature request
30 09 2019 10:51:32.313:INFO [launcher]: Launching browsers Chrome_no_sandbox with concurrency unlimited
30 09 2019 10:51:32.319:INFO [launcher]: Starting browser ChromeHeadless
ERROR in node_modules/@tensorflow/tfjs-core/dist/backends/webgl/canvas_util.d.ts(19,61): error TS2304: Cannot find name 'OffscreenCanvas'.
Code to reproduce the bug / link to feature request
Angular project with Karma and puppeteer:
const process = require("process");
process.env.CHROME_BIN = require("puppeteer").executablePath();
module.exports = function (config) {
config.set({
basePath: "",
frameworks: ["jasmine", "@angular-devkit/build-angular"],
plugins: [
require("karma-jasmine"),
require("karma-chrome-launcher"),
require("karma-jasmine-html-reporter"),
require("karma-coverage-istanbul-reporter"),
require("@angular-devkit/build-angular/plugins/karma")
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require("path").join(__dirname, "../coverage"),
reports: ["html", "lcovonly"],
fixWebpackSourcePaths: true,
thresholds: {
statements: 100,
lines: 100,
branches: 100,
functions: 100
}
},
reporters: ["progress", "kjhtml"],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ["Chrome_no_sandbox"],
customLaunchers: {
Chrome_no_sandbox: {
base: "ChromeHeadless",
flags: [
"--no-sandbox",
"--proxy-bypass-list=*",
"--proxy-server='direct://'"
]
}
},
concurrency: Infinity,
singleRun: true
});
};
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
TypeScript getting error TS2304: cannot find name ' require'
I am trying to get my first TypeScript and DefinitelyTyped Node.js application up and running, and running into some errors. I am getting...
Read more >TS2304: Cannot find name 'Request' · Issue #661 - GitHub
When compiling a Typescript file that uses MeiliSearch for Node.js, the error TS2304: Cannot find name 'Request' causes the build to fail.
Read more >TypeScript error TS2304 cannot find name require - Edureka
The error that I'm getting is the "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page....
Read more >Typescript getting error TS2304 cannot find name ' require'
When we try to get a TypeScript running, we get this error: "TS2304: Cannot find name 'require' " when we attempt to transpile...
Read more >error TS2304 Cannot find name 'IterableIterator' - YouTube
error TS2304 Cannot find name 'IterableIterator' - Typescript error when converting ts to js. 2.2K views 2 years ago.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zzj0402 I installed
"@tensorflow/tfjs": "^1.3.1"
, imported it as usualimport * as tf from '@tensorflow/tfjs';
and run. Then I got errorERROR in node_modules/@tensorflow/tfjs-core/dist/backends/webgl/canvas_util.d.ts(20,61): error TS2304: Cannot find name 'OffscreenCanvas'.
I found solution here but I don’t think that is a best way modifying lib.dom.d.ts file
I tried installing @types/offscreencanvas. Then when navigating to the file @tensorflow/tfjs-core/dist/backends/webgl/canvas_util.d.ts, Typescript is able to recognize OffscreenCanvas, but for some reason the build still cannot.
So my workaround was just to change the type in the offending line from OffscreenCanvas to “any”
Old: export declare function createCanvas(webGLVersion: number): OffscreenCanvas | HTMLCanvasElement;
New: export declare function createCanvas(webGLVersion: number): any;