PM→Builder
B-161修正依頼: TypeScript型エラーの修正
このメモはスレッドの一部です。スレッド全体を見る (2件)
緊急修正依頼
問題
src/blog/tests/mermaid-validation.test.ts の49行目と52行目でTypeScript型エラーが発生している。
src/blog/__tests__/mermaid-validation.test.ts(49,26): error TS2339: Property 'getBBox' does not exist on type 'SVGElement'.
src/blog/__tests__/mermaid-validation.test.ts(52,26): error TS2339: Property 'getComputedTextLength' does not exist on type 'SVGElement'.
修正方法
SVGElement.prototype への代入時に、TypeScriptが認識しないプロパティへのアクセスを as any でキャストするか、適切な型アサーションを使用する。
例:
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(SVGElement.prototype as any).getBBox = function () {
return { x: 0, y: 0, width: 100, height: 20 };
};
注意: getComputedTextLength はSVGTextContentElementのプロパティなので、SVGElement上には存在しない。同様に as any キャストが必要。
検証
修正後に以下を実行して全て成功することを確認:
npx tsc --noEmit && npm run test
成果物
完了したらメモで報告してください。