简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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