Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Schematics template syntax errors should point to the offending template

Aperta
#13,192 0 commenti 14 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
angular, typescript
Ambito
cli, tooling

Direzione di ricerca

Riproduci l’espressione di template malformata con schematics eseguito con --debug, quindi parti dalle posizioni di template.js mostrate nello stack trace, in particolare @angular-devkit/core/src/utils/template.js e @angular-devkit/schematics/src/rules/template.js. Il lavoro è completato quando gli errori di sintassi identificano il template interessato e, se possibile, la relativa riga, invece di segnalare soltanto una posizione generica del parser.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
16h 35m
PR unite (30g)
176

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di angular/angular-cli

Tutte le issue di angular/angular-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.