Skip to content

Commit

Permalink
Export types along the default export (#3564)
Browse files Browse the repository at this point in the history
* Export types along the default export

* Fix lint

* Export only the types

* Fix lint and docs generation

* Added import to the test to make sure this won't happen in the future, removed unneeded files

* remove unneeded files

* Fix tests failure due to build

* Move imports to use generated types
  • Loading branch information
HarelM authored Jan 11, 2024
1 parent b364c52 commit a203720
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
if: runner.os == 'Linux'
run: nohup Xvfb &
echo "DISPLAY=:0" >> $GITHUB_ENV
- run: npm run build-dev
- run: npm run build-dist
- run: npm run test-render
env:
CURRENT_SPLIT_INDEX: ${{ matrix.split }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- _...Add new stuff here..._

### 🐞 Bug fixes

- Fix missing export `Map` type in the `d.ts` file ([#3564](https://github.com/maplibre/maplibre-gl-js/pull/3564))
- _...Add new stuff here..._

## 4.0.0-pre.3
Expand Down
18 changes: 0 additions & 18 deletions build/generate-typings.ts

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@
"generate-shaders": "node --no-warnings --loader ts-node/esm build/generate-shaders.ts",
"generate-struct-arrays": "node --no-warnings --loader ts-node/esm build/generate-struct-arrays.ts",
"generate-style-code": "node --no-warnings --loader ts-node/esm build/generate-style-code.ts",
"generate-typings": "node --no-warnings --loader ts-node/esm build/generate-typings.ts",
"generate-typings": "dts-bundle-generator --umd-module-name=maplibregl -o ./dist/maplibre-gl.d.ts ./src/index.ts",
"generate-docs": "typedoc && node --no-warnings --loader ts-node/esm build/generate-docs.ts",
"generate-images": "node --no-warnings --loader ts-node/esm build/generate-doc-images.ts",
"build-dist": "run-p --print-label generate-typings build-dev build-prod build-csp build-csp-dev build-css",
"build-dist": "npm run generate-typings && run-p --print-label build-dev build-prod build-csp build-csp-dev build-css",
"build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev",
"watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch",
"build-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production",
Expand Down
51 changes: 50 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {prewarm, clearPrewarmedResources} from './util/global_worker_pool';
import {PerformanceUtils} from './util/performance';
import {AJAXError} from './util/ajax';
import {GeoJSONSource} from './source/geojson_source';
import {CanvasSource} from './source/canvas_source';
import {CanvasSource, CanvasSourceSpecification} from './source/canvas_source';
import {ImageSource} from './source/image_source';
import {RasterDEMTileSource} from './source/raster_dem_tile_source';
import {RasterTileSource} from './source/raster_tile_source';
Expand All @@ -33,6 +33,15 @@ import {VideoSource} from './source/video_source';
import {addSourceType, type SourceClass} from './source/source';
import {addProtocol, removeProtocol} from './source/protocol_crud';
import {getGlobalDispatcher} from './util/dispatcher';
import {MapContextEvent, MapMouseEvent, MapTouchEvent, MapWheelEvent} from './ui/events';
import {IControl} from './ui/control/control';
import {ScrollZoomHandler} from './ui/handler/scroll_zoom';
import {TwoFingersTouchZoomRotateHandler} from './ui/handler/shim/two_fingers_touch';
import {DragPanHandler} from './ui/handler/shim/drag_pan';
import {DoubleClickZoomHandler} from './ui/handler/shim/dblclick_zoom';
import {BoxZoomHandler} from './ui/handler/box_zoom';
import {DragRotateHandler} from './ui/handler/shim/drag_rotate';
import {CustomLayerInterface} from './style/style_layer/custom_style_layer';
const version = packageJSON.version;

export type * from '@maplibre/maplibre-gl-style-spec';
Expand Down Expand Up @@ -268,4 +277,44 @@ class MapLibreGL {
//This gets automatically stripped out in production builds.
Debug.extend(MapLibreGL, {isSafari, getPerformanceMetrics: PerformanceUtils.getPerformanceMetrics});

export {
type Map,
type NavigationControl,
type GeolocateControl,
type AttributionControl,
type LogoControl,
type ScaleControl,
type FullscreenControl,
type TerrainControl,
type Popup,
type Marker,
type Style,
type LngLat,
type LngLatBounds,
type Point,
type MercatorCoordinate,
type Evented,
type AJAXError,
type CanvasSource,
type GeoJSONSource,
type ImageSource,
type RasterDEMTileSource,
type RasterTileSource,
type VectorTileSource,
type VideoSource,
type MapMouseEvent,
type MapTouchEvent,
type MapWheelEvent,
type MapContextEvent,
type IControl,
type ScrollZoomHandler,
type TwoFingersTouchZoomRotateHandler,
type DragPanHandler,
type DoubleClickZoomHandler,
type BoxZoomHandler,
type DragRotateHandler,
type CustomLayerInterface,
type CanvasSourceSpecification
};

export default MapLibreGL;
5 changes: 0 additions & 5 deletions test/integration/assets/tiles/package.json

This file was deleted.

46 changes: 0 additions & 46 deletions test/integration/assets/tiles/upgrade.js

This file was deleted.

6 changes: 2 additions & 4 deletions test/integration/browser/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import puppeteer, {Page, Browser} from 'puppeteer';
import st from 'st';
import http from 'http';
import type {Server} from 'http';
import http, {type Server} from 'http';
import type {AddressInfo} from 'net';
import type {Map} from '../../../src/ui/map';
import type {default as MapLibreGL} from '../../../src/index';
import type {default as MapLibreGL, Map} from '../../../dist/maplibre-gl';
import {sleep} from '../../../src/util/test/util';

const testWidth = 800;
Expand Down
7 changes: 2 additions & 5 deletions test/integration/render/run_render_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import http from 'http';
import puppeteer, {Page, Browser} from 'puppeteer';
import v8toIstanbul from 'v8-to-istanbul';
import {localizeURLs} from '../lib/localize-urls';
import maplibregl from '../../../src/index';
import type {StyleSpecification} from '@maplibre/maplibre-gl-style-spec';
import type {CanvasSource} from '../../../src/source/canvas_source';
import type {Map} from '../../../src/ui/map';
import type {PointLike} from '../../../src/ui/camera';
import type {default as MapLibreGL, Map, CanvasSource, PointLike, StyleSpecification} from '../../../dist/maplibre-gl';

const __dirname = dirname(fileURLToPath(import.meta.url));
let maplibregl: typeof MapLibreGL;

type TestData = {
id: string;
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"include": [
"rollup.config.*",
"src/**/*",
"test/bench/**/*"
"test/bench/**/*",
"test/integration/**/*"
],
"exclude": [
"node_modules",
Expand Down

0 comments on commit a203720

Please sign in to comment.