Fixup types to make TS happy

This commit is contained in:
Tangent 2023-08-06 02:09:30 -04:00
parent 8fc2892630
commit e9fbf137c7
3 changed files with 13 additions and 14 deletions

View file

@ -32,11 +32,11 @@ type Vm = {
};
/**
* @param {Vm} state VM state
* @param {string} code Script to run
* @returns {string} Markup to render / output
* @param state VM state
* @param code Script to run
* @returns Markup to render / output
*/
function renderCard(state, code) {
function renderCard(state: Vm, code: string) {
const script = parse(code);
if (script[0]) {
state.output = JSON.stringify(script[1], null, 2);
@ -48,9 +48,8 @@ function renderCard(state, code) {
/**
* Global state: a single card
* @type {Card}
*/
let theCard = {
let theCard: Card = {
id: 100,
fields: {},
code: String.raw`
@ -100,8 +99,8 @@ const display = document.createElement("blockquote");
const debugDisplay = document.createElement("pre");
function render() {
const vm = {
mode: /** @type {ScriptType} */ "render",
const vm: Vm = {
mode: "render",
output: "",
};
const html = renderCard(vm, theCard.code);