Closed
Description
*Templated added by @mjbvz
TypeScript Version: 3.7.0-dev.20190919
Search terms
- React
- quick fix
- add missing import
original issue below
- VSCode Version: 1.38.1 and 1.39.0
- OS Version: macOS
Very weird issue... In React Native if you write <Text></Text>
and you use Quick Fix...
on the first <Text>
you will get Import default 'React' from "react"
, but if you use Quick Fix...
on the second </Text>
(closing) you will get Import 'Text' from module "react-native"
(which is correct).
It's hard to describe the issue so these screenshots will explain everything.
I expect to get the same behavior like with </Text>
(closing) if I use Quick Fix on the <Text>
(opening).
Steps to Reproduce:
yarn add react react-native @types/react @types/react-native
- Create
tsconfig.json
with the content below. - Create new file
App.tsx
with the content below. - Move cursor to the first
<Text>
and pressCMD+.
or useQuick Fix...
from Command Palette.
tsconfig.json
{
"compilerOptions": {
"jsx": "react-native",
"lib": ["es6"],
"esModuleInterop": true,
"moduleResolution": "node"
}
}
package.json
{
"dependencies": {
"@types/react": "^16.9.2",
"@types/react-native": "^0.60.15",
"react": "^16.9.0",
"react-native": "^0.60.5"
}
}
App.tsx
import React from 'react';
function App() {
return <Text>Hello, World!</Text>;
}