nuxt / nuxt/module-builder

incorrect type generation

Open
#355 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
275
Forks
35
Avg merge
4h 42m
Merged PRs (30d)
6

Description

What happens?

My module.ts

import type { LogEntry } from "./runtime/server/types/LogEntry";

export interface ModuleOptions {
  delayOnBan: boolean;
  log: false | LogEntry;
}

export default defineNuxtModule<ModuleOptions>({
  meta: {
    name: "nuxt-api-shield",
    configKey: "nuxtApiShield",
  },
  defaults: {
    delayOnBan: true,
    log: false,
  },

After running yarn dev:prepare I get the following in .nuxt/types/schema.d.ts

interface PublicRuntimeConfig {
   nuxtApiShield: {
      delayOnBan: boolean,
      log: boolean,
   },
  }

What is expected?

log type should be false | LogEntry

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown module.ts example by running yarn dev:prepare, then inspect the generated .nuxt/types/schema.d.ts and the module-builder type-generation entry points. Done means the generated nuxtApiShield.log type remains false | LogEntry instead of being reduced to boolean.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.