latest typescript breaking changes in lib.dom.ts file

前端 未结 2 714
梦谈多话
梦谈多话 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:02

    You can also use these easy codes at top of file

    interface Element {
       msMatchesSelector: any;
    }
    
    0 讨论(0)
  • 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;
    }
    
    0 讨论(0)
提交回复
热议问题