tsc-correctness != runtime-correctness
The article discusses a common TypeScript error related to importing SVGs as React components. It highlights the gap between TypeScript's type-checking and the actual runtime behavior of the code. The author introduces a solution using tsfix to address this issue by providing context about library migrations.
- ▪TypeScript errors can occur when importing SVGs due to changes in library behavior.
- ▪The TypeScript compiler suggests fixes that may not align with the runtime requirements of the code.
- ▪The tsfix tool improves code repair by injecting context about library migrations into the prompt.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3119068) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Oscar Green Posted on May 24 tsc-correctness != runtime-correctness #ai #opensource #typescript #webdev Here is a TypeScript error you have probably seen. src/Header.tsx:3:10 - error TS2614: Module '"./logo.svg"' has no exported member 'ReactComponent'. Did you mean to use 'import Logo from "./logo.svg"' instead? Enter fullscreen mode Exit fullscreen mode tsc helpfully tells you the fix. Your editor offers it as a one-click Quick Fix. An LLM doing code repair will reliably take it.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).