Skip to content

Commit cf4aa9d

Browse files
antonisclaude
andcommitted
fix(core): Fix oxlint error with type assertion approach
Use Object() wrapper instead of `as unknown` cast to access isWellFormed/toWellFormed without triggering oxlint's unnecessary-assertion rule or TS strict mode errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fdfa633 commit cf4aa9d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/core/src/logs/internal.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,10 @@ function sanitizeLogAttributes(attributes: Attributes): Attributes {
252252
* On older runtimes without native support, returns the string as-is.
253253
*/
254254
export function _INTERNAL_removeLoneSurrogates(str: string): string {
255-
const s = str as unknown as { isWellFormed?: () => boolean; toWellFormed?: () => string };
256-
if (typeof s.isWellFormed === 'function') {
257-
return s.isWellFormed() ? str : s.toWellFormed ? s.toWellFormed() : str;
255+
// isWellFormed/toWellFormed are ES2024 (not in our TS lib target), so we feature-detect via Object().
256+
const strObj: Record<string, unknown> = Object(str);
257+
if (typeof strObj['isWellFormed'] === 'function') {
258+
return (strObj['isWellFormed'] as () => boolean)() ? str : (strObj['toWellFormed'] as () => string)();
258259
}
259260
return str;
260261
}

0 commit comments

Comments
 (0)