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
DecimationAlgorithm enum not found #8993
Comments
The Do you have a reproduce that uses TS? I created this test case and it worked as expected import { Chart, DecimationAlgorithm } from '../../../index.esm';
const chart = new Chart('id', {
type: 'bubble',
data: {
labels: [],
datasets: [{
data: []
}]
},
options: {
plugins: {
decimation: {
algorithm: DecimationAlgorithm.lttb,
}
}
}
}); |
Sorry for the delay, took a few days off, the codepen exhibits the not found exception, and for the TS, something like this does not work (which I agree is weird as I also saw the export on d.ts file)
This functions creates for me the ChartOptions and I use it to build several different graphs. |
I could try to setup a mock project and post the link here if you want (probably not before tomorrow though) |
Here's a repro: https://codesandbox.io/s/competent-hooks-bi2i7?file=/src/index.ts The issues is, chart.js is written in javascript, so the exported typescript enum never gets compiled and transpiled to an object, as it would in a typescript project. So it really is undefined. The type checking works fine though, so you can just use 'lttb'.
Edit: I think we should do the same as with export declare enum UpdateModeEnum {
resize = 'resize',
reset = 'reset',
none = 'none',
hide = 'hide',
show = 'show',
normal = 'normal',
active = 'active'
}
export type UpdateMode = keyof typeof UpdateModeEnum;
|
And another note, seems like there is a better solution, by using |
Thanks for the update @kurkle, I agree that using 'lttb' works (it is what I'm doing right not), but if using a strict check with tslint, it will fails as string != DecimationAlgorithm, that was basically my point |
Sorry for missing the actual point, but I think the |
Didn't saw the last part of comment, I think that indeed it might do the trick, thanks for the help, didn't think of it (still pretty new too) But nonetheless, I either missed a thing or the generation is effectively clunky as I agree with @etimberg that I also see the |
I believe the string was fixed in #9010. |
Indeed, the type will now match. Concerning the enum export, I'll trust you on what to do with this Issue |
I tried out the |
What do you mean by "output .d.ts"? We are shipping the definitions as is now, if I'm not mistaken. |
I meant the built files that we generate as a result of |
that could be it |
@etimberg sorry for the ping, but since you were the one approving the other PR and this follows the same pattern, would you mind reviewing the PR I've just prepared. Thanks! |
Expected Behavior
I am no pro at Angular/JS, but by seeing the d.ts file and how the decimationOptions are defined, I expect the DecimationAlgorithm enum to be exported
And that, when declaring options, I can use the following:
Current Behavior
https://codepen.io/Nico-DF/pen/WNRWJQr
"export 'DecimationAlgorithm' was not found in 'chart.js'
error Command failed with exit code 1.
Maybe it is a misunderstanding on my side, but currently, I'm forced to do the following:
The ts-ignore is needed due to the definition of the option
The text was updated successfully, but these errors were encountered: