Modules for consola/browser and consola/basic not found in typescript project
kepi opened this issue · 1 comments
kepi commented
Environment
- NodeJS version 18.17.0
- Typescript .2.2
- Consola 3.2.3
Reproduction
git clone https://github.com/kepi/consola-typescript-import-repro.git
cd consola-typescript-import-repro
npm install
npm run check.types
Describe the bug
I'm trying to use consola in universal application, which is running both on backend and browser.
My idea was to import createConsola
from basic and browser and use one I need according to browser check logic. Problem is, that Typescript doesn't see consola/basic
and consola/browser
node modules correctly. consolas/core
works just fine.
Btw. I alsow saw in package.json
that there is some logic to detect which files would be used for basic according to environment. Should this work even with bundled app? Is there any other way how to include directly consola/basic
for NodeJS without auto detection?
Here is how I'm trying to import functions:
import { createConsola as createBasicConsola } from "consola/basic";
import { createConsola as createBrowserConsola } from "consola/browser";
import { createConsola } from "consola/core";
Additional context
No response
Logs
~/dev/os/consola-typescript-import-repro main*
❯ npm run check.types
> consola-typescript-import-repro@1.0.0 check.types
> tsc --noEmit
src/logger/index.ts:1:53 - error TS2307: Cannot find module 'consola/basic' or its corresponding type declarations.
1 import { createConsola as createBasicConsola } from "consola/basic";
~~~~~~~~~~~~~~~
src/logger/index.ts:2:55 - error TS2307: Cannot find module 'consola/browser' or its corresponding type declarations.
2 import { createConsola as createBrowserConsola } from "consola/browser";
~~~~~~~~~~~~~~~~~
Found 2 errors in the same file, starting at: src/logger/index.ts:1
juanmagalhaes commented
Same here 👍