From 686e49328889378cf51fe2cfd1bceec14232dffe Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 3 Feb 2019 23:45:27 +0100 Subject: [PATCH] Document TypeScript configuration in the README --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index abaa9c3a7e..246b432006 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,28 @@ See the following examples for more detail on bundling OpenLayers with your appl * Using [Parcel](https://github.com/openlayers/ol-parcel) * Using [Browserify](https://github.com/openlayers/ol-browserify) +## TypeScript and VS Code IntelliSense support + +The `ol` package contains a `src/` folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a `tsconfig.json` like this: +```js +{ + "compilerOptions": { + // Enable JavaScript support + "allowJs": true, + // Point to the JSDoc typed sources when using modules from the ol package + "baseUrl": "./", + "paths": { + "ol": ["node_modules/ol/src"], + "ol/*": ["node_modules/ol/src/*"] + } + }, + "include": [ + // Include JavaScript files from the ol package + "node_modules/ol/**/*.js" + ] +} +``` + ## Supported Browsers OpenLayers runs on all modern browsers that support [HTML5](https://html.spec.whatwg.org/multipage/) and [ECMAScript 5](http://www.ecma-international.org/ecma-262/5.1/). This includes Chrome, Firefox, Safari and Edge. For older browsers and platforms like Internet Explorer (down to version 9) and Android 4.x, [polyfills](http://polyfill.io) for `requestAnimationFrame` and `Element.prototype.classList` are required, and using the KML format requires a polyfill for `URL`.