Angle 2: common errors and solutions of NGC

Time:2020-11-13

If your angular 2 code can run normally in the debugging environment, but it can’t passngcCompile (or some other task that needs to be compiled, such as ionic 2’sionic build androidCommand, etc.) and you’ll find some very crazy reasons for the error.

TypeError: cannot read property 'kind' of undefined

This is an example of a wrong ontology having nothing to do with the description, as the original answer to the link below says,

But unlike other incompatibilities, this one generates the most cryptic error message ever.

The real reason for this error is that the AOT settings of angular are not compatible, so you can’t use default exports. You need to use named output. that is

// somefile.ts
export default function (...) {
    ...
}
...
// some-other-file.ts
import whatevar from './somefile';

Need to be changed to

// somefile.ts
export function whatevar(...) {
    ...
}
...
// some-other-file.ts
import { whatevar } from './somefile';

See questionhttp://stackoverflow.com/ques…The highest number of answers and comments.

Duplicate identifier 'Promise'

See previous questionshttps://segmentfault.com/q/10…。 It turns out that instead of using @ types / ES6 promise (types install, which I tried, it doesn’t seem to work, but I’m not sure), instead use the promise definition built into typescript.

In addition, when HTML calls a method, the number and type of parameters must be consistent with the method signature of the typescript file.

Recommended Today

Publish subscribe mode

Publish subscribe mode class EventEmitter { constructor() { this.cache = {} } //Registration events $on(eventType, fn) { //Add event this.cache[eventType] = this.cache[eventType] || []; this.cache[eventType].push(fn); } //Logout event $off(eventType) { if(this.cache[eventType]) { delete this.cache[name]; } } //Trigger event $emit(eventType) { if(this.cache[eventType]) { this.cache[eventType].forEach(handle=>{ handle(); }) } } } //Testing let eventEmitter = new EventEmitter(); function […]