Fixup types to make TS happy
This commit is contained in:
parent
8fc2892630
commit
e9fbf137c7
3 changed files with 13 additions and 14 deletions
src
15
src/3x5.ts
15
src/3x5.ts
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue