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_1.04.ts
Created May 31, 2018 16:44
S1. F04. example of implicitAnyIndex in TypeScript (ARTICLE: TS-Module w/ Declarations (Part 1/4))
/** TS-Module w/ Declarations (Part 1/4)
* http://TGRstack.com/#ts-module_articles_part-1
* example of ENUM w/ Redux ./tsconfig.json (Section 1. Figure 04.)
**/
interface ISomeObject {
firstKey: string;
secondKey: string;
thirdKey: string;
[key: string]: string;
}
@Falieson
Falieson / tgr_tsmod_2.01.bash
Last active May 31, 2018 18:27
S2. F01. 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
# Init HelloWorld.ts (Section 2. Figure 01.)
###
falieson:./ts-module/$ mkdir src
falieson:./ts-module/$ touch src/index.ts src/HelloWorld.ts
@Falieson
Falieson / tgr_tsmod_2.02.ts
Last active May 31, 2018 21:21
S2. F02. 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
* ./src/HelloWorld.ts (Section 2. Figure 02.)
**/
function HelloWorldMaker(first: string, second: string): string {
return `${first} ${second}`
}
export default HelloWorldMaker
@Falieson
Falieson / tgr_tsmod_2.03.ts
Last active May 31, 2018 18:28
S2. F03. import HelloWorld and use it (ARTICLE: TS-Module w/ Declarations (Part 1/4))
/** TS-Module w/ Declarations (Part 1/4)
* http://TGRstack.com/#ts-module_articles_part-1
* ./src/index.ts (Section 2. Figure 03.)
**/
import {default as HelloWorld} from './HelloWorld'
const FirstPart: string = "Hi"
const LastPart: string = "Earth"
console.log(HelloWorld(FirstPart, LastPart))
@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
@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_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_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_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.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",