diff --git a/README.md b/README.md index 670651fddb..c92d107461 100644 --- a/README.md +++ b/README.md @@ -105,20 +105,7 @@ The untranspiled sources in the `src/` folder are JSDoc type annotated. For appl ## TypeScript support -When authoring in TypeScript, we recommend you try out the types that are included in the `ol` package. To use these types, add the following entry for `@types/ol` to your `package.json`'s `devDependencies` section: -``` -{ - ... - "devDependencies": { - ... - "@types/ol": "file:node_modules/ol/types", - ... - } -} -``` -Make sure to run `npm install` before and after adding that entry. - -These types are auto-generated by the TypeScript compiler, and will be the only type source in future versions. For now, you can still use third-party types from [Definitely Typed](https://definitelytyped.org) (`npm install @types/ol`) or from [hanreev/types-ol](https://github.com/hanreev/types-ol). +The [ol package](https://npmjs.com/package/ol) includes auto-generated TypeScript declarations as `*.d.ts` files. ## Supported Browsers diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index d6b37c7815..cb4a84af8d 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -2,6 +2,19 @@ ### Next version +#### Included TypeScript declarations + +The [ol package](https://npmjs.com/package/ol) now includes TypeScript declarations as `*.d.ts` files. + +If desired, e.g. when you don't want to adjust your code after upgrading from a previous version where you used `@types/ol`, you can opt out of the included types and use third-party types by specifying aliases in the `compilerOptions` section of `tsconfig.json`, e.g. +```json + "baseUrl": "./", + "paths": { + "ol": ["node_modules/@types/ol"], + "ol/*": ["node_modules/@types/ol/*"] + }, +``` + #### Deprecation of `image` render mode for vector tile layers `renderMode: 'image'` for vector tile layers has been deprecated. Applications continue to work, but a warning will be issued to the console. To get rid of the warning, simply remove the `renderMode` option. diff --git a/package.json b/package.json index d1f2916551..1fcf3e4b62 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build-legacy": "shx rm -rf build/legacy && npm run build-index && webpack --config config/webpack-config-legacy-build.js && cleancss --source-map src/ol/ol.css -o build/legacy/ol.css", "build-site": "npm run build-examples && npm run apidoc && mkdir -p build/site && cp site/index.html build/site && mv build/apidoc build/site/apidoc && mv build/examples build/site/examples", "copy-css": "shx cp src/ol/ol.css build/ol/ol.css", - "generate-types": "npx --package=typescript@3.8.3 -y -- tsc --project config/tsconfig-build.json --declaration --declarationMap --emitDeclarationOnly --outdir build/ol/types", + "generate-types": "npx --package=typescript@3.8.3 -y -- tsc --project config/tsconfig-build.json --declaration --declarationMap --emitDeclarationOnly --outdir build/ol", "transpile": "shx rm -rf build/ol && shx mkdir -p build/ol && shx cp -rf src/ol build/ol/src && node tasks/serialize-workers.cjs && npx --package=typescript@4.3.5 -y -- tsc --project config/tsconfig-build.json", "typecheck": "npx --package=typescript@4.3.5 -y -- 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",