From ad9c4449759c98df4f5131f4828b4956dd6dd3be Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sat, 4 Apr 2020 20:09:59 +0200 Subject: [PATCH] Remove .d.ts files from the package --- README.md | 25 +++++++++++++++++++++++++ config/tsconfig-build.json | 4 ++-- package.json | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c789b6835..dd54fb0ed9 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,31 @@ OpenLayers appreciates contributions of all kinds. We especially want to thank See our [Open Collective](https://opencollective.com/openlayers/contribute/sponsors-214/checkout) page if you too are interested in becoming a regular sponsor. +## IntelliSense support and type checking for VS Code + +The ol package contains a src/ folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a `jsconfig.json` config file in the project root: + +```json +{ + "compilerOptions": { + "checkJs": true, + "baseUrl": "./", + "paths": { + "ol": ["node_modules/ol/src"], + "ol/*": ["node_modules/ol/src/*"] + } + }, + "include": [ + "**/*.js", + "node_modules/ol/**/*.js" + ] +} +``` + +Project template with this configuration: https://gist.github.com/9a7253cb4712e8bf38d75d8ac898e36c. + +Note that the above only works when authoring in plain JavaScript. For similar configurations with a `tsconfig.json` in TypeScript projects, your mileage may vary. You may want to use a [third-party types package](https://github.com/hanreev/types-ol) in this case. + ## 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`. diff --git a/config/tsconfig-build.json b/config/tsconfig-build.json index f5a8720329..56de194321 100644 --- a/config/tsconfig-build.json +++ b/config/tsconfig-build.json @@ -7,8 +7,8 @@ "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true, /* Generates corresponding '.d.ts' file. */ - "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "../build/ol", /* Redirect output structure to the directory. */ diff --git a/package.json b/package.json index 8c59997158..a2930cc3e3 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "build-index": "npm run build-package && node tasks/generate-index", "build-legacy": "shx rm -rf build && npm run build-index && webpack --config config/webpack-config-legacy-build.js && cleancss --source-map src/ol/ol.css -o build/legacy/ol.css", "copy-css": "shx cp src/ol/ol.css build/ol/ol.css", - "transpile": "shx rm -rf build/ol && shx mkdir -p build/ol && shx cp -rf src/ol build/ol/src && node tasks/serialize-workers && npx --package typescript@3.9.0-dev.20200403 tsc --project config/tsconfig-build.json", + "transpile": "shx rm -rf build/ol && shx mkdir -p build/ol && shx cp -rf src/ol build/ol/src && node tasks/serialize-workers && tsc --project config/tsconfig-build.json", "typecheck": "tsc --pretty", "apidoc-debug": "shx rm -rf build/apidoc && node --inspect-brk=9229 ./node_modules/jsdoc/jsdoc.js -R config/jsdoc/api/index.md -c config/jsdoc/api/conf.json -P package.json -d build/apidoc", "apidoc": "shx rm -rf build/apidoc && jsdoc -R config/jsdoc/api/index.md -c config/jsdoc/api/conf.json -P package.json -d build/apidoc"