Repository: TypeScript
Issue: Destructured tuple elements are no longer literals
Labels: Bug,Help Wanted

<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!

Please help us by doing the following steps before logging an issue:
  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues
  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ

Please fill in the *entire* template below.
-->

**TypeScript Version:**  3.9.0-dev.20200315

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**

- tuple
- destructuring
- literal types
- literals
- inline
- indexed access

**Expected behavior:**

When destructuring a tuple of array literals, destructured elements should preserve literal values.

**Actual behavior:**

Destructured elements are not literals.

<!-- Did you find other bugs that looked similar? -->
**Related Issues:**

- #32003
- #31613

**Code**

If I create a tuple of literals:

```ts
declare function enumerate<T>(): <U extends T[]>(...elements: U) => U;

type Color = 'black' | 'white';

// $ExpectType ["black", "white"] ✅
const colors = enumerate<Color>()('black', 'white');
```

the accessed elements are also literals; regardless of whether I destructure them inline or read them in separate lines. That's good.

```ts
// $ExpectType ["black", "white"] ✅
const [primo, secundo] = colors;

// $ExpectType "black" ✅
const first = colors[0];

// $ExpectType "white" ✅
const second = colors[1];
```

However, when I do the same with a tuple returned by a function, their “literalness” is preserved only when the values are read using the square bracket notation:

```ts
// $ExpectType "black" ✅
const erste = enumerate<Color>()('black', 'white')[0];

// $ExpectType "white" ✅
const zweite = enumerate<Color>()('black', 'white')[1];
```

but not when the assignment happens via destructuring:

```ts
// $ExpectType ["black", "white"], received [Color, Color] ⛔️
const [one, two] = enumerate<Color>()('black', 'white');
```

<details><summary><b>Output</b></summary>

```ts
"use strict";
// $ExpectType ["black", "white"] ✅
const colors = enumerate()('black', 'white');
// $ExpectType ["black", "white"] ✅
const [primo, secundo] = colors;
// $ExpectType "black" ✅
const first = colors[0];
// $ExpectType "white" ✅
const second = colors[1];
// $ExpectType "black" ✅
const erste = enumerate()('black', 'white')[0];
// $ExpectType "white" ✅
const zweite = enumerate()('black', 'white')[1];
// $ExpectType ["black", "white"], received [Color, Color] ⛔️
const [one, two] = enumerate()('black', 'white');

```


</details>


<details><summary><b>Compiler Options</b></summary>

```json
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": 2,
    "target": "ES2017",
    "jsx": "React",
    "module": "ESNext"
  }
}
```


</details>

**Playground Link:** [Provided](https://www.typescriptlang.org/play?ts=next#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXxFWQFsQYoMQAeAFQD4AKASgC54qBVAgD0tWADO8GgG0AuowB00kBBClUGAWw5N4AXjrwOAbgCwAKEMYAngAcEAYRwQcMDfADkAI2hgA1o-gAfJwHcACyxKR30jAwB6CPgAEgBRbgtMGnMEEQAiVygPdIAaeHTA4JB0sXhAUHJDMDwBDHhq2xghdQIiUnJKKmtGxiYGFzdPfMcikKYwwyjYhKSMFIt4DKyc-MKgylKKqpq6kTMYLGIcfIFwNGAcMpaGuwEJyOj4xPA51ILl93Stg2rUWqQsE06tcbLcRAAGMT3KZPWbzBBrYpfSo-HbwU6-YAOG5NEQARihhkmjxmL3h70GyO2fzqZFqCBahBIZAo1G6dl6-Q+jmGoxAjiYEMJ4RhpOSb0RG2+v3+AC8-CBig4me1WV1QTBOQNskN-Ot+YKCdCSc9xQslpTVnzSvk4GBFQA3EBYkTsmD5N1lQArZIB4P+p-xEeBA+QwfkuyraLM6bq13N5+oF9yAA)