jamsinclair / jSquash

Browser & Web Worker focussed wasm bundles derived from the Squoosh App.
Apache License 2.0
222 stars 14 forks source link

Fails to build with typescript when skipLibCheck is false #11

Closed andrewdavidcostello closed 2 years ago

andrewdavidcostello commented 2 years ago

Firstly just wanted to say thanks for the library, works great!

Vite: 2.8.2 Typescript: 4.5.5

"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,

This typescript issue looks to be directly related to: https://github.com/GoogleChromeLabs/squoosh/issues/1219

error TS2503: Cannot find namespace 'EmscriptenWasm'.
export interface MozJPEGModule extends EmscriptenWasm.Module {
error TS2503: Cannot find namespace 'EmscriptenWasm'.
declare var moduleFactory: EmscriptenWasm.ModuleFactory<MozJPEGModule>;
error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
export { EncodeOptions, MozJpegColorSpace };

Tried directly installing types for Emscripten but didn't work.

For now we have simply enabled skipLibCheck but thought this would be a good one to keep track of.

jamsinclair commented 2 years ago

Thanks for the report @andrewdavidcostello. Looks like it was a simple issue I missed 😅 .

I've re-published affected packages @jsquash/avif, @jsquash/jpeg and @jsquash/webp. Let me know if that would resolve the need for you to use skipLibCheck.