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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript code fails to compile, but compiles with a preexisting ng serve #11689

Closed
alexrosenfeld10 opened this issue Jul 27, 2018 · 4 comments
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely needs: investigation Requires some digging to determine if action is needed severity1: confusing type: bug/fix
Milestone

Comments

@alexrosenfeld10
Copy link

alexrosenfeld10 commented Jul 27, 2018

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Windows 10.

node -- version v8.11.3

npm --version 5.6.0

`ng --version
Angular CLI: 6.0.8
Node: 8.11.3
OS: win32 x64
Angular: 6.0.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cli 6.0.8
@ngtools/webpack 6.0.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.2
typescript 2.7.2
webpack 4.8.3
`

Repro steps

  1. Write Angular project that uses the following code, where "filter-selection" is a select element:
    let dropdown = document.getElementById("filter-selection"); selectedFilter = dropdown.options[dropdown.selectedIndex].value;
  2. run ng serve. It will fail to compile.
  3. Comment out the Javascript code, run ng serve. It will compile. Leave ng serve active.
  4. Add the Javascript code back in. Save the file. The cli will update the webapp, and show a compile error but then compile successfully and publish the changes.

The log given by the failure

i 「wdm」: Compiled successfully. ERROR in src/app/my-component/my-component.component.ts(21,35): error TS2339: Property 'options' does not exist on type 'HTMLElement'. src/app/my-component/my-component.component.ts(21,52): error TS2339: Property 'selectedIndex' does not exist on type 'HTMLElement'.

Desired functionality

The cli should notice the failed code and not allow it to compile with the change.

Mention any other details that might be useful

Please view the SO post found here.

@masv87
Copy link

masv87 commented Aug 1, 2018

I have the same issue, but with TS code

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc
    Versions
    Official docker image - node:10-stretch
    node --version v10.7.0 (the same was for 8.11 image)
    npm --version 6.2.0
    ng --version
    Angular CLI: 6.1.1
    Node: 10.7.0
    OS: linux x64
    Angular:
    ...

Package Version

@angular-devkit/architect 0.7.1
@angular-devkit/core 0.7.1
@angular-devkit/schematics 0.7.1
@schematics/angular 0.7.1
@schematics/update 0.7.1
rxjs 6.2.2
typescript 2.7.2

Repro steps

  1. Having angular project with problem: this.historyFilter = {
    nd2s: true
    };
    Where this.historyFilter is an object implementing interface which doesn't have nd2ds property.
  2. run ng serve - compilation fails, error message is

ERROR in src/app/finance/wallet/history/history.service.ts(11,7): error TS2322: Type '{ nd2s: boolean; }' is not assignable to type 'HistoryFilter'.

  1. leave ng serve active.
  2. Change something, like nd2s: true to nd2ds2: true (also doesn't exists)
  3. The cli will update the webapp, and show a compile error but then compile successfully and publish the changes.

@clydin clydin added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity1: confusing labels Aug 2, 2018
@ngbot ngbot bot added this to the Backlog milestone Jan 24, 2019
@dyingangel666
Copy link

Have the same issue now with angular 9. ng build throws an error, but build was successful, and bamboo doesn't recognize the error and shows the build as successful

@kyliau kyliau added triage #1 needs: investigation Requires some digging to determine if action is needed labels May 27, 2020
@alan-agius4
Copy link
Collaborator

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@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 Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely needs: investigation Requires some digging to determine if action is needed severity1: confusing type: bug/fix
Projects
None yet
Development

No branches or pull requests

7 participants