Skip to content

Instantly share code, notes, and snippets.

@stevenvachon
Last active January 8, 2020 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenvachon/92d8dac8032f1ca6b213ebb9549afd11 to your computer and use it in GitHub Desktop.
Save stevenvachon/92d8dac8032f1ca6b213ebb9549afd11 to your computer and use it in GitHub Desktop.
TypeScript issue
declare module '@finos/perspective-viewer' {
export interface PerspectiveViewer extends PerspectiveViewerOptions, HTMLElement {
load(data: TableData | Table, options?: TableOptions): void;
load(schema: Schema, options?: TableOptions): void;
update(data: TableData): void;
notifyResize(): void;
delete(delete_table: boolean): Promise<void>;
clear() : void;
replace(data: TableData) : void;
flush(): Promise<void>;
toggleConfig(): void;
save(): PerspectiveViewerOptions;
reset(): void;
restore(x: any): Promise<void>;
restyleElement(): void;
readonly table?: Table;
}
}
// ...
ERROR in /component.tsx(6,10)

TS2740: Type '{ ref: RefObject<PerspectiveViewer>; }' is missing the following properties from type 'PerspectiveViewer': load, update, notifyResize, delete, and 249 more. 
import { PerspectiveViewer } from 'types';
import React, { createRef, PureComponent } from 'react';
import '@finos/perspective-viewer';
export class PerspectivePanel extends PureComponent {
perspectiveViewer = createRef<PerspectiveViewer>();
render() {
return (<perspective-viewer ref={this.perspectiveViewer} />);
}
}
import { PerspectiveViewer as PerspectiveViewerOriginal } from '@finos/perspective-viewer';
import { Ref } from 'react';
// @todo https://github.com/Microsoft/TypeScript/issues/16936
export interface PerspectiveViewer extends PerspectiveViewerOriginal {
ref: Ref<PerspectiveViewerOriginal>;
}
declare global {
namespace JSX {
interface IntrinsicElements {
'perspective-viewer': PerspectiveViewer;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment