我有以下.d.ts文件(摘录)
declare const Auth0: Auth0Static;
declare module "auth0-js" {
export = Auth0
}现在,在我的.ts文件中,我使用了以下内容
import { Auth0 } from 'auth0-js';我得到以下错误
auth0-js没有导出成员Auth0。
这里出什么问题了?
发布于 2017-04-15 06:52:56
auth0-js库不导出任何名为Auth0的内容。
如果您只想导入所有内容,那么将您的导入更改为import * as Auth0 from 'auth0-js'。否则,您可以导入单个导出,如import { WebAuth } from 'auth0-js';。
还有,你在自己打打字机吗?否则,您可以只使用npm install @types/auth0-js中已经可用的类型。
确保您的tsconfig.json配置为查找类型:
{
"compilerOptions": {
...
"typeRoots": [
"node_modules/@types"
],
...
}
}发布于 2017-06-01 11:19:00
在我们的角-cli项目中,我们成功地通过
npm install auth0-js @types/auth0-js --save
并导入您需要的路径(如import { WebAuth } from 'auth0-js'; )
发布于 2017-04-19 01:57:16
您可以将auth0脚本包含在index.html中
在你的auth.ts里面。您可以使用
declare var auth0: any;这样就避免了任何没有找到类型记录可能引发的错误的名称。
https://stackoverflow.com/questions/41255302
复制相似问题