Skip to content

1.0.0 wrong type definition, class AxiosError is not exported #5001

Closed

Description

@trim21

Describe the bug

class AxiosError is exported through axios' property, but type definition says it's exported both way.

To Reproduce

install axios 1.0.0 and create index.ts, transpile it without esModuleInterop

import { AxiosError } from "axios";
import * as axios from "axios";

console.log(AxiosError);
console.log(AxiosError == axios.AxiosError);

Then run output file:

This will pass typescript's type checking, but raise a error at runtime:

import { AxiosError } from "axios";
         ^^^^^^^^^^
SyntaxError: The requested module 'axios' does not provide an export named 'AxiosError'

This is because ini index.d.ts,

export class AxiosError<T = unknown, D = any> extends Error {

this means we have a export class AxiosError in our ./dist/esm/axios.js, but it doesn't, we have only axios.AxiosError = AxiosError and export default axios,

This is correct in type as in here

AxiosError: typeof AxiosError;

Expected behavior

A clear and concise description of what you expected to happen.

Environment

  • Axios Version 1.0.0
  • Node.js Version 16.17.1

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Activity

  1. changed the title [-]1.0.0 wrong type definition[/-] [+]1.0.0 wrong type definition, class `AxiosError` is not exported[/+] on Oct 5, 2022
  2. jasonsaayman commented on Oct 5, 2022

    @jasonsaayman
    Member

    Merged will release asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions