ds300 / react-native-typescript-transformer

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

Ignoring "outDir" from tsconfig.json #61

Closed jasin755 closed 6 years ago

jasin755 commented 6 years ago

react-native-typescript-transformer ignore outDir defined in my tsconfig.json

tsconfig.json:

{
    "compilerOptions": {
        "target": "es2015",
        "module": "es2015",
        "jsx": "react-native",
        "moduleResolution": "node",
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "noImplicitAny": true,
        "strict": true,
        "outDir": "./artifacts"
    }
}

and rn-cli.config.js

module.exports = {
    getTransformModulePath() {
        return require.resolve('react-native-typescript-transformer');
    },
    getSourceExts() {
        return ['ts', 'tsx'];
    }
}

I use this command: /usr/local/bin/node /usr/local/lib/node_modules/react-native-cli start --config /Users/xxxxx/WebstormProjects/untitled2/rn-cli.config.js to start app and typescript files always compile to same place where is original ts/tsx file

aMarCruz commented 6 years ago

@jasin755 , I'm using tsc -p . --noEmit false yarn start without problems, this is my config:

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "es6",
    "jsx": "preserve",
    "noEmit": true,
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "baseUrl": ".",
    "forceConsistentCasingInFileNames": true,
    "newLine": "lf",
    "charset": "utf8",
    "allowJs": true,
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noImplicitUseStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    "preserveConstEnums": false,
    "pretty": true,
    "outDir": "./~js"
  },
  "files": [
    "index.d.ts",
    "index.js",
  ],
  "include": [
    "typings/**/*.ts",
    "app/**/*.ts"
  ],
  "exclude": [
    "~js",
    "android",
    "ios",
    "node_modules"
  ]
}

rn-cli.config.js:

/* eslint-env node */
module.exports = {
  getTransformModulePath () {
    return require.resolve('react-native-typescript-transformer')
  },
  getSourceExts () {
    return ['ts', 'tsx']
  },
}

.babelrc

{
  "presets": ["react-native"],
  "env": {
    "production": {
      "plugins": [
        "transform-remove-console"
      ]
    }
  }
}

...and this script in package.json:

"start": "node node_modules/react-native/local-cli/cli.js start",

maybe you need the "noEmit": true,

RN 0.55.3, typescript: 2.8.3 react-native-typescript-transformer: 1.2.4

ds300 commented 6 years ago

I'm going to close this issue due to inactivity. If you're still having trouble with compilation, please feel free to open another issue and link to this one :pray:

Thanks for fielding this one, @aMarCruz 🙌