Microsoft/TypeScript

CanvasRenderingContext2D has no reset() method

Open

#55,162 建立於 2023年7月26日

在 GitHub 查看
 (4 留言) (3 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

Bug Report

According to MDN docs and HTML Standard a CanvasRenderingContext2D object should have the reset() method, but latest tsc (5.1.6) does not have it defined.

🔎 Search Terms

CanvasRenderingContext2D

🕗 Version & Regression Information

This is a crash

⏯ Playground Link

Playground link with relevant code

💻 Code

const canvas = document.createElement('canvas');
(() => {
  const context = canvas.getContext('2d');
  if (!context) return;

  context.reset();
})();

🙁 Actual behavior

PS C:\Users\Davin\Documents\GitHub\2dCanvasTypescriptResetBug> npx tsc
index.tsx:6:11 - error TS2339: Property 'reset' does not exist on type 'CanvasRenderingContext2D'.

6   context.reset();
            ~~~~~


Found 1 error in index.tsx:6

🙂 Expected behavior

Found 0 errors

貢獻者指南