[BUG][typescript-axios] 'this' implicitly has type 'any' because it does not have a type annotation.
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What’s the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
There is an error in the ts file generated from yaml.
async getTagsTagName(tagName: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<InlineResponse200>> {
const localVarAxiosArgs = await TagApiAxiosParamCreator(configuration).getTagsTagName(tagName, options);
return (axios: AxiosInstance = globalAxios, basePath: string = this.basePath) => {
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
> error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
> return (axios: AxiosInstance = globalAxios, basePath: string = this.basePath) => {
openapi-generator version
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: test
version: '1.0'
description:
contact:
name: name
email: mail@example.com
servers:
- url: 'http://localhost:4010'
description: dev
paths:
'/tags/{tag_name}':
parameters:
- schema:
type: string
name: tag_name
in: path
required: true
get:
summary:
tags:
- tag
responses:
'200':
$ref: '#/components/responses/questionlist'
operationId: get-tags-tag_name
description:
components:
schemas:
QuestionHeader:
title: QuestionHeader
x-examples: {}
x-tags:
- question
type: object
description:
properties:
id:
type: string
title:
type: string
consumer_name:
type: string
consumer_icon_url:
type: string
answer_count:
type: number
tags:
type: array
items:
$ref: '#/components/schemas/Tag'
posted_at:
type: string
description: ''
example: '2020-11-29 00:00:00'
pattern: '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
status_type:
type: string
description:
enum:
- '0'
- '1'
- '9'
required:
- id
- title
- consumer_name
- consumer_icon_url
- answer_count
- tags
- posted_at
- status_type
Tag:
title: Tag
type: string
description:
x-tags:
- tag
securitySchemes: {}
responses:
questionlist:
description:
content:
application/json:
schema:
type: object
properties:
totalCount:
type: number
questions:
type: array
items:
$ref: '#/components/schemas/QuestionHeader'
required:
- totalCount
- questions
examples: {}
parameters: {}
tags:
- name: answer
- name: consumer
- name: question
- name: reply
- name: tag
Generation Details
❯ docker run openapitools/openapi-generator-cli version
5.0.0-SNAPSHOT
However, this problem does not occur in v5.0.0-beta3.
Steps to reproduce
Deploy yaml and run the script in docker.
❯ docker run -v ${PWD}/modules/api:/local openapitools/openapi-generator-cli generate -g typescript-axios -i /local/openapi/ask.v1.yaml -o /local/ask-api-client
Related issues/PRs
This merge seems to be the cause. https://github.com/OpenAPITools/openapi-generator/pull/8078
Suggest a fix
Reverting # 8078 may cure.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
'this' implicitly has type 'any' because it does not have a type ...
The error is indeed fixed by inserting this with a type annotation as the first callback parameter. My attempt to do that was...
Read more >'this' implicitly has type 'any' error in TypeScript | bobbyhadz
The error "this implicitly has type any" occurs when we use the `this` keyword outside of classes and its type cannot be inferred....
Read more >"Implicitly has type 'any'" when type annotation is provided
Since "getString" method has an explicit return type (string), in my opinion "type annotation" is provided, and the error should not be thrown....
Read more >Implicitly has return type 'any' because it does not ... - YouTube
I got the following error in angular project " implicitly has return type ' any ' because it does not have a return...
Read more >How to fix this error? "'this' implicitly has type 'any' because it ...
"'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)". This is my sample code from codepen and it is ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Perfect
@macjohnny let me know if you’re happy with the suggested solution. I’ll fix up the failing build etc once approved.
@sahanatroam yes, a rollback would be good, if there is no way to get the „this“ context