egoist / egoist/tsup

Error with @nuxt/schema

Open
#624 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am new to building packages. I am trying to create a small UI lib. I want to create a nuxt module for it and when I try to include below `nuxt.ts` file I get error: `src/nuxt.ts(4,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@nuxt+schema@3.0.0-rc.2_vite@2.9.8/node_modules/@nuxt/schema'. This is likely not portable. A type annotation is necessary.`

```ts
// nuxt.ts
import { defineNuxtModule } from "@nuxt/kit";
import { fileURLToPath } from "node:url";

export default defineNuxtModule({
hooks: {
"components:dirs"(dirs) {
// Add ./components dir to the list
dirs.push({
path: fileURLToPath(new URL("./components/", import.meta.url)),
});
},
},
});
```

my tsup config:
```ts
import { defineConfig } from "tsup";

export default defineConfig({
dts: true,
format: ["cjs", "esm"],
entry: ["src/index.ts", "src/nuxt.ts"],
// splitting: false,
// sourcemap: true,
clean: true,
});
```

How can I resolve this 🤔

Contributor guide

Open the contributing guide

Research direction

Start with src/nuxt.ts and the shown tsup configuration, then run the build with dts generation enabled to reproduce TS2742. Trace how the nuxt module entry is handled during declaration generation; done means the package builds and emits portable declarations without the error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.