react native - Components are being seen as types - Stack Overflow

admin2025-04-15  3

I have gotten a new computer, where everything finally is installed. Upon opening my project, all the pages contain errors.

Errors

'GestureHandlerRootView' refers to a value, but is being used as a type here. Did you mean 'typeof GestureHandlerRootView'?ts(2749)

'SheetProvider' refers to a value, but is being used as a type here. Did you mean 'typeof SheetProvider'?ts(2749)

Code

     <GestureHandlerRootView
        style={{
          flex: 1,
        }}
      >
        <SheetProvider context="global">
          <SafeAreaProvider>
            <NavigationContainer>
              <AppContextProvider>
                <StatusBar animated translucent style={"light"} />
                <AppContext />
              </AppContextProvider>
            </NavigationContainer>
          </SafeAreaProvider>
        </SheetProvider>
      </GestureHandlerRootView>

tsconfig.json

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "jsx": "react-jsx",
    "plugins": [
      {
        "name": "@styled/typescript-styled-plugin",
        "lint": {
          "validProperties": [
            "shadow-color",
            "shadow-opacity",
            "shadow-offset",
            "shadow-radius",
            "padding-horizontal",
            "padding-vertical",
            "margin-vertical",
            "margin-horizontal",
            "tint-color",
            "aspect-ratio",
            "elevation"
          ]
        }
      }
    ],
    "strict": true,
    "typeRoots": ["./src/types", "node_modules/@types"],
    "baseUrl": ".",
    "noImplicitAny": false, // Disables error where no type is given in import statements.
    "paths": {
      "@/components/*": ["./src/components/*"],
      "@/config/*": ["./src/config/*"],
      "@/i18n/*": ["./src/i18n/*"],
      "@/screens/*": ["./src/screens/*"],
      "@/utils/*": ["./src/utils/*"],
      "@/assets/*": ["./assets/*"],
      "@/navigation/*": ["./src/navigation/*"],
      "@/context/*": ["./src/context/*"],
      "@/data/*": ["./src/data/*"],
      "@/state/*": ["./src/state/*"],
      "@/hooks/*": ["./src/hooks/*"],
      "@/types/*": ["./src/types/*"],
      "@/src/*": ["./src/*"],
      "@/root/*": ["./*"]
    },
    "types": ["styled-components-react-native"]
  },
  "include": ["src"]
}

package.json

{
    "expo": "~50.0.20",
    "react": "18.2.0",
    "react-native": "0.73.6",
}
转载请注明原文地址:http://www.anycun.com/QandA/1744728673a86796.html