Is there a way to write a type or an interface that forces the object keys to be in camelCase?
type CamelCaseObject = // ... ?
const myObject: CamelCaseObject;
myObject.camelCaseKey; // Ok
myObject.not_camel_case_key; // Not ok.
Or an interface would be fine too.
interface ICamelCaseObject = {
[key: string /* that matches camelCase */]: OtherType;
}
const myObject: ICamelCaseObject;
myObject.camelCaseKey; // Ok
myObject.not_camel_case_key; // Not ok.