Add typings for mongoose-geojson-schema (#21028)

* Add typings fro mongoose-geojson-schema

* Fix lint errors
This commit is contained in:
Bond 2017-10-26 19:26:57 +01:00 committed by Sheetal Nandi
parent 57989134a3
commit e063f03d60
4 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,79 @@
// Type definitions for mongoose-geojson-schema 2.1
// Project: https://github.com/rideamigoscorp/mongoose-geojson-schema#readme
// Definitions by: Bond <https://github.com/bondz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import mongoose = require('mongoose');
declare module 'mongoose' {
namespace Schema {
namespace Types {
class GeoJSON extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'GeoJSON';
}
class Point extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'Point';
}
class MultiPoint extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'MultiPoint';
}
class LineString extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'LineString';
}
class MultiLineString extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'MultiLineString';
}
class Polygon extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'Polygon';
}
class MultiPolygon extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'MultiPolygon';
}
class Geometry extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'Geometry';
}
class GeometryCollection extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'GeometryCollection';
}
class Feature extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'Feature';
}
class FeatureCollection extends SchemaType {
constructor(key: string, options?: object);
cast(geojson: object): this;
static schemaName: 'FeatureCollection';
}
}
}
}

View File

@ -0,0 +1,22 @@
'use strict';
import * as mongoose from 'mongoose';
import * as mongooseGeoJSONSchema from 'mongoose-geojson-schema';
const TestSchema = new mongoose.Schema(
{
title: String,
test: {},
point: mongoose.Schema.Types.Point,
multipoint: mongoose.Schema.Types.MultiPoint,
linestring: mongoose.Schema.Types.LineString,
multilinestring: mongoose.Schema.Types.MultiLineString,
polygon: mongoose.Schema.Types.Polygon,
multipolygon: mongoose.Schema.Types.MultiPolygon,
geometry: mongoose.Schema.Types.Geometry,
geometrycollection: mongoose.Schema.Types.GeometryCollection,
feature: mongoose.Schema.Types.Feature,
featurecollection: mongoose.Schema.Types.FeatureCollection,
},
{ typeKey: '$type', collection: 'echoes' }
);

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mongoose-geojson-schema-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }