tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
383 stars 257 forks source link

Allow raw axios headers #521

Open sharifzadesina opened 1 month ago

sharifzadesina commented 1 month ago

On v6, This code has type error:

import { TronWeb } from "tronweb";

var tw = new TronWeb({
  fullHost: '',
  headers: { 'test': 'test' },
});

But this code is fine:

const instance = axios.create({
  headers: { 'test': 'test' }
});

The reason is you are using AxiosRequestHeaders instead of RawAxiosRequestHeaders | AxiosHeaders. AxiosRequestHeaders is equal to RawAxiosRequestHeaders & AxiosHeaders which means having feathers of both RawAxiosRequestHeaders and AxiosHeaders.

start940315 commented 1 month ago

We are consider to use our inner type HeadersType in file src/lib/providers/HttpProvider.ts. Thanks! You can now add @ts-ignore and it will work.