Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Class constructor View cannot be invoked without 'new' #433

Open
liamcharmer opened this issue Sep 22, 2020 · 26 comments
Open

TypeError: Class constructor View cannot be invoked without 'new' #433

liamcharmer opened this issue Sep 22, 2020 · 26 comments

Comments

@liamcharmer
Copy link

TypeError: Class constructor View cannot be invoked without 'new'

NativeScript 7 with Vue.js when trying to create the map.

@ebiscardi
Copy link

ebiscardi commented Sep 23, 2020

Same error with NativeScript 7.0.8 with typescript (NativeScript Core)

@mouadhkaabachi
Copy link

Same error

@prlytght
Copy link

prlytght commented Sep 23, 2020

same error w/ Nativescript 7.0.7 with JS (NativeScript Vue)

@prlytght
Copy link

I managed to invoke this error by trying to create an instance outside of the registerElement
CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Uncaught TypeError: Class constructor View cannot be invoked without 'new' at MapViewBase(file: node_modules/nativescript-google-maps-sdk/map-view-common.js:128:46) at MapView(file: node_modules/nativescript-google-maps-sdk/map-view.ios.js:240:27) at (file:///app/bundle.js:887:12) at ./main.js(file:///app/bundle.js:907:30) at __webpack_require__(file: src/webpack/bootstrap:816:0) at checkDeferredModules(file: src/webpack/bootstrap:43:0) at webpackJsonpCallback(file: src/webpack/bootstrap:30:0) at (file:///app/bundle.js:2:57) at require(:1:137) ', reason: '(null)' *** First throw call stack: ( 0 CoreFoundation 0x00007fff2043a126 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20177f78 objc_exception_throw + 48 2 NativeScript 0x000000010d7f62b4 _ZN3tns21NativeScriptException15OnUncaughtErrorEN2v85LocalINS1_7MessageEEENS2_INS1_5ValueEEE + 882 3 NativeScript 0x000000010dc23668 _ZN2v88internal14Me<…>

@prlytght
Copy link

prlytght commented Sep 23, 2020

So my issue turned out be the handling of the plugin by babel

presets: [ [ '@babel/preset-env', { targets: { esmodules: true }, ----> include: ["transform-classes"] } ] ],

the inclusion of "include":"[transform-classes"] solved it for me, I arrived to this answer through this https://stackoverflow.com/questions/36577683/babel-error-class-constructor-foo-cannot-be-invoked-without-new answer. I hope this helps someone.

@benco8186
Copy link

So my issue turned out be the handling of the plugin by babel

presets: [ [ '@babel/preset-env', { targets: { esmodules: true }, ----> include: ["transform-classes"] } ] ],

the inclusion of "include":"[transform-classes"] solved it for me, I arrived to this answer through this https://stackoverflow.com/questions/36577683/babel-error-class-constructor-foo-cannot-be-invoked-without-new answer. I hope this helps someone.

Hi, could you show your code please? I include a .babelrc file with your presets but this solution doesn't work for me :(

@mouadhkaabachi
Copy link

@benco8186
try this:

  1. tns install babel
  2. put this in .babelrc
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "esmodules": true
        },
        "include": [
          "transform-classes"
        ]
      }
    ]
  ]
}

@benco8186
Copy link

@benco8186
try this:

  1. tns install babel
  2. put this in .babelrc
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "esmodules": true
        },
        "include": [
          "transform-classes"
        ]
      }
    ]
  ]
}

Thank you, but it still doesn't work, may be it's because i'm using angular and not vue, also i'm not on nativescript 7, i use nativescript 6.5.3

@benco8186
Copy link

benco8186 commented Sep 28, 2020

I have created a fork and updated nativescript dependencies and typescript compiler version, if you compile the files and replace in the node module by these (map-view-common.js,map-view.android.js,map-view.ios.js,map-view.d.js),it works
the fork url : https://github.com/benco8186/nativescript-google-maps-sdk/

@liamcharmer
Copy link
Author

I have created a fork and updated nativescript dependencies and typescript compiler version, if you compile the files and replace in the node module by these (map-view-common.js,map-view.android.js,map-view.ios.js,map-view.d.js),it works
the fork url : https://github.com/benco8186/nativescript-google-maps-sdk/

Tried but wasn't able to get this achieved

@benco8186
Copy link

I have created a fork and updated nativescript dependencies and typescript compiler version, if you compile the files and replace in the node module by these (map-view-common.js,map-view.android.js,map-view.ios.js,map-view.d.js),it works
the fork url : https://github.com/benco8186/nativescript-google-maps-sdk/

Tried but wasn't able to get this achieved

Clone my fork, in the src folder open a terminal and run npm install, then tsc, don't worry about error informations. After that copy the .js files and in your project, in the original dependency nativescript maps sdk (in node_module), paste these files (replace the Originals). Normally that will work

@mouadhkaabachi
Copy link

I have created a fork and updated nativescript dependencies and typescript compiler version, if you compile the files and replace in the node module by these (map-view-common.js,map-view.android.js,map-view.ios.js,map-view.d.js),it works
the fork url : https://github.com/benco8186/nativescript-google-maps-sdk/

Tried but wasn't able to get this achieved

Clone my fork, in the src folder open a terminal and run npm install, then tsc, don't worry about error informations. After that copy the .js files and in your project, in the original dependency nativescript maps sdk (in node_module), paste these files (replace the Originals). Normally that will work

I tried this and now I got new error : Error: This value is not a native object.

@hypery2k
Copy link

hypery2k commented Oct 7, 2020

getting the same error

@hypery2k
Copy link

hypery2k commented Oct 7, 2020

see #420

@benco8186
Copy link

sorry, don't replace map-view.d.ts by a js file but by the ts file
I attach a zip file with the files I used
maps.zip

@kefahB
Copy link
Contributor

kefahB commented Oct 7, 2020

@hypery2k cool staff 👍

the infoWindowTemplate does not showing on !

@funder7
Copy link

funder7 commented Oct 8, 2020

hi @kefahB, when the infoWindow is not showing? thx

@kefahB
Copy link
Contributor

kefahB commented Oct 8, 2020

@funder7 .. this happen when I click on the marker .. I've did some debugs, it seems the infowindow does not exist at all on the plugin side.

@funder7
Copy link

funder7 commented Oct 10, 2020

.. this happen when I click on the marker .. I've did some debugs, it seems the infowindow does not exist at all on the plugin side.

Okay! Does it happen with the stable version of the plugin and nativescript 7+ or with the plugin version of #420? (nativescript 7 compatibility PR)

@kefahB
Copy link
Contributor

kefahB commented Oct 10, 2020

It work as expected with NS6.3

@RibuRoyson
Copy link

sorry, don't replace map-view.d.ts by a js file but by the ts file
I attach a zip file with the files I used
maps.zip

@benco8186 got this worked..but cameraChanged function not working after i tired this...!!!

@jlafitte
Copy link

jlafitte commented Oct 14, 2020

I could not get this working either with NS7. But as documented here a bit, I was having problems still trying to use the old CLI with ios. So I'm basically using NS7 cli with my NS6 project, and it seems to work I just have to use --force. This will probably hold me over for now, but would really like to get it working with NS7 fully at some point.

@mouadhkaabachi
Copy link

sorry, don't replace map-view.d.ts by a js file but by the ts file
I attach a zip file with the files I used
maps.zip

@benco8186 got this worked..but cameraChanged function not working after i tired this...!!!

@benco8186 same issue

@kefahB
Copy link
Contributor

kefahB commented Nov 6, 2020

Hi,

to resolve this issue you should declare NativeClass() on MapViewDelegateImpl and IndoorDisplayDelegateImpl then you add ts-patch at your package.json (dev), then add the flowing to your tsconfig.json

"plugins": [{
            "transform": "@nativescript/webpack/transformers/ns-transform-native-classes",
            "type": "raw"
        }]

and edit package.json at the script key like this :

"build": "npm run clean && ts-patch install && tsc",

@manishgautam12
Copy link

same error...anyone handle this problem ...please describe breafly

@kefahB
Copy link
Contributor

kefahB commented Nov 5, 2022

Hi every one, this repo isn’t maintained frequently, try This plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests