Gary Sieling

Typings: browser vs main

If you set up typings, you will see “browser” and “main” in the folder that has the type bindings you’ve downloaded:

ls -al typings
total 16
drwxr-xr-x   6 gary  staff  204 Apr 26 21:40 .
drwxr-xr-x  10 gary  staff  340 Apr 26 21:42 ..
drwxr-xr-x   3 gary  staff  102 Apr 26 21:40 browser
-rw-r--r--   1 gary  staff   62 Apr 26 21:40 browser.d.ts
drwxr-xr-x   3 gary  staff  102 Apr 26 21:40 main
-rw-r--r--   1 gary  staff   59 Apr 26 21:40 main.d.ts

Each type definition file is just a wrapper that loads all the sub-files you’ve requested:

Garys-MBP:youtube gary$ diff typings/browser.d.ts typings/main.d.ts 
1c1
< /// 
---
> /// 

In fact, the actual type bindings you’ve downloaded are likely to be the same for each.

The purpose of this is to allow the type bindings to differ between the browser and Node versions (e.g. if an API is not available or different for whatever reason). Most of the type these are the same, so it is not an issue.

You likely want to pick just the appropriate to include, e.g.:

///  
Exit mobile version