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-ol
There are several ways to use this package. Please choose one:
-
Install as
@types/ol
. This will simulate@types/ol
installation fromnode_modules/@hanreev/types-ol/ol
directory.
Why?- TypeScript compiler will look for types in
node_modules/@types
by 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.paths
intsconfig.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_options
constructor parameter ofol/source/IIIF~IIIF
as optional. ol/Object~BaseObject
derived classes can accept extra options.- Change
ol/size.Size
type fromnumber[]
to[number, number]
- Set
- v3.1.0
- Update to OpenLayers v6.1.1
- Change
ol/extent.Extent
type fromnumber[]
to[number, number, number, number]
- Tools upgrade:
[email protected]
and[email protected]
- v3.0.0
- OpenLayers v6
- v2.0.8
- nullable parameter types
- fix
ol/Feature.setStyle
andol/layer/Vector.setStyle
- v2.0.7
- Add unified
undefined
parameter type--e.g.,ol/Overlay~Overlay#setPosition
method can accept either coordinate orundefined
- Add unified
- v2.0.6
- Fix external import with same member name--e.g.,
GeoJSON
fromgeojson
module 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
object
type - Use relative import path for
ol
modules (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-signatures
array-type
max-line-length
no-self-import
no-unnecessary-class
no-unnecessary-generics
unified-signatures
- v1.0.2
- Sort imports
- NPM compatibility as
@types/ol
- v1.0.1
- Fix
ol/MapBrowserEventType
module
- Fix
- v1.0.0
- Initial release
Copyright © 2019 Rifa'i M. Hanif
Licensed under MIT License