小编Mar*_*ras的帖子

是否有可能在合并之前获得合并提交的哈希?

假设我有 2 个分支 - master 和 feature。此外,我有一个拉取请求,其中包含 2 次从功能到主控的提交。如果我合并它,我将有一个合并提交。这个提交在合并之前已经以某种方式配置了吗?我可以看看它吗?我知道我可以获得 refs/pull-requests/1/from 和 refs/pull-requests/1/merge 分支的哈希值,但是我可以得到类似“合并”提交的信息吗?

git

5
推荐指数
1
解决办法
567
查看次数

检查数组是否为空或包含值,打字稿

我以这种方式检查数组是否包含该值:

testArray.includes(value)
Run Code Online (Sandbox Code Playgroud)

如果数组为空或它包含该值,我需要执行相同的操作。所以我有这样的条件:

if (testArray == [] || testArray.includes(value)) {
    // do something
}
Run Code Online (Sandbox Code Playgroud)

typescript正在尝试执行此条件的第二部分,即使testArray == []。所以我收到一个错误testArray.includes is underfined

我知道我可以这样修复它:

if (testArray == []) {
    // do something
} else if (testArray.includes(value)) {
    // do the same thing
}
Run Code Online (Sandbox Code Playgroud)

但看起来不太好。有没有办法把它放在一个if中?

testArray是一个 openapi 查询参数,如果它很重要的话。

arrays typescript

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

是否可以在装饰器函数中使用函数的返回值?

我想使用函数的输出值作为该函数正在使用的装饰器的输入。例如,类似的事情:

function dec(otherFuncOutput: string) {
  console.log(otherFuncOutput)
}

@dec
function otherFunc(): string {
  const otherFuncOutput: string = "output";
  return otherFuncOutput;
}
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?

typescript typescript-decorator

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

标签 统计

typescript ×2

arrays ×1

git ×1

typescript-decorator ×1