Skip to content
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

[typescript]: Default export type not being picked up with module: "nodenext" #1329

Open
wight554 opened this issue Oct 22, 2022 · 10 comments
Open

Comments

@wight554
Copy link

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: ^9.0.2
  • Rollup Version: 2.78.1 (vite ^3.1.4)
  • Operating System (or Browser): macOS 12.6
  • Node Version: 16
  • Link to reproduction (⚠️ read below): https://github.com/wight554/rollup-typescript-repro

Expected Behavior

Typing should be picked-up

Actual Behavior

This expression is not callable.
  Type 'typeof import("/Users/Volodymyr_Zhdanov/playground/blog-template/node_modules/@rollup/plugin-typescript/types/index")' has no call signatures.

Additional Information

Steps to reproduct:

  1. Add these settings to tsconfig:
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
  1. Add "type": "module" to package.json
  2. Import and use typescript plugin
  3. See the error

3 possible fixes:

  1. Add named export for plugin
  2. Use CJS styled export in typings: export default function typescript => export = typescript;
  3. Use declaration merging to make default export namespace and function simultaneously, example here: make type definitons "module": "nodenext" compatible fastify/fastify-cookie#184

I've used this thin wrapper for fixing typings before, might be helpful: https://github.com/wight554/vite-plugin-typescript/blob/main/index.d.ts

@unional
Copy link

unional commented Dec 16, 2022

#1375

@stale stale bot added the x⁷ ⋅ stale label Feb 18, 2023
@Polve
Copy link

Polve commented Mar 11, 2023

I have the same problem: are there any workarounds before an official support is complete?

@stale stale bot removed the x⁷ ⋅ stale label Mar 11, 2023
@wight554
Copy link
Author

I have the same problem: are there any workarounds before an official support is complete?

Seems like this one is completely ignored. When I created issue without repro I received feedback immediately. No one checked this issue since I wasted my time on repro

@Polve
Copy link

Polve commented Mar 12, 2023

I'm sorry I don't understand what you mean, exactly: I'm unable to understand any of your workarounds: are you saying I ignored them?

@rijkvanzanten
Copy link

rijkvanzanten commented Apr 3, 2023

Ran into this as well.. Too bad it's ignored!

For now, I'm using the following hacky workaround:

import virtualDefault from '@rollup/plugin-virtual';
import aliasDefault from '@rollup/plugin-alias';

const virtual = virtualDefault as unknown as virtualDefault.default;
const alias = aliasDefault as unknown as aliasDefault.default;

@DetachHead
Copy link

adding "type": "module" to the plugin's package.json seems to fix this, but i'm not sure if that's the correct solution since i'm not too familiar with esm

@cowwoc
Copy link

cowwoc commented Jul 6, 2023

Per algolia/algoliasearch-client-javascript#1431 (comment) and https://arethetypeswrong.github.io/ the problem is not necessarily node.js, but rather the export statement.

I can't say I fully understand it myself, but take a look.

@stale stale bot removed the x⁷ ⋅ stale label Jul 6, 2023
@lazarljubenovic
Copy link

I've described the issue in more detail here #1541, including the exact reason why it happens and the way to fix it (skip over to "Additional Details" for it). I'm not familiar enough with this repository to write a fix, since it's almost entirely about the way the packages are distributed, and not the code itself.

@shellscape
Copy link
Collaborator

OK. Just be aware this is unlikely to see a resolution without community contribution

@benmccann
Copy link
Contributor

Setting up publint for the package would also catch this. For example:

@stale stale bot removed the x⁷ ⋅ stale label Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants