Most TS package as it's own @types. At times we might get conflicts between them. This error might happen when using React + TypeScript + styled-components (duplicate identifier error with a lot of types). An example of types error:
The problem is that @types/styled-components has a dependency on @types/react-native and it's causing the issue.
If you have this configuration and you don't get this error, please check that the skipLibCheck option in tsconfig is set to false (which is the default value).
Steps to Reproduce
Create a React+TypeScript project.
Install styled-components and @types/styled-components.
Create a simple component that uses styled-components.
We can configure TypeScript the library we want to use when doing type checking using --types (list of names of type definitions to include).
To do it in Bit, you'll need to configure the Bit compiler's tsconfig. To do that, open your project's Bit configuration to override the compiler's default configuration (and add types).
And you need also to add @types/node as dev dependencies of your components, so it will build correctly in the Bit React-TypeScript compiler, to do so, just use the overridesoption in Bit, like this:
Describe the bug
Most TS package as it's own
@types
. At times we might get conflicts between them. This error might happen when using React + TypeScript + styled-components (duplicate identifier error with a lot of types). An example of types error:The problem is that
@types/styled-components
has a dependency on@types/react-native
and it's causing the issue.Steps to Reproduce
styled-components
.Screenshots, exceptions and logs
The dependencies from
@types/styled-components
package that include@types/react-native
and causing the error:How to solve this?
We can configure TypeScript the library we want to use when doing type checking using
--types
(list of names of type definitions to include).To do it in Bit, you'll need to configure the Bit compiler's
tsconfig
. To do that, open your project's Bit configuration to override the compiler's default configuration (and addtypes
).And you need also to add
@types/node
as dev dependencies of your components, so it will build correctly in the Bit React-TypeScript compiler, to do so, just use theoverrides
option in Bit, like this:Specifications