In my case, It seems I have made a mistake by changing the files svelte.config.js and vite.config.js both to be Typescript (.ts instead of .js).
svelte.config.js
vite.config.js
When I reverted that, intuitively, the types were successfully recognized.