“声明"在“导出声明类操作"中有什么作用?

编程入门 行业动态 更新时间:2024-10-08 12:44:40
本文介绍了“声明"在“导出声明类操作"中有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

为什么我们需要声明中的declare?

Why do we need the declare in the statement?

export declare class Actions {
    ...
}

推荐答案

找到了我要找的东西:

声明与 var

var 创建一个新变量.declare 用于告诉 TypeScript 该变量已在别处创建.如果您使用 declare,则不会在生成的 JavaScript 中添加任何内容 - 它只是对编译器的提示.

var creates a new variable. declare is used to tell TypeScript that the variable has been created elsewhere. If you use declare, nothing is added to the JavaScript that is generated - it is simply a hint to the compiler.

例如,如果您使用定义了 var externalModule 的外部脚本,您将使用 declare var externalModule 来提示 externalModule 的 TypeScript 编译器代码>已经设置

For example, if you use an external script that defines var externalModule, you would use declare var externalModule to hint to the TypeScript compiler that externalModule has already been set up

这篇关于“声明"在“导出声明类操作"中有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 11:02:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1188567.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声明   中有   作用   操作   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!