Still a bit new to coding. I'm trying to create a TypeScript class in an Angular project based on a larger JSON file. I'm not sure if it doesn't like the way the properties were with the string literals, but that was how they were declared in the JSON and I'm not sure if there's a better way to declare them in TS. When I declare the properties, they're fine...
// this all seems ok
export class State {
'FIPS Code': number;
'Postal': string;
'Area Name': string;
'Less than a high school diploma, 1970': number;
...
}
When I make a constructor, I get various errors...
// all parameter identifiers say 'identifier expected'
constructor('FIPS Code': number, 'Postal': string,
'Area Name': string,
'Less than a high school diploma, 1970': number,
'High school diploma only, 1970': number,
...) {
// Type '"FIPS Code"' is not assignable to type 'number'
this['FIPS Code'] = 'FIPS Code';
// the next two are ok, I assume because they're strings
this['Postal'] = 'Postal';
this['Area Name'] = 'Area Name';
// everything else remaining says not assignable to type 'number'
this['Less than a high school diploma, 1970'] = 'Less than a high school diploma, 1970';
...
}