In Typescript I can add a type for a hashtable foo whose keys are members of an enum Flag with foo: { [key in Flag]: any}. However, this requires that foo contains a key-value pair for every member of the Flag enum. What if I just want it to be partial - to say that the keys in foo can only be members of Flag, but I'm not expecting every member of Flag?
How to type a hashtable whose keys can only be members of an enum?
15 Views Asked by Patrick Finnigan At
1
There are 1 best solutions below
Related Questions in ENUMS
- How to solve unchecked cast
- Approaches to persist enum in java
- how to convert varchar variable to enum without first declaring the enum type?
- Why does Enum require to implement toEnum and fromEnum, if that's not enough for types larger than Int?
- Put enum in tuple and return tuple from C++ function
- Retrieving text value from ENUM by using int number that doesn't exist in said ENUM returns that int number in C#?
- match a partially moved enum Rust
- Separate big Enum list in different file in C#
- for loop is not printing all defined enum
- SwiftUI @Observable class ViewModel gets initialized twice when setting an enum variable, but not class ViewModel: ObservableObject
- Generate Custom Enum using NSWag cli
- Few enums have constants values in common, causing OpenAPI Generator to fail. How to put some of the model classes, types in different packages?
- Get int value from Enum in Visual Scripting (Unity)
- Blazor custom dropdown with HTML select and sorting by text, not value for enums
- How to use php8 enum types in Laravel where conditions?
Related Questions in HASHTABLE
- Hashing vertices of a Graph in C
- The difference between set definitions in Python
- Order of a set in Python
- Why is fast lookup possible for dict.items()?
- Radix tree vs Hashtable
- Hashtable lookup time confusing if hash function is not constant
- Hash Table creation runtime complexity
- Powershell script no longer working, error "The assignment expression is not valid. "
- Why python3 dict's get method O(1) time while under the hood it is aclually O(n)?
- How to benchmark/compare Hlist and rbtree?
- Powershell I can not figure out how to process several hash-tables to desired output with help of inlayed foreach cycles
- Is there a way to call libcuckoo's cuckoo_hash_map with keys only (C++)?
- Problem with not existing element in Hash Table in C
- Memory leak in C: free a hashtable
- My program just stopped printing in the outputFile after I add some changes
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Add a question mark to mark the keys as optional:
foo: { [key in Flag]?: any}