No exported names found in module '../../types/recordTypes.js'
3
4import { getConfigProperty } from '../../helpers/functions.config.js'
5import { type ConfigBatchExport_RBCPreauthorized } from '../../types/configTypes.js'
6import type * as recordTypes from '../../types/recordTypes.js' 7import type { GetBatchExportReturn } from '../batchExport.js'
8
9import {
Description
It is recommended that when a name is being used from a module that is imported as a full namespace, the name should be exported from the imported module. That is, whenever we import a module using a wildcard (*
) like this:
import * as someModuleName from './path/to/the/module'
And use its function or variable or class like this:
const data = someModuleName.getData()
it is important to make sure that the name that is being used (getData
in the above example) should be exported from the referenced module; otherwise, it will give unexpected values like undefined
for variables and it might throw TypeError
as well (for example when calling a function).
Bad Practice
// <!-- config.js -->
export const KEYS = 'secret'
const TTY = 2030
const isValid = (a) => a < TTY
// <!-- index.js -->
import * as config from './config.js'
console.log(config.TTY) // undefined
console.log(config.isValid(2000)) // TypeError : isValid is not a function.
Recommended
// <!-- config.js -->
export const KEYS = 'secret'
export const TTY = 2030
export const isValid = (a) => a < TTY
// <!-- index.js -->
import * as config from './config.js'
console.log(config.TTY) // 2030
console.log(config.isValid(2000)) // true