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()
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()
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.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us