TypeScript/ํ์
์คํฌ๋ฆฝํธ TypeScript
[ํ์ ์คํฌ๋ฆฝํธ] .d.ts ์ ๋ํ ์ดํด
Rainbow๐Coder
2022. 5. 4. 16:26
728x90
https://typescript-kr.github.io/pages/declaration-files/creating-dts-files-from-js.html
https://spookyjelly.tistory.com/39
.d.ts ์ ๋ํ ์ดํด๊ฐ ์์ด์ผ ํ๋ค.
Js ํ์ผ์ js ํ์ผ๋ผ๋ฆฌ๋ง ๋ฐ๋ผ๋ณผ ์ ์๋ค
Ts ํ์ผ์ ts ํ์ผ๋ผ๋ฆฌ๋ง ๋ฐ๋ผ๋ณผ ์ ์๋ค
TypeScript 3.7์์, TypeScript๋ JSDoc ๊ตฌ๋ฌธ์ ์ฌ์ฉํ JavaScript์์ .d.ts ํ์ผ์ ์์ฑํ ์ ์๊ฒ ๋์๋ค.
๐.d.ts ํ์ผ์ ๊ธฐ์กด JS ๋ชจ๋์ ํ์ ์คํฌ๋ฆฝํธ์์ ์ฌ์ฉํ๊ธฐ ์ฉ์ดํ๋๋ก ๊ธฐ์กด JS ๋ชจ๋์ ํ์ ์ ๋ณด๋ฅผ ๋ณ๋์ ํ์ผ๋ก ์ ์ธํ๊ฒ๐
๐งจd.ts ํ์ผ์ ํ์ ์ ์ธ๋ง ์ด๋ฃจ์ด์ง์ ์ ์๐งจ
d.ts ์์ฑ๋ฒ
- @types ์์ ํด๋น ๋ชจ๋๋ช ์ ๋๋ ํ ๋ฆฌ ์์ฑ
- ์์ฑํ ๋๋ ํ ๋ฆฌ ์์ index.d.ts ์์ฑ
- export ํ ํ์ ์ ์ธํฐํ์ด์ค ์ ์ธ
- ํด๋น ์ธํฐํ์ด์ค ํ์ ์ ๋ณ์ (์์ ๋ฌด๊ด) ์ ์ธ
- export ์ ์ธ
d.ts๊ฐ ์๋ ์ผ๋ฐ ts ํ์ผ ๋ด์์๋ declare global๋ก ์ ์ธํด๋ ๋๋ค
728x90