Skip to content

Commit 4c7a0cb

Browse files
committed
docs(assert): fixed #100
1 parent 84474db commit 4c7a0cb

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

docs/assert.md

-9
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,6 @@ const s2:string = value as string; // 正确
114114

115115
上面示例中,unknown 类型的变量`value`不能直接赋值给其他类型的变量,但是可以将它断言为其他类型,这样就可以赋值给别的变量了。
116116

117-
另外,类型断言也适合指定联合类型的值的具体类型。
118-
119-
```typescript
120-
const s1:number|string = 'hello';
121-
const s2:number = s1 as number;
122-
```
123-
124-
上面示例中,变量`s1`是联合类型,可以断言其为联合类型里面的一种具体类型,再将其赋值给变量`s2`
125-
126117
## 类型断言的条件
127118

128119
类型断言并不意味着,可以把某个值断言为任意类型。

0 commit comments

Comments
 (0)