ds300 / react-native-typescript-transformer

Seamlessly use TypeScript with React Native
MIT License
657 stars 50 forks source link

rootDir error #26

Closed jasonkuhrt closed 7 years ago

jasonkuhrt commented 7 years ago

I'm getting the following error, following the given instructions in the readme. Am I doing something wrong?

image

ds300 commented 7 years ago

I haven't seen that before. Can you post your tsconfig.json file?

jasonkuhrt commented 7 years ago

Yup this was related to a badly configured tsconfig.json file. I had this:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "jsx": "react-native",
    "outDir": "build",
    "rootDir": "source",
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "preserveConstEnums": true,
    "allowJs": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "skipLibCheck": true,
    "moduleResolution": "node"
  },
  "include": ["./source/**/*.ts", "./source/**/*.tsx", "./typings.d.ts"],
  "exclude": ["App.js", "App.test.js", "build", "node_modules"],
  "compileOnSave": true
}

But the following change fixed things for me:

❯ gd tsconfig.json
diff --git a/react-native-apollo/tsconfig.json b/react-native-apollo/tsconfig.json
index 16bf72c..2c985f5 100644
--- a/react-native-apollo/tsconfig.json
+++ b/react-native-apollo/tsconfig.json
@@ -3,8 +3,6 @@
     "target": "es2015",
     "module": "commonjs",
     "jsx": "react-native",
-    "outDir": "build",
-    "rootDir": "source",
     "noImplicitAny": true,
     "experimentalDecorators": true,
     "preserveConstEnums": true,
@@ -19,7 +17,16 @@
     "skipLibCheck": true,
     "moduleResolution": "node"
   },
mptorz commented 5 years ago

@jasonkuhrt I had the same issue and it was blocking me for 4 hours. Thank you so much man! If you are in London I will buy you a beer or something xD

jasonkuhrt commented 5 years ago

@mptorz sounds good lol, or also if you're ever in Montreal ever :D