TypeScript类型忽略大小写

TypeScript类型忽略大小写

本文介绍了TypeScript类型忽略大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在TypeScript中具有以下类型定义:

I have this type definition in TypeScript:

export type xhrTypes = "GET" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "CONNECT" | "HEAD";

不幸的是,这是区分大小写的...是否有任何方法可以区分大小写?

Sadly, this is case sensitive...is there any way to define it case insensitive?

谢谢

推荐答案

就这么一个答案:不,

Just so there's an answer on this post: No, it is not possible.

更新5/15/2018 :仍然不可能。最接近的东西,即正则表达式验证的字符串类型,在最近一次在语言设计会议上提出时并没有得到很好的接受。

Update 5/15/2018: Still not possible. The closest thing, regex-validated string types, was not well-received the most recent time it was proposed at the language design meeting.

这篇关于TypeScript类型忽略大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 17:29