Repository: TypeScript
Issue: Prevent spreading of promises, as it's likely not intended
Labels: Suggestion,Experience Enhancement

# Suggestion

Spreading a promise in an object is correct Javascript, and Typescript allows it. But it doesn't do anything:
```ts
{ ...Promise.resolve({ key: 42 }) } // returns {}
```

Any time you're trying to spread a promise, it's much more likely that you have an async function that you forgot to await. The following code compiles.
```ts
const myAsyncFunc = () => Promise.resolve({ key: 42 });

const result = {
  foo: 'bar',
  ...myAsyncFunc(),
}; 
```

While this is "correct", it's almost certainly not what the programmer intended.

## 🔍 Search Terms

<!--
  💡 Did you know? TypeScript has over 2,000 open suggestions!
  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
  The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests

  Replace the text below:
-->

Spreading promise.

## ✅ Viability Checklist

<!--
   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
   We always recommend reviewing the TypeScript design goals before investing time writing
   a proposal for ideas outside the scope of the project.
-->
My suggestion meets these guidelines:

* [ ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).

(I'm not sure about the first point. This would be a breaking change, but it should only affect code that likely contains a bug. The feature request does support the goal of "Statically identify constructs that are likely to be errors.")


## ⭐ Suggestion

<!-- A summary of what you'd like to see added or changed -->

Prevent code that spreads promises from compiling.

## 📃 Motivating Example

<!--
  If you were announcing this feature in a blog post, what's a short explanation that shows
  a developer why this feature improves the language?
-->

As it's almost certainly unintended, Typescript should prevent promises from being spread in objects.

## 💻 Use Cases

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

This would prevent a bug that I personally faced recently. I can't think of any scenario where someone would intentionally want to spread a promise.

An IDE or a plugin could detect that you're spreading a function marked as `async`, but I'm not sure whether they would be able to detect that a function returns a promise, or that a function returns the result of another function call that returns a promise.