I am creating a data-file that looks like this:
interface ISprite { textureName: string, frame: Frame, origin: Vec2, zIndex?: number}export let sprites: Record<string, ISprite> = { monster: { textureName: "monster", frame: new Frame(0, 0, 32, 41), origin: new Vec2(16, 28), zIndex: -1 }, player: { textureName: "player", frame: new Frame(0, 0, 32, 32), origin: new Vec2(15, 32) }};If I then try to import this data file from another file like so:
import { sprites } from "../data/sprites";And then try to access a property like this:
let player = sprites.player;Then I don't get Intellisense (code completion) when I type sprites.
I noticed, however, that if I remove the Record<string, ISprite> annotation from the sprites variable declaration that I do get intellisense.
However, I believe I require this annotation, because one of my functions only takes ISprite types, and I don't want to instead make it take an any.
Is it possible to maintain the strong typing while also having code completion?