---
url: /docs/guide/usage/linter/rules/unicorn/no-thenable.md
---

### 它的作用

禁止定义 `then` 属性。

### 为什么这不好？

如果一个对象被定义为“thenable”，一旦它被意外地
用于 `await` 表达式中，可能会导致问题。

### 示例

以下是此规则的**错误**代码示例：

```javascript
async function example() {
  const foo = {
    unicorn: 1,
    then() {},
  };

  const { unicorn } = await foo;

  console.log("after"); // <- 这永远不会执行
}
```

以下是此规则的**正确**代码示例：

```javascript
async function example() {
  const foo = {
    unicorn: 1,
    bar() {},
  };

  const { unicorn } = await foo;

  console.log("after");
}
```

## 如何使用

## 版本

此规则在 v0.0.13 中加入。

## 参考资料
