-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Handsontable.plugins.BasePlugin cannot be extended: TS 2507: Base is not a constructor function type #6107
Comments
After changing 2294 line in handsontable.d.ts: interface Plugins {
+ BasePlugin: typeof plugins.Base;
- BasePlugin: plugins.Base
} I solved the problem. But I'm not quite sure what problem this modify will cause. |
Hey @imageslr I've asked about the feedback from our devs, but to check if that solution is the right one we'd need to have a demo where the issue can be replicable. Please share one. |
I need something where the issue can be replicable. I was thinking about JSFiddle/CodePen or a .zip - what you'd find easier to share. |
I have tested it with only two files. The files are uploaded below. Thanks! package.json
index.tsximport Handsontable from "handsontable";
/**
* Execute the command below in shell:
*
* tsc index.tsx --jsx --react
*
* and I got an error:
▶ tsc index.tsx --jsx react
index.tsx:10:43 - error TS2507: Type 'Base' is not a constructor function type.
10 export default class CustomPlugin extends Handsontable.plugins.BasePlugin {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors.
*/
export default class CustomPlugin extends Handsontable.plugins.BasePlugin {}
// ------------------------
/**
* if I change the above line to the line above, compile success.
*
▶ tsc index.tsx --jsx react
../node_modules/handsontable/handsontable.d.ts:893:23 - error TS2583: Cannot find name 'WeakSet'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
893 listenersCount: WeakSet<HTMLElement>;
~~~~~~~
Found 1 error.
*/
// export default class CustomPlugin extends (Handsontable.plugins.BasePlugin as any) {} tsc version
and the files are uploaded. |
Hey @imageslr have you tried to build the plugin using our skeleton https://github.com/handsontable/handsontable-skeleton/blob/master/plugins/internal/internalPluginSkeleton.js |
Yes I'm indeed follow the skeleton,except I'm using typescript and causing this problem. It's not a problem with codes, but maybe with handsontable's type definition file. |
This case needs further investigation. I'll ask our developer to check it. |
Hey :) we've just published a PR that fixes the issue. |
Thanks ever so. Very quick fix😄 |
You were the one to guide us :) ps. please do not close it yet. We'll close it with the version update. |
* Add some property to Core and change hot property in BasePlugin #6107
Also released in v |
Description
While trying to create a custom plugin using ts, I found that class
Base
declared in handsontable.d.ts cannot be extended.Steps to reproduce
just simple codes:
and I got an error:
Type 'Base' is not a constructor function type.
。I believe this is similar with the issue #4326 . I wonder know how can I extend
BasePlugin
and implement my own plugin using ts, without having to build my own handsontable.full.js. Thanks for helping!The text was updated successfully, but these errors were encountered: