3

我使用Clone.clone fromnodegit并且正在寻找进度状态回调。该函数有一个CheckoutOptions对象,我这样称呼它:

var opts: CloneOptions = {};
opts.checkoutOpts = {
    progressCb: function() {
        console.log("Foo");
    },
}

但这似乎使 BrowserWindow 崩溃。有没有人通过查看CheckoutOptions我可能做错的声明?

注意,CheckoutOptions是会员CloneOptions


export class CheckoutOptions {
    version?: number;
    checkoutStrategy?: number;
    disableFilters?: number;
    dirMode?: number;
    fileMode?: number;
    fileOpenFlags?: number;
    notifyFlags?: number;
    notifyCb?: any;
    notifyPayload?: undefined;
    progressCb?: any;
    progressPayload?: undefined;
    paths?: Strarray | string | string[];
    baseline?: Tree;
    baselineIndex?: Index;
    targetDirectory?: string;
    ancestorLabel?: string;
    ourLabel?: string;
    theirLabel?: string;
    perfdataCb?: any;
    perfdataPayload?: undefined;
    [key: string]: any;
}

export class CloneOptions {
    version?: number;
    checkoutOpts?: CheckoutOptions;
    fetchOpts?: FetchOptions;
    bare?: number;
    local?: number;
    checkoutBranch?: string;
    repositoryCbPayload?: any;
    remoteCbPayload?: any;
}
4

1 回答 1

2

尝试使用new CheckoutOptions()而不是仅使用空对象来初始化结帐选项{}

此版本有效:

var opts = {};
opts.checkoutOpts = new CheckoutOptions();
opts.checkoutOpts.progressCb = function(){
    console.log("Foo");
};

这个版本崩溃了:

var opts = {};
opts.checkoutOpts = {};
opts.checkoutOpts.progressCb = function(){
    console.log("Foo");
};
于 2020-09-25T21:19:36.293 回答