Write a user-defined type guard isString(x): x is string and use it in onlyStrings(values) to return just the strings from a mixed array.
Signatures:
isString(x: unknown): x is stringonlyStrings(values: unknown[]): string[]The guard lets TypeScript narrow unknown to string, so filter(isString) produces a string[]. Export onlyStrings (the tests call it).
A type guard returns x is string and checks typeof x === 'string'.
values.filter(isString) narrows to string[] automatically.
Test natijalarini ko'rish uchun kodingizni ishga tushiring.