microsoft / microsoft/TypeScript
[Discussion] Better Way to Declare Globals in JavaScript files
オープン
@rbuckton がすでに取り組んでいます。
2017年5月11日 から。
Domain: JavaScript
Needs Proposal
Suggestion
VS Code Tracked
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Problem
Using the new checkJs feature, it is currently difficult to tell TypeScript about a global variable:
// @ts-check
myGlobal
window.myVar = 'foo';
The only way around this that I know is to create a .d.ts file that defines these:
interface Window {
myVar: string;
}
declare var myGlobal: string;
JavaScript users should not have to write *.d.ts files.
Possible Approaches
@egamma proposes that may be able to use the global comment from ESlint http://eslint.org/docs/user-guide/configuring : /* global var1, var2 */
I'd also be interested to see if we could put type information in a jsdoc somehow, something like:
/**
* @global {string} myGlobal
*/
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。