这个警告是什么意思?
条件始终为真,因为类型“string”和“null”没有重叠
有问题的代码:
function foo() {
let input: string | null = prompt("test");
if (input !== null) {
console.log("not aborted");
}
}
这似乎只发生在
<script setup lang="ts">
文件的 .vue
部分,而不是在独立的 .ts
文件中。
我的
tsconfig.json
有 strict
和 isolatedModules
设置为 true
.