Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

typescript

v3.0.29arrow_drop_down
v3.0.29
v3.0.28
v3.0.27
v3.0.26
v3.0.25
v3.0.24
v3.0.23
v3.0.22
v3.0.21
v3.0.20
v3.0.19
v3.0.18
v3.0.17
v3.0.16
v3.0.15
v3.0.14
v3.0.13
v3.0.12
v3.0.11
v3.0.10
v3.0.9
v3.0.8
v3.0.7
v3.0.6
v3.0.5
v3.0.4
v3.0.3
v3.0.2
v3.0.1
v3.0.0
v0.0.5
v0.0.4
v0.0.3
v0.0.2
v0.0.1
STATUS
Passing
DOWNLOADS
3,504
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 days ago
SIZE
N/A
subject
Bit TypeScript compiler. Compiles a component for TypeScript.
4 contributors
Use typescript in your project ?
Copied
npm i @bit/bit.envs.compilers.typescript
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
modifieddraft
modifieddraft
 bit import bit.envs/compilers/typescript -c
modifieddraft
chevron_left
chevron_right

TS Compiler

Support for the Typescript language using tsc.

How to use?

Import the environment.

bit import bit.envs/compilers/typescript -c

Then build using bit build.

bit build

Supported

  1. Copy policy.
  2. Static configuration with the compiler (fork to change).

Features:

Configuration The compiler will read the author environment tsconfig.json and will adapt it to the structure of the component. Detection of config will happen automatic unless directed otherwise by the user. The user may also override specific tsconfig.json from the bit.json file. This is to correct a situation when a config makes sense in the project but not in a component and vice versa. Some dependencies are implicitly deduced from tsconfig.json and not from the codebase. TS-compiler will use bit’s API to add those dependencies to the component.

Some configuration is imposed on tsc from bit:

  1. The entry of a component and the entry of a project are different. This will force configuration change around files|include.
  2. for now multilayer configuration isn’t supported so extends keyword will be omitted. Missing config can be done with overrides.
  3. The order of configuration will be : project, compiler, bit.json where bit.json is most important.

Isolation Bit will use the capsule API to isolate the component from the rest of the project so tsc will only walk the needed imports. In case compilation fails you may debug an isolated environment by using env DEBUG=true bit build which keeps the capsule in the /tmp/bit/cpausle-[number] folder.

Copy policy - Files which don’t get compiled will be copied to the dist.

Preset Allow the users to choose configuration from a list of predefined configs or bit-ID

example bit.json

{
    "bit": {
        "env": {
            "compiler": {
                "@bit.envs/compilers/typescript": {
                    "rawConfig": {
                        // this overrides tsconfig.json from the project/compiler.
                    },
                    "files": {
                        "tsconfig": "./tsconfig.json", // naming the configuration file.
                    },
                    "options": {
                        "preset": "" // bitId or some name like react
                    }
                }
            }
        }
    }
}