microsoft / microsoft/TypeScript
[Discussion] Better Way to Declare Globals in JavaScript files
Abierto
@rbuckton ya está trabajando en esto.
Desde el 11/5/2017.
Domain: JavaScript
Needs Proposal
Suggestion
VS Code Tracked
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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
*/
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.