Merge branch 'master' of https://github.com/DefinitelyTyped/DefinitelyTyped into nunjucks-fixes

This commit is contained in:
Tyler Johnson
2018-08-15 18:11:01 -06:00
54 changed files with 755 additions and 194 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ interface CopyWebpackPluginConfiguration {
}
interface CopyWebpackPlugin {
new (patterns?: CopyPattern[], options?: CopyWebpackPluginConfiguration): Plugin
new (patterns?: (string | CopyPattern)[], options?: CopyWebpackPluginConfiguration): Plugin
}
declare const copyWebpackPlugin: CopyWebpackPlugin
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"opentracing": ">=0.14.1"
}
}
-29
View File
@@ -1,29 +0,0 @@
import Span = require('./span');
import SpanContext = require('./span_context');
declare class Reference {
/**
* @return The Reference type (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM).
*/
type(): string;
/**
* @return The SpanContext being referred to (e.g., the
* parent in a REFERENCE_CHILD_OF Reference).
*/
referencedContext(): SpanContext;
/**
* Initialize a new Reference instance.
*
* @param type - the Reference type constant (e.g.,
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
* @param referencedContext - the SpanContext being referred
* to. As a convenience, a Span instance may be passed in instead
* (in which case its .context() is used here).
*/
constructor(type: string, referencedContext: SpanContext | Span);
}
export = Reference;
+3 -2
View File
@@ -1,7 +1,8 @@
import Tracer = require('./tracer');
import SpanContext = require('./span_context');
import { Span } from 'opentracing';
declare class Span {
declare class DatadogSpan extends Span {
/**
* Returns the SpanContext object associated with this Span.
*/
@@ -117,4 +118,4 @@ declare class Span {
finish(finishTime?: number): void;
}
export = Span;
export = DatadogSpan;
+4 -2
View File
@@ -1,3 +1,5 @@
import { SpanContext } from 'opentracing';
/**
* SpanContext represents Span state that must propagate to descendant Spans
* and across process boundaries.
@@ -8,7 +10,7 @@
* identify or otherwise contextualize the associated Span instance (e.g., a
* <trace_id, span_id, sampled> tuple).
*/
declare class SpanContext {
declare class DatadogSpanContext extends SpanContext {
/**
* Use to create references to parent spans.
*/
@@ -35,4 +37,4 @@ interface SpanContextLike {
spanId: number;
}
export = SpanContext;
export = DatadogSpanContext;
-37
View File
@@ -1,37 +0,0 @@
import Span = require('./span');
import Reference = require('./reference');
import SpanContext = require('./span_context');
interface SpanOptions {
/**
* a parent SpanContext (or Span, for convenience) that the newly-started
* span will be the child of (per REFERENCE_CHILD_OF). If specified,
* `references` must be unspecified.
*/
childOf?: Span | SpanContext;
/**
* an array of Reference instances, each pointing to a causal parent
* SpanContext. If specified, `fields.childOf` must be unspecified.
*/
references?: Reference[];
/**
* set of key-value pairs which will be set as tags on the newly created
* Span. Ownership of the object is passed to the created span for
* efficiency reasons (the caller should not modify this object after
* calling startSpan).
*/
tags?: {
[key: string]: any;
};
/**
* a manually specified start time for the created Span object. The time
* should be specified in milliseconds as Unix timestamp. Decimal value are
* supported to represent time values with sub-millisecond accuracy.
*/
startTime?: number;
}
export = SpanOptions;
+3 -83
View File
@@ -1,91 +1,11 @@
import SpanOptions = require('./span_options');
import Span = require('./span');
import SpanContext = require('./span_context');
import { Tracer } from 'opentracing';
/**
* Tracer is the entry-point between the instrumentation API and the tracing
* implementation.
*/
declare class Tracer {
/**
* Starts and returns a new Span representing a logical unit of work.
*
* For example:
*
* // Start a new (parentless) root Span:
* var parent = Tracer.startSpan('DoWork');
*
* // Start a new (child) Span:
* var child = Tracer.startSpan('load-from-db', {
* childOf: parent.context(),
* });
*
* // Start a new async (FollowsFrom) Span:
* var child = Tracer.startSpan('async-cache-write', {
* references: [
* opentracing.followsFrom(parent.context())
* ],
* });
*
* @param name - the name of the operation (REQUIRED).
* @param options - options for the newly created span.
* @return A new Span object.
*/
startSpan(name: string, options?: SpanOptions): Span;
declare class DatadogTracer extends Tracer {
/**
* Injects the given SpanContext instance for cross-process propagation
* within `carrier`. The expected type of `carrier` depends on the value of
* `format.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* var clientSpan = ...;
* ...
* // Inject clientSpan into a text carrier.
* var headersCarrier = {};
* Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* // Incorporate the textCarrier into the outbound HTTP request header
* // map.
* Object.assign(outboundHTTPReq.headers, headersCarrier);
* // ... send the httpReq
*
* @param spanContext - the SpanContext to inject into the
* carrier object. As a convenience, a Span instance may be passed
* in instead (in which case its .context() is used for the
* inject()).
* @param format - the format of the carrier.
* @param carrier - see the documentation for the chosen `format`
* for a description of the carrier object.
*/
inject(spanContext: SpanContext | Span, format: string, carrier: any): void;
/**
* Returns a SpanContext instance extracted from `carrier` in the given
* `format`.
*
* OpenTracing defines a common set of `format` values (see
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
* an expected carrier type.
*
* Consider this pseudocode example:
*
* // Use the inbound HTTP request's headers as a text map carrier.
* var headersCarrier = inboundHTTPReq.headers;
* var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
* var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
*
* @param format - the format of the carrier.
* @param carrier - the type of the carrier object is determined by
* the format.
* @return The extracted SpanContext, or null if no such SpanContext could
* be found in `carrier`
*/
extract(format: string, carrier: any): SpanContext | null;
}
export = Tracer;
export = DatadogTracer;
@@ -95,13 +95,15 @@ const withSourceAndArgsAndContextTyped = createBatchResolver<
SomeTestResult,
SomeTestArgs,
SomeTestContext
>(async (sources, args, context) => {
>(async (sources, args, context, info) => {
// $ExpectType ReadonlyArray<SomeTestSource>
const verifySources = sources;
// $ExpectType string
const verifyArgs = args.someArg;
// $ExpectType string
const verifyContext = context.someContextProp;
// $ExpectType GraphQLResolveInfo
const verifyInfo = info;
const result = await asyncBatchFunction(sources);
return result;
+4 -1
View File
@@ -4,6 +4,8 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { GraphQLResolveInfo } from 'graphql';
/**
* Creates a GraphQL.js field resolver that batches together multiple resolves
* together that share the *exact* same GraphQL field selection.
@@ -45,5 +47,6 @@ export type ResolverFunction<TSource, TArgs, TContext, TReturn> = (
export type BatchResolveFunction<TSource, TArgs, TContext, TReturn> = (
sources: ReadonlyArray<TSource>,
args: TArgs,
context: TContext
context: TContext,
info: GraphQLResolveInfo
) => TReturn[] | Promise<TReturn[]>;
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for is-uuid 1.0
// Project: https://github.com/afram/is-uuid#readme
// Definitions by: André Thériault <https://github.com/tedre191>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Returns true if the value is a v1 UUID
* @param value The value to test
*/
export function v1(value: string): boolean;
/**
* Returns true if the value is a v2 UUID
* @param value The value to test
*/
export function v2(value: string): boolean;
/**
* Returns true if the value is a v3 UUID
* @param value The value to test
*/
export function v3(value: string): boolean;
/**
* Returns true if the value is a v4 UUID
* @param value The value to test
*/
export function v4(value: string): boolean;
/**
* Returns true if the value is a v5 UUID
* @param value The value to test
*/
export function v5(value: string): boolean;
/**
* Returns true if the value is a nil UUID
* @param value The value to test
*/
export function nil(value: string): boolean;
/**
* Returns true for v1 - v5 UUID. Will return false for nil UUID
* @param value The value to test
*/
export function anyNonNil(value: string): boolean;
+10
View File
@@ -0,0 +1,10 @@
import * as isUUID from 'is-uuid';
isUUID.v1('857b3f0a-a777-11e5-bf7f-feff819cdc9f');
isUUID.v2('9a7b330a-a736-21e5-af7f-feaf819cdc9f');
isUUID.v3('0a7b330a-a736-35ea-8f7f-feaf019cdc00');
isUUID.v4('c51c80c2-66a1-442a-91e2-4f55b4256a72');
isUUID.v5('5a2de30a-a736-5aea-8f7f-ad0f019cdc00');
isUUID.anyNonNil('c51c80c2-66a1-442a-91e2-4f55b4256a72');
isUUID.nil('00000000-0000-0000-0000-000000000000');
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"is-uuid-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+15 -3
View File
@@ -146,12 +146,24 @@ interface JQueryStatic {
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
* by passing an HTML string.
*
* @param element_elementArray A DOM element to wrap in a jQuery object.
* An array containing a set of DOM elements to wrap in a jQuery object.
* @param element A DOM element to wrap in a jQuery object.
* @see \`{@link https://api.jquery.com/jQuery/ }\`
* @since 1.0
*/
<T extends Element>(element_elementArray: T | ArrayLike<T>): JQuery<T>;
// Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810)
// tslint:disable-next-line:unified-signatures
<T extends Element>(element: T): JQuery<T>;
/**
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
* by passing an HTML string.
*
* @param elementArray An array containing a set of DOM elements to wrap in a jQuery object.
* @see \`{@link https://api.jquery.com/jQuery/ }\`
* @since 1.0
*/
// Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810)
// tslint:disable-next-line:unified-signatures
<T extends Element>(elementArray: T[]): JQuery<T>;
/**
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
* by passing an HTML string.
+6
View File
@@ -69,6 +69,12 @@ function JQueryStatic() {
// $ExpectType JQuery<Element>
$<Element>();
// $ExpectType JQuery<HTMLSelectElement>
$(new HTMLSelectElement());
// $ExpectType JQuery<HTMLSelectElement>
$([new HTMLSelectElement()]);
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432
function issue_19597_378218432() {
const myDiv = $(document.createElement('div'));
+9 -5
View File
@@ -26,6 +26,7 @@
// Lishude <https://github.com/islishude>
// Andrew Makarov <https://github.com/r3nya>
// Zane Hannan AU <https://github.com/ZaneHannanAU>
// Thomas den Hollander <https://github.com/ThomasdenH>
// Eugene Y. Q. Shen <https://github.com/eyqs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -172,6 +173,10 @@ interface SymbolConstructor {
readonly asyncIterator: symbol;
}
declare var Symbol: SymbolConstructor;
interface SharedArrayBuffer {
readonly byteLength: number;
slice(begin?: number, end?: number): SharedArrayBuffer;
}
// Node.js ESNEXT support
interface String {
@@ -349,13 +354,13 @@ declare var Buffer: {
new(array: Uint8Array): Buffer;
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}.
* the given {ArrayBuffer}/{SharedArrayBuffer}.
*
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
*/
new(arrayBuffer: ArrayBuffer): Buffer;
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
/**
* Allocates a new buffer containing the given {array} of octets.
*
@@ -379,8 +384,7 @@ declare var Buffer: {
*
* @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
*/
from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
// from(arrayBuffer: SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Creates a new Buffer using the passed {data}
* @param data data to create a new Buffer
@@ -418,7 +422,7 @@ declare var Buffer: {
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer /*| SharedArrayBuffer */, encoding?: string): number;
byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
+5
View File
@@ -446,6 +446,11 @@ function bufferTests() {
const arrUint8: Uint8Array = new Uint8Array(2);
const buf5: Buffer = Buffer.from(arrUint8);
const buf6: Buffer = Buffer.from(buf1);
const sharedArrayBuffer: SharedArrayBuffer = {
byteLength: 10,
slice: (begin?: number, end?: number) => sharedArrayBuffer
};
const buf7: Buffer = Buffer.from(sharedArrayBuffer);
}
// Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
+3 -3
View File
@@ -27,8 +27,8 @@ import * as puppeteer from "puppeteer";
// Get the "viewport" of the page, as reported by the page.
const dimensions = await page.evaluate(() => {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
width: document.documentElement!.clientWidth,
height: document.documentElement!.clientHeight,
deviceScaleFactor: window.devicePixelRatio
};
});
@@ -300,7 +300,7 @@ puppeteer.launch().then(async browser => {
someElement; // $ExpectType ElementHandle<HTMLDivElement>
// If one passes an ElementHandle, puppeteer will unwrap its DOM reference instead
await page.$eval('.hello-world', (e, x1: HTMLDivElement) => x1.noWrap, someElement);
await page.$eval('.hello-world', (e, x1) => (x1 as any).noWrap, someElement);
browser.close();
})();
+26 -19
View File
@@ -4754,7 +4754,7 @@ declare class MaskedViewComponent extends React.Component<MaskedViewIOSProps> {}
declare const MaskedViewBase: Constructor<NativeMethodsMixin> & typeof MaskedViewComponent;
export class MaskedViewIOS extends MaskedViewBase {}
export interface ModalProps {
export interface ModalBaseProps {
// Only `animated` is documented. The JS code says `animated` is
// deprecated and `animationType` is preferred.
animated?: boolean;
@@ -4784,35 +4784,42 @@ export interface ModalProps {
* The `onShow` prop allows passing a function that will be called once the modal has been shown.
*/
onShow?: (event: NativeSyntheticEvent<any>) => void;
}
export interface ModalPropsIOS {
/**
* The `presentationStyle` determines the style of modal to show
*/
presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen";
/**
* The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations.
* On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.
* @platform ios
*/
supportedOrientations?: (
| "portrait"
| "portrait-upside-down"
| "landscape"
| "landscape-left"
| "landscape-right")[];
supportedOrientations?: Array<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right">;
/**
* The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed.
*/
onDismiss?: () => void;
/**
* The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed.
* The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.
* @platform ios
*/
onOrientationChange?: (event?: NativeSyntheticEvent<any>) => void;
/**
* The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed.
* @platform ios
*/
onDismiss?: () => void;
/**
* The `presentationStyle` determines the style of modal to show
* @platform ios
*/
presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen";
}
export interface ModalPropsAndroid {
/**
* Controls whether to force hardware acceleration for the underlying window.
*/
hardwareAccelerated?: boolean;
}
export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid;
export class Modal extends React.Component<ModalProps> {}
/**
+5
View File
@@ -71,6 +71,7 @@ import {
TextInputSubmitEditingEventData,
WebView,
KeyboardAvoidingView,
Modal,
} from "react-native";
declare module "react-native" {
@@ -754,3 +755,7 @@ const AlertIOSTest = () => {
'email-address'
);
}
const ModalTest = () => (
<Modal hardwareAccelerated />
)
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for react-router-hash-link 1.2
// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
// Definitions by: Sam Baeck <https://github.com/zoompie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
import { LinkProps, NavLinkProps } from 'react-router-dom';
export interface HashLinkProps extends LinkProps {
smooth?: boolean;
scroll?: (element: HTMLElement) => void;
}
export class HashLink extends React.Component<HashLinkProps, any> {}
export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {}
export class NavHashLink extends React.Component<NavHashLinkProps, any> {}
@@ -0,0 +1,24 @@
import * as H from 'history';
import * as React from 'react';
import { match } from 'react-router';
import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link';
interface Props extends NavHashLinkProps {
extraProp: string;
}
const getIsActive = (extraProp: string) => (match: match<any>, location: H.Location) => !!extraProp;
export default function(props: Props) {
const {extraProp, ...rest} = props;
const isActive = getIsActive(extraProp);
return (
<NavHashLink {...rest} isActive={isActive} />
);
}
<HashLink to="url" />;
const acceptRef = (node: HTMLAnchorElement | null) => {
};
<HashLink to="/url" replace={true} innerRef={acceptRef} />;
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"jsx": "react",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-router-hash-link-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1
View File
@@ -1459,6 +1459,7 @@ declare namespace React {
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
alt?: string;
crossOrigin?: "anonymous" | "use-credentials" | "";
decoding?: "async" | "auto" | "sync";
height?: number | string;
sizes?: string;
src?: string;
+1 -1
View File
@@ -774,7 +774,7 @@ const selectedData: Select2.OptionData[] = $("#mySelect2").select2("data");
// jQuery Generic
declare let select: HTMLSelectElement;
const $select: JQuery<HTMLSelectElement> = $(select) as JQuery<HTMLSelectElement>;
const $select: JQuery<HTMLSelectElement> = $(select);
select = $select.select2().get(0);
select = $select.select2({tags: true}).get(0);
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for shallow-equals 1.0
// Project: https://github.com/hughsk/shallow-equals
// Definitions by: Ross Solomon <https://github.com/rsolomon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = shallow_equals;
declare function shallow_equals<A, B>(
a?: A,
b?: B,
compare?: (objA: A, objB: B) => boolean,
): boolean;
@@ -0,0 +1,19 @@
import shallowEquals = require('shallow-equals');
interface A {
foo: string;
}
interface B {
foo: string;
bar?: string;
}
const a: A = { foo: 'bar' };
const b: B = { foo: 'baz' };
function compare(a: A, b: B) {
return false;
}
shallowEquals(a, b);
shallowEquals(a, b, compare);
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "shallow-equals-tests.ts"]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+61
View File
@@ -0,0 +1,61 @@
// Type definitions for steam-login 0.1
// Project: http://github.com/cpancake/steam-login
// Definitions by: Nick Winans <https://github.com/Nicell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { Request, RequestHandler } from 'express';
export interface MiddlewareOptions {
verify: string;
realm: string;
apiKey: string;
useSession?: boolean;
}
export interface SteamUser {
_json: {
steamid: string;
personaname: string;
profileurl: string;
avatar: string;
avatarmedium: string;
avatarfull: string;
personastate: number;
communityvisibilitystate: number;
profilestate?: number;
lastlogoff: number;
commentpermission?: number;
realname?: string;
primaryclanid?: string;
timecreated?: number;
gameid?: string;
gameserverip?: string;
gameextrainfo?: string;
loccountrycode?: string;
locstatecode?: string;
loccityid?: number;
};
steamid: string;
username: string;
name: string;
profile: string;
avatar: {
small: string;
medium: string;
large: string;
};
}
export interface SteamRequest extends Request {
logout?(): (req: Request) => () => void;
user?: SteamUser;
}
export function middleware(opts: MiddlewareOptions): RequestHandler;
export function enforceLogin(redirect: string): RequestHandler;
export function verify(): RequestHandler;
export function authenticate(): RequestHandler;
+35
View File
@@ -0,0 +1,35 @@
// Port of https://github.com/cpancake/steam-login/blob/master/example.js
import * as express from 'express';
import * as steam from 'steam-login';
import * as session from 'express-session';
const app = express();
app.use(session({ resave: false, saveUninitialized: false, secret: 'a secret' }));
app.use(steam.middleware({
realm: 'http://localhost:3000/',
verify: 'http://localhost:3000/verify',
apiKey: process.argv[2]
}
));
app.get('/', (req: steam.SteamRequest, res) => {
res.send(req.user == null ? 'not logged in' : 'hello ' + req.user.username).end();
});
app.get('/authenticate', steam.authenticate(), (req, res) => {
res.redirect('/');
});
app.get('/verify', steam.verify(), (req: steam.SteamRequest, res) => {
res.send(req.user).end();
});
app.get('/logout', steam.enforceLogin('/'), (req: steam.SteamRequest, res) => {
req.logout ? req.logout() : null;
res.redirect('/');
});
app.listen(3000);
console.log('listening');
+23
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",
"steam-login-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for superagent-bunyan 5.2
// Project: https://github.com/joaquimserafim/superagent-bunyan#readme
// Definitions by: Alex Brick <https://github.com/bricka>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as Logger from 'bunyan';
import { Plugin } from 'superagent';
declare function superagentLogger(logger: Logger, requestId?: string, extra?: object): Plugin;
export = superagentLogger;
@@ -0,0 +1,16 @@
import * as request from 'superagent';
import * as bunyan from 'bunyan';
import superagentLogger = require('superagent-bunyan');
const logger = bunyan.createLogger({name: 'my_log'});
logger.info('Hey!');
request
.get('http://localhost:3000')
.use(superagentLogger(logger))
.use(superagentLogger(logger, 'requestId'))
.use(superagentLogger(logger, 'requestId', { foo: 'bar' }))
.use(superagentLogger(logger, undefined, { foo: 'bar' }))
.end((err, res) => {});
+23
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",
"superagent-bunyan-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for ttf2woff2 2.0
// Project: https://github.com/nfroidure/ttf2woff2
// Definitions by: Thomas den Hollander <https://github.com/ThomasdenH>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare function ttf2woff2(inputContent: Buffer): Buffer;
export = ttf2woff2;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"ttf2woff2-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+4
View File
@@ -0,0 +1,4 @@
import ttf2woff2 = require('ttf2woff2');
const input = Buffer.alloc(10);
const result: Buffer = ttf2woff2(input);
+6 -6
View File
@@ -1,13 +1,13 @@
// Type definitions for Underscore 1.8
// Project: http://underscorejs.org/
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Josh Baldwin <https://github.com/jbaldwin>, Christopher Currens <https://github.com/ccurrens>, Cassey Lottman <https://github.com/clottman>
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Josh Baldwin <https://github.com/jbaldwin>, Christopher Currens <https://github.com/ccurrens>, Cassey Lottman <https://github.com/clottman>, Ard Timmerman <https://github.com/confususs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var _: _.UnderscoreStatic;
export = _;
export as namespace _;
// The DOM is not required to be present, but these definitions reference type Element for the
// The DOM is not required to be present, but these definitions reference type Element for the
// isElement check. If the DOM is present, this declaration will merge.
declare global {
interface Element { }
@@ -3631,7 +3631,7 @@ declare module _ {
* @param object Convert this object to a list of [key, value] pairs.
* @return List of [key, value] pairs on `object`.
**/
pairs(object: any): any[][];
pairs(object: any): [string, any][];
/**
* Returns a copy of the object where the keys have become the values and the values the keys.
@@ -4738,7 +4738,7 @@ declare module _ {
* Wrapped type `object`.
* @see _.pairs
**/
pairs(): any[][];
pairs(): [string, any][];
/**
* Wrapped type `object`.
@@ -5692,7 +5692,7 @@ declare module _ {
* Wrapped type `object`.
* @see _.values
**/
values(): _Chain<T>;
values(): _Chain<any>;
/**
* Wrapped type `object`.
@@ -5704,7 +5704,7 @@ declare module _ {
* Wrapped type `object`.
* @see _.pairs
**/
pairs(): _Chain<T[]>;
pairs(): _Chain<[string, any]>;
/**
* Wrapped type `object`.
+10
View File
@@ -527,6 +527,16 @@ function chain_tests() {
.keys() // return ['foo', 'bar'] : string[]
.pairs() // return [['foo', '0'], ['bar', '1']] : string[][]
.value();
interface IYears {
2016: number;
2017: number;
}
let yearObject: IYears = {2016: 1, 2017: 2};
let valuePerYear: number[] = _.chain(yearObject)
.values()
.value()
}
var obj: { [k: string] : number } = {
+102
View File
@@ -0,0 +1,102 @@
// Type definitions for universal-cookie 2.2
// Project: https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie#readme
// Definitions by: Tomi Turtiainen <https://github.com/tomi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export interface CookiesByName {
[cookieName: string]: string;
}
export interface GetOpts {
/**
* do not convert the cookie into an object no matter what
*/
doNotParse: boolean;
}
export interface CookieOpts {
/**
* cookie path, use / as the path if you want your cookie to be accessible on all pages
*/
path?: string;
/**
* absolute expiration date for the cookie
*/
expires?: Date;
/**
* relative max age of the cookie from when the client receives it in second
*/
maxAge?: number;
/**
* domain for the cookie (sub.domain.com or .allsubdomains.com)
*/
domain?: string;
/**
* Is only accessible through HTTPS?
*/
secure?: boolean;
/**
* Is only the server can access the cookie?
*/
httpOnly?: boolean;
}
export type ChangeListenerCallback = (
name: string,
value: string | object,
options: CookieOpts
) => void;
export default class Cookies {
constructor(cookieHeader?: string | CookiesByName);
/**
* Get a cookie value
*
* @param name cookie name
* @param options.doNotParse do not convert the cookie into an object no matter what
*/
get(name: string, options?: GetOpts): string;
/**
* Get all cookies
*
* @param options.doNotParse do not convert the cookie into an object no matter what
*/
getAll(options?: GetOpts): CookiesByName;
/**
* Set a cookie value
*
* @param name cookie name
* @param value save the value and stringify the object if needed
* @param options Support all the cookie options from RFC 6265
*/
set(name: string, value: string | object, options?: CookieOpts): void;
/**
* Set a cookie value
*
* @param name cookie name
* @param options Support all the cookie options from RFC 6265
*/
remove(name: string, options?: CookieOpts): void;
/**
* Add a listener to when a cookie is set or removed.
*
* @param callback Call that will be called with the first argument containing name, value and options of the changed cookie.
*/
addChangeListener(callback: ChangeListenerCallback): void;
/**
* Remove a listener from the change callback.
*/
removeChangeListener(callback: ChangeListenerCallback): void;
}
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "universal-cookie-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,20 @@
import Cookies from "universal-cookie";
const cookies = new Cookies();
new Cookies("My=Cookie");
new Cookies({});
cookies.set("my", "cookie");
cookies.set("object", { some: "value" });
cookies.set("with", "options", {
path: "/"
});
cookies.get("my");
cookies.getAll();
cookies.remove("object");
cookies.remove("object", { path: "/" });
cookies.addChangeListener((name, value) => {});
cookies.removeChangeListener((name, value) => {});
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for varint 5.0
// Project: https://github.com/chrisdickinson/varint#readme
// Definitions by: David Brockman Smoliansky <https://github.com/dbrockman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
export const encode: {
/**
* Encodes `num` into `buffer` starting at `offset`. returns `buffer`, with the encoded varint written into it.
* `varint.encode.bytes` will now be set to the number of bytes modified.
*/
(num: number, buffer: Buffer, offset?: number): Buffer;
/**
* Encodes `num` into `array` starting at `offset`. returns `array`, with the encoded varint written into it.
* If `array` is not provided, it will default to a new array.
* `varint.encode.bytes` will now be set to the number of bytes modified.
*/
(num: number, array?: number[], offset?: number): number[];
/**
* Similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array).
* You can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode.
*/
bytes: number;
};
export const decode: {
/**
* Decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer.
* Throws a `RangeError` when `data` does not represent a valid encoding.
*/
(buf: Buffer | number[], offset?: number): number;
/**
* If you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`.
* This is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode.
*/
bytes: number;
};
/**
* returns the number of bytes this number will be encoded as, up to a maximum of 8.
*/
export function encodingLength(num: number): number;
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "varint-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+17
View File
@@ -0,0 +1,17 @@
import { decode, encode, encodingLength } from 'varint';
encode(0); // $ExpectType number[]
encode(0, []); // $ExpectType number[]
encode(0, [], 0); // $ExpectType number[]
encode(0, Buffer.alloc(1)); // $ExpectType Buffer
encode(0, Buffer.alloc(1), 0); // $ExpectType Buffer
encode.bytes; // $ExpectType number
decode(Buffer.alloc(1)); // $ExpectType number
decode(Buffer.alloc(1), 0); // $ExpectType number
decode.bytes; // $ExpectType number
encodingLength(0); // $ExpectType number
+1 -1
View File
@@ -117,7 +117,7 @@ declare namespace webpack {
[name: string]: string | string[];
}
type EntryFunc = () => (string | string[] | Promise<string | string[]>);
type EntryFunc = () => (string | string[] | Entry | Promise<string | string[] | Entry>);
interface DevtoolModuleFilenameTemplateInfo {
identifier: string;
+16
View File
@@ -55,6 +55,14 @@ configuration = {
entry: () => ['./demo', './demo2']
};
configuration = {
entry: () => ({
p1: "./page1",
p2: "./page2",
p3: "./page3"
})
};
configuration = {
entry: () => new Promise((resolve) => resolve('./demo'))
};
@@ -63,6 +71,14 @@ configuration = {
entry: () => new Promise((resolve) => resolve(['./demo', './demo2']))
};
configuration = {
entry: () => new Promise((resolve) => resolve({
p1: "./page1",
p2: "./page2",
p3: "./page3"
}))
};
//
// https://webpack.github.io/docs/optimization.html
//