tju-yxq opened a new pull request, #5266:
URL: https://github.com/apache/rocketmq-dashboard/pull/5266
### Which Issue(s) This PR Fixes
- Fixes #5264
### Brief Description
`MetricsExplorer.test.tsx`'s `metricData` fixture is an untyped literal, so
`labels` is inferred as the concrete `{ cluster: string; node_id: string }`
shape. `createDeferred<typeof metricData>()` locks `resolve()` to that narrowed
type, and the custom-query fixtures that add a `query` label fail the
excess-property check — although the API contract is `labels: Record<string,
string>`. This is the error that fails `Frontend Build (Node 20)` and `Frontend
Docker Build` at the typecheck step on **every** PR targeting `rocketmq-studio`.
The fix annotates the fixture with `MetricData` (imported as a type from
`../../api/metrics`) so the deferred and every object spread built from the
fixture are checked against the real contract. One file touched, five lines
changed, no runtime behavior change.
### How Did You Test This Change?
On a clean `rocketmq-studio` checkout (before the fix) — the reproduction
from the issue:
```
cd web && npx tsc -b --force
src/components/__tests__/MetricsExplorer.test.tsx(516,38): error TS2353:
Object literal
may only specify known properties, and 'query' does not exist in type '{
cluster: string; node_id: string; }'.
```
With this branch:
```
cd web && npx tsc -b --force
(no output — exit 0, no errors anywhere in the project)
```
```
cd web && npm test -- MetricsExplorer.test.tsx --run
Test Files 1 passed (1)
Tests 35 passed (35)
```
```
cd web && npm run lint
✖ 10 problems (0 errors, 10 warnings) # all pre-existing warnings in files
this PR does not touch
```
```
cd web && npm run build # = tsc -b && vite build && npm run license:check
✓ 8098 modules transformed.
```
`tsc -b` passes and the vite build now runs past transform (on trunk it
never gets there). The subsequent vendored-license integrity checks in `vite
build` fail **only on this Windows machine**: `core.autocrlf` converts the
vendored text files on checkout, and `scripts/licenses.mjs` pins them by exact
sha256. Proof that the repository content is correct: the sha256 of
`web/licenses/toggle-selection-1.0.6/LICENSE` after LF-normalization equals the
pinned hash `5149051a…` exactly, and `node_modules/toggle-selection/index.js`
matches its pinned hash as-is. CI's LF checkout is unaffected by this local
artifact.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test` (the fix itself is validated by the typecheck; all 35 existing tests
in the file keep passing)
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no new UI text — test-only change)
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks) (no Java changes)
- [x] New source files carry the ASF license header (no new source files)
- [ ] Documentation touched where behaviour changed (README / `docs/` /
in-app help) (no behavior change)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]