NSwag: baseUrl not set correctly for TypeScript with version 13.8.0.0

We have a project which generates TS code using NSwag and today I updated to version 13.8.0.0, and it seems to have broken how baseUrl is set.

Where it previously, in the constructor, generated:

this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl("");

It now generates:

this.baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");

Notice the value isn’t actually set anywhere.

A quick search/replace to the following, fixed the problem:

this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("");

I have made other changes to my code recently, but nothing I can think of would cause this other than upgrading the packages.

I’ll gladly provide more info, if you let me know what you need to know. I was just wondering, if what you were after, was:

this.baseUrl = baseUrl ?? this.getBaseUrl("");

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Thanks for the quick fix!

Sorry, I’m learning TypeScript as I debug… I had a “this.” in the condition. All good. 13.8.1 fixes it. 🙂

Thank you @johnnyreilly for your quick fix! 😉

Actually I think I see a problem https://github.com/RicoSuter/NSwag/pull/3065/commits/fa43fdfd1f1e2f0581c5cc64dd638038bc7ee07f

Give me 10 minutes and I’ll raise a fix PR