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
-[Default and Named Module Exports](#default-and-named-module-exports)
74
+
-[Type Augmentation for npm libraries](#type-augmentation-for-npm-libraries)
75
+
-[Override type-definitions for npm libraries](#override-type-definitions-for-npm-libraries)
75
76
-[FAQ](#faq)
76
77
-[Tutorials](#tutorials)
77
78
-[Contributors](#contributors)
@@ -1304,7 +1305,7 @@ configure({ adapter: new Adapter() });
1304
1305
1305
1306
# Recipes
1306
1307
1307
-
### tsconfig.json
1308
+
### Baseline tsconfig.json
1308
1309
- Recommended baseline config carefully optimized for strict type-checking and optimal webpack workflow
1309
1310
- Install [`tslib`](https://www.npmjs.com/package/tslib) to cut on bundle size, by using external runtime helpers instead of adding them inline: `npm i tslib`
1310
1311
- Example "paths" setup for baseUrl relative imports with Webpack
@@ -1314,21 +1315,22 @@ configure({ adapter: new Adapter() });
#### To quick-fix missing type declarations for vendor modules you can "assert" a module type with `any` using [Shorthand Ambient Modules](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#shorthand-ambient-modules)
1416
+
#### To quick-fix missing type-definitions for vendor modules you can "assert" a module type with `any` using [Shorthand Ambient Modules](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#shorthand-ambient-modules)
1422
1417
1423
1418
```tsx
1424
1419
// typings/modules.d.ts
@@ -1428,7 +1423,25 @@ declare module 'enzyme';
1428
1423
1429
1424
```
1430
1425
1431
-
> More advanced scenarios for working with vendor module declarations can be found here [Official TypeScript Docs](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#working-with-other-javascript-libraries)
1426
+
> More advanced scenarios for working with vendor type-definitions can be found here [Official TypeScript Docs](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#working-with-other-javascript-libraries)
1427
+
1428
+
[⇧ back to top](#table-of-contents)
1429
+
1430
+
### Override type-definitions for npm libraries
1431
+
If you want to use an alternative (customized) type-definitions for some npm library (that usually comes with it's own type definitions), you can do it by adding an override in `paths` compiler option.
1432
+
1433
+
```ts
1434
+
{
1435
+
"compilerOptions": {
1436
+
"baseUrl": ".",
1437
+
"paths": {
1438
+
"redux": ["typings/redux"], // use an alternative type-definitions instead of the included one
Copy file name to clipboardExpand all lines: docs/markdown/4_recipes.md
+34-22
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Recipes
2
2
3
-
### tsconfig.json
3
+
### Baseline tsconfig.json
4
4
- Recommended baseline config carefully optimized for strict type-checking and optimal webpack workflow
5
5
- Install [`tslib`](https://www.npmjs.com/package/tslib) to cut on bundle size, by using external runtime helpers instead of adding them inline: `npm i tslib`
6
6
- Example "paths" setup for baseUrl relative imports with Webpack
#### To quick-fix missing type declarations for vendor modules you can "assert" a module type with `any` using [Shorthand Ambient Modules](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#shorthand-ambient-modules)
111
+
#### To quick-fix missing type-definitions for vendor modules you can "assert" a module type with `any` using [Shorthand Ambient Modules](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#shorthand-ambient-modules)
> More advanced scenarios for working with vendor module declarations can be found here [Official TypeScript Docs](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#working-with-other-javascript-libraries)
115
+
> More advanced scenarios for working with vendor type-definitions can be found here [Official TypeScript Docs](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#working-with-other-javascript-libraries)
116
+
117
+
[⇧ back to top](#table-of-contents)
118
+
119
+
### Override type-definitions for npm libraries
120
+
If you want to use an alternative (customized) type-definitions for some npm library (that usually comes with it's own type definitions), you can do it by adding an override in `paths` compiler option.
121
+
122
+
```ts
123
+
{
124
+
"compilerOptions": {
125
+
"baseUrl": ".",
126
+
"paths": {
127
+
"redux": ["typings/redux"], // use an alternative type-definitions instead of the included one
0 commit comments