angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Dump compiled factories

Open achimha opened this issue 9 years ago • 14 comments

Bug Report or Feature Request (mark with an x)

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

Versions.

angular-cli 1.0.0 angular 2.4.10

Repro steps.

With the latest bugfix that uncovered AOT errors, I noticed how hard it is to pinpoint those errors. The reason is that all we get is an error during compilation like this:

ERROR in /src/$$_gendir/app/lazy/support/support.component.ngfactory.ts (2126,52): Supplied parameters do not match any signature of call target.

The offending file is transient and cannot be inspected. Due to the recently fixed bug, the code error has been there for a long time and it is now very difficult to spot the offending code in a module that has been working for months.

Desired functionality.

There should be a way to inspect (= keep) the transient file to get a better idea what the AOT compiler complains about.

achimha avatar Mar 24 '17 10:03 achimha

I think the bugfix mentioned is https://github.com/angular/angular-cli/pull/5601.

@hansl is there maybe a way we can have better info on these errors?

filipesilva avatar Mar 24 '17 15:03 filipesilva

how can I temporarry fix this

"Supplied parameters do not match any signature of call target."

get more inputs from console ? cause donno how fix that

ERROR in C:/.../$$_gendir/app/shared/dependances-entites/dependances-region.component.ngfactory.ts (1,1): Property 'length' does not exist on type 'BuildingDistrictDependencyDTO'.
ng:///C:/.../shared/dependances-entites/dependances-region.component.html (2,1): Property 'length' does not exist on type 'BuildingDistrictDependencyDTO'.

ERROR in ng:///C:/.../comptabilite/plan-comptable/modeles-plan-comptable.component.html (8,27): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../immeuble/popup-suppression-immeuble/popup-suppression-immeuble.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/normes-mesures/popup-suppression-norme-mesure.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/regions-quartiers/popup-suppression-region.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/regions-quartiers/popup-suppression-quartier.component.html (44,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/frais-accessoires/popup-suppression-frais-accessoire.component.html (45,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/commodites/popup-suppression-commodites.component.html (43,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../personne/adresse/popup-suppression-adresse.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../personne/personne-compte-bancaire/popup-suppression-compte-bancaire.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../objet/popup-suppression-objet.component.html (38,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../autorisations/utilisateurs/utilisateurs.component.html (7,27): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../autorisations/utilisateurs/form-utilisateur-groupes.component.html (27,25): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../comptabilite/parametres-comptables/form-parametres-comptables.component.html (134,19): Operator '>' cannot be applied to types 'any[]' and 'number'.

ERROR in ng:///C:/.../comptabilite/repartition-charges/repartitions-charges.component.html (8,27): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../immeuble/immeubles.component.html (22,29): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../objet/popup-suppression-objet.component.html (38,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../immeuble/popup-suppression-immeuble/popup-suppression-immeuble.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../personne/adresse/popup-suppression-adresse.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../personne/personne-compte-bancaire/popup-suppression-compte-bancaire.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/normes-mesures/popup-suppression-norme-mesure.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/regions-quartiers/popup-suppression-region.component.html (39,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/regions-quartiers/popup-suppression-quartier.component.html (44,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/frais-accessoires/popup-suppression-frais-accessoire.component.html (45,15): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../donnees-statiques/donnees-statiques-immeuble/commodites/popup-suppression-commodites.component.html (43,15): Supplied parameters do not match any signature of call target.

ERROR in C:/.../$$_gendir/app/shared/dependances-entites/dependances-region.component.ngfactory.ts (1,1): Property 'length' does not exist on type 'BuildingDistrictDependencyDTO'.
ng:///C:/.../shared/dependances-entites/dependances-region.component.html (2,1): Property 'length' does not exist on type 'BuildingDistrictDependencyDTO'.

ERROR in ng:///C:/.../immeuble/immeubles.component.html (22,29): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../comptabilite/plan-comptable/modeles-plan-comptable.component.html (8,27): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../comptabilite/repartition-charges/repartitions-charges.component.html (8,27): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../autorisations/utilisateurs/utilisateurs.component.html (7,27): Supplied parameters do not match any signature of call target.

ERROR in ng:///C:/.../comptabilite/parametres-comptables/form-parametres-comptables.component.html (134,19): Operator '>' cannot be applied to types 'any[]' and 'number'.

ERROR in ng:///C:/.../autorisations/utilisateurs/form-utilisateur-groupes.component.html (27,25): Supplied parameters do not match any signature of call target.

elvisbegovic avatar Mar 27 '17 09:03 elvisbegovic

as work around, I am adding

fs.writeFile(`build-error-${line}-${path.basename(fileName)}`,
  `${fileName} (${line + 1},${character + 1}): ${message}
                ${sourceText}`, (err) => {console.log(err)});

in `node_modules/@ngtools/webpack/src/plugins.js

here:

        if (diagnostics.length > 0) {
            const message = diagnostics
                .map(diagnostic => {
                const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
                const sourceText = diagnostic.file.getFullText();
                let { line, character, fileName } = this._translateSourceMap(sourceText, diagnostic.file.fileName, position);
                const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
fs.writeFile(`build-error-${line}-${path.basename(fileName)}`,`${fileName} (${line + 1},${character + 1}): ${message}
                ${sourceText}`, (err) => {console.log(err)});
                return `${fileName} (${line + 1},${character + 1}): ${message}`;
            })
                .join('\n');
            this._compilation.errors.push(message);
        }

valorkin avatar Mar 27 '17 12:03 valorkin

Could a flag be added for that (i.e. ng build --keep-gendir)?

FabienDehopre avatar Mar 28 '17 07:03 FabienDehopre

@valorkin Thanks for showing us that! I ended up modifying your code so that the file name generated has the same line number and character position as the error. I also didn't add the additional error message to the top of the file as that throws off the line number count and instead just put the error message on the same line.

Here's that code incase someone finds it useful.

if (diagnostics.length > 0) {
    const message = diagnostics
        .map(diagnostic => {
        const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
        let sourceText = diagnostic.file.getFullText();
        let { line, character, fileName } = this._translateSourceMap(sourceText, diagnostic.file.fileName, position);
        const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
        let lines = sourceText.split("\n");
        lines[line] = lines[line] + `\/\/ERROR: ${message}`;
        sourceText = lines.join("\n");
         fs.writeFile(`build-error-${line + 1}-${character + 1}-${path.basename(fileName)}`,
            `${sourceText}`, (err) => {console.log(err)});
        return `${fileName} (${line + 1},${character + 1}): ${message}`;
    })
        .join('\n');
    this._compilation.errors.push(message);
}

And the comment it makes to the file

  this.context.ngOnChanges(this._changes);//ERROR: Supplied parameters do not match any signature of call target.

JacobBrandt avatar Mar 30 '17 21:03 JacobBrandt

+1 for the --keep-gendir flag I'm currently trying to add AoT to a very complex project, and some very weird issues are showing up. Having the ngfactories would be awesome.

diestrin avatar Apr 10 '17 21:04 diestrin

Thanks @valorkin and @JacobBrandt for the @ngtools/webpack patch. Incidentally, it will dump out log files if you run ng test too - I caught some TS errors that weren't always showing up in the CLI output that way.

eppsilon avatar Apr 18 '17 00:04 eppsilon

Is this issue fixed and released? I am using the following, and still getting the same error: "@angular/cli": "1.1.2", "@angular/compiler-cli": "^4.0.0",

As reported by @achimha while raising the issue, it is now very difficult to spot the offending code in a module that has been working for months. Kindly guide how I can figure out the root-cause of the error in my code.

jpradeep2003 avatar Jun 25 '17 07:06 jpradeep2003

I have found that with angular 4.2.x, error reporting is much improved and most of the time, the offending line in the template is pointed out. While it was mostly guess work before, I haven't felt the need to inspect a compiled factory in quite some time.

achimha avatar Jun 25 '17 07:06 achimha

I did not find 4.2x to give clearer messages. The error was cause for me by the output event on the component html (myEvent)="myEvent($event)" called a method in the component typescript: myEvent(). Changing it to be: (myEvent)="myEvent()" solved this issue.

samrantmedia avatar Jun 30 '17 15:06 samrantmedia

Okay so how again are we suppose to figure out where the problem is if we have a:

ERROR in C:/.../src/$$_gendir/app/app.module.ngfactory.ts (159,52): Supplied parameters do not match any signature of call target.

??? I don't see the file mentioned by @JacobBrandt in any file named plugin.js . I am using the CLI and running ng build --prod and ng serve --aot and both of them through this ambiguous error.

wakawaka54 avatar Sep 22 '17 04:09 wakawaka54

@wakawaka54 You're looking for this file. node_modules/@ngtools/webpack/src/plugin.js

JacobBrandt avatar Sep 22 '17 05:09 JacobBrandt

Closing as this is obsolete. Since factory files are no longer generated with Ivy.

alan-agius4 avatar May 26 '20 08:05 alan-agius4

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.