相关疑难解决方法(0)

最新的打字稿打破了lib.dom.ts文件中的变化

在spec.ts例如:Dom.spec.ts

  describe('matchesSelector', () => {
    let result: boolean;
    let matchelement: HTMLElement;
it('Matches for the opera browser', () => {
        matchelement.matches = matchelement.msMatchesSelector = null;
        result = Dom.matches(matchelement, '#match');
        expect(result).toBe(true);
    });
Run Code Online (Sandbox Code Playgroud)

在上面的代码中调用matchelement.msMatchesSelector中的msmatchesSelector时,它会在lib.dom.ts中获取specfic类型.当我将打字稿版本升级到3.0时,它会重现以下错误

spec\dom.spec.ts(304,49): error TS2339: Property 'msMatchesSelector' does not exist on type 'HTMLElement'.
Run Code Online (Sandbox Code Playgroud)

但它在我以前的打字稿版本2.6.2中工作正常

typescript

5
推荐指数
1
解决办法
2279
查看次数

标签 统计

typescript ×1