typescript discriminated_union.ts

Posted

tags:

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

// this is an example of discriminated unions
// this file isn't used in the project

interface ActionAdd {
  type: "ADD",
  payload: string
}

interface ActionDelete {
  type: "DELETE",
  payload: number
}

type Actions = ActionAdd | ActionDelete

function reducer(a: Actions) {
  switch(a.type) {
    case "ADD" : {
      // payload is a string
    }
    case "DELETE" : {
      // payload is a number
    }
  }
}

以上是关于typescript discriminated_union.ts的主要内容,如果未能解决你的问题,请参考以下文章

[mybatis]映射文件_select_resultMap_discriminator鉴别器

Discriminative LocalizationLearning Deep Features for Discriminative Localization 论文解析(转)

discriminator 鉴别器

Mybatis学习第23节 -- 鉴别器 discriminator

线性判别分析(Linear Discriminant Analysis, LDA)算法初识

生成模型(Generative)和判别模型(Discriminative)