https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#--declaration-and---allowjs
### 同時指定が可能
[[declaration]]と[[allowJS]]を同時に指定できるようになった。
TypeScript3.6までは以下のエラーになっていた。
```
'allowJs' cannot be specified with option 'declaration'
```
### 型の付与
また、[[JSDoc]]に型が記載されていれば適切な型signatureが付くようになった。
`math.js`
```js
/**
* @param {number} x
* @param {number} y
* @returns {number}
*/
export function sum(x, y) {
return x + y;
}
```
↓
`tsc --declaration --allowJS`
↓
`math.d.ts`
```ts
/**
* @param {number} x
* @param {number} y
* @returns {number}
*/
export function sum(x: number, y: number): number;
```
型が明示されてなくても推論可能なら最大限考慮してくれる。
`human.js`
```js
export class Human {
/**
* @param {number} id
* @param {string} name
*/
constructor(id, name) {
this.id = id;
this.name = name;
}
incrementID(value = 1) {
return this.id + value;
}
}
```
↓
`tsc --declaration --allowJS`
↓
`human.d.ts`
```ts
export class Human {
/**
* @param {number} id
* @param {string} name
*/
constructor(id: number, name: string);
id: number;
name: string;
incrementID(value?: number): number;
}
```