-
Notifications
You must be signed in to change notification settings - Fork 162
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
"This expression is not callable" with module: "node16" in tsconfig.json #469
Comments
Thanks for this great bug report. Unfortunately, I don't see at first glance why the type definitions are being generated incorrectly and since I have a visitor this weekend, I probably won't be able to deal with it extensively until next week. I hope that's ok, otherwise pull requests are always appreciated of course. Thank you. |
Also not 100% sure what Lines 5 to 10 in f105df9
|
Maybe the |
Forked the StackBlitz demo to a new one, seems like it's working 🙌 Thanks! Closing this. Updated (working) StackBlitz demo: https://stackblitz.com/edit/node-5l65bv?file=tsconfig.json,package.json&file=tsconfig.json,index.ts |
@sebbo2002 reopening this - StackBlitz Demo: https://stackblitz.com/edit/node-rrwxxe?file=package.json&file=index.ts Also check it out on Are The Types Wrong? |
Yes, I've seen when merged it in, but I don't understand the error yet and I haven't had time to look at it. The |
Haven't looked at your project configuration / publishing formats yet, but maybe you need |
That's what I meant with duplicating the file. Okay. I will play around a bit more on the weekend, feel free to use the |
Yeah the |
Fixed with 🎉 4.0.0 |
Great, thanks so much for this! 🙌 I can confirm that it's working - just upgraded to I would have a question: how did you get the compiler to emit the Was it just this change to the - "module": "none",
- "moduleResolution": "node",
+ "module": "nodenext",
+ "moduleResolution": "nodenext", I'd like to learn how you did it to be able to recommend things for other packages too... If you have any other changes that should be highlighted, happy to hear about those too! |
Oh wait, maybe it's this manual - "build": "tsc",
+ "build": "tsup && cp ./dist/index.d.ts ./dist/index.d.cts", I thought there would have been a way for |
Yep, it's the manual |
Yeah, any issue in Are The Types Wrong? is an issue, any "Masquerading as ..." error is going to cause the same type of errors when Thanks for the tip with |
@sebbo2002 It seems that this currently does not work for "node16" in tsconfig.json with Node v20.9.0 and v20.11.1
Reproduction example: https://codesandbox.io/p/devbox/simple-express-server-forked-vvg49x?file=%2Fpackage.json%3A14%2C26
I looked into ways to fix it:Option 1:
Option 2: // src/index.ts in ical-generator
- function ical(data?: ICalCalendarData): ICalCalendar {
+ export function ical(data?: ICalCalendarData): ICalCalendar {
return new ICalCalendar(data);
}
export default ical;
// usage:
import { ical } from "ical-generator"; It could be that it is related to this: microsoft/TypeScript#50175 |
Hi @sebbo2002 👋 Thanks again for
ical-generator
, very useful!The new module resolution option
node16
does not work withical-generator
unfortunately, failing with theThis expression is not callable
error:StackBlitz demo: https://stackblitz.com/edit/node-mmyw9w?file=tsconfig.json,package.json&file=tsconfig.json,index.ts
The problem is the
export default
in the publishedindex.d.ts
, as far as I understand, sinceical-generator
uses a CommonJSmodule.exports =
export, this should actually instead beexport =
.You can also see this on the tool Are The Types Wrong from @andrewbranch:
The text was updated successfully, but these errors were encountered: