打字稿没有找到定义

打字稿没有找到定义

问题描述:

我有以下文件结构:打字稿没有找到定义

+ src 
| test.ts 
| z_module.d.ts 
tsconfig.json 

test.ts

// does nothing? 
/// <reference path="./z_module.d.ts" /> 
// can't now write: 
var a: zzrm.zzrmObject; 

// have to use:  
import * as zzrm from 'zzrm'; 
var a: zzrm.zzrmObject; 

z_module.d.ts

declare module "zzrm" { 
    export interface zzrmObject {id: string} 
} 

我试图减少的问题,但很可能降低它不正确。这个问题最初来自尝试使用sequelize-auto-ts。 Downloading the repo,升级sequelize.d.ts并打开Visual Studio代码(版本0.10.6)立即突出显示this line,并显示错误“Can not find namespace sequelize'”。

var Sequelize:sequelize.SequelizeStatic = require('sequelize'); 
       ^^^^^^^^^ 

即使sequelize.d.ts成功引用在与文件的顶部:/// <reference path="../../typings/sequelize/sequelize.d.ts" />

以上“降低”示例工作如果zzrm模块不带引号声明:

declare module zzrm { 
    export interface zzrmObject {id: string} 
} 

当我更新sequelize.d.ts时,我没有注意到模块声明已从

declare module sequelize { ... } 

declare module "sequelize" { ... } 

这在打字稿文档"Ambient External Modules"下提及,但我还没有完全还没有想出如何将这些零部件全部结合在一起,为什么他们需要你还可以添加import * as zzrm from 'z_module';