小编pir*_*-gh的帖子

为什么使用concat减少数组时TypeScript会推断“从不”类型?

代码胜于语言,因此:

['a', 'b', 'c'].reduce((accumulator, value) => accumulator.concat(value), []);
Run Code Online (Sandbox Code Playgroud)

该代码非常愚蠢,并返回一个复制的数组...

TS抱怨concat的参数:TS2345:类型'string'的参数不能分配给'ConcatArray'类型的参数。

reduce functional-programming reducers typescript

11
推荐指数
3
解决办法
4271
查看次数

为什么'await'在'async'函数返回的代理上触发'.then()'?

我正在用babel(env)编译代码,编译到ES5。

这是代码:

(async () => {
     const p = async () => {
          return new Proxy({}, {
               get: (target, property) => {
                    console.log(property);
               }
          })
     };

     const r = await p();// await calls .then on the result of p()
})();
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 es6-promise babeljs es6-proxy

6
推荐指数
1
解决办法
433
查看次数

为什么 TypeScript 中允许基元和对象相交?

为什么以下没有产生never

type test = string & {name: string}
Run Code Online (Sandbox Code Playgroud)

是因为原始类型不是名义类型的吗?

types typescript

4
推荐指数
1
解决办法
847
查看次数

字符串映射不能处理超过 varchar(255)

一旦 Map String(s) 的总长度大于 255,JPA 将无法提交事务。我在 Play 2 Framework 中使用 JPA 2.0。

@ElementCollection
private Map<EmailNotificationType, String> mailContents = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)

我试过

@列(长度 = 2048)

@高球

@MapKeyColumn(长度 = 2048)

我想尽可能多地坚持下去,因为它的大小是动态的。

java hibernate jpa

2
推荐指数
2
解决办法
5055
查看次数