Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何扩展$tw api #21

Open
oeyoews opened this issue Dec 30, 2023 · 2 comments
Open

如何扩展$tw api #21

oeyoews opened this issue Dec 30, 2023 · 2 comments

Comments

@oeyoews
Copy link
Contributor

oeyoews commented Dec 30, 2023

如果希望在项目中扩展一些自定义的api, 下面的这种方法似乎不能覆盖 掉原有的$tw

import { ITiddlyWiki } from 'tw5-typed';

export interface TiddlyWiki extends ITiddlyWiki {
  Notify: {
    name: string;
  };
}

declare global {
  export const $tw: TiddlyWiki;
}
@linonetwo
Copy link
Contributor

在 src\core.d.ts , 你看

    wiki: Wiki;
    boot: IBoot;
    crypto: Crypto;
    utils: IUtils;
    config: IConfig;
    version: string;
    safeMode: boolean;
    modules: IModules;
    rootWidget: Widget;
    notifier: Notifier;
    language: ILanguage;
    locationHash: string;
    fakeDocument: IFakeDocument;
    passwordPrompt: PasswordPrompt;
    packageInfo: Record<string, unknown>;
    modal: IModal;

那一大摞

@oeyoews
Copy link
Contributor Author

oeyoews commented Dec 30, 2023

似乎只能通过直接修改 core.d.ts 的方式修改 ITiddlywiki 接口, 不能 直接在项目的 types.d.ts 里面继承 该接口,然后覆盖

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

No branches or pull requests

2 participants