1

Is there any way to generate Typescript definitions from a NodeJS/Javascript file ?

I have file which looks like :

module.exports = {
  account_a: {
    name: 'a',
    title: 'Account a',
  },
  account_n: {
    name: 'n',
    title: 'Account n',
  },
  // and so on
};

and would like to generate some Typescript definitions of it.

Actually, I'm copy/pasting its content to a TS file and compile it using tsc --declaration . but it's not ideal, any idea ?

5

1 Answer 1

0

actually you can using in TypeScript this below code

**exports** = {
      account_a: {
        name: 'a',
        title: 'Account a',
      },
      account_n: {
        name: 'n',
        title: 'Account n',
      },
      // and so on
    };
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.