Skip to content

Instantly share code, notes, and snippets.

View Falieson's full-sized avatar
:shipit:

Florian Mettetal Falieson

:shipit:
View GitHub Profile
@Falieson
Falieson / tgr_tsmod_6.01.bash
Last active May 31, 2018 22:11
S6. F01. Init ts-module-consumer (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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
@Falieson
Falieson / tgr_tsmod_5.02.json5
Last active May 31, 2018 22:01
S5. F02. Package.json Settings (ARTICLE: TS-Module w/ Declarations (Part 1/4))
/** 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",
@Falieson
Falieson / tgr_tsmod_3.01.bash
Last active May 31, 2018 21:30
S3. F01. List all files in ./dist (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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
@Falieson
Falieson / tgr_tsmod_5.05.bash
Last active May 31, 2018 22:04
S5. F05. Commit Progress (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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)
@Falieson
Falieson / tgr_tsmod_5.04.json5
Last active May 31, 2018 22:20
S5. F04. package scripts(ARTICLE: TS-Module w/ Declarations (Part 1/4))
/** 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",
@Falieson
Falieson / tgr_tsmod_5.03.bash
Last active May 31, 2018 21:59
S5. F03. Set NVM (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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
@Falieson
Falieson / tgr_tsmod_5.01.bash
Last active May 31, 2018 21:51
S5. F01. Init NPM & disable package-lock (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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
@Falieson
Falieson / tgr_tsmod_4.01.bash
Last active May 31, 2018 21:43
S4. F01. Init Git (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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 .
@Falieson
Falieson / tgr_tsmod_2.05.bash
Last active May 31, 2018 21:28
S2. F05. TSC recompilation issues (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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
@Falieson
Falieson / tgr_tsmod_2.04.bash
Last active May 31, 2018 21:24
S2. F04. Init HelloWorld (ARTICLE: TS-Module w/ Declarations (Part 1/4))
### 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