TypeScript Deep Dive
  • README
  • 시작하기
    • 왜 타입스크립트인가
  • 자바스크립트
    • 비교 연산자
    • 참조 연산자
    • Null vs. Undefined
    • this
    • 클로저
    • Number
    • Truthy
  • 미래의 자바스크립트
    • 클래스
      • 즉시실행함수
    • 화살표 함수
    • 나머지 연산자
    • let
    • const
    • 비구조화 할당
    • 전개 연산자
    • for...of
    • 이터레이터
    • 템플릿 리터럴
    • 프로미스
    • 제네레이터
    • Async Await
  • 프로젝트
    • 컴파일러 제어
      • tsconfig.json
      • 파일 경로 지정
    • 선언
    • 모듈화
      • 파일을 이용한 모듈화
      • globals.d.ts
    • 네임스페이스
    • 동적 표현식 가져오기
  • Node.js 시작하기
  • Browser 시작하기
  • 타입스크립트 타입 시스템
    • 자바스크립트 마이그레이션 가이드
    • @types
    • 주변 선언
      • 파일 선언
      • 변수
    • 인터페이스
    • 열거형(Enums)
    • lib.d.ts
    • 함수
    • 콜러블(Callable)
    • 타입 표명(Type Assertion)
    • 신선도(Freshness)
    • 타입 가드
    • 리터럴(Literal)
    • 읽기 전용(readonly)
    • 제네릭
    • 타입 인터페이스
    • 타입 호환성
    • Never 타입
    • 구별된 유니온
    • 인덱스 서명(Index Signature)
    • 타입 이동하기
    • 예외 처리
    • 믹스인(Mixin)
  • JSX
    • React
    • Non React JSX
  • Options
    • noImplicitAny
    • strictNullChecks
  • 타입스크립트 에러
    • 에러 메세지
    • 공통 에러
  • NPM
  • 테스트
    • Jest
    • Cypress
  • Tools
    • Prettier
    • Husky
    • ESLint
    • Changelog
  • 팁
    • 문자열 Enums
    • 타입 단언
    • 상태 저장 함수
    • 커링
    • 제네릭 타입 예시
    • 객체 타입 설정
    • 유용한 클래스
    • Import / Export
    • 속성 Setters
    • outFile 주의사항
    • 제이쿼리 팁
    • 정적 생성자
    • 싱글톤 패턴
    • 함수 파라미터
    • 토글 생성
    • Import 여러개 하기
    • 배열 생성
    • 생성자에서 타입정의
  • 스타일 가이드
  • 타입스크립트 컴파일러 구조
    • Program
    • AST
      • TIP: Visit Children
      • TIP: SyntaxKind enum
      • Trivia
    • Scanner
    • Parser
      • Parser Functions
    • Binder
      • Binder Functions
      • Binder Declarations
      • Binder Container
      • Binder SymbolTable
      • Binder Error Reporting
    • Checker
      • Checker Diagnostics
      • Checker Error Reporting
    • Emitter
      • Emitter Functions
      • Emitter SourceMaps
    • Contributing
Powered by GitBook
On this page
  • Setup
  • Setup Fork
  • Running Tests
  • Baselines
  • Test Categories
  • Compiler Tests
  • Debugging Tests
  • More

Was this helpful?

  1. 타입스크립트 컴파일러 구조

Contributing

PreviousEmitter SourceMaps

Last updated 6 years ago

Was this helpful?

TypeScript is and the team welcomes community input.

Setup

Super easy:

git clone https://github.com/Microsoft/TypeScript.git
cd TypeScript
npm install -g jake
npm install

Setup Fork

You would obviously need to setup Microsoft/TypeScript as an upstream remote and your own fork (use the GitHub fork button) as origin:

git remote rm origin
git remote rm upstream
git remote add upstream https://github.com/Microsoft/TypeScript.git
git remote add origin https://github.com/basarat/TypeScript.git

Additionally I like to work off branches like bas/ to have it show up cleaner in the branch listings.

Running Tests

There are lots of test and build options in their JakeFile. You can run all tests with jake runtests

Baselines

Baselines are used to manage if there are any changes in the expected output of the TypeScript compiler. Baselines are located in tests/baselines.

  • Reference (expected) baselines: tests/baselines/reference

  • Generated (in this test run) baselines : tests/baselines/local (this folder is in .gitignore)

If there are any differences between these folders tests will fail. You can diff the two folders with tools like BeyondCompare or KDiff3.

If you think these changes in generated files are valid then accept baselines using jake baseline-accept. The changes to reference baselines will now show as a git diff you can commit.

Note that if you don't run all tests then use jake baseline-accept[soft] which will only copy over the new files and not delete the whole reference directory.

Test Categories

There are different categories for different scenarios and even different test infrastructures. Here are a few of these explained.

Compiler Tests

These ensure that compiling a file :

  • generates errors as expected

  • generated JS as expected

  • types are identified as expected

  • symbols are identified as expected

These expectations are validated using the baselines infrastructure.

Creating a Compiler Test

Test can be created by adding a new file yourtest.ts to tests/cases/compiler. As soon as you do so and run the tests you should get baseline failure. Accept these baselines (to get them to show up in git), and tweak them to be what you expect them to be ... now get the tests to pass.

Run all of these in isolation using jake runtests tests=compiler, or just your new file using jake runtests tests=compiler/yourtest

I will even often do jake runtests tests=compiler/yourtest || jake baseline-accept[soft] and get the diff in git.

Debugging Tests

jake runtests-browser tests=theNameOfYourTest and debugging in-browser usually works pretty well.

More

An article by Remo : 🌹

OSS and on GitHub
https://dev.to/remojansen/learn-how-to-contribute-to-the-typescript-compiler-on-github-through-a-real-world-example-4df0