{
 "schemaVersion": 1,
 "pathSlug": "typescript",
 "items": [
  {
   "questionId": "typescript.basic_types__500",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which type annotation accepts only "
      },
      {
       "t": "code",
       "v": "true"
      },
      {
       "t": "text",
       "v": " or "
      },
      {
       "t": "code",
       "v": "false"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "let isActive = true;",
    "label": "basic-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "true | false"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Boolean"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "boolean"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "bool"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__8190475",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which line correctly annotates "
      },
      {
       "t": "code",
       "v": "age"
      },
      {
       "t": "text",
       "v": " as a number?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "let age: number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "let age of number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "let number: age"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "let age = number"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__40617",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which keyword tells TypeScript to infer a variable's type from its initializer?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "const count = 42; // TypeScript infers: number",
    "label": "basic-types.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "let or const with no explicit annotation"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "the infer keyword before the type name"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a dynamic annotation on the declaration"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "the auto keyword in place of the type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__8190488",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does a literal type like "
      },
      {
       "t": "code",
       "v": "\"GET\""
      },
      {
       "t": "text",
       "v": " restrict a value to?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "exactly that one specific value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "any string of the same length"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "any value in the same category"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "only values longer than that one"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__18218976",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "code",
       "v": "declare const brand: unique symbol; type UserId = string & { [brand]: \"UserId\" };"
      },
      {
       "t": "text",
       "v": " - nothing in emitted JS references "
      },
      {
       "t": "code",
       "v": "brand"
      },
      {
       "t": "text",
       "v": ". A plain "
      },
      {
       "t": "code",
       "v": "\"abc\" as UserId"
      },
      {
       "t": "text",
       "v": " still compiles. What is the actual guarantee the pattern buys, if any?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "declare const brand: unique symbol;\ntype UserId = string & { [brand]: \"UserId\" };\nconst id = \"abc\" as UserId; // still compiles\nfunction load(u: UserId) {}\nload(\"abc\"); // error - needs brand",
    "label": "basic-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Structural incompatibility between branded aliases prevents accidental cross-assignment without a deliberate cast."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Branded aliases produce a distinct wrapper object whose identity the compiler can match against its alias list."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Runtime tagging via the declared symbol ensures branded values cannot leak into unrelated APIs at call sites."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Unique symbol branding injects a hidden prototype chain entry that survives JSON.parse round-tripping at runtime."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__700002",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You interpolate user input into "
      },
      {
       "t": "code",
       "v": "new RegExp(...)"
      },
      {
       "t": "text",
       "v": ". What does "
      },
      {
       "t": "code",
       "v": "RegExp.escape(input)"
      },
      {
       "t": "text",
       "v": ", typed under the ES2025 lib in TS 6, give you back?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Compiles a regex from a string and caches it under a normalized form"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Returns a string with regex metacharacters escaped for safe use in patterns"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Removes regex metacharacters from a string so the result is plain text"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Throws when its input contains characters that cannot appear in a regex"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__500003",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes the behaviour of "
      },
      {
       "t": "code",
       "v": "exactOptionalPropertyTypes"
      },
      {
       "t": "text",
       "v": " when enabled in tsconfig?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Reading an omitted optional property yields a runtime throw rather than the undefined primitive"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Writing an explicit undefined to an optional property becomes a diagnostic unless the annotation includes it"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Optional modifiers are rewritten into union annotations during emit so callers observe both forms"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Optional properties are widened to accept null in addition to their declared annotation value"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__438058",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A reviewer rewrites "
      },
      {
       "t": "code",
       "v": "const roles = ['admin', 'guest'] as Role[]"
      },
      {
       "t": "text",
       "v": " to "
      },
      {
       "t": "code",
       "v": "const roles = ['admin', 'guest'] as const satisfies readonly Role[]"
      },
      {
       "t": "text",
       "v": ". Why is the rewritten form preferred in a scenario where the reviewer cares about both narrowness and conformance?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It preserves the exact literal inference while still verifying the array conforms to the expected contract."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It triggers an implicit runtime check that throws whenever a string outside the role list is pushed later."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It widens elements to the declared contract so mutation is allowed inside the readonly annotation."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It collapses the array into a mapped tuple keyed by the role identifier before inference runs."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__40661",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is structural typing in TypeScript?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface Point { x: number; y: number; }\nconst p = { x: 1, y: 2, z: 3 }; // extra property is fine\nconst pt: Point = p;             // valid, structural compatibility",
    "label": "basic-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeScript compares the declared name first and only then the shape of the members"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Every type must explicitly extend or implement another type in order to be assignable"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Types are compatible if they have the same shape, so explicit declarations are not required"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Types must share the same declared name before either one of them becomes assignable"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.basic_types__521",
   "topic": "typescript",
   "subSkill": "basic_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the "
      },
      {
       "t": "code",
       "v": "Record<K, V>"
      },
      {
       "t": "text",
       "v": " utility type equivalent to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Scores = Record<'math' | 'science', number>;\n// { math: number; science: number }\n\nconst scores: Scores = {\n  math: 95,\n  science: 88\n};",
    "label": "basic-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An object type with keys of type K and values of type V"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A class with a constructor that accepts K and V parameters"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An immutable Map with key type K and value type V"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A tuple where the first element is K and the second is V"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__2046123",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Does "
      },
      {
       "t": "code",
       "v": "x satisfies T"
      },
      {
       "t": "text",
       "v": " create a new variable or binding?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Yes, it registers a new global constant"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Yes, it defines a variable named T"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "No, it only checks an existing expression"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Yes, it creates a binding called x2"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__2046112",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Can the type after "
      },
      {
       "t": "code",
       "v": "satisfies"
      },
      {
       "t": "text",
       "v": " be an "
      },
      {
       "t": "code",
       "v": "interface"
      },
      {
       "t": "text",
       "v": " you declared?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "No, only inline object types are allowed after it"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Yes, any named type or interface can be the constraint"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "No, interfaces must be checked with implements instead"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Yes, but the interface has to be marked as readonly"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__710297",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You have "
      },
      {
       "t": "code",
       "v": "const routes = { home: '/', about: '/about' }"
      },
      {
       "t": "text",
       "v": ". You want "
      },
      {
       "t": "code",
       "v": "keyof typeof routes"
      },
      {
       "t": "text",
       "v": " to equal "
      },
      {
       "t": "code",
       "v": "'home' | 'about'"
      },
      {
       "t": "text",
       "v": " while still ensuring every value is a "
      },
      {
       "t": "code",
       "v": "/${string}"
      },
      {
       "t": "text",
       "v": ". Which form achieves both?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "apply the post-fix check against "
       },
       {
        "t": "code",
        "v": "Record<string, "
       },
       {
        "t": "text",
        "v": "/${string}"
       },
       {
        "t": "code",
        "v": ">"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "wrap the literal with "
       },
       {
        "t": "code",
        "v": "Object.freeze"
       },
       {
        "t": "text",
        "v": " and rely on readonly inference"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "assert the literal with "
       },
       {
        "t": "code",
        "v": "as Record<string, "
       },
       {
        "t": "text",
        "v": "/${string}"
       },
       {
        "t": "code",
        "v": ">"
       },
       {
        "t": "text",
        "v": " at the end"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "annotate the binding as "
       },
       {
        "t": "code",
        "v": "Record<string, "
       },
       {
        "t": "text",
        "v": "/${string}"
       },
       {
        "t": "code",
        "v": ">"
       },
       {
        "t": "text",
        "v": " directly"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__202210",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the inferred type of "
      },
      {
       "t": "code",
       "v": "env.DB_URL"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "const env = {\n  DB_URL: \"postgres://localhost\",\n  PORT: \"5432\",\n} satisfies Record<string, string>;\ntype T = typeof env.DB_URL;",
    "label": "satisfies-operator.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "code",
        "v": "postgres://${string}"
       },
       {
        "t": "text",
        "v": " template type"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "\"postgres://localhost\" literal"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "string (widened by constraint)"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "code",
        "v": "Uppercase<\"postgres\">"
       },
       {
        "t": "text",
        "v": " mapped form"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__40680",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is a practical use case for "
      },
      {
       "t": "code",
       "v": "satisfies"
      },
      {
       "t": "text",
       "v": " with "
      },
      {
       "t": "code",
       "v": "Record"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Color = 'red' | 'green' | 'blue';\nconst hex = {\n  red: '#ff0000',\n  green: '#00ff00',\n  blue: '#0000ff',\n} satisfies Record<Color, string>;\n// hex.red is string; satisfies checks all Color keys are present",
    "label": "satisfies-operator.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Creating a runtime dictionary that throws on missing keys"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Converting a Record into a Map with full type safety"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Checking each union key is present while rejecting extras"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Ensuring the Record has no more than the specified number of keys"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__2046111",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "For a "
      },
      {
       "t": "code",
       "v": "satisfies"
      },
      {
       "t": "text",
       "v": " check to pass, the value must be what, with respect to the type?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "identical in every field"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "a subtype only by name"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "convertible using a cast"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "assignable to that type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__40650",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "When using "
      },
      {
       "t": "code",
       "v": "satisfies"
      },
      {
       "t": "text",
       "v": ", what happens if the expression does NOT match the type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Colors = 'red' | 'green' | 'blue';\nconst x = { purple: '#800080' } satisfies Record<Colors, string>;\n// Error: Object literal may only specify known properties",
    "label": "satisfies-operator.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeScript silently widens the type to match"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript reports a compile-time error"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The value is cast to the type at runtime"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The property is set to undefined"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__2046106",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Can you write "
      },
      {
       "t": "code",
       "v": "satisfies"
      },
      {
       "t": "text",
       "v": " on its own without naming a type after it?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Yes, it then defaults to checking against any"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "No, but only object types may follow it here"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Yes, it infers the type from the value alone"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "No, a target type must follow the keyword"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__710314",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You have "
      },
      {
       "t": "code",
       "v": "function asRoutes<T>(t: T): T extends Record<string, Handler> ? T : never {}"
      },
      {
       "t": "text",
       "v": ". A caller passes a literal. Comparing this to simply using the 4.9 operator at the call site, which statement is most accurate?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "function form can map T while still rejecting non-conformers structurally"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "validator return-types to "
       },
       {
        "t": "code",
        "v": "never"
       },
       {
        "t": "text",
        "v": " on mismatch, matching the function's behaviour"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "function form always loses literal keys because conditional types widen"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "validator gives the same conditional branching behaviour on bad input"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.satisfies_operator__1168923",
   "topic": "typescript",
   "subSkill": "satisfies_operator",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Given "
      },
      {
       "t": "code",
       "v": "const handlers = { click: (e: MouseEvent) => e.clientX, keydown: (e: KeyboardEvent) => e.key } satisfies Record<string, (e: Event) => unknown>"
      },
      {
       "t": "text",
       "v": ", what is the subtle contravariance pitfall here?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "const handlers = {\n  click: (e: MouseEvent) => e.clientX,\n  keydown: (e: KeyboardEvent) => e.key\n} satisfies Record<string, (e: Event) => unknown>",
    "label": "satisfies-operator.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The return positions compare covariantly so mixing differently typed returns breaks the record compatibility test"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The operator invokes bivariant parameter comparison which silently accepts unsafe narrowing of the event object"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The "
       },
       {
        "t": "code",
        "v": "unknown"
       },
       {
        "t": "text",
        "v": " return value widens each handler to never which blocks structural matching against the union record"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Function parameter positions compare in the opposite direction so wider parameter types reject narrower handlers"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__40686",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is a recursive type alias in TypeScript?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type TreeNode<T> = {\n  value: T;\n  children: TreeNode<T>[];\n};",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A type that extends another type in a circular dependency"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A type that is computed recursively at runtime"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A generic type whose depth grows with each type argument"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A type that references itself in its own definition"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__304847",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Comparing "
      },
      {
       "t": "code",
       "v": "readonly T[]"
      },
      {
       "t": "text",
       "v": " with "
      },
      {
       "t": "code",
       "v": "ReadonlyArray<T>"
      },
      {
       "t": "text",
       "v": " as a parameter type, which claim holds for the two forms in modern TS?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "function f(xs: readonly number[]) {}\nfunction g(xs: ReadonlyArray<number>) {}",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Modifier form mutates"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Generic one mutates"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "They are equivalent"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Generic widens keys"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__504",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the "
      },
      {
       "t": "code",
       "v": "readonly"
      },
      {
       "t": "text",
       "v": " modifier on an interface property?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface Point {\n  readonly x: number;\n  readonly y: number;\n}\n\nconst p: Point = { x: 10, y: 20 };\n// p.x = 30; // Error: Cannot assign to 'x'",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Freezes the property value at runtime using Object.freeze() internally"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Prevents the property from being included in JSON serialization output"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Makes the property accessible only within the same source file"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Prevents reassignment after creation, enforced at compile time only"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__404852",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "code",
       "v": "type Keys = keyof T"
      },
      {
       "t": "text",
       "v": " where T is "
      },
      {
       "t": "code",
       "v": "{ [k: string]: V; id: number }"
      },
      {
       "t": "text",
       "v": " - what is Keys equal to, and why does that result surprise readers expecting the explicit member set?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Keys = keyof { [k: string]: V; id: number }",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "\"id\" literal one"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "string | number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "never subtype only"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "string only type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__530",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is a companion object pattern in TypeScript?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface Result<T> {\n  ok: boolean;\n  value: T;\n}\n\nconst Result = {\n  ok<T>(value: T): Result<T> {\n    return { ok: true, value };\n  },\n  fail<T>(value: T): Result<T> {\n    return { ok: false, value };\n  }\n};\n\nconst r: Result<string> = Result.ok('done');",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A design pattern where two classes share a private communication channel"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A pattern where interfaces are paired with corresponding mock implementations"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A pattern where an object accompanies a class as its serialization format"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A pattern where a value and a type share the same name, usable as both type and value"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__510",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the difference between "
      },
      {
       "t": "code",
       "v": "interface A { x: number }"
      },
      {
       "t": "text",
       "v": " and "
      },
      {
       "t": "code",
       "v": "type A = { x: number }"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Interface can hold methods alone, while a type alias also holds data"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Interface creates a runtime class, while a type alias is compile-time"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Interfaces merge and extend, type aliases take unions but cannot reopen"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Type alias is faster for the compiler to process than an interface declaration"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__700005",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does writing "
      },
      {
       "t": "code",
       "v": "value as HTMLElement"
      },
      {
       "t": "text",
       "v": " tell the compiler?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "const el = document.getElementById(\"main\") as HTMLCanvasElement;",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Convert the value into that type when it runs"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Treat the value as the more specific type you named"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Copy the value into a new object of that type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Check while running that the value has that type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__700011",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "The parameter "
      },
      {
       "t": "code",
       "v": "pt"
      },
      {
       "t": "text",
       "v": " is annotated "
      },
      {
       "t": "code",
       "v": "{ x: number; y: number }"
      },
      {
       "t": "text",
       "v": ". What does that annotation require?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "function printPoint(pt: { x: number; y: number }) {\n  console.log(pt.x, pt.y);\n}",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A block of code that assigns "
       },
       {
        "t": "code",
        "v": "x"
       },
       {
        "t": "text",
        "v": " and "
       },
       {
        "t": "code",
        "v": "y"
       },
       {
        "t": "text",
        "v": " first"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A map keyed by the strings "
       },
       {
        "t": "code",
        "v": "\"x\""
       },
       {
        "t": "text",
        "v": " and "
       },
       {
        "t": "code",
        "v": "\"y\""
       },
       {
        "t": "text",
        "v": " only"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A pair of separate variables named "
       },
       {
        "t": "code",
        "v": "x"
       },
       {
        "t": "text",
        "v": " and "
       },
       {
        "t": "code",
        "v": "y"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An object with numeric "
       },
       {
        "t": "code",
        "v": "x"
       },
       {
        "t": "text",
        "v": " and "
       },
       {
        "t": "code",
        "v": "y"
       },
       {
        "t": "text",
        "v": " properties"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__533",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does TypeScript resolve the type when an interface inherits from two interfaces that both have the same method name with different signatures?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface A {\n  handle(x: string): string;\n}\ninterface B {\n  handle(x: number): number;\n}\n\ninterface C extends A, B {}\n// C.handle has overloads:\n// (x: number): number  (from B, higher priority)\n// (x: string): string  (from A)",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeScript reports a compile error for conflicting method signatures"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript creates a union type of both return types for the merged method"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The first parent interface's signature wins and the second one is ignored"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The result carries overloads from both parents, the later one first"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.interfaces_types__511",
   "topic": "typescript",
   "subSkill": "interfaces_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "implements"
      },
      {
       "t": "text",
       "v": " do when a class uses an interface?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface Serializable {\n  serialize(): string;\n}\n\nclass User implements Serializable {\n  name: string;\n  constructor(name: string) { this.name = name; }\n  serialize() { return JSON.stringify({ name: this.name }); }\n}",
    "label": "interfaces-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Automatically generates property definitions from the interface declarations"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Verifies the class satisfies the interface without adding properties automatically"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Copies method implementations from the interface into the class body"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Creates a runtime check that throws if the interface contract is violated"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__515",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Why might a type guard function return incorrect narrowing?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// Dangerous: always returns true regardless of actual type\nfunction isNumber(x: unknown): x is number {\n  return true; // BUG: no actual check!\n}\n\nconst val: unknown = 'hello';\nif (isNumber(val)) {\n  val.toFixed(2); // Compiles but crashes at runtime\n}",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The type predicate is trusted by TypeScript even if the runtime check does not actually validate the asserted type"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript statically verifies that the predicate body proves the asserted target type before the guard compiles"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Guards declared with the "
       },
       {
        "t": "code",
        "v": "is"
       },
       {
        "t": "text",
        "v": " keyword have their body cross-checked against the target's structural shape automatically"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The compiler instruments the body so failing checks throw at runtime and narrowing never reaches the caller scope"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__9201857",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does the expression "
      },
      {
       "t": "code",
       "v": "\"id\" in user"
      },
      {
       "t": "text",
       "v": " evaluate to?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "the value currently stored at that key"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "true or false, whether the key exists"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "the number of keys on the object given"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "the key itself given back as a string"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__648911",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A union "
      },
      {
       "t": "code",
       "v": "{kind:\"a\"; x:number} | {kind:\"b\"; y:string}"
      },
      {
       "t": "text",
       "v": ". Which narrowing is the most ergonomic and TS-idiomatic?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "typeof on the kind property"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "switch on value.kind literal"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "hasOwnProperty on distinct keys"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "instanceof per variant class"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__531",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What happens when a type guard is applied to an array element accessed by index?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "const arr: (string | number)[] = ['hello', 42];\n\nif (typeof arr[0] === 'string') {\n  arr[0].toUpperCase(); // OK: narrowed\n}\n\n// Better pattern: extract to const\nconst first = arr[0];\nif (typeof first === 'string') {\n  first.toUpperCase(); // Reliably narrowed\n}",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeScript tracks the index and narrows the later accesses too"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Narrows that element but does not track the index afterwards"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Array element type guards are unsupported in TypeScript"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The entire array is narrowed to hold guarded-type elements"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__40638",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "typeof"
      },
      {
       "t": "text",
       "v": " do in a TypeScript type guard?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "function print(val: string | number) {\n  if (typeof val === 'string') {\n    console.log(val.toUpperCase()); // string here\n  } else {\n    console.log(val.toFixed(2)); // number here\n  }\n}",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Narrows a value by its runtime type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Extracts the type parameter from a generic"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Asserts a value is an instance of a class"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Removes null from a union type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__533",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which of the following best describes limitation of assertion functions in async code?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// Cannot work: narrowing needs to be synchronous\n// async function assertValid(x: unknown): asserts x is User {\n//   const result = await validate(x); // async validation\n//   if (!result.ok) throw new Error();\n// }\n\n// Alternative: return typed result\nasync function validateUser(x: unknown): Promise<User> {\n  const result = await validate(x);\n  if (!result.ok) throw new Error();\n  return result.data as User;\n}",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Assertion functions cannot be async, so narrowing stays synchronous"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript wraps assertion functions in await in async contexts automatically"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Assertion functions work identically in async and sync contexts"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Async assertion functions narrow the type inside the awaited promise"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__308112",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "After an "
      },
      {
       "t": "code",
       "v": "await"
      },
      {
       "t": "text",
       "v": " inside a branch that narrowed "
      },
      {
       "t": "code",
       "v": "x"
      },
      {
       "t": "text",
       "v": " to a subtype, the subsequent code treats "
      },
      {
       "t": "code",
       "v": "x"
      },
      {
       "t": "text",
       "v": " as the original union again. Root cause?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Captured locals reset to their declaration types whenever an await appears anywhere in the closure."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Async functions inject a hidden "
       },
       {
        "t": "code",
        "v": "try/catch"
       },
       {
        "t": "text",
        "v": ", which resets the narrowing state for captured bindings."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The compiler conservatively widens narrowings across awaits because a captured variable may be reassigned."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The narrowing only applies to the first microtask; awaiting moves code into a second analysis frame."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__524",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does TypeScript narrow through property access chains?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface Config {\n  db?: {\n    host: string;\n    port: number;\n  };\n}\n\nfunction connect(config: Config) {\n  if (config.db) {\n    console.log(config.db.host); // OK: narrowed\n    console.log(config.db.port); // OK: narrowed\n  }\n}",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Property chain narrowing works with the optional chaining operator alone"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript does not narrow through property access; direct checks work"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "TypeScript narrows through property access chains equally, whatever the syntax"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Narrows intermediate objects for direct access, not bracket notation"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__9201849",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "typeof [1, 2, 3]"
      },
      {
       "t": "text",
       "v": " evaluate to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "console.log(typeof [1, 2, 3]); // ?",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "the string \"tuple\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "the string \"list\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "the string \"array\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "the string \"object\""
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.type_guards__503",
   "topic": "typescript",
   "subSkill": "type_guards",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does equality narrowing work with "
      },
      {
       "t": "code",
       "v": "==="
      },
      {
       "t": "text",
       "v": " in TypeScript?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "function check(x: string | number, y: number | boolean) {\n  if (x === y) {\n    // Both narrowed to 'number' (only common type)\n    console.log(x.toFixed(2)); // x: number\n    console.log(y.toFixed(2)); // y: number\n  }\n}",
    "label": "type-guards.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Comparing to a literal narrows; cross-variable narrowing requires "
       },
       {
        "t": "code",
        "v": "in"
       },
       {
        "t": "text",
        "v": " checks"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Comparing with a literal narrows to it; comparing two variables narrows both"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Comparing with a literal narrows; comparing variables leaves both unchanged"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Equality narrows the truthy branch only; the false branch keeps the union"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__8467307",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In "
      },
      {
       "t": "code",
       "v": "switch (shape.kind)"
      },
      {
       "t": "text",
       "v": ", what does each "
      },
      {
       "t": "code",
       "v": "case"
      },
      {
       "t": "text",
       "v": " label compare against?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "switch (shape.kind) {\n  case \"circle\": /* ... */ break;\n  case \"square\": /* ... */ break;\n}",
    "label": "discriminated-unions.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "a property name found on that variant"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "an index number of the variant order"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a literal tag value such as "
       },
       {
        "t": "code",
        "v": "\"circle\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "a class the variant was created from"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__89206",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What happens when you use "
      },
      {
       "t": "code",
       "v": "switch(true)"
      },
      {
       "t": "text",
       "v": " with a discriminated union and miss a case?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Action = { type: 'add'; item: string } | { type: 'remove'; id: number };\n\nfunction handle(action: Action) {\n  switch (action.type) {\n    case 'add': return action.item;\n    // Missing 'remove' case!\n    default: {\n      const _exhaustive: never = action;\n      //    ^^^^^^^^^ Error: Type '{ type: \"remove\"; id: number }' is not assignable to type 'never'\n      throw new Error(`Unhandled: ${_exhaustive}`);\n    }\n  }\n}",
    "label": "discriminated-unions.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeScript infers the return type as including undefined for the missing case"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript automatically errors on the missing case, just like switch on the discriminant"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Nothing happens automatically, so add an exhaustive check in the default case"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The switch silently falls through to the next case statement below"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__521",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You want exhaustive pattern matching over a tagged union without writing a switch statement, and the compiler should reject any variant you forget to handle. Which construction gives you that?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Shape = { kind: 'circle'; r: number } | { kind: 'square'; s: number };\n\ntype Handlers<T extends { kind: string }, R> = {\n  [K in T['kind']]: (v: Extract<T, { kind: K }>) => R;\n};\n\nfunction match<T extends { kind: string }, R>(\n  value: T,\n  handlers: Handlers<T, R>\n): R {\n  return (handlers as Record<string, (v: T) => R>)[value.kind](value);\n}\n\nmatch({ kind: 'circle', r: 5 } as Shape, {\n  circle: (c) => c.r * 2,\n  square: (s) => s.s * 4,\n});",
    "label": "discriminated-unions.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A generic function accepting a handler map per discriminant, with TypeScript enforcing all cases"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use a "
       },
       {
        "t": "code",
        "v": "switch (true)"
       },
       {
        "t": "text",
        "v": " chain with a type assertion inside every case clause to recover the variant"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Function.prototype.call"
       },
       {
        "t": "text",
        "v": " to dispatch dynamically to handlers keyed by the discriminant"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Create a Proxy that intercepts property access and dispatches based on the discriminant value"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__8467298",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A discriminated union is also known by which other name?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "a mapped union"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "a tagged union"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a nominal union"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "a generic union"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__40745",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What pattern best models a state machine with mutually exclusive states in TypeScript?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A single interface with the possible fields as optional properties"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A generic type "
       },
       {
        "t": "code",
        "v": "State<T>"
       },
       {
        "t": "text",
        "v": " where T is a union of the payloads"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A class hierarchy with abstract base methods for each state transition"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A discriminated union where each variant holds just its own data"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__8467305",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does adding "
      },
      {
       "t": "code",
       "v": "as const"
      },
      {
       "t": "text",
       "v": " to "
      },
      {
       "t": "code",
       "v": "{ kind: \"circle\" }"
      },
      {
       "t": "text",
       "v": " do for the "
      },
      {
       "t": "code",
       "v": "kind"
      },
      {
       "t": "text",
       "v": " property?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "keeps its type as that exact literal, not "
       },
       {
        "t": "code",
        "v": "string"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "makes the property read-only but widens to "
       },
       {
        "t": "code",
        "v": "string"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "marks the property optional on the final object type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "copies the object so later edits cannot change it"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__503",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does exhaustive checking mean in the context of discriminated unions?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Shape = { kind: 'circle' } | { kind: 'square' };\n\nfunction handle(s: Shape) {\n  switch (s.kind) {\n    case 'circle': return;\n    case 'square': return;\n    default:\n      const _exhaustive: never = s;\n      return _exhaustive;\n  }\n}",
    "label": "discriminated-unions.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Ensuring every member is handled, typically by assigning the remainder to "
       },
       {
        "t": "code",
        "v": "never"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Verifying that no two members share the same discriminant literal value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Running all possible test cases against the union type at compile time"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Checking that the discriminant property exists on the value at runtime"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__120947",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the correct characterization of the informal label 'tag' when discussing tagged unions in TypeScript?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A reserved keyword placed before an interface to opt that interface into structural narrowing"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A symbol installed at runtime by the compiler to distinguish union members from one another"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The shared property name whose literal value identifies which variant of the union a value belongs to"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A JSDoc annotation emitted into declaration files to preserve union variant identity downstream"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__40747",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What happens when you spread two discriminated union members into a new object?"
      }
     ]
    },
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the type of "
      },
      {
       "t": "code",
       "v": "merged.kind"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "'a'"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "'b'"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "string"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "'a' | 'b'"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.discriminated_unions__515",
   "topic": "typescript",
   "subSkill": "discriminated_unions",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does TypeScript narrow a discriminated union stored in a variable versus a property?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type State = { status: 'loading' } | { status: 'done'; data: string };\n\nfunction process(box: { state: State }) {\n  if (box.state.status === 'done') {\n    console.log(box.state.data); // OK here\n    mutate(box);\n    console.log(box.state.data); // error: property narrowing was reset\n  }\n\n  const state = box.state;\n  if (state.status === 'done') {\n    mutate(box);\n    console.log(state.data); // still OK: local keeps its narrowing\n  }\n}\n\ndeclare function mutate(b: { state: State }): void;",
    "label": "discriminated-unions.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Local variables keep narrowing; mutable object properties lose it across an intervening call"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Object properties narrow more precisely because TypeScript tracks every mutation to them"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Both local variables and object properties are narrowed identically in every context"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Local variables lose their narrowing as soon as any function call happens in that scope"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__524",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is a generic type with multiple "
      },
      {
       "t": "code",
       "v": "infer"
      },
      {
       "t": "text",
       "v": " positions used for?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Unpack<T> = T extends Map<infer K, infer V>\n  ? { key: K; value: V }\n  : never;\n\ntype Result = Unpack<Map<string, number>>;\n// { key: string; value: number }",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Inferring the same type from different argument positions for consistency"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Creating multiple output types from a single generic call"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Generating runtime type guards for each inferred position"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Extracting several type components from one complex type at once"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__40704",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "DeepReadonly<T>"
      },
      {
       "t": "text",
       "v": " require compared to "
      },
      {
       "t": "code",
       "v": "Readonly<T>"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type DeepReadonly<T> = {\n  readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];\n};",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "code",
        "v": "DeepReadonly<T>"
       },
       {
        "t": "text",
        "v": " calls Object.freeze() recursively at runtime"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "code",
        "v": "DeepReadonly<T>"
       },
       {
        "t": "text",
        "v": " only applies to the top-level properties like "
       },
       {
        "t": "code",
        "v": "Readonly<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "code",
        "v": "DeepReadonly<T>"
       },
       {
        "t": "text",
        "v": " recursively makes all nested object properties readonly"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "code",
        "v": "DeepReadonly<T>"
       },
       {
        "t": "text",
        "v": " is a built-in TypeScript utility type"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__40656",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "infer"
      },
      {
       "t": "text",
       "v": " do inside a conditional type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type UnwrapPromise<T> = T extends Promise<infer R> ? R : T;\ntype A = UnwrapPromise<Promise<string>>; // string\ntype B = UnwrapPromise<number>;           // number",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Forces TypeScript to infer the return type of a generic function"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Captures a type variable from the matched type for later"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Declares an implicit type parameter without angle brackets"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Extracts runtime type information from a value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__40695",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the difference between "
      },
      {
       "t": "code",
       "v": "T extends keyof U"
      },
      {
       "t": "text",
       "v": " and "
      },
      {
       "t": "code",
       "v": "keyof U"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "function pluck<T, K extends keyof T>(arr: T[], key: K): T[K][] {\n  return arr.map(item => item[key]);\n}",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "They are identical: both produce a union of U's keys"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "code",
        "v": "T extends keyof U"
       },
       {
        "t": "text",
        "v": " is valid inside conditional types alone"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "code",
        "v": "keyof U"
       },
       {
        "t": "text",
        "v": " is a runtime operation; "
       },
       {
        "t": "code",
        "v": "T extends keyof U"
       },
       {
        "t": "text",
        "v": " is compile-time"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "code",
        "v": "T extends keyof U"
       },
       {
        "t": "text",
        "v": " constrains a parameter, "
       },
       {
        "t": "code",
        "v": "keyof U"
       },
       {
        "t": "text",
        "v": " is a type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__531",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the TypeScript pattern for a 'builder' that tracks which properties have been set via generics?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Builder<Set extends string = never> = {\n  host(h: string): Builder<Set | 'host'>;\n  port(p: number): Builder<Set | 'port'>;\n} & ('host' | 'port' extends Set\n  ? { build(): Config }\n  : {});\n\n// builder().host('x').port(3000).build() // OK\n// builder().host('x').build() // Error: build not available",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Create a separate builder class for each combination of set properties needed"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Each setter returns the builder with an updated type tracking set keys"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use conditional types in the constructor to check property completeness statically"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Use optional properties and validate completeness at runtime in the build method"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__40684",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is a distributive conditional type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type ToArray<T> = T extends unknown ? T[] : never;\ntype R = ToArray<string | number>;\n// string[] | number[]  (not (string | number)[])",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A conditional type that distributes across multiple type parameters"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A conditional type applied to each element of a tuple"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A conditional type that evaluates both of its branches"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The conditional distributes over union members when T is bare"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__511",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does the "
      },
      {
       "t": "code",
       "v": "infer"
      },
      {
       "t": "text",
       "v": " keyword work inside a conditional type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type ReturnOf<T> = T extends (...args: any[]) => infer R ? R : never;\n\ntype A = ReturnOf<() => string>;    // string\ntype B = ReturnOf<(x: number) => boolean>; // boolean",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It marks the type parameter as bivariant so the conditional check succeeds whenever the structures share any common members"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It instructs the compiler to recompute the conditional with the inferred type substituted at every recursion step until stable"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It declares a type variable that TypeScript infers from the structure being checked, available only in the true branch"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It generates type-level pattern matching against the checked type and binds the variable across both true and false branches"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__529",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you create a type-safe event emitter using generics?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "interface Events {\n  login: (user: string) => void;\n  error: (code: number, msg: string) => void;\n}\n\nclass Emitter<E extends Record<string, (...args: any[]) => void>> {\n  on<K extends keyof E>(event: K, handler: E[K]) {}\n  emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>) {}\n}\n\nconst bus = new Emitter<Events>();\nbus.on('login', (user) => {}); // user: string\nbus.emit('error', 404, 'Not found');",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use loose handlers and cast them when consuming events later"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use string enums as event names with a generic handler type parameter"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Define an event map and use keyof with indexed access to constrain"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Create a separate class for each individual event type in the system"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__523",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you prevent distribution in a conditional type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// Distributed: applies to each member\ntype ToArray1<T> = T extends any ? T[] : never;\ntype A = ToArray1<string | number>; // string[] | number[]\n\n// Non-distributed: treats union as whole\ntype ToArray2<T> = [T] extends [any] ? T[] : never;\ntype B = ToArray2<string | number>; // (string | number)[]",
    "label": "generics.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "T satisfies U"
       },
       {
        "t": "text",
        "v": " instead of "
       },
       {
        "t": "code",
        "v": "T extends U"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Add the "
       },
       {
        "t": "code",
        "v": "nodistribute"
       },
       {
        "t": "text",
        "v": " modifier before the type parameter"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Declare T as "
       },
       {
        "t": "code",
        "v": "const T"
       },
       {
        "t": "text",
        "v": " to prevent distribution"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Wrap the type parameter in a tuple, "
       },
       {
        "t": "code",
        "v": "[T] extends [U]"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.generics__700006",
   "topic": "typescript",
   "subSkill": "generics",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does the type "
      },
      {
       "t": "code",
       "v": "Array<string>"
      },
      {
       "t": "text",
       "v": " describe?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A list whose elements are all text values"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A pair of one text value and a number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A list that may hold values of any kind"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A single text value stored in a wrapper"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__1536154",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which utility type unwraps a Promise to the type of its resolved value?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Record<K, V>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Awaited<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Readonly<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Required<T>"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__525",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you create a utility type that extracts only the string-keyed properties from an object type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type StringKeysOnly<T> = Pick<T, Extract<keyof T, string>>;\n\ninterface Mixed {\n  name: string;\n  [Symbol.iterator](): Iterator<unknown>;\n  0: boolean;\n}\n\ntype OnlyStrings = StringKeysOnly<Mixed>;\n// { name: string }",
    "label": "utility-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Pick<T, string>"
       },
       {
        "t": "text",
        "v": " because "
       },
       {
        "t": "code",
        "v": "string"
       },
       {
        "t": "text",
        "v": " is treated as a wildcard for any string-keyed prop"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Cast "
       },
       {
        "t": "code",
        "v": "keyof T"
       },
       {
        "t": "text",
        "v": " to "
       },
       {
        "t": "code",
        "v": "string"
       },
       {
        "t": "text",
        "v": " using "
       },
       {
        "t": "code",
        "v": "as"
       },
       {
        "t": "text",
        "v": " inside the mapped iteration over the property keys"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Omit<T, keyof T>"
       },
       {
        "t": "text",
        "v": " and then re-add only properties whose name extends string literal"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Extract<keyof T, string>"
       },
       {
        "t": "text",
        "v": " to filter keys, then index into T with those keys"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__40668",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "Awaited<T>"
      },
      {
       "t": "text",
       "v": " produce?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "async function fetchUser(): Promise<{ id: number }> { /* ... */ }\ntype User = Awaited<ReturnType<typeof fetchUser>>;\n// { id: number }",
    "label": "utility-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A Promise that resolves to the type T"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The union of types that T can await"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The type T with its async modifiers removed"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The recursively unwrapped thenable type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__1536148",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which utility type constructs an object type from a set of keys and a single value type?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Partial<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Pick<T, K>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Record<K, V>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Omit<T, K>"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__40666",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "NonNullable<T>"
      },
      {
       "t": "text",
       "v": " produce?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type MaybeString = string | null | undefined;\ntype DefiniteString = NonNullable<MaybeString>; // string",
    "label": "utility-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "T where every property is non-null at the object level"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "T with the string 'null' excluded from string unions"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "T with null and undefined removed from the union"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "T with all optional properties made required"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__1536158",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Do built-in utility types like "
      },
      {
       "t": "code",
       "v": "Partial"
      },
      {
       "t": "text",
       "v": " and "
      },
      {
       "t": "code",
       "v": "Readonly"
      },
      {
       "t": "text",
       "v": " generate any JavaScript when the code is compiled?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "No, they exist only for type checking and are erased at compile time"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Yes, they compile into calls that reshape the value at runtime later"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "No, but they inject runtime comments describing each field of the type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Yes, each one emits a small runtime helper into the compiled output"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__532",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does key remapping with "
      },
      {
       "t": "code",
       "v": "as"
      },
      {
       "t": "text",
       "v": " in mapped types enable more powerful utility types?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// Transform keys to getter names\ntype Getters<T> = {\n  [K in keyof T as `get${Capitalize<K & string>}`]: () => T[K];\n};\n\ninterface Person { name: string; age: number }\ntype PersonGetters = Getters<Person>;\n// { getName: () => string; getAge: () => number }",
    "label": "utility-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Allows transforming, filtering and computing new key names"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Converts number keys to string keys automatically during type mapping"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Enables runtime key renaming on mapped objects during transformation"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Provides type assertions for mapped type values at compile time"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__104827",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Given "
      },
      {
       "t": "code",
       "v": "type User = { name: string; address: { city: string } }"
      },
      {
       "t": "text",
       "v": ", what does "
      },
      {
       "t": "code",
       "v": "Partial<User>"
      },
      {
       "t": "text",
       "v": " produce for the nested "
      },
      {
       "t": "code",
       "v": "address"
      },
      {
       "t": "text",
       "v": " property?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type User = { name: string; address: { city: string } };\ntype P = Partial<User>;\n// P = { name?: string; address?: { city: string } }",
    "label": "utility-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A TS error is raised because "
       },
       {
        "t": "code",
        "v": "Partial"
       },
       {
        "t": "text",
        "v": " refuses to operate on nested shapes"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "code",
        "v": "address"
       },
       {
        "t": "text",
        "v": " itself becomes optional, but "
       },
       {
        "t": "code",
        "v": "city"
       },
       {
        "t": "text",
        "v": " inside it stays required"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Every leaf property, including "
       },
       {
        "t": "code",
        "v": "city"
       },
       {
        "t": "text",
        "v": ", recursively becomes optional"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The entire object collapses so that "
       },
       {
        "t": "code",
        "v": "address.city"
       },
       {
        "t": "text",
        "v": " resolves as "
       },
       {
        "t": "code",
        "v": "undefined"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__1536153",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which utility type yields the object shape a constructor produces when called with "
      },
      {
       "t": "code",
       "v": "new"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "InstanceType<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "NonNullable<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Parameters<T>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "ReturnType<T>"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.utility_types__523",
   "topic": "typescript",
   "subSkill": "utility_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does the "
      },
      {
       "t": "code",
       "v": "NoInfer<T>"
      },
      {
       "t": "text",
       "v": " utility type do?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "declare function fill<T>(\n  arr: T[],\n  value: NoInfer<T>\n): T[];\n\nfill([1, 2, 3], 0);    // T = number, OK\n// fill([1, 2, 3], 'x'); // Error: string not number",
    "label": "utility-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Removes T from the function's public type signature completely"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Makes T invariant instead of covariant for variance checking"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Prevents any type inference in the entire function signature scope"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Wraps T to prevent it from being an inference site for the type parameter"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__40792",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What TypeScript feature lets you turn a string type like "
      },
      {
       "t": "code",
       "v": "'abc'"
      },
      {
       "t": "text",
       "v": " into a tuple of its individual characters?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Split<T extends string> =\n  T extends `${infer Head}${infer Tail}`\n    ? [Head, ...Split<Tail>]\n    : [];",
    "label": "template-literals.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Recursive conditional types using "
       },
       {
        "t": "code",
        "v": "infer"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The "
       },
       {
        "t": "code",
        "v": "Entries<T>"
       },
       {
        "t": "text",
        "v": " utility type from TypeScript 4.5"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Array destructuring applied to a string type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The built-in "
       },
       {
        "t": "code",
        "v": "Split<T, S>"
       },
       {
        "t": "text",
        "v": " utility type"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__400743",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You're designing an SQL-like query builder. `"
      },
      {
       "t": "code",
       "v": " "
      },
      {
       "t": "text",
       "v": "SELECT ${string} FROM ${string}"
      },
      {
       "t": "code",
       "v": " "
      },
      {
       "t": "code",
       "v": " vs. "
      },
      {
       "t": "code",
       "v": " "
      },
      {
       "t": "text",
       "v": "SELECT ${Cols} FROM ${Table}"
      },
      {
       "t": "code",
       "v": " "
      },
      {
       "t": "text",
       "v": "` with generics. What's the practical trade-off?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The generic version produces stricter runtime validation of the query shape"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The generic version unifies with wider primitive strings on contextual assignment"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The generic version runs faster because the compiler caches pattern parts"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The generic version preserves the captured parts for downstream inference"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__7295191",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Inside a template literal, what does a dollar sign directly before curly braces begin?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "an escaped control sequence"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "an interpolated expression"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a currency-formatted number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "a nested block statement"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__40772",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "Handler"
      },
      {
       "t": "text",
       "v": " resolve to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type EventName = 'click' | 'focus';\ntype Handler = `on${Capitalize<EventName>}`;",
    "label": "template-literals.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "\"on\" | \"Click\" | \"Focus\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "\"onClick\" | \"onFocus\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "string"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "\"onclick\" | \"onfocus\""
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__7295186",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which syntax inserts a value into a template literal string?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "&{value}"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "${value}"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "#{value}"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "@{value}"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__500812",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In practice, why does `"
      },
      {
       "t": "code",
       "v": " "
      },
      {
       "t": "text",
       "v": "${infer A}${infer B}"
      },
      {
       "t": "code",
       "v": " "
      },
      {
       "t": "text",
       "v": "` bind A to the first character even though inference is typically greedy elsewhere?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Inference in template positions runs right-to-left unlike normal inference"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Each placeholder caps at one character unless constrained to a longer shape"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Consecutive placeholders force the compiler to choose the shortest head match"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Placeholders with no separator disable inference and fall back to string"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__508",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the type of id in the following code?"
      }
     ]
    },
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "const id: ID = 'user_abc123';"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type ID = `user_${string}`;\nconst a: ID = 'user_abc123'; // OK\nconst b: ID = 'user_';       // OK\n// const c: ID = 'admin_abc'; // Error",
    "label": "template-literals.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A compile error because string cannot be used in template literal types"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "string: template literal types widen to string at value level"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A pattern type matching strings that begin with the 'user_' prefix"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "\"user_abc123\": the literal type of the assigned value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__6284109",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What type does "
      },
      {
       "t": "code",
       "v": "'a,b,c'"
      },
      {
       "t": "text",
       "v": " resolve to under "
      },
      {
       "t": "code",
       "v": "type Split<S> = S extends "
      },
      {
       "t": "text",
       "v": "${infer H},${infer R}"
      },
      {
       "t": "code",
       "v": " ? [H, ...Split<R>] : [S]"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Split<S extends string> = S extends `${infer H},${infer R}`\n  ? [H, ...Split<R>]\n  : [S];\ntype R = Split<\"a,b,c\">;",
    "label": "template-literals.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The union "
       },
       {
        "t": "code",
        "v": "\"a\" | \"b\" | \"c\""
       },
       {
        "t": "text",
        "v": " since template literal inference distributes over comma-separated spans."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A tuple "
       },
       {
        "t": "code",
        "v": "[\"a\", \"b\", \"c\"]"
       },
       {
        "t": "text",
        "v": " because "
       },
       {
        "t": "code",
        "v": "infer"
       },
       {
        "t": "text",
        "v": " binds greedily from the left, peeling one delimiter at a time."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A tuple "
       },
       {
        "t": "code",
        "v": "[\"a,b\", \"c\"]"
       },
       {
        "t": "text",
        "v": " because inferred positions match from the right side of the literal by default."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A tuple "
       },
       {
        "t": "code",
        "v": "[\"a\", \"b,c\"]"
       },
       {
        "t": "text",
        "v": " since the first match consumes the remainder without further recursion through it."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__519",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does the following type produce?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type DotPath<T, Prefix extends string = ''> = T extends object\n  ? { [K in keyof T & string]:\n      | `${Prefix}${K}`\n      | DotPath<T[K], `${Prefix}${K}.`>\n    }[keyof T & string]\n  : never;",
    "label": "template-literals.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A compile error because recursive template literals are not supported"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An array of the path segments in declaration order"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A single string representing the deepest path in the object"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A union of the dot-separated paths through the object type"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.template_literals__400618",
   "topic": "typescript",
   "subSkill": "template_literals",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You have "
      },
      {
       "t": "code",
       "v": "type Join<T, D> = ..."
      },
      {
       "t": "text",
       "v": " and you want strict string output. Which "
      },
      {
       "t": "code",
       "v": "infer"
      },
      {
       "t": "text",
       "v": " constraint keeps the compiler from widening the tuple entries to "
      },
      {
       "t": "code",
       "v": "unknown"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Intersecting the whole result with "
       },
       {
        "t": "code",
        "v": "string"
       },
       {
        "t": "text",
        "v": " after the recursion"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Applying "
       },
       {
        "t": "code",
        "v": "Uppercase<H>"
       },
       {
        "t": "text",
        "v": " inside the template to force a string shape"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "code",
        "v": "infer H extends string"
       },
       {
        "t": "text",
        "v": " on the head in the recursive branch"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Wrapping the template with "
       },
       {
        "t": "code",
        "v": "Extract<..., string>"
       },
       {
        "t": "text",
        "v": " on each call"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__40731",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "NonNullable<T>"
      },
      {
       "t": "text",
       "v": " remove from a type?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type MaybeString = string | null | undefined;\ntype DefiniteString = NonNullable<MaybeString>; // string",
    "label": "conditional-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Only "
       },
       {
        "t": "code",
        "v": "undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "code",
        "v": "null"
       },
       {
        "t": "text",
        "v": ", "
       },
       {
        "t": "code",
        "v": "undefined"
       },
       {
        "t": "text",
        "v": ", and "
       },
       {
        "t": "code",
        "v": "void"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "code",
        "v": "null"
       },
       {
        "t": "text",
        "v": " and "
       },
       {
        "t": "code",
        "v": "undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Only "
       },
       {
        "t": "code",
        "v": "null"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__512",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you use conditional types to make function parameters conditional?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Args<T> = T extends 'detailed'\n  ? [format: T, options: { verbose: boolean }]\n  : [format: T];\n\nfunction log<T extends 'simple' | 'detailed'>(\n  ...args: Args<T>\n) {}\n\nlog('simple');           // OK: no options needed\nlog('detailed', { verbose: true }); // OK: options required",
    "label": "conditional-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A conditional type for one param that depends on another's type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Conditional types cannot be used for function parameters here"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Wrap each parameter in a conditional type separately and independently"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Use the "
       },
       {
        "t": "code",
        "v": "?:"
       },
       {
        "t": "text",
        "v": " ternary operator directly in parameter declaration syntax"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__963187424",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Does the "
      },
      {
       "t": "code",
       "v": "extends"
      },
      {
       "t": "text",
       "v": " test in a conditional type require the two types to be exactly equal?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "yes, only while strict mode is on"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "no, it only checks reference links"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "yes, both types must match exactly"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "no, it checks assignability, not equality"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__963187416",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In a conditional type, which symbol comes right after the test and begins the two result types?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "|"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "&"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": ":"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "?"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__40751",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "infer"
      },
      {
       "t": "text",
       "v": " do in "
      },
      {
       "t": "code",
       "v": "type UnpackPromise<T> = T extends Promise<infer U> ? U : T"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type UnpackPromise<T> = T extends Promise<infer U> ? U : T;\ntype A = UnpackPromise<Promise<number>>; // number\ntype B = UnpackPromise<string>;          // string",
    "label": "conditional-types.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Converts T to U at runtime by awaiting the value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Declares U as a named type alias for T itself"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Captures the Promise's resolved type into a variable"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Infers the runtime value returned by awaiting the Promise"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__963187414",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In "
      },
      {
       "t": "code",
       "v": "A extends B ? X : Y"
      },
      {
       "t": "text",
       "v": ", what is the role of "
      },
      {
       "t": "code",
       "v": "B"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "the type returned on success"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "the type returned on failure"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "the alias name of the result"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "the type A is being compared to"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__40767",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is "
      },
      {
       "t": "code",
       "v": "ConstructorParameters<typeof Date>"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type DateParams = ConstructorParameters<typeof Date>;\n// [value: string | number | Date]  (from the last constructor overload only)",
    "label": "conditional-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A tuple of "
       },
       {
        "t": "code",
        "v": "Date"
       },
       {
        "t": "text",
        "v": " constructor arguments"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The instance type produced by "
       },
       {
        "t": "code",
        "v": "new Date()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A union of the valid date string formats"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The return type of the "
       },
       {
        "t": "code",
        "v": "Date"
       },
       {
        "t": "text",
        "v": " constructor"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__513",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the purpose of "
      },
      {
       "t": "code",
       "v": "Exclude"
      },
      {
       "t": "text",
       "v": " and "
      },
      {
       "t": "code",
       "v": "Extract"
      },
      {
       "t": "text",
       "v": " as conditional types?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type T = 'a' | 'b' | 'c' | 1 | 2;\n\ntype Strings = Extract<T, string>; // 'a' | 'b' | 'c'\ntype Numbers = Extract<T, number>; // 1 | 2\ntype NoA = Exclude<T, 'a'>;        // 'b' | 'c' | 1 | 2",
    "label": "conditional-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Exclude filters arrays by element type; Extract maps over elements"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "They convert between union and intersection types in opposite directions"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Exclude removes properties from objects, while Extract adds them"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "code",
        "v": "Exclude"
       },
       {
        "t": "text",
        "v": " drops members assignable to U, "
       },
       {
        "t": "code",
        "v": "Extract"
       },
       {
        "t": "text",
        "v": " keeps them"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__963187426",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "The type written after the "
      },
      {
       "t": "code",
       "v": ":"
      },
      {
       "t": "text",
       "v": " in a conditional type is used when the test does what?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "fails, meaning the check is not met"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "is skipped for that type entirely"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "throws an error during checking"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "passes, meaning the check is met"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.conditional_types__963187404",
   "topic": "typescript",
   "subSkill": "conditional_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In a conditional type, which keyword is written between the checked type and the type it is compared against?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "equals"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "resolves"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "matches"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "extends"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__430428",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "The two mapped types in the snippet differ only in the conditional branch. For which member shape do they produce different output?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type NullableArrays<T> = {\n  [P in keyof T]: T[P] extends Array<infer U> ? Array<U | null> : T[P]\n};\n\ntype Passthrough<T> = {\n  [P in keyof T]: T[P]\n};",
    "label": "mapped-types.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A property declared as a "
       },
       {
        "t": "code",
        "v": "ReadonlyArray"
       },
       {
        "t": "text",
        "v": " of a value type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A method property whose signature uses an overloaded call shape"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A primitive-valued property whose type is a string literal union"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A property whose declared type is a mutable array "
       },
       {
        "t": "code",
        "v": "U[]"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__525",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you write a mapped type that converts every method of a service into its Promise-based equivalent?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type AsyncMethods<T> = {\n  [K in keyof T]: T[K] extends (...args: infer A) => infer R\n    ? (...args: A) => Promise<R>\n    : T[K];\n};\n\ninterface UserService {\n  getUser(id: number): User;\n  updateUser(user: User): void;\n  name: string;\n}\n\ntype AsyncUserService = AsyncMethods<UserService>;\n// { getUser: (id: number) => Promise<User>;\n//   updateUser: (user: User) => Promise<void>;\n//   name: string }",
    "label": "mapped-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A conditional in the mapped value wraps the function return type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Promisify<T>"
       },
       {
        "t": "text",
        "v": " which is built into TypeScript's standard library"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Wrap the entire mapped type in Promise<> for asynchronous type output"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Apply the async keyword to each method at the type level in mapping"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__4048295",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "The second type argument to "
      },
      {
       "t": "code",
       "v": "Pick<T, K>"
      },
      {
       "t": "text",
       "v": " should be what?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "one or more keys selected from T"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "a fresh name for the produced type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a number of how many keys to take"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "one or more value types found in T"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__40764",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "DeepReadonly"
      },
      {
       "t": "text",
       "v": " need that "
      },
      {
       "t": "code",
       "v": "Readonly"
      },
      {
       "t": "text",
       "v": " does not?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type DeepReadonly<T> = {\n  readonly [K in keyof T]: T[K] extends object\n    ? DeepReadonly<T[K]>\n    : T[K];\n};",
    "label": "mapped-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A mapped type that sets the values to "
       },
       {
        "t": "code",
        "v": "unknown"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A special "
       },
       {
        "t": "code",
        "v": "deepReadonly"
       },
       {
        "t": "text",
        "v": " modifier supported since TypeScript 5.0"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The "
       },
       {
        "t": "code",
        "v": "satisfies"
       },
       {
        "t": "text",
        "v": " operator to enforce deep immutability"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A recursive conditional applying Readonly at each level"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__301034",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the inferred type of "
      },
      {
       "t": "code",
       "v": "q"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type T = { a: number; b: number };\ntype Q = { [K in keyof T]: string };\ndeclare const q: Q;",
    "label": "mapped-types.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Record<keyof T, string>"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "{ [k: string]: string }"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "{ a: string; b: string }"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "{ a?: string; b?: string }"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__810074",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A team writes "
      },
      {
       "t": "code",
       "v": "DeepReadonly<T>"
      },
      {
       "t": "text",
       "v": " but hits recursion issues when T contains arrays, tuples, and nested objects. The reviewer explains the fix depends on which mapping flavor is used. Which design is the most robust mitigation?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Recurse with a homomorphic mapped type guarded by a conditional that stops on primitive leaves"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Recurse through a non-homomorphic mapping with explicit key unions assembled from each nested object"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Flatten nested objects first with a path-string utility and then apply the readonly modifier at the end"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Stop recursion using a template-literal check on the typeof expression returned by a sample runtime value"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__4048285",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Given "
      },
      {
       "t": "code",
       "v": "type T = { a: string; b: number }"
      },
      {
       "t": "text",
       "v": ", "
      },
      {
       "t": "code",
       "v": "keyof T"
      },
      {
       "t": "text",
       "v": " evaluates to which of these?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "a union of key names: \"a\" | \"b\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "a numeric count of keys: 2"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a union of values: string | number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "an array of names: [\"a\", \"b\"]"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__522",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you implement a "
      },
      {
       "t": "code",
       "v": "Merge<A, B>"
      },
      {
       "t": "text",
       "v": " type that combines two types with B's properties taking precedence?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Merge<A, B> = Omit<A, keyof B> & B;\n\ntype Base = { id: number; name: string; version: number };\ntype Override = { name: string; active: boolean };\n\ntype Result = Merge<Base, Override>;\n// { id: number; version: number; name: string; active: boolean }",
    "label": "mapped-types.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "A & B"
       },
       {
        "t": "text",
        "v": " which gives B precedence over conflicting properties"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Spread<A, B>"
       },
       {
        "t": "text",
        "v": " from TypeScript's standard library"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "code",
        "v": "Omit<A, keyof B> & B"
       },
       {
        "t": "text",
        "v": ", which gives B precedence over A"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Apply "
       },
       {
        "t": "code",
        "v": "Object.assign<A, B>()"
       },
       {
        "t": "text",
        "v": " at the type level for merging"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__4048288",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "Readonly<{ x: number }>"
      },
      {
       "t": "text",
       "v": " resolve to?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "{ x: readonly number }"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "readonly { x: number }"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "{ readonly x: number }"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "{ readonly x?: number }"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.mapped_types__4048299",
   "topic": "typescript",
   "subSkill": "mapped_types",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "The "
      },
      {
       "t": "code",
       "v": "readonly"
      },
      {
       "t": "text",
       "v": " modifier on a mapped property restricts which operation?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "writing to it, by blocking reassignment"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "iterating it, by hiding it from "
       },
       {
        "t": "code",
        "v": "keyof"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "reading it, by blocking property access"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "comparing it, by freezing its identity"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__510",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does type "
      },
      {
       "t": "code",
       "v": "A"
      },
      {
       "t": "text",
       "v": " resolve to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Tail<T extends any[]> = T extends [any, ...infer R] ? R : never;\n\ntype A = Tail<[string, number, boolean]>;",
    "label": "infer-keyword.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "[number, boolean]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "[string]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "boolean"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "[string, number]"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__512",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In the following code, what does "
      },
      {
       "t": "code",
       "v": "Result"
      },
      {
       "t": "text",
       "v": " resolve to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type MapValue<T> = T extends Map<any, infer V> ? V : never;\n\ntype Result = MapValue<Map<string, number>>;",
    "label": "infer-keyword.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "number"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "string"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "[string, number]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "code",
        "v": "Map<string, number>"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__200301",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes how a type-challenges style "
      },
      {
       "t": "code",
       "v": "Last<T>"
      },
      {
       "t": "text",
       "v": " utility for tuples is authored?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "With Array.prototype.at(-1) invoked inside a template literal wrapper at compile time"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "With a rest-spread prefix and trailing capture slot that binds the final member"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "With a recursion on "
       },
       {
        "t": "code",
        "v": "Tail<T>"
       },
       {
        "t": "text",
        "v": " that returns the unchanged item sitting at the front spot"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "With a mapped form that subtracts one from the input's length property at each step"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__520",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does type "
      },
      {
       "t": "code",
       "v": "Result"
      },
      {
       "t": "text",
       "v": " resolve to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Reverse<T extends any[]> =\n  T extends [infer First, ...infer Rest]\n    ? [...Reverse<Rest>, First]\n    : [];\n\ntype Result = Reverse<[1, 2, 3]>;",
    "label": "infer-keyword.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "[1]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "never"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "[3, 2, 1]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "[1, 2, 3]"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__200502",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes how solving interacts with variadic tuples that have a rest slot between fixed prefix and suffix slots?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Variadic shapes block the solver entirely and force callers to pass an explicit argument set"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The compiler matches the head and the trailing side from both ends, binding the middle span"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Only the leading slots are considered, and any trailing slots are silently dropped off by it"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The middle span resolves to 'any[]' whenever its arity cannot be determined in one pass only"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__210583",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A team replaces a hand-rolled helper that pulled the resolved result of a callable with the standard library equivalent. A reviewer asks what machinery the built-in uses internally. What is the most accurate description?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A mapped type iterating keyof the callable and collecting the final indexed property into a union"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A conditional that pattern-matches a call signature and binds the output slot to a bound placeholder"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A runtime helper that invokes the callable with synthetic args and reads typeof the resolved output"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A template literal transformation parsing the printed shape string exposed by the compiler service"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__200305",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes how PromiseLike unwrapping traditionally worked before "
      },
      {
       "t": "code",
       "v": "Awaited<T>"
      },
      {
       "t": "text",
       "v": " was introduced?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Authors wrote a recursive conditional helper that peeled one thenable layer per step"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The compiler handled nested promises automatically via built-in runtime coercion rules"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Consumers explicitly cast through unknown because no structural match was expressible"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Community libraries relied on Pick and Omit to strip the 'then' property at each layer"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__40808",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you prevent a conditional type from distributing over a union type parameter?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type NoDistrib<T> = [T] extends [string] ? true : false;\ntype R = NoDistrib<string | number>;\n// => false  (not distributed)",
    "label": "infer-keyword.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Add "
       },
       {
        "t": "code",
        "v": "readonly"
       },
       {
        "t": "text",
        "v": " to the extends clause: "
       },
       {
        "t": "code",
        "v": "readonly T extends U ? A : B"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Distribution cannot be prevented: it is always applied"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "T & {} extends U ? A : B"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Wrap both sides in a tuple: "
       },
       {
        "t": "code",
        "v": "[T] extends [U] ? A : B"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__528",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How can infer be used to implement a type-safe curry function signature?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "type Curry<T> = T extends (first: infer A, ...rest: infer R) => infer Ret\n  ? R extends []\n    ? (a: A) => Ret\n    : (a: A) => Curry<(...args: R) => Ret>\n  : T;\n\ntype Curried = Curry<(a: string, b: number, c: boolean) => void>;\n// (a: string) => (a: number) => (a: boolean) => void",
    "label": "infer-keyword.ts"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeScript's infer keyword is fundamentally unable to express curried function type signatures"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Infer all parameters at once as a tuple and split them into individual arguments at runtime"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Infer the first parameter and rest parameters separately, then return a function chain"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Use infer to capture the function body type and reconstruct it as a curried sequence"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.infer_keyword__200401",
   "topic": "typescript",
   "subSkill": "infer_keyword",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes the effect of an 'extends' guard placed on an infer placeholder (e.g., infer X extends string)?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The placeholder becomes covariant with the bound, which forces all candidates to widen up"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Inference narrows the captured candidate to the bound, enabling literal-type preservation"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The guard is ignored at inference-time and applied only as a runtime instanceof assertion"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The match fails whenever the checked slot holds any disjunction whose members overlap up"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__700004",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Why does TypeScript 6 ship the "
      },
      {
       "t": "code",
       "v": "--stableTypeOrdering"
      },
      {
       "t": "text",
       "v": " flag?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "To enforce stable property order in object literals when widening to a type"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "To match TS 7's deterministic type ordering, shrinking diffs between versions"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "To sort declared members alphabetically in emitted .d.ts files at build time"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "To freeze the order generic parameters appear in inferred function signatures"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__521",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the difference between "
      },
      {
       "t": "code",
       "v": "noUnusedLocals"
      },
      {
       "t": "text",
       "v": " and "
      },
      {
       "t": "code",
       "v": "noUnusedParameters"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "noUnusedLocals checks global scope; noUnusedParameters checks function scope"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Both options are identical and check the same things in the same scope"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "noUnusedLocals removes unused code from output; noUnusedParameters does not"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "code",
        "v": "noUnusedLocals"
       },
       {
        "t": "text",
        "v": " errors on unused locals; "
       },
       {
        "t": "code",
        "v": "noUnusedParameters"
       },
       {
        "t": "text",
        "v": " on unused params"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__40691",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "verbatimModuleSyntax"
      },
      {
       "t": "text",
       "v": " enforce (TypeScript 5.0)?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// Required with verbatimModuleSyntax:\nimport type { User } from './types';\nimport { fetchUser } from './api';",
    "label": "config-compiler.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Imports and exports use "
       },
       {
        "t": "code",
        "v": "import type"
       },
       {
        "t": "text",
        "v": " for the type-only ones"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript emits import statements verbatim without transformation"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Module syntax has to use CommonJS require() style throughout"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "ESM syntax alone is allowed: CommonJS interop is disabled"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__400005",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes the purpose of the 'typeRoots' option?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It maps a module specifier to the precise declaration file used to type that import"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It lists folders scanned for ambient declaration packages to include globally"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It enumerates individual .d.ts entry files to ship in the published distribution bundle"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It rewrites triple-slash reference directives to point at a canonical shared location"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__675707492765",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A tsconfig sets exactly one compiler option, module: \"node20\". Running tsc 7.0.2 with --showConfig prints two further options it filled in. Which pair?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "{\n  \"compilerOptions\": { \"module\": \"node20\" },\n  \"files\": [\"./a.ts\"]\n}",
    "label": "config-compiler.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "\"moduleResolution\": \"node16\" plus \"moduleDetection\": \"force\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "\"esModuleInterop\": true plus \"verbatimModuleSyntax\": true"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "\"moduleResolution\": \"nodenext\" plus \"moduleDetection\": \"auto\""
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "\"moduleResolution\": \"bundler\" plus \"moduleDetection\": \"legacy\""
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__400713",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Between two strict-family flags, which one distinguishes "
      },
      {
       "t": "code",
       "v": "{ x?: string }"
      },
      {
       "t": "text",
       "v": " from "
      },
      {
       "t": "code",
       "v": "{ x: string | undefined }"
      },
      {
       "t": "text",
       "v": ", so that explicitly assigning "
      },
      {
       "t": "code",
       "v": "undefined"
      },
      {
       "t": "text",
       "v": " to "
      },
      {
       "t": "code",
       "v": "x"
      },
      {
       "t": "text",
       "v": " becomes an error when only the optional "
      },
      {
       "t": "code",
       "v": "?"
      },
      {
       "t": "text",
       "v": " form was declared?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "strictPropertyInitialization"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "strictNullChecks"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "exactOptionalPropertyTypes"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "noUncheckedIndexedAccess"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__403892",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A team wants "
      },
      {
       "t": "code",
       "v": "{ x?: number }"
      },
      {
       "t": "text",
       "v": " and "
      },
      {
       "t": "code",
       "v": "{ x?: number | undefined }"
      },
      {
       "t": "text",
       "v": " to mean different things - explicitly assigning "
      },
      {
       "t": "code",
       "v": "undefined"
      },
      {
       "t": "text",
       "v": " to a merely-optional field should be rejected. Which flag introduces that distinction?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "strictNullChecks"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "noUncheckedIndexedAccess"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "exactOptionalPropertyTypes"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "strictPropertyInitialization"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__403891",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A library author enables full strict mode but downstream consumers still crash when they read "
      },
      {
       "t": "code",
       "v": "record[key].name"
      },
      {
       "t": "text",
       "v": " without checking. "
      },
      {
       "t": "code",
       "v": "strict"
      },
      {
       "t": "text",
       "v": " alone doesn't flag this. Which option catches the implicit-undefined from "
      },
      {
       "t": "code",
       "v": "Record"
      },
      {
       "t": "text",
       "v": " lookups and array indexing?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "strictNullChecks"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "exactOptionalPropertyTypes"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "noUncheckedIndexedAccess"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "strictPropertyInitialization"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__100433",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Two compiler options each reduce some type-check work, but only one skips type checking of all declaration files (including those under node_modules and your own .d.ts files). Which one?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "skipDefaultLibCheck"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "noLib"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "skipLibCheck"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "types"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.config_compiler__412056",
   "topic": "typescript",
   "subSkill": "config_compiler",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which tsconfig option does the current handbook recommend so reads from arrays and records ("
      },
      {
       "t": "code",
       "v": "arr[i]"
      },
      {
       "t": "text",
       "v": ", "
      },
      {
       "t": "code",
       "v": "record[key]"
      },
      {
       "t": "text",
       "v": ") yield a possibly-undefined result at the read site?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "noPropertyAccessFromIndexSignature"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "noUncheckedIndexedAccess"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "strictNullChecks"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "exactOptionalPropertyTypes"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__12779436",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which keyword tells TypeScript that a global value exists at runtime but is defined somewhere else?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "ambient"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "declare"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "resolve"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "extern"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__402808",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes how the "
      },
      {
       "t": "code",
       "v": "exports"
      },
      {
       "t": "text",
       "v": " field in package.json interacts with TypeScript's type resolution?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The compiler ignores exports entirely and always looks up types via the top-level "
       },
       {
        "t": "code",
        "v": "types"
       },
       {
        "t": "text",
        "v": " field on the manifest."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TS copies the exports map into a synthetic paths configuration so the rootDir alias can resolve subpath imports."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Each export entry may carry a "
       },
       {
        "t": "code",
        "v": "types"
       },
       {
        "t": "text",
        "v": " condition that points at the .d.ts the compiler should load for that subpath."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A module with an exports field disables ambient module augmentation for every subpath listed inside that field."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__402717",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does tsc say about "
      },
      {
       "t": "code",
       "v": "X"
      },
      {
       "t": "text",
       "v": " in consumer.ts?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// lib.d.ts\ndeclare namespace Lib {\n  type Ok = 'ok';\n}\nexport = Lib;\n\n// consumer.ts\nimport Lib = require('./lib');\ntype X = Lib.Ok;\nconsole.log(X);\n",
    "label": "declaration-files.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "OK: logs the string 'ok' once at runtime via export="
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Error: 'X' is not defined; missing default export here"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "OK - logs { X: 'ok' } once at runtime from import default"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Error: 'X' only refers to a type, but is being used as a value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__507",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A teammate asks where "
      },
      {
       "t": "code",
       "v": "@types/lodash"
      },
      {
       "t": "text",
       "v": " actually comes from, and what makes "
      },
      {
       "t": "code",
       "v": "tsc"
      },
      {
       "t": "text",
       "v": " load a "
      },
      {
       "t": "code",
       "v": "@types"
      },
      {
       "t": "text",
       "v": " package at all. Which statement is correct?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A mirror of the npm registry where every package gets a parallel "
       },
       {
        "t": "code",
        "v": "@types/<name>"
       },
       {
        "t": "text",
        "v": " entry auto-generated by "
       },
       {
        "t": "code",
        "v": "tsc"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeScript-authored source rewrites of popular packages, shipped as "
       },
       {
        "t": "code",
        "v": ".ts"
       },
       {
        "t": "text",
        "v": " files for stronger inference at build time"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Community declarations from DefinitelyTyped: module ones load on import, ambient globals only once something pulls the package in"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Declarations generated on install by npm's postinstall hook from the library's JSDoc, then cached under "
       },
       {
        "t": "code",
        "v": "node_modules/@types"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__1517344",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A library's "
      },
      {
       "t": "code",
       "v": ".d.ts"
      },
      {
       "t": "text",
       "v": " declares a namespace "
      },
      {
       "t": "code",
       "v": "X"
      },
      {
       "t": "text",
       "v": " with an "
      },
      {
       "t": "code",
       "v": "Options"
      },
      {
       "t": "text",
       "v": " interface, a callable "
      },
      {
       "t": "code",
       "v": "declare function X"
      },
      {
       "t": "text",
       "v": ", and "
      },
      {
       "t": "code",
       "v": "export = X"
      },
      {
       "t": "text",
       "v": ". A consumer writes "
      },
      {
       "t": "code",
       "v": "import * as X from 'lib'"
      },
      {
       "t": "text",
       "v": ", annotates a value with "
      },
      {
       "t": "code",
       "v": "X.Options"
      },
      {
       "t": "text",
       "v": ", then calls "
      },
      {
       "t": "code",
       "v": "X(opts)"
      },
      {
       "t": "text",
       "v": ". What does TypeScript 7 report?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// lib.d.ts\ndeclare namespace X {\n  export interface Options { debug?: boolean }\n}\ndeclare function X(opts?: X.Options): string;\nexport = X;\n\n// consumer.ts\nimport * as X from 'lib';\nconst opts: X.Options = { debug: true };\nexport const s = X(opts);",
    "label": "declaration-files.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The "
       },
       {
        "t": "code",
        "v": "X.Options"
       },
       {
        "t": "text",
        "v": " annotation fails instead: nested namespace types are stripped from wildcard namespace imports unless "
       },
       {
        "t": "code",
        "v": "isolatedModules"
       },
       {
        "t": "text",
        "v": " is set"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Both fail: an ES module namespace import cannot cross the CJS boundary without an "
       },
       {
        "t": "code",
        "v": ".mts"
       },
       {
        "t": "text",
        "v": " file on the consumer side"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "code",
        "v": "X.Options"
       },
       {
        "t": "text",
        "v": " resolves fine, but the call fails: the "
       },
       {
        "t": "code",
        "v": "import *"
       },
       {
        "t": "text",
        "v": " namespace object has no call signatures (TS2349)"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Nothing fails: with "
       },
       {
        "t": "code",
        "v": "esModuleInterop"
       },
       {
        "t": "text",
        "v": " now mandatory, an "
       },
       {
        "t": "code",
        "v": "export ="
       },
       {
        "t": "text",
        "v": " namespace is callable through "
       },
       {
        "t": "code",
        "v": "import *"
       },
       {
        "t": "text",
        "v": " as well as indexable"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__40779",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Where does TypeScript look for community-maintained type declarations for a package like "
      },
      {
       "t": "code",
       "v": "lodash"
      },
      {
       "t": "text",
       "v": "?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The lodash package's own GitHub repository"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "@types/lodash on npm"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A local .types/ folder in the project root"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A built-in TypeScript registry at types.typescriptlang.org"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__12779431",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A published library's .d.ts uses "
      },
      {
       "t": "code",
       "v": "private password: string"
      },
      {
       "t": "text",
       "v": " to signal a secret field. Consumers report they can read and even overwrite the property: "
      },
      {
       "t": "code",
       "v": "acct['password']"
      },
      {
       "t": "text",
       "v": " type-checks fine, and the value is plainly there at runtime. What went wrong?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The field needed "
       },
       {
        "t": "code",
        "v": "readonly private"
       },
       {
        "t": "text",
        "v": " rather than "
       },
       {
        "t": "code",
        "v": "private"
       },
       {
        "t": "text",
        "v": " alone to hide it across module boundaries."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Private modifiers only work when the class is exported via "
       },
       {
        "t": "code",
        "v": "export default"
       },
       {
        "t": "text",
        "v": " instead of named export."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Access modifiers in declarations are compile-only; nominal secrecy requires a brand or symbol trick."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Consumers set "
       },
       {
        "t": "code",
        "v": "strictPropertyInitialization"
       },
       {
        "t": "text",
        "v": " to false, which disables private access across packages."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__3739562",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You publish "
      },
      {
       "t": "code",
       "v": "index.d.ts"
      },
      {
       "t": "text",
       "v": " with "
      },
      {
       "t": "code",
       "v": "export declare const x: Readonly<Config>"
      },
      {
       "t": "text",
       "v": ". After "
      },
      {
       "t": "code",
       "v": "tsc --declaration"
      },
      {
       "t": "text",
       "v": " from another package consumes yours, the re-emitted .d.ts inlines the full Config object literal instead of referencing it. What triggers this?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "// src/config.ts, not exported from package root\ninterface Config { a: number; b: string }\nexport declare const x: Readonly<Config>;",
    "label": "declaration-files.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The original Config type was declared with "
       },
       {
        "t": "code",
        "v": "const type"
       },
       {
        "t": "text",
        "v": " which the printer eagerly expands at usage sites"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Declaration printer expands types whose source symbol is not visible under the current export graph"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Readonly mapped types are always inlined because the declaration emitter cannot serialize the utility form"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The consumer build set "
       },
       {
        "t": "code",
        "v": "preserveSymlinks: false"
       },
       {
        "t": "text",
        "v": " which forces the printer to expand all referenced aliases"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__301696",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You are typing a legacy CommonJS package whose entry file hands back one function rather than a set of named bindings. What does "
      },
      {
       "t": "code",
       "v": "export ="
      },
      {
       "t": "text",
       "v": " express in the .d.ts you write for it?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It models that the module's runtime exports object is itself a single value, mirroring "
       },
       {
        "t": "code",
        "v": "module.exports = x;"
       },
       {
        "t": "text",
        "v": " in CJS."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It sets the default export of the module to the identifier after the equals sign and removes any named exports."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It freezes the module record so downstream consumers cannot shadow or augment its bindings after first import."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It signals to tsc that the module should be emitted with an ES module shape regardless of target module setting."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "typescript.declaration_files__40799",
   "topic": "typescript",
   "subSkill": "declaration_files",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "declare global { ... }"
      },
      {
       "t": "text",
       "v": " allow you to do inside a module-scoped "
      },
      {
       "t": "code",
       "v": ".d.ts"
      },
      {
       "t": "text",
       "v": " file?"
      }
     ]
    }
   ],
   "code": {
    "lang": "ts",
    "code": "export {}; // makes this file a module\ndeclare global {\n  interface Window {\n    analytics: AnalyticsInstance;\n  }\n}",
    "label": "declaration-files.ts"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Declare an ambient module matching the unresolved imports"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Re-export everything from the file into the global namespace"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Add declarations to the global scope from inside a module"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Suppress the TypeScript errors within the block"
       }
      ],
      "shape": "short"
     }
    ]
   }
  }
 ]
}
