Object is possibly ‘undefined’

The ESLint static code analysis tool flags code where we operate on objects which can be undefined. Object is possibly ‘undefined’ The end of the red line shows the extent of the object which can be undefined, as the “children” element is defined as optional in the type definition: To satisfy the linter, we need to …

Type error: Type ‘string’ is not assignable to type ‘number’

When you create an array in TypeScript the type of the first element defines the type of all elements of the array. When we reuse an array with new data, the array type has already been defined, so when we assign new values to the same array we get the error message: Type error: Type …

Error: Component definition is missing display name react/display-name

If you use the VirtualTable in a React TypeScript web application ESLint will throw an error when it checks the VirtuosoTableComponents. Error: Component definition is missing display name react/display-name The Virtuoso component uses arrow functions to declare the Scroller and TableBody. Arrow functions do not provide the displayName property used by developer tools. We can modify the component to …

The top-level-await experiment is not enabled

When we try to call an async function with await from a .tsx file in a Next.js React TypeScript web application we get the error message: Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it) Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it) The …

Module not found: Can’t resolve ‘fs’

If you use Webpack version 5 or later you may encounter the error message Module not found: Can’t resolve ‘fs’ The cause is, that Webpack 5 has a breaking change, and the “fs” module is most likely not included anymore in the client-side code. To eliminate the issue, add the “browser” element to the package.js …