How to use @types/[library] in a component?

Hello ! =).

I am a beginner in Ionic 2 and TypeScript, and i try to despair to use the external library “geolib” during two day. ( in my project with @types/geolib.

I have read lot of forum about that, but nothing work for me… I know i am probably a noob ^^".

So i have do :

npm install --save @types/geolib

and in my component i try to use it like that :

import * as Geolib from "geolib";

Result error : File ‘/Users/***/Lab/[project name]/node_modules/@types/geolib/index.d.ts’ is not a module.

I have try too with

/// <reference path="..." /> and /// <reference type="..." />

My tsconfig.json :

    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [
        "module": "es2015",
        "moduleResolution": "node",
        "sourceMap": true,
        "target": "es5"
    "include": [
    "exclude": [
    "compileOnSave": false,
    "atom": {
        "rewriteTsconfig": false

Someone can explain me what I do wrong ? Thanks

It looks like that library has TypeScript definitions included with it, so I would get rid of that @types/geolib for starters.

1 Like

My bad … You right ! it’s work, thanks rapropos :grin:

I juste need to do :

npm install geolib

And import with :

import * as Geolib from 'geolib';