Skip to content

Commit 73f9d6d

Browse files
authored
Merge pull request openlayers#7741 from ahocevar/typecheck-full-build
Type checking and full build creation
2 parents 2779fe5 + 9dad964 commit 73f9d6d

24 files changed

+278
-101
lines changed

.babelrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugins": ["jsdoc-closure"],
3+
"parserOpts": {
4+
"parser": "recast"
5+
},
6+
"generatorOpts": {
7+
"generator": "recast"
8+
}
9+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/coverage/
33
/dist/
44
/node_modules/
5+
src/index.js

config/jsdoc/info/api-plugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports.defineTags = function(dictionary) {
88

99
dictionary.defineTag('api', {
1010
onTagged: function(doclet, tag) {
11-
doclet.api = tag.text || 'experimental';
11+
doclet.api = true;
1212
}
1313
});
1414

config/jsdoc/info/publish.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ exports.publish = function(data, opts) {
3030
{define: {isObject: true}},
3131
function() {
3232
if (this.kind == 'class') {
33-
if (!('extends' in this) || typeof this.api == 'string') {
33+
if (!('extends' in this) || typeof this.api == 'boolean') {
3434
classes[this.longname] = this;
3535
return true;
3636
}
3737
}
38-
return (typeof this.api == 'string' ||
38+
return (typeof this.api == 'boolean' ||
3939
this.meta && (/[\\\/]externs$/).test(this.meta.path));
4040
}
4141
],
@@ -53,7 +53,7 @@ exports.publish = function(data, opts) {
5353
docs.filter(function(doc) {
5454
var include = true;
5555
var constructor = doc.memberof;
56-
if (constructor && constructor.substr(-1) === '_') {
56+
if (constructor && constructor.substr(-1) === '_' && constructor.indexOf('module:') === -1) {
5757
assert.strictEqual(doc.inherited, true,
5858
'Unexpected export on private class: ' + doc.longname);
5959
include = false;
@@ -92,7 +92,6 @@ exports.publish = function(data, opts) {
9292
name: doc.longname,
9393
kind: doc.kind,
9494
description: doc.classdesc || doc.description,
95-
stability: doc.api,
9695
path: path.join(doc.meta.path, doc.meta.filename)
9796
};
9897
if (doc.augments) {

config/webpack.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const webpack = require('webpack');
2+
const MinifyPlugin = require('babel-minify-webpack-plugin');
3+
4+
module.exports = {
5+
entry: './src/index.js',
6+
output: {
7+
filename: 'build/ol.js'
8+
},
9+
devtool: 'source-map',
10+
plugins: [
11+
new webpack.optimize.ModuleConcatenationPlugin(),
12+
new MinifyPlugin()
13+
]
14+
};

package.json

+14-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@
99
],
1010
"homepage": "https://openlayers.org/",
1111
"scripts": {
12-
"lint": "eslint tasks test src examples transforms",
13-
"pretest": "npm run lint",
12+
"lint": "eslint tasks test src/ol examples transforms",
13+
"pretest": "npm run lint && npm run typecheck",
1414
"test": "npm run karma -- --single-run",
1515
"karma": "karma start test/karma.config.js",
1616
"serve-examples": "mkdir -p build/examples && webpack --config examples/webpack/config.js --watch & serve build/examples",
17-
"build-examples": "webpack --config examples/webpack/config.js --env=prod"
17+
"build-examples": "webpack --config examples/webpack/config.js --env=prod",
18+
"build-index": "node tasks/generate-index.js",
19+
"prebuild": "npm run build-index",
20+
"build": "webpack --config config/webpack.js",
21+
"presrc-closure": "npm run prebuild",
22+
"src-closure": "babel -q --out-dir build/src-closure src/",
23+
"pretypecheck": "npm run src-closure",
24+
"typecheck": "node tasks/typecheck"
1825
},
1926
"main": "src/ol/index.js",
2027
"repository": {
@@ -36,7 +43,9 @@
3643
},
3744
"devDependencies": {
3845
"async": "2.6.0",
46+
"babel-cli": "6.26.0",
3947
"babel-minify-webpack-plugin": "^0.3.0",
48+
"babel-plugin-jsdoc-closure": "1.0.2",
4049
"clean-css-cli": "4.1.10",
4150
"copy-webpack-plugin": "^4.0.1",
4251
"coveralls": "3.0.0",
@@ -46,6 +55,7 @@
4655
"front-matter": "^2.1.2",
4756
"fs-extra": "5.0.0",
4857
"glob": "7.1.1",
58+
"google-closure-compiler": "20180101.0.0",
4959
"handlebars": "4.0.11",
5060
"html-webpack-plugin": "^2.30.1",
5161
"istanbul": "0.4.5",
@@ -65,6 +75,7 @@
6575
"nomnom": "1.8.1",
6676
"pixelmatch": "^4.0.2",
6777
"proj4": "2.4.4",
78+
"recast": "0.13.0",
6879
"serve": "^6.0.6",
6980
"sinon": "4.2.2",
7081
"url-polyfill": "^1.0.7",

src/ol.jsdoc

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/**
22
* @namespace ol
33
*/
4+

src/ol/View.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import Units from './proj/Units.js';
2424

2525

2626
/**
27-
* @type {number} Default min zoom level for the map view.
27+
* Default min zoom level for the map view.
28+
* @type {number}
2829
*/
2930
const DEFAULT_MIN_ZOOM = 0;
3031

src/ol/control/OverviewMap.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ import {containsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight,
2121

2222

2323
/**
24-
* @type {number} Maximum width and/or height extent ratio that determines
25-
* when the overview map should be zoomed out.
24+
* Maximum width and/or height extent ratio that determines when the overview
25+
* map should be zoomed out.
26+
* @type {number}
2627
*/
2728
const MAX_RATIO = 0.75;
2829

2930

3031
/**
31-
* @type {number} Minimum width and/or height extent ratio that determines
32-
* when the overview map should be zoomed in.
32+
* Minimum width and/or height extent ratio that determines when the overview
33+
* map should be zoomed in.
34+
* @type {number}
3335
*/
3436
const MIN_RATIO = 0.1;
3537

src/ol/index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/**
2-
* @module ol/index
2+
* @module ol
33
*/
44

55
import webgl from './webgl.js';
66

77

88
/**
9+
* Include debuggable shader sources. Default is `true`. This should be set to
10+
* `false` for production builds.
911
* TODO: move to a separate ol-webgl package
10-
* @type {boolean} Include debuggable shader sources. Default is `true`.
11-
* This should be set to `false` for production builds.
12+
* @type {boolean}
1213
*/
1314
export const DEBUG_WEBGL = true;
1415

@@ -60,7 +61,8 @@ export {HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE, WEBGL_EXTENSIONS};
6061

6162

6263
/**
63-
* @type {string} OpenLayers version.
64+
* OpenLayers version.
65+
* @type {string}
6466
*/
6567
export const VERSION = 'v4.6.4';
6668

src/ol/interaction/MouseWheelZoom.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {clamp} from '../math.js';
1212

1313

1414
/**
15-
* @type {number} Maximum mouse wheel delta.
15+
* Maximum mouse wheel delta.
16+
* @type {number}
1617
*/
1718
const MAX_DELTA = 1;
1819

src/ol/renderer/vector.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const _ol_renderer_vector_ = {};
99

1010

1111
/**
12-
* @type {number} Tolerance for geometry simplification in device pixels.
12+
* Tolerance for geometry simplification in device pixels.
13+
* @type {number}
1314
*/
1415
const SIMPLIFY_TOLERANCE = 0.5;
1516

src/ol/renderer/webgl/Map.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import ContextEventType from '../../webgl/ContextEventType.js';
2323

2424

2525
/**
26-
* @type {number} Texture cache high water mark.
26+
* Texture cache high water mark.
27+
* @type {number}
2728
*/
2829
const WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
2930

src/ol/reproj/Triangulation.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@ import {getTransform} from '../proj.js';
88

99

1010
/**
11-
* @type {number} Maximum number of subdivision steps during raster
12-
* reprojection triangulation. Prevents high memory usage and large
13-
* number of proj4 calls (for certain transformations and areas).
14-
* At most `2*(2^this)` triangles are created for each triangulated
15-
* extent (tile/image).
11+
* Maximum number of subdivision steps during raster reprojection triangulation.
12+
* Prevents high memory usage and large number of proj4 calls (for certain
13+
* transformations and areas). At most `2*(2^this)` triangles are created for
14+
* each triangulated extent (tile/image).
15+
* @type {number}
1616
*/
1717
const MAX_SUBDIVISION = 10;
1818

1919

2020
/**
21-
* @type {number} Maximum allowed size of triangle relative to world width.
22-
* When transforming corners of world extent between certain projections,
23-
* the resulting triangulation seems to have zero error and no subdivision
24-
* is performed.
25-
* If the triangle width is more than this (relative to world width; 0-1),
26-
* subdivison is forced (up to `MAX_SUBDIVISION`).
27-
* Default is `0.25`.
21+
* Maximum allowed size of triangle relative to world width. When transforming
22+
* corners of world extent between certain projections, the resulting
23+
* triangulation seems to have zero error and no subdivision is performed. If
24+
* the triangle width is more than this (relative to world width; 0-1),
25+
* subdivison is forced (up to `MAX_SUBDIVISION`). Default is `0.25`.
26+
* @type {number}
2827
*/
2928
const MAX_TRIANGLE_WIDTH = 0.25;
3029

src/ol/reproj/common.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/**
2-
* @type {number} Default maximum allowed threshold (in pixels) for
3-
* reprojection triangulation.
2+
* Default maximum allowed threshold (in pixels) for reprojection
3+
* triangulation.
4+
* @type {number}
45
*/
56
export const ERROR_THRESHOLD = 0.5;
67

78
/**
9+
* Enable automatic reprojection of raster sources. Default is `true`.
810
* TODO: decide if we want to expose this as a build flag or remove it
9-
* @type {boolean} Enable automatic reprojection of raster sources. Default is
10-
* `true`.
11+
* @type {boolean}
1112
*/
1213
export const ENABLE_RASTER_REPROJECTION = true;

src/ol/source/Raster.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {createCanvasContext2D} from '../dom.js';
88
import {listen} from '../events.js';
99
import Event from '../events/Event.js';
1010
import EventType from '../events/EventType.js';
11-
import {Processor} from 'pixelworks';
11+
import {Processor} from 'pixelworks/lib/index';
1212
import {equals, getCenter, getHeight, getWidth} from '../extent.js';
1313
import ImageLayer from '../layer/Image.js';
1414
import TileLayer from '../layer/Tile.js';

src/ol/source/common.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
2-
* @type {string} Default WMS version.
2+
* Default WMS version.
3+
* @type {string}
34
*/
45
export const DEFAULT_WMS_VERSION = '1.3.0';

src/ol/sphere.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
/**
9-
* @module ol/Sphere
9+
* @module ol/sphere
1010
*/
1111
import {toRadians, toDegrees} from './math.js';
1212
import GeometryType from './geom/GeometryType.js';

src/ol/style/AtlasManager.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import Atlas from '../style/Atlas.js';
66

77

88
/**
9-
* @type {number} The size in pixels of the first atlas image.
9+
* The size in pixels of the first atlas image.
10+
* @type {number}
1011
*/
1112
const INITIAL_ATLAS_SIZE = 256;
1213

1314
/**
14-
* @type {number} The maximum size in pixels of atlas images.
15+
* The maximum size in pixels of atlas images.
16+
* @type {number}
1517
*/
1618
const MAX_ATLAS_SIZE = -1;
1719

src/ol/tilegrid/common.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/**
2-
* @type {number} Default maximum zoom for default tile grids.
2+
* Default maximum zoom for default tile grids.
3+
* @type {number}
34
*/
45
export const DEFAULT_MAX_ZOOM = 42;
56

67
/**
7-
* @type {number} Default tile size.
8+
* Default tile size.
9+
* @type {number}
810
*/
911
export const DEFAULT_TILE_SIZE = 256;

src/ol/typedefs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* @module ol/typedefs
33
*/
44

5-
/* global ol:false */
5+
//FIXME Remove when reworking typedefs, export typedefs as variables instead
6+
const ol = {};
67

78
/**
89
* File for all typedefs used by the compiler, and referenced by JSDoc.

0 commit comments

Comments
 (0)