open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
6.98k stars 227 forks source link

Error TS2349 using concurrently in full ESM module #454

Closed throrin19 closed 7 months ago

throrin19 commented 8 months ago

Hello,

I have a problem using concurrently (and others modules) in my project after migrate from CJS to full ESM. I have the error TS2349 when I try to call concurrently function. But, In VSCode, the definition is correctly loaded on CTRL+click :/

This is my config :

And my example code :

import concurrently from 'concurrently';

const main = async () => {
    concurrently([
        { command : 'ls /etc' },
        { command : 'ls /usr' }
    ]);
}

main();

He is a screen on my VSCode : image

I don't know how to do to fix that. I think my problem is with typescript, but I don't understand how to fix that :/

gustavohenke commented 8 months ago

Hey! So apparently there's a lengthy discussion here about this issue: https://github.com/microsoft/TypeScript/issues/50058 It's coming from the use of module: "Nodenext" in your tsconfig.json.

There are a couple of hacks suggested in there that you could try, but none that is pretty. It seems that what typescript is doing is right for your compiler options. Concurrently is a commonjs module, hacked to look like a native ESM module.