Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Types from consola and consola/core are not the same #382

@tobiasdiez

Description

@tobiasdiez

Environment

  • Operating System: Windows_NT
  • Node Version: v23.9.0
  • Nuxt Version: 3.14.1592
  • CLI Version: 3.16.0
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]

Reproduction

import { useLogger } from '@nuxt/kit'
import type { ConsolaInstance } from 'consola/core'

export const logger: ConsolaInstance = useLogger('nuxt:storybook')

Describe the bug

The above code yields

src/logger.ts(7,14): error TS2719: Type 'import("D:/Programming/nuxt-storybook/node_modules/.pnpm/[email protected]/node_modules/cons…  
│   Type 'ConsolaInstance' is not assignable to type 'Consola'.
│     The types of 'options.reporters' are incompatible between these types.
│       Type 'import("D:/Programming/nuxt-storybook/node_modules/.pnpm/[email protected]/node_modules/consola/dist/core").ConsolaReport…  
│         Type 'import("D:/Programming/nuxt-storybook/node_modules/.pnpm/[email protected]/node_modules/consola/dist/core").ConsolaRepo…  
│           Types of property 'log' are incompatible.
│             Type '(logObj: import("D:/Programming/nuxt-storybook/node_modules/.pnpm/[email protected]/node_modules/consola/dist/core"…  
│               Types of parameters 'ctx' and 'ctx' are incompatible.
│                 Type '{ options: import("D:/Programming/nuxt-storybook/node_modules/.pnpm/[email protected]/node_modules/consola/dist…  
│                   The types of 'options.prompt' are incompatible between these types.
│                     Type '(<_ = any, __ = any, T extends PromptOptions = import("D:/Programming/nuxt-storybook/node_modules/.pnpm…
│                       Type '<_ = any, __ = any, T extends PromptOptions = import("D:/Programming/nuxt-storybook/node_modules/.pnp…  
│                         Type 'Promise<inferPromptReturnType<T> | inferPromptCancalReturnType<T>>' is not assignable to type 'Prom…  
│                           Type 'inferPromptReturnType<T> | inferPromptCancalReturnType<T>' is not assignable to type 'inferPrompt…  
│                             Type 'inferPromptCancalReturnType<T>' is not assignable to type 'inferPromptReturnType<T> | inferProm…  
│                               Type 'string | boolean | SelectOption | (string | SelectOption)[] | unique symbol | null | undefine…  
│                                 Type 'undefined' is not assignable to type 'inferPromptReturnType<T> | inferPromptCancalReturnTyp…  

while using import type { ConsolaInstance } from 'consola' (without /core) works perfectly fine.

Additional context

Context:
nuxt-modules/storybook#880
nuxt-modules/storybook#870 (comment)
nuxt-modules/tailwindcss#972

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions