build-plugin icon indicating copy to clipboard operation
build-plugin copied to clipboard

Adding types property to package.json

Open leotrj9 opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe:

While trying to import this in a typescript file, we ran into some typscript warnings/errors because it was missing type declarations. We're unable to import BuildPlugin unless we force typscript to ignore the type.

error TS2307: Cannot find module '@datadog/build-plugin' or its corresponding type declarations.
13 import * as BuildPlugin from "@datadog/build-plugin";

Describe the solution you'd like:

According to https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package, package.json might need types: "./src/types.ts" (or ./src/types.d.ts?). We suspect this might be the cause of the missing types error.

Describe alternatives you've considered:

For now, we worked around this issue by adding // @ts-ignore flag to the import line.

Additional context:

leotrj9 avatar Feb 04 '22 17:02 leotrj9

Hello there :wave:. Sorry for the delays, I'm checking this right now. I'm wondering in which context you're using import * as BuildPlugin from "@datadog/build-plugin"?

Do you have the same issue if you're doing import { BuildPlugin } from '@datadog/build-plugin/dist/webpack'; ?

Because all the types are already there, but we don't have a "main" entry in our package.json.

yoannmoinet avatar Apr 21 '22 07:04 yoannmoinet

Closing this for lack of details, and this will most likely be covered by v2.

yoannmoinet avatar May 14 '24 14:05 yoannmoinet