语法问题咨询:SyntaxError: Initializers are not allowed in ambient contexts.?

如题:语法问题咨询:SyntaxError: Initializers are not allowed in ambient contexts.?

阅读 776
1 个回答

通过使用 declare 它将定义一个类类型。类型只是定义的,不应该有实现。

export declare namespace UKey {
  const ALG: number;

  interface IKey {
    GetLibVersion(): string;
  }

  abstract class CodeException extends Error {
    static readonly SUCCESS:number;
    static readonly OPERATION_FAILED:number;

    abstract getErrorCode(): number

    abstract getMessage(): string;
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进