sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

Cannot find module 'ow' or its corresponding type declarations #252

Closed rsbmkJ closed 1 year ago

rsbmkJ commented 1 year ago
image

In my React typescript project always I have this error .

rsbmkJ commented 1 year ago

I already have the solution!! Instead of importing like this import ow from "ow" import this import ow from "ow/dist"

rsbmkJ commented 1 year ago
image

When importing the library as indicated in my previous comment, then I get this error

sindresorhus commented 1 year ago

See: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c Especially, the TS section.

Jiri-Mihal commented 8 months ago

@sindresorhus please add the lines below to your package.json files for backwards compatibility with TS projects using "type": "module" in package.json and "moduleResolution": "Node" in tsconfig.json.

"main": "./dist/index.js",
"types": "./dist/index.d.ts",

It also gracefully resolves this issue and I believe has no side effects.

sindresorhus commented 8 months ago

I have no plans to do this.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm

Jiri-Mihal commented 8 months ago

I consider it closed, yet this may change your mind: https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-main-and-types