3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

js ファイルから JSDoc で d.ts の型を参照して型チェックする ( jest.config.js を例に)

Posted at

概要

jsにd.tsの型をつけ、補完したり、間違った値を入れたら分かるようにする

方法

// @ts-check
/**
 * @type {import('@jest/types').Config.InitialOptions}
 */
const config = {
  ...
};

module.exports = config;

備考

  • VSCodeでしか確認していない
  • @typedef でもimportが使える
  • allowJsとcheckJsを有効にしたら // @ts-check 不要かもしれない

参考

https://www.reddit.com/r/javascript/comments/aezwdh/using_typescript_declaration_files_with_jsdoc/
https://gist.github.com/hrdtbs/f7e567c0738725a16a9de7326dc11127

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?