Can you cast a series to e.g. SeriesGaugeOptions in TypeScript

3 weeks ago 20
ARTICLE AD BOX

We are evaluating using Highcharts in our Blazor application and installed Highcharts using package.json (npm) in VS 2026

The tsconfig.json file looks like this:

{ "compilerOptions": { "allowJs": true, "checkJs": true, "noImplicitAny": false, "noEmitOnError": true, "removeComments": false, "lib": [ "ES2021", "DOM" ], "target": "ES2021", "moduleResolution": "node", "sourceMap": true, "outDir": "wwwroot/js" }, "exclude": [ "node_modules" ], "include": [ "JS" ] }

In order to import Highcharts, I had to do the following in a separate ts file than the one where I actually create the chart.

// We cannot add the import line in a ts file. If we do the browser reports an error // 'Cannot use import statement outside a module' // and the js file is not loaded. // So we add the import(s) here to import all members (types) needed using the 'Highcharts' alias. import * as Highcharts from 'highcharts'; export default Highcharts;

As a test, I create a gauge

let chart = Highcharts.chart(....)

I'd like to now check the series, and from what I have read, I need to cast the series to the right seriesoptions, which makes sense.

But I cannot find a find a way to use SeriesGaugeOptions in my code. I.e. what I'd like to do is check the type and if it is a SeriesGaugeOptions, then cast so I can look at specific gauge options.

Is there a way to do that? Am I missing something?

Read Entire Article