File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
1212
13- _ 1313 TILs and counting..._
13+ _ 1314 TILs and counting..._
1414
1515---
1616
@@ -1212,6 +1212,7 @@ _1313 TILs and counting..._
12121212- [ Create Union Type From Constants] ( typescript/create-union-type-from-constants.md )
12131213- [ Extract Object Type Keys Into A Union Type] ( typescript/extract-object-type-keys-into-a-union-type.md )
12141214- [ Extract Object Type Values Into A Union Type] ( typescript/extract-object-type-values-into-a-union-type.md )
1215+ - [ Generate An Initial tsconfig File] ( typescript/generate-an-initial-tsconfig-file.md )
12151216- [ Generate Inferred Type From Zod Schema] ( typescript/generate-inferred-type-from-zod-schema.md )
12161217- [ Get The Return Type Of An Async Function] ( typescript/get-the-return-type-of-an-async-function.md )
12171218- [ Interfaces With The Same Name Are Merged] ( typescript/interfaces-with-the-same-name-are-merged.md )
Original file line number Diff line number Diff line change 1+ # Generate An Initial tsconfig File
2+
3+ A new ` tsconfig.json ` file can be generated using the ` tsc ` CLI which is part
4+ of the ` typescript ` node package.
5+
6+ You'll first want to add ` typescript ` to your project:
7+
8+ ``` bash
9+ $ npm install typescript --save-dev
10+ ```
11+
12+ Since it is a local project dependency, you'll want to add ` tsc ` as a script in
13+ your ` package.json ` .
14+
15+ ``` json
16+ "scripts" : {
17+ "tsc" : " tsc"
18+ }
19+ ```
20+
21+ Now you can use ` npm ` to run ` tsc --init ` like so:
22+
23+ ``` bash
24+ $ npm run tsc -- --init
25+ ```
26+
27+ Notice the delimiting ` -- ` which tells ` npm ` to pass the remaining arguments to
28+ the command being invoked. This makes sure ` --init ` gets passed as an argument
29+ to ` tsc ` .
30+
31+ This will generate a huge, mostly commented-out ` tsconfig.json ` file full of
32+ annotations that looks something like this:
33+
34+ ``` json
35+ {
36+ "compilerOptions" : {
37+ /* Visit https://aka.ms/tsconfig to read more about this file */
38+
39+ /* Projects */
40+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
41+ /* ... */
42+
43+ /* Language and Environment */
44+ "target" : " es2016" , /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
45+ /* ... */
46+ }
47+ }
48+ ```
You can’t perform that action at this time.
0 commit comments