mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-11 00:36:14 +00:00
refactor: extract inline type definitions
This commit is contained in:
45
CONTRIBUTING.md
Normal file
45
CONTRIBUTING.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Contributing to `@openstapps/core`
|
||||
|
||||
Please see the appropriate general group contributing guides in [project-management](https://gitlab.com/openstapps/projectmanagement/tree/master/project-docs/workflow).
|
||||
|
||||
## Additional coding style
|
||||
|
||||
### Extract inline type definitions
|
||||
|
||||
For consistency and correct functionality of `core-tools` we need well-defined type assignments.
|
||||
|
||||
Type assignments shall always be primitive types, classes, interfaces, enums or unions. Not allowed are inline type-definitions. Those shall be refactored accordingly:
|
||||
|
||||
```typescript
|
||||
export interface SCPlaceWithoutReferences extends SCThing {
|
||||
...
|
||||
// Use this:
|
||||
geo: SCGeoInformation;
|
||||
|
||||
// Instead of:
|
||||
geo: {
|
||||
point: Point,
|
||||
polygon?: Polygon,
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Reuse the map structure
|
||||
|
||||
If you come around a map-like-type use `SCMap<T>`.
|
||||
|
||||
```typescript
|
||||
// Use this:
|
||||
interface AnyClass{
|
||||
inventory: SCMap<number>;
|
||||
}
|
||||
|
||||
// Instead of:
|
||||
interface AnyClass{
|
||||
inventory?: Array<{ key: string, value: number }>;
|
||||
}
|
||||
// or instead of
|
||||
interface AnyClass{
|
||||
inventory?: { [key: string]: number };
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user