JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.js"></script>
JavaScript
var source =
/* Valid geometries:
2.1.2. Point
2.1.3. MultiPoint
2.1.4. LineString
2.1.5. MultiLineString
2.1.6. Polygon
2.1.7. MultiPolygon
/* Use OpenLayers 3 for parsing GeoJSON data */
*/
source.type = "MultiPolygon";
var geoJSONFormat = new ol.format.GeoJSON();
var geoJSONGeometry = geoJSONFormat.readGeometry(source).transform("EPSG:3857", "EPSG:4326");
var geoJSONFeature = new ol.Feature(geoJSONGeometry);
/* Open Browser console and see result */
console.log(geoJSONFormat.writeFeature(geoJSONFeature));