I have been initializing some constant classes as
export class A {
foo: string,
b: B
}
export class B {
bar: number
}
And then importing them into another class and initializing them in another file. However, if I have issues using class B when I want to initialize class A.
Example:
import { A, B } from '../models/class';
export const myVariable: A = {
foo: 'FOO',
b: B = {
bar: 5
}
}
the first assignment is correct. However, the B class inside A will give me the error - Cannot assign to 'B' because it is an import.
AandBhave to be classes? If you only need them for their types, it'd make much more sense to make theminterfaces and you makeb: {...} as B.