Anybody know , how to define the parameter datatype in typescript, please let me know. whenever i define the datatype see in below(line 4) it give me syntax error
const env1:any=require("./config")
const Sequelize:any = require('sequelize');
module.exports = new Sequelize(env1.Variable.DATABASE_URL :any, {
host: 'localhost',
dialect: 'postgres',
operatorsAliases: false,
});
whenever i don't define the datatype it give me the error shown in below
CodePudding user response:
Your error is not type-related, rather the value you are passing as the database URL is undefined
. Check the whether env1.Variable.DATABASE_URL
has the correct value, which should be a string.
A console.log(env1.Variable.DATABASE_URL);
should do the trick.
const env1 = require("./config")
const Sequelize = require('sequelize');
console.log("DATABASE URL", env1.Variable.DATABASE_URL);
module.exports = new Sequelize(env1.Variable.DATABASE_URL, {
host: 'localhost',
dialect: 'postgres',
operatorsAliases: false,
});
Good luck.