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

3.0.0-rc: type error #8679

Closed
sgratzl opened this issue Mar 20, 2021 · 3 comments · Fixed by #8681
Closed

3.0.0-rc: type error #8679

sgratzl opened this issue Mar 20, 2021 · 3 comments · Fixed by #8681

Comments

@sgratzl
Copy link
Contributor

sgratzl commented Mar 20, 2021

Expected Behavior

I'm trying to bundle my typings using https://github.com/Swatinem/rollup-plugin-dts. However, it fails with the following error:

chart.js/dist/chunks/index.esm.d.ts(1476,14): error TS4025: Exported variable 'Scale' has or is using private name 'Scale'.

see also https://github.com/sgratzl/chartjs-chart-boxplot/runs/2155166769?check_suite_focus=true

Current Behavior

Possible Solution

make sure that all the used types are properly exported

Steps to Reproduce

see https://github.com/sgratzl/chartjs-chart-boxplot/runs/2155166769?check_suite_focus=true

Context

Environment

@kurkle
Copy link
Member

kurkle commented Mar 20, 2021

I'm not sure what would be the error here. Maybe you need to re-export the Scale interface?

export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends Element<{}, O>, LayoutItem {

@etimberg
Copy link
Member

The problem here seems to be how the scale gets exported after the build. We use this pattern of declaration merging to define the constructor for the objects that need it. My guess is that once built, the declaration merging is broken.

Src Types

export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends Element<{}, O>, LayoutItem {
  ....
}
export const Scale: {
  prototype: Scale;
  new <O extends CoreScaleOptions = CoreScaleOptions>(cfg: AnyObject): Scale<O>;
};

Built Types

interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends Element<{}, O>, LayoutItem {
  ...
}
declare const Scale: {
  prototype: Scale;
  new <O extends CoreScaleOptions = CoreScaleOptions>(cfg: AnyObject): Scale<O>;
};

@etimberg
Copy link
Member

https://stackoverflow.com/questions/66135714/typescript-type-definitions-how-to-declare-class-constructors indicates that one way to handle this would be to use declare class instead of the interface style, but I'm not sure we can write the Scale definition that way since it implements Element and LayoutItem

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

Successfully merging a pull request may close this issue.

3 participants