To activate the Quick Fix
feature for all files when encountering the error message
'Cannot find name 'myUtil'.ts(2304)'
, there is a need to tweak TypeScript settings. While TypeScript excels at recognizing files that have export default MyComponent
with names like MyComponent.tsx
, it falls short when it comes to files containing only export const myFunction = () => {}
inside filenames such as utils/my-util.ts
. In such cases, the code snippet
myUtil.myFunction()
triggers an error without offering the Quick Fix
option:
'Cannot find name 'myUtil'.ts(2304)'
Typically, Quick Fix
would add:
import MyComponent from 'components/MyComponent'
However, this behavior doesn't seem to apply when trying to import using:
import * as myUtil from 'utils/my-util'
How can VSCode be configured to enable the Quick Fix functionality for files lacking default exports and not following the same naming conventions for both export and import? Would changing filenames to match imported names - e.g., utils/myUtil
- or exporting a default object containing all exports instead of individual ones make any difference?