typescript - 创建暴露给浏览器全局的 UMD 库
问题描述
我想在浏览器中将我的代码公开为全局范围内的库。我的代码遵循这样的结构:
const SOMETHING = 'test';
interface Library {
...
}
export const Library = (params: Library) => {
...
}
在我的 TS 配置中,我设置了以下选项:
{
"compilerOptions": {
"target": "es6",
"module": "umd",
"declaration": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",
"downlevelIteration": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
当我在做:
const Library = (params: Library) => {
然后我window.Library
开始工作了,而且还被window.SOMETHING
暴露了。如何配置 TypeScript,只公开window.Library
?
解决方案
推荐阅读
- jquery - 淘汰赛:未捕获的 ReferenceError:分配中的左侧无效
- javascript - 提交时调用 php 函数,如果可能,不使用 jQuery
- tensorflow - 需要帮助??为 Win 10 Pro 9-2-18 安装 Tensorflow-GPU
- angularjs - 不能在 angularjs 指令中使用 $mdSelect
- c++ - imwrite opencv 会影响捕获时间吗?
- node.js - 将 azure mobileservice 编译为较新版本的 nodejs
- regex - 正则表达式忽略带有部分字符串的单词
- lc3 - 我不知道为什么循环没有停止-LC3
- java - 拥有1的最佳方法是Java中的N个双向Hashmap结构
- c# - 使用 asp.net web api 2 将媒体上传到 azure blob 存储