Here is an example code snippet to consider:
type PredefinedStrings = 'test' | 'otherTest';
interface MyObject {
type: string | PredefinedStrings;
}
The interface MyObject
has a single property called type
, which can be one of the predefined strings in PredefinedStrings
or a custom string defined by the developer.
The goal is to allow developers to input any string for the type
property while still showing predefined options as suggestions using IntelliSense. Is there a way to achieve this dual functionality?