smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.04k stars 273 forks source link

import failed: Angular11, leaflet1.7.1; "error TS1192: Module '.../leaflet/index" has no default export" #272

Closed gianmarco-todesco closed 3 years ago

gianmarco-todesco commented 3 years ago

I'm trying to use leaflet-geosearch in an Angular11 webapp. I'm using leaflet 1.7.1. The import of SearchControl.d.ts fails with an error message. Quick fix (SearchControl.d.ts:1):

Replace line:

import L, { ControlPosition, FeatureGroup, MarkerOptions, Map } from 'leaflet';

With lines:

import * as L from 'leaflet'; import { ControlPosition, FeatureGroup, MarkerOptions, Map } from 'leaflet';

pedropapa commented 3 years ago

Try adding "allowSyntheticDefaultImports": true, to your tsconfig.json under angularCompilerOptions option.

gianmarco-todesco commented 3 years ago

It works. Thank you. gm

On Sun, Apr 25, 2021 at 3:08 AM Pedro Papadópolis @.***> wrote:

Try adding "allowSyntheticDefaultImports": true, to your tsconfig.json.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smeijer/leaflet-geosearch/issues/272#issuecomment-826185191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETEEMBNIQ3HQ74TBTR5ASTTKNTSJANCNFSM42SIRRSQ .

smeijer commented 3 years ago

Thanks for the help @pedropapa!

gianmarco-todesco commented 3 years ago

you are welcome gm

On Sun, Apr 25, 2021 at 6:57 PM Stephan Meijer @.***> wrote:

Thanks for the help @pedropapa https://github.com/pedropapa!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smeijer/leaflet-geosearch/issues/272#issuecomment-826354953, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETEEMBX6RPYJM35PLCDVEDTKRCV3ANCNFSM42SIRRSQ .

VjeraTurk commented 3 years ago

@pedropapa In my case, the same flag had to be set in tsconfig.app.json, not tsconfig.json