回答編集履歴
1
エラーメッセージを追加
answer
CHANGED
@@ -20,12 +20,16 @@
|
|
20
20
|
|
21
21
|
具体的に、`A1`が`any`、`A2`が`string`であるケースを考えてみます:
|
22
22
|
|
23
|
-
[playground](https://www.typescriptlang.org/play?#code/
|
23
|
+
[playground](https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEEQBd4A8Bc8A8BBAfABQCU8AvPvLvCGsiAHbADO8zyMAlgwObwD88AIzwsABgBQoSLARJUATyzYAQkVIV4KmnUYt4UBgoHDR8SQHoL8QBUMgS4ZAPwyAsf8AADIGO5QKaKgcwZAsgyArBkARBgkreAAVBQAHBAByVXVySm1aeiZWQ2NBEXFo+E5WBgB7VChmZk4eBigAIyR4ZAK6yJi8eM1qZL1Wdi5eEyzzaIA6YOswpvho9t1UgyM+szEcvPhC4tLyypqEesaoiamU-W7uPkyFoZH4K7G96LF4AB9hJfyig3WK6tqd5HHJnUOXQ4J3m2WGIWuV3Ct0WuVeazKny2dQav1uB06bGBvTOYMIACYAMz4-HECRocjwBRAA)
|
24
24
|
|
25
25
|
```
|
26
26
|
declare let x: <A>() => A extends string ? 1 : 0
|
27
27
|
declare let y: <B>() => B extends any ? 1 : 0
|
28
28
|
// エラー: 代入できない
|
29
|
+
// Type '<B>() => B extends any ? 1 : 0' is not assignable to type '<A>() => A extends string ? 1 : 0'.
|
30
|
+
// Type 'A extends any ? 1 : 0' is not assignable to type 'A extends string ? 1 : 0'.
|
31
|
+
// Type '0 | 1' is not assignable to type 'A extends string ? 1 : 0'.
|
32
|
+
// Type '0' is not assignable to type 'A extends string ? 1 : 0'.(2322)
|
29
33
|
x = y
|
30
34
|
```
|
31
35
|
|