Skip to content

Commit

Permalink
Merge pull request #826 from ahennr/typescript
Browse files Browse the repository at this point in the history
Move ol-util to typescript
  • Loading branch information
ahennr authored Oct 27, 2022
2 parents 5eba2f8 + a098dea commit 809371c
Show file tree
Hide file tree
Showing 46 changed files with 2,329 additions and 2,146 deletions.
39 changes: 6 additions & 33 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
{
"extends": [
"eslint:recommended"
"@terrestris/eslint-config-typescript"
],
"plugins": [],
"env": {
"browser": true,
"node": true
},
"parser": "@babel/eslint-parser",
"globals": {
"Promise": false
},
"plugins": ["simple-import-sort"],
"rules": {
"no-console": "error",
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"semi": ["error", "always"],
"one-var": ["error", "never"],
"no-confusing-arrow": "error",
"no-unused-vars": ["error", {
"ignoreRestSiblings": true
}],
"key-spacing": ["error", {
"beforeColon": false,
"afterColon": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true
}
}],
"space-infix-ops": ["error", {"int32Hint": false}]
"@typescript-eslint/member-ordering": "off",
"no-underscore-dangle": "off",
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": "warn"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [16.x]

steps:
- name: Checkout sources
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on-push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x

- name: Cache Node.js modules 💾
uses: actions/cache@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ node_modules/
dist/

coverage/

# Ignore IntelliJ iml files
*.iml
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# [8.0.0]

### :rotating_light: BREAKING CHANGES :rotating_light:

* Adds typings for all util functions. This may lead to type conflicts in certain projects
* `CapabilitiesUtil.parseWmsCapabilities(…)` has been removed. Can be replaced by `CapabilitiesUtil.getWmsCapabilities(…)`
* `GeomtryUtil`
* Use `ProjectionLike` (OpenLayers ype) instead of `string` for projections
* `separateGeometries` can either handle simple geometry or geometry array now
* `MapUtil`
* remove `getInteractionsByClass` in MapUtils - Instead:
* set name to interaction and use `getInteractionByName`
* filter interactions using `typeof` in your project
* `ProjectionUtil`:
* Crs definitions are typed now and `defaultProj4CrsDefinitions` moved to an array of `CrsDefinition`
* if custom definitions are used in `initProj4Definitions` these have to migrated in the following way:
```javascript
{
'EPSG:25832': '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
'EPSG:25833': '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
}
```
has to be migrated to
```typescript
[{
crsCode: 'EPSG:25832',
definition: '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
}, {
crsCode: 'EPSG:25833',
definition: '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'}
}]
```
* Crs mappings are typed now and `defaultProj4CrsMappings` moved to an array of `CrsMapping`
* if custom definitions are used in `initProj4DefinitionMappings` these have to migrated in the following way:
```javascript
{
'urn:ogc:def:crs:EPSG::25832': 'EPSG:25832',
'urn:ogc:def:crs:EPSG::25833': 'EPSG:25833'
}
```
has to be migrated to
```typescript
[{
alias: 'urn:ogc:def:crs:EPSG::25832',
mappedCode: 'EPSG:25832'
}, {
alias: 'urn:ogc:def:crs:EPSG::25833',
mappedCode: 'EPSG:25833'
}]
```
* `WfsFilterUtil` as completely been overhauled:
* in contrast to the migrated `WfsFilterUtil`, from now on the search / filter has to be configured using new type `SearchConfig`.
* For example: a filter creation for an exact search of `my search term` in attribute `name` of feature type `TEST:MYTYPE` look slike this:
```typescript
const attributeDetails: AttributeDetails [] = [{
type: 'string',
exactSearch: true,
attributeName: 'name'
}];
const searchTerm = 'my search term';
const filter = WfsFilterUtil.createWfsFilter(searchTerm, attributeDetails);
};
```
File renamed without changes.
18 changes: 8 additions & 10 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module.exports = {
'presets': [
'@babel/env',
'@babel/react',
presets: [
[
'@babel/preset-env', {
targets: {
node: 'current'
}
}
],
'@babel/preset-typescript'
],
'plugins': [
'@babel/plugin-proposal-function-bind',
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-typescript',
['@babel/plugin-proposal-class-properties', { 'loose': false }],
]
};
30 changes: 16 additions & 14 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleFileExtensions: [
'js'
],
moduleDirectories: [
'node_modules'
'ts',
'js',
'json'
],
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'^.+\\.ts$': '<rootDir>/node_modules/babel-jest'
},
transformIgnorePatterns: [
'node_modules/(?!(ol)/)'
'<rootDir>/node_modules/(?!(ol|@babel|jest-runtime|@terrestris))'
],
setupFiles: [
'<rootDir>/jest/__mocks__/shim.js',
'<rootDir>/jest/setup.js'
],
testEnvironment: 'jsdom',
collectCoverage: false,
testRegex: '/src/.*\\.spec.(ts|js)$',
collectCoverageFrom: [
'src/**/*.js',
'!src/TestUtil.js'
'src/**/*.{ts,js}',
'!src/spec/**/*.{ts,js}'
],
coverageDirectory: '<rootDir>/coverage'
roots: [
'./src'
]
};
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.fetch = jest.fn();
1 change: 0 additions & 1 deletion jest/__mocks__/fileMock.js

This file was deleted.

3 changes: 0 additions & 3 deletions jest/__mocks__/shim.js

This file was deleted.

5 changes: 0 additions & 5 deletions jest/setup.js

This file was deleted.

Loading

0 comments on commit 809371c

Please sign in to comment.