

TypeScript Behaviors
A reference for every question, with code and detailed explanations.
What is the type of `Result`?
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Open in PlaygroundWhat will TypeScript do if you write the code below?
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Open in PlaygroundWhat is the output of `UserWithoutBirthdate`? (assume that 'exactOptionalPropertyTypes' option in tsconfig is set to true)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Open in PlaygroundWhat's the type of `Result`?
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Open in PlaygroundWhat does TypeScript infer as the return type of this function?
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Open in PlaygroundWhat is the type of `Result` in the code below involving `never` type?
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Open in PlaygroundWhat will TypeScript do in the following scenario with a faulty type guard?
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.
Open in PlaygroundWhat will TypeScript do in the following scenario with a faulty assertion function?
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur.
Open in PlaygroundWhat will TypeScript infer for the type of `UserWithoutName`?
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.
Open in PlaygroundWhat is the type of `NewUser`?
Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam.
Open in PlaygroundWhat is the type of `NameType`?
Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur.
Open in PlaygroundWhat is the type of `Result`?
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum.
Open in PlaygroundWhat is the type of `Keys`?
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.
Open in PlaygroundWhat is the type of `arr`?
Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet.
Open in PlaygroundWhat is the type of `RedType`?
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores.
Open in PlaygroundWhat is the type of `TupleType`?
Nulla facilisi. Morbi tempus iaculis urna id volutpat lacus laoreet non curabitur gravida.
Open in PlaygroundWhat will TypeScript do with the code below?
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Open in PlaygroundWhat is the type of `Handler`?
Viverra accumsan in nisl nisi scelerisque eu ultrices vitae auctor eu augue ut lectus.
Open in PlaygroundWhat is the type of `Result`?
Eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus.
Open in PlaygroundWhat is the type of `Result`?
Amet consectetur adipiscing elit pellentesque habitant morbi tristique senectus et netus.
Open in Playground