Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
How to properly declare a global type in typescript

I try to use a global type but when I do, node crashes without any real error.

My global.d.ts:

import { Method } from 'axios';

declare global { 
    type AxiosConf = { url: string, method: Method, data: object };
}

export {};

Then, the following code makes node crash:

const postBaseline: AxiosConf = { 
    url: urlObj.urlStr, 
    method: urlObj.urlMethod as Method,
    data: {}
};

Resulting in [nodemon] app crashed - waiting for file changes before starting....

What is wrong with my code?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I eventually didn't used global declaration, but rather an export of the type and then importing it

types.d.ts:

import { Method } from 'axios';

// Axios config object
export type AxiosConf = { url: string, method: Method, data: object };

When using it:

import { AxiosConf } from "../lib/global/types"
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!