Number-embedded template literal doesn't validate collect
bugcheckingtsc-behaviour
## TSC
in:
```ts
const invalidNum: `${1}` = 1;
const invalidNum2: `${1}` = "1";
const invalidNum3: `${1}` = "2";
```
out:
```txt
tmp.ts:1:7 - error TS2322: Type '1' is not assignable to type '"1"'.
1 const invalidNum: `${1}` = 1;
~~~~~~~~~~
tmp.ts:3:7 - error TS2322: Type '"2"' is not assignable to type '"1"'.
3 const invalidNum3: `${1}` = "2";
~~~~~~~~~~~
```
## Ezno
in:
```ts
error:
┌─ tmp.ts:2:29
│
2 │ const invalidNum2: `${1}` = "1";
│ ----- ^^^ Type "1" is not assignable to type string
│ │
│ Variable declared with type string
error:
┌─ tmp.ts:3:29
│
3 │ const invalidNum3: `${1}` = "2";
│ ----- ^^^ Type "2" is not assignable to type string
│ │
│ Variable declared with type string
```
关闭于 2024-11-13 2 条评论