Skip to content

Additions Plotly.js Type Definition - #17108

Merged
sandersn merged 2 commits into
DefinitelyTyped:masterfrom
chrisgervang:plotly
Jun 22, 2017
Merged

sandersn merged 2 commits into
DefinitelyTyped:masterfrom
chrisgervang:plotly

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Jun 10, 2017 •

Copy link
Copy Markdown
Contributor

added Legend, Axis title, and Data types are Partials

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

@dt-bot

dt-bot commented Jun 10, 2017

Copy link
Copy Markdown
Member

types/plotly.js/index.d.ts

to author (@martinduparc). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

@wismill

wismill commented Jun 12, 2017

Copy link
Copy Markdown

Hi, it seems there is a mistake at the end of the file.

I have replaced:

export = Plotly;

by:

declare module "plotly.js" {
    export = Plotly;
}

and then it works.

@wismill

wismill commented Jun 12, 2017 •

Copy link
Copy Markdown

Axis is missing title: string

@chrisgervang

chrisgervang commented Jun 12, 2017 •

Copy link
Copy Markdown
Contributor Author

@wismill I'm not sure what you meant by the second comment. The Axis type was previously missing the title attribute, but now it has been added.

The correct way to import this package is import * as Plotly from 'plotly', right?

Like you said, I do believe we should add

declare module 'plotly' {
    var Plotly: Plotly.PlotlyStatic;
    export = Plotly;
}

to the definition. maybe it's named plotly.js? I'm not sure. In my app I've add the snippet above with the name 'plotly' and it works.

@minestarks

minestarks commented Jun 15, 2017 •

Copy link
Copy Markdown
Contributor

@wismill @chrisgervang
What you already have should work for the module. I don't see a reason to add the declare module.

If your goal is to get typings for the Plotly global (i.e. for using the CDN) you just need to add

export as namespace Plotly;

at the end.

@sandersn
sandersn merged commit c8f15d7 into DefinitelyTyped:master Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants