Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng build throws downlevelIteration error targeting es2015 #14697

Closed
lppedd opened this issue Jun 6, 2019 · 3 comments 路 Fixed by #14698
Closed

ng build throws downlevelIteration error targeting es2015 #14697

lppedd opened this issue Jun 6, 2019 · 3 comments 路 Fixed by #14698
Labels
area: schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@lppedd
Copy link

lppedd commented Jun 6, 2019

馃悶 Bug report

Command (mark with an x)

- [ ] new
- [x] 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: 7.3.*

Description

Building with ng build while targeting es2015 throws downlevelIteration error.

馃敩 Minimal Reproduction

Create a new Angular application and use this code for app.component.ts

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  map = new Map<string, string>();

  ngOnInit(): void {
    this.map.set('key', 'value');

    for (const [k, v] of this.map) {
      console.log(k, v);
    }
  }
}

馃敟 Exception or Error


ERROR in src/app/app.component.ts(15,26): error TS2569: Type 'Map' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

馃實 Your Environment


Angular CLI: 8.0.1
Node: 10.11.0
OS: win32 x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.1
@angular-devkit/build-angular     0.800.1
@angular-devkit/build-optimizer   0.800.1
@angular-devkit/build-webpack     0.800.1
@angular-devkit/core              8.0.1
@angular-devkit/schematics        8.0.1
@angular/cli                      8.0.1
@ngtools/webpack                  8.0.1
@schematics/angular               8.0.1
@schematics/update                0.800.1
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

tsconfig.json


{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
@lppedd
Copy link
Author

lppedd commented Jun 6, 2019

@alan-agius4 judging by your commit I suppose I could just add it to the tsconfig.json file, and it would be "equivalent". Am I right? How was it different in 7.* (I mean, here I was not targeting ES5)?
Btw, thanks for the quick response.

Edit: ok, I think I got it. It's because of differential loading.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jun 7, 2019

Yeah you are right 馃槉, thanks for brining this to our attention.

kyliau pushed a commit that referenced this issue Jun 7, 2019
We by default now use ES2015. Users can use ES2015 iterations however the ES5 build will fail.

Fixes #14697
kyliau pushed a commit that referenced this issue Jun 10, 2019
We by default now use ES2015. Users can use ES2015 iterations however the ES5 build will fail.

Fixes #14697
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants