@angular/core and @angular/compiler explicitly listed as dependencies in published package.json
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- angular, typescript
- 領域
- build-system, tooling
調査の方向性
公開された package.json と angular/templates/basicTemplateAstVisitor.d.ts を調査し、提示された imports と依存関係のバージョンで TypeScript エラーを再現します。@angular/core と @angular/compiler がどのように宣言およびインストールされているかを確認し、完成したパッケージで Angular の重複した型が解決されなくなり、再現コードがコンパイルされることを検証します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 2.5k
- フォーク
- 232
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mgechev/codelyzer のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 32/100
-
Angular 14オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
-
Support for Angular 10対応中かも @ccarmesin が 1842 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
mgechev/codelyzer の issue をすべて見る
似ている issue
-
agent-ready area: ui-server priority: p3 type: test
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
schlessera/brain-kit#4249 ·
メンテナーはふだん 1 日以内に返信
-
documentation tool triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
can1357/oh-my-pi#19608 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
dependencies tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
bcgov/nr-waste-plus#1549 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
blixvip/solana-token-meta#17 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
blixvip/solana-tx-parse#18 ·