language-service icon indicating copy to clipboard operation
language-service copied to clipboard

Refactor to Schema: support conversion of `typeof A` where A is a const string to Literal

Open adrian-gierakowski opened this issue 7 months ago • 0 comments

What is the problem this feature would solve?

given following code:

const A = 'A' as const

export type MyObj = {
  a: typeof A
}

executing "Refactor to Schema" actions results in the following:

const A = 'A' as const

export const MyObj = Schema.Struct({
  a:  /* Not supported conversion: typeof A */
})

export type MyObj = {
  a: typeof A
}

What is the feature you are proposing to solve the problem?

Would be great if given the input above, we could get the following schema:

export const MyObj = Schema.Struct({
  a:  Schema.Literal('A')
})

What alternatives have you considered?

No response

adrian-gierakowski avatar May 22 '25 18:05 adrian-gierakowski