New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dnt on WebSocket base project. #194
Comments
You need to add the following to your config: {
shims: {
custom: [{
package: {
name: "stream/web",
},
globalNames: ["ReadableStream", "TransformStream"],
},
},
} As well as you should update your |
That better now, aside the resolveDns I still have a few error: WritableStreamDefaultWriter errorssrc/deps/deno.land/x/event@2.0.0/mod.ts:17:19 - error TS2304: Cannot find name 'WritableStreamDefaultWriter'.
17 #globalWriters: WritableStreamDefaultWriter<Entry<E, keyof E>>[] = [];
~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/deps/deno.land/x/event@2.0.0/mod.ts:19:22 - error TS2304: Cannot find name 'WritableStreamDefaultWriter'.
19 [K in keyof E]?: WritableStreamDefaultWriter<E[K]>[];
~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/deps/deno.land/x/event@2.0.0/mod.ts:142:14 - error TS2304: Cannot find name 'WritableStreamDefaultWriter'.
142 ) as WritableStreamDefaultWriter<E[K]>[][]
~~~~~~~~~~~~~~~~~~~~~~~~~~~ websocket onmessage() typing differencessrc/lib/chrome.ts:167:27 - error TS2304: Cannot find name 'MessageEvent'.
167 ws.onmessage = (data: MessageEvent) => {
~~~~~~~~~~~~ this one I can fix / hide it by replacing MessageEvent by a my build step: await build({
entryPoints: ["./mod.ts"],
outDir: "./npm",
shims: {
// see JS docs for overview and more options
deno: true,
webSocket: true,
undici: true,
custom: [
{
package: {
name: "stream/web",
},
globalNames: ["ReadableStream", "TransformStream"],
}
],
},
compilerOptions: {
lib: [ "esnext" ],
},
package: {...}
}); and for now |
Try |
Now I'im using: compilerOptions: {
lib: [ "dom", "esnext" ],
}, I think that there is a bug in dnt, my code: #connectToWebSocket(): Promise<WebSocket> {
const ws = new WebSocket(this.webSocketDebuggerUrl);
ws.onmessage = (message: MessageEvent) => { is converted as: #connectToWebSocket(): Promise<dntShim.WebSocket> {
const ws = new dntShim.WebSocket(this.webSocketDebuggerUrl);
ws.onmessage = (message: MessageEvent) => { but should had been converted do: #connectToWebSocket(): Promise<dntShim.WebSocket> {
const ws = new dntShim.WebSocket(this.webSocketDebuggerUrl);
ws.onmessage = (message: dntShim.WebSocket.MessageEvent) => { and this code works. to bypasse the isseI replaced My original nodeJS version work fine with the code:import WebSocket from "ws";
...
#connectToWebSocket(): Promise<WebSocket> {
const ws = new WebSocket(this.webSocketDebuggerUrl);
ws.onmessage = (message: WebSocket.MessageEvent) => {
if (typeof message.data === "string") { Now I just need to implement that fine. |
This comment was marked as outdated.
This comment was marked as outdated.
after reading the source code of dns, I fix my build by adding: {
globalNames: [ {name: "MessageEvent", typeOnly: true} ],
package: {
name: "ws",
},
} My recomentation, add a logic to avoid using: export interface GlobalName {
name: string;
exportName?: string;
typeOnly?: boolean;
} Allow export names: "type TypeName" and "default as name" and "type theType as name" Since a type can not contains space, you won't have any breaking change, and such a syntax is easy to read. I can PR this change for you. |
I there anything actionable from your viewpoint on this issue now, other than maybe continue to improve the documentation? |
I'm trying to convert a simple project from nodeJS to deno.
Deno branch: chrome-remote-interface
but building nodejs version give me those Errors:
is
https://deno.land/x/event
have a dntShim? or can I use an alternative lib?how can I fix the
Deno.resolveDns(hostname, "A");
Just 2 mapping errors to fix.
The text was updated successfully, but these errors were encountered: