google-maps-services-js icon indicating copy to clipboard operation
google-maps-services-js copied to clipboard

Error: Type '"origin" | undefined' is not assignable to type '"origin"' during Build.

Open us24man opened this issue 1 year ago • 7 comments

While building my Next JS project using "npm run build" I get this error.

Type error: Type '"origin" | undefined' is not assignable to type '"origin"'.
  Type 'undefined' is not assignable to type '"origin"'.
./node_modules/@googlemaps/js-api-loader/src/index.ts:301:5

  299 |   }: LoaderOptions) {
  300 |     this.apiKey = apiKey;
> 301 |     this.authReferrerPolicy = authReferrerPolicy;
      |     ^
  302 |     this.channel = channel;
  303 |     this.client = client;
  304 |     this.id = id || DEFAULT_ID; // Do not allow empty string

This is really annoying as i am unable to deploy the app to Vercel because of this.

Steps to reproduce:

  1. Create a Next JS app
  2. Install the latest version of this package
  3. Build

package version 3.4.0 Next JS version 14.2.3 Typescript version ^5

us24man avatar May 12 '24 20:05 us24man

If you would like to upvote the priority of this issue, please comment below or react on the original post above with :+1: so we can see what is popular when we triage.

@us24man Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

wangela avatar May 12 '24 20:05 wangela

I am unable to deploy my project to vercel due to this. Not sure if others are facing the same issue but this is pretty important for me.

us24man avatar May 18 '24 10:05 us24man

@us24man Hello, I tried to reproduce your problem with same setup and everything works fine, I can build application.

"@googlemaps/google-maps-services-js": "^3.4.0",
"next": "14.2.3",
"typescript": "^5"

What version of Node you're using?

majovkovic avatar May 24 '24 17:05 majovkovic

@majovkovic thank you for responding here. My node version is 20.11.1

us24man avatar May 26 '24 09:05 us24man

@us24man Okay I dont think its about Node version. I'am passing build with 20.11.1. I would try to set "this.authReferrerPolicy" to: this.authReferrerPolicy = authReferrerPolicy || "origin"; or this.authReferrerPolicy = "origin";

majovkovic avatar May 26 '24 10:05 majovkovic

@us24man Okay I dont think its about Node version. I'am passing build with 20.11.1. I would try to set "this.authReferrerPolicy" to: this.authReferrerPolicy = authReferrerPolicy || "origin"; or this.authReferrerPolicy = "origin";

I could go into node_modules and modify this to build locally but the issue will persist on Vercel. But the fact that you could build your Next JS app with this package installed means I might have some other package conflicting with it and causing issues in Build.

us24man avatar May 27 '24 15:05 us24man

Most likely something else causes a problem. Anyway, good luck with your project.

majovkovic avatar May 27 '24 16:05 majovkovic