@hanreev/types-ol

OpenLayers 6+ TypeScript definition

Usage no npm install needed!

<script type="module">
  import hanreevTypesOl from 'https://cdn.skypack.dev/@hanreev/types-ol';
</script>

README

Build Status npm version

OpenLayers TypeScript Definition

Definitions from this project will be syncronized with official @types/ol package.

As of v6.6.0, OpenLayers has officially provided its own TypeScript definitions. Installation of third party package like @hanreev/types-ol or @types/ol may no longer be needed.

This project contains TypeScript definition for OpenLayers v6.x.x that includes all documented API and protected class members and methods. Check v5.3.x branch for OpenLayers v5.3.x definitions.

Installation

# NPM
npm i -D @hanreev/types-ol

# Yarn
yarn add -D @hanreev/types-ol

Development version

# NPM
npm i -D @hanreev/types-ol@dev

# Yarn
yarn add -D @hanreev/types-ol@dev

Usage

  • Add ol and ol/* to compilerOptions.paths in tsconfig.json

    // file: tsconfig.json
    
    {
      "compilerOptions": {
        ...
        "baseUrl": "./",
        "paths": {
          "ol": ["node_modules/@hanreev/types-ol/ol"],
          "ol/*": ["node_modules/@hanreev/types-ol/ol/*"]
        },
        ...
      }
    }
    

Configuring and Building TypeScript definition files

Configuration is located at jsdoc/conf.json

// file: jsdoc/conf.json

{
  "source": {
    ...
    "include": [
      "openlayers/src/ol" // openlayers source
    ]
  },
  ...
  "typescript": {
    "moduleRoot": "openlayers/src", // openlayers source
    "definition": {
      "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 definitions were patched manually. If you found any error please create a new issue.

Changelog

CHANGELOG.md

License

Copyright © 2019 Rifa'i M. Hanif
Licensed under MIT License