봇트레이드 타입스크립트 밑천 기술

봇트레이드 출판

봇트레이드 타입스크립트 밑천 기술

AI 가 코드를 쓰는 시대에 사람이 쥐고 있어야 할 기초를 타입스크립트 한 권에 담았습니다.

봇트레이드 타입스크립트 밑천 기술 · 470쪽

Google Play

맛보기 — 눌러서 들어 보세요A taste — tap to hear it

맛보기는 앞 두 장입니다. 모든 장은 책에 있습니다.

  1. 타입스크립트taipseukeuripteu

    TypeScript타입스크립트

    자바스크립트에 타입을 적는 자리를 더한 언어The language that adds a place to write types onto JavaScript

    타입스크립트 파일은 자바스크립트로 바뀌어 돌아간다.A TypeScript file is turned into JavaScript and then runs.

  2. 타입 체계taip chegye

    type system타이프 시스텀

    어떤 값이 어디에 들어갈 수 있는지 정해 둔 규칙 한 벌The set of rules that decide which value may go where

    타입 체계는 어디에 무엇이 들어갈 수 있는지 미리 정해 준다.The type system fixes in advance what may go where.

  3. 타입 검사기taip geomsagi

    type checker타이프 체커

    코드를 돌리지 않고 타입 규칙에 어긋난 곳을 찾아 주는 쪽The part that finds what breaks the type rules without running the code

    타입 검사기가 돌리기 전에 어긋난 줄을 알려 주었다.The type checker pointed at the wrong line before anything ran.

  4. 정적 타입 검사jeongjeok taip geomsa

    static type checking스태틱 타이프 체킹

    돌리기 전에 글만 읽어서 하는 검사Checking done by reading the text, before anything runs

    정적 타입 검사는 코드를 돌리지 않고 글만 읽는다.Static type checking only reads the text; it runs nothing.

  5. 컴파일 시점keompail sijeom

    compile time컴파일 타임

    코드를 돌리기 전, 검사하고 자바스크립트로 바꾸는 때Before the code runs: when it is checked and turned into JavaScript

    컴파일 시점에 잡히는 실수는 돈이 들지 않는다.A mistake caught at compile time costs nothing.

  6. 타입 표기taip pyogi

    type annotation타이프 애너테이션

    이름 뒤에 그 자리에 올 타입을 적어 두는 일Writing down, after a name, the type that belongs in that place

    매개변수에 타입 표기를 달면 부르는 쪽까지 검사된다.A type annotation on a parameter gets the caller checked too.

  7. 타입 추론taip churon

    type inference타이프 인퍼런스

    적지 않아도 값을 보고 타입을 스스로 알아내는 일Working out the type from the value, with nothing written down

    값을 바로 넣었으면 타입 추론에 맡기고 적지 않는다.If the value is right there, leave it to type inference and write nothing.

  8. 타입 에러taip ereo

    type error타이프 에러

    값과 자리의 타입이 맞지 않아 돌리기 전에 나는 에러An error raised before running, because a value and its place do not match

    타입 에러는 돌려 보기 전에 나므로 사용자는 보지 않는다.A type error happens before running, so no user ever sees it.

  9. 에러 번호ereo beonho

    error code에러 코우드

    에러마다 붙은 번호 — 같은 번호는 늘 같은 종류의 어긋남이다The number on each error: the same number always means the same kind of mismatch

    에러 번호로 찾으면 같은 종류의 어긋남을 모아 볼 수 있다.Searching by error code gathers the same kind of mismatch together.

  10. 진단 글jindan geul

    diagnostic다이어그나스틱

    검사기가 내놓는 한 건의 알림 — 번호·자리·설명이 함께 온다One report from the checker: a number, a place, and a sentence

    진단 글 하나에는 번호와 자리와 설명이 함께 들어 있다.One diagnostic carries a number, a place, and a sentence.

  11. 내보내기naebonaegi

    emit이밋

    검사를 끝낸 뒤 돌아갈 자바스크립트 파일을 만들어 내는 일Producing the JavaScript files that will run, after the check

    검사만 하고 내보내기는 끄는 설정도 있다.There is a setting that checks but turns the emit off.

  12. 타입 지워짐taip jiwojim

    type erasure타이프 이레이저

    내보낸 코드에는 타입이 한 줄도 남지 않는 성질The fact that no type survives into the code that is emitted

    타입 지워짐 때문에 타입으로 돌아가는 중에 값을 가릴 수는 없다.Because types are erased, a type cannot tell values apart while running.

  13. 상위 집합sangwi jipap

    superset수퍼셋

    자바스크립트로 적은 것은 모두 그대로 쓸 수 있고 적을 거리가 더 있다는 뜻Anything written in JavaScript still counts, with more that can be written

    상위 집합이라 자바스크립트 파일 이름만 바꾸어도 시작할 수 있다.Being a superset, renaming a JavaScript file is enough to start.

  14. 타입 안전taip anjeon

    type safety타이프 세이픠티

    맞지 않는 값이 자리에 들어가는 일을 미리 막아 두는 정도How far wrong values are kept out of a place in advance

    타입 안전은 모두 아니면 전무가 아니라 설정으로 올려 간다.Type safety is not all or nothing; settings raise it step by step.

  15. 의미 에러uimi ereo

    semantic error시맨틱 에러

    모양은 맞는데 뜻이 어긋난 곳 — 타입 에러가 여기 든다A place that is shaped right but means something wrong; type errors are these

    괄호를 빠뜨리면 문법 에러, 타입이 어긋나면 의미 에러다.A missing bracket is a syntax error; a mismatched type is a semantic one.

  16. 편집기 도움pyeonjipgi doum

    editor support에디터 서포트

    타입을 알기에 이름 채우기·이름 바꾸기·설명 띄우기가 되는 일Completion, renaming, and hover text, all possible because the types are known

    타입을 적어 두면 편집기 도움으로 이름이 저절로 채워진다.Write the types down and editor support fills the names in.

  17. 암묵적 anyammukjeok any

    implicit any임플리싯 에니

    아무것도 적지 않아 검사를 받지 못한 자리A place with nothing written, so nothing is checked

    암묵적 any 를 막아 두면 빈 자리가 에러로 드러난다.Forbid implicit any and the empty places show up as errors.

  18. 밝혀 적은 표기balkyeo jeogeun pyogi

    explicit annotation익스플리싯 애너테이션

    추론에 맡기지 않고 사람이 손으로 적은 타입A type written by hand instead of left to inference

    바깥에 내놓는 함수에는 밝혀 적은 표기를 둔다.Put an explicit annotation on a function you hand outward.

  19. 헛경고heotgyeonggo

    false positive폴스 파지티브

    코드는 맞는데 검사기가 틀렸다고 말하는 경우The code is right but the checker says it is wrong

    헛경고라고 단언으로 덮기 전에 왜 그렇게 보이는지 먼저 본다.Before covering a false positive with an assertion, see why it looks that way.

  20. 조금씩 들이기jogeumssik deurigi

    incremental adoption인크리멘털 어답션

    한꺼번에 다 바꾸지 않고 파일·설정을 하나씩 엄하게 해 가는 길Turning it on file by file and setting by setting, instead of all at once

    조금씩 들이기로 파일 한 벌씩 엄하게 했다.With incremental adoption, one batch of files was made strict at a time.

  21. 컴파일러keompailleo

    compiler컴파일러

    검사와 내보내기를 함께 하는 프로그램The program that both checks and emits

    컴파일러는 검사와 내보내기를 함께 한다.The compiler both checks and emits.

  22. 런타임 에러reontaim ereo

    runtime error런타임 에러

    돌아가는 중에 터지는 에러 — 타입 검사로 다 막지는 못한다An error that blows up while running; type checking cannot stop them all

    바깥에서 온 값은 타입 검사로 못 막으므로 런타임 에러로 남는다.A value from outside is not caught by the checker, so it stays a runtime error.

  23. 원시 타입wonsi taip

    primitive type프리미티브 타이프

    쪼갤 수 없는 값 하나하나의 타입The type of a single value that cannot be taken apart

    원시 타입은 값 하나이고 그 안에 이름이 없다.A primitive type is one value with no names inside it.

  24. number 타입number taip

    number type넘버 타이프

    정수와 소수를 한꺼번에 담는 숫자 타입The number type, holding whole numbers and decimals alike

    number 타입 하나로 정수와 소수를 모두 담는다.The one number type holds whole numbers and decimals alike.

  25. string 타입string taip

    string type스트링 타이프

    글자가 늘어선 값의 타입The type of a run of characters

    string 타입에는 글자가 늘어선 값이 들어간다.A run of characters goes in the string type.

  26. boolean 타입boolean taip

    boolean type불리언 타이프

    참과 거짓 두 값만 있는 타입The type with only the two values true and false

    boolean 타입은 참과 거짓 두 값뿐이다.The boolean type has only true and false.

  27. null 타입null taip

    null type널 타이프

    값이 비어 있다고 사람이 넣어 둔 값만 들어가는 타입The type whose only value is the empty one a person put there

    null 타입은 사람이 비워 두었다는 뜻으로 쓴다.The null type is used to mean a person left it empty.

  28. undefined 타입undefined taip

    undefined type언디파인드 타이프

    아직 아무 값도 놓이지 않은 자리의 타입The type of a place where no value has been put yet

    아직 넣지 않은 자리는 undefined 타입이다.A place nothing was put in yet is of the undefined type.

  29. symbol 타입symbol taip

    symbol type심벌 타이프

    다른 어떤 것과도 겹치지 않는 이름표 값의 타입The type of a label value that can never clash with another

    symbol 타입 값은 둘을 만들어도 서로 같지 않다.Two values of the symbol type are never equal.

  30. bigint 타입bigint taip

    bigint type빅인트 타이프

    자릿수 제한 없이 큰 정수를 담는 타입The type for whole numbers as large as needed

    자릿수가 큰 셈에는 bigint 타입을 쓴다.For sums with many digits, use the bigint type.

  31. 리터럴 타입riteoreol taip

    literal type리터럴 타이프

    값 하나만 들어갈 수 있는 타입A type that admits exactly one value

    리터럴 타입은 그 값 하나만 받아들인다.A literal type takes that one value and nothing else.

  32. 문자열 리터럴 타입munjayeol riteoreol taip

    string literal type스트링 리터럴 타이프

    정해 둔 글 하나만 들어가는 타입A type that admits one fixed piece of text

    「열림」 과 「닫힘」 만 받으려면 문자열 리터럴 타입을 쓴다.To take only "open" and "closed", use string literal types.

  33. 숫자 리터럴 타입sutja riteoreol taip

    numeric literal type뉴메릭 리터럴 타이프

    정해 둔 숫자 하나만 들어가는 타입A type that admits one fixed number

    숫자 리터럴 타입으로 0 과 1 만 받게 했다.Numeric literal types let only 0 and 1 through.

  34. 불 리터럴 타입bul riteoreol taip

    boolean literal type불리언 리터럴 타이프

    true 하나만, 또는 false 하나만 들어가는 타입A type that admits only true, or only false

    불 리터럴 타입은 판별 칸으로 자주 쓰인다.Boolean literal types often serve as the telling field.

  35. 리터럴 넓어짐riteoreol neolbeojim

    literal widening리터럴 와이드닝

    고칠 수 있는 자리에 넣으면 값 하나 타입이 넓은 타입으로 바뀌는 일A one-value type turning into the wide one when it can still be changed

    고칠 수 있는 변수에 넣으면 리터럴 넓어짐으로 string 이 된다.Put it in a changeable variable and literal widening makes it string.

  36. const 단언const daneon

    const assertion칸스트 어서션

    값을 더 넓어지지 않게 묶어 두는 표기The note that pins a value so it does not widen

    const 단언을 붙이면 값 하나 타입이 그대로 남는다.With a const assertion the one-value type stays.

  37. as constas const

    as const애즈 칸스트

    그 값과 그 안의 것까지 바뀌지 않는 값으로 못 박는 말The words that fix a value, and what is inside it, as unchanging

    as const 를 쓰면 안에 든 것까지 바뀌지 않는 값이 된다.With as const even what is inside becomes unchanging.

  38. 리터럴 유니언riteoreol yunieon

    union of literals유니언 어븨 리터럴즈

    허락된 값 몇 개만 늘어놓아 만든 타입A type made by listing only the values that are allowed

    리터럴 유니언은 허락된 글 몇 개만 늘어놓은 것이다.A union of literals just lists the few allowed pieces of text.

  39. 열거형yeolgeohyeong

    enum이넘

    이름 붙인 값 묶음을 하나의 타입으로 만든 것A set of named values gathered into one type

    열거형은 돌아가는 코드에도 남으므로 리터럴 유니언과 견주어 고른다.An enum stays in the running code, so weigh it against a union of literals.

  40. 숫자 열거형sutja yeolgeohyeong

    numeric enum뉴메릭 이넘

    이름마다 숫자가 매겨지는 열거형An enum where each name is given a number

    숫자 열거형은 적지 않은 번호를 저절로 매긴다.A numeric enum hands out numbers you did not write.

  41. 문자열 열거형munjayeol yeolgeohyeong

    string enum스트링 이넘

    이름마다 글을 손으로 정해 주는 열거형An enum where each name is given a piece of text by hand

    문자열 열거형은 값이 글이라 기록에서 알아보기 쉽다.A string enum keeps text values, easy to read in a log.

  42. const 열거형const yeolgeohyeong

    const enum칸스트 이넘

    쓰는 자리에 값이 그대로 박혀 들어가는 열거형An enum whose value is pasted straight into the place that uses it

    const 열거형은 값이 박혀 들어가 쓰는 쪽과 따로 떨어지기 쉽다.A const enum is pasted in, so it comes apart from where it is used.

  43. typeof (타입 자리의 typeof)typeof

    typeof (type query)타입오브 타이프 퀴어리

    값의 타입을 그 값에서 그대로 떠 오는 말The words that lift a type out of a value

    이미 있는 값에서 typeof 로 타입을 떠 오면 두 곳을 따로 고칠 일이 없다.Lifting the type off an existing value with typeof saves fixing two places.

  44. 열거형 멤버yeolgeohyeong membeo

    enum member이넘 멤버

    열거형 안의 이름 하나 — 그 자체가 리터럴 타입이 된다One name inside an enum; it is itself a one-value type

    열거형 멤버 하나하나가 그 자체로 리터럴 타입이다.Each enum member is a one-value type by itself.

  45. 거꾸로 찾기geokkuro chatgi

    reverse mapping리버스 매핑

    숫자 열거형만 가진, 숫자에서 이름을 되찾는 자리A place only numeric enums have: finding the name back from the number

    숫자 열거형만 거꾸로 찾기가 되고, 문자열 열거형은 안 된다.Only numeric enums get reverse mapping; string enums do not.

  1. Q타입스크립트는 왜 쓰니?taipseukeuripteuneun wae sseuni?Why use TypeScript?와이 유스 타입스크립트

    A같은 실수를 돌려 보기 전에 잡아 주기 때문이다. 고치는 값이 가장 싼 때가 컴파일 시점이다.gateun silsureul dollyeo bogi jeone jaba jugi ttaemunida. gochineun gapsi gajang ssan ttaega keompail sijeomida.It catches the same mistakes before anything runs. The cheapest time to fix is compile time.잇 캐치이즈 둬 세임 미스테이크스 비푀 에니씽 런즈. 둬 치피스트 타임 투 픽스 이즈 컴파일 타임.

  2. Q타입스크립트와 자바스크립트는 뭐가 달라?taipseukeuripteuwa jabaseukeuripteuneun mwoga dalla?How does TypeScript differ from JavaScript?하우 더즈 타입스크립트 디풔 픠럼 자바스크립트

    A돌아가는 것은 똑같다. 타입을 적을 자리가 더 있고, 그 자리는 돌아가기 전에만 쓰인다.doraganeun geoseun ttokgatda. taibeul jeogeul jariga deo itgo, geu jarineun doragagi jeoneman sseuinda.What runs is the same. There is more to write down, and that writing is used only before it runs.왓 런즈 이즈 둬 세임. 뒈어 이즈 모 투 라잇 다운 앤드 됏 라이팅 이즈 유즈드 온리 비푀 잇 런즈.

  3. Q타입은 돌아갈 때도 남아?taibeun doragal ttaedo nama?Do types stay while it runs?두 타이프스 스테이 와일 잇 런즈

    A남지 않는다. 내보낸 코드에는 타입이 한 줄도 없다. 그래서 타입으로 값을 가릴 수는 없다.namji anneunda. naebonaen kodeueneun taibi han juldo eopda. geuraeseo taibeuro gapseul garil suneun eopda.They do not. The emitted code holds no type, so a type cannot tell values apart.뒈이 두 낫. 둬 이미티드 코우드 호울즈 노우 타이프 소우 어 타이프 캐낫 텔 봴류즈 어파트.

  4. Q타입 표기를 어디까지 적어?taip pyogireul eodikkaji jeogeo?How much should be annotated?하우 머치 슈드 비 애너테이티드

    A바깥과 닿는 자리에는 적고, 안에서 값을 바로 넣는 자리는 추론에 맡긴다.bakkatgwa danneun jarieneun jeokgo, aneseo gapseul baro neonneun jarineun churone matginda.Annotate where it touches the outside; leave inference to settle a value put in right there.애너테잇 웨어 잇 터치즈 둬 아웃사이드 을리븨 인퍼런스 투 세틀 어 봴류 풋 인 라잇 뒈어.

  5. Q타입 검사기가 잡아 주지 못하는 것은?taip geomsagiga jaba juji motaneun geoseun?What does the type checker not catch?왓 더즈 둬 타이프 체커 낫 캐치

    A바깥에서 들어온 값의 모양과 셈의 뜻이다. 둘은 돌려 보거나 확인하는 코드로 막는다.bakkateseo deureoon gapsui moyanggwa semui tteusida. dureun dollyeo bogeona hwaginhaneun kodeuro mangneunda.The shape of what came from outside, and whether the sums mean the right thing.둬 쉐이프 어븨 왓 케임 픠럼 아웃사이드 앤드 웨둬 둬 섬즈 민 둬 라잇 씽.

  6. Q에러 번호는 왜 봐?ereo beonhoneun wae bwa?Why look at the error code?와이 을룩 앳 둬 에러 코우드

    A같은 번호는 늘 같은 종류의 어긋남이다. 번호로 찾으면 같은 실수를 모아 볼 수 있다.gateun beonhoneun neul gateun jongnyuui eogeunnamida. beonhoro chajeumyeon gateun silsureul moa bol su itda.The same code is always the same kind of mismatch, so searching by it gathers them.둬 세임 코우드 이즈 올웨이즈 둬 세임 카인드 어븨 미스매치 소우 서칭 바이 잇 개둬즈 뒘.

  7. Q타입스크립트를 쓰면 시험을 안 써도 돼?taipseukeuripteureul sseumyeon siheomeul an sseodo dwae?Does TypeScript replace tests?더즈 타입스크립트 리플레이스 테스츠

    A아니다. 타입은 모양을 맞추고 시험은 뜻을 맞춘다. 둘이 보는 곳이 다르다.anida. taibeun moyangeul matchugo siheomeun tteuseul matchunda. duri boneun gosi dareuda.No. Types match the shape, tests match the meaning. They look at different things.노우. 타이프스 매치 둬 쉐이프 테스츠 매치 둬 미닝. 뒈이 을룩 앳 디풔런트 씽즈.

  8. Q있는 코드에 어떻게 들여?inneun kodeue eotteoke deuryeo?How is it brought into existing code?하우 이즈 잇 브롯 인투 이그지스팅 코우드

    A조금씩 들인다. 파일을 옮기고, 빈 자리를 막고, 설정을 하나씩 올린다.jogeumssik deurinda. paireul omgigo, bin jarireul makgo, seoljeongeul hanassik ollinda.Bit by bit: move the files, close the empty places, raise the settings one at a time.빗 바이 빗 무븨 둬 퐈일즈 클로우스 둬 엠프티 플레이시즈 레이즈 둬 세팅즈 원 앳 어 타임.

  9. Q헛경고는 어떻게 다뤄?heotgyeonggoneun eotteoke darwo?What about a false positive?왓 어바웃 어 폴스 파지티브

    A먼저 왜 그렇게 보이는지 읽는다. 열에 아홉은 코드가 정말 애매한 자리다.meonjeo wae geureoke boineunji ingneunda. yeore ahobeun kodeuga jeongmal aemaehan jarida.First read why it looks that way. Nine times in ten the code really is ambiguous there.풔스트 레드 와이 잇 을룩스 됏 웨이. 나인 타임즈 인 텐 둬 코우드 릴리 이즈 앰비규어스 뒈어.

  10. Q편집기 도움이 왜 공짜로 따라와?pyeonjipgi doumi wae gongjjaro ttarawa?Why does editor support come along for free?와이 더즈 에디터 서포트 컴 얼롱 푀 픠리

    A타입을 알면 무엇을 쓸 수 있는지도 아는 셈이어서, 이름 채우기와 이름 바꾸기가 그 위에서 돈다.taibeul almyeon mueoseul sseul su inneunjido aneun semieoseo, ireum chaeugiwa ireum bakkugiga geu wieseo donda.Knowing the types is knowing what is available, and completion and renaming run on that.노우잉 둬 타이프스 이즈 노우잉 왓 이즈 어붸일러블 앤드 컴플리션 앤드 리네이밍 런 안 됏.

  11. QAI 가 타입이 안 맞는 자리마다 any 를 넣어 왔어. 무엇을 물을까?AI ga taibi an manneun jarimada any reul neoeo wasseo. mueoseul mureulkka?It put any wherever types did not match. What do I ask?잇 풋 에니 웨레붜 타이프스 디드 낫 매치. 왓 두 아이 애스크

    A「그 자리마다 왜 안 맞았는지」를 묻는다. any 는 어긋남을 고친 것이 아니라 가린 것이다.「geu jarimada wae an majanneunji」reul munneunda. any neun eogeunnameul gochin geosi anira garin geosida.Ask why each place did not match: any did not fix the mismatch, it hid it.애스크 와이 이치 플레이스 디드 낫 매치 에니 디드 낫 픽스 둬 미스매치 잇 히드 잇.

  12. Q「고쳤습니다」라는 말만 왔을 때 무엇을 해?「gochyeotseumnida」raneun malman wasseul ttae mueoseul hae?It only says "fixed". What then?잇 온리 세즈 퓍스트 왓 뒌

    A검사를 돌려 보고 나온 글을 본다. 돌려 보지 않은 말은 받아들이지 않는다.geomsareul dollyeo bogo naon geureul bonda. dollyeo boji aneun mareun badadeuriji anneunda.Run the check and look at what came out: a claim not run is not taken in.런 둬 첵 앤드 을룩 앳 왓 케임 아웃 어 클레임 낫 런 이즈 낫 테이큰 인.

차례 — 16장Contents — 16 chapters

  1. 0왜 타입인가Why Types
  2. 1기본 타입과 리터럴 타입Basic and Literal Types
  3. 2배열·튜플·객체 타입Arrays, Tuples, and Object Types
  4. 3유니언과 교차 타입Unions and Intersections
  5. 4타입 좁히기Narrowing
  6. 5함수 타입Function Types
  7. 6인터페이스와 타입 별칭Interfaces and Type Aliases
  8. 7제네릭Generics
  9. 8키·인덱스 접근·매핑 타입Keys, Indexed Access, and Mapped Types
  10. 9유틸리티 타입Utility Types
  11. 10조건부 타입과 템플릿 리터럴 타입Conditional and Template Literal Types
  12. 11any · unknown · never · voidany, unknown, never, void
  13. 12모듈과 선언 파일Modules and Declaration Files
  14. 13엄격 모드 설정Strictness Settings
  15. 14타입과 런타임의 경계The Line Between Types and Runtime
  16. 15오류 읽기·시험·AI 와 일하기Reading Errors, Testing, and Working with AI
봇트레이드가 낸 책 모두 보기Every book from BotTrade→