Skip to content

Commit

Permalink
Fix typings in workers
Browse files Browse the repository at this point in the history
The worker self object is simply cast to any to make sure typescript
does not complain.
Actual typecheck may be restored once the following issue is fixed:
microsoft/TypeScript#20595
  • Loading branch information
jahow committed Sep 23, 2019
1 parent b58c78c commit 5b5a365
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/ol/worker/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
*/
import {VERSION} from '../util.js';

onmessage = event => {
/** @type {any} */
const worker = self;

worker.onmessage = event => {
console.log('version worker received message:', event.data); // eslint-disable-line
postMessage(`version: ${VERSION}`);
worker.postMessage(`version: ${VERSION}`);
};

export let create;
7 changes: 5 additions & 2 deletions src/ol/worker/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
} from '../renderer/webgl/Layer.js';
import {assign} from '../obj.js';

onmessage = event => {
/** @type {any} */
const worker = self;

worker.onmessage = event => {
const received = event.data;
if (received.type === WebGLWorkerMessageType.GENERATE_BUFFERS) {
const renderInstructions = new Float32Array(received.renderInstructions);
Expand Down Expand Up @@ -41,7 +44,7 @@ onmessage = event => {
renderInstructions: renderInstructions.buffer
}, received);

postMessage(message, [vertexBuffer.buffer, indexBuffer.buffer, renderInstructions.buffer]);
worker.postMessage(message, [vertexBuffer.buffer, indexBuffer.buffer, renderInstructions.buffer]);
}
};

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* Basic Options */
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es2017", "dom", "webworker"], /* Specify library files to be included in the compilation. */
"lib": ["es2017", "dom"], /* Specify library files to be included in the compilation. */
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down

0 comments on commit 5b5a365

Please sign in to comment.