Architect#scheduleBuilder or context.scheduleBuilder results in incorrect target on context
- 主要言語
- TypeScript
- スター
- 27k
- フォーク
- 11.8k
- 平均マージ
- 14時間 23分
- マージ済み PR(30日)
- 162
説明
# 🐞 Bug report
### Command (mark with an `x`)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
### Is this a regression?
Not that I know of
### Description
If a builder is executed via `architect.scheduleBuilder`, that builder is passed a context that doesn't match the declared interface in typescript. The same happens when using `context.scheduleBuilder` if no target is passed via the `scheduleOptions`.
```js
console.log(context.target);
// logs {project: undefined, target: undefined, configuration: undefined}
// but type is {project: string, target: string, configuration?: string} | undefined
```
## 🔬 Minimal Reproduction
Run `yarn bazel test //packages/angular_devkit/architect:architect_test` with the following patch:
```patch
diff --git a/packages/angular_devkit/architect/src/index_spec.ts b/packages/angular_devkit/architect/src/index_spec.ts
index 57d76c5a6..bbd59b3fc 100644
--- a/packages/angular_devkit/architect/src/index_spec.ts
+++ b/packages/angular_devkit/architect/src/index_spec.ts
@@ -36,10 +36,12 @@ describe('architect', () => {
options = {};
called = 0;
- testArchitectHost.addBuilder('package:test', createBuilder(async o => {
+ testArchitectHost.addBuilder('package:test', createBuilder(async (o, ctx) => {
called++;
options = o;
+ expect(ctx.target != null && ctx.target.target == null).toBe(false);
+
return new Promise(resolve => {
setTimeout(() => resolve({ success: true }), 10);
});
```
## 🔥 Exception or Error
Failures:
1) architect runs builders parallel
Message:
Expected true to be false.
Stack:
Error: Expected true to be false.
at
at packages/angular_devkit/architect/src/index_spec.ts:43:63
at onInput (packages/angular_devkit/architect/src/create-builder.ts:201:20)
at SafeSubscriber._next (packages/angular_devkit/architect/src/create-builder.ts:87:17)
## 🌍 Your Environment
Master branch on this repo
**Anything else relevant?**
コントリビューションガイド
調査の方向性
packages/angular_devkit/architect/src/index_spec.ts から始め、yarn bazel test //packages/angular_devkit/architect:architect_test を使って失敗を再現します。スタックが示している packages/angular_devkit/architect/src/create-builder.ts を通じて builder のコンテキストを追跡し、scheduleBuilder が宣言された TypeScript インターフェースに一致する target を提供していることを確認します。architect の対象を絞ったテストが有効な target で成功すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- build-system
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 38/100