mtennoe / swagger-typescript-codegen

A Swagger Codegenerator tailored for typescript.
Apache License 2.0
141 stars 52 forks source link

Property 'default' does not exist on type 'SuperAgentStatic' #98

Open timmartin opened 4 years ago

timmartin commented 4 years ago

I generated some code, and it fails the Typescript build with

Property 'default' does not exist on type 'SuperAgentStatic'

The code in question is

    const agent = this.configureAgentHandler ?
        this.configureAgentHandler(request.default) :
        request.default;

It seems that the default property doesn't exist according to @types/superagent.

At first glance this issue seems to have been introduced by this change. I can't find a related issue or any other context on that change, but it's clearly a deliberate change that fixed some other problem.

I'm using Superagent v5.1.0 and @types/superagent v4.1.3.

mtennoe commented 4 years ago

Hm, interesting that the PR to change this had the opposite problem. @Kosta-Github what versions of superagent and @types/superagent were you using when seeing the original issue and creating the fix?

@timmartin - If this is blocking you in some way and you need and urgent workaround until this is resolved, you can copy the class.mustache file, change it and use it as a custom template file

sloan-dog commented 4 years ago

@here This is is still an issue for me.

"@types/superagent": {
  "version": "4.1.7",

"superagent": {
  "version": "3.8.3",

"swagger-typescript-codegen": "^3.0.3",
mtennoe commented 4 years ago

@sloan-dog - Hm, considering we have seen some inconsistencies in the behavior here, can you try out what happens if you downgrade the version of @types/superagent? If it works in an older version, seems like we in this change broke it for newer versions. In that case we should support the newer version of it imo.

Does it work if you disable typings with an "as any" cast btw? If so, it might be a bug in @types/superagent itself

tgilland95 commented 4 years ago

@here I've had this issue before and for me what resolves it is adjusting compiler options in the tsconfig. This may not solve it for everyone, but adding "esModuleInterop": true fixes my error.

bitsofinfo commented 4 years ago

same issue, any updates?

mtennoe commented 4 years ago

No updates from my side sadly. Have you tried what tgilland95 suggested above?