1

I have problem with leaflet dictionary. I saw similar problems on stackoverflow, but it has not been resolved. I reinstalled leaflet and types, but there is still a problem. When I import L from leaflet, i have this problem

I installed leaflet like that npm install leaflet and npm install @types/leaflet

This is line of code where i have problem

import * as L from 'leaflet'

1
  • 1
    Welcome to SO. Please post the exact error you're getting. Commented Jul 24, 2019 at 8:57

1 Answer 1

1

You should use import L from 'leaflet' :)

4
  • I used that earlierModule '"xyz/node_modules/@types/leaflet/index"' has no default export.ts(1192) Commented Jul 24, 2019 at 9:06
  • Can you try : import 'leaflet'; const L = window['L'];
    – Hadrien K.
    Commented Jul 24, 2019 at 9:11
  • 1
    If this doesn't work put allowSyntheticDefaultImports: true in your typescript config file.
    – Hadrien K.
    Commented Jul 24, 2019 at 9:14
  • I must use global and source, now import leaflet in typings.json and package.json. I have a problem with old source type. error TS1110: Type expected. Commented Jul 24, 2019 at 11:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.