Answers for "what are modules in typescript"

0

what are modules in typescript

Starting with ECMAScript 2015, JavaScript has a concept of modules. 
TypeScript shares this concept.

Modules are executed within their own scope,
not in the global scope; this means that variables, functions, classes, etc. 
declared in a module are not visible outside the module unless
they are explicitly exported using one of the export forms. 
Conversely, to consume a variable, function, class, interface, etc. exported from a
different module, it has to be imported using one of the import forms.
Posted by: Guest on March-24-2022
0

typescript module

// module.ts
export const name = 'name'

function fnExample() {
	console.log('Example')
}

export default {
	fnExample
}

// Import module.ts
import modName, { name } from './module.ts'

modName.fnExample()
Posted by: Guest on February-13-2022

Code answers related to "TypeScript"

Browse Popular Code Answers by Language