Hacker News new | ask | show | jobs
by lupodevelop 31 days ago
Looking at the README, it seems to have one. With strict on and noUncheckedIndexedAccess off, tsc is fine with this:

  export function stale(xs: string[]): string {
    const n = xs.length;
    xs.pop();
    return xs[n - 1];
  }
You get undefined at runtime even though the signature says string. TScert won't take it unless you admit it in the return type, with string | undefined.
1 comments

But why not just enable noUncheckedIndexedAccess?