可以扩展接口并修改父属性而无需重新声明所有属性?

时间:2016-07-13 09:19:48

标签: typescript

我有接口IObfuscatorOptions,它描述了包自定义选项对象(对于用户)。

export interface IObfuscatorOptions {
    compact?: boolean;
    debugProtection?: boolean;
    debugProtectionInterval?: boolean;
    disableConsoleOutput?: boolean;
    encodeUnicodeLiterals?: boolean;
    reservedNames?: string[];
    rotateUnicodeArray?: boolean;
    selfDefending?: boolean;
    sourceMap?: boolean;
    sourceMapMode?: TSourceMapMode;
    unicodeArray?: boolean;
    unicodeArrayThreshold?: number;
    wrapUnicodeArrayCalls?: boolean;
    [key: string]: any;
}

现在我想创建一个包含成员的内部类Options - 来自IObfuscatorOptions的所有选项。 此类将实现接口IOptions

我希望该界面IOptions包含IObfuscatorOptions的所有选项,但不包含optional修饰符和readonly修饰符。

如果不像我现在那样重新声明所有IObfuscatorOptions属性,可以这样做吗?

// bad bad bad
export interface IOptions {
    readonly compact: boolean;
    readonly debugProtection: boolean;
    readonly debugProtectionInterval: boolean;
    readonly disableConsoleOutput: boolean;
    readonly encodeUnicodeLiterals: boolean;
    readonly reservedNames: string[];
    readonly rotateUnicodeArray: boolean;
    readonly selfDefending: boolean;
    readonly sourceMap: boolean;
    readonly sourceMapMode: TSourceMapMode;
    readonly unicodeArray: boolean;
    readonly unicodeArrayThreshold: number;
    readonly wrapUnicodeArrayCalls: boolean;
}

0 个答案:

没有答案