You can use an object type instead of an interface, which are mostly interchangeable:
type IMargin = {
[key in 'foo' | 'bar']: boolean;
}
Related Contents:
- Are strongly-typed functions as parameters possible in TypeScript?
- What is “not assignable to parameter of type never” error in TypeScript?
- Angular no provider for NameService
- What is the question mark for in a Typescript parameter name
- Typescript ReferenceError: exports is not defined
- How to configure custom global interfaces (.d.ts files) for TypeScript?
- How to define an interface for objects with dynamic keys?
- Typescript: Check “typeof” against custom type
- TypeScript hashmap/dictionary interface
- What does the “as” keyword do?
- Why does Typescript use the keyword “export” to make classes and interfaces public?
- Property ‘assign’ does not exist on type ‘ObjectConstructor’
- tsc throws `TS2307: Cannot find module` for a local file
- How to use fetch in TypeScript
- How do you debug Jest Tests?
- Is there a way to use npm scripts to run tsc -watch && nodemon –watch?
- Private setter typescript?
- Reexport class in Typescript
- Why am I getting an error “Object literal may only specify known properties”?
- TypeScript: deep partial?
- How to disable automatic import statements in VsCode October 2017
- Typescript: How to export a variable
- TypeScript function arrow expression returning object
- What is the difference between type and class in Typescript?
- TypeScript error in Angular2 code: Cannot find name ‘module’
- Is it possible to restrict TypeScript object to contain only properties defined by its class?
- TypeScript – Removing readonly modifier
- How to declare a type globally in a project (typescript)
- What is the purpose of bivarianceHack in TypeScript types?
- Debugging nest.js application with vscode
- Angular 2 Multiple validators
- Determine the number of enum elements TypeScript
- How do I access Typescript Enum by ordinal
- How to pass variable to “data-target=” angular 2
- How to fix “Expression produces a union type that is too complex to represent. ts(2590)”?
- Circular Type References in TypeScript
- How to generate basic TypeScript interfaces from Swagger schema?
- How to have npm install a typescript dependency from a GitHub url?
- Typescript: Omit a property from all interfaces in a union, but keep the union structure
- What to put in package.json types field for typescript based libs
- ts-jest does not recognize es6 imports
- TypeScript linter warning: no-unused-variable is deprecated; but I’m not using this config
- TypeORM: How to order by a relation field
- How do I include output parameters in a function with Typescript?
- exporting enum from typescript type definition file
- How to fix ‘Cannot use namespace as a type ts(2709)’ in typescript?
- TypeScript type for reduce
- Why can’t an interface be assigned to Record?
- Using globalThis in Typescript
- Can I check a type against a union type in typescript?