英文:
Highcharts TypeScript - Property 'RangeSelector' does not exist on type 'typeof import'
问题
"我想在TypeScript中原型化drawInput Highcharts函数,当我尝试这样做时:
(function (H) {
Highcharts.RangeSelector.prototype.drawInput = () => {
// 一些代码
};
})(Highcharts);
它会显示"Property 'RangeSelector' does not exist on type 'typeof import'"。
我尝试了以下方法:
(function (H) {
console.log(Highcharts.RangeSelector)
})(Highcharts as any);
它返回undefined。奇怪的是,当我只是这样做时:
console.log(Highcharts)
它显示了RangeSelector选项。"
英文:
I want to prototype the drawInput Highcharts function in TypeScript and when I want to do:
(function (H) {
Highcharts.RangeSelector.prototype.drawInput = () => {
// some code
};
})(Highcharts);
it says that "Property 'RangeSelector' does not exist on type 'typeof import'"
I tried to do the following:
(function (H) {
console.log(Highcharts.RangeSelector)
})(Highcharts as any);
and it returned undefined. Strange is that when I simply do the
console.log(Highcharts)
it shows the RangeSelector option
答案1
得分: 0
Just cast the Highcharts object as any:
(function (H) {
console.log((H as any).RangeSelector);
(H as any).RangeSelector.prototype.drawInput = () => {
// some code
};
})(Highcharts);
https://codesandbox.io/s/highcharts-typescript-rangeselector-68zhz2
英文:
Just cast the Highcharts object as any:
(function (H) {
console.log((H as any).RangeSelector);
(H as any).RangeSelector.prototype.drawInput = () => {
// some code
};
})(Highcharts);
https://codesandbox.io/s/highcharts-typescript-rangeselector-68zhz2
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论