Definitions by:
in index.d.ts
์ฐธ์กฐ) ๋๋ตํ๋ค.#11365, #11365 ๋ฐ #17846์ ๋ํ ๋์ฒด ์ถ์ ๋ฌธ์ ๋ก ์ด ๋ฌธ์ ๋ฅผ ๋ง๋ค๊ณ ์์ต๋๋ค.
๋ค์์ D3 ๋ชจ๋ ์ ์์ ๊ด๋ จ๋ ๊ฐ์ /๊ธฐ์ ๋ถ์ฑ๋ฅผ ์ถ์ ํ๊ธฐ ์ํ ํ์ ๋๋ค.
strictNullChecks
์ ๋ํด ๊ฒ์ฆ๋์์ผ๋ฉฐ ์ปดํ์ผ๋ฌ ์ต์
์ด true
๋ก ์ค์ ๋์์ต๋๋ค.strictFunctionTypes
์ ๋ํด ๊ฒ์ฆ๋์์ผ๋ฉฐ ์ปดํ์ผ๋ฌ ์ต์
์ด true
๋ก ์ค์ ๋์์ต๋๋ค.| ์ ์| JSDoc | strictNullChecks
| strictFunctionTypes
| TS 2.3
|
| --- | --- | --- | --- | --- |
| d3 | ํด๋น ์์ | ๐ฒ | ๐ฒ | โ
|
| d3 ๋ฐฐ์ด | ๐ฒ | โ
| ๐ฒ | ๐ฒ |
| d3์ถ | โ
| โ
| โ
| โ
|
| d3-๋ธ๋ฌ์ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ์ฝ๋ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ์ปฌ๋ ์
| โ
| โ
| โ
| โ
|
| d3์ | ๐ฒ | โ
| โ
| โ
|
| d3 ์ค๊ณฝ | โ
| โ
| โ
| ๐ฒ |
| d3-๋์คํจ์น | โ
| โ
| โ
| โ
|
| d3-๋๋๊ทธ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3-dsv | โ
| โ
| ๐ฒ | ๐ฒ |
| d3-์ด์ฆ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ๊ฐ์ ธ์ค๊ธฐ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3-ํฌ์ค | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ํ์ | โ
| โ
| โ
| โ
|
| d3-geo | โ
| โ
| โ
| โ
|
| d3-ํฅ์ค๋น | ๐ฒ | ๐ฒ | ๐ฒ | ๐ฒ |
| d3 ๊ณ์ธต | ๐ฒ | ๐ฒ | ๐ฒ | ๐ฒ |
| d3 ๋ณด๊ฐ | ๐ฒ | ๐ฒ | ๐ฒ | ๐ฒ |
| d3-๊ฒฝ๋ก | โ
| โ
| ๐ฒ | ๐ฒ |
| d3-ํด๋ฆฌ๊ณค | โ
| โ
| โ
| โ
|
| d3 ์ฟผ๋ ํธ๋ฆฌ | ๐ฒ | ๐ฒ | ๐ฒ | ๐ฒ |
| d3 ํ | โ
| ๐ฒ | ๐ฒ | ๐ฒ |
| d3-๋ฌด์์ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3-์์ฒญ | ๐ฒ | ๐ฒ | ๐ฒ | ๐ฒ |
| d3-sankey | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ์ค์ผ์ผ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ์ค์ผ์ผ ๋ฐ์๊ณ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ์ ํ | โ
| โ
| โ
| ๐ฒ |
| d3-selection-multi | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ๋ชจ์ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3์๊ฐ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ์๊ฐ ํ์ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3 ํ์ด๋จธ | โ
| ๐ฒ | ๐ฒ | ๐ฒ |
| d3-์ ํ | โ
| โ
| ๐ฒ | ๐ฒ |
| d3-๋ณด๋ก๋
ธ์ด | โ
| ๐ฒ | ๐ฒ | ๐ฒ |
| d3 ํ๋ | โ
| โ
| ๐ฒ | ๐ฒ |
ํต์ฌ ํ ์ ์ง ๊ด๋ฆฌ์ "์ธ๋ถ":
| ๋ชจ๋ | JSDoc | strictNullChecks
| strictFunctionTypes
| TS 2.3
|
| --- | --- | --- | --- | --- |
| d3-hsv | โ
| โ
| โ
| โ
|
@gustavderdrache @Ledragon ์์์ D3 ์ ์ ์ธํธ์ธ ์ํ์ ๋ง๋ฌด๋ฆฌํ๊ธฐ ์ํด ๋ช ๊ฐ์ง ๋ฏธํด๊ฒฐ ์์ ์ ํตํฉํ์ต๋๋ค.
ํต์ฌ ์ง๋ฌธ: ๋ชจ๋ ์ ์๋ฅผ TS >=2.3 ์ ์ฝ ์กฐ๊ฑด์ผ๋ก ์ผ๊ด๋๊ฒ ์
๊ทธ๋ ์ด๋ํ๊ณ ๊ทธ ๊ณผ์ ์์ ์ ๋ค๋ฆญ์ ๋ํ ๊ธฐ๋ณธ ํ ๋น์ ์ฌ์ฉํ์ฌ ์ผ๋ถ ๊ธฐ๋ฅ/๋ฉ์๋ ์ค๋ฒ๋ก๋๋ฅผ ์ ๊ฑฐํ์๊ฒ ์ต๋๊น?
(์ค์๋ก) ์ผ๋ถ ์ ์์๋ ์ด๋ฏธ ์ ์ ํค๋์ // TypeScript Version: 2.3
์ ์ฝ ์กฐ๊ฑด์ด ์๋ ๊ฒ์ผ๋ก ๋ํ๋ฌ์ต๋๋ค. ์: geoJson
์ ์๋ฅผ ์ฌ์ฉํ๋ d3-geo . ์ด๋ค์ ์ด๋ฏธ ์ผ๋ฐ ๊ธฐ๋ณธ๊ฐ์ ์ฌ์ฉํฉ๋๋ค.
์ด ๋ฌธ์ ์ ๋ํ ๊ทํ์ ์๊ฐ์ ๋ฌด์๋ณด๋ค ํ์ํ ๊ฒ์ ๋๋ค.
์ด๊ฒ์ ์ดํดํ๊ณ ๊ณต๋ถํด์ผํฉ๋๋ค
์ต์ TS 2.3์ ๊ตฌํํ๋ ๊ฒฝ์ฐ ์ ์ ํ ๊ฒฝ์ฐ any
๋์ object
์ ํ์ ์ฌ์ฉํ ์๋ ์์ต๋๋ค. TS 2.2์ ํจ๊ป ์ ๊ณต๋ฉ๋๋ค. ์ ๊ธฐ์ต์ด ๋ง๋ค๋ฉด ๊ฐ์ฒด ๋ณด๊ฐ๊ธฐ์ d3-collection์ ๋ช ๊ฐ์ง ๊ธฐํ๊ฐ ์์์ต๋๋ค.
์ฒซ ๋ฒ์งธ ์๊ฐ:
strictNullChecks
๋ฐ strictFunctionTypes
๊ฐ ์๋ ์ง์ ์ด ์์ต๋๋ค . ์
๋ฐ์ดํธํ์ฌ PR์ ์ ์ถํ๊ฒ ์ต๋๋ค. ํ๋ ์ค ์์๋๋ฐ ์๋ ๊ฒ ๊ฐ๋ค์ด์ ๋ํ ์๊ฒฌ์ด ์๊ธฐ ์ ์ ๊ธฐ๋ณธ ์ ๋ค๋ฆญ์ ๋ํด ๋ฐฐ์์ผ ํฉ๋๋ค.p
TS 2.3๊ณผ ํจ๊ป ์ฐ๋ฆฌ๋ 2017๋
4์์ ๋ฆด๋ฆฌ์ค๋ฅผ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ต๋๋ค.
TS 2.4๋ 2017๋
6์์ ๋ฆด๋ฆฌ์ค๋์์ต๋๋ค.
๋ฐ๋ผ์ ๊ฐ์ฅ ํฐ ์ง๋ฌธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ์ต์ 2.4(2.3์ด ์๋)๋ฅผ ๊ฐ์ ์ ์ฉํ ๋ ์ค์น ๊ธฐ๋ฐ์ ์ผ๋ถ ๋๋ ๋ฌด์ํ ์ ์๋ ๋ถ๋ถ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๊น?
์ถ๊ฐ๋ ๊ณผ์ ์ค ํ๋๋ D3 ์ ์๊ฐ ์ฌ์ฉ๋๋ ๋ฐฉ์์ ๋ํ ์ ์ฌ์ ์ธ ์ฃผ์ ๋ณ๊ฒฝ ์ฌํญ์ ํ๋๊ทธ๋ฅผ ์ง์ ํ๋ ๋ณ๊ฒฝ ๋ก๊ทธ ์์ฒด๊ฐ ์๋ค๋ ๊ฒ์ ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ธฐ๋ณธ D3 ๋ฆด๋ฆฌ์ค ์ฃผ๊ธฐ์ ์ ๋ ฌ๋์ด ์๊ธฐ ๋๋ฌธ์ ์ ์์ ๋ง์ด๋ ๋ฒ์ ๋ฆด๋ฆฌ์ค์์ ์ฃผ์ ๋ณ๊ฒฝ ์ฌํญ์ด ๋ฐ์ํ ์ ์๋ค๋ ๋ช ๋ฐฑํ ๋จ์ ์ด ์์ต๋๋ค.
@gustavderdrache ์๋ก์ด ์ต์ ์ฌ์์ผ๋ก TS 2.4์ ๋ํด ์ด๋ป๊ฒ ์๊ฐํ์ญ๋๊น?
PR #23654์์ ๋ณผ ์ ์๋ฏ์ด TS 2.4๋ก ์ด๋ํ ๋ ๋น ๋ฅด๊ฒ ์บ์ค์ผ์ด๋ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค(๋ฌธ์์ด ์ด๊ฑฐํ๊ณผ ๊ฐ์ TS 2.4 ๊ธฐ๋ฅ์ ์ฌ์ฉํ์ง ์๊ณ DT๋ฅผ ์ํด ์ ์ฝ ์กฐ๊ฑด์ ๋ถ๊ณผํ๋ ๊ฒฝ์ฐ์๋).
์๋ก์ด PR #23724์ ๋ฐ๋ผ ๋ช ํ์ฑ์ ์ํด TS 2.3์ ์ฌ์ฉํ์ฌ ์งํํ ์ ์์ต๋๋ค. ํ์ฌ๋ก์๋ TS 2.4๋ฅผ ์ถ์งํ ํ์๊ฐ ์์ต๋๋ค.
@Ledragon ๋ก์ปฌ d3-geo ํฌํฌ์์ ์ด๋ฏธ ๋ณด๋ฅ ์ค์ธ PR์ ์ด๋ ค๋ฉด ์์ ํ์ธ๋์ ์ ํํ์ฌ ์์ ํ ์ ์์ต๋๋ค.
์ค์ ๋ก ๋ก์ปฌ์์ ํ ์คํธ๋ฅผ ํ ์๋ ์์ต๋๋ค... ๊ทธ๋์ ์ ์ถํ ์ ์์ ๊ฒ ๊ฐ์ง๋ง ํธ๋๋น์ค ํ ์คํธ๋ฅผ ํต๊ณผํ ๊ฒ ๊ฐ์ง๋ ์์ต๋๋ค. ๊ทธ๋ฅ ๊ฐ์ ๋ณผ๊ฒ
์, ๋ฌธ์ ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. d3-geo
ํ
์คํธ๋ TS 2.3์์ ์คํจํ์ต๋๋ค. ๊ทธ๋์ ๋ฒ์ ์ 2.4๋ก ์ค์ ํด ๋ณด์์ต๋๋ค. ๊ทธ๋ฌ๋ d3
global์ TS 2.3์ผ๋ก ์ค์ ๋์ด ์์ด์ ์ด๊ฒ๋ ์๋ํ์ง ์์ต๋๋ค. ์งํ ๋ฐฉ๋ฒ์ ๋ํ ์กฐ์ธ์ด ์์ต๋๊น?
๋๋ g3-geo PR์ ์ดํด๋ณด๊ณ ๊ทธ๋ค์ด ์ง์คํ ์ ์๋๋ก ๋ฆฌ๋ทฐ ์ฝ๋ฉํธ๋ฅผ ๊ฑฐ๊ธฐ์ ๋ ๊ฒ์ ๋๋ค. d3-collection ์์ ๊ฐ์ง๊ณ ์์๋ OoM ๋ฒ๊ทธ์ ๋ฌ๋ฆฌ, ์ฐ๋ฆฌ๋ ์์ ํ ์ ์ ํ ์ค๋ฅ ๋ฉ์์ง๊ฐ ์์ต๋๋ค ๐
d3-contour
๋ฅผ 1.2.0์ผ๋ก ์
๋ฐ์ดํธํ๊ธฐ ์ํด #24118์ ๋ฐฉ๊ธ ์ ์ถํ์ต๋๋ค.
d3-contour
์ ํ์ด ์ด๋ฏธ TS2.3
์ ์๊ณ strictNullChecks
๋ฐ strictFunctionTypes
๊ฐ true๋ก ์ค์ ๋์ด ์์์ ์์์ต๋๋ค :-)
d3-contour ์์ ๋จธ๋ฌผ๋ฌ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค. ์ด์ํ ์ด์ ๋ก "Watching"์ ๋ํ ๋ฆฌํฌ์งํ ๋ฆฌ๊ฐ ์๋ค๋ ๊ฒ์ ์๊ฒ๋์์ต๋๋ค. ๋ณ๊ฒฝํ์ต๋๋ค! :์๋ค:
๊ณง PR์ ๋ณผ ๊ฒ์ ๋๋ค.
์ ๋ d3์ถ ๋ฐ d3 ํ์์์ ์์ ํ๊ณ ์์ต๋๋ค. ๊ฑฐ์ ๋๋ฌ์ด์. ํ์ง๋ง ์ง๋ฌธ์ด ์ข...
d3 ํ์์์๋ d3 ๋ฐฐ์ด์์์ ๋์ผํ Numeric
์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์ต๋๋ค.
interface Numeric {
valueOf(): number;
}
๊ทธ๋ฌ๋ ์ด๊ฒ์ ํ ๋ d3 ์ ์ญ ์ ์์์ ๋
ผ๋ฆฌ์ ์ผ๋ก ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. Module 'd3-array' has already exported a member named 'Numeric'.
d3 ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ๊ณต์ ์ ํ์ ๋ฃ์ ์ฅ์๊ฐ ์์ต๋๊น?
๋ํ ์ผ๋ถ d3 ์ ์(interpolate, scale, shape)์์ ํตํฉ ์ ํ number | { valueOf(): number }
์ ์ฐพ์ ์ ์์ต๋๋ค. { valueOf(): number }
์ถฉ๋ถํ์ง ์์ต๋๊น?
@denisname d3-axis
, d3-format
๋ฐ ์ดํ d3-array
์์๋ด์ฌ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค !!!
์์ ์ง๋ฌธ์:
(1) d3-xxx
๋ชจ๋์ ๋ํ ์ ์๋ฅผ ์์ฑํ๊ธฐ ์ํ ๊ธฐ๋ณธ ๊ท์น์ผ๋ก ์ ์๋ ๊ธฐ๋ณธ ํด๋น D3 ๋ชจ๋ ๊ฐ์ ์กด์ฌํ์ง ์๋ ์ข
์์ฑ์ ๋์
ํด์๋ ์ ๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด d3-axis
์๋ d3-array
์ ๋ํ ์ข
์์ฑ์ด ์์ผ๋ฏ๋ก d3-axis ์ ๋ํ ์ ์ index.ts
ํ์ผ์ d3-axis
d3-array
์์ ๊ฐ์ ธ์ค์ง ์์์ผ ํฉ๋๋ค. ์ด๊ฒ์ JS ์์ค์ ํด๋นํ๋ ๋์จํ ๊ฒฐํฉ์ ๋ณด์ฅํฉ๋๋ค. ๋ฐ๋ผ์ ์์ฌ์ค๋ฌ์ด ๊ฒฝ์ฐ ๊ธฐ๋ณธ D3 ๋ชจ๋ package.json
์ dependencies
์์ฑ์ ํ์ธํ์ญ์์ค. _์ฐธ๊ณ : ๋ฌผ๋ก d3-xxx-test.ts
ํ์ผ์ ๋ชจ๋ ํจํค์ง์์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. ์ฐ๋ฆฌ๋ "ํตํฉ" ํ
์คํธ๋ฅผ ์ํด ์ฌ๋ฌ ํจํค์ง์์ ๋ฐ๋์ต๋๋ค. ์ฆ, ๋ ํจํค์ง ์ฌ์ด์ ํ์์ ์ธ ์ข
์์ฑ์ด ์์ ์ ์์ง๋ง ํ๋์ ๋ฉค๋ฒ๋ "์์ฐ์ค๋ฝ๊ฒ" ๋ค๋ฅธ ํจํค์ง์ ๋ํ ์
๋ ฅ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด ์ฝ๋ ๊ฒฝ๋ก๊ฐ ๋ฌธ์ ์์ด ์ ํ ์์ฑ ์ค์ ๊ธฐ๋ก ์ ๋ฌ๋ ์ ์๋๋ก d3-chord
d3-selection
์ฌ์ฉํ๊ณ ์์ต๋๋ค._
(2) Numeric
์ธํฐํ์ด์ค๋ ๊ท์น (1)์ ๋ฐ๋ผ d3-array
์์ ๊ฐ์ ธ์ฌ ์ ์๋ ๋ค๋ฅธ D3 ๋ชจ๋์์ ๋ค์ ์ ์ธํ ์ ์์ต๋๋ค.
(3) { valueOf(): number }
๊ฐ ๋ถ์กฑํฉ๋๊น? ๊ธฐ์ ์ ์ผ๋ก ๊ทธ๋ ์ต๋๋ค. ์ค์ ๋ก, ๊ต์ฐจ ์ ํ์ ์ฝ๊ฐ์ ์ค๋ณต์ฑ์ด ์์ง๋ง ๋ง์ ์ธ๊ฐ ์ฌ์ฉ์์๊ฒ ์ ์ธ์ ์ผ๋ก ๋ ๋ช
ํํ ๊ฒ์
๋๋ค. ์ฆ, number
๋ ์ ์ ๊ณก์ ์์ด ์ธ๋ป ๋ณด๊ธฐ์ ์ ํจํ ์ ํ์์ ๋ณด์ฌ์ค๋๋ค. :๋์ง:
d3-color์ ๋ํด prototype
๊ฐ ๋ชจ๋ ์ฃผ์ ์ฒ๋ฆฌ๋ ์ด์ ๋ ๋ฌด์์
๋๊น? @tomwanzek๊ฐ ์ด ์ปค๋ฐ ์์ ์ํํ์ต๋๋ค.
ํ๋กํ ํ์
์ ๋ค์ ์ค์ ํ๋ฉด typeguard ๊ธฐ๋ฅ ์์ด instanceof
๋ฅผ ์ง์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
let cRGB: d3.RGBColor;
let cHSL: d3.HSLColor;
const c: d3.RGBColor | d3.HSLColor = d3.color("steelblue");
if (c instanceof d3.rgb) {
cRGB = c;
} else {
cHSL = c;
}
@denisname ์ธํฐํ์ด์ค์ ๊ฒ์๋ API์ ์ผ๋ถ๋ก prototype
๋ฅผ ์ ์ํ๋ ๊ฒ์ ์ฃผ์ ํ์ต๋๋ค. ๋๋ฌด ํดํน๋ ๊ฒ ๊ฐ์ต๋๋ค.
์ค๋์ type Guards spec ์์ ๋ด๊ฐ ์ดํดํ ๊ฒ์ . ์ด๊ฒ์ ์ด์ ์ ํจํ _๊ฑด์ค_์ผ๋ก ๊ฐ์ฃผ๋ฉ๋๋ค. ๋ชฉ๋ก ํญ๋ชฉ์ ์ฐธ์กฐํ์ญ์์ค.
x instanceof C
ํ์์ ์ ํ ๊ฐ๋, ์ฌ๊ธฐ์ x๋ Any ์ ํ์ด ์๋๊ณ ,C
๋ ์ ์ญ ์ ํ 'Function'์ ํ์ ์ ํ์ด๋ฉฐ,C
์๋ ๋ค์๊ณผ ๊ฐ์ ์์ฑ์ด ์์ต๋๋ค. 'ํ๋กํ ํ์ ' [...]
d3-color
์ strictNullChecks
๋ฒ์ ์ ์ ์ํ๊ณ ์ถ์ต๋๋ค. ๋จ ํ ์ค์ ๋ณ๊ฒฝ ์ฌํญ์
๋๋ค. prototype
๋ ์ถ๊ฐํ ์ ์๋ ๊ธฐํ์
๋๋ค.
๋ด ํ
์คํธ์์ $# instanceof
์ ๋ํ prototype
์์ฑ์ด๋ new(): T
์ ์ธ์ด ํ์ํ์ฌ ์ ํ์ ์ ์ ํ๊ฒ ์ขํ ์ ์์ต๋๋ค. ๋๋ v3 ํ์ดํ์์ new(): Color
๋ณํ์ ์ฌ์ฉํ๊ณ ํด๋น ๊ด์ฉ๊ตฌ๊ฐ D3v4 ์ด์์์ ์ฌ์ ํ ์ง์๋๋ค๋ฉด ์ ์ฉํ ์ ์์ต๋๋ค.
๋ ์ค ํ๋๊ฐ ๊ด์ฐฎ์ ๋ณด์ด๋ฏ๋ก ์ฐ์์ฑ์ ์ํด v3 ๊ท์น์ ๋ฐ๋ฅผ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ํ๋ฅญํ ์ํ์ ๋๋ค. ๋ ๋ค.
@gustavderdrache
d3 v3์์ ์๋ํ๋ ์ด์ ๋ new()
์ ๋ฐํ ์ ํ์ด ํญ์ prototype
์ ํ๊ณผ ๋์ผํ๋ค๋ ๊ฒ์
๋๋ค. ๊ทธ๋ฌ๋ d3 v4์๋ ๋ค์๋ ์์ต๋๋ค.
export const color: ColorFactory;
export interface ColorFactory extends Function {
(cssColorSpecifier: string): RGBColor | HSLColor;
prototype: Color; // and not RGBColor | HSLColor !
}
์ค์ ๋ก d3.lab(0,0,0) instanceof d3.color
๋ ์ฌ์ค์
๋๋ค. ๋ฐ๋ผ์ ์ด ์ธํฐํ์ด์ค๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ๋ฉด
export const color: ColorFactory;
export interface ColorFactory extends Function {
(cssColorSpecifier: string): RGBColor | HSLColor;
new (cssColorSpecifier: string): RGBColor | HSLColor;
}
ColorFactory
์ ํ Color
์๋ $#$ prototype
$#$ ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ค์ ์ฝ๋๋ ์ปดํ์ผ์ ์คํจํ์ง๋ง ๊ทธ๋ ๊ฒ ํด์๋ ์ ๋ฉ๋๋ค.
declare let l: d3.LabColor | null;
declare let c: d3.Color;
declare let nil: null;
if (l instanceof d3.color) {
c = l; // l is not inferred as `d3.LabColor`...
} else {
nil = l; // fail, l is a `d3.LabColor | null` should be a `null`
}
๋น์ ์ ์๊ฒฌ ๊ฒ์
๋๋ค? new
์ ํจ๊ป ์๋ํ๋๋ก ํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น? ๊ฐ์ฌ ํด์.
์ผ๋ถ ํ
์คํธ์ ๋ฐ๋ฅด๋ฉด color()
์ ๋ํ prototype
์์ฑ์ $#$ RGBColor | HSLColor
Color
$์ฌ์ผ ํฉ๋๋ค.
> d3.color.prototype === d3.rgb.prototype
false
> d3.rgb.prototype instanceof d3.color
true
color()
ํจ์๋ RGB ๋๋ HSL ์์์ ๋ฐํํ์ง๋ง ํด๋น ํ๋กํ ํ์
์ ๋ค๋ฅธ ์์ ๊ณต๊ฐ์ ์์ ์ ํ์
๋๋ค.
@denisname @Ledragon @gustavderdrache ์ฌ๋ฌ๋ถ์ด ์ด ์ค๋ ๋์ ๋ชจ๋ ์ฐธ์ฌํ๊ณ ์๊ธฐ ๋๋ฌธ์ ๊ฐ๋ตํ ์ฐธ๊ณ ์ฉ์ผ๋ก: ์ด๋ฒ ์ฃผ๋ง์ ์ฌ๋ฌ๋ถ์ด ์๊ณ ์๋ ๊ณต๊ฐ ํญ๋ชฉ์ ๋ฐ๋ผ์ก์ ์๊ฐ์ ๋๋ค.
์, d3-geo๊ฐ ๋ฌธ ๋ฐ์ ์์ต๋๋ค(@ledragon์๊ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค). @denisname ์ ๋ถํํ๋ d3-format
๋ฐ d3-axis
์ ๋ํ ํ์๋ PR์ ๋ํด ์ธ๊ธํ์ต๋๋ค.
์ผ๋ฐ์ ์ผ๋ก @denisname ์ ์ ์์ ๋ํ ๋ค๋ฅธ ์ ์ง ๊ด๋ฆฌ์๋ก ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ค์์ d3-color
๋ฅผ ์ดํด๋ณด๊ณ 1.1.0 ์ผ๋ก ์
๋ฐ์ดํธํ์ฌ ํฉ๋ฅํ ์ ์์ต๋๋ค. ์ด ์
๊ทธ๋ ์ด๋์ ๋ํด ๋ณ๋์ ๋ฌธ์ ๋ฅผ ์ด์ด์ผ ํฉ๋๊น?
๋ํ @denisname ์ ์ค์ ๊ฒ์ ํ์ํฉ๋๋ค!
@Ledragon ๊ฐ์ฌํฉ๋๋ค.
d3-color
์ ๋ํ ์
๋ฐ์ดํธ๊ฐ ์ค๋น๋์ด ์์ต๋๋ค( lhc
๋ฐ gray
๋ ์์ง ์์). ๋๋ ๋จ์ง ํ๋์ ์์ ๋ฌธ์ ๋ก ๋งํ์ต๋๋ค.
@gustavderdrache ๋ ๋ค์๊ณผ ๊ฐ์ด ๋งํ์ต๋๋ค.
color() ํจ์๋ RGB ๋๋ HSL ์์์ ๋ฐํํ์ง๋ง ํด๋น ํ๋กํ ํ์ ์ ๋ค๋ฅธ ์์ ๊ณต๊ฐ์ ์์ ์ ํ์ ๋๋ค.
์ค์ ๋ก ์ด๊ฒ์ ์ฝ๊ฒ _typed_ํ ์ ์์ต๋๋ค. ๋ด ์๊ฒฌ ์ ์ฒซ ๋ฒ์งธ ์ธํฐํ์ด์ค๋ฅผ ์ฐธ์กฐํ์ญ์์ค. ๊ทธ๋ฌ๋ @tomwanzek ์ new()
๋ง ์ฌ์ฉํ๊ณ prototype
๋ ํผํ๋๋ก ์ ์ ํ์ต๋๋ค. ์ด ํน๋ณํ ๊ฒฝ์ฐ์๋ ๋ถ๊ฐ๋ฅํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ์๋์?...
์ข ๋ ๊ฐ์ง๊ณ ๋๊ณ ๋๋ฉด ๋ฌธ์ ๊ฐ ๋ณด์
๋๋ค. ColorConstructor
์ธํฐํ์ด์ค์์ new(): Color
๋ฅผ ์ค์ ํ ์ ์์ง๋ง ์ค์ ๋ก๋ ํจ์์ ๋ฐํ ๊ฐ์ ๋ค๋ฃจ์ง ์์ต๋๋ค.
declare namespace d3 {
interface Color {
// I forgot what was on the Color interface
// This property exists just to make Color incompatible with {}
__isColor: never;
toString(): string;
}
interface RGBColor extends Color {
r: number;
g: number;
b: number;
}
interface HSLColor extends Color {
h: number;
s: number;
l: number;
}
interface LABColor extends Color {
l: number;
a: number;
b: number;
}
interface ColorConstructor {
(specifier: string): RGBColor | HSLColor;
new(specifier: string): Color; // <- TS uses this for narrowing with instanceof
}
const color: ColorConstructor;
}
declare let l: d3.LABColor | null;
declare let c: d3.Color;
declare let nil: null;
if (l instanceof d3.color) {
// Succeeds with l: d3.LABColor
c = l;
} else {
// Succeeds with l: null
nil = l;
}
๊ฒฐ๋ก : prototype
์์ฑ์ ๋
ธ์ถํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ์๋ํ๋ฉด ์ด๊ฒ์ด ์์ฑ์์ instanceof
ํ
์คํธ์ ์ฌ๋ฐ๋ฅธ ๋์์ ๋ค๋ฃจ๋ ์ ์ผํ ๋ฐฉ๋ฒ์ด๊ธฐ ๋๋ฌธ์
๋๋ค.
interface ColorConstructor {
(specifier: string): RGBColor | HSLColor;
new(specifier: string): RGBColor | HSLColor;
readonly prototype: Color;
}
์ฃ์กํฉ๋๋ค. ์ด ๋ฌธ์ ์ ๋ํ ๋ต๋ณ์ด ๋ฆ์ด์ ธ ์ฃ์กํฉ๋๋ค. ์์ ๋กญ๊ฒ prototype
๋ฅผ ์ฌ์ฉํ์ญ์์ค. ๋น์์๋ instanceof
๋ ๋ค๋ฃจ๋ ค๋ ์ฒซ ๋ฒ์งธ ์ถฉ๋์ด์์ต๋๋ค. ๊ทธ๋ฅ "๋๋"์ด ๋ฌ์ง๋ง ํ์ฉ ๊ฐ๋ฅํ ๊ดํ์ผ๋ก ๊ฐ์ฃผ๋๊ณ D3v3์์์ ๊ฐ์ด new()
๋ฅผ ๊ณ์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ต์
์ด ์๋ ๊ฒฝ์ฐ...ํจ๊ณผ๊ฐ ์๋ ๊ฒ์ผ๋ก ๊ฐ์!
@tomwanzek ์์ ์ถ์ ํ ์ด๋ธ์ ์ ๋ฐ์ดํธํ ์ ์์ต๋๋ค.
d3-axis
, d3-color
, d3-dispatch
, d3-format
๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ฒฝ์ฐ $ strictNullChecks
strictFunctionTypes
๋ฐ TS 2.3
์ด์ โ
๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค. d3-format
, d3-polygon
๋ฐ d3-hsv
.
๋ํ d3-dispatch
, d3-polygon
๋ฐ d3-hsv
$ ์ ๋ํด $ JSDoc
์ด์ โ
๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
๊ฐ์ฌ ํด์
d3-geo
์ธํฐํ์ด์ค GeoIdentityTranform
์ ์คํ๊ฐ ์์ต๋๋ค. GeoIdentityTransform
( s
ํฌํจ)์ฌ์ผ ํฉ๋๋ค. ์์ ํด๋ ๋ ๊น์? ์ด์ ๋ฒ์ ๊ณผ์ ํธํ์ฑ์ ๋ํ ์ฐ๋ ค ์ฌํญ์ด ์์ต๋๊น?
@denisname for d3-geo
s GeoIdentityTranform
, ๋ค์์ ์ํํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
geoIdentity()
์ ๋ฐํ ์ ํ์ผ๋ก ์ฌ์ฉ ํฌํจ)/**
* <strong i="13">@deprecated</strong> Misspelled name. Use GeoIdentityTransform.
*/
export type GeoIdentityTranform = GeoIdentityTransform;
@denisname ๐ฏ @gustavderdrache @ledragon ์ง๋ ์งง์ ์๊ฐ ๋์ ๋ชจ๋ ์๊ณ ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ์ถ์ ํ ์ด๋ธ์ ์ ๋ฐ์ดํธํ๋๋ฐ ๋ฒ์จ ํจ์ฌ ๋ ์๋ป์! ์์ ์ถ์ ํ ์ด๋ธ์ด ์ฐ๋ฆฌ๊ฐ ์ฌ๊ธฐ์ ๋ชฉํ๋ก ํ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ๋๋ค :์ค๋ง์ผ:
์์ ์ถ์ ํ ์ด๋ธ์ด ์ฐ๋ฆฌ๊ฐ ์ฌ๊ธฐ์ ๋ชฉํ๋ก ํ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์
์ ์ ์ผ๋ก! ๊ฐ์ ๋ ์ ํ ์ ์๋ ์ฆ๊ฑฐ์ด ๋ถ์์ฉ์ผ ๋ฟ์ ๋๋ค.
๊ธฐ์ ๋ถ์ฑ์ ์์ฑ์ ์ํด ์ง๊ธ ๊ตฌ์ฒด์ ์ธ ์ ์๋ฅผ ๋ด๋ฆฌ๊ณ ์๋ ์ฌ๋์ด ์์ต๋๊น? d3-array ๊ฐ ์งํ๋๋ ๋์. ๋๋ strictFunctionTypes
in d3-transition ์ ์ฒ๋ฆฌํ๊ณ d3-selection ๊ณผ ํจ๋ฆฌํฐ๋ก ๊ฐ์ ธ์ต๋๋ค. #25805๊ฐ ๋ณํฉ๋๊ธฐ๋ฅผ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ต๋๋ค.
ATM์ด ์๋๋๋ค. ๋ด๊ฐ ํ๋ฉด ์ธ์ ํ๋์ง ๋ชจ๋ ์๋ ค์ค๊ฒ
5.2.0 ๊ธ๋ก๋ฒ ๋ฒ๋ค์ ์คํฌํ๋ฅผ ์ฐ์ ์ ์๋๋ก #25582 ์์ ์ค
d3-hierarchy
์ ๋ํ ์
๋ฐ์ดํธ๊ฐ ์ค๋น๋์ด ์์ต๋๋ค(strict ๋ฐ jsDoc).
d3-dsv
๋ฐ d3-fetch
๋ ์์
์ค์
๋๋ค(ts 2.3).
@denisname @tomwanzek @gustavderdrache
์ด๊ฒ์ ์ง์คํด์ผ ํ ๊น์, ์๋๋ฉด d3๋ฅผ ์ต์ ๋ฒ์ ์ผ๋ก ์
๋ฐ์ดํธํด์ผ ํ ๊น์? ์ฐ๋ฆฌ๋ ์ด์ ๊ธ๋ก๋ฒ ํจํค์ง์ ๋ํด 5๊ฐ์ ๋ง์ด๋ ๋ฒ์ ์ด ์์ต๋๋ค(๋ชจ๋ ํ์ ํจํค์ง๊ฐ 5.2.0
์ ๋ํด ์ค๋น๋์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค). ๊ธ๋ก๋ฒ ํจํค์ง ์ํ๋ฅผ ์ถ์ ํ๊ธฐ ์ํด ๋ณ๋์ ๋ฌธ์ ๋ฅผ ์ด์ด์ผ ํฉ๋๊น?
@Ledragon ์ค๋ ๋ฐค ์ด๋ฆฐ PR์ ๋ฐ๋ผ ์ก๊ณ ํตํ์ ๋ํ ๋ชจ๋ D3 ๋ชจ๋ ์ ์๋ฅผ ๊ตฌ๋ฌธ ๋ถ์ํฉ๋๋ค. ์ง์ฐ์ด ์๋ ๊ฒฝ์ฐ ํ๋์ ์ถ์ ๋ฌธ์ ๋ฅผ ๋ง๋ค์ด ์ ์ ์์ค์ผ๋ก ๋์ด์ฌ๋ฆฝ๋๋ค. ์ฐ์ ์์์ ๊ดํด์๋ ํตํ๊ฐ ๊ธฐ์ ๋ถ์ฑ ๊ฐ์๋ณด๋ค ์ฐ์ ํด์ผ ํ๋ค๋ ๋ฐ ๋์ํฉ๋๋ค.
์ด ์ค๋ ๋๋ฅผ ๋๋ฝํ์ ์ฃ์กํฉ๋๋ค. ์ด์ ์ ํ๋ก์ ํธ๋ฅผ ์ํด D3.js๋ก ๋์๊ฐ๊ณ ์์ต๋๋ค. ์ธ๋ผ์ธ TypeScript ์ฃผ์์ด D3์ ๋ํด ๊ณ ๋ ค๋์๋์ง ๊ถ๊ธํฉ๋๋ค.
/** <strong i="6">@type</strong> {SyncBailHook<Compilation>} */
shouldEmit: new SyncBailHook(["compilation"]),
webpack์์ TypeScript ์ปดํ์ผ๋ฌ๋ก JavaScript๋ฅผ ํ์ธํ๋ ๋ฐ ์ฌ์ฉํ๊ธฐ ์์ํ์ต๋๋ค. ํฐ ์ฅ์ ์ ์ค์ ์ฝ๋ ๋ฐ๋ก ์์ ํ์ดํ ์ ์๊ฐ ์๋ค๋ ๊ฒ์
๋๋ค.
https://github.com/webpack/webpack/blob/master/lib/Compiler.js#L51
์๋
ํ์ธ์ @phil-lgr์
๋๋ค.
์ผ๋ง ์ ์ d3
์ด์ ํธ๋์ปค์ ๋ํ ํ ๋ก ์ด ์์๊ณ ์ฐ์ ์์ ๋ชฉ๋ก์ ๋งจ ์์ ์๋ ๊ฒ ๊ฐ์ง ์์์ต๋๋ค(์: Mike Bostock์ ํ์ดํ๋ณด๋ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ฒด ๊ฐ๋ฐ์ ์ง์คํ๋ ๊ฒ์ ์ ํธํ์ต๋๋ค). ์ค๋ ๋์ ๋ํ ๋งํฌ๋ฅผ ์ฐพ์ ์ ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด ์๋ก์ด ์ ๋ณด ๋๋ถ์ ๋ค์ ์ง๋ฌธ์ด ์ ๊ธฐ๋ ์ ์๊ฒ ์ง๋ง ๊ทธ๋ด ๊ฐ๋ฅ์ฑ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
@tomwanzek ์์ ์ถ์ ํ ์ด๋ธ์ ์ ๋ฐ์ดํธํ ์ ์์ต๋๋ค.
d3-array
, d3-array
, d3-dsv
, d3-fetch
๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ฒฝ์ฐ $ strictNullChecks
strictFunctionTypes
๋ฐ TS 2.3
์ด์ โ
๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค. d3-fetch
, d3-hexbin
, d3-hierarchy
, d3-interpolate
, d3-quadtree
, d3-queue
, d3-request
, d3-timer
๋ฐ d3-voronoi
.
๋ํ d3-color
, d3-hexbin
, d3-hierarchy
, d3-interpolate
๋ฐ d3-quadtree
$ ์ ๋ํด $ JSDoc
์ด์ โ
๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
๊ฐ์ฌ ํด์
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@denisname ๐ฏ @gustavderdrache @ledragon ์ง๋ ์งง์ ์๊ฐ ๋์ ๋ชจ๋ ์๊ณ ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ์ถ์ ํ ์ด๋ธ์ ์ ๋ฐ์ดํธํ๋๋ฐ ๋ฒ์จ ํจ์ฌ ๋ ์๋ป์! ์์ ์ถ์ ํ ์ด๋ธ์ด ์ฐ๋ฆฌ๊ฐ ์ฌ๊ธฐ์ ๋ชฉํ๋ก ํ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ๋๋ค :์ค๋ง์ผ: