typescript 记录良好的打字稿界面

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript 记录良好的打字稿界面相关的知识,希望对你有一定的参考价值。

import AsyncData from '@/util/AsyncData';
import { AxiosError } from '../axios';
import RefreshableData from '@/util/RefreshableData';

export interface IDeploymentHistoryRecord {
  appId: number;
  created: string; // ISO 8601 Datetime String
  createdBy: string; // SSO
  current: boolean;
  envId: number;
  id: number;
  // TODO: What all can these be?
  status: 'SUCCESS' | 'FAILED' | 'WORKING' | 'QUEUED';
  // TODO: What all can these be?
  statusMessage: 'SUCCESS' | 'FAILED' | 'DEPLOYING' | 'QUEUED' | 'DELETING';
  svcId: number;
  totalEvents: number;
  totalPropertie: number;
  updated: string; // ISO 8601 Datetime String
  updatedBy: string; // SSO
  uuid: string; // UUID
  version: string; // Hopefully Semver, but it could technically be anything.
}

export interface IAvailableVersion {
  /**
   * The name of this version, hopefully in semver.
   */
  name: string;
}

export interface ICurrentDeploymentStatus {
  /**
   * ID of the service being deployed.
   */
  id: number;
  /**
   * Backend status of the deployment.
   *
   * NOTE: If there are no deploys, the backend returns 'QUEUED'?
   *
   * TODO: Get full list.
   */
  status: 'SUCCESS' | 'FAILED' | 'WORKING' | 'QUEUED';
  /**
   * Friendlier status of the deployment.
   *
   * NOTE: If there are no deploys, the backend returns 'QUEUED'?
   *
   * TODO: Get full list.
   */
  statusMessage: 'SUCCESS' | 'FAILED' | 'DEPLOYING' | 'QUEUED' | 'DELETING';
  /**
   * Version selected for this deploy.
   *
   * NOTE: If there are no deploys, the backend returns null.
   */
  versionSelected: string | null;
}

export interface ICurrentDeploymentStatusWatch {
  /**
   * ID of the service whose status is currently being watched.
   */
  serviceId: number;
  /**
   * ID of the timeout until next ping.
   *
   * This will probably change to something else if switching to
   * websockets or server-sent events or something.
   */
  timeoutId: number | null;
  /**
   * Timeout time.
   */
  timeoutTime: number | null;
  /**
   * Current status, as a RefreshableData instance.
   */
  status: RefreshableData<CurrentDeploymentStatusData>;
}

export type DeploymentHistoryData = AsyncData<IDeploymentHistoryRecord[], AxiosError>;
export type AvailableVersionsData = AsyncData<IAvailableVersion[], AxiosError>;
export type CurrentDeploymentStatusData = AsyncData<ICurrentDeploymentStatus, AxiosError>;

export default interface IDeploymentsPage {
  // TODO: Better types.
  /**
   * State specific to the Deployments Tab.
   */
  deploymentTab: {
    /**
     * What versions are available to deploy.
     * These come from the server sorted newest-first, i.e. in descending order.
     */
    availableVersions: AvailableVersionsData;
    /**
     * Past deploys of the selected service,
     * listed in descending order by date of record creation.
     */
    history: DeploymentHistoryData;
    downloadEvents: object[];
  };
  // /**
  //  * Status of the current deployment if any.
  //  */
  // currentDeploymentStatus: CurrentDeploymentStatusData;
  /**
   * Watch for the Current Deployment Status.
   */
  currentDeploymentStatusWatch: ICurrentDeploymentStatusWatch;
  events: object[];
  versions: object[];
}

以上是关于typescript 记录良好的打字稿界面的主要内容,如果未能解决你的问题,请参考以下文章

用玩笑模拟打字稿界面

通过打字稿的界面来反应状态[重复]

如何将打字稿界面转换为棱镜模型

离子 2 - 打字稿 |填充接口对象数组

打字稿类型定义 - 继承

打字稿:嵌套对象的深度键