Open starkpsmichael opened 3 years ago
Related to #8219 and others.
We need workspace folders and a config flag that indicates that files are worker scripts.
What about DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, TextDecoderStream, TextEncoderStream, AbortController, BlobPart, Blob, File, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, ...
. which do not depend on workers?
@Mesteery those currently work. If you have issues with them being available it is not related to this feature request. I would open a new issue in vscode_deno with reproduction information.
Yes they work but not when accessed from globalThis
: globalThis.ByteLengthQueuingStrategy
, for example, raises a error :
error: TS2339 [ERROR]: Property 'ByteLengthQueuingStrategy' does not exist on type 'typeof globalThis'.
globalThis.ByteLengthQueuingStrategy
Is there a workaround to this?
Is there a workaround to this?
Also wondering. Is there a way to flag a file as being a worker?
Similar
Property 'onmessage' does not exist on type 'Window & typeof globalThis'.deno-ts(2339)
Is there a workaround to this?
My workaround is to do this.
const worker = self as unknown as Worker;
You could ignore the line
// @ts-ignore: lack of types in deno
self.onmessage = (e: MessageEvent) => {}
Using deno canary, latest stable vscode and vscode-deno ext.
Don't know who produce this problem but i'm trying to solve the problem that some type definitions aren't available in webworkers:
Create a file called
a.ts
Create a file called
b.ts
deno run
a.ts
works - with no errors, but hovering over postMessage gives:Property 'postMessage' does not exist on type 'Window & typeof globalThis'.deno-ts(2339)
Trying to solve this with a tripple slash directive at the top of the file:
but `deno run` now gives the following errors:
```sh deno run --allow-read a.ts Check file:///workspaces/fk/b.ts error: Uncaught (in worker "") TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL interface AddEventListenerOptions extends EventListenerOptions { ~~~~~~~~~ at asset:///lib.webworker.d.ts:25:1 Conflicts are in this file. declare class DOMException extends Error { ~~~~~~~ at asset:///lib.deno.web.d.ts:8:1 TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: Global, Instance, Memory, Module, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, Worker, PerformanceEntryList, Performance, PerformanceEntry, PerformanceMark, PerformanceMeasure, CustomEvent interface AddEventListenerOptions extends EventListenerOptions { ~~~~~~~~~ at asset:///lib.webworker.d.ts:25:1 Conflicts are in this file. declare namespace WebAssembly { ~~~~~~~ at asset:///lib.deno.shared_globals.d.ts:13:1 TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response interface AddEventListenerOptions extends EventListenerOptions { ~~~~~~~~~ at asset:///lib.webworker.d.ts:25:1 Conflicts are in this file. interface DomIterable