Skip to content

Commit

Permalink
fix: try to fix storybook build error
Browse files Browse the repository at this point in the history
  • Loading branch information
zyf722 committed Aug 4, 2024
1 parent 2a96337 commit a204bce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
23 changes: 1 addition & 22 deletions src/livecodes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,6 @@ import {
} from './i18n/utils';
import type { I18nTranslationTemplate } from './i18n/locales/models';

// declare global dependencies
declare global {
interface Window {
deps: {
showMode: typeof showMode;
/**
* String-level i18n helper function.
* @param key The key of the translation.
* @param value The default value to translate.
* @param args The interpolation object.
* @returns The translated string.
*/
translateString: <Key extends I18nKeyType, Value extends string>(
key: Key,
value: I18nValueType<Key, Value>,
...args: I18nInterpolationType<I18nValueType<Key, Value>>
) => string;
};
}
}

const stores: Stores = createStores();
const eventsManager = createEventsManager();
let notifications: ReturnType<typeof createNotifications>;
Expand Down Expand Up @@ -523,7 +502,7 @@ const updateEditors = async (editors: Editors, config: Config) => {
}
};

const showMode = (mode?: Config['mode']) => {
export const showMode = (mode?: Config['mode']) => {
if (!mode) {
mode = 'full';
}
Expand Down
25 changes: 25 additions & 0 deletions src/livecodes/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { showMode } from './core';

// eslint-disable-next-line import/no-internal-modules
import type { I18nKeyType, I18nValueType, I18nInterpolationType } from './i18n/utils';

// declare global dependencies
declare global {
interface Window {
deps: {
showMode: typeof showMode;
/**
* String-level i18n helper function.
* @param key The key of the translation.
* @param value The default value to translate.
* @param args The interpolation object.
* @returns The translated string.
*/
translateString: <Key extends I18nKeyType, Value extends string>(
key: Key,
value: I18nValueType<Key, Value>,
...args: I18nInterpolationType<I18nValueType<Key, Value>>
) => string;
};
}
}
1 change: 1 addition & 0 deletions storybook/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="../../src/livecodes/global.d.ts" />
export * from './LiveCodes';

0 comments on commit a204bce

Please sign in to comment.