How does typescript node declare global variables?

recently I"ve been learning that ts, doesn"t quite understand this part of global variables. For example, such an expression in the original node

global.sql = require("./tools/mysql").sql;

this allows you to define a global variable.
and how should this sql global variable be defined in ts?

Apr.07,2021

first of all, TypeScript discourages writing global variables and encourages the use of modular systems. Therefore, TS does not and will not have a convenient way to write global.
secondly, the module system of TypeScript has been replaced with import / export of the ES standard, and should not continue to use require .

then answer your question. The way to define global variables is

  1. write

    in sql.ts
      

    what if you are in the rendering process?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e60f12-458e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e60f12-458e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?