ds300 / react-native-typescript-transformer

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

Support tsconfig inheritance via extends option #74

Closed doomsower closed 5 years ago

doomsower commented 6 years ago

I have a monorepo with multiple typescript projects. To keep tsconfigs simple and synced I decided to extract common tconfig.json in project root and extend it inside packages. For react-native projects, yarn run tsc works fine, however packager fails.

It seems that react-native-typescript-transformer only reads top-level tsconfig and doesn't follow extends hierarchy.

It would be nice if someone could fix this

jkillian commented 5 years ago

Ran in to this error myself today, and got a mysterious error from react-native:

Cannot convert undefined or null to object

because of this line:

https://github.com/ds300/react-native-typescript-transformer/blob/7aa16d351a14068b1dcfa95aa99edaa163686700/index.js#L187

As it turns out, my tsconfig file didn't have a compilerOptions field defined because it uses extends to inherit from a different file. A nicer error message here would be great, and even better would be support for extends!

TypeScript itself likely provides APIs for loading its config files; so that should make things easier than figuring out how to handle extends manually.

ncuillery-youitv commented 5 years ago

@doomsower @JKillian Kudos to both of you. 👏

Thank to you, I manage to workaround the issue by adding compilerOptions: {} in my tsconfig.json file

ncuillery-youitv commented 5 years ago

Nevermind, the compilerOptions in the parent tsconfig.json are not read so it's not a viable solution 😄