简体   繁体   English

编写声明文件:打字稿

[英]Writing a declaration file: typescript

How would I write a declaration file for我将如何编写声明文件

define(function() {
    'use strict';
    return Object.freeze({
        BTN_LINK: 'btnLink',
        COMBO_BOX: 'comboBox',
        TEXT: 'text'
    });
});

The type of the object you have frozen is:您冻结的对象的类型是:

type example = Readonly<{ BTN_LINK: string; COMBO_BOX: string; TEXT: string; }>;

You can get some guidance on best practices , and detailed instructions on writing type definitions if you want to find out more about ambient types.如果您想了解有关环境类型的更多信息,您可以获得有关最佳实践的一些指导,以及有关编写类型定义的详细说明。 In particular, the best practices link describes how to create ghost modules, which you will be interested in if you want to put this type into a ghost module to describe the whole file.特别是最佳实践链接描述了如何创建ghost模块,如果您想将此类型放入ghost模块来描述整个文件,您会感兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM