Definitions from this project will be syncronized with official @types/ol package.
This project contains TypeScript definition for OpenLayers v6.1.1 that includes all documented API and protected class members and methods.
Check v5.3.x branch for OpenLayers v5.3.x definitions.
- Fix Generic Types
# NPM
npm i -D @types/ol
# Yarn
yarn add -D @types/ol# NPM
npm i -D @hanreev/types-ol
# Yarn
yarn add -D @hanreev/types-olThere are several ways to use this package. Please choose one:
-
Install as
@types/ol. This will simulate@types/olinstallation fromnode_modules/@hanreev/types-ol/oldirectory.
Why?- TypeScript compiler will look for types in
node_modules/@typesby default. - If you're using Visual Studio Code, its IntelliSense will only recognize types from
node_modules/@types.
// file: package.json { ... "devDependencies": { ... "@hanreev/types-ol": "^3.1.1", "@types/ol": "file:node_modules/@hanreev/types-ol/ol", ... } }
then run
# NPM npm i # Yarn yarn install
Note:
This package must be installed first before adding"@types/ol": "file:node_modules/@hanreev/types-ol/ol"inpackage.json. - TypeScript compiler will look for types in
-
Using
compilerOptions.pathsintsconfig.json// file: tsconfig.json { "compilerOptions": { ... "baseUrl": "./", "paths": { "ol": ["node_modules/@hanreev/types-ol/ol"], "ol/*": ["node_modules/@hanreev/types-ol/ol/*"] }, ... } }
Configuration is located at jsdoc/conf.json
// file: jsdoc/conf.json
{
"source": {
...
"include": [
"openlayers/src/ol" // openlayers source
]
},
...
"typescript": {
"moduleRoot": "openlayers/src", // openlayers source
"declaration": {
"extraOptions": true, // BaseObject derivatives can accept extra properties.
"mode": "multiple", // "single" will generate all declarations in single index.d.ts file.
"strictGenericTypes": false // set to true to extract classes generic type from super class, members and methods.
"strictReturnTypes": false // set to true to include undefined and null return.
}
},
...
}-
Install all dependencies
# NPM npm i # Yarn yarn install
-
Run build
# NPM npm run build-format && npm run lint # Yarn yarn build-format && yarn lint
-
Run test
# NPM npm run lint-test && npm run test # Yarn yarn lint-test && yarn test
Note:
Some definition was patched manually. If you found any error please create a new issue.
- v3.1.1
- Set
opt_optionsconstructor parameter ofol/source/IIIF~IIIFas optional. ol/Object~BaseObjectderived classes can accept extra options.- Change
ol/size.Sizetype fromnumber[]to[number, number]
- Set
- v3.1.0
- Update to OpenLayers v6.1.1
- Change
ol/extent.Extenttype fromnumber[]to[number, number, number, number] - Tools upgrade:
jsdoc@3.6.3andjsdoc-plugin-typescript@2.0.5
- v3.0.0
- OpenLayers v6
- v2.0.8
- nullable parameter types
- fix
ol/Feature.setStyleandol/layer/Vector.setStyle
- v2.0.7
- Add unified
undefinedparameter type--e.g.,ol/Overlay~Overlay#setPositionmethod can accept either coordinate orundefined
- Add unified
- v2.0.6
- Fix external import with same member name--e.g.,
GeoJSONfromgeojsonmodule inol/format/GeoJSON - Order module members by kind
- Fix external import with same member name--e.g.,
- v2.0.5
- Fix anonymous function parameters type
- Fix union types
- v2.0.4
- Fix optional parameters in function type--e.g., third parameter of
{function(*, Array<*>, string=): (Node|undefined)} - Test files fixes
- Fix optional parameters in function type--e.g., third parameter of
- v2.0.3
- OpenLayers 5.3.3 source
- Members and methods sorting
- v2.0.2
- Fix
objecttype - Use relative import path for
olmodules (no-self-import)
- Fix
- v2.0.1
- Refactor definition filenames
- Remove module declaration (no-declare-current-package)
- DefinitelyTyped standard. These dtslint rules are ignored:
adjacent-overload-signaturesarray-typemax-line-lengthno-self-importno-unnecessary-classno-unnecessary-genericsunified-signatures
- v1.0.2
- Sort imports
- NPM compatibility as
@types/ol
- v1.0.1
- Fix
ol/MapBrowserEventTypemodule
- Fix
- v1.0.0
- Initial release
Copyright © 2019 Rifa'i M. Hanif
Licensed under MIT License