Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Switch: create all cases - doesnt work for dynamic union type #37

Closed
sellalone opened this issue Jul 7, 2021 · 1 comment
Closed

Switch: create all cases - doesnt work for dynamic union type #37

sellalone opened this issue Jul 7, 2021 · 1 comment
Labels
🐛 Bug Something isn't working

Comments

@sellalone
Copy link

Describe the bug

I have dynamic union type as type Animal = "cat" | "dog" | "rabbit" | "snake" coming from string literal type of array values and I don't see the option Create all cases

How to reproduce

try to use the following code :

export type Lit = string | number | boolean | undefined | null | void | {};
export const tuple = <T extends Lit[]>(...args: T) => args;

const animals = tuple('cat', 'dog', 'rabbit', 'snake');
type Animal = (typeof animals)[number];  // union type

function getAnimalInfo(value: Animal): string {
  switch (value) {
  }
}

Expected behavior

Successfully creates a case for each member of the union type like

function getAnimalInfo(value: Animal): string {
  switch (value) {
    case 'cat':
      return 'Here is some info';
    case 'dog':
      return 'Here is some info';
    case 'rabbit':
      return 'Here is some info';
    case 'snake':
      return 'Here is some info';
    default:
      return '';
  }
}

Screenshots

Screenshot 2021-07-07 at 13 47 07

Additional information

  • Version of the extension impacted: v1.7.0
@sellalone sellalone added the 🐛 Bug Something isn't working label Jul 7, 2021
@nicoespeon
Copy link
Owner

Hey, thanks for reporting but it's been a while since I updated this extension and I'm not planning to do this in the foreseeable future. I'm archiving the extension 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants