In spec.ts For Example: 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);
});
when calling msmatchesSelector in matchelement.msMatchesSelector in above code it fetch the specfic type in lib.dom.ts . It reproduce the below error when I uprade the typescript version to 3.0
spec\dom.spec.ts(304,49): error TS2339: Property 'msMatchesSelector' does not exist on type 'HTMLElement'.
But It works fine in my previous typescript version 2.6.2
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With