EduFlow
Advanced TypeScript Patterns

Checkpoint: Shipping TypeScript

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

A script run with node checkout.ts (Node’s built-in type stripping) contains enum Channel { Web = 'web' } and fails at startup. Which compiler flag would have flagged the enum during tsc?

Question 2 of 5

Why can this charge run while the cart is unlocked?

TypeScript
async function pay(cartId: string, needsLock: boolean) {
  if (needsLock) {
    using lock = acquireCartLock(cartId);
  }
  await charge(cartId);
}
Question 3 of 5

interface Window { dataLayer: unknown[] } sits at the top level of src/analytics.ts, which also has imports. window.dataLayer is still an error. Why?

Question 4 of 5

A monorepo has six packages type-checked as one big program, and every small change re-checks all of them for 90 seconds. Which change helps most?

Question 5 of 5

A .js file starts with // @ts-check and declares /** @param {Order} order */ function ship(order) { … }. What does TypeScript do with it (with allowJs on)?

5 questions unanswered