-1
import DataTypes = require('./lib/data-types')

Please someone explain to me. Why can use import and require together. This is in a module of NodeJS. Sequelize

  • 1
    Does this answer your question? [The difference between "require(x)" and "import x"](https://stackoverflow.com/questions/46677752/the-difference-between-requirex-and-import-x) – chazsolo Mar 30 '21 at 14:43
  • Also [RTM](https://sequelize.org/master/variable/index.html#static-variable-DataTypes) – mplungjan Mar 30 '21 at 14:50

2 Answers2

0

This syntax is specific to TypeScript. See: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
When exporting a module using export =, TypeScript-specific import module = require("module") must be used to import the module.

Robert Kawecki
  • 2,218
  • 1
  • 9
  • 17
0

This is a Typescript syntax.

Try using

import * as x from 'x'

Or

const … = require(…)
Mozzdy
  • 51
  • 1