ds300 / react-native-typescript-transformer

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

#29 respect noEmitOnError #75

Open simonhoss opened 6 years ago

simonhoss commented 6 years ago

Hi

This is a implementation to respect the noEmitOnError config. If any problem exists (not only syntax errors) it will report the first error and stop compiling.

Please review and give me feedback.

Greets

henrikra commented 6 years ago

So if I get compile error does it show red screen on my app or something?

simonhoss commented 6 years ago

It shows an error on the react-native packager, but I was not able to make a build without errors. It seems that createProgram is a bit different than tsc -p tsconfig.json or maybe my tsconfig.json is wrong?!

henrikra commented 6 years ago

Can you show Gif/video of the this feature?

mvdam commented 6 years ago

@simonhoss I was able to fix the Unexpected moduleResolution: node error by using

const moduleResolution = compilerOptions.moduleResolution === 'node'
  ? ts.ModuleResolutionKind.NodeJs
  : ts.ModuleResolutionKind.Classic

const program = ts.createProgram([filename], {
  ...compilerOptions,
  moduleResolution
})

(Source)

But after this it will throw Cannot find global type 'Array'.. It really looks like the ts.createProgram() takes a different type of compiler options then ts.transpileModule().

I will also try to find a solution for this somewhere this week because we really need this! Please let me know if you know more (already).

mvdam commented 6 years ago

I found a solution and made a PR for this (on top of the changes of @simonhoss -> https://github.com/simonhoss/react-native-typescript-transformer/pull/1). If you guys can provide some feedback that would be great!