Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
为什么类型参数不被推断为联合类型?
这段代码 declare function fn
typescript
typescriptgenerics
重载签名、联合类型和“没有重载与此调用匹配”错误
想象一个 TypeScript 4 2 2 函数接收一个string or a Promise
typescript
typescriptgenerics
与仅使用接口相比,此返回类型从不做什么?
在尝试用 Typescript 创建工厂时 我遇到了本文 https medium com codex factory pattern type script implementation with type map ea422f38862
typescript
typescripttypings
typescriptgenerics
混合联合类型、泛型和条件类型会导致意外的“类型不可分配给类型”错误
我遇到了类型推断的问题 特别是当条件类型在联合类型中使用时 可能有一种更短的方法来证明这个问题 但我找不到一个 在此查看实际问题游乐场链接 https www typescriptlang org play ts 3 9 7 code PT
Typescript 参数 - 对象的通用数组和对象键的数组(部分)
我想要一个接受对象数组和一些对象键数组的方法 该方法将返回对象值数组的数组 但仅返回选定键的数组 data firstName Jane lastName Doe firstName John lastName Doe fields fir
Arrays
typescript
typescriptgenerics
keyof
为什么TS中的通用接口不能正确推断类型?
一旦 延长Explicit value 在泛型接口中使用时 TS 的类型系统会变得 愚蠢 即使代码 100 正确 function fn
typescript
typescriptgenerics
如何在 TypeScript 中使可为 null 的属性可选?
我有这样的类型 type City name string id number null 并想把它变成这样的类型 type City name string id number 我已经看到很多帖子解释如何使可选类型可以为空 但我想要相反的东
typescript
typescriptgenerics
带有 'as' 属性的通用 React TypeScript 组件(能够渲染任何有效的 dom 节点)
我在下面的示例中按预期工作 我的问题是 无论如何我可以重写它 这样我就不必传递通用的T和as支柱 理想情况下我想通过asprop 并让组件的 prop 接口使用它 这在 TypeScript 中可能吗 export type Props l
javascript
ReactJS
typescript
typescriptgenerics
是否可以在打字稿中重用泛型类型?
我想做这样的事情 namepace Namespace
typescript
typescriptgenerics
TypeScript 提供(未指定)泛型类型作为泛型参数
我希望提供一个泛型类型作为类型参数无需先将其解析为具体类型 换句话说 我正在寻找一种方法来指定从基类继承时可以使用的类型映射函数 示例 不正确的 语法希望比我能解释得更好 abstract class RunIt
typescript
typescriptgenerics
从 Angular 11 更新到 12 时,MatSelect OverlayDir 现在是私有的。现在如何访问它?
在 Angular 11 中 node modules angular material select 中有一个变量 Overlay pane containing the options deprecated To be turned i
第二个函数参数的条件类型
我有以下功能 function doSomething param1 string param2 string return param1 param2 我也有基于 json 的类型 其结构看起来与此类似 a1 b1 something1
typescript
literals
typescriptgenerics
Typescript 通用联盟
所以我有通用对象数组 想要迭代但打字稿不允许我 这是一些示例代码 有关如何解决此问题的任何建议 type someGeneric
typescript
typescripttypings
typescriptgenerics
仅覆盖一些通用变量
考虑以下场景 class Test a const TestValue Test a
typescript
typescriptgenerics
Typescript 泛型 - “扩展对象”毫无意义吗?最佳实践是什么?
我注意到了 p 泛型通常是没有意义的 因为基本上 javascript 中的所有内容都是对象 大多数文字都是具有 toString 方法的对象 字符串是具有 length 属性等的对象 我更喜欢 p p 但很好奇其他人注意到了什么 我现在没
typescript
typescriptgenerics
如何为十六进制颜色字符串创建独立类型?
我正在尝试在 TypeScript 中创建一个独立类型 可用于将单个有效的十六进制颜色代码表示为完全类型安全的字符串 我的尝试如下 但由于实际上不是独立类型而未能实现 而这正是我希望实现的目标 type HexDigit
typescript
Colors
Hex
typescriptgenerics
colorcodes
更窄的类型不能分配给其他类型
有两种类型 type ExcludeString
typescript
typescripttypings
typescriptgenerics
我可以在 juxt 函数中使用映射元组类型吗?
juxt 调用函数数组来返回值数组 文件 ramda https ramdajs com docs juxt clojure https clojuredocs org clojure core juxt 我正在尝试输入一个不带覆盖的数据优
typescript
typescriptgenerics
ramdajs
TypeScript:具有自定义方法的工厂 - 第三步
我在一家工厂工作 我最终需要添加自定义方法 谢谢这个答案 https stackoverflow com a 70334385 4690946 and 这个答案 https stackoverflow com a 70361134 4690
typescript
typescriptgenerics
Typescript - 逐步扩展对象的类型
我试图通过 TS 实现以下目标 let m Extendable m add one 1 m now has one field m add two 2 m now has one and two fields 我熟悉通过以下方式在 TS
typescript
typescriptgenerics
1
2
3
4
5
»