1. Remove null | undefined from a union:
NonNullable<T> is a shorthand for excluding null and undefined. It guarantees a defined value.
type MaybeStr = string | null | undefined; type Str = NonNullable<MaybeStr>; // string
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Atlassian · Typescript
Practice Typescript questions specifically asked in Atlassian interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
3
Tagged for this company + subject
Company
Atlassian
View company-wise questions
Subject
Typescript
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Atlassian Typescript round.
NonNullable<T> is a shorthand for excluding null and undefined. It guarantees a defined value.
type MaybeStr = string | null | undefined; type Str = NonNullable<MaybeStr>; // string
For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.
`never` marks code paths that cannot produce a value—such as a function that always throws or an infinite loop. It is also used to enforce exhaustive checks on unions; a fall-through to a `never` variable signals a missing case.
function fail(msg: string): never { throw new Error(msg); }
while (true) { /* ... */ } // type of this loop is never
// Exhaustive example
function assertNever(x: never) { /* compile-time guard */ }The “infer U” captures whatever a Promise resolves to. If T is Promise<string>, U becomes string.
type P<T> = T extends Promise<infer U> ? U : T; type A = P<Promise<'ok'>>; // 'ok' type B = P<number>; // number