-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Default imports don't work with moduleResolution=node16 #53349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm pretty sure the the type package is wrong; add |
You are right @jakebailey. Thank you for your help |
I encountered this issue with |
Probably not. As mentioned above
Thus, you'd only add |
If I use import pino from "pino";
import pinoPretty from "pino-pretty"; If I use import { pino } from "pino";
import { PinoPretty as pinoPretty } from "pino-pretty"; It's weird. Isn't it a bug? |
This issue was only related to In the case of pino, it appears that the types it publishes are not accurate. I have seen this often in types packages too, where the declare const Module: typeof pino & {
pino: typeof pino
}
export = Module Go ahead and share this repo with pino authors: https://github.com/tminuscode/pino-types |
I think this issue should be re-opened. I'm running into the same thing. This is my setup: package.json: {
"type": "module",
"devDependencies": {
"@types/react": "^18.2.65",
"typescript": "^5.4.2"
},
"dependencies": {
"next": "^14.1.3"
}
} tsconfig.json: {
"compilerOptions": {
"module": "Node16",
"jsx": "preserve"
}
} index.tsx: import Head from 'next/head.js';
<Head><title>Hello</title></Head>; Running index.tsx:2:2 - error TS2604: JSX element type 'Head' does not have any construct or call signatures.
2 <Head><title>Hello</title></Head>
~~~~
index.tsx:2:2 - error TS2786: 'Head' cannot be used as a JSX component.
Its type 'typeof import("/private/tmp/ts-test/node_modules/next/head")' is not a valid JSX element type.
2 <Head><title>Hello</title></Head>
~~~~
Found 2 errors in the same file, starting at: index.tsx:2 The types are correct in Next: node_modules/next/head.d.ts: import Head from './dist/shared/lib/head'
export * from './dist/shared/lib/head'
export default Head node_modules/next/dist/shared/lib/head.d.ts: import React from 'react';
export declare function defaultHead(inAmpMode?: boolean): JSX.Element[];
/**
* This component injects elements to `<head>` of your page.
* To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
*/
declare function Head({ children }: {
children: React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;
export default Head; |
@mohd-akram please open a new issue with the "module resolution" template |
Bug Report
🔎 Search Terms
node16 default export
🕗 Version & Regression Information
I saw this in various versions on 4.8, 4.9 and 5.0 RC
💻 Code
I import modules which are typed in DT. For example
The type declaration is
Here's a reproduction: https://gist.github.com/tpluscode/8d1bfc9737f82f5005a5849e42f8f297
🙁 Actual behavior
When I set
moduleResolution = "node16"
Typescript complains withTS2349: This expression is not callable.
.The error goes away with
moduleResolution = "node"
. Also tsc stops showing the error when I add.default
, which is wrong and will fail at runtime🙂 Expected behavior
There should be no error
The text was updated successfully, but these errors were encountered: