Does Google Charts have TypeScript definition file(s)?
Asked Answered
T

2

6

I want to use Google Charts with TypeScript, but I'm not sure if Google Charts has .d.ts file(s). Does anyone know if they're out there available for download and if yes, can you link them?

Tripinnate answered 25/5, 2017 at 0:55 Comment(6)
Might be of interest: github.com/DefinitelyTyped/DefinitelyTyped/issues/15835Tsingyuan
thanks but that's for angular google chart and I'm not using Angular I'm using ReactTripinnate
I believe the project is merely an angular wrapper, but there is a typings file in that repository: github.com/angular-google-chart/google-chart-typings/blob/… - it doesn't seem to be related to angular in particular.Tsingyuan
oh, that's awesome, thanks....have you used it personally? do you have an idea of how complete it is?Tripinnate
Sorry, no - I haven't actually used it; though it's the only result I could find. Might be worth while contacting the author and asking how complete it is, and seeing if it's possible to have it pulled into the DefinitelyTyped repository for othersTsingyuan
The repository description says "very incomplete and work in progress"...perhaps I should look into other charting librariesTripinnate
L
8

It does (at least nowadays), called google.visualization:

npm install @types/google.visualization
Latrice answered 21/5, 2018 at 17:28 Comment(4)
still up to date?Lager
I added that and still get [lint] [tsc] src/pages/charts.tsx:23:18 - error TS2304: Cannot find name 'google'.Lager
you need to add "google.visualization" to tsconfig.app.json compilerOptions -> types arraySideman
@Sideman I tried with this but it still gives me this error: .../@types/google.visualization/index.d.ts' is not a module.Pricilla
E
0

You can see them on github: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/google.visualization

You can download index.d.ts file

Equalizer answered 19/10, 2020 at 16:36 Comment(2)
how to add this to file so that google var is recognised? google.charts.load('current', { packages: ['corechart', 'bar'] });Lager
install @types/google.visualization and add "google.visualization" to tsconfig.app.json compilerOptions -> types arraySideman

© 2022 - 2024 — McMap. All rights reserved.