From 82c95f6a5efaec05a2b6d1bfdc08d92222be4668 Mon Sep 17 00:00:00 2001 From: Eric Naeseth Date: Fri, 13 Jan 2017 01:50:06 -0800 Subject: [PATCH 1/8] [passport] Support creating Passport instances --- passport/index.d.ts | 9 +++++++-- passport/passport-tests.ts | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/passport/index.d.ts b/passport/index.d.ts index 26ae940a2f..9f6641c552 100644 --- a/passport/index.d.ts +++ b/passport/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Passport 0.3 // Project: http://passportjs.org -// Definitions by: Horiuchi_H +// Definitions by: Horiuchi_H , Eric Naeseth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Express { @@ -60,6 +60,11 @@ declare module 'passport' { transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void; } + interface PassportStatic extends Passport { + Passport: {new(): Passport}; + Authenticator: {new(): Passport}; + } + interface Strategy { name?: string; authenticate(req: express.Request, options?: any): void; @@ -91,7 +96,7 @@ declare module 'passport' { } } - const passport: passport.Passport; + const passport: passport.PassportStatic; export = passport; } diff --git a/passport/passport-tests.ts b/passport/passport-tests.ts index 43630f5c9f..4c1778df7f 100644 --- a/passport/passport-tests.ts +++ b/passport/passport-tests.ts @@ -108,3 +108,8 @@ function ensureAuthenticated(req: express.Request, res: express.Response, next: } } +const passportInstance: passport.Passport = new passport.Passport() +passportInstance.use(new TestStrategy()) + +const authenticator: passport.Passport = new passport.Authenticator() +authenticator.use(new TestStrategy()) \ No newline at end of file From ed3b56890d24209535c35c00a66d7c2551e1a1e9 Mon Sep 17 00:00:00 2001 From: Maksim Sharnin Date: Fri, 13 Jan 2017 23:03:08 +0700 Subject: [PATCH 2/8] mongoose capped types fix --- mongoose/v3/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/v3/index.d.ts b/mongoose/v3/index.d.ts index f5d831b205..34d129a0f7 100644 --- a/mongoose/v3/index.d.ts +++ b/mongoose/v3/index.d.ts @@ -312,7 +312,7 @@ declare module "mongoose" { export interface SchemaOption { autoIndex?: boolean; bufferCommands?: boolean; - capped?: boolean; + capped?: boolean|number|Object; collection?: string; id?: boolean; _id?: boolean; From 0584ef8f74a85ef66de6c9d98f775f3f44d4b481 Mon Sep 17 00:00:00 2001 From: Maksim Sharnin Date: Sat, 14 Jan 2017 02:05:11 +0700 Subject: [PATCH 3/8] added capped option interface --- mongoose/v3/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mongoose/v3/index.d.ts b/mongoose/v3/index.d.ts index 34d129a0f7..8fe05d9b17 100644 --- a/mongoose/v3/index.d.ts +++ b/mongoose/v3/index.d.ts @@ -309,10 +309,16 @@ declare module "mongoose" { (...hookArgs:any[]): any; } + interface CappedOptions { + size: number, + max?: number, + autoIndexId?: boolean + } + export interface SchemaOption { autoIndex?: boolean; bufferCommands?: boolean; - capped?: boolean|number|Object; + capped?: boolean|number|CappedOptions; collection?: string; id?: boolean; _id?: boolean; From 39840a0f970ea33678c1e7840e4b5df8bd90dc2c Mon Sep 17 00:00:00 2001 From: Maksim Sharnin Date: Sat, 14 Jan 2017 02:07:07 +0700 Subject: [PATCH 4/8] fix capped option interface --- mongoose/v3/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mongoose/v3/index.d.ts b/mongoose/v3/index.d.ts index 8fe05d9b17..956d6ef4ae 100644 --- a/mongoose/v3/index.d.ts +++ b/mongoose/v3/index.d.ts @@ -310,9 +310,9 @@ declare module "mongoose" { } interface CappedOptions { - size: number, - max?: number, - autoIndexId?: boolean + size: number; + max?: number; + autoIndexId?: boolean; } export interface SchemaOption { From 4300f138765e9828dce35ef199cc961939148086 Mon Sep 17 00:00:00 2001 From: Pavel Puchkov <0x6368656174@gmail.com> Date: Sat, 14 Jan 2017 10:00:57 +1000 Subject: [PATCH 5/8] Add types for https://github.com/jaredhanson/connect-ensure-login (#13981) * Add "movieImages()" method, add "language" opional parametr * Change Definitions by * Add types for https://github.com/jaredhanson/connect-ensure-login * Add tslint.json for connect-ensure-login * Remove module from connect-ensure-login * Set strictNullChecks to true in connect-ensure-login --- .../connect-ensure-login-tests.ts | 13 ++++ connect-ensure-login/index.d.ts | 73 +++++++++++++++++++ connect-ensure-login/tsconfig.json | 20 +++++ connect-ensure-login/tslint.json | 3 + 4 files changed, 109 insertions(+) create mode 100644 connect-ensure-login/connect-ensure-login-tests.ts create mode 100644 connect-ensure-login/index.d.ts create mode 100644 connect-ensure-login/tsconfig.json create mode 100644 connect-ensure-login/tslint.json diff --git a/connect-ensure-login/connect-ensure-login-tests.ts b/connect-ensure-login/connect-ensure-login-tests.ts new file mode 100644 index 0000000000..68ce1a76a2 --- /dev/null +++ b/connect-ensure-login/connect-ensure-login-tests.ts @@ -0,0 +1,13 @@ +import login = require("connect-ensure-login"); + +login.ensureLoggedIn(); +login.ensureLoggedIn("/login"); +login.ensureLoggedIn({ + redirectTo: "/login", +}); + +login.ensureLoggedOut(); +login.ensureLoggedOut("/"); +login.ensureLoggedOut({ + redirectTo: "/", +}); \ No newline at end of file diff --git a/connect-ensure-login/index.d.ts b/connect-ensure-login/index.d.ts new file mode 100644 index 0000000000..d542f63a90 --- /dev/null +++ b/connect-ensure-login/index.d.ts @@ -0,0 +1,73 @@ +// Type definitions for connect-ensure-login 0.1 +// Project: https://github.com/jaredhanson/connect-ensure-login +// Definitions by: Pavel Puchkov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { RequestHandler } from "express"; + +interface LoggedInOptions { + /** + * URL to redirect to for login, defaults to _/login_ + */ + redirectTo?: string; + /** + * set redirectTo in session, defaults to _true_ + */ + setRedirectTo?: boolean; +} +interface LoggedOutOptions { + /** + * URL to redirect to in logged in, defaults to _/_ + */ + redirectTo?: string; +} + +/** +* Ensure that a user is logged in before proceeding to next route middleware. +* +* This middleware ensures that a user is logged in. If a request is received +* that is unauthenticated, the request will be redirected to a login page (by +* default to `/login`). +* +* Additionally, `returnTo` will be be set in the session to the URL of the +* current request. After authentication, this value can be used to redirect +* the user to the page that was originally requested. +* +* Examples: +* +* app.get('/profile', +* ensureLoggedIn(), +* function(req, res) { ... }); +* +* app.get('/profile', +* ensureLoggedIn('/signin'), +* function(req, res) { ... }); +* +* app.get('/profile', +* ensureLoggedIn({ redirectTo: '/session/new', setReturnTo: false }), +* function(req, res) { ... }); +*/ +export declare function ensureLoggedIn(options?: LoggedInOptions | string): RequestHandler; + +/** +* Ensure that no user is logged in before proceeding to next route middleware. +* +* This middleware ensures that no user is logged in. If a request is received +* that is authenticated, the request will be redirected to another page (by +* default to `/`). +* +* Examples: +* +* app.get('/login', +* ensureLoggedOut(), +* function(req, res) { ... }); +* +* app.get('/login', +* ensureLoggedOut('/home'), +* function(req, res) { ... }); +* +* app.get('/login', +* ensureLoggedOut({ redirectTo: '/home' }), +* function(req, res) { ... }); +*/ +export declare function ensureLoggedOut(options?: LoggedOutOptions | string): RequestHandler; \ No newline at end of file diff --git a/connect-ensure-login/tsconfig.json b/connect-ensure-login/tsconfig.json new file mode 100644 index 0000000000..d683bed903 --- /dev/null +++ b/connect-ensure-login/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "connect-ensure-login-tests.ts" + ] +} diff --git a/connect-ensure-login/tslint.json b/connect-ensure-login/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/connect-ensure-login/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From c10f2864b9ad968aac6d2eae240bd4d1e7b9fc82 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 13 Jan 2017 19:03:04 -0500 Subject: [PATCH 6/8] Implement Geodesy definition (#14004) * Implement Geodesy definition * Geodesy - added tslint * Fixed Geodesy build failing - Removed patch release - strictNullChecks = null - Export class Dms --- geodesy/geodesy-tests.ts | 118 +++++++++++++++++++++++++++++++ geodesy/index.d.ts | 149 +++++++++++++++++++++++++++++++++++++++ geodesy/tsconfig.json | 20 ++++++ geodesy/tslint.json | 1 + 4 files changed, 288 insertions(+) create mode 100644 geodesy/geodesy-tests.ts create mode 100644 geodesy/index.d.ts create mode 100644 geodesy/tsconfig.json create mode 100644 geodesy/tslint.json diff --git a/geodesy/geodesy-tests.ts b/geodesy/geodesy-tests.ts new file mode 100644 index 0000000000..53c3b5c05c --- /dev/null +++ b/geodesy/geodesy-tests.ts @@ -0,0 +1,118 @@ +import { + Mgrs, + Utm, + Dms, + Vector3d, + OsGridRef, + LatLonEllipsoidal as LatLon } from 'geodesy'; + +/** + * Mgrs + */ +const mgrs = new Mgrs(31, 'U', 'D', 'Q', 48251, 11932); +const bandMgrs = mgrs.band; +const datumMgrs = mgrs.datum; +const e100kMgrs = mgrs.e100k; +const e100kLettersMgrs = mgrs.e100kLetters; +const eastingMgrs = mgrs.easting; +const latBandsMgrs = mgrs.latBands; +const n100kMgrs = mgrs.n100k; +const n100kLettersMgrs = mgrs.n100kLetters; +const northingMgrs = mgrs.northing; +const zoneMgrs = mgrs.zone; +mgrs.toString(); +mgrs.toUtm(); + + +// Static Functions +Mgrs.parse('31U DQ 48251 11932'); + +/** + * Utm + */ +const utm = new Utm(31, 'N', 448251, 5411932); +const convergenceUtm = utm.convergence; +const datumUtm = utm.datum; +const eastingUtm = utm.easting; +const hemisphereUtm = utm.hemisphere; +const northingUtm = utm.northing; +const scaleUtm = utm.scale; +utm.toLatLonE(); +utm.toMgrs(); +utm.toString(); + +// Static Functions +Utm.parse('31 N 448251 5411932'); + +/** + * Dms + */ + +Dms.separator = '\u202f'; + +// Static Functions +Dms.parseDMS('51° 28′ 40.12″ N'); + +Dms.toDMS(45); +Dms.toDMS(45, 'dm'); +Dms.toDMS(45, 'd', 2); +Dms.toDMS(45, 'dms', 4); + +Dms.toLat(45); +Dms.toLat(45, 'dm'); +Dms.toLat(45, 'd', 2); +Dms.toLat(45, 'dms', 4); + +Dms.toLon(45); +Dms.toLon(45, 'dm'); +Dms.toLon(45, 'd', 2); +Dms.toLon(45, 'dms', 4); + +Dms.toBrng(90); +Dms.toBrng(90, 'dm'); +Dms.toBrng(90, 'd', 2); +Dms.toBrng(90, 'dms', 4); + +Dms.compassPoint(180); +Dms.compassPoint(180, 1); +Dms.compassPoint(180, 2); +Dms.compassPoint(180, 3); + +/** + * Vector3d + */ +const v1 = new Vector3d(4, 23, 13); +const v2 = new Vector3d(5, 42, 33); +const v3 = new Vector3d(8, 12, 43); + +v1.cross(v2).dot(v3); + +/** + * LatLon + */ +const latlon = new LatLon(52.65798, 1.71605); +const latlonWGS84 = new LatLon(51.4778, -0.0016, LatLon.datum.WGS84); +const pWGS84 = new LatLon(51.4778, -0.0016, LatLon.datum.WGS84); +const pOSGB = pWGS84.convertDatum(LatLon.datum.OSGB36); + +latlon.toUtm(); +latlon.toCartesian(); +latlon.toString(); +latlon.toString('dm'); +latlon.toString('d', 0); + +const mgrsGrid = new LatLon(45.4215296, -75.697193).toUtm().toMgrs(); +mgrsGrid.toString(6); + +/** + * OsGridRef + */ +const gridref = new OsGridRef(651409, 313177); +const osgrid = new OsGridRef(651409.903, 313177.270); +new OsGridRef(651409, 313177).toString(); + +// Static Functions +OsGridRef.latLonToOsGrid(latlon); +OsGridRef.osGridToLatLon(gridref); +OsGridRef.osGridToLatLon(gridref, LatLon.datum.OSGB36); +OsGridRef.parse('TG 51409 13177'); diff --git a/geodesy/index.d.ts b/geodesy/index.d.ts new file mode 100644 index 0000000000..d5436f073d --- /dev/null +++ b/geodesy/index.d.ts @@ -0,0 +1,149 @@ +// Type definitions for geodesy 1.1 +// Project: https://github.com/chrisveness/geodesy +// Definitions by: Denis Carriere +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type format = 'd' | 'dm' | 'dms'; +export type datum = 'ED50'| 'Irl1975'| 'NAD27'| 'NAD83'| 'NTF'| 'OSGB36'| 'Potsdam'| 'TokyoJapan'| 'WGS72'| 'WGS84'; +export type hemisphere = 'N' | 'S'; +export type ellipsoid = 'WGS84' | 'Airy1830' | 'AiryModified' | 'Bessel1841' | 'Clarke1866' | 'Clarke1880IGN' | 'GRS80' | 'Intl1924' | 'WGS72'; +export type transform = [number, number, number, number, number, number, number]; +export type LatLon = LatLonEllipsoidal; + +export interface Datum { + ellipsoid: Ellipsoid; + transform: [number, number, number, number, number, number, number]; +} + +export interface Datums { + ED50: Datum; + Irl1975: Datum; + NAD27: Datum; + NAD83: Datum; + NTF: Datum; + OSGB36: Datum; + Potsdam: Datum; + TokyoJapan: Datum; + WGS72: Datum; + WGS84: Datum; +} + +export interface Ellipsoid { + a: number; + b: number; + f: number; +} + +export interface Ellipsoids { + WGS84: Ellipsoid; + GRS80: Ellipsoid; + Airy1830: Ellipsoid; + AiryModified: Ellipsoid; + Intl1924: Ellipsoid; + Bessel1841: Ellipsoid; +} + +export declare class Mgrs { + zone: number; + band: string; + e100k: string; + n100k: string; + easting: number; + northing: number; + datum: datum; + latBands: string; + e100kLetters: string; + n100kLetters: string; + constructor( + zone: number, + band: string, + e100k: string, + n100k: string, + easting: number, + northing: number, + datum?: datum + ) + static parse(mgrsGridRef: string): Mgrs; + toUtm(): Utm; + toString(digits?: 2 | 4 | 6 | 8 | 10): string; +} + +export declare class Utm { + zone: number; + hemisphere: hemisphere; + easting: number; + northing: number; + datum: Datum; + convergence: number; + scale: number; + constructor( + zone: number, + hemisphere: hemisphere, + easting: number, + northing: number, + datum?: datum, + convergence?: number, + scale?: number + ); + static parse(utmCoord: string, datum?: datum): Utm; + toLatLonE(): LatLon; + toMgrs(): Mgrs; + toString(digits?: number): string; +} + +export declare namespace Dms { + export let separator: string; +} + +export declare class Dms { + static parseDMS(dmsStr: string): number; + static toDMS(deg: number, format?: format, dp?: 0 | 2 | 4): string; + static toLat(deg: number, format?: format, dp?: 0 | 2 | 4): string; + static toLon(deg: number, format?: format, dp?: 0 | 2 | 4): string; + static toBrng(deg: number, format?: format, dp?: 0 | 2 | 4): string; + static compassPoint(bearing: number, precision?: 1 | 2 | 3): string; +} + +export declare class Vector3d { + x: number; + y: number; + z: number; + constructor(x: number, y: number, z: number); + plus(v: Vector3d): Vector3d; + minus(v: Vector3d): Vector3d; + times(x: number): Vector3d; + dividedBy(x: number): Vector3d; + dot(v: Vector3d): number; + cross(v: Vector3d): Vector3d; + negate(): Vector3d; + length(): number; + unit(): Vector3d; + angleTo(v: Vector3d, n?: Vector3d): number; + rotateAround(axis: Vector3d, theta: number): Vector3d; + toString(precision?: number): string; + toLatLonE(datum: Datum): LatLon; + applyTransform(t: number[]): Vector3d; +} + +export declare class OsGridRef { + easting: number; + northing: number; + constructor(easting: number, northing: number); + static latLonToOsGrid(p: LatLon): OsGridRef; + static osGridToLatLon(gridref: OsGridRef, datum?: Datum): LatLon; + static parse(gridref: string): OsGridRef; + toString(digits?: number): string; +} + +export declare class LatLonEllipsoidal { + lat: number; + lon: number; + datum: Datum; + constructor(lat: number, lon: number, datum?: Datum); + toUtm(): Utm; + convertDatum(toDatum: Datum): LatLon; + toCartesian(): Vector3d; + toString(format?: format, dp?: 0 | 2 | 4): string; + static datum: Datums; + static ellipsoid: Ellipsoids; +} diff --git a/geodesy/tsconfig.json b/geodesy/tsconfig.json new file mode 100644 index 0000000000..b73fab8bb3 --- /dev/null +++ b/geodesy/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "geodesy-tests.ts" + ] +} diff --git a/geodesy/tslint.json b/geodesy/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/geodesy/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 3153e0fb9982cd5135d141a0b6d8aa84e33be4e8 Mon Sep 17 00:00:00 2001 From: ersimont Date: Fri, 13 Jan 2017 19:50:55 -0500 Subject: [PATCH 7/8] Add a couple `|null`s (#13956) --- angular/index.d.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index bd4cd76f59..bae6351cfb 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -901,8 +901,17 @@ declare namespace angular { */ interface ILocationService { absUrl(): string; + + /** + * Returns the hash fragment + */ hash(): string; - hash(newHash: string): ILocationService; + + /** + * Changes the hash fragment and returns `$location` + */ + hash(newHash: string|null): ILocationService; + host(): string; /** @@ -942,7 +951,7 @@ declare namespace angular { * @param search New search params * @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign. */ - search(search: string, paramValue: string|number|string[]|boolean): ILocationService; + search(search: string, paramValue: string|number|null|string[]|boolean): ILocationService; state(): any; state(state: any): ILocationService; From 883d3b5b75a344712acd371886cbb83077919e07 Mon Sep 17 00:00:00 2001 From: Maksim Sharnin Date: Sat, 14 Jan 2017 19:03:51 +0700 Subject: [PATCH 8/8] capped codestyle fix --- mongoose/v3/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/v3/index.d.ts b/mongoose/v3/index.d.ts index 956d6ef4ae..80cca9da2f 100644 --- a/mongoose/v3/index.d.ts +++ b/mongoose/v3/index.d.ts @@ -318,7 +318,7 @@ declare module "mongoose" { export interface SchemaOption { autoIndex?: boolean; bufferCommands?: boolean; - capped?: boolean|number|CappedOptions; + capped?: boolean | number | CappedOptions; collection?: string; id?: boolean; _id?: boolean;