Skip to content

tsconfig.app.json types are ignored #5351

Closed

Description

@coryrylan

Please provide us with the following information:

OS?

Windows 10 x64

Versions.

@angular/cli: 1.0.0-rc.1
node: 6.9.1
os: win32 x64

Repro steps.

Update package.json from @angular/cli": "1.0.0-rc.0 to @angular/cli": "1.0.0-rc.1.

The log given by the failure.

Cannot find name 'require'
Cannot find namespace 'ol'
Cannot find name 'describe'
Cannot find name 'beforeEach'
Cannot find name 'it'
Cannot find name 'expect'

Mention any other details that might be useful.

When using certain 3rd party libraries or require() you need to add the types to the tsconfig.app.json as described here https://github.com/angular/angular-cli/wiki/stories-third-party-lib. In the latest RC1 it looks like the types option is ignored resulting the above error. If I remove the types entry and replace it with the global typeRoots entry it seems to work but is not ideal to pull in all types. This also affects the tsconfig.spec.json.

Breaks in RC1, used to work in RC0

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "types": [
      "node",
      "openlayers"
    ]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

Work around for RC1

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "typeRoots": [
      "../node_modules/@types"
    ]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

Activity

  1. GustavoMantuan commented on Mar 11, 2017

    @GustavoMantuan

    Thank you so much, Its helped me a lot.

  2. zurie commented on Mar 17, 2017

    @zurie

    this helped me, would be nice to know a official workaround is in place or if i need to just memorize this as a 'gotcha' fix

  3. filipesilva commented on Mar 17, 2017

    @filipesilva
    Contributor

    There has to be something else going on here. I know for a fact that ng test worked in all RCs and it relies on having the jasmine types.

    I also just tried the https://github.com/angular/angular-cli/wiki/stories-third-party-lib example and it worked.

    Have you tried clearing your local node_modules? Maybe there's something wrong in there.

    I can't reproduce this myself. If you can provide a repo where this happens I can investigate.

  4. coryrylan commented on Mar 17, 2017

    @coryrylan
    ContributorAuthor

    Yeah this has persisted since rc1 after clearing nodemodules. Going to update the project to the latest RC Monday and will report back

  5. filipesilva commented on Mar 18, 2017

    @filipesilva
    Contributor

    Actually, I was investigating #5332 and it seems they are related.

    The reason ng test works and has it's typings seems to be due to a weird (and erroneous) compilation setup.

    That error was seems to be masking this one.

  6. added 2 commits that reference this issue on Mar 18, 2017
    4f05519
    ad58c18
  7. filipesilva commented on Mar 19, 2017

    @filipesilva
    Contributor

    Further investigation reveals this is a windows specific problem. A fix is on the way.

  8. added 10 commits that reference this issue on Mar 19, 2017
    73211d6
    e6cfb77
    eb63b6f
    5ab01b7
    e549f72
    f8a34c1
    31ece40
    2d6d4e2
    a560646
    adabd88
  9. added a commit that references this issue on Mar 20, 2017
    303b2c0
  10. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Sep 6, 2019
  12. added a commit that references this issue on May 29, 2026
    586606e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions