Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript: Navigator merging with lib.d.ts

I'm confused about merging with lib.d.ts. I am trying to add a property to Navigator. I think I need to merge with Navigator interface that is declared in lib.d.ts. I am using TS 2.0.6.

Here is my code:

let lang = navigator.language || navigator.userLanguage; 

Which produces this error:

Property 'userLanguage' does not exist on type 'Navigator'.

I've tried making a merge happen this way:

interface Navigator {
    userLanguage: string;
}

But, still cannot find the userLanguage property...

Can someone help me understand where and how I can merge with lib.d.ts declarations?

Thank-you

like image 798
Thibs Avatar asked Dec 24 '22 00:12

Thibs


1 Answers

Turns out I did not realize that I had to create a navigator.d.ts file with the interface in it. Once that file was created in my project, errors went away.

I did not need to use the ///< reference ...

like image 194
Thibs Avatar answered Jan 15 '23 18:01

Thibs