builder icon indicating copy to clipboard operation
builder copied to clipboard

`@builder.io/sdk-vue` is not properly reporting type declarations in `package.json`, causing type errors

Open Joepocalyptic opened this issue 11 months ago • 2 comments

Describe the bug

@builder.io/sdk-vue is not properly reporting its type declarations in the output package.json. The .d.cts files exist, but they appear to not be configured in the exports object. This causes a TS7016 error as shown below:

TS7016: Could not find a declaration file for module @builder.io/sdk-vue.
.../node_modules/.pnpm/@[email protected][email protected]/node_modules/@builder.io/sdk-vue/lib/browser/index.js
implicitly has an any type.
There are types at .../node_modules/@builder.io/sdk-vue/lib/node/index.d.cts, but this result could not be resolved when respecting package.json exports. The @builder.io/sdk-vue library may need to update its package.json or typings.

According to: https://github.com/BuilderIO/builder/blob/46a8ba4c0f577f2539fd649f1194cc65746912c7/packages/sdks/output/vue/package.json#L45-L48 It might be possible to fix this by adding a types key to each export referencing the .d.cts file.

To Reproduce

Steps to reproduce the behavior:

  1. Use @builder.io/sdk-vue in an environment with a type checker (such as vue-tsc)
  2. Attempt to reference an export from @builder-io/sdk-vue.
  3. Run the type checker if it was not done automatically during dev/build.

Expected behavior

Type checking and TypeScript IDE features function properly.

Screenshots

image image

Joepocalyptic avatar Mar 22 '24 06:03 Joepocalyptic

@Joepocalyptic thanks for the detailed report!

@samijaber can you take a look please?

mrkoreye avatar Mar 22 '24 17:03 mrkoreye

Hi! Just wondering if there was any progress on this?

Joepocalyptic avatar Apr 12 '24 06:04 Joepocalyptic

@Joepocalyptic Can you try 1.0.28? It includes a fix for ESM types

https://github.com/BuilderIO/builder/blob/main/packages/sdks/output/vue/CHANGELOG.md#1028

samijaber avatar Jun 10 '24 21:06 samijaber

Marking this as closed given the fix made above.

samijaber avatar Jun 24 '24 12:06 samijaber