This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# Create a new consumer of our ts-module | |
### | |
falieson:./ts-module/$ mkdir -p ~/Code/Playground/ts-module-consumer | |
falieson:./ts-module/$ cd ~/Code/Playground/ts-module-consumer | |
falieson:./ts-module-consumer/$ npm init -y | |
falieson:./ts-module-consumer/$ npm install ../../Templates/ts-module/ | |
falieson:./ts-module-consumer/$ tsc -init | |
falieson:./ts-module-consumer/$ touch index.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** TS-Module w/ Declarations (Part 1/4) | |
* http://TGRstack.com/#ts-module_articles_part-1 | |
* package settings (Section 5. Figure 02.) | |
* complete file: https://github.com/Falieson/2018-typescript-module/blob/master/package.json | |
// json5 file format to support comments | |
**/ | |
{ | |
"name": "ts-module", | |
"version": "1.0.0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# List all files in ./dist (Section 3. Figure 01.) | |
# including subdirectories | |
### | |
falieson:./ts-module/$ tsc ../ # run the compiler a third time in a row | |
falieson:./ts-module/$ cd dist/ && find . && cd ../ # return the root dir | |
. | |
./hello | |
./hello/HelloWorld.d.ts # <== the new declaration file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# Commit Progress (Section 5. Figure 04.) | |
### | |
falieson:./ts-module/$ git add . | |
falieson:./ts-module/$ git status | |
On branch mvp | |
Changes to be committed: | |
(use "git reset HEAD <file>..." to unstage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** TS-Module w/ Declarations (Part 1/4) | |
* http://TGRstack.com/#ts-module_articles_part-1 | |
* package-scripts (Section 5. Figure 04.) | |
* complete file: https://github.com/Falieson/2018-typescript-module/blob/master/package.json | |
**/ | |
{ | |
... // some stuff | |
"scripts": { | |
"build": "rimraf dist/ && tsc", | |
"start:build": "node dist/index.js", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# Set NVM (Section 5. Figure 03.) | |
### | |
falieson:./ts-module/$ NV=$(node --version) | |
falieson:./ts-module/$ echo "${NV:1:${#NV}-1}" >> ".nvmrc" # set pkg node version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# Init NPM, npmrc, npmignore (Section 5. Figure 01.) | |
# Also, disable package-lock.json | |
### | |
falieson:./ts-module/$ npm init -y | |
falieson:./ts-module/$ echo "node_modules/" >> ".gitignore" # 1 | |
falieson:./ts-module/$ echo "package-lock.json" >> ".gitignore" # 2 | |
falieson:./ts-module/$ echo "package-lock=false" >> ".npmrc" # 3 | |
falieson:./ts-module/$ echo "save-exact=true" >> ".npmrc" # 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# Init Git, branch, commit (Section 4. Figure 01.) | |
### | |
falieson:./ts-module/$ git init | |
Initialized empty Git repository in ./ts-module/.git/ | |
falieson:./ts-module/$ git checkout -b mvp | |
falieson:./ts-module/$ echo "dist/" >> ".gitignore" # don't add tsc output to the source | |
falieson:./ts-module/$ git add . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# mv HelloWorld and re-compile (Section 2. Figure 05.) | |
### | |
falieson:./ts-module/$ mkdir src/hello | |
falieson:./ts-module/$ mv src/HelloWorld.ts src/hello/ | |
## !! update references in src/index.ts to the new hello directory !! | |
falieson:./ts-module/$ tsc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### TS-Module w/ Declarations (Part 1/4) | |
# http://TGRstack.com/#ts-module_articles_part-1 | |
# Compile and Run the module (Section 2. Figure 04.) | |
### | |
falieson:./ts-module/$ tsc # wait a minute or so while it works | |
falieson:./ts-module/$ ls | |
.git | |
dist # <=== tsc created this |