Select to view content in your preferred language

typescript error creating MapView from TypeScript

122
6
Jump to solution
Wednesday
john_cartwright_noaa
Regular Contributor

Hello All,

Can someone tell me how to address the following TypeScript error:

 

 const view = new MapView({
        container: mapDiv.current,
        // ERROR: "Type 'WebMap' is not assignable to type 'MapProperties'."
        map: webmap
      });

 

JSAPI version 4.33

 

Thanks!

 

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Esri Frequent Contributor

Found it! You have the old AMD types installed too, remove those and you should be good.

https://github.com/CI-CMG/pointstore-dashboard/blob/main/package.json#L21

 

Probably want to remove "src" from includes in the node tsconfig too

https://github.com/CI-CMG/pointstore-dashboard/blob/main/tsconfig.node.json#L27

View solution in original post

6 Replies
JonathanDawe_BAS
Occasional Contributor

Is your webmap constructed using `new Webmap`? I don't get a typescript error in my application using arcgis 4.33 with equivalent code. 

0 Kudos
john_cartwright_noaa
Regular Contributor

Thanks for your reply. Yes, it looks like this:

const webmap = new WebMap({
  portalItem: {
    id: "43b93cc9be994efbb5a60a2b2d85f151"
  }
})
const view = new MapView({
  container: mapDiv.current,
  // Type 'WebMap' is not assignable to type 'MapProperties'.
  map: map
});

 

I wonder if I'm missing something in my VSCode configuration then?

0 Kudos
ReneRubalcava
Esri Frequent Contributor

Tried this out with a new vite TS app and not seeing this. Could you try deleting your node_modules/package-lock.json/yarn.lock and try again? If you have a github repro, can take a look.

0 Kudos
john_cartwright_noaa
Regular Contributor

Thanks for the suggestion and your offer to help Rene. Re-creating the node_modules and package-lock.json file did not seem to help.

Here's the repo: git@github.com:CI-CMG/pointstore-dashboard.git

 

 

0 Kudos
ReneRubalcava
Esri Frequent Contributor

Found it! You have the old AMD types installed too, remove those and you should be good.

https://github.com/CI-CMG/pointstore-dashboard/blob/main/package.json#L21

 

Probably want to remove "src" from includes in the node tsconfig too

https://github.com/CI-CMG/pointstore-dashboard/blob/main/tsconfig.node.json#L27

john_cartwright_noaa
Regular Contributor

Thank you Rene - that's really helpful!

0 Kudos