discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
328 stars 112 forks source link

discordjs/voice TypeScript's definition "import" causes a TypeScript compilation error #240

Open TIRTAGT opened 2 years ago

TIRTAGT commented 2 years ago

Issue description

Steps to reproduce the issue :

Module '"${ProjectPath}/node_modules/@types/ws/index"' can only be default-imported using the 'esModuleInterop' flag

Code sample

${ProjectPath}/node_modules/@discordjs/voice/dist/index.d.ts, contents : 

import { Readable, ReadableOptions } from 'node:stream';
import prism from 'prism-media';
import { TypedEmitter } from 'tiny-typed-emitter';
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9';
import WebSocket, {MessageEvent} from 'ws';

@discordjs/voice version

0.7.5

Node.js version

v17.2.0

Operating system

Linux, BTW I use "linux 5.15.5.arch1-1" kernel

Priority this issue should have

Medium (should be fixed soon)

TIRTAGT commented 2 years ago

Temporary fix I have currently, replace the ${ProjectPath}/node_modules/@discordjs/voice/dist/index.d.ts from line 1 to 6 with these :

import { Readable, ReadableOptions } from 'node:stream';
import * as prism from 'prism-media';
import { TypedEmitter } from 'tiny-typed-emitter';
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9';
import * as WebSocket from 'ws';
import { MessageEvent } from 'ws';

Differences between the original and my temporary fix :

import { Readable, ReadableOptions } from 'node:stream';
import prism from 'prism-media';      // - Original
import * as prism from 'prism-media'; // + Modified
import { TypedEmitter } from 'tiny-typed-emitter';
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9';
import WebSocket, {MessageEvent} from 'ws'; // - Original
import * as WebSocket from 'ws';            // + Modified
import { MessageEvent } from 'ws';          // + Modified