Search code examples
angularjstypescriptangular-ui-routervisual-studio-code

Can't find inline index.d.ts of @uirouter/angularjs


I'm using the latest Typescript version with Angularjs 1.6.4 and ui-router, using VS Code.

Currently I'm using the @types folder for type definitions.

There's this problem with Typescript definitions file I've been having for quite some time - namely with moment.js and now when I tried upgrading "angular-ui-router" to the new nested @uirouter/angularjs.

The problem seems to be that typescript doesn't know to look at the "Typings" field in the package.json file of external libraries for their definitions file, even in cases where there clearly is such file e.g in moment.js and @uirouter/angularjs.

This is my tsconfig:

{
    "compilerOptions": {
        "baseUrl": "",
        "module": "es6",
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "removeComments": true,
        "strictNullChecks": true,
        "sourceMap": true,
        "target": "es5",
        "outDir": "junk_js_files",
        "paths": {
            "services": ["app/scripts/services/*"],
            "inputDirectives": ["app/scripts/inputDirectivesModule/*"],
            "common": ["app/scripts/common/*"]
        }
    },
    "include": [
        "app/**/*.ts",
        "DefinitelyTyped/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts",
        "dist"
    ]
}

In both moment.js and @uirouter/angularjs you can clearly see there's a field in the package.json file stating where the typings (index.d.ts) file is, why is typescript ignoring it?

I can't upgrade to the latest uirouter because of this annoying bug, which prevents me from working with the newest definitions file.

How can I "teach" typescript to look for the typings field and use the index.d.ts provided by 3rd party libraries?

Thanks, Avi.


Solution

  • Whoever finds this and also has this problem, here: https://github.com/Microsoft/TypeScript/issues/17958