2

How would I write a declaration file for

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.