typescriptreact-nativeexpotscreact-native-gifted-charts

`tsc` keeps tracking `node_modules`. Can anyone help me resolve this issue?


I'm using Expo. This is my tsconfig.json:

{
    "compilerOptions": {
        "paths": {
            "@/*": [
                "./src/*"
            ],
            "@assets/*": [
                "./assets/*"
            ]
        },
        "strict": true,
        "strictFunctionTypes": false,
        "noFallthroughCasesInSwitch": true
    },
    "include": [
        "src",
        ".expo/types/**/*.ts",
        "expo-env.d.ts"
    ],
    "extends": "expo/tsconfig.base"
}

as you see, it extends expo/tsconfig.base:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Expo",

  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "jsx": "react-native",
    "lib": ["DOM", "ESNext"],
    "moduleResolution": "node",
    "noEmit": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "target": "ESNext"
  },

  "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}

tsc keeps tracking node_modules. why? I can't find any solutions about it.

$ yarn tsc

...

Errors  Files
     1  node_modules/react-native-gifted-charts/src/BarChart/Animated2DWithGradient.tsx:110
     8  node_modules/react-native-gifted-charts/src/BarChart/index.tsx:19
     3  node_modules/react-native-gifted-charts/src/BarChart/RenderBars.tsx:219
     1  node_modules/react-native-gifted-charts/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx:8
     3  node_modules/react-native-gifted-charts/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx:7
     1  node_modules/react-native-gifted-charts/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx:5
     1  node_modules/react-native-gifted-charts/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx:4
     2  node_modules/react-native-gifted-charts/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx:6
     1  node_modules/react-native-gifted-charts/src/Components/BarSpecificComponents/barBackgroundPattern.tsx:4
     1  node_modules/react-native-gifted-charts/src/Components/BarSpecificComponents/cap.tsx:5
     1  node_modules/react-native-gifted-charts/src/Components/common/Pointer.tsx:4
     1  node_modules/react-native-gifted-charts/src/Components/common/StripAndLabel.tsx:6
    37  node_modules/react-native-gifted-charts/src/LineChart/index.tsx:411
    16  node_modules/react-native-gifted-charts/src/LineChart/LineChartBicolor.tsx:193
     2  node_modules/react-native-gifted-charts/src/PieChart/index.tsx:32
error Command failed with exit code 2.

Note that tsc is a pure command without any customization in package.json.


Solution

  • It's because of the library react-native-gifted-charts. I've pointed out the problem to that library:

    https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/625

    A temporary workaround is this:

    https://gist.github.com/araphiel/b3d13ade7f9fe69e99c3d053196557d2