Centralized TypeScript type definitions for plotly.js.
// Import from main index (recommended)
import type { GraphDiv, Layout, PlotData } from '../types';
// Or use path alias
import type { GraphDiv } from '@types';types/
├── index.d.ts # Main export - import from here
├── core/ # Core Plotly types (GraphDiv, Layout, Data, Config, Events)
├── traces/ # Trace-specific types
├── components/ # Component-specific types
├── plots/ # Plot-specific types
└── lib/ # Utility types
import type { GraphDiv } from '../types';
function draw(gd: GraphDiv): void {
const layout = gd._fullLayout;
const data = gd._fullData;
}import type { Layout } from '../types';
function updateLayout(layout: Partial<Layout>): void {
layout.title = 'New Title';
}import type { PlotData, ScatterTrace } from '../types';
function processTrace(trace: PlotData): void {
if (trace.type === 'scatter') {
const scatter = trace as ScatterTrace;
}
}- Create file in appropriate subdirectory
- Export from
index.d.ts - Use in your TypeScript files