Skip to content

Commit 5e35d57

Browse files
authored
Publish flow types (mapbox#7079)
Closes mapbox#6963
1 parent 8bf3301 commit 5e35d57

File tree

8 files changed

+59
-1
lines changed

8 files changed

+59
-1
lines changed

.flowconfig

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
.*/node_modules/@mapbox/geojson-types/fixtures/.*
1212
.*/test/unit/style-spec/fixture/invalidjson.input.json
1313
.*/test/integration/render-tests/.*
14+
.*/test/build/downstream-flow-fixture/.*
1415

1516
[version]
1617
0.77.0

build/mapbox-gl.js.flow

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @flow
2+
/* eslint-disable */
3+
export * from '../src/index.js';

circle.yml

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ jobs:
132132
- run: yarn run build-dev
133133
- run: yarn run build-css
134134
- run: yarn run build-style-spec
135+
- run: yarn run build-flow-types
135136
- run: yarn run test-build
136137
- persist_to_workspace:
137138
root: .

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"build-dev": "rollup -c --environment BUILD:dev",
110110
"watch-dev": "rollup -c --environment BUILD:dev --watch",
111111
"build-min": "rollup -c --environment BUILD:production",
112+
"build-flow-types": "cp build/mapbox-gl.js.flow dist/mapbox-gl.js.flow && cp build/mapbox-gl.js.flow dist/mapbox-gl-dev.js.flow",
112113
"build-css": "postcss -o dist/mapbox-gl.css src/css/mapbox-gl.css",
113114
"build-style-spec": "cd src/style-spec && npm run build && cd ../.. && mkdir -p dist/style-spec && cp src/style-spec/dist/* dist/style-spec",
114115
"watch-css": "postcss --watch -o dist/mapbox-gl.css src/css/mapbox-gl.css",
@@ -139,7 +140,7 @@
139140
"test-flow": "build/run-node build/generate-flow-typed-style-spec && flow .",
140141
"test-flow-cov": "flow-coverage-report -i 'src/**/*.js' -t html",
141142
"test-cov": "nyc --require=@mapbox/flow-remove-types/register --reporter=text-summary --reporter=lcov --cache run-s test-unit test-expressions test-query test-render",
142-
"prepublishOnly": "run-s build-dev build-min build-css build-style-spec test-build",
143+
"prepublishOnly": "run-s build-flow-types build-dev build-min build-css build-style-spec test-build",
143144
"codegen": "build/run-node build/generate-style-code.js && build/run-node build/generate-struct-arrays.js"
144145
},
145146
"files": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[ignore]
2+
.*/node_modules/@mapbox/jsonlint-lines-primitives/.*
3+
.*/node_modules/stylelint/.*
4+
.*/node_modules/unflowify/.*
5+
.*/node_modules/flow-coverage-report/.*
6+
.*/node_modules/babel-plugin-transform-react-remove-prop-types/.*
7+
.*/node_modules/conventional-changelog-core/.*
8+
.*/node_modules/htmltojsx/.*
9+
.*/node_modules/documentation/.*
10+
.*/node_modules/module-deps/.*
11+
.*/node_modules/@mapbox/geojson-types/fixtures/.*
12+
.*/test/unit/style-spec/fixture/invalidjson.input.json
13+
.*/test/integration/render-tests/.*
14+
15+
[include]
16+
../../..
17+
18+
[libs]
19+
../../../flow-typed
20+
21+
[lints]
22+
23+
[options]
24+
25+
[strict]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @flow
2+
/* eslint-disable */
3+
import mapboxgl from '../../..';
4+
const Map = mapboxgl.Map;
5+
const map = new Map({});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @flow
2+
/* eslint-disable */
3+
import mapboxgl from '../../..';
4+
const Map = mapboxgl.Map;
5+
const map = new Map({
6+
container: document.getElementById('map')
7+
});

test/build/published-flow-types.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { test } from 'mapbox-gl-js-test';
2+
import cp from 'child_process';
3+
4+
test('downstream projects can consume published flow types', (t) => {
5+
cp.exec(`${__dirname}/../../node_modules/.bin/flow check --strip-root --json ${__dirname}/downstream-flow-fixture`, {}, (error, stdout) => {
6+
const result = JSON.parse(stdout);
7+
t.equal(result.errors.length, 1);
8+
for (const error of result.errors) {
9+
for (const message of error.message) {
10+
t.notEqual(message.path, 'valid.js');
11+
}
12+
}
13+
t.end();
14+
});
15+
});

0 commit comments

Comments
 (0)