score:-2
this is similar to this question. you can basically use the builtin typescript utility type exclude.
or you could do it like this :
enum statusminimal {
completed = 'completed',
created = 'created'
}
enum statusextended {
completed = 'completed',
created = 'created'
}
type status = statusminimal | statusextended;
score:1
as far as i know there is no trivial way. see this similiar question.
i would start with minimal and extend the status enum from the minimal implementation. (i know, not what your asked for)
score:4
you can define a property/parameter based on the status
and exclude
the unwanted values
function test(s: exclude<status, status.cancelled>): void {}
test(status.completed)
test(status.created)
test(status.cancelled) // not assignable
Source: stackoverflow.com
Related Query
- typescript how to omit enum values
- How to pass multiple enum values to a variable in ReactJs typescript
- How to set multiple values at once in react hook form using Typescript
- How to set react-final-form onSubmit values param type TypeScript
- How to push configuration values from Asp.Net Core MVC 2.0 config file to React TypeScript client script?
- How to constrain select's defaultValue to one of the option's values in TypeScript
- How to use an enum in typescript as a default prop value for a react component
- How to get default values from Typescript object?
- How to make TypeScript enum restrict to specific number
- Typescript - how to omit properties so a subset can be transferred with spread?
- How do I import a Mobx state tree and reference its values in a Typescript file without a component?
- How to Set Initial Values to Formik using Axios with Typescript
- How to declare multiple enum in a single TypeScript file and return under single export statement (so that not exposing individual enums directly)
- How do I provide default values to optional nested props of type Object in typescript + React?
- How to write omit function with proper types in typescript
- How can I set default values for props on a React TypeScript component?
- How to store input values when moving to another component in react typescript functional components
- How to extend enum for Typescript in React
- How to update nested state or values in Typescript and Reactjs?
- How create React Typescript component with required and optional values but required value without default value?
- How do I handle possible null values in TypeScript when I can't access the defintions
- How to use enum values as a type
- How can I show enum values ​from API in select dropdown in reactjs?
- How to describe extracted values to an array in typescript
- How to Update Typescript React Redux State With One or More Reducer State Values
- How to use refs in React with Typescript
- How to specify (optional) default props with TypeScript for stateless, functional React components?
- How to define css variables in style attribute in React and typescript
- How do I restrict the type of React Children in TypeScript, using the newly added support in TypeScript 2.3?
- How to properly validate input values with React.JS?
More Query from same tag
- React/JS/TS - Adding prop to component by location
- Reinitialization of @ion-phaser/react function component removes canvas from dom
- BrowseRouter MIME type error
- How to render a 50x50 table in React?
- How to display an image which comes back from an axios request (React)?
- ngReact: watch-depth attribute types explained
- React. I am trying to set the default state of quote to to an array containing one random object from my quotes array when the browser launches
- React with Rails 5.1 Calling Database Objects into React Components
- Run render and reconciler on children only
- Ensure parent only displays when all childs are loaded
- Check to compare password field with confirm password reactjs/spring boot
- How to apply disableGutters props on MTableToolbar?
- Reactjs : TypeError: Cannot read property 'value' of undefined
- Protect routes with react router dom v6 Nothing was returned from render
- Next.js dynamic route - 404 on page reload after added SLUG
- Scrollable drop down lists in react-bootstrap
- Remove movement/draggable scroll on google maps react
- Insert a React component inside markdown without MDX
- My react form is not submitting correctly
- How to filter array of objects in React
- Remove inner padding border in Material UI Outlined Text Field
- Remove element that is not in .css
- React rendering issue with material-ui library
- Trying to use getCurrentContent in draftjs file
- Unexpected Results Splicing on Spreaded Array
- Not able to call onChange function of a TextInput in Redux, React JS
- changing the order from asc to desc or vice versa on click table header react
- Convert json data in reactjs
- Prevent Gatsby page at a specific domain path from appearing in Google Search
- ESLint configuration in .eslintrc is invalid: - Unexpected top-level property "import/no-extraneous-dependencies"