TypeScript 주석의 구문은 어디에 기록되어 있습니까?
TypeScript 주석의 구문은 어디에나 문서화되어 있습니까?
그리고 우연히 이제 C # ///
시스템을 지원 합니까?
올바른 구문은 이제 TSDoc에서 사용되는 구문입니다 . Visual Studio Code 또는 기타 문서 도구로 의견을 이해할 수 있습니다.
구문에 대한 개요는 여기 및 특히 여기에서 볼 수 있습니다 . 정확한 사양 은 "곧"작성되어야합니다 .
체크 아웃 다른 파일의 가치는 이 하나의 유용한 표준 태그를 볼 수 있습니다.
참고 : TSDoc 메인 페이지에 설명 된대로 JSDoc을 사용하면 안됩니다. 왜 JSDoc을 표준으로 사용할 수 없습니까? 불행히도 JSDoc 문법은 엄격하게 지정되지 않고 특정 구현의 동작에서 유추됩니다. 표준 JSDoc 태그의 대부분은 일반 JavaScript에 대한 유형 주석을 제공하는 데 주력하고 있으며 이는 TypeScript와 같은 강력한 유형의 언어와 관련이 없습니다. TSDoc은 이러한 한계를 해결하면서보다 복잡한 목표를 다루고 있습니다.
TypeScript는 JSDoc을 사용합니다. 예 :
/** This is a description of the foo function. */
function foo() {
}
jsdoc을 배우려면 : https://jsdoc.app/
그러나 JSDoc에서는 유형 주석 확장명을 사용할 필요가 없습니다.
당신은 (해야하고) 여전히 다른 jsdoc에 사용할 수있는 블록 태그 와 같은 @returns
등
예
단지 예입니다. 내용이 아닌 유형에 중점을 둡니다.
JSDoc 버전 (문서의 통지 유형) :
/**
* Returns the sum of a and b
* @param {number} a
* @param {number} b
* @returns {number}
*/
function sum(a, b) {
return a + b;
}
TypeScript 버전 (유형 재배치에 유의) :
/**
* Takes two numbers and returns their sum
* @param a first input to sum
* @param b second input to sum
* @returns sum of a and b
*/
function sum(a: number, b: number): number {
return a + b;
}
다음을 사용하여 매개 변수, 리턴 등에 대한 정보를 추가 할 수 있습니다.
/**
* This is the foo function
* @param bar This is the bar parameter
* @returns returns a string version of bar
*/
function foo(bar: number): string {
return bar.toString()
}
VS 코드와 같은 편집기는 다음과 같이 표시합니다.
일반 JavaScript에서와 같이 주석을 사용할 수 있습니다.
TypeScript 구문은 Ecmascript 5 (ES5) 구문의 상위 집합입니다. [...]
이 문서는 TypeScript에 의해 추가 된 문법 문법을 설명합니다
그 외에 언어 사양에서 주석에 대해서만 이것을 찾았습니다.
TypeScript also provides to JavaScript programmers a system of optional type annotations. These type annotations are like the JSDoc comments found in the Closure system, but in TypeScript they are integrated directly into the language syntax. This integration makes the code more readable and reduces the maintenance cost of synchronizing type annotations with their corresponding variables.
11.1.1 Source Files Dependencies:
A comment of the form
/// <reference path="..."/>
adds a dependency on the source file specified in the path argument. The path is resolved relative to the directory of the containing source file
Source:
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md
TypeScript is a strict syntactical superset of JavaScript hence
- Single line comments start with //
- 여러 줄 주석은 / *로 시작하고 * /로 끝납니다.
참고 URL : https://stackoverflow.com/questions/23072286/where-is-the-syntax-for-typescript-comments-documented
'programing tip' 카테고리의 다른 글
자바에서 로그에 줄 번호를 인쇄하는 방법 (0) | 2020.07.03 |
---|---|
Spring Security를 사용한 단위 테스트 (0) | 2020.07.03 |
.NET에서 매핑 및 축소 (0) | 2020.07.03 |
ArrayAdapter를 사용하는 방법 (0) | 2020.07.03 |
배열에서 첫 x 항목 반환 (0) | 2020.07.03 |