Skip to content

Commit

Permalink
chore: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Sep 9, 2024
1 parent 957255f commit edf93d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface User {
encapsulation,
changeDetection,
})
export default class Example<T extends User> {
export default class Example<T extends User = User> {
protected readonly items = inject<readonly string[]>('Pythons' as any);

protected readonly users = [
Expand All @@ -37,17 +37,17 @@ export default class Example<T extends User> {
{id: 3, name: 'Graham Chapman'},
{id: 4, name: 'Michael Palin'},
{id: 5, name: 'Terry Gilliam'},
] as T[]; // only template compile check
] as unknown as readonly T[];

protected readonly form = new FormGroup({
user: new FormControl<User | null>(null),
user2: new FormControl<User | null>(null),
user: new FormControl<T | null>(null),
user2: new FormControl<T | null>(null),
});

protected readonly stringify = ({name}: User): string => name;
protected readonly stringify = ({name}: T): string => name;

protected readonly matcherString = (name: string, search: string): boolean =>
name.split(' ').pop()!.toLowerCase().startsWith(search.toLowerCase());
name.split(' ').pop()?.toLowerCase().startsWith(search.toLowerCase()) ?? false;

protected readonly matcherUser: TuiStringMatcher<T> = (user, search): boolean =>
user.name.toLowerCase().startsWith(search.toLowerCase());
Expand Down
8 changes: 0 additions & 8 deletions projects/kit/pipes/filter-by-input/filter-by-input.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ import {TUI_DATA_LIST_HOST} from '@taiga-ui/core/components/data-list';
import {TuiTextfieldComponent} from '@taiga-ui/core/components/textfield';
import {tuiIsFlat} from '@taiga-ui/kit/utils';

type TuiArrayElement<A> =
A extends ReadonlyArray<infer T>
? A extends ReadonlyArray<ReadonlyArray<infer G>>
? G
: T
: never;

// TODO: Consider replacing TuiTextfieldComponent with proper token once we refactor textfields
@Pipe({
standalone: true,
Expand All @@ -26,7 +19,6 @@ export class TuiFilterByInputPipe implements PipeTransform {
private readonly host = inject(TUI_DATA_LIST_HOST);

public transform<T>(items: readonly T[], matcher?: TuiStringMatcher<T>): readonly T[];
public transform<T>(items: T, matcher?: TuiStringMatcher<TuiArrayElement<T>>): T;
public transform<T>(
items: ReadonlyArray<readonly T[]> | readonly T[] | null,
matcher: TuiStringMatcher<T> = TUI_DEFAULT_MATCHER,
Expand Down

0 comments on commit edf93d6

Please sign in to comment.