Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode doesn't import <Text> component in typescript

VSCode with typescript has this awesome feature where if you do CMD+. on a module that hasn't been imported yet, it gives you the option to automatically import that module or import all modules that are missing.

It's particularly helpful when copying a bunch of JSX, and letting vscode handle all the imports. This works great but with one exception, it won't import the component. I figured it's probably because it refers to https://developer.mozilla.org/en-US/docs/Web/API/Text/Text.

Is there a way to point typescript in the right direction?

Example below:

Example

like image 562
Tim de Wolf Avatar asked Aug 15 '26 08:08

Tim de Wolf


1 Answers

Put your Text.tsx component in a path/to/Text/ folder, then rename it to index.tsx. This should get VSCode to start suggesting the import.

like image 53
tester Avatar answered Aug 17 '26 22:08

tester