FIX typescript

This commit is contained in:
Norbert de Langen 2019-01-28 01:40:11 +01:00
parent de501e24da
commit 52e21c38b3
3 changed files with 17 additions and 6 deletions

View File

@ -101,8 +101,9 @@ export default class NotesPanel extends React.Component<Props, NotesPanelState>
return null;
}
// TODO: maybe memoize
const options = { ...defaultOptions, overrides: { ...defaultOptions.overrides, ...api.getElements(types.NOTES_ELEMENT) } };
// TODO: memoize
const extraElements = Object.entries(api.getElements(types.NOTES_ELEMENT)).reduce((acc, [k, v]) => ({ ...acc, [k]: v.render }), {});
const options = { ...defaultOptions, overrides: { ...defaultOptions.overrides, ...extraElements } };
return value ? (
<Panel className="addon-notes-container">

View File

@ -6,11 +6,11 @@ import { logger } from '@storybook/client-logger';
interface Props {
query: string;
}
interface GiphyState {
src?: string;
interface State {
src: string | null;
}
export default class Giphy extends Component<Props, GiphyState> {
state = {
export default class Giphy extends Component<Props, State> {
state: State = {
src: null,
};
componentDidMount() {

View File

@ -1,3 +1,5 @@
import { ReactElement } from 'react';
export const ADDON_ID = 'storybooks/notes';
export const PANEL_ID = `${ADDON_ID}/panel`;
export const PARAM_KEY = `notes`;
@ -9,6 +11,14 @@ export interface API {
emit(event: string, callback: (...args: any) => any): void;
getParameters(id: string, scope?: string): undefined | Parameters;
getElements(
type: string
): {
[id: string]: {
id: string;
render: () => ReactElement<any>;
};
};
}
interface TextParameter {