I am getting the error:
Element implicitly has an 'any' type because expression of type '"bla"' can't be used to index type 'Record<string, any> | PropertiesI'.
Property 'bla' does not exist on type 'Record<string, any> | PropertiesI'.ts(7053)
In the following typescript:
interface PropertiesI {
bar: string;
}
interface ParentSchemaI {
foo: string;
properties: PropertiesI | Record<string, any>;
}
const mySchema: ParentSchemaI = {
foo: "baz",
properties: {
bla: "blabla", // This doesn't give me an error
},
};
const attempt = mySchema.properties["bla"]; // yet this flags as an error?
Why would typescript allow me to create a property on a new object and then throw an error when I try to access the same property?