Skip to content

fix(types): corrige useRef sem argumento após @types/react 19 - #129

Merged
adm01-debug merged 5 commits into
mainfrom
claude/auditoria-tecnica-sistema-xj2rvh
Sep 2, 2026
Merged

fix(types): corrige useRef sem argumento após @types/react 19#129
adm01-debug merged 5 commits into
mainfrom
claude/auditoria-tecnica-sistema-xj2rvh

Conversation

@adm01-debug

@adm01-debug adm01-debug commented Sep 2, 2026

Copy link
Copy Markdown
Owner

📝 Descrição

Segue o PR #128 (já mergeado). @types/react@19 removeu o overload de useRef<T>() sem valor inicial — com strictNullChecks ligado (ligado naquele PR), isso vira TS2554: Expected 1 arguments, but got 0.

14 ocorrências em 11 arquivos, todas useRef<X>()useRef<X | undefined>(undefined) — mesmo valor inicial de hoje (undefined), zero mudança de comportamento em runtime. Verifiquei arquivo por arquivo se algum consumidor comparava o ref contra undefined de um jeito que trocar para null quebraria (achei um caso real, useTimingHooks.ts:56) — por isso mantive undefined como sentinela em vez de padronizar para null (convenção usada em outros arquivos do repo), evitando qualquer risco de mudança de lógica.

Baseline do typecheck ratchet atualizado: 147 → 133 ocorrências.

🎯 Tipo de Mudança

  • 🐛 Bug fix (correção de bug)

🧪 Testes Realizados

  • Testei localmente: node scripts/ci/typecheck-ratchet.mjs (133/133, 0 novas), node scripts/ci/lint-ratchet.mjs (0 novas), bun run build (ok), bun run test (2525/2525 passando, 32 skipped — mesmo baseline de antes)

✅ Checklist

  • Self-review realizado
  • Sem console.log ou debug code
  • Sem secrets/credenciais hardcoded
  • Tipos TypeScript corretos

⚠️ Notas para Reviewer

Diff mecânico e de baixo risco — só assinatura de tipo, sem mudança de lógica. O único ponto que exigiu atenção (useTimingHooks.ts) está documentado acima.


🤖 Generated with Claude Code

https://claude.ai/code/session_01UDFCBv9FvzHkwHCN6YcKVa


Summary by cubic

Fixes 14 useRef<T>() calls across 11 files for @types/react@19, which removed the no-argument overload and caused TS2554; each now initializes with undefined, preserving runtime behavior. Updates vitest and postcss, forcing nested dependencies to use the fixed PostCSS version and eliminating the critical audit finding.

  • Lowers the typecheck baseline from 147 to 133 remaining errors.
  • Build, lint, and typecheck ratchets pass; 2,525 unit tests and 167 contract tests pass.
  • Reduces bun audit findings from 47 to 38 with no critical findings; the remaining findings affect xlsx or transitive build tooling and require separate supply-chain, override, or breaking-upgrade decisions.

Written for commit 1dac997. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Correções

    • Corrigida a verificação de tipos em temporizadores, debounce, animações, monitoramento e pré-carregamento.
    • Mantido o comportamento existente de agendamento, cancelamento e otimização de chamadas.
  • Qualidade

    • Resolvidos erros de typecheck relacionados à inicialização de referências sem argumentos.

@types/react@19 removeu o overload de useRef<T>() sem valor inicial;
com strictNullChecks ligado isso vira "Expected 1 arguments, but got 0"
(TS2554). 14 ocorrencias em 11 arquivos, todas useRef<X>() -> useRef<X
| undefined>(undefined) - mesmo valor inicial de hoje (undefined),
zero mudanca de comportamento em runtime.

Baseline do typecheck ratchet atualizado: 147 -> 133 ocorrencias.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UDFCBv9FvzHkwHCN6YcKVa

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm01-debug has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
zapp_web_v2 Ready Ready Preview Sep 2, 2026 10:28am UTC

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 97 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: e5d2e69b-beef-4ed7-973e-691750d2aa84

📥 Commits

Reviewing files that changed from the base of the PR and between fdfcfab and 1dac997.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • package.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 6719dd91-a2cf-4408-830a-dd0600d22ccb

📥 Commits

Reviewing files that changed from the base of the PR and between db55e43 and fdfcfab.

📒 Files selected for processing (12)
  • scripts/ci/typecheck-baseline.json
  • src/components/contacts/ContactForm.tsx
  • src/components/contacts/useContactFormValidation.ts
  • src/components/mobile/MobileSlidePanel.tsx
  • src/hooks/analytics/usePerformanceOptimizations.ts
  • src/hooks/communication/useVoiceAgent.ts
  • src/hooks/crm/useContactsSearch.ts
  • src/hooks/integrations/useKnowledgeBaseSearch.ts
  • src/hooks/performance/useDataOptimization.ts
  • src/hooks/performance/useMonitoring.ts
  • src/hooks/performance/useTimingHooks.ts
  • src/hooks/system/useResourcePrefetch.ts
💤 Files with no reviewable changes (1)
  • scripts/ci/typecheck-baseline.json

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

As referências de temporizadores, animação e monitoramento passam a declarar explicitamente undefined. O baseline de typecheck remove os erros TS2554 correspondentes.

Changes

Tipagem explícita de referências

Layer / File(s) Summary
Inicialização explícita das referências
src/components/contacts/*, src/components/mobile/MobileSlidePanel.tsx, src/hooks/analytics/*, src/hooks/communication/*, src/hooks/crm/*, src/hooks/integrations/*, src/hooks/performance/*, src/hooks/system/*, scripts/ci/typecheck-baseline.json
As referências de temporizadores, requestAnimationFrame e startTime passam a usar tipos que incluem undefined e inicialização explícita. A lógica de agendamento, limpeza, debounce, animação e monitoramento permanece inalterada. O baseline remove os erros TS2554 relacionados.

Estimated code review effort: 2 (Simple) | ~10 minutos

Merge Risk: ⚪ Minimal · up to fdfcf

This PR makes a localized TypeScript compatibility fix while preserving the existing undefined sentinel and runtime behavior. No actionable merge-blocking risk remains after normal checks and review.

Poem

Eu, coelho, vejo refs com início definido
Timers aguardam seu estado permitido
O typecheck encontra o caminho limpo
Debounce e animação seguem o mesmo ritmo
Pulo contente sobre o código corrigido

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed O título descreve de forma clara e específica a correção principal: atualizar chamadas de useRef sem argumento após a mudança em @types/react@19.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@adm01-debug
adm01-debug marked this pull request as ready for review September 2, 2026 10:07
Copilot AI lite review requested due to automatic review settings September 2, 2026 10:07
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm01-debug has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm01-debug has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 12 files

Re-trigger cubic

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

As mudanças são mecânicas e consistentes, mantendo o sentinela undefined e apenas eliminando TS2554 sem introduzir alteração de lógica observável.

Pull request overview

Este PR ajusta chamadas useRef<T>() sem argumento inicial para serem compatíveis com @types/react@19, que removeu o overload sem valor inicial quando strictNullChecks está ativo, eliminando erros TS2554 sem alterar o comportamento em runtime.

Changes:

  • Atualiza 11 refs de useRef<T>() para useRef<T | undefined>(undefined) mantendo undefined como sentinela.
  • Remove entradas agora resolvidas (TS2554) do scripts/ci/typecheck-baseline.json, reduzindo o baseline (147 → 133).
  • Mantém lógica existente de cancelamento/cleanup (timers/RAF) e checks explícitos contra undefined onde aplicável.
File summaries
File Description
src/hooks/system/useResourcePrefetch.ts Ajusta timeoutRef para `useRef<...
src/hooks/performance/useTimingHooks.ts Ajusta refs de RAF/tempo para `...
src/hooks/performance/useMonitoring.ts Ajusta startTime ref para aceitar undefined e inicializa explicitamente.
src/hooks/performance/useDataOptimization.ts Ajusta timeoutRef para `...
src/hooks/integrations/useKnowledgeBaseSearch.ts Ajusta debounceRef para `...
src/hooks/crm/useContactsSearch.ts Ajusta debounceRef para `...
src/hooks/communication/useVoiceAgent.ts Ajusta refs de timers (setTimeout) para `...
src/hooks/analytics/usePerformanceOptimizations.ts Ajusta lastCallTimer para `...
src/components/mobile/MobileSlidePanel.tsx Ajusta timerRef do long-press para `...
src/components/contacts/useContactFormValidation.ts Ajusta dupCheckTimer para `...
src/components/contacts/ContactForm.tsx Ajusta empresaBlurTimer para `...
scripts/ci/typecheck-baseline.json Remove ocorrências TS2554 agora resolvidas do baseline do typecheck ratchet.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

bun audit reportava 47 vulnerabilidades (1 critica, 46 altas). Corrigidas
as 2 que tinham fix direto disponivel via npm registry:

- vitest 4.0.18 -> 4.1.11: critica (GHSA-5xrq-8626-4rwp, leitura
  arbitraria de arquivo quando o UI server do Vitest esta escutando)
- postcss 8.5.6 -> 8.5.26: 2 altas (GHSA-6g55-p6wh-862q,
  GHSA-r28c-9q8g-f849, disclosure via sourceMappingURL malicioso)

Resultado real (bun audit rodado apos o fix): 47 -> 43 vulnerabilidades,
0 criticas. Validado: build ok, 2525/2525 testes unitarios + 167
contract tests passando, lint ratchet e typecheck ratchet sem novas
ocorrencias.

Nao corrigidas nesta rodada (documentado, nao ignorado):
- xlsx <0.19.3: SheetJS nunca publicou a versao corrigida no registry
  npm (fica em 0.18.5 la), o patch so existe via CDN proprio deles
  (cdn.sheetjs.com) - trocar a fonte do pacote e uma decisao de
  supply-chain que exige aprovacao explicita, nao um bump de rotina.
- picomatch, ws, fast-uri, browserslist,
  @babel/plugin-transform-modules-systemjs: todas transitivas de
  tooling de build/dev (vite, vitest, eslint, tailwindcss,
  vite-plugin-pwa), nao chegam ao bundle de producao. picomatch tem
  2 faixas vulneraveis em majors diferentes (2.x e 4.x) puxadas por
  cadeias de dependencia distintas - forcar uma versao via override
  quebraria uma das duas sem validacao individual de cada consumidor.
  @babel/plugin-transform-modules-systemjs so tem fix na v8 (breaking,
  o resto do babel aqui e 7.x). Risco pratico baixo (ReDoS em matching
  de glob durante build local/CI, nao alcancavel por usuario final).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UDFCBv9FvzHkwHCN6YcKVa

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm01-debug has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread package.json
…cubic)

O bump direto de postcss (commit anterior) nao alcancava a copia
aninhada lovable-tagger > tailwindcss > postcss@8.5.6, ainda na faixa
vulneravel (<=8.5.11) - achado real do bot cubic no PR, verificado no
bun.lock antes de aplicar o fix. lovable-tagger continua em uso
(vite.config.ts), entao a correcao e "overrides" no package.json
forcando todo o grafo de dependencias a resolver postcss em ^8.5.26,
em vez de remover/trocar a lib.

bun audit: 43 -> 38 vulnerabilidades, zero linha de postcss restante.
Validado: build ok, 2525/2525 testes unitarios (32 skipped, mesmo
baseline), lint ratchet e typecheck ratchet sem novas ocorrencias.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UDFCBv9FvzHkwHCN6YcKVa

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm01-debug has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm01-debug has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@adm01-debug
adm01-debug merged commit 242110d into main Sep 2, 2026
13 checks passed
@adm01-debug
adm01-debug deleted the claude/auditoria-tecnica-sistema-xj2rvh branch September 2, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants