我已安装在我的Ionic 3项目pdfjs-dist中,来自npm和typings from DT,但我没有得到正确的智能感知,请看:http://imgur.com/ctIqkE7
VS代码:1.12.2 打字稿:2.3.3
在我的打字文件夹中,我有:
我的tsconfig.json说:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"allowJs": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
我的依赖是:
"dependencies": {
"@angular/common": "4.1.2",
"@angular/compiler": "4.1.2",
"@angular/compiler-cli": "4.1.2",
"@angular/core": "4.1.2",
"@angular/forms": "4.1.2",
"@angular/http": "4.1.2",
"@angular/platform-browser": "4.1.2",
"@angular/platform-browser-dynamic": "4.1.2",
"@ionic-native/core": "3.10.2",
"@ionic-native/splash-screen": "3.10.2",
"@ionic-native/status-bar": "3.10.2",
"@ionic/storage": "2.0.1",
"@types/pdf": "0.0.31",
"cordova-android": "^6.2.3",
"cordova-ios": "^4.4.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"ionic-angular": "3.3.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"pdfjs-dist": "^1.8.428",
"rxjs": "5.1.1",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.11"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.7",
"@ionic/cli-plugin-cordova": "1.3.0",
"@ionic/cli-plugin-ionic-angular": "1.3.0",
"typescript": "2.3.3"
},
我在这里查看了其他问题like这个或this并没有找到解决方案。
修改
我已经添加了更新的我的包含dt typings "typings/**/*.d.ts"
的路径,并在编译时收到了此警告:
typescript:node_modules/@types/pdf/index.d.ts,line:51 重复的字符串索引签名。
L51:*用于标识PDF的唯一ID。不保证是独一无二的。 [jbaldwin:哈哈什么]
L52:** /
我指出,这些类型并非来自typings/**
,而是来自node_modules/@types/
。我看一看,看到两个index.d.ts
文件完全相同,所以我在节点外面卸载了打字。
经过一段时间的研究,我有两个关于我的问题的主要理论。 我不知道我在做什么(非常可能) 2.打字错误和/或过时。
我找到了一个PDFJSStatic
界面,其中包含我在屏幕截图中的“unintellisensed”方法,该方法是在打字中导出的。如果我这样做:
import * as PDF_JS from 'pdfjs-dist';
let pdfjsLib : PDFJSStatic = PDF_JS;
我终于获得了有关getDocument()
方法的信息,但很多其他功能都被破坏了。
如果我将PDFJSStatic作为自己的变量:
var PDFJSStatic : PDFJSStatic = pdfjsLib.PDF;
智能感知有效,但显然功能不存在。