google / google/closure-compiler

Object spread fails to type check

Open
#3,132 4 comments 0 reactions 0 assignees View on GitHub
bug internal-issue-created P3 triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Given

```js
/** @param {{x: number, y: string}} x */
function f(x) {}

/** @type {{y: string}} */
const o = {y: "a"};

f({x: 1, ...o})
```

https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%250A%252F**%2520%2540param%2520%257B%257Bx%253A%2520number%252C%2520y%253A%2520string%257D%257D%2520x%2520*%252F%250Afunction%2520f(x)%2520%257B%257D%250A%250A%252F**%2520%2540type%2520%257B%257By%253A%2520string%257D%257D%2520*%252F%250Aconst%2520o%2520%253D%2520%257By%253A%2520%2522a%2522%257D%253B%250A%250Af(%257Bx%253A%25201%252C%2520...o%257D)

I'm getting a type error. I assume this is just because object spread is not fully implemented yet?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.