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
610
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
800
READMEにバッヂが欲しくてテストを書き始めました
yusukehirao
1
750
ユニバーサルなマークアップをしよう
yusukehirao
2
880
アクセシビリティチェックを自動化するためのmarkuplintのロードマップ
yusukehirao
2
2.1k
本当に必要ですか?そのJavaScript 〜スクロールイベント・リサイズイベント編〜
yusukehirao
0
590
コードレビュー なんてしてられるかッ!!
yusukehirao
24
14k
自動化をデザインしよう
yusukehirao
1
880
JSONの型のはなし
yusukehirao
0
600
トランスパイラという文化(…とその後) - PHPカンファレンス福岡2016
yusukehirao
1
2.7k
Other Decks in Technology
See All in Technology
2024AWSで個人的にアツかったアップデート
nagisa53
1
110
JAWS-UG20250116_iOSアプリエンジニアがAWSreInventに行ってきた(真面目編)
totokit4
0
140
AWSマルチアカウント統制環境のすゝめ / 20250115 Mitsutoshi Matsuo
shift_evolve
0
120
機械学習を「社会実装」するということ 2025年版 / Social Implementation of Machine Learning 2025 Version
moepy_stats
5
1.2k
Kotlin Multiplatformのポテンシャル
recruitengineers
PRO
2
150
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
170
Formal Development of Operating Systems in Rust
riru
1
420
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.5k
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
あなたの知らないクラフトビールの世界
miura55
0
130
デジタルアイデンティティ人材育成推進ワーキンググループ 翻訳サブワーキンググループ 活動報告 / 20250114-OIDF-J-EduWG-TranslationSWG
oidfj
0
540
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
290
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Building Adaptive Systems
keathley
38
2.4k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Code Reviewing Like a Champion
maltzj
521
39k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Building Applications with DynamoDB
mza
93
6.2k
For a Future-Friendly Web
brad_frost
176
9.5k
Agile that works and the tools we love
rasmusluckow
328
21k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
How STYLIGHT went responsive
nonsquared
96
5.3k
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