ds300/react-native-typescript-transformer

Support tsconfig inheritance via extends option

doomsower opened this issue ยท 3 comments

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

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:

const compilerOptions = Object.assign(tsConfig.compilerOptions, {

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.

@doomsower @jkillian Kudos to both of you. ๐Ÿ‘

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

Nevermind, the compilerOptions in the parent tsconfig.json are not read so it's not a viable solution ๐Ÿ˜„