How to install types for ow?

Viewed 19

I have installed ow by

npm i --save ow

and when I use it in my TypeScript project, I get

/home/ss/projects/m/node_modules/ts-node/src/index.ts:843
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/modules/setPropertyOffer.ts(1,16): error TS2307: Cannot find module 'ow' or its corresponding type declarations.

Doing

npm i --save @types/ow

doesn't exist.

Question

How are the types installed for ow?

1 Answers

If you can't find the some library's type, you have to make a type file for that.

  1. Add the custom typeroot option (./@types) in tsconfig.json
// tsconfig.json

{
  // ...
  "typeRoots": ["./node_modules/@types", "./@types"]
  // ...
}
  1. Create a folder for some library and create a index.d.ts file.
// ./@types/someLibrary/index.d.ts

declare module 'someLibrary';

For ow:

// ./@types/ow/index.d.ts

declare module 'ow';
Related