What does the ! (exclamation mark) operator mean when accessing an object property in TypeScript?
Hi everyone! I recently started learning TypeScript and came across a construct I don't understand. In a colleague's code, I saw the use of an exclamation mark after a variable or before accessing an object property. For example:
```typescript
const userName: string | null = getUserName();
const length = userName!.length;
```
Or this variant:
```typescript
interface User {
name?: string;
email?: string;
}
function getUserEmail(user: User): string {
return user.email!;
}
```
I understand that `?` means an optional value (can be undefined or null). But what does `!` do? Is it some kind of forced access operator? Won't it cause a runtime error if the value actually turns out to be null or undefined?
I tried Googling, but everywhere they write