Closed mrn closed 2 years ago
src/.../file.ts:139:24 - error TS2345: Argument of type 'typeof import("/Users/me/project/node_modules/ffmpeg-static/types/index")' is not assignable to parameter of type 'string'. 139 .setFfmpegPath(ffmpegPath) ~~~~~~~~~~
This is weird, as the typings clearly say that it exports a string: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/2e051a5f3e3a28d405d447fbed9b73009a5e63c7/types/ffmpeg-static/index.d.ts
What's causing this? I did a clean install of all packages, which didn't help.
My colleague can compile it without the error.
That sounds a lot like the error is caused by your environments. Double-check that
mkdir foo; cd foo; npm init -y
)package.json
or a lockfile?)Interesting, my ffmpeg-static/types/index.d.ts
is this:
declare const ffmpegPath: string | null;
export default ffmpegPath;
The versions are from package.json
I have no idea what caused that, but I recreated the project (deleted, cloned the repo, installed npm packages) and now the same version of @types/ffmpeg-static
declares ffmpegPath
as only a string.
This is weird, as the typings clearly say that it exports a string: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/2e051a5f3e3a28d405d447fbed9b73009a5e63c7/types/ffmpeg-static/index.d.ts
As you pointed out, my statement was wrong: As of f63f44ce95cd991bb05e5b44191788c3f9341ea2, ffmpeg-static
bundles the type declarations by itself:
Nevertheless, glad that it works now.
I've just run into the same issue, using:
ffmpeg-static@5.1.0
typescript@4.8.3
Curiously, the old @types/ffmpeg-static
package exported the type as
declare const ffmpegPath: string | null;
export = ffmpegPath;
However, this package exports it as
declare const ffmpegPath: string | null;
export default ffmpegPath;
Note the =
and default
. If I change my local index.d.ts
file within this package to use =
, the error goes away.
Edit: Minimum repro repo results in
error TS2322: Type 'typeof import("C:/Users/me/Workspace/ffmpeg-static-115/node_modules/ffmpeg-static/types/index")' is not assignable to type 'string'.
If you know of a fix, please submit a PR. Thanks!
When compiling a typescript project, I get this error:
The import:
import * as ffmpegPath from "ffmpeg-static";
What's causing this? I did a clean install of all packages, which didn't help.
My colleague can compile it without the error.
Some package versions: