freddy freddy - 1 year ago 356
TypeScript Question

TypeScript - how to exclude one of the typings?

I'm creating a web + mobile app using react-native and TypeScript. So essentialy, I have two different outputs for two different TS configs.

For the web, my target is

and module
. So I have to use the
typing to make
happy when transpiling.

For mobile (different
), my target is
and module
. The problem is that this collides with the
typing and
outputs many "Duplicate identifier" errors. If I remove the shim,
is happy (but then web transpilation stops working).

I've tried excluding the typing in the tsconfig for mobile like so:

"exclude": [

...but no luck, TypeScript compiler finds the typing anyway (probably because of a reference from
to the es6-shim typing) and still outputs many "Duplicate identifier" errors for the mobile build.

Am I doing the ignore the wrong way? Am I thinking about it wrong and there is some other way to solve this?

Answer Source

Exclude typings/index.d.ts for the ES6 build as well.

If you have something else in that file that needs to be included in the ES6 build, then move out es6-shim reference into a separate .d.ts file for the ES6 build and exclude that instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download