swagger-typescript-codegen icon indicating copy to clipboard operation
swagger-typescript-codegen copied to clipboard

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

Open timmartin opened this issue 5 years ago • 6 comments

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.

timmartin avatar Oct 09 '19 15:10 timmartin

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

mtennoe avatar Oct 11 '19 06:10 mtennoe

@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",

sloan-dog avatar Mar 09 '20 23:03 sloan-dog

@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

mtennoe avatar Mar 10 '20 09:03 mtennoe

@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.

tgilland95 avatar Apr 16 '20 22:04 tgilland95

same issue, any updates?

bitsofinfo avatar Sep 22 '20 16:09 bitsofinfo

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

mtennoe avatar Sep 23 '20 08:09 mtennoe