question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript types for @squoosh/lib

See original GitHub issue

I am trying to use Typescript to use @squoosh/lib but getting the usual error when no types are available:

Could not find a declaration file for module '@squoosh/lib'. '/test/squoosh/node_modules/@squoosh/lib/build/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/squoosh__lib` if it exists or add a new declaration (.d.ts) file containing `declare module '@squoosh/lib';`ts(7016)

Are there are no types included for this library or could I doing something wrong?

Currently using

// @ts-ignore
import { ImagePool } from '@squoosh/lib';

as a workaround.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ergunshcommented, Sep 3, 2021

Totally @styfle! 😃

I was a bit skeptical to expose the types before improving the type definitions for preprocess and encode functions since those take some complicated parameters and providing ts types without them felt a bit meaningless.

So, I created a PR to add the parameter types to those https://github.com/GoogleChromeLabs/squoosh/pull/1141 and created another PR to expose the types https://github.com/GoogleChromeLabs/squoosh/pull/1142

2reactions
surmacommented, Jun 26, 2021

Yeah, we don’t have full types for libSquoosh yet, only for some of the files. It’s an incremental migration that @ergunsh is working on 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

squoosh/lib missing types · Issue #1211
squoosh /lib does not have a types or typings field which makes using it in TypeScript projects very unpleasant.
Read more >
squoosh/lib
A Node library for Squoosh. Latest version: 0.4.0, last published: a year ago. Start using @squoosh/lib in your project by running `npm i ......
Read more >
Introducing libSquoosh - web.dev
We are happy to introduce libSquoosh, an experimental Node library on top of which the Squoosh CLI is built, giving you all the...
Read more >
squoosh/lib - npm Package Health Analysis
libSquoosh is an experimental way to run all the codecs you know from the Squoosh web app directly inside your own JavaScript program....
Read more >
ImageMinimizerWebpackPlugin
This plugin can use 4 tools to optimize/generate images: imagemin - optimize your images by default, since it is stable and works with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found