0

I have this command in my terminal

$ ng build --watch
Date: 2018-01-02T21:42:45.851Z                                                      
Hash: f72a8ce7baf664dc5d5a
Time: 3260ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 303 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 323 bytes [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 57.9 kB [initial] [rendered]

ERROR in src/main.ts(50,42): error TS2339: Property 'value' does not exist on type 'HTMLElement'.

How can I force transpilation even with an error using ng build? I want angular-cli to always output the target files to the dist director no matter what.

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • Possible duplicate of [Ignore Typescript Errors "property does not exist on value of type"](https://stackoverflow.com/questions/18083389/ignore-typescript-errors-property-does-not-exist-on-value-of-type) – nwxdev Jan 02 '18 at 21:56
  • not a dupe of that issue, I need to ignore all errors at the command line so transpilation always happens – Alexander Mills Jan 02 '18 at 22:01
  • Possible duplicate of https://stackoverflow.com/questions/45028233/property-value-does-not-exist-on-type-htmlelement-for-textarea-angular – nwxdev Jan 02 '18 at 22:05
  • Possible duplicate of https://stackoverflow.com/questions/41497187/typescript-complains-about-htmlelement-do-not-have-value-property – nwxdev Jan 02 '18 at 22:05
  • 1
    Relates to (discussion) https://github.com/Microsoft/TypeScript/issues/11051 – nwxdev Jan 02 '18 at 22:09

1 Answers1

1

The recommended method is to use a type assertion:

let inputFields = document.getElementsByClassName("settings") as HTMLInputElement

As described in this TypeScript bug.

Based on the angular-cli configuration options, there is no way to suppress errors during build.

You need to either fix your TypeScript code using a type assertion, cast the variable to type any, or use configuration flags in your tsconfig.json file - such as "compilerOptions":{ "noImplicitAny":false } which you can read more about here.

For a full list of TypeScript complier options, see:

https://www.typescriptlang.org/docs/handbook/compiler-options.html

nwxdev
  • 4,194
  • 3
  • 16
  • 22