You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/en/guide/basic/typescript.mdx
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,14 @@ You can create a `src/env.d.ts` file to reference it:
40
40
/// <referencetypes="@rslib/core/types" />
41
41
```
42
42
43
+
## Type checking
44
+
45
+
When transpiling TypeScript code using tools like SWC and Babel, type checking is not performed.
46
+
47
+
Rslib provides the [lib.dts](/config/lib/dts) configuration item for generating TypeScript declaration files, and type checking is performed by default during the generation process.
48
+
49
+
You can skip type checking by setting the [noCheck](https://www.typescriptlang.org/tsconfig/#noCheck) configuration item to `true` in the `tsconfig.json` file.
50
+
43
51
## tsconfig.json path
44
52
45
53
Rslib by default reads the `tsconfig.json` file from the root directory. You can use [source.tsconfigPath](/config/rsbuild/source#sourcetsconfigpath) to configure a custom `tsconfig.json` file path.
@@ -54,3 +62,9 @@ export default {
54
62
},
55
63
};
56
64
```
65
+
66
+
## Decorators version
67
+
68
+
By default, Rslib uses the [`2022-03`](https://rsbuild.rs/config/source/decorators#2022-03) version of the decorators.
69
+
70
+
If [experimentalDecorators](https://www.typescriptlang.org/tsconfig/#experimentalDecorators) is enabled in `tsconfig.json`, Rslib will set [source.decorators.version](/config/rsbuild/source#sourcedecorators) to `legacy` to use the legacy decorators.
Copy file name to clipboardExpand all lines: website/docs/en/guide/faq/features.mdx
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,73 @@ export default {
95
95
96
96
## Declaration files generation
97
97
98
+
### How to avoid generating declaration files for certain files?
99
+
100
+
As shown below, Rslib ignores the files under the `src/tests` directory when emitting JavaScript outputs, but these files still generate corresponding declaration files.
101
+
102
+
```ts title="rslib.config.ts"
103
+
exportdefault {
104
+
lib: [
105
+
source: {
106
+
entry: {
107
+
index: ['src/**/*', '!src/tests/**/*'],
108
+
}
109
+
}
110
+
],
111
+
};
112
+
```
113
+
114
+
The entry set by [source.entry](/config/lib/bundle#bundle-false) can exclude some files that do not generate corresponding JavaScript outputs, but cannot exclude the generation of corresponding declaration files. This needs to be achieved by setting [include](https://www.typescriptlang.org/tsconfig/#include) and [exclude](https://www.typescriptlang.org/tsconfig/#exclude) in `tsconfig.json`, as shown below:
115
+
116
+
```json title="tsconfig.json"
117
+
{
118
+
"compilerOptions": {
119
+
// ...
120
+
},
121
+
"include": ["src/**/*"],
122
+
"exclude": ["src/tests/**/*"]
123
+
}
124
+
```
125
+
126
+
If you want to keep type prompts and checking for these files, but do not generate corresponding declaration files, you can inherit a basic `tsconfig.json` by [extends](https://www.typescriptlang.org/tsconfig/#extends) and then override the `include` and `exclude` options as follows:
127
+
128
+
```json title="tsconfig.json"
129
+
{
130
+
"compilerOptions": {
131
+
// ...
132
+
},
133
+
"include": ["src/**/*", "rslib.config.ts"]
134
+
}
135
+
```
136
+
137
+
```json title="tsconfig.build.json"
138
+
{
139
+
"extends": "./tsconfig.json",
140
+
"compilerOptions": {
141
+
// ...
142
+
},
143
+
"include": ["src/**/*"],
144
+
"exclude": ["src/tests/**/*"]
145
+
}
146
+
```
147
+
148
+
The newly added `tsconfig.build.json` needs to be configured in the [source.tsconfigPath](/config/rsbuild/source#sourcetsconfigpath) option in `rslib.config.ts`:
149
+
150
+
```ts title="rslib.config.ts"
151
+
exportdefault {
152
+
lib: [
153
+
source: {
154
+
entry: {
155
+
index: ['src/**/*', '!src/tests/**/*'],
156
+
}
157
+
}
158
+
],
159
+
source: {
160
+
tsconfigPath: 'tsconfig.build.json',
161
+
},
162
+
};
163
+
```
164
+
98
165
### How to additionally exclude specified dependencies when `dts.bundle` is `true`?
99
166
100
167
Rslib uses [rsbuild-plugin-dts](https://github.com/web-infra-dev/rslib/blob/main/packages/plugin-dts/README.md) to generate declaration files, which supports configuration via [output.externals](/config/rsbuild/output#outputtarget) for excluding certain dependencies from bundled declaration files.
0 commit comments