Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify should remove e:break e; #2496

Closed
colelawrence opened this issue Aug 28, 2022 · 0 comments
Closed

Minify should remove e:break e; #2496

colelawrence opened this issue Aug 28, 2022 · 0 comments

Comments

@colelawrence
Copy link

Hi there, I'm doing something a little funny in order to put some type-only tests in my TypeScript files and they look like the following:

/**
 *  * `A` is assignable to `B`, and
 *  * `B` is assignable to `C`, but
 *  * `A` is *not* assignable to `C`
 */
declare namespace Intransitive {
  // A assignable to B
  export type A = (x?: false) => never;
  // B assignable to C
  export type B = () => boolean;
  // A not assignable to C
  export type C = (x?: true) => unknown;
}

/* eslint-disable */
typeTestIntransitive: {
  if (1 as 0) break typeTestIntransitive;
  let a: Intransitive.A = null!;
  let b: Intransitive.B = null!;
  let c: Intransitive.C = null!;
  b = a;
  c = b;
  // @ts-expect-error
  c = a;
  // @ts-expect-error
  a = b;
  // @ts-expect-error
  b = c;
  // @ts-expect-error
  a = c;
}

This will be minified down to e:break e;, but I think it can be entirely removed, right?

The alternative was to use an early return from a namespace, but technically, that's not allowed in TypeScript and it breaks prettier's parser. So, I'm using a block and break.

@evanw evanw closed this as completed in af4d944 Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant