Public Access
fix: resolve tsc-b build errors (Tex JSX type, Essay index sig, ExamRunner closure, vitest config)
This commit is contained in:
1 parent
61496b4b2f
commit
2b12223da6
5 files changed
+9
-6
No files matched your search
@@ -95,7 +95,7 @@ export default function App() {
|
|||||||
<Landing onLoadExam={loadExam} history={history} onResume={resume} onClearHistory={clearAllHistory} onReviewAttempt={reviewAttempt} />
|
<Landing onLoadExam={loadExam} history={history} onResume={resume} onClearHistory={clearAllHistory} onReviewAttempt={reviewAttempt} />
|
||||||
)}
|
)}
|
||||||
{screen === 'exam' && exam && examState && (
|
{screen === 'exam' && exam && examState && (
|
||||||
<ExamRunner exam={exam} state={examState} setState={setExamState} onSubmit={submit} onExit={exit} />
|
<ExamRunner exam={exam} state={examState} setState={setExamState as React.Dispatch<React.SetStateAction<ExamState>>} onSubmit={submit} onExit={exit} />
|
||||||
)}
|
)}
|
||||||
{(screen === 'results' || screen === 'review') && exam && examState && (
|
{(screen === 'results' || screen === 'review') && exam && examState && (
|
||||||
<Results exam={exam} state={examState} onRestart={restart} onExit={exit} reviewOnly={screen === 'review'} />
|
<Results exam={exam} state={examState} onRestart={restart} onExit={exit} reviewOnly={screen === 'review'} />
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ export default function ExamRunner({ exam, state, setState, onSubmit, onExit }:
|
|||||||
if (e.key === 'f') toggleFlag()
|
if (e.key === 'f') toggleFlag()
|
||||||
if (/^[1-9]$/.test(e.key) && q.type === 'multiple-choice' && q.choices) {
|
if (/^[1-9]$/.test(e.key) && q.type === 'multiple-choice' && q.choices) {
|
||||||
const ci = parseInt(e.key, 10) - 1
|
const ci = parseInt(e.key, 10) - 1
|
||||||
if (q.choices[ci]) setState((s) => ({ ...s, answers: { ...s.answers, [q.id]: q.choices[ci].id } }))
|
const choices = q.choices
|
||||||
|
if (choices[ci]) setState((s) => ({ ...s, answers: { ...s.answers, [q.id]: choices[ci].id } }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', handler)
|
window.addEventListener('keydown', handler)
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
|
import type React from 'react'
|
||||||
import { renderLatex } from '../utils/latex'
|
import { renderLatex } from '../utils/latex'
|
||||||
|
|
||||||
interface TexProps {
|
interface TexProps {
|
||||||
children?: string | null
|
children?: string | null
|
||||||
tag?: keyof JSX.IntrinsicElements
|
tag?: keyof React.JSX.IntrinsicElements
|
||||||
className?: string
|
className?: string
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe: renderLatex only produces KaTeX-controlled HTML + HTML-escaped plain text.
|
// Safe: renderLatex only produces KaTeX-controlled HTML + HTML-escaped plain text.
|
||||||
export default function Tex({ children, tag: Tag = 'span', className, style }: TexProps) {
|
export default function Tex({ children, tag = 'span', className, style }: Readonly<TexProps>) {
|
||||||
|
const Tag = tag as React.ElementType
|
||||||
const html = String(children ?? '').split('\n').map(renderLatex).join('<br/>')
|
const html = String(children ?? '').split('\n').map(renderLatex).join('<br/>')
|
||||||
return <Tag className={className} style={style} dangerouslySetInnerHTML={{ __html: html }} />
|
return <Tag className={className} style={style} dangerouslySetInnerHTML={{ __html: html }} />
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import type { Question } from '../../types'
|
|||||||
interface EssayValue {
|
interface EssayValue {
|
||||||
text?: string
|
text?: string
|
||||||
selfGrade?: number
|
selfGrade?: number
|
||||||
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/// <reference types="vitest" />
|
import { defineConfig } from 'vitest/config'
|
||||||
import { defineConfig } from 'vite'
|
|
||||||
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
|
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
|
||||||
import babel from '@rolldown/plugin-babel'
|
import babel from '@rolldown/plugin-babel'
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user