TS2304:找不到名称 'Office'。部署到 Azure 时
TS2304: Cannot find name 'Office'. when deploying to azure
我已经使用 yo office
(Yeoman Office Generator) 创建了一个 Word 插件 - 使用 typescript
、react
、webpack
.
当我在我的开发环境中使用 npm start
运行 它时,它工作得很好。
当我通过 Github
+ Kudu
部署到 Azure
时,编译成功但是当我浏览它时,我收到以下错误:
ERROR in /home/site/wwwroot/function-file/function-file.ts(12,3)
TS2304: Cannot find name 'Office'.
ERROR in /home/site/wwwroot/function-file/function-file.ts(21,12)
TS2304: Cannot find name 'Word'.
还有更多同类...
office-js
加载到我的 html <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js"></script>
但是我的 tsx
文件中没有 imports
...我保留了生成器创建它时的所有内容。
关于如何解决这个问题有什么想法吗?
看来您仍然需要指定应使用 office-js 类型。打开 src/tsconfig.app.json 并将 office-js 添加到类型数组,如果它之前是一个空数组,它应该看起来像这样:
"types": [
"office-js"
]
接下来,您需要在您的项目目录中 运行 命令 tsc -p tsconfig.json,然后再尝试再次构建该项目。
看看 link reference。
在顶部添加这个
/// <reference path="../node_modules/@types/office-js/index.d.ts" />
我已经使用 yo office
(Yeoman Office Generator) 创建了一个 Word 插件 - 使用 typescript
、react
、webpack
.
当我在我的开发环境中使用 npm start
运行 它时,它工作得很好。
当我通过 Github
+ Kudu
部署到 Azure
时,编译成功但是当我浏览它时,我收到以下错误:
ERROR in /home/site/wwwroot/function-file/function-file.ts(12,3)
TS2304: Cannot find name 'Office'.
ERROR in /home/site/wwwroot/function-file/function-file.ts(21,12)
TS2304: Cannot find name 'Word'.
还有更多同类...
office-js
加载到我的 html <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js"></script>
但是我的 tsx
文件中没有 imports
...我保留了生成器创建它时的所有内容。
关于如何解决这个问题有什么想法吗?
看来您仍然需要指定应使用 office-js 类型。打开 src/tsconfig.app.json 并将 office-js 添加到类型数组,如果它之前是一个空数组,它应该看起来像这样:
"types": [
"office-js"
]
接下来,您需要在您的项目目录中 运行 命令 tsc -p tsconfig.json,然后再尝试再次构建该项目。
看看 link reference。
在顶部添加这个
/// <reference path="../node_modules/@types/office-js/index.d.ts" />