A
A
Anton Mashletov2017-11-08 10:25:32
JavaScript
Anton Mashletov, 2017-11-08 10:25:32

How to declare a global variable in TypeScript?

onload = () => {
    const gl = getGLContext(<HTMLCanvasElement>document.getElementById('scene'));
};

How can I change it so that the const gl constant becomes global? Those. we initialize it in one file in onload, and it is available in all ts-files for use.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GreatRash, 2017-11-08
@mashletov

interface Window {
  someVariable: Number;
}

window.someVariable = 1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question