microsoft / microsoft/TypeScript
[Discussion] Better Way to Declare Globals in JavaScript files
@rbuckton y travaille déjà.
Depuis le 11/5/2017.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
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
*/
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Évaluation
Cette issue n'a pas encore été évaluée.