@angular/core and @angular/compiler explicitly listed as dependencies in published package.json
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 42/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- angular, typescript
- Bereich
- build-system, tooling
Rechercherichtung
Untersuche die veröffentlichte package.json und angular/templates/basicTemplateAstVisitor.d.ts und reproduziere den TypeScript-Fehler mit den bereitgestellten Imports und Abhängigkeitsversionen. Prüfe, wie @angular/core und @angular/compiler deklariert und installiert sind, und verifiziere, dass das fertige Paket keine doppelten Angular-Typen mehr auflöst und die Reproduktion kompiliert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
I'm seeing a Typescript issue because of @angular/core being explicitly listed as a dependency of codelyzer.
Context and configuration
codelyzer lists @angular/core: 9.0.0 as an explicit dependency in its package.json, while my own app is running @angular/core: 9.2.13. I have a custom rule that extends BasicTemplateAstVisitor.
The following code snippet is a minimal reproduction of the scenario I'm facing:
import { ElementAst } from '@angular/compiler';
import { BasicTemplateAstVisitor } from 'codelyzer';
export class TemplateVisitorController extends BasicTemplateAstVisitor {
visitElement(elementAst: ElementAst, context: BasicTemplateAstVisitor): void {
this.validateElement(elementAst);
super.visitElement(elementAst, context);
}
}
This throws a Typescript error with the latest version of codelyzer:
libs/design-system-tslint/src/rules/util/designSystemComponentHelper.ts(51,5): error TS2416: Property 'visitElement' in type 'TemplateVisitorController' is not assignable to the same property in base type 'BasicTemplateAstVisitor'.
Type '(elementAst: ElementAst, context: BasicTemplateAstVisitor) => any' is not assignable to type '(element: ElementAst, context: any) => any'.
Types of parameters 'elementAst' and 'element' are incompatible.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").ElementAst' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").ElementAst'.
Types of property 'attrs' are incompatible.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst[]' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst[]'.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst'.
Types of property 'visit' are incompatible.
Type '(visitor: import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor, context: any) => any' is not assignable to type '(visitor: import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor, context: any) => any'.
Types of parameters 'visitor' and 'visitor' are incompatible.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor'.
Types of property 'visitEmbeddedTemplate' are incompatible.
Type '(ast: import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst, context: any) => any' is not assignable to type '(ast: import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst, context: any) => any'.
Types of parameters 'ast' and 'ast' are incompatible.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst'.
Types of property 'outputs' are incompatible.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").BoundEventAst[]' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").BoundEventAst[]'.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").BoundEventAst' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").BoundEventAst'.
Types of property 'handler' are incompatible.
Type 'AST' is missing the following properties from type 'ASTWithSource': ast, source, location, errors
libs/design-system-tslint/src/rules/util/designSystemComponentHelper.ts(53,28): error TS2345: Argument of type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").ElementAst' is not assignable to parameter of type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").ElementAst'.
Types of property 'attrs' are incompatible.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst[]' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst[]'.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").AttrAst'.
Types of property 'visit' are incompatible.
Type '(visitor: import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor, context: any) => any' is not assignable to type '(visitor: import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor, context: any) => any'.
Types of parameters 'visitor' and 'visitor' are incompatible.
Type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor' is not assignable to type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").TemplateAstVisitor'.
Types of property 'visitEmbeddedTemplate' are incompatible.
Type '(ast: import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst, context: any) => any' is not assignable to type '(ast: import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst, context: any) => any'.
Types of parameters 'ast' and 'ast' are incompatible.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").EmbeddedTemplateAst'.
Types of property 'directives' are incompatible.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").DirectiveAst[]' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").DirectiveAst[]'.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").DirectiveAst' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").DirectiveAst'.
Types of property 'hostProperties' are incompatible.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").BoundElementPropertyAst[]' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").BoundElementPropertyAst[]'.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").BoundElementPropertyAst' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").BoundElementPropertyAst'.
Types of property 'type' are incompatible.
Type 'import("/usr/src/app/node_modules/@angular/compiler/src/template_parser/template_ast").PropertyBindingType' is not assignable to type 'import("/usr/src/app/node_modules/codelyzer/node_modules/@angular/compiler/src/template_parser/template_ast").PropertyBindingType'.
This error stems from the fact that ElementAst in visitElement (node_modules\codelyzer\angular\templates\basicTemplateAstVisitor.d.ts) refers to node_modules\codelyzer\node_modules\@angular\compiler\src\template_parser\template_ast.d.ts as opposed to node_modules\@angular\compiler\compiler.d.ts.
Removing both @angular/core as well as @angular/compiler from the codelyzer package.json and running an npm i in node_modules/codelyzer addresses the issue locally, because it then starts using the right @angular/compiler.
So this makes me wonder: why are @angular/core and @angular/common explicitly listed as dependencies in the published package? AFAIK having dependencies in a package is bad idea, and peerDependencies are the way to go. Am I missing something here?
Expected behavior
No Typescript error should be thrown, since codelyzer should be using @angular/core from your main node_modules.
Proposed fix
Remove @angular/core and @angular/compiler from the published package.json.
Environment
Irrelevant AFAIK, can add if needed.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.5k
- Forks
- 232
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus mgechev/codelyzer
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 32/100
-
Angular 14Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
-
Support for Angular 10Evtl. vergeben @ccarmesin hat das vor 1842 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
Alle Issues in mgechev/codelyzer
Ähnliche Issues
-
clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster maturity:stable P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
openclaw/openclaw#200937 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
accepted bug needs-info triaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
zts212653/clowder-ai#2025 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
letehaha/moneymatter#906 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
blinkospace/blinko#1287 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Feyisara2108/stellargive#1379 ·
Maintainer antworten meist innerhalb von 1 Tag