Conversation
Replaces `any`/legacy-typed provider consts/`Function`-shaped callbacks across the autocomplete component family in src/ui-kit/form-controls, following the same approach used for the non-autocomplete slice (#732) and the parent issue #586. - autocomplete/autocomplete.component.ts: introduced AutocompleteItem (Record<string, unknown>) for key/value option objects; typed options/categories/enterEvent/httpRequest/cache/keyEvents/ propogateChange/onKeydown/setSelected/writeValue/registerOnChange against string | AutocompleteItem instead of any; NG_VALUE_ACCESSOR provider const typed as Angular's Provider - autocomplete/autocomplete.service.ts: setFetchMethod/fetch return types narrowed from any to void/unknown[] - autocomplete-multiselect/autocomplete-cache.ts: Cached/AutocompleteCache made generic (<T = unknown>) instead of any[]/any-typed members - autocomplete-multiselect/autocomplete-multiselect.component.ts: introduced MultiselectItem and CategorizedList<T> (typed replacement for the associative-array-like `list` structure sortByCategory/ filterOptions build); typed options/categories/serviceOptions/ itemTemplate/writeValue/registerOnChange and the NodeList-based selection helpers - sam-sds-autocomplete/{autocomplete,autocomplete-search,selected-result}: NG_VALUE_ACCESSOR provider consts typed as Provider; writeValue/registerOnChange/registerOnTouched/propogateChange narrowed to unknown/typed callbacks; TemplateRef<any> -> TemplateRef<unknown>; getFlatElements/checkItemSelected typed - sds-selected-item-model-helper.ts: clearItems(model: any) -> clearItems(model: SAMSDSSelectedItemModel) - autocomplete-seach-test-service.spec.ts: introduced HierarchicalDataItem interface for the sample fixture shape, replacing implicit any on loadedData/itemsListOutofObservable - autocomplete-search.component.spec.ts: removed any from local test fixture types (propagated/previous/item locals) - formly/components/autocomplete/test.service.ts: TestAutocompleteService updated to match AutocompleteService's Observable<unknown[]> contract Lowers the root ESLint warning baseline 143 -> 44 (0 errors). All previously-passing specs still pass (1936/1936); test-app build and coverage-floor gate both pass with no regression.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical public API compatibility and test-compilation issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 9
Open (9)
Record index signature breaks typed option interfaces · New CategorizedList requirement breaks plain-object callers · New Record index signature breaks typed autocomplete options · New Autocomplete categories no longer accept string labels · New Observable<unknown[]> breaks AutocompleteService consumers · New unknown callback value breaks typed fixture assignment · New Required callbacks break autocomplete-search test stubs · New Required callbacks break autocomplete wrapper test stubs · New Required callbacks break selected-result test stubs · New
What changed in this PR
This PR replaces unsafe TypeScript types across the autocomplete component family and reduces the ESLint warning baseline.
Changes:
- Adds typed autocomplete items, caches, callbacks, services, and CVA APIs.
- Updates related test fixtures and Formly typings.
- Lowers the ESLint baseline from 143 to 44 warnings.
| File | Summary |
|---|---|
src/ui-kit/form-controls/sam-sds-autocomplete/selected-result/selected-result.component.ts |
Types selected-result CVA APIs. |
src/ui-kit/form-controls/sam-sds-autocomplete/selected-result/models/sds-selected-item-model-helper.ts |
Types selected-item model clearing. |
src/ui-kit/form-controls/sam-sds-autocomplete/autocomplete/autocomplete.component.ts |
Types autocomplete CVA APIs. |
src/ui-kit/form-controls/sam-sds-autocomplete/autocomplete-search/autocomplete-search.component.ts |
Types search callbacks and helpers. |
src/ui-kit/form-controls/sam-sds-autocomplete/autocomplete-search/autocomplete-search.component.spec.ts |
Updates search test fixture types. |
src/ui-kit/form-controls/sam-sds-autocomplete/autocomplete-search/autocomplete-seach-test-service.spec.ts |
Adds typed hierarchical fixtures. |
src/ui-kit/form-controls/autocomplete/autocomplete.service.ts |
Narrows service method types. |
src/ui-kit/form-controls/autocomplete/autocomplete.component.ts |
Types autocomplete inputs and callbacks. |
src/ui-kit/form-controls/autocomplete-multiselect/autocomplete-multiselect.component.ts |
Adds typed multiselect items and helpers. |
src/ui-kit/form-controls/autocomplete-multiselect/autocomplete-cache.ts |
Makes cache implementations generic. |
src/formly/components/autocomplete/test.service.ts |
Aligns the test service contract. |
eslint-baseline.json |
Ratchets down the warning baseline. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- MultiselectItem/AutocompleteItem: use `object` instead of
`Record<string, unknown>` so consumers' named option interfaces
(which lack a string index signature) remain assignable, matching
the old `any[]` API's compatibility.
- CategorizedList.totalItems(): make optional so structural inputs
(e.g. `{ 0: [], categories: [...] }`) built by callers/tests without
the bookkeeping method still type-check.
- SamAutocompleteComponent.categories: keep `Array<string |
AutocompleteItem>` instead of narrowing to `AutocompleteItem[]`, so
plain string category labels are still accepted.
- AutocompleteService: make generic (`AutocompleteService<T =
unknown>`) so `fetch()` returns `Observable<T[]>`; the standalone
autocomplete component parameterizes it with `string |
AutocompleteItem`, and existing untyped consumers keep compiling via
the `unknown` default.
- Updated registerOnChange/registerOnTouched spec stubs in
autocomplete-search, sam-sds-autocomplete, and selected-result specs
to pass no-op functions instead of `{}`, matching the CVA callback
signatures.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Replaces
any, unsafe function types, and legacy untyped callbacks across the autocomplete component family insrc/ui-kit/form-controls, following the approach established in #706 and #732.Scope:
autocomplete/autocomplete.component.ts: introducedAutocompleteItem(Record<string, unknown>), typedoptions/categories/enterEvent/httpRequest/cache/keyEvents/propogateChange/onKeydown/setSelected/writeValue/registerOnChangeagainststring | AutocompleteIteminstead ofany;NG_VALUE_ACCESSORtyped asProviderautocomplete/autocomplete.service.ts:setFetchMethod/fetchreturn types narrowed fromanytovoid/unknown[]autocomplete-multiselect/autocomplete-cache.ts:Cached/AutocompleteCachemade generic (<T = unknown>)autocomplete-multiselect/autocomplete-multiselect.component.ts: introducedMultiselectItemandCategorizedList<T>; typedoptions/categories/serviceOptions/itemTemplate/writeValue/registerOnChangeandNodeListselection helperssam-sds-autocomplete/{autocomplete,autocomplete-search,selected-result}:NG_VALUE_ACCESSORtyped asProvider;writeValue/registerOnChange/registerOnTouched/propogateChangenarrowed tounknown/typed callbacks;TemplateRef<unknown>;getFlatElements/checkItemSelectedtypedsds-selected-item-model-helper.ts: typedclearItems(model: SAMSDSSelectedItemModel)autocomplete-seach-test-service.spec.ts&autocomplete-search.component.spec.ts: removedanyfrom test fixtures, introducedHierarchicalDataItemformly/components/autocomplete/test.service.ts: updated to matchAutocompleteServicecontracteslint-baseline.json: ratcheted down warning baseline from 143 to 44 (0 errors)Motivation and Context
Closes #728
Part of the tech debt burndown for ESLint and TypeScript safety (#580, #586). Resolves unsafe-type lint findings across the autocomplete family while preserving public API and consumer-compiled compatibility.
Type of Change (Select One and Apply Label)
maintenancelabel (appliedtech-debt)How to Test
npx eslint src/ui-kit/form-controls/{autocomplete,autocomplete-multiselect,sam-sds-autocomplete}(0 warnings, 0 errors)npm run lint:baseline(44 warnings, passes gate)npx vitest run --coverage(176 test files, 1,936 passing)npm run coverage:check(passes all metrics)npm --prefix test-app run buildExpected result: All lint checks, unit tests, coverage gates, and test-app AOT compilation pass.
Screenshots (if appropriate)
N/A — TypeScript type narrowing and lint cleanup only.
Checklist
gh-<number>-<slug>)format:checkpasses (npm run format:check)lintpasses (npm run lint)buildpasses (cd test-app && npm run build)cd test-app && npm test)