Skip to main content
TypeScript Code Reorder Medium +20 XP

Type Guard Pattern

Arrange to create a proper type guard.

Click lines in the correct order

Available lines3 left

Your order

Click lines above to build your solution.

Show answer and explanation

Answer: function isString(value: unknown): value is string { return typeof value === "string"; }

Type guard function declaration comes first with the 'value is string' return type, then the check.

Hint: Function signature comes before body.

What this challenge tests

Code Reorder in TypeScript: type-guards, narrowing.

Related challenges