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

TypeScript definition for dataset and plugin options #105

Closed
Laroosta opened this issue Dec 14, 2018 · 8 comments
Closed

TypeScript definition for dataset and plugin options #105

Laroosta opened this issue Dec 14, 2018 · 8 comments

Comments

@Laroosta
Copy link

Laroosta commented Dec 14, 2018

Hi,

I'm currently getting typing errors when adding datalabels to a dataset, which is then preventing the app to compile.

If I manually add the datalabels properties in the @types/chart.js file, it works fine, but this is not a proper solutions, as one should not add specific properties to the chart.js typings library for a plugin.

For now I had to duplicate the chart.js typings and add them as a typeRoots to the project. This means that the typings need to maintained locally.

Does anyone know how this problem can be solved? Is it not possible to extend the chart.js typings and add the plugin specific properties?

@simonbrunel
Copy link
Member

@Laroosta can you share a minimal project that reproduces this issue and instructions to build it?

@Laroosta
Copy link
Author

@simonbrunel sure, here is a test project:
https://bitbucket.org/laroosta/chartjs-plugin-datalabels-problem/src/master/

npm i -g ionic
cd to folder:
npm i
ionic serve

Let me know if you have any issues getting the project going.

Thanks in advance!

@simonbrunel
Copy link
Member

simonbrunel commented Dec 16, 2018

@Laroosta Thanks!

I will take a look to add a TypeScript definition for this project (inside this repository) but it may take a while to get it in and released. In the meantime, I think you can create a minimal definition file to prevent compilation errors, for example:

/src/pages/homes/chartjs-plugin-datalabels.d.ts:

declare module 'chart.js' {
    interface ChartDataSets {
        datalabels?: any
    }
}

/src/pages/homes/home.ts:

///<reference path="chartjs-plugin-datalabels.d.ts" />
import { Component, OnInit, ViewChild, ElementRef } from "@angular/core";
// ...

@simonbrunel simonbrunel changed the title Typings for datasets TypeScript definition for dataset and plugin options Dec 16, 2018
@Laroosta
Copy link
Author

Laroosta commented Dec 16, 2018 via email

@simonbrunel simonbrunel added this to the Version 0.6 milestone Dec 21, 2018
@simonbrunel simonbrunel self-assigned this Dec 27, 2018
@simonbrunel
Copy link
Member

simonbrunel commented Jan 30, 2019

TypeScript definition files added in 9e00265, will be released in v0.6.0

@RiQuY
Copy link

RiQuY commented Mar 13, 2019

This would be very useful, is the v0.6.0 far from be released?
If yes, do you know a way to apply this to a project on TypeScript that I'm working on before v0.6.0 release?

EDIT: Would this be added to https://github.com/DefinitelyTyped/DefinitelyTyped/ like @types/chartjs-plugin-datalabels to be able to import it in TypeScript like: import { ChartDataLabels } from 'chartjs-plugin-datalabels';?

@simonbrunel
Copy link
Member

v0.6.0 is about to be released (probably this week)

do you know a way to apply this to a project on TypeScript that I'm working on before v0.6.0 release?

No, I don't (I don't use TypeScript myself)

Would this be added to DefinitelyTyped ... ?

I don't think so because it will conflict with the one in this repository.

@simonbrunel
Copy link
Member

Version 0.6.0 has been released.

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

No branches or pull requests

3 participants