desandro / masonry

:love_hotel: Cascading grid layout plugin
https://masonry.desandro.com
16.39k stars 2.11k forks source link

How to import Masonry in angular/typescript application ? #1037

Closed Anthony-Breneliere closed 6 years ago

Anthony-Breneliere commented 6 years ago

Hello,

I use successfully Masonry in dev environement, importing it like this:

import Masonry = require( 'masonry-layout/masonry' );

...
            this.grid = new Masonry( '.masonry_grid', {
                itemSelector: 'section',
                columnWidth: 10,
                containerStyle: { position: 'relative' }
              });

...but I cannot build it. The command :

ng build

.. returns:

ERROR in src/app/intervention/details/intervention.details.ts(51,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.

...but I cannot use those forms of import.

I installed @types/Masonry for typescript.

In the masonry.js.. I see

var Masonry = Outlayer.create('masonry');

But how do I import it ?

desandro commented 6 years ago

Thanks for reporting this issue. See possible solutions over in #839