我将一个声明文件添加到打包的typescript中。 有一些这样的语法:
import * as Sequelize from 'sequelize'; // this @types/sequelize export a namespace
//...
interface Application{
Sequelize: Sequelize; // <---error TS2709: Cannot use namespace 'Sequelize' as a type.
}
所以我写了一个这样的文件(index.d.ts):
// 0 = eldest = pre
//everytime i run this code i get names in pattern that makes no sense to me
public class cousin {
public static void main(String[] args)
{
String[] children = {"Arm", "Jo", "Ra", "Jas", "Pre", "She"};
int[] sortAge = {2, 4, 3, 5, 0, 1};
int x = 0;
int y = 1;
while ( x < 6)
{
int ref = sortAge[x];
System.out.print(y+ "\t");
System.out.println(children[ref]);
x = x + 1;
y = y + 1; }
}
}
如何解决这个问题?
答案 0 :(得分:0)
您的import语句表示您要从sequelize
模块导入所有内容,并将其放在名为Sequelize
的名称空间中。
您需要引用以namespace.member
方式导入的任何成员 - 在您的示例中Sequelize.Sequelize
,尽管作为个人偏好,我会重命名命名空间以避免重复。
import * as Sequelize from 'sequelize';
//...
interface Application{
Sequelize: Sequelize.Sequelize;
}