3

How do I convert the JavaScript module.exports to typescript

The JavaScript code of the module.exports is :

module.exports = {
    discord: {
        clientID: "",
        clientSecret: "",
        clientToken: "",
    },
    tokens: {
        twitchClientID: "",
        openWeatherMap: "",
    },
};
1

2 Answers 2

2

use export default

const val = {
    discord: {
        clientID: "",
        clientSecret: "",
        clientToken: "",
    },
    tokens: {
        twitchClientID: "",
        openWeatherMap: "",
    },
};
export default val
Sign up to request clarification or add additional context in comments.

Comments

1

Try to use the export default keyword:

export default {
    discord: {
        clientID: "",
        clientSecret: "",
        clientToken: "",
    },
    tokens: {
        twitchClientID: "",
        openWeatherMap: "",
    },
}

You can also export single elements (equivalent of module.exports.foo = { ... }):

export const foo = {
    discord: {
        clientID: "",
        clientSecret: "",
        clientToken: "",
    },
    tokens: {
        twitchClientID: "",
        openWeatherMap: "",
    },
}

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.