Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TypeScriptでつくるNode.jsパッケージ
Search
Yusuke Hirao
May 15, 2019
Technology
3
580
TypeScriptでつくるNode.jsパッケージ
Fukuoka.js #8「TypeScript」
Yusuke Hirao
May 15, 2019
Tweet
Share
More Decks by Yusuke Hirao
See All by Yusuke Hirao
ユニバーサルHTMLとWebのポテンシャル
yusukehirao
1
780
READMEにバッヂが欲しくてテストを書き始めました
yusukehirao
1
730
ユニバーサルなマークアップをしよう
yusukehirao
2
850
アクセシビリティチェックを自動化するためのmarkuplintのロードマップ
yusukehirao
2
2k
本当に必要ですか?そのJavaScript 〜スクロールイベント・リサイズイベント編〜
yusukehirao
0
570
コードレビュー なんてしてられるかッ!!
yusukehirao
24
14k
自動化をデザインしよう
yusukehirao
1
860
JSONの型のはなし
yusukehirao
0
590
トランスパイラという文化(…とその後) - PHPカンファレンス福岡2016
yusukehirao
1
2.6k
Other Decks in Technology
See All in Technology
【若手エンジニア応援LT会】AWS Security Hubの活用に苦労した話
kazushi_ohata
0
160
小規模に始めるデータメッシュとデータガバナンスの実践
kimujun
3
580
マネジメント視点でのre:Invent参加 ~もしCEOがre:Inventに行ったら~
kojiasai
0
450
20241031_AWS_生成AIハッカソン_GenMuck
tsumita
0
110
「視座」の上げ方が成人発達理論にわかりやすくまとまってた / think_ perspective_hidden_dimensions
shuzon
2
120
急成長中のWINTICKETにおける品質と開発スピードと向き合ったQA戦略と今後の展望 / winticket-autify
cyberagentdevelopers
PRO
1
160
Figma Dev Modeで進化するデザインとエンジニアリングの協働 / figma-with-engineering
cyberagentdevelopers
PRO
1
430
10分でわかるfreeeのQA
freee
1
3.4k
グローバル展開を見据えたサービスにおける機械翻訳プラクティス / dp-ai-translating
cyberagentdevelopers
PRO
1
150
初心者に Vue.js を 教えるには
tsukuha
5
390
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.6k
AWSコンテナ本出版から3年経った今、もし改めて執筆し直すなら / If I revise our container book
iselegant
15
3.9k
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
Unsuck your backbone
ammeep
668
57k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
How to Think Like a Performance Engineer
csswizardry
19
1.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Ruby is Unlike a Banana
tanoku
96
11k
Measuring & Analyzing Core Web Vitals
bluesmoon
1
39
Speed Design
sergeychernyshev
24
570
Fireside Chat
paigeccino
32
3k
Rails Girls Zürich Keynote
gr2m
93
13k
How GitHub (no longer) Works
holman
311
140k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Transcript
5ZQF4DSJQUͰͭ͘Δ /PEFKTύοέʔδ 'VLVPLBKTň5ZQF4DSJQUʼn גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ฏඌΏ͏ͯΜ
©2019 Yusuke Hirao גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ฏඌΏ͏ͯΜ 5ZQF4DSJQUͰͭ͘Δ /PEFKTύοέʔδ 'VLVPLBKTň5ZQF4DSJQUʼn
©2019 Yusuke Hirao ࣗݾհ ฏඌ༏యʢͻΒ͓Ώ͏ͯΜʣ גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ϑϩϯτΤϯυΤϯδχΞ #-0(IUUQTOPUFNVZVTVLFIJSBP Yusuke
Hirao @cloud10designs
©2019 Yusuke Hirao ͜Μͳͷ࡞ͬͯ·͢ KBDPKTຊޠ༻จࣈมϥΠϒϥϦ NBSLVQMJOU)5.-ϦϯλʔόϦσʔλʔ
©2019 Yusuke Hirao ࠓͳ͢͜ͱ ࠷ݶͷϛχϚϜͳ tsconfig.json packge.json ઃఆʹ͍ͭͯ
©2019 Yusuke Hirao ࠓͳ͞ͳ͍͜ͱ ܕͷͳ͠ NPOPSFQPʹ͍ͭͯ
©2019 Yusuke Hirao ΞδΣϯμ ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ઃఆ Ϗϧυ͢Δ ύϒϦογϡ͢Δ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ϦϙδτϦͷσΟϨΫτϦߏ +BWB4DSJQUϑΝΠϧ ܕఆٛϑΝΠϧʢ*.d.tsʣͳͲͷॻ͖ग़͠ઌ w OQNͰެ։͢ΔϑΝΠϧ܊ΛೖΕΔɻ w
HJUͰআ֎͢Δɻ w ໊લlibͰdistͰԿͰ͓ΈͰɻϞδϡʔϧʹύεࢀ রͰ͖Δύοέʔδʢ5SFF4IBLJOHͷͨΊͩͬͨΓʣʹ͍ͨ͠ ߹ɺσΟϨΫτϦ໊ͪΐͬͱॏཁɻʢྫKBDPKTʣ import toHiragana from "jaco/fn/toHiragana"; toHiragana("ΧλΧφΛͻΒͳ͕ʹ");
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ϦϙδτϦͷσΟϨΫτϦߏ 5ZQF4DSJQUϑΝΠϧͳͲιʔείʔυஔ͖ w OQNͰެ։͠ͳ͍ʢ͍͍ͯ͠ʣɻ w ໊͜͜લ͓ΈͰɻ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ϦϙδτϦͷσΟϨΫτϦߏ ϑΥϧμผʑ͕Φεεϝ w HJUOQNͷআ֎ઃఆָ͕ɻ w ܕఆٛϑΝΠϧʢ*.d.ts.mapʣͷιʔεϚοϓΛར༻Ͱ͖Δɻ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ॻ͖ग़͢+4ͷόʔδϣϯʢtargetʣ es5 es2017 esnext ϝϦοτ
ͲΜͳڥͰಈ͘ /PEFKTWҎ্ ͳΒಈ͘ import.metaରԠ ʢ&4.ʹඞਢʣ σϝϦοτ async/await for..ofͳͲ͕ ϨΨγʔίʔυม͞ΕΔ ϒϥβͰ͏߹ CBCFMͳͲ͕ඞཁʹͳΔ ී௨ʹ͏ͳΒ CBCFMͳͲ͕ඞཁ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ॻ͖ग़͢+4ͷϞδϡʔϧγεςϜʢmoduleʣ commonjs esnext ͦͷଞ ϝϦοτ
ݱࡏͷඪ४ import.metaରԠ ʢ&4.ʹඞਢʣ ͠ΒΜ σϝϦοτ &4.Ͱ͑ͳ͍ ී௨ʹ͏ͳΒ CBCFMͳͲ͕ඞཁ Θ͔ΒΜ
©2019 Yusuke Hirao ઃఆ
©2019 Yusuke Hirao ઃఆ $ yarn init { "name": "@yusukehirao/sample",
"version": "0.1.0-alpha.0", "main": "lib/index.js", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT" } ࣮ݧͷࡍ4DPQFEQBDLFHFʹ͠·͠ΐ͏ ઌʹܾΊͨσΟϨΫτϦͷΤϯτϦʔϑΝΠϧ import sample from "@yusukehirao/sample"; ௨ৗͷimport࣌ͷࢀরઌʹͳΔ package.json
©2019 Yusuke Hirao ઃఆ $ yarn add -D typescript ίϯύΠϥΛΠϯετʔϧ
{ "name": "@yusukehirao/sample", "version": "0.1.0-alpha.0", "main": "lib/index.js", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT", "devDependencies": { "typescript": "^3.4.5" } } package.json
©2019 Yusuke Hirao ઃఆ $ ./node_modules/.bin/tsc —init { "compilerOptions": {
"target": "es2017", "module": "commonjs", "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "./lib", "rootDir": "./src", "strict": true, "esModuleInterop": true } } tsconfig.json ܾΊͨॻ͖ग़͠ઌͱιʔείʔυஔ͖ ܾΊͨ&4όʔδϣϯϞδϡʔϧγεςϜ
©2019 Yusuke Hirao ઃఆ $ ./node_modules/.bin/tsc —init { "compilerOptions": {
"target": "es2017", "module": "commonjs", "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "./lib", "rootDir": "./src", "strict": true, "esModuleInterop": true } } tsconfig.json ܕఆٛϑΝΠϧͱιʔεϚοϓϑΝΠϧͷ ੜΛ༗ޮʹ͓ͯ͘͠
©2019 Yusuke Hirao ઃఆ ίϯύΠϧίϚϯυΛొ tsc ίϚϯυΛొ͓ͯ͘͠ { "name": "@yusukehirao/sample",
"version": "0.1.0-alpha.0", "main": "lib/index.js", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT", "scripts": { "build": "tsc", "prepack": "tsc" }, "devDependencies": { "typescript": "^3.4.5" } } package.json w Φϓγϣϯtsconfig.jsonʹॻ͍͓͚ͯ جຊ͍Βͳ͍ɻ w prepackεΫϦϓτύοέʔδެ։࣌ͷ ϏϧυΕࢭɻ
©2019 Yusuke Hirao ઃఆ ܕఆٛϑΝΠϧΛొ ΤϯτϦʔϑΝΠϧͷܕఆٛϑΝΠϧͷύε { "name": "@yusukehirao/sample", "version":
"0.1.0-alpha.0", "main": "lib/index.js", "types": "lib/index.d.ts", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT", "scripts": { "build": "tsc", "prepack": "tsc" }, "devDependencies": { "typescript": "^3.4.5" } } package.json w ܕใΛఏڙͰ͖Δɻ w Α͘ @types/xxxxxͰࢀর͢Δ %FpOJUFMZ5ZQFE%FpOJUFMZ5ZQFEʹ13 ૹΔඞཁͳ͍ɻ
©2019 Yusuke Hirao Ϗϧυ͢Δ
©2019 Yusuke Hirao Ϗϧυ͢Δ $ yarn build
©2019 Yusuke Hirao Ϗϧυ͢Δ $ yarn build
©2019 Yusuke Hirao ύϒϦογϡ͢Δ
©2019 Yusuke Hirao ύϒϦογϡ͢Δ $ touch .npmignore ύοέʔδʹؚ·ͳ͍ϑΝΠϧͷআ֎ઃఆΛ͢Δ src tsconfig.json
tsconfig.tsbuildinfo .npmignore w package.jsonͷfilesʹύοέʔδʹؚΊ ͍ͨϑΝΠϧͷϗϫΠτϦετΛॻ͍ͯΑ ͍ɻ w .npmignore͔files͕ͳ͍ͱɺ.gitignore Λআ֎ઃఆͱΈͳ͢ͷͰɺॻ͖ग़͠ઌͷσΟϨ ΫτϦ͕ύοέʔδʹೖΒͳ͍൵ࢂͳ͜ͱʹͳ Δ
©2019 Yusuke Hirao ύϒϦογϡ͢Δ $ npm publish
©2019 Yusuke Hirao ύϒϦογϡ͢Δ ܕఆٛϑΝΠϧެ։͍ͯ͠ΔͷͰɺ 5ZQF4DSJQU͔ΒͪΖΜɺ+BWB4DSJQUͰܕΛࢀরͰ͖Δ
5ZQF4DSJQUͰ ར༻ͯ͠Β͑·͢Αʔʹ
גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ฏඌΏ͏ͯΜ 5ZQF4DSJQUͰͭ͘Δ /PEFKTύοέʔδ 'VLVPLBKTň5ZQF4DSJQUʼn