Here is a class I am working with:
export class Character {
id: number;
name: string;
portrait: string;
abilities: array;
equipment: array;
statistics: object;
money: number;
description: string;
}
The data is being exported to a mock file as shown below:
import { Character } from './character';
export const CHARACTERS: Character[] = [{
"id": 1,
"name": "Dragon-Bear",
"portrait": "dbear.png",
"abilities": ["Wounded Roar", "Summon Wildings", "Bear Sprint", "Alternative Appearance"],
"equipment": ["Imbedded Thorn", "Bloodstone Necklace", "Spirit Flask"],
"statistics": { "Business Sense": 47, "Sexuality": 87, "Weirdness": 86, "Persuation": 92, "Cuddliness": 76, "Meme Influence Zone": 23, "Close Reading": 63, "Humanity": 30 },
"money": 134,
"description": "Dragon-Bears are wild and ferocious creatures, but also have a gentle, nurturing side. Once a Dragon-Bear mates, it will protect its partner and any offspring with its life. Dragon-Bears also like to cuddle."
}, {
"id": 2,
"name": "Lene-Cow",
"portrait": "lcow.png",
"abilities": ["Fade Into Background", "Alter Vibrations", "Cunning Innocence", "Create Milk"],
"equipment": ["Long Glass Of Milk", "Scarf Of Influence"],
"statistics": { "Business Sense": 34, "Sexuality": 73, "Weirdness": 92, "Persuation": 74, "Cuddliness": 86, "Meme Influence Zone": 32, "Close Reading": 43, "Humanity": 77 },
"money": 324,
"description": "Lene-Cows are canny and stealthy, and beguiled almost everyone they meet. They are, however, occasionally prone to minor fits of rage, but their natural charm and magnetism means people usually accept this trait as a lovable quirk, rather than a character flaw. Lene-Cows are very good at keeping secrets."
}, {
"id": 3,
"name": "Clown-Fox",
"portrait": "cfox.png",
"abilities": ["Fox Charm", "Hypnotise"],
"equipment": ["Judge's Wig", "Clown Nose"],
"statistics": { "Business Sense": 89, "Sexuality": 98, "Weirdness": 45, "Persuation": 98, "Cuddliness": 21, "Meme Influence Zone": 52, "Close Reading": 63, "Humanity": 30 },
"money": 234,
"description": "Charming and dashing, Clown-Foxes are particularly adept at wooing members of the opposite sex, of whatever species. They are also extremely skilled at convincing people to do business with them."
}];
Unfortunately, when attempting to transpile from TypeScript, the following error is encountered:
app/characters/character.ts(5,19): error TS2304: Cannot find name 'array'.
app/characters/character.ts(6,19): error TS2304: Cannot find name 'array'.
app/characters/character.ts(7,20): error TS2304: Cannot find name 'object'.
app/characters/characters-mocks.ts(29,7): error TS2322: Type '({ "id": number; "name": string; "portrait": string; "abilities": string[]; "equipment": string[]...' is not assignable to type 'Character[]'.
Type '{ "id": number; "name": string; "portrait": string; "abilities": string[]; "equipment": string[];...' is not assignable to type 'Character'.
Type '{ "id": number; "name": string; "portrait": string; "abilities": string[]; "equipment": string[];...' is not assignable to type 'Character'.
Object literal may only specify known properties, and '"Description"' does not exist in type 'Character'.
I need help in correctly implementing and referencing the data in my project.