Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Schematics template syntax errors should point to the offending template

Ouverte
#13,192 0 commentaires 14 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
angular, typescript
Domaine
cli, tooling

Piste de recherche

Reproduisez l’expression de template malformée avec schematics exécuté avec --debug, puis partez des emplacements de template.js indiqués dans la stack trace, en particulier @angular-devkit/core/src/utils/template.js et @angular-devkit/schematics/src/rules/template.js. Le travail est considéré comme terminé lorsque les erreurs de syntaxe identifient le template concerné et, si possible, sa ligne, au lieu de signaler uniquement un emplacement générique du parser.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area: @angular-devkit/schematics freq1: low severity3: broken type: bug/fix
Bug Report or Feature Request (mark with an x)
- [ ] bug report -> please search issues before submitting
- [x] feature request
Repro steps
  • Have a syntax error in your template.
  • Run the schematic with --debug, and get a stack trace that points to schematics code, but that doesn't point to any of your own code.
The log given by the failure

This is easier to handle when you when the syntax error is something simple like misspelling a variable name, e.g. you pass in template variable foobar and have a template with <%= foobat %>:

An error occured:
ReferenceError: foobat is not defined
    at eval (eval at template (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/node_modules/@angular-devkit/core/src/utils/template.js:257:16), <anonymous>:22:18)
    at /usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/template.js:35:79
    at tree.visit (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/base.js:130:30)
    at files.forEach.path (/usr/local/google/home/nsidhom/.nvm/versions/node/v10.1.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/tree/virtual.js:131:40)
    at Array.forEach (<anonymous>)
    at FileSystemCreateTree.visit (/usr/local/google/home/nsidhom/.nvm/versions/node/v10.1.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/tree/virtual.js:131:24)
    at /usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/base.js:126:14
    at MergeMapSubscriber.input.pipe.operators_1.mergeMap.inputTree [as project] (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/call.js:77:24)
    at MergeMapSubscriber._tryNext (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/operators/mergeMap.js:65:27)
    at MergeMapSubscriber._next (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/operators/mergeMap.js:55:18)

But if you have a syntax error such as putting an unintended second symbol within the brackets like <%= foobar unintended %>, then you just get SyntaxError: Unexpected identifier, which could be anywhere and is hard to hunt down:

An error occured:
SyntaxError: Unexpected identifier
    at Function (<anonymous>)
    at Object.template (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/node_modules/@angular-devkit/core/src/utils/template.js:257:16)
    at /usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/template.js:35:40
    at tree.visit (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/base.js:130:30)
    at files.forEach.path (/usr/local/google/home/nsidhom/.nvm/versions/node/v10.1.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/tree/virtual.js:131:40)
    at Array.forEach (<anonymous>)
    at FileSystemCreateTree.visit (/usr/local/google/home/nsidhom/.nvm/versions/node/v10.1.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/tree/virtual.js:131:24)
    at /usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/base.js:126:14
    at MergeMapSubscriber.input.pipe.operators_1.mergeMap.inputTree [as project] (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/src/rules/call.js:77:24)
    at MergeMapSubscriber._tryNext (/usr/local/google/home/nsidhom/schematics/pantheon/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/operators/mergeMap.js:65:27)
Desired functionality

I would like for the error to point me to the offending template, and if possible, the offending line of the template. As is, these errors are incredibly hard to debug.

Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
17 h 25 min
PR mergées (30 j)
183

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de angular/angular-cli

Toutes les issues de angular/angular-cli

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.