Skip to content

[BUG][typescript-axios] 'this' implicitly has type 'any' because it does not have a type annotation. #8176

@fl-terui

Description

@fl-terui

Bug 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: [email protected]
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.
#8078

Suggest a fix

Reverting # 8078 may cure.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions