diff --git a/docs/tagged_union_pattern_in_typescript.md b/docs/tagged_union_pattern_in_typescript.md index 9b1b715..59238b9 100644 --- a/docs/tagged_union_pattern_in_typescript.md +++ b/docs/tagged_union_pattern_in_typescript.md @@ -35,7 +35,7 @@ type ExprWithKind = Expr & { kind: { tag: Tag } }; The type `ExprKind["Tag"]` is a union of each `tag` value, i.e. in this example `"Int" | "Add"`. Saying `Tag extends ExprTag` means that `Tag` (type) is either `"Int"` or `"Add"`, i.e. for `.is("Int")`, `Tag` will be `"Int"` and for `.is("Add")`, `Tag` will be `"Add"`. The *narrowed* type `ExprWithKind` is defined by saying that we want an `Expr` that specifically has the `kind.tag` value of `Tag`. -Then define a methed that with a *type predicate*: +Then define a method that with a *type predicate*: ```ts class Expr { @@ -95,7 +95,7 @@ class Expr { case "Add": return k.right.eval() + k.left.eval(); } - const _: never = k; // compile time exhaustiveness check + k satisfies never; // compile time exhaustiveness check } // ... } @@ -201,7 +201,7 @@ class Expr { k.right.visit(v); return } - const _: never = k; + k satisfies never; } // ... } diff --git a/src/mir_interpreter.ts b/src/mir_interpreter.ts index 95c8471..9b5e4ba 100644 --- a/src/mir_interpreter.ts +++ b/src/mir_interpreter.ts @@ -134,7 +134,7 @@ export class MirInterpreter { ); continue; } - const _: never = k; + k satisfies never; } return Val.Void; } @@ -158,7 +158,7 @@ class Val { case "Fn": return `<${k.fn.ty.pretty()}>`; } - const _: never = k; + k satisfies never; } }