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.

Add TypeScript definitions

See original GitHub issue

I’m using imagemin-webpack in my webpack configuration, and it would be nice to have type definitions for this loader.

This is fairly easy to add:

  1. Run npm install --save-dev typescript.
  2. Create a tsconfig.json file like:
    {
      "compilerOptions": {
        "target": "ES5",
        "outDir": "types",
        "newLine": "LF",
        "allowJs": true,
        "declaration": true,
        "emitDeclarationOnly": true
      },
      "include": [
        "index.js",
        "src/**/*"
      ],
      "compileOnSave": false
    }
    
  3. Add "types": "types/index.d.ts" to package.json.
  4. Run npx tsc to generate the declaration files.

(optional: Add an npm script and add some JSDoc comments)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Jun 30, 2020

Yep, good idea, it is on roadmap for all loaders/plugins, feel free to send a PR

0reactions
alexander-akaitcommented, May 28, 2021

You can get them from ImageMinimizerPlugin, i.e. ImageMinimizerPlugin['options'], types some wrong right now

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: Adding Custom Type Definitions for Existing ...
The step-by-step process to get to that definition is started by adding a property that does exist, and going to the definitions of...
Read more >
Documentation - Type Declarations - TypeScript
TypeScript automatically finds type definitions under node_modules/@types , so there's no other step needed to get these types available in your program.
Read more >
Add your own Type Definition to any Javascript 3rd party module
1. To the typeRoots property add your local-types folder path. "compilerOptions" : { ... "typeRoots": [ "node_modules/@types", · 2. Add a paths ...
Read more >
How to add custom types into the TypeScript project - drag13.io
Create custom typings · Create a root folder for your types. You can give any name for it but let it be types...
Read more >
The repository for high quality TypeScript type definitions.
If you are adding typings for an npm package, create a directory with the same name. If the package you are adding typings...
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