Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using RawAxiosRequestHeaders cause compiler error #6369

Open
dimkajasons opened this issue Apr 24, 2024 · 1 comment · May be fixed by #6389
Open

Using RawAxiosRequestHeaders cause compiler error #6369

dimkajasons opened this issue Apr 24, 2024 · 1 comment · May be fixed by #6389

Comments

@dimkajasons
Copy link

Describe the bug

I need to create a proper type for axios headers object
I have followed #5476 this one - so I can't use AxiosRequestHeaders.

I believe I need to use RawAxiosRequestHeaders. But in case i need to use this type as a generic argument, for example, with React.createContext - it cause compiler error

import { RawAxiosRequestHeaders } from 'axios';

export const RequestHeadersContext = createContext<RawAxiosRequestHeaders | undefined>(undefined);
Exported variable 'RequestHeadersContext' has or is using name 'RawAxiosHeaders' from external module "...node_modules/axios/index" but cannot be named.

I guess it's because interface RawAxiosHeaders is declared locally.

To Reproduce

No response

Code snippet

No response

Expected behavior

No response

Axios Version

No response

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@ramram1048
Copy link

Faced same issue and made PR for fix this.

MAYBE this issue related with tsconfig options, so I just want to paste my reproducible tsconfig options here:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Next.js",
  "compilerOptions": {
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "declaration": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": false,
    "isolatedModules": true,
    "experimentalDecorators": true,
    "incremental": true,
    "noEmit": true,
    "target": "es5",
    "lib": ["dom", "dom.iterable", "es2021"],
    "module": "esnext",
    "jsx": "preserve",
    "jsxImportSource": "@emotion/react",
    "typeRoots": ["./node_modules/@types", "./@types"]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants