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

Plugin code TypeScript build error starting 2.78.0 #4623

Closed
jeremymeng opened this issue Aug 30, 2022 · 2 comments
Closed

Plugin code TypeScript build error starting 2.78.0 #4623

jeremymeng opened this issue Aug 30, 2022 · 2 comments

Comments

@jeremymeng
Copy link

Rollup Version

2.78.0

Operating System (or Browser)

all

Node Version (if applicable)

No response

Link To Reproduction

https://github.com/jeremymeng/rollup-repro

Expected Behaviour

existing code not broken

Actual Behaviour

$ tsc
test.ts:7:10 - error TS2339: Property 'call' does not exist on type 'ObjectHook<(this: PluginContext, id: string) => LoadResult | Promise<LoadResult>, {}>'.
  Property 'call' does not exist on type '{ handler: (this: PluginContext, id: string) => LoadResult | Promise<LoadResult>; order?: "pre" | "post" | null | undefined; }'.

7     load.call(context, id);
           ~~~~


Found 1 error.

This seems to be related to PR #4600. Before that load is of type any. Now it's an ObjectHook<>

@jeremymeng jeremymeng changed the title TypeScript build error starting 2.78.0 Plugin code TypeScript build error starting 2.78.0 Aug 30, 2022
@lukastaegert
Copy link
Member

This error is correct. Now it is possible that plugin hooks are objects instead of functions and you should use a type guard if you want to directly call a plugin hook.
This change which is breaking for you was unavoidable to introduce the feature. Nevertheless we chose to introduce it in a minor version as it should not affect end users and is only a typing issue.

@jeremymeng
Copy link
Author

Got it. Thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants