728x90
반응형
코멘트로 이루어진 문법
ts 파일이 아닌 js 파일에서 타입을 지정해줄 때에 사용하며,
타입스크립트 문법을 사용하지 않아도 타입스크립트가 자바스크립트 파일을 확인해줌
- 코멘트 생성 방법
//@ts-check
/** + 엔터
ts.config.json 파일 내에 "allowJs":true 추가
{
"include" : ["src"],
"compilerOptions": {
"allowJs": true
}
}
- 사용 예시
//@ts-check
/**
* Initializes the project
* @param {object} config
* @param {boolean} config.debug
* @param {string} config.url
* @returns {boolean}
*/
export function init(config) {
return true;
}
/**
* Exit the program
* @param {number} code
* @returns {number}
*/
export function exit(code) {
return code + 1;
}
728x90
'Frontend > TypeScript' 카테고리의 다른 글
[TypeScript] 다형성 (Polymorphism) (0) | 2023.02.10 |
---|---|
[TypeScript] VSC 타입스크립트 설치 및 설정 방법 (0) | 2023.02.01 |
[TypeScript] 타입 VS 인터페이스 (0) | 2023.01.31 |
[TypeScript] 인터페이스 (Interface) (0) | 2023.01.30 |
[TypeScript] 클래스, 추상 클래스, 추상 메소드 (Classes, Abstract Classes, Abstract Method) (0) | 2023.01.29 |