Sitelet https://github.com/angular/angular/issues/38979
Skip to content

Losing @types/* packages types on second+ server rebuild #38979

Description

@artaommahe

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 9.x

Description

Somehow typescript loses @types/* types on second+ angular app rebuild. It works fine on devserver start, first rebuild and on build command.
We faced this for require and some webpack typings in our apps after update ng9 -> ng10.

🔬 Minimal Reproduction

Adding types: ['node'] solves require type error, but you need to add all @types/* packages for big projects. @types/* should work fine without any additional actions.

🔥 Exception or Error


    ERROR in src/app/app.component.ts:2:1 - error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node`.
    
    2 require('./test.svg');
      ~~~~~~~

🌍 Your Environment


PS D:\projects\issues\angular-cli-missing-types-on-rebuild> yarn ng version
yarn run v1.16.0
$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.1.2
Node: 12.18.1
OS: win32 x64

Angular: 10.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.2
@angular-devkit/build-angular   0.1001.2
@angular-devkit/core            10.1.2
@angular-devkit/schematics      10.1.2
@schematics/angular             10.1.2
@schematics/update              0.1001.2
rxjs                            6.6.3
typescript                      4.0.3

Anything else relevant?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions