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 | |
* example of ENUM w/ Redux ./tsconfig.json (Section 1. Figure 04.) | |
**/ | |
interface ISomeObject { | |
firstKey: string; | |
secondKey: string; | |
thirdKey: string; | |
[key: string]: string; | |
} |
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 HelloWorld.ts (Section 2. Figure 01.) | |
### | |
falieson:./ts-module/$ mkdir src | |
falieson:./ts-module/$ touch src/index.ts src/HelloWorld.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 | |
* ./src/HelloWorld.ts (Section 2. Figure 02.) | |
**/ | |
function HelloWorldMaker(first: string, second: string): string { | |
return `${first} ${second}` | |
} | |
export default HelloWorldMaker |
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 | |
* ./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)) |
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 |
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 | |
# 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 | |
# 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 | |
# 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 | |
* 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", |