Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Enum types potentially too strict #325

@mattrothenberg

Description

@mattrothenberg

Describe the bug

When using the VSCodeRadioGroup component, I noticed that the following code resulted in a Typescript error

<VSCodeRadioGroup orientation="vertical">
    <VSCodeRadio value="apple">Apple</VSCodeRadio>
    <VSCodeRadio value="banana">Banana</VSCodeRadio>
    <VSCodeRadio value="orange">Orange</VSCodeRadio>
  </VSCodeRadioGroup>
Type '"vertical"' is not assignable to type 'Orientation | undefined'.ts(2322)

While I was able to resolve this by importing the RadioGroupOrientation enum from the package, it struck me as odd that the string vertical or horizontal didn't satisfy the orientation prop. Particularly considering the definition of the enum itself 👇

import { RadioGroupOrientation } from "@vscode/webview-ui-toolkit";
console.log(RadioGroupOrientation) // {horizontal: "horizontal", vertical: "vertical"}

As a React developer, I would expect both values – "vertical" and RadioGroupOrientation.vertical – to function correctly here.

Screenshots

https://codesandbox.io/s/purple-shape-j1ih4?file=/src/App.tsx:247-258

Desktop (please complete the following information):

  • OS Version: MacOS 11.6.2
  • Toolkit Version: 0.9.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions