Hello, I am using a code-generation library and had trouble wrapping my mind around some issue. Take a look at the following piece of code:
export namespace components {
export const component2 = {
component1Flag: components['component1'].flag
}
export const component1 = {
flag: true
}
}
On a strict type level, this works. Typescript sees no type issue in the previous code. However, at runtime this piece of code fails with the error components['component1'] is undefined on line 3.
Why is this code authorized at the type level while it doesn't run?
Thank you