Skip to content

Comments

Update TypeScript typings with generic type parameters (#1061)#10

Open
MitchLewis930 wants to merge 2 commits intopr_030_beforefrom
pr_030_after
Open

Update TypeScript typings with generic type parameters (#1061)#10
MitchLewis930 wants to merge 2 commits intopr_030_beforefrom
pr_030_after

Conversation

@MitchLewis930
Copy link

PR_030

Daniel Fischer and others added 2 commits August 29, 2017 20:53
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 00:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the TypeScript test suite by adding comprehensive type-safety demonstrations for Axios HTTP methods. The changes showcase how the library supports generic type parameters to provide compile-time type checking for API responses.

Changes:

  • Added a User interface to demonstrate typed API responses
  • Created typed HTTP method calls using generic type parameters (<User>)
  • Introduced handleUserResponse function to demonstrate type-safe response handling
Comments suppressed due to low confidence (1)

test/typescript/axios.ts:1

  • Inconsistent indentation detected in promise chains. These lines use tabs while the existing promise chains in the file (lines 88-98) use spaces. Please use spaces consistently with the existing code style.
import axios, {

Comment on lines +107 to +129
console.log(response.data.id);
console.log(response.data.name);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
};

axios.get<User>('/user?id=12345')
.then(handleUserResponse)
.catch(handleError);

axios.get<User>('/user', { params: { id: 12345 } })
.then(handleUserResponse)
.catch(handleError);

axios.post<User>('/user', { foo: 'bar' })
.then(handleUserResponse)
.catch(handleError);

axios.post<User>('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } })
.then(handleUserResponse)
.catch(handleError);
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected. The function body uses tabs while the rest of the file appears to use spaces for indentation. Please use spaces consistently with the existing code style.

Suggested change
console.log(response.data.id);
console.log(response.data.name);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
};
axios.get<User>('/user?id=12345')
.then(handleUserResponse)
.catch(handleError);
axios.get<User>('/user', { params: { id: 12345 } })
.then(handleUserResponse)
.catch(handleError);
axios.post<User>('/user', { foo: 'bar' })
.then(handleUserResponse)
.catch(handleError);
axios.post<User>('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } })
.then(handleUserResponse)
.catch(handleError);
console.log(response.data.id);
console.log(response.data.name);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
};
axios.get<User>('/user?id=12345')
.then(handleUserResponse)
.catch(handleError);
axios.get<User>('/user', { params: { id: 12345 } })
.then(handleUserResponse)
.catch(handleError);
axios.post<User>('/user', { foo: 'bar' })
.then(handleUserResponse)
.catch(handleError);
axios.post<User>('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } })
.then(handleUserResponse)
.catch(handleError);

Copilot uses AI. Check for mistakes.
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 this pull request may close these issues.

2 participants