- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在声明一个函数说 getValue。然后我定义了这个 getValue。但我收到错误error TS2384: Overload signatures must all be ambient or non-ambient
.
环境过载签名是什么意思?非环境签名是什么意思?如何在不出现此错误的情况下定义声明的函数?
declare function getValue(key:string):any;
function getValue(key:string):any{
return key;
}
最佳答案
declare
意味着您永远不打算为该变量提供值。它对编译器说:
"I know this value doesn't exist in the code you can see, but I promise you that it's defined somewhere that is available to this scope, and this is its type"
declare
如果您还提供了具体的值(value)。要么
declare
函数,这意味着它被定义在 typescript 编译器看不到的地方,或者完全删除声明行并导出函数本身以供您在任何地方使用。
What does ambient overload signature mean?
declare
触发的关键词。
Overload当您使用不同的参数类型/返回类型多次编写 a 函数类型时,会发生签名。通过在两行中提到函数, typescript 将其解释为函数重载。
What does non-ambient signature mean?
How do I define a declared function without getting this error?
declare
该函数类型的关键字。
关于typescript - 试图声明一个函数,得到错误 TS2384 : Overload signatures must all be ambient or non-ambient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65584688/
如何将多个 TS 文件合并为一个具有正确时间戳的 TS 文件?我可以将文件合并为一个,而无需接触数据。这将生成一个可播放的文件,但时间戳不正确,因此不会显示时间线(例如在 VLC 中)。因此,我需要重
有一个视频,其实是一个HLS流(TS文件的序列) 我想取出一个 TS block 并用另一个替换它。 另一个 block 将使用相同的 FFMPEG 编码设置进行编码。 如果你想知道我为什么需要这个:
这段代码取自https://en.cppreference.com/w/cpp/utility/variant/visit using var_t = std::variant; template s
我刚刚开始使用 ts-node。这是一个非常方便的工具。运行时间看起来很清晰。但它不适用于 CLI 解决方案。我无法将参数传递到编译的脚本中。 ts-node --preserve-symlinks
如果您愿意花 2 美分来解决调用另一个文件中定义的函数的问题,我将不胜感激。我阅读了 Typescript 的文档,其中建议设置一个接口(interface)或一个模块,然后引用它,但我收到了与下面相
我在努力 tsc ts/game.ts --out test.js --module amd 在我在 webstorm 中的 typescript 项目上,但是控制台没有显示任何错误,也没有输出 t
我已经意识到有一段时间了,一些 typescript 文件有一个 .d.ts 而其他的只有一个 .ts 扩展名。 它们代表什么?有什么区别? 最佳答案 这些是 declaration files ,或
是否有一种简单的方法可以将std::variant中包含的数据移动到std::variant中? 我想可以通过一个额外的类模板来切换Ts...中的所有类型,但是我想知道是否存在一种更优雅的就地方法。
我是 Angular 的新手,正在查看文档,但我想我也应该在这里问我的问题。 我正在导出一个越来越大的类,因此我想将其分成两个文件,并将 d1、d2、d3 等存储在一个单独的文件中,然后将它们导入到
无法通过指定 ts.t 找到条目(ts 是时间戳类型) 挖oplog,想搞清楚一秒钟有多少操作。 无法通过指定时间戳字段找到条目,其他字段可以。$在蒙戈外壳中: > db.oplog.rs.findO
这是我的 Angular5 项目结构。 tsconfig.app.json 和package.json 都包含这个部分 "include": [ "/src/main.ts",
我在 Angular 10 中有一个项目,遇到了奇怪的 TS (TSLint) 错误。在我使用 $localize 的任何地方的 Visual Studio Code 中,我都收到错误消息 Canno
所以我创建了一个快速服务器,它获取一个 mp3 文件(现在存储在本地,但稍后将从 mongo db 中获取)并使用 ffmpeg 制作 .m3u8 和 .ts 文件。文件成功发送到客户端,在客户端播放
我有一个 MY_FILE.ts像这样的文件: const someFunction = (param: MY_NAMESPACE.PARAM) : boolean => { // DO SOMETHI
我过去常常在运行前编译用 TS 编写的 e2e Protractor 测试,但现在我想出了如何在运行时编译 ts 文件——ts-node 似乎是一个很好的工具。正如许多文章所说,我在 Protract
我不熟悉 mod-rewrite,我找不到任何类似的问题或解决方案。 非常感谢... 模板: {query1}_{query2}.ts ts.php?v={query1}&seg={query2} 例
我有 firestore.service.ts,在一种方法中,我在 firebase 中创建和更新了一个集合……离开该方法后,我更改了集合的“id”,但我需要这个“id”是没有丢失,因为我需要它到下一
DefinitelyTyped 有许多库的类型定义,但当 Javascript 实现与 Typescript 分离时,我常常找不到使用它们的好方法,比如当库通过 a 将自己分配给窗口的属性时 标记,
我正在寻找一种在我发布到 NPM 时忽略项目中所有 .ts 文件的好方法,我可以通过将以下内容添加到我的 .npmignore 文件中来做到这一点: *.ts 但是等等......实际上我想在我的项目
我的 Yarn 工作区结构如下: /project package.json /packages /app package.json webpack.confi
我是一名优秀的程序员,十分优秀!