latest typescript breaking changes in lib.dom.ts file

前端 未结 2 724
梦谈多话
梦谈多话 2021-01-02 20:43

In spec.ts For Example: Dom.spec.ts

  describe(\'matchesSelector\', () => {
    let result: boolean;
    let matchelement: HTMLElement;
it(\'Matches for t         


        
2条回答
  •  一个人的身影
    2021-01-02 21:25

    This is a breaking change between 3.0 and 3.1:

    TypeScript's built-in .d.ts library (lib.d.ts and family) is now partially generated from Web IDL files from the DOM specification. As a result some vendor-specific types have been removed.

    The recommendation is to extend the built-in definitions as needed:

    If your run-time guarantees that some of these names are available at run-time (e.g. for an IE-only app), add the declarations locally in your project, e.g.: For Element.msMatchesSelector, add the following to a local dom.ie.d.ts

    interface Element {
        msMatchesSelector(selectors: string): boolean;
    }
    

提交回复
热议问题