Ronald Zarīts Ronald Zarīts - 15 days ago 16
TypeScript Question

TypeScript typings in NPM @types org packages

I've noticed there's an NPM organization @types, which contains typing packages, but can't find any documentation on it. How are these meant to be used?

Is it meant to be used with typings tool? If so, how to install them? For instance, there's a

package, but
typings search npm:openlayers
returns nothing.

Is it meant to be used separately from the typings tool? E.g. installed directly with


As of TypeScript 2.0, typings is no longer required. The npm organization is an entity to setup a developers team. I believe Microsoft setup the @types organization in NPM and added the TypeScript developer team to the organization. Packages on under the @types organization are published automatically from DefinitelyTyped using the types-publisher tool as per the docs.

In addition, to there is another way to add types to your packages:

In your package.json

If your package has a main .js file, you will need to indicate the main declaration file in your package.json file as well. Set the types property to point to your bundled declaration file. For example:

    "name": "awesome",
    "author": "Vandelay Industries",
    "version": "1.0.0",
    "main": "./lib/main.js",
    "types": "./lib/main.d.ts"

Note that the "typings" field is synonymous with "types", and could be used as well.

Also note that if your main declaration file is named index.d.ts and lives at the root of the package (next to index.js) you do not need to mark the "types" property, though it is advisable to do so.

Regarding searching types

For the most part, type declaration packages should always have the same name as the package name on npm, but prefixed with @types/, but if you need, you can check out to find the package for your favorite library.

From -

But when I did npm search @types/openlayers, I did not get any results. But doing the search from the web interface did return me the results. So I guess npm search does not search across organizations.