Merge branch 'master' of github.com:DefinitelyTyped/DefinitelyTyped into ember-error

This commit is contained in:
Mike North 2018-09-24 16:25:55 -07:00
commit 3995e0d15e
102 changed files with 2384 additions and 1798 deletions

View File

@ -6,6 +6,12 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/// <reference types="ember" />
/// <reference types="ember__object" />
/// <reference types="ember__controller" />
/// <reference types="ember__routing" />
/// <reference types="ember__test" />
declare module 'ember-data' {
import Ember from 'ember';
import Evented from '@ember/object/evented';
@ -2088,36 +2094,34 @@ declare module 'ember-data' {
normalize(typeClass: Model, hash: {}): {};
}
}
export default DS;
}
declare module 'ember' {
import DS from 'ember-data';
namespace Ember {
/*
* The store is automatically injected into these objects
*
* https://github.com/emberjs/data/blob/05e95280e11c411177f2fbcb65fd83488d6a9d89/addon/setup-container.js#L71-L78
*/
interface Route {
store: DS.Store;
}
interface Controller {
store: DS.Store;
}
interface DataAdapter {
/**
* The store is automatically injected into these objects
*
* https://github.com/emberjs/data/blob/05e95280e11c411177f2fbcb65fd83488d6a9d89/addon/setup-container.js#L71-L78
*/
module '@ember/controller' {
export default interface Controller {
store: DS.Store;
}
}
module '@ember/routing/route' {
export default interface Route {
store: DS.Store;
}
}
module '@ember/debug/data-adapter' {
export default interface DataAdapter {
store: DS.Store;
}
}
// It is also available to inject anywhere
module '@ember/service' {
interface Registry {
'store': DS.Store;
}
}
export default DS;
}
declare module 'ember-test-helpers' {
import DS from 'ember-data';
interface TestContext {

View File

@ -1,5 +1,6 @@
import Ember from 'ember';
import DS from 'ember-data';
import Controller from '@ember/controller';
class MyModel extends DS.Model {}
@ -15,9 +16,10 @@ Ember.Route.extend({
}
});
Ember.Controller.extend({
Controller.extend({
actions: {
create(): any {
this.queryParams;
return this.store.createRecord('my-model');
}
}

View File

@ -101,7 +101,7 @@ const MyRoute = Ember.Route.extend({
});
// Store is injectable via `inject` and resolves to `DS.Store`.
const SomeComponent = Ember.Component.extend({
const SomeComponent = Ember.Object.extend({
store: Ember.inject.service('store'),
lookUpUsers() {

View File

@ -18,6 +18,11 @@
"@ember/debug/*": ["ember__debug/*"],
"@ember/array": ["ember__array"],
"@ember/array/*": ["ember__array/*"],
"@ember/debug": ["ember__debug"],
"@ember/debug/*": ["ember__debug/*"],
"@ember/controller": ["ember__controller"],
"@ember/routing": ["ember__routing"],
"@ember/routing/*": ["ember__routing/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"]
},

View File

@ -15,6 +15,8 @@
"paths": {
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"]
},

View File

@ -15,7 +15,9 @@
],
"paths": {
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"]
"@ember/object/*": ["ember__object/*"],
"@ember/component": ["ember__component"],
"@ember/component/*": ["ember__component/*"]
},
"types": [],
"noEmit": true,

View File

@ -14,6 +14,12 @@
"../"
],
"paths": {
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"]
},

View File

@ -1,5 +1,5 @@
import EmberResolver from 'ember-resolver';
import { Ember } from 'ember';
import Ember from 'ember';
const MyResolver = EmberResolver.extend({
pluralizedTypes: {

View File

@ -15,6 +15,8 @@
"paths": {
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"]
},

View File

@ -16,6 +16,8 @@
"paths": {
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"]
},

1365
types/ember/index.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,277 @@
import Ember from 'ember';
// $
Ember.$; // $ExpectType JQueryStatic
// A
Ember.A(); // $ExpectType NativeArray<{}>
Ember.A([1, 2]); // $ExpectType NativeArray<number>
// addListener
Ember.addListener({ a: 'foo' }, 'a', {}, () => {});
Ember.addListener({ a: 'foo' }, 'a', null, () => {});
// addObserver
Ember.addObserver({ a: 'foo' }, 'a', null, () => {});
Ember.addObserver({ a: 'foo' }, 'a', {}, () => {});
// aliasMethod
Ember.aliasMethod('init');
// assert
Ember.assert('2+2 should always be 4', 2 + 2 === 4);
// assign
const o1 = Ember.assign({ a: 1 }, { b: 2 });
o1.a; // $ExpectType number
o1.b; // $ExpectType number
o1.c; // $ExpectError
// Ember.bind // $ExpectError
// cacheFor
Ember.cacheFor({ a: 123 }, 'a'); // $ExpectType number | undefined
Ember.cacheFor({ a: 123 }, 'x'); // $ExpectError
// compare
Ember.compare('31', '114'); // $ExpectType number
// copy
Ember.copy({ a: 12 }, true).a; // $ExpectType number
Ember.copy({ a: 12 }); // $ExpectType any
Ember.copy({ a: 12 }).a; // $ExpectType any
Ember.copy({ a: 12 }).b; // $ExpectType any
// debug
Ember.debug('some info for developers');
// deprecate
Ember.deprecate("you shouldn't use this anymore", 3 === 3, {
id: 'no-longer-allowed',
until: '99.0.0'
});
// get
Ember.get({ z: 23 }, 'z'); // $ExpectType number
Ember.get({ z: 23 }, 'zz'); // $ExpectError
// getEngineParent
Ember.getEngineParent(new Ember.EngineInstance()); // $ExpectType EngineInstance
// getOwner
Ember.getOwner(new Ember.Component());
// getProperties
Ember.getProperties({ z: 23 }, 'z').z; // $ExpectType number
Ember.getProperties({ z: 23 }, 'z', 'z').z; // $ExpectType number
Ember.getProperties({ z: 23 }, 'z', 'a').z; // $ExpectError
Ember.getProperties({ z: 23 }, ['z', 'z']).z; // $ExpectType number
Ember.getProperties({ z: 23 }, ['z', 'a']).z; // $ExpectError
// getWithDefault
Ember.getWithDefault({ z: 23 }, 'z', 43); // $ExpectType number
Ember.getWithDefault({ a: undefined as number | undefined, z: 23 }, 'a', 99); // $ExpectType number | undefined
// guidFor
Ember.guidFor({}); // $ExpectType string
Ember.guidFor(''); // $ExpectType string
// isArray
Ember.isArray(''); // $ExpectType boolean
Ember.isArray([]); // $ExpectType boolean
// isBlank
Ember.isBlank(''); // $ExpectType boolean
Ember.isBlank([]); // $ExpectType boolean
// isEmpty
Ember.isEmpty(''); // $ExpectType boolean
Ember.isEmpty([]); // $ExpectType boolean
// isEqual
Ember.isEqual('', 'foo'); // $ExpectType boolean
Ember.isEqual([], ''); // $ExpectType boolean
// isNone
Ember.isNone(''); // $ExpectType boolean
Ember.isNone([]); // $ExpectType boolean
// isPresent
Ember.isPresent(''); // $ExpectType boolean
Ember.isPresent([]); // $ExpectType boolean
// merge
Ember.merge({ a: 12 }, { b: 34 }).a; // $ExpectType number
// observer
const o2 = Ember.Object.extend({
name: 'foo',
age: 3,
nameWatcher: Ember.observer('name', () => {}),
nameWatcher2: Ember.observer('name', 'fullName', () => {})
});
// on
const o3 = Ember.Object.extend({
name: 'foo',
nameWatcher: Ember.on('init', () => {}),
nameWatcher2: Ember.on('destroy', () => {})
});
// removeListener
Ember.addListener(o2, 'create', () => {});
Ember.addListener({}, 'create', () => {}); // $ExpectError
// removeObserver
Ember.removeObserver(o2, 'create', () => {});
Ember.removeObserver({}, 'create', () => {}); // $ExpectError
// runInDebug
Ember.runInDebug(() => {});
// sendEvent
Ember.sendEvent(o2, 'clicked', [1, 2]); // $ExpectType boolean
// set
Ember.set(o2.create(), 'name', 'bar'); // $ExpectType string
Ember.set(o2.create(), 'age', 4); // $ExpectType number
Ember.set(o2.create(), 'nam', 'bar'); // $ExpectError
// setOwner
Ember.setOwner(o2.create(), {});
// setProperties
Ember.setProperties(o2.create(), { name: 'bar' }).name; // $ExpectType string
// tryInvoke
Ember.tryInvoke(o2, 'init');
Ember.tryInvoke(o2, 'init', [441]);
// trySet
Ember.trySet(o2, 'nam', ''); // $ExpectType any
// typeOf
Ember.typeOf(''); // $ExpectType "string"
Ember.typeOf(Ember.A()); // $ExpectType "array"
// warn
Ember.warn('be caseful!');
// VERSION
Ember.VERSION; // $ExpectType string
// onerror
Ember.onerror = (err: Error) => console.error(err);
Ember.onerror = (num: number, err: Error) => console.error(err); // $ExpectError
// Classes
// TODO ContainerProxyMixin
// Ember
// Ember.Application
new Ember.Application(); // $ExpectType Application
Ember.Application.create(); // $ExpectType Application
// Ember.ApplicationInstance
new Ember.ApplicationInstance(); // $ExpectType ApplicationInstance
Ember.ApplicationInstance.create(); // $ExpectType ApplicationInstance
// TODO: Ember.ApplicationInstance.BootOptions
// Ember.Array
const a1: Ember.Array<string> = [];
const a2: Ember.Array<string> = {}; // $ExpectError
// Ember.ArrayProxy
new Ember.ArrayProxy<number>([3, 3, 2]); // $ExpectType ArrayProxy<number>
// Ember.Checkbox
const cb = new Ember.Checkbox(); // $ExpectType Checkbox
cb.tagName; // $ExpectType string
// Ember.Component
const C1 = Ember.Component.extend({ classNames: ['foo'] });
class C2 extends Ember.Component {
classNames = ['foo'];
}
const c1 = new C1();
const c2 = new C2();
C1.create();
C2.create();
c1.didInsertElement();
c2.didInsertElement();
// Ember.ComputedProperty
const cp: Ember.ComputedProperty<string, string> = Ember.computed('foo', {
get(): string {
return '';
},
set(_key: string, newVal: string): string {
return '';
}
});
// Ember.ContainerDebugAdapter
const cda = new Ember.ContainerDebugAdapter(); // $ExpectType ContainerDebugAdapter
// Ember.Controller
const con = new Ember.Controller(); // $ExpectType Controller
// Ember.CoreObject
const co = new Ember.CoreObject(); // $ExpectType CoreObject
// Ember.DataAdapter
const da = new Ember.DataAdapter(); // $ExpectType DataAdapter
// Ember.Debug
Ember.Debug.registerDeprecationHandler(() => {});
Ember.Debug.registerWarnHandler(() => {});
// Ember.DefaultResolver
const dr = new Ember.DefaultResolver();
dr.resolve('route:index');
dr.resolve(); // $ExpectError
// Ember.Engine
const e1 = new Ember.Engine();
e1.register('data:foo', {}, { instantiate: false });
// Ember.EngineInstance
const ei1 = new Ember.EngineInstance();
ei1.lookup('data:foo');
// Ember.Error
new Ember.Error('Halp!');
// Ember.Evented
const oe1 = Ember.Object.extend(Ember.Evented).create();
oe1.trigger('foo');
oe1.on('bar', () => {});
oe1.on('bar', { foo() {}}, () => {});
// Ember.HashLocation
const hl = new Ember.HashLocation(); // $ExpectType HashLocation
// Ember.Helper
const h1 = Ember.Helper.extend({
compute() {
this.recompute();
return '';
}
});
// Ember.HistoryLocation
const hil = new Ember.HistoryLocation(); // $ExpectType HistoryLocation
// Ember.LinkComponent
Ember.LinkComponent.create(); // $ExpectType LinkComponent
// Ember.Mixin
Ember.Object.extend(Ember.Mixin.create({ foo: 'bar' }), {
baz() {
this.foo; // $ExpectType string
}
});
// Ember.MutableArray
const ma1: Ember.MutableArray<string> = [
'money',
'in',
'the',
'bananna',
'stand'
];
ma1.addObject('!'); // $ExpectType string
ma1.filterBy(''); // $ExpectType NativeArray<string>
// Ember.MutableEnumerable
// tslint:disable-next-line:prefer-const
let me1: Ember.MutableEnumerable<[string]> = null as any;
me1.compact(); // $ExpectType NativeArray<[string]>
// Ember.Namespace
const myNs = Ember.Namespace.extend({});
// Ember.NativeArray
const na: Ember.NativeArray<number> = Ember.A([2, 3, 4]);
na; // $ExpectType NativeArray<number>
na.clear(); // $ExpectType NativeArray<number>
// Ember.NoneLocation
new Ember.NoneLocation(); // $ExpectType NoneLocation
// Ember.Object
new Ember.Object();
// Ember.ObjectProxy
new Ember.ObjectProxy(); // $ExpectType ObjectProxy
// Ember.Observable
Ember.Object.extend(Ember.Observable, {});
// Ember.PromiseProxyMixin
Ember.Object.extend(Ember.PromiseProxyMixin, {
foo() {
this.reason; // $ExpectType any
this.isPending; // $ExpectType boolean
}
});
// Ember.Route
new Ember.Route();
// Ember.Router
new Ember.Router();
// Ember.Service
new Ember.Service();
// Ember.Test
Ember.Test;
// Ember.Test.Adapter
new Ember.Test.Adapter();
// Ember.Test.QUnitAdapter
new Ember.Test.QUnitAdapter();
// Ember.TextArea
new Ember.TextArea();
// Ember.TextField
new Ember.TextField();
// Ember.Helper
// helper
Ember.Helper.helper(([a, b]: [number, number]) => a + b);
// Ember.String
Ember.String;
// htmlSafe
Ember.String.htmlSafe('foo'); // $ExpectType SafeString
// isHTMLSafe
Ember.String.isHTMLSafe('foo'); // $ExpectType boolean
// Ember.Test
Ember.Test.checkWaiters(); // $ExpectType boolean
// checkWaiters

View File

@ -25,8 +25,17 @@
"@ember/array/*": ["ember__array/*"],
"@ember/debug": ["ember__debug"],
"@ember/debug/*": ["ember__debug/*"],
"@ember/routing": ["ember__routing"],
"@ember/routing/*": ["ember__routing/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"],
"@ember/component": ["ember__component"],
"@ember/component/*": ["ember__component/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/controller": ["ember__controller"],
"@ember/polyfills": ["ember__polyfills"]
},
"types": [],
@ -55,6 +64,7 @@
"test/debug.ts",
"test/detect-instance.ts",
"test/detect.ts",
"test/ember-module-tests.ts",
"test/ember-tests.ts",
"test/engine-instance.ts",
"test/engine.ts",

View File

@ -0,0 +1,21 @@
import Resolver from "@ember/engine/-private/resolver";
import Application from "@ember/application";
/**
* The DefaultResolver defines the default lookup rules to resolve
* container lookups before consulting the container for registered
* items:
*/
export default class DefaultResolver extends Resolver {
/**
* This method is called via the container's resolver method.
* It parses the provided `fullName` and then looks up and
* returns the appropriate template or class.
*/
resolve(fullName: string): {};
/**
* This will be set to the Application instance when it is
* created.
*/
namespace: Application;
}

View File

@ -0,0 +1,16 @@
import { EventDispatcherEvents } from "@ember/application/types";
/**
* `Ember.EventDispatcher` handles delegating browser events to their
* corresponding `Ember.Views.` For example, when you click on a view,
* `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets
* called.
*/
export default class EventDispatcher extends Object {
/**
* The set of events names (and associated handler function names) to be setup
* and dispatched by the `EventDispatcher`. Modifications to this list can be done
* at setup time, generally via the `Ember.Application.customEvents` hash.
*/
events: EventDispatcherEvents;
}

View File

@ -0,0 +1,13 @@
import { EmberClassConstructor } from "@ember/object/-private/types";
/**
* A registry used to store factory and option information keyed
* by type.
*/
export default class Registry {
register(
fullName: string,
factory: EmberClassConstructor<any>,
options?: { singleton?: boolean }
): void;
}

View File

@ -1,4 +1,35 @@
import Ember from 'ember';
/**
* Display a deprecation warning with the provided message and a stack trace
* (Chrome and Firefox only).
*/
export function deprecate(
message: string,
test: boolean,
options: { id: string; until: string }
): any;
export const deprecate: typeof Ember.deprecate;
export const deprecateFunc: typeof Ember.deprecateFunc;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
export function deprecate(
message: string,
test: boolean,
options?: { id?: string; until?: string }
): any;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
export function deprecateFunc<Func extends ((...args: any[]) => any)>(
message: string,
func: Func
): Func;
/**
* Alias an old, deprecated method with its new counterpart.
*/
export function deprecateFunc<Func extends ((...args: any[]) => any)>(
message: string,
options: { id: string; until: string },
func: Func
): Func;

View File

@ -1,3 +1 @@
import Ember from 'ember';
export default class GlobalsResolver extends Ember.DefaultResolver { }
export { default } from '@ember/application/-private/default-resolver';

View File

@ -4,10 +4,133 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import Ember from 'ember';
import Engine from '@ember/engine';
import ApplicationInstance from '@ember/application/instance';
import EventDispatcher from '@ember/application/-private/event-dispatcher';
import { EventDispatcherEvents } from '@ember/application/types';
import DefaultResolver from '@ember/application/-private/default-resolver';
import { Router } from '@ember/routing';
import Registry from '@ember/application/-private/registry';
export default class Application extends Ember.Application { }
export const getOwner: typeof Ember.getOwner;
export const onLoad: typeof Ember.onLoad;
export const runLoadHooks: typeof Ember.runLoadHooks;
export const setOwner: typeof Ember.setOwner;
/**
* An instance of Ember.Application is the starting point for every Ember application. It helps to
* instantiate, initialize and coordinate the many objects that make up your app.
*/
export default class Application extends Engine {
/**
* Call advanceReadiness after any asynchronous setup logic has completed.
* Each call to deferReadiness must be matched by a call to advanceReadiness
* or the application will never become ready and routing will not begin.
*/
advanceReadiness(): void;
/**
* Use this to defer readiness until some condition is true.
*
* This allows you to perform asynchronous setup logic and defer
* booting your application until the setup has finished.
*
* However, if the setup requires a loading UI, it might be better
* to use the router for this purpose.
*/
deferReadiness(): void;
/**
* defines an injection or typeInjection
*/
inject(factoryNameOrType: string, property: string, injectionName: string): void;
/**
* This injects the test helpers into the window's scope. If a function of the
* same name has already been defined it will be cached (so that it can be reset
* if the helper is removed with `unregisterHelper` or `removeTestHelpers`).
* Any callbacks registered with `onInjectHelpers` will be called once the
* helpers have been injected.
*/
injectTestHelpers(): void;
/**
* registers a factory for later injection
* @param fullName type:name (e.g., 'model:user')
* @param factory (e.g., App.Person)
*/
register(fullName: string, factory: any): void;
/**
* This removes all helpers that have been registered, and resets and functions
* that were overridden by the helpers.
*/
removeTestHelpers(): void;
/**
* Reset the application. This is typically used only in tests.
*/
reset(): void;
/**
* This hook defers the readiness of the application, so that you can start
* the app when your tests are ready to run. It also sets the router's
* location to 'none', so that the window's location will not be modified
* (preventing both accidental leaking of state between tests and interference
* with your testing framework).
*/
setupForTesting(): void;
/**
* The DOM events for which the event dispatcher should listen.
*/
customEvents: EventDispatcherEvents;
/**
* The Ember.EventDispatcher responsible for delegating events to this application's views.
*/
eventDispatcher: EventDispatcher;
/**
* Set this to provide an alternate class to Ember.DefaultResolver
*/
resolver: DefaultResolver;
/**
* The root DOM element of the Application. This can be specified as an
* element or a jQuery-compatible selector string.
*
* This is the element that will be passed to the Application's, eventDispatcher,
* which sets up the listeners for event delegation. Every view in your application
* should be a child of the element you specify here.
*/
rootElement: HTMLElement | string;
/**
* Called when the Application has become ready.
* The call will be delayed until the DOM has become ready.
*/
ready: (...args: any[]) => any;
/**
* Application's router.
*/
Router: Router;
registry: Registry;
/**
* Initialize the application and return a promise that resolves with the `Application`
* object when the boot process is complete.
*/
boot(): Promise<Application>;
/**
* Create an ApplicationInstance for this Application.
*/
buildInstance(options?: object): ApplicationInstance;
}
/**
* Framework objects in an Ember application (components, services, routes, etc.)
* are created via a factory and dependency injection system. Each of these
* objects is the responsibility of an "owner", which handled its
* instantiation and manages its lifetime.
*/
export function getOwner(object: any): any;
/**
* `setOwner` forces a new owner on a given object instance. This is primarily
* useful in some testing cases.
*/
export function setOwner(object: any, owner: any): void;
/**
* Detects when a specific package of Ember (e.g. 'Ember.Application')
* has fully loaded and is available for extension.
*/
export function onLoad(name: string, callback: (...args: any[]) => any): any;
/**
* Called when an Ember.js package (e.g Ember.Application) has finished
* loading. Triggers any callbacks registered for this event.
*/
export function runLoadHooks(name: string, object?: {}): any;

View File

@ -1,3 +1,7 @@
import Ember from 'ember';
import EngineInstance from "@ember/engine/instance";
export default class ApplicationInstance extends Ember.ApplicationInstance { }
/**
* The `ApplicationInstance` encapsulates all of the stateful aspects of a
* running `Application`.
*/
export default class ApplicationInstance extends EngineInstance {}

View File

@ -1,3 +1,3 @@
import Ember from 'ember';
import EmberObject from '@ember/object';
export default class Resolver extends Ember.Resolver { }
export default class Resolver extends EmberObject {}

View File

@ -19,6 +19,8 @@
"@ember/object/*": ["ember__object/*"],
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/routing": ["ember__routing"],
"@ember/routing/*": ["ember__routing/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"]
},
@ -32,6 +34,10 @@
"index.d.ts",
"instance.d.ts",
"resolver.d.ts",
"types.d.ts",
"-private/default-resolver.d.ts",
"-private/event-dispatcher.d.ts",
"-private/registry.d.ts",
"test/application.ts",
"test/deprecations.ts",
"test/resolver.ts",

30
types/ember__application/types.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
export interface EventDispatcherEvents {
touchstart?: string | null;
touchmove?: string | null;
touchend?: string | null;
touchcancel?: string | null;
keydown?: string | null;
keyup?: string | null;
keypress?: string | null;
mousedown?: string | null;
mouseup?: string | null;
contextmenu?: string | null;
click?: string | null;
dblclick?: string | null;
mousemove?: string | null;
focusin?: string | null;
focusout?: string | null;
mouseenter?: string | null;
mouseleave?: string | null;
submit?: string | null;
input?: string | null;
change?: string | null;
dragstart?: string | null;
drag?: string | null;
dragenter?: string | null;
dragleave?: string | null;
dragover?: string | null;
drop?: string | null;
dragend?: string | null;
[event: string]: string | null | undefined;
}

View File

@ -0,0 +1,8 @@
import Mixin from "@ember/object/mixin";
interface ActionSupport {
sendAction(action: string, ...params: any[]): void;
}
declare const ActionSupport: Mixin<ActionSupport>;
export default ActionSupport;

View File

@ -0,0 +1,25 @@
import Mixin from "@ember/object/mixin";
interface ClassNamesSupport {
/**
* A list of properties of the view to apply as class names. If the property is a string value,
* the value of that string will be applied as a class name.
*
* If the value of the property is a Boolean, the name of that property is added as a dasherized
* class name.
*
* If you would prefer to use a custom value instead of the dasherized property name, you can
* pass a binding like this: `classNameBindings: ['isUrgent:urgent']`
*
* This list of properties is inherited from the component's superclasses as well.
*/
classNameBindings: string[];
/**
* Standard CSS class names to apply to the view's outer element. This
* property automatically inherits any class names defined by the view's
* superclasses as well.
*/
classNames: string[];
}
declare const ClassNamesSupport: Mixin<ClassNamesSupport>;
export default ClassNamesSupport;

View File

@ -0,0 +1,11 @@
import EmberObject from "@ember/object";
import Evented from "@ember/object/evented";
import ActionHandler from "@ember/object/-private/action-handler";
/**
* Ember.CoreView is an abstract class that exists to give view-like behavior to both Ember's main
* view class Ember.Component and other classes that don't need the full functionality of Ember.Component.
*
* Unless you have specific needs for CoreView, you will use Ember.Component in your applications.
*/
export default class CoreView extends EmberObject.extend(Evented, ActionHandler) {}

View File

@ -0,0 +1,18 @@
import EmberObject from "@ember/object";
// tslint:disable-next-line:strict-export-declare-modifiers
interface TriggerActionOptions {
action?: string;
target?: EmberObject;
actionContext?: EmberObject;
}
/**
* Ember.TargetActionSupport is a mixin that can be included in a class to add a triggerAction method
* with semantics similar to the Handlebars {{action}} helper. In normal Ember usage, the {{action}}
* helper is usually the best choice. This mixin is most often useful when you are doing more
* complex event handling in Components.
*/
export default interface TargetActionSupport {
triggerAction(opts: TriggerActionOptions): boolean;
}

View File

@ -0,0 +1,30 @@
import TargetActionSupport from "@ember/component/-private/target-action-support";
import Mixin from "@ember/object/mixin";
/**
* `TextSupport` is a shared mixin used by both `Ember.TextField` and
* `Ember.TextArea`. `TextSupport` adds a number of methods that allow you to
* specify a controller action to invoke when a certain event is fired on your
* text field or textarea. The specifed controller action would get the current
* value of the field passed in as the only argument unless the value of
* the field is empty. In that case, the instance of the field itself is passed
* in as the only argument.
*/
interface TextSupport extends TargetActionSupport {
// tslint:disable-next-line:ban-types
cancel(event: Function): void;
// tslint:disable-next-line:ban-types
focusIn(event: Function): void;
// tslint:disable-next-line:ban-types
focusOut(event: Function): void;
// tslint:disable-next-line:ban-types
insertNewLine(event: Function): void;
// tslint:disable-next-line:ban-types
keyPress(event: Function): void;
action: string;
bubbles: boolean;
onEvent: string;
}
declare const TextSupport: Mixin<TextSupport>;
export default TextSupport;

View File

@ -0,0 +1,63 @@
import Mixin from "@ember/object/mixin";
interface ViewMixin {
/**
* A list of properties of the view to apply as attributes. If the property
* is a string value, the value of that string will be applied as the value
* for an attribute of the property's name.
*/
attributeBindings: string[];
/**
* Returns the current DOM element for the view.
*/
element: Element;
/**
* Returns a jQuery object for this view's element. If you pass in a selector
* string, this method will return a jQuery object, using the current element
* as its buffer.
*/
$: JQueryStatic;
/**
* The HTML `id` of the view's element in the DOM. You can provide this
* value yourself but it must be unique (just as in HTML):
*/
elementId: string;
/**
* Tag name for the view's outer element. The tag name is only used when an
* element is first created. If you change the `tagName` for an element, you
* must destroy and recreate the view element.
*/
tagName: string;
/**
* Renders the view again. This will work regardless of whether the
* view is already in the DOM or not. If the view is in the DOM, the
* rendering process will be deferred to give bindings a chance
* to synchronize.
*/
rerender(): void;
/**
* Called when a view is going to insert an element into the DOM.
*/
willInsertElement(): void;
/**
* Called when the element of the view has been inserted into the DOM.
* Override this function to do any set up that requires an element
* in the document body.
*/
didInsertElement(): void;
/**
* Called when the view is about to rerender, but before anything has
* been torn down. This is a good opportunity to tear down any manual
* observers you have installed based on the DOM state
*/
willClearRender(): void;
/**
* Called when the element of the view is going to be destroyed. Override
* this function to do any teardown that requires an element, like removing
* event listeners.
*/
willDestroyElement(): void;
}
declare const ViewMixin: Mixin<ViewMixin>;
export default ViewMixin;

View File

@ -1,3 +1,8 @@
import Ember from 'ember';
import Component from '@ember/component';
export default class Checkbox extends Ember.Checkbox { }
/**
* The internal class used to create text inputs when the {{input}} helper is used
* with type of checkbox. See Handlebars.helpers.input for usage details.
*/
export default class Checkbox extends Component {}

View File

@ -1,6 +1,27 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
/**
* Ember Helpers are functions that can compute values, and are used in templates.
* For example, this code calls a helper named `format-currency`:
*/
export default class Helper extends EmberObject {
/**
* In many cases, the ceremony of a full `Ember.Helper` class is not required.
* The `helper` method create pure-function helpers without instances. For
* example:
*/
static helper(helper: (params: any[], hash?: object) => any): Helper;
/**
* Override this function when writing a class-based helper.
*/
compute(params: any[], hash: object): any;
/**
* On a class-based helper, it may be useful to force a recomputation of that
* helpers value. This is akin to `rerender` on a component.
*/
recompute(): any;
}
export default class Helper extends Ember.Helper { }
/**
* In many cases, the ceremony of a full `Helper` class is not required.
* The `helper` method create pure-function helpers without instances. For

View File

@ -4,6 +4,92 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import Ember from 'ember';
/// <reference types="jquery" />
export default class Component extends Ember.Component { }
import CoreView from "@ember/component/-private/core-view";
import ClassNamesSupport from "@ember/component/-private/class-names-support";
import ViewMixin from "@ember/component/-private/view-mixin";
import ActionSupport from "@ember/component/-private/action-support";
// tslint:disable-next-line:strict-export-declare-modifiers
interface TemplateFactory {
__htmlbars_inline_precompile_template_factory: any;
}
/**
* A view that is completely isolated. Property access in its templates go to the view object
* and actions are targeted at the view object. There is no access to the surrounding context or
* outer controller; all contextual information is passed in.
*/
export default class Component extends CoreView.extend(
ViewMixin,
ActionSupport,
ClassNamesSupport
) {
// methods
readDOMAttr(name: string): string;
// properties
/**
* The WAI-ARIA role of the control represented by this view. For example, a button may have a
* role of type 'button', or a pane may have a role of type 'alertdialog'. This property is
* used by assistive software to help visually challenged users navigate rich web applications.
*/
ariaRole: string;
/**
* The HTML id of the component's element in the DOM. You can provide this value yourself but
* it must be unique (just as in HTML):
*
* If not manually set a default value will be provided by the framework. Once rendered an
* element's elementId is considered immutable and you should never change it. If you need
* to compute a dynamic value for the elementId, you should do this when the component or
* element is being instantiated:
*/
elementId: string;
/**
* If false, the view will appear hidden in DOM.
*/
isVisible: boolean;
/**
* A component may contain a layout. A layout is a regular template but supersedes the template
* property during rendering. It is the responsibility of the layout template to retrieve the
* template property from the component (or alternatively, call Handlebars.helpers.yield,
* {{yield}}) to render it in the correct location. This is useful for a component that has a
* shared wrapper, but which delegates the rendering of the contents of the wrapper to the
* template property on a subclass.
*/
layout: TemplateFactory | string;
/**
* Enables components to take a list of parameters as arguments.
*/
static positionalParams: string[] | string;
// events
/**
* Called when the attributes passed into the component have been updated. Called both during the
* initial render of a container and during a rerender. Can be used in place of an observer; code
* placed here will be executed every time any attribute updates.
*/
didReceiveAttrs(): void;
/**
* Called after a component has been rendered, both on initial render and in subsequent rerenders.
*/
didRender(): void;
/**
* Called when the component has updated and rerendered itself. Called only during a rerender,
* not during an initial render.
*/
didUpdate(): void;
/**
* Called when the attributes passed into the component have been changed. Called only during a
* rerender, not during an initial render.
*/
didUpdateAttrs(): void;
/**
* Called before a component has been rendered, both on initial render and in subsequent rerenders.
*/
willRender(): void;
/**
* Called when the component is about to update and rerender itself. Called only during a rerender,
* not during an initial render.
*/
willUpdate(): void;
}

View File

@ -1,3 +1,8 @@
import Ember from 'ember';
import TextSupport from "@ember/component/-private/text-support";
import Component from "@ember/component";
export default class TextArea extends Ember.TextArea { }
/**
* The internal class used to create textarea element when the `{{textarea}}`
* helper is used.
*/
export default class TextArea extends Component.extend(TextSupport) {}

View File

@ -1,3 +1,33 @@
import Ember from 'ember';
export default class TextField extends Ember.TextField { }
import Component from "@ember/component";
import TextSupport from '@ember/component/-private/text-support';
/**
* The internal class used to create text inputs when the `{{input}}`
* helper is used with `type` of `text`.
*/
export default class TextField extends Component.extend(TextSupport) {
/**
* The `value` attribute of the input element. As the user inputs text, this
* property is updated live.
*/
value: string;
/**
* The `type` attribute of the input element.
*/
type: string;
/**
* The `size` of the text field in characters.
*/
size: string;
/**
* The `pattern` attribute of input element.
*/
pattern: string;
/**
* The `min` attribute of input element used with `type="number"` or `type="range"`.
*/
min: string;
/**
* The `max` attribute of input element used with `type="number"` or `type="range"`.
*/
max: string;
}

View File

@ -17,6 +17,8 @@
"paths": {
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"],
"@ember/controller": ["ember__controller"],
"@ember/controller/*": ["ember__controller/*"],
"@ember/component": ["ember__component"],
"@ember/component/*": ["ember__component/*"]
},
@ -30,6 +32,12 @@
"text-area.d.ts",
"text-field.d.ts",
"helper.d.ts",
"-private/core-view.d.ts",
"-private/class-names-support.d.ts",
"-private/view-mixin.d.ts",
"-private/action-support.d.ts",
"-private/target-action-support.d.ts",
"-private/text-support.d.ts",
"test/lib/assert.ts",
"test/component.ts",
"test/helper.ts"

View File

@ -4,10 +4,36 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import Ember from 'ember';
import ActionHandler from '@ember/object/-private/action-handler';
import Mixin from '@ember/object/mixin';
import EmberObject from '@ember/object';
import ComputedProperty from '@ember/object/computed';
export default class Controller extends Ember.Controller { }
export const inject: typeof Ember.inject.controller;
// tslint:disable-next-line strict-export-declare-modifiers
type QueryParamTypes = 'boolean' | 'number' | 'array' | 'string';
// tslint:disable-next-line strict-export-declare-modifiers
type QueryParamScopeTypes = 'controller' | 'model';
/**
* Additional methods for the Controller.
*/
export interface ControllerMixin extends ActionHandler {
replaceRoute(name: string, ...args: any[]): void;
transitionToRoute(name: string, ...args: any[]): void;
model: any;
queryParams: string | string[] | Array<{ [key: string]: {
type?: QueryParamTypes,
scope?: QueryParamScopeTypes,
as?: string
}}>;
target: object;
}
export const ControllerMixin: Mixin<ControllerMixin>;
// tslint:disable-next-line:no-empty-interface
export default class Controller extends EmberObject.extend(ControllerMixin) {}
export function inject<K extends keyof Registry>(
name: K
): ComputedProperty<Registry[K]>;
// A type registry for Ember `Controller`s. Meant to be declaration-merged
// so string lookups resolve to the correct type.

View File

@ -1,6 +1,7 @@
import ContainerDebugAdapter from "@ember/debug/container-debug-adapter";
import EmberObject from "@ember/object";
// tslint:disable-next-line:strict-export-declare-modifiers
declare namespace DataAdapter {
interface Column {
name: string;
@ -25,7 +26,7 @@ declare namespace DataAdapter {
* The `DataAdapter` helps a data persistence library
* interface with tools that debug Ember such as Chrome and Firefox.
*/
declare class DataAdapter extends EmberObject {
export default class DataAdapter extends EmberObject {
/**
* The container-debug-adapter which is used
* to list all models.
@ -60,5 +61,3 @@ declare class DataAdapter extends EmberObject {
recordsRemoved: (idx: number, count: number) => void
): () => void;
}
export default DataAdapter;

View File

@ -0,0 +1,28 @@
import Mixin from "@ember/object/mixin";
interface ActionsHash {
[index: string]: (...params: any[]) => any;
}
/**
* Ember.ActionHandler is available on some familiar classes including Ember.Route,
* Ember.Component, and Ember.Controller. (Internally the mixin is used by Ember.CoreView,
* Ember.ControllerMixin, and Ember.Route and available to the above classes through inheritance.)
*/
interface ActionHandler {
/**
* Triggers a named action on the ActionHandler. Any parameters supplied after the actionName
* string will be passed as arguments to the action target function.
*
* If the ActionHandler has its target property set, actions may bubble to the target.
* Bubbling happens when an actionName can not be found in the ActionHandler's actions
* hash or if the action target function returns true.
*/
send(actionName: string, ...args: any[]): void;
/**
* The collection of functions, keyed by name, available on this ActionHandler as action targets.
*/
actions: ActionsHash;
}
declare const ActionHandler: Mixin<ActionHandler>;
export default ActionHandler;

View File

@ -14,6 +14,7 @@ export function cacheFor<T, K extends keyof T>(
* Creates a shallow copy of the passed object. A deep copy of the object is
* returned if the optional `deep` argument is `true`.
*/
export function copy<T>(obj: T, deep: true): T;
export function copy(obj: any, deep?: boolean): any;
/**
* Returns a unique id for the object. If the object does not yet have a guid,

View File

@ -36,6 +36,7 @@
"proxy.d.ts",
"-private/types.d.ts",
"-private/copyable.d.ts",
"-private/action-handler.d.ts",
"test/lib/assert.ts",
"test/access-modifier.ts",
"test/core.ts",

View File

@ -0,0 +1,18 @@
export default class RouterDSL {
constructor(name: string, options: object);
route(name: string, callback: (this: RouterDSL) => void): void;
route(
name: string,
options?: { path?: string; resetNamespace?: boolean },
callback?: (this: RouterDSL) => void
): void;
mount(
name: string,
options?: {
as?: string,
path?: string,
resetNamespace?: boolean,
engineInfo?: any
}
): void;
}

View File

@ -0,0 +1,13 @@
export default interface Transition {
/**
* Aborts the Transition. Note you can also implicitly abort a transition
* by initiating another transition while a previous one is underway.
*/
abort(): Transition;
/**
* Retries a previously-aborted transition (making sure to abort the
* transition if it's still active). Returns a new transition that
* represents the new attempt to transition.
*/
retry(): Transition;
}

View File

@ -1,3 +1,6 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
export default class AutoLocation extends Ember.AutoLocation { }
/**
* AutoLocation will select the best location option based off browser support with the priority order: history, hash, none.
*/
export default class AutoLocation extends EmberObject {}

View File

@ -1,3 +1,8 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
export default class HashLocation extends Ember.HashLocation { }
/**
* `Ember.HashLocation` implements the location API using the browser's
* hash. At present, it relies on a `hashchange` event existing in the
* browser.
*/
export default class HashLocation extends EmberObject {}

View File

@ -1,3 +1,7 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
export default class HistoryLocation extends Ember.HistoryLocation { }
/**
* Ember.HistoryLocation implements the location API using the browser's
* history.pushState API.
*/
export default class HistoryLocation extends EmberObject {}

View File

@ -6,3 +6,9 @@
export { default as Route } from '@ember/routing/route';
export { default as Router } from '@ember/routing/router';
import RouterService from '@ember/routing/router-service';
// tslint:disable-next-line:strict-export-declare-modifiers
interface Registry {
'router': RouterService;
}

View File

@ -1,3 +1,39 @@
import Ember from 'ember';
import Component from "@ember/component";
export default class LinkComponent extends Ember.LinkComponent { }
/**
* `Ember.LinkComponent` renders an element whose `click` event triggers a
* transition of the application's instance of `Ember.Router` to
* a supplied route by name.
*/
export default class LinkComponent extends Component {
/**
* Used to determine when this `LinkComponent` is active.
*/
currentWhen: any;
/**
* Sets the `title` attribute of the `LinkComponent`'s HTML element.
*/
title: string | null;
/**
* Sets the `rel` attribute of the `LinkComponent`'s HTML element.
*/
rel: string | null;
/**
* Sets the `tabindex` attribute of the `LinkComponent`'s HTML element.
*/
tabindex: string | null;
/**
* Sets the `target` attribute of the `LinkComponent`'s HTML element.
*/
target: string | null;
/**
* The CSS class to apply to `LinkComponent`'s element when its `active`
* property is `true`.
*/
activeClass: string;
/**
* Determines whether the `LinkComponent` will trigger routing via
* the `replaceWith` routing strategy.
*/
replace: boolean;
}

View File

@ -1,4 +1,13 @@
import Ember from 'ember';
export const Location: typeof Ember.Location;
/**
* Ember.Location returns an instance of the correct implementation of
* the `location` API.
*/
declare const Location: {
/**
* This is deprecated in favor of using the container to lookup the location
* implementation as desired.
* @deprecated Use the container to lookup the location implementation that you need.
*/
create(options?: {}): any;
};
export default Location;

View File

@ -1,3 +1,9 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
export default class NoneLocation extends Ember.NoneLocation { }
/**
* Ember.NoneLocation does not interact with the browser. It is useful for
* testing, or when you need to manage state with your Router, but temporarily
* don't want it to muck with the URL (for example when you embed your
* application in a larger page).
*/
export default class NoneLocation extends EmberObject {}

View File

@ -1,3 +1,286 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
import ActionHandler from "@ember/object/-private/action-handler";
import Transition from "@ember/routing/-private/transition";
import Evented from "@ember/object/evented";
import { RenderOptions, RouteQueryParam } from "@ember/routing/types";
import Controller, { Registry as ControllerRegistry } from '@ember/controller';
export default class Route extends Ember.Route { }
/**
* The `Ember.Route` class is used to define individual routes. Refer to
* the [routing guide](http://emberjs.com/guides/routing/) for documentation.
*/
export default class Route extends EmberObject.extend(ActionHandler, Evented) {
// methods
/**
* This hook is called after this route's model has resolved.
* It follows identical async/promise semantics to `beforeModel`
* but is provided the route's resolved model in addition to
* the `transition`, and is therefore suited to performing
* logic that can only take place after the model has already
* resolved.
*/
afterModel(resolvedModel: any, transition: Transition): any;
/**
* This hook is the first of the route entry validation hooks
* called when an attempt is made to transition into a route
* or one of its children. It is called before `model` and
* `afterModel`, and is appropriate for cases when:
* 1) A decision can be made to redirect elsewhere without
* needing to resolve the model first.
* 2) Any async operations need to occur first before the
* model is attempted to be resolved.
* This hook is provided the current `transition` attempt
* as a parameter, which can be used to `.abort()` the transition,
* save it for a later `.retry()`, or retrieve values set
* on it from a previous hook. You can also just call
* `this.transitionTo` to another route to implicitly
* abort the `transition`.
* You can return a promise from this hook to pause the
* transition until the promise resolves (or rejects). This could
* be useful, for instance, for retrieving async code from
* the server that is required to enter a route.
*/
beforeModel(transition: Transition): any;
/**
* Returns the controller for a particular route or name.
* The controller instance must already have been created, either through entering the
* associated route or using `generateController`.
*/
controllerFor<K extends keyof ControllerRegistry>(name: K): ControllerRegistry[K];
/**
* Disconnects a view that has been rendered into an outlet.
*/
disconnectOutlet(options: string | { outlet?: string; parentView?: string }): void;
/**
* A hook you can implement to convert the URL into the model for
* this route.
*/
model(params: {}, transition: Transition): any;
/**
* Returns the model of a parent (or any ancestor) route
* in a route hierarchy. During a transition, all routes
* must resolve a model object, and if a route
* needs access to a parent route's model in order to
* resolve a model (or just reuse the model from a parent),
* it can call `this.modelFor(theNameOfParentRoute)` to
* retrieve it.
*/
modelFor(name: string): {};
/**
* Retrieves parameters, for current route using the state.params
* variable and getQueryParamsFor, using the supplied routeName.
*/
paramsFor(name: string): {};
/**
* Refresh the model on this route and any child routes, firing the
* `beforeModel`, `model`, and `afterModel` hooks in a similar fashion
* to how routes are entered when transitioning in from other route.
* The current route params (e.g. `article_id`) will be passed in
* to the respective model hooks, and if a different model is returned,
* `setupController` and associated route hooks will re-fire as well.
* An example usage of this method is re-querying the server for the
* latest information using the same parameters as when the route
* was first entered.
* Note that this will cause `model` hooks to fire even on routes
* that were provided a model object when the route was initially
* entered.
*/
redirect(): Transition;
/**
* Refresh the model on this route and any child routes, firing the
* `beforeModel`, `model`, and `afterModel` hooks in a similar fashion
* to how routes are entered when transitioning in from other route.
* The current route params (e.g. `article_id`) will be passed in
* to the respective model hooks, and if a different model is returned,
* `setupController` and associated route hooks will re-fire as well.
* An example usage of this method is re-querying the server for the
* latest information using the same parameters as when the route
* was first entered.
* Note that this will cause `model` hooks to fire even on routes
* that were provided a model object when the route was initially
* entered.
*/
refresh(): Transition;
/**
* `render` is used to render a template into a region of another template
* (indicated by an `{{outlet}}`). `render` is used both during the entry
* phase of routing (via the `renderTemplate` hook) and later in response to
* user interaction.
*/
render(name: string, options?: RenderOptions): void;
/**
* A hook you can use to render the template for the current route.
* This method is called with the controller for the current route and the
* model supplied by the `model` hook. By default, it renders the route's
* template, configured with the controller for the route.
* This method can be overridden to set up and render additional or
* alternative templates.
*/
renderTemplate(controller: Controller, model: {}): void;
/**
* Transition into another route while replacing the current URL, if possible.
* This will replace the current history entry instead of adding a new one.
* Beside that, it is identical to `transitionTo` in all other respects. See
* 'transitionTo' for additional information regarding multiple models.
*/
replaceWith(name: string, ...args: any[]): Transition;
/**
* A hook you can use to reset controller values either when the model
* changes or the route is exiting.
*/
resetController(controller: Controller, isExiting: boolean, transition: any): void;
/**
* Sends an action to the router, which will delegate it to the currently active
* route hierarchy per the bubbling rules explained under actions.
*/
send(name: string, ...args: any[]): void;
/**
* A hook you can implement to convert the route's model into parameters
* for the URL.
*
* The default `serialize` method will insert the model's `id` into the
* route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'.
* If the route has multiple dynamic segments or does not contain '_id', `serialize`
* will return `Ember.getProperties(model, params)`
* This method is called when `transitionTo` is called with a context
* in order to populate the URL.
*/
serialize(model: {}, params: string[]): string | object;
/**
* A hook you can use to setup the controller for the current route.
* This method is called with the controller for the current route and the
* model supplied by the `model` hook.
* By default, the `setupController` hook sets the `model` property of
* the controller to the `model`.
* If you implement the `setupController` hook in your Route, it will
* prevent this default behavior. If you want to preserve that behavior
* when implementing your `setupController` function, make sure to call
* `_super`
*/
setupController(controller: Controller, model: {}): void;
/**
* Transition the application into another route. The route may
* be either a single route or route path
*/
transitionTo(name: string, ...object: any[]): Transition;
/**
* The name of the view to use by default when rendering this routes template.
* When rendering a template, the route will, by default, determine the
* template and view to use from the name of the route itself. If you need to
* define a specific view, set this property.
* This is useful when multiple routes would benefit from using the same view
* because it doesn't require a custom `renderTemplate` method.
*/
transitionTo(name: string, ...object: any[]): Transition;
// https://emberjs.com/api/ember/3.2/classes/Route/methods/intermediateTransitionTo?anchor=intermediateTransitionTo
/**
* Perform a synchronous transition into another route without attempting to resolve promises,
* update the URL, or abort any currently active asynchronous transitions
* (i.e. regular transitions caused by transitionTo or URL changes).
*
* @param name the name of the route or a URL
* @param object the model(s) or identifier(s) to be used while
* transitioning to the route.
* @returns the Transition object associated with this attempted transition
*/
intermediateTransitionTo(name: string, ...object: any[]): Transition;
// properties
/**
* The controller associated with this route.
*/
controller: Controller;
/**
* The name of the controller to associate with this route.
* By default, Ember will lookup a route's controller that matches the name
* of the route (i.e. `App.PostController` for `App.PostRoute`). However,
* if you would like to define a specific controller to use, you can do so
* using this property.
* This is useful in many ways, as the controller specified will be:
* * p assed to the `setupController` method.
* * used as the controller for the view being rendered by the route.
* * returned from a call to `controllerFor` for the route.
*/
controllerName: string;
/**
* Configuration hash for this route's queryParams.
*/
queryParams: { [key: string]: RouteQueryParam };
/**
* The name of the route, dot-delimited
*/
routeName: string;
/**
* The name of the template to use by default when rendering this routes
* template.
* This is similar with `viewName`, but is useful when you just want a custom
* template without a view.
*/
templateName: string;
// events
/**
* This hook is executed when the router enters the route. It is not executed
* when the model for the route changes.
*/
activate(): void;
/**
* This hook is executed when the router completely exits this route. It is
* not executed when the model for the route changes.
*/
deactivate(): void;
/**
* The didTransition action is fired after a transition has successfully been
* completed. This occurs after the normal model hooks (beforeModel, model,
* afterModel, setupController) have resolved. The didTransition action has
* no arguments, however, it can be useful for tracking page views or resetting
* state on the controller.
*/
didTransition(): void;
/**
* When attempting to transition into a route, any of the hooks may return a promise
* that rejects, at which point an error action will be fired on the partially-entered
* routes, allowing for per-route error handling logic, or shared error handling logic
* defined on a parent route.
*/
error(error: any, transition: Transition): void;
/**
* The loading action is fired on the route when a route's model hook returns a
* promise that is not already resolved. The current Transition object is the first
* parameter and the route that triggered the loading event is the second parameter.
*/
loading(transition: Transition, route: Route): void;
/**
* The willTransition action is fired at the beginning of any attempted transition
* with a Transition object as the sole argument. This action can be used for aborting,
* redirecting, or decorating the transition from the currently active routes.
*/
willTransition(transition: Transition): void;
}

View File

@ -1,3 +1,215 @@
import { RouterService } from 'ember';
import Transition from '@ember/routing/-private/transition';
import Service from '@ember/service';
export default class extends RouterService { }
// tslint:disable-next-line:strict-export-declare-modifiers
type RouteModel = object | string | number;
// https://emberjs.com/api/ember/2.18/classes/RouterService
/**
* The Router service is the public API that provides component/view layer access to the router.
*/
export default class RouterService extends Service {
//
/**
* Name of the current route.
* This property represent the logical name of the route,
* which is comma separated.
* For the following router:
* ```app/router.js
* Router.map(function() {
* this.route('about');
* this.route('blog', function () {
* this.route('post', { path: ':post_id' });
* });
* });
* ```
* It will return:
* * `index` when you visit `/`
* * `about` when you visit `/about`
* * `blog.index` when you visit `/blog`
* * `blog.post` when you visit `/blog/some-post-id`
*/
readonly currentRouteName: string;
//
/**
* Current URL for the application.
* This property represent the URL path for this route.
* For the following router:
* ```app/router.js
* Router.map(function() {
* this.route('about');
* this.route('blog', function () {
* this.route('post', { path: ':post_id' });
* });
* });
* ```
* It will return:
* * `/` when you visit `/`
* * `/about` when you visit `/about`
* * `/blog` when you visit `/blog`
* * `/blog/some-post-id` when you visit `/blog/some-post-id`
*/
readonly currentURL: string;
//
/**
* Determines whether a route is active.
*
* @param routeName the name of the route
* @param models the model(s) or identifier(s) to be used while
* transitioning to the route
* @param options optional hash with a queryParams property containing a
* mapping of query parameters
*/
isActive(routeName: string, options?: { queryParams: object }): boolean;
isActive(
routeName: string,
models: RouteModel,
options?: { queryParams: object }
): boolean;
isActive(
routeName: string,
modelsA: RouteModel,
modelsB: RouteModel,
options?: { queryParams: object }
): boolean;
isActive(
routeName: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
options?: { queryParams: object }
): boolean;
isActive(
routeName: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
modelsD: RouteModel,
options?: { queryParams: object }
): boolean;
// https://emberjs.com/api/ember/2.18/classes/RouterService/methods/isActive?anchor=replaceWith
/**
* Transition into another route while replacing the current URL, if
* possible. The route may be either a single route or route path.
*
* @param routeNameOrUrl the name of the route or a URL
* @param models the model(s) or identifier(s) to be used while
* transitioning to the route.
* @param options optional hash with a queryParams property
* containing a mapping of query parameters
* @returns the Transition object associated with this attempted transition
*/
replaceWith(
routeNameOrUrl: string,
options?: { queryParams: object }
): Transition;
replaceWith(
routeNameOrUrl: string,
models: RouteModel,
options?: { queryParams: object }
): Transition;
replaceWith(
routeNameOrUrl: string,
modelsA: RouteModel,
modelsB: RouteModel,
options?: { queryParams: object }
): Transition;
replaceWith(
routeNameOrUrl: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
options?: { queryParams: object }
): Transition;
replaceWith(
routeNameOrUrl: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
modelsD: RouteModel,
options?: { queryParams: object }
): Transition;
// https://emberjs.com/api/ember/2.18/classes/RouterService/methods/isActive?anchor=transitionTo
/**
* Transition the application into another route. The route may be
* either a single route or route path
*
* @param routeNameOrUrl the name of the route or a URL
* @param models the model(s) or identifier(s) to be used while
* transitioning to the route.
* @param options optional hash with a queryParams property
* containing a mapping of query parameters
* @returns the Transition object associated with this attempted transition
*/
transitionTo(
routeNameOrUrl: string,
options?: { queryParam: object }
): Transition;
transitionTo(
routeNameOrUrl: string,
models: RouteModel,
options?: { queryParams: object }
): Transition;
transitionTo(
routeNameOrUrl: string,
modelsA: RouteModel,
modelsB: RouteModel,
options?: { queryParams: object }
): Transition;
transitionTo(
routeNameOrUrl: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
options?: { queryParams: object }
): Transition;
transitionTo(
routeNameOrUrl: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
modelsD: RouteModel,
options?: { queryParams: object }
): Transition;
// https://emberjs.com/api/ember/2.18/classes/RouterService/methods/isActive?anchor=urlFor
/**
* Generate a URL based on the supplied route name.
*
* @param routeName the name of the route or a URL
* @param models the model(s) or identifier(s) to be used while
* transitioning to the route.
* @param options optional hash with a queryParams property containing
* a mapping of query parameters
* @returns the string representing the generated URL
*/
urlFor(routeName: string, options?: { queryParams: object }): string;
urlFor(
routeName: string,
models: RouteModel,
options?: { queryParams: object }
): string;
urlFor(
routeName: string,
modelsA: RouteModel,
modelsB: RouteModel,
options?: { queryParams: object }
): string;
urlFor(
routeName: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
options?: { queryParams: object }
): string;
urlFor(
routeName: string,
modelsA: RouteModel,
modelsB: RouteModel,
modelsC: RouteModel,
modelsD: RouteModel,
options?: { queryParams: object }
): string;
}

View File

@ -1,3 +1,51 @@
import Ember from 'ember';
import EmberObject from "@ember/object";
import Evented from "@ember/object/evented";
import RouterDSL from "@ember/routing/-private/router-dsl";
import Transition from "@ember/routing/-private/transition";
import RouterService from "@ember/routing/router-service";
export default class EmberRouter extends Ember.Router { }
/**
* The `Ember.Router` class manages the application state and URLs. Refer to
* the [routing guide](http://emberjs.com/guides/routing/) for documentation.
*/
export default class Router extends EmberObject.extend(Evented) {
/**
* The `Router.map` function allows you to define mappings from URLs to routes
* in your application. These mappings are defined within the
* supplied callback function using `this.route`.
*/
static map(callback: (this: RouterDSL) => void): void;
/**
* The `location` property determines the type of URL's that your
* application will use.
*/
location: string;
/**
* Represents the URL of the root of the application, often '/'. This prefix is
* assumed on all routes defined on this router.
*/
rootURL: string;
/**
* Handles updating the paths and notifying any listeners of the URL
* change.
*/
didTransition(): any;
/**
* Handles notifying any listeners of an impending URL
* change.
*/
willTransition(): any;
/**
* Transition the application into another route. The route may
* be either a single route or route path:
*/
transitionTo(name: string, options?: {}): Transition;
transitionTo(name: string, ...models: any[]): Transition;
transitionTo(name: string, options: {}): Transition;
}
declare module '@ember/service' {
interface Registry {
'router': RouterService;
}
}

View File

@ -1,21 +1,21 @@
import Route from '@ember/routing/route';
import Array from '@ember/array';
import Ember from 'ember'; // currently needed for Transition
import EmberObject from '@ember/object';
import Controller from '@ember/controller';
import Transition from '@ember/routing/-private/transition';
class Post extends EmberObject {}
interface Posts extends Array<Post> {}
Route.extend({
beforeModel(transition: Ember.Transition) {
beforeModel(transition: Transition) {
this.transitionTo('someOtherRoute');
},
});
Route.extend({
afterModel(posts: Posts, transition: Ember.Transition) {
afterModel(posts: Posts, transition: Transition) {
if (posts.length === 1) {
this.transitionTo('post.show', posts.firstObject);
}
@ -39,7 +39,7 @@ Route.extend({
},
});
Ember.Route.extend({
Route.extend({
model() {
return this.modelFor('post');
},
@ -61,7 +61,7 @@ Route.extend({
});
Route.extend({
renderTemplate(controller: Ember.Controller, model: {}) {
renderTemplate(controller: Controller, model: {}) {
this.render('posts', {
view: 'someView', // the template to render, referenced by name
into: 'application', // the template to render into, referenced by name
@ -73,7 +73,7 @@ Route.extend({
});
Route.extend({
resetController(controller: Ember.Controller, isExiting: boolean, transition: boolean) {
resetController(controller: Controller, isExiting: boolean, transition: boolean) {
if (isExiting) {
// controller.set('page', 1);
}

View File

@ -1,7 +1,9 @@
import Ember from 'ember';
import { assertType } from './lib/assert';
import Router from '@ember/routing/router';
import Service, { inject as service } from '@ember/service';
import EmberObject, { get } from '@ember/object';
const AppRouter = Ember.Router.extend({
const AppRouter = Router.extend({
});
AppRouter.map(function() {
@ -24,31 +26,31 @@ AppRouter.map(function() {
this.mount('my-engine', { as: 'some-other-engine', path: '/some-other-engine'});
});
const RouterServiceConsumer = Ember.Service.extend({
router: Ember.inject.service('router'),
const RouterServiceConsumer = Service.extend({
router: service('router'),
currentRouteName() {
const x: string = Ember.get(this, 'router').currentRouteName;
const x: string = get(this, 'router').currentRouteName;
},
currentURL() {
const x: string = Ember.get(this, 'router').currentURL;
const x: string = get(this, 'router').currentURL;
},
transitionWithoutModel() {
Ember.get(this, 'router')
get(this, 'router')
.transitionTo('some-route');
},
transitionWithModel() {
const model = Ember.Object.create();
Ember.get(this, 'router')
const model = EmberObject.create();
get(this, 'router')
.transitionTo('some.other.route', model);
},
transitionWithMultiModel() {
const model = Ember.Object.create();
Ember.get(this, 'router')
const model = EmberObject.create();
get(this, 'router')
.transitionTo('some.other.route', model, model);
},
transitionWithModelAndOptions() {
const model = Ember.Object.create();
Ember.get(this, 'router')
const model = EmberObject.create();
get(this, 'router')
.transitionTo('index', model, { queryParams: { search: 'ember' }});
}
});

View File

@ -19,6 +19,11 @@
"@ember/object/*": ["ember__object/*"],
"@ember/array": ["ember__array"],
"@ember/array/*": ["ember__array/*"],
"@ember/service": ["ember__service"],
"@ember/service/*": ["ember__service/*"],
"@ember/component": ["ember__component"],
"@ember/component/*": ["ember__component/*"],
"@ember/controller": ["ember__controller"],
"@ember/routing": ["ember__routing"],
"@ember/routing/*": ["ember__routing/*"]
},
@ -37,6 +42,9 @@
"route.d.ts",
"router-service.d.ts",
"router.d.ts",
"types.d.ts",
"-private/router-dsl.d.ts",
"-private/transition.d.ts",
"test/lib/assert.ts",
"test/route.ts",
"test/router.ts"

13
types/ember__routing/types.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
export interface RenderOptions {
into?: string;
controller?: string;
model?: any;
outlet?: string;
view?: string;
}
export interface RouteQueryParam {
refreshModel?: boolean;
replace?: boolean;
as?: string;
}

View File

@ -1,9 +1,9 @@
import Ember from 'ember';
import RSVP from 'rsvp';
import { run } from '@ember/runloop';
import EmberObject from '@ember/object';
Ember.run.queues; // $ExpectType EmberRunQueues[]
const queues: string[] = Ember.run.queues;
run.queues; // $ExpectType EmberRunQueues[]
const queues: string[] = run.queues;
function testRun() {
run(() => { // $ExpectType number
@ -11,8 +11,8 @@ function testRun() {
return 123;
});
function destroyApp(application: Ember.Application) {
Ember.run(application, 'destroy');
function destroyApp(application: EmberObject) {
run(application, 'destroy');
run(application, function() {
this.destroy();
});
@ -20,9 +20,9 @@ function testRun() {
}
function testBind() {
Ember.Component.extend({
EmberObject.extend({
init() {
const bound = Ember.run.bind(this, this.setupEditor);
const bound = run.bind(this, this.setupEditor);
bound();
},
@ -91,14 +91,14 @@ function testDebounce() {
run.debounce(myContext, runIt, 150);
run.debounce(myContext, runIt, 150, true);
Ember.Component.extend({
EmberObject.extend({
searchValue: 'test',
fetchResults(value: string) {},
actions: {
handleTyping() {
// the fetchResults function is passed into the component from its parent
Ember.run.debounce(this, this.get('fetchResults'), this.get('searchValue'), 250);
run.debounce(this, this.get('fetchResults'), this.get('searchValue'), 250);
}
}
});
@ -124,7 +124,7 @@ function testJoin() {
});
new RSVP.Promise((resolve) => {
Ember.run.later(() => {
run.later(() => {
resolve({ msg: 'Hold Your Horses' });
}, 3000);
});
@ -146,9 +146,9 @@ function testNext() {
}
function testOnce() {
Ember.Component.extend({
EmberObject.extend({
init() {
Ember.run.once(this, 'processFullName');
run.once(this, 'processFullName');
},
processFullName() {
@ -157,7 +157,7 @@ function testOnce() {
}
function testSchedule() {
Ember.Component.extend({
EmberObject.extend({
init() {
run.schedule('sync', this, () => {
// this will be executed in the first RunLoop queue, when bindings are synced
@ -171,7 +171,7 @@ function testSchedule() {
}
});
Ember.run.schedule('actions', () => {
run.schedule('actions', () => {
// Do more things
});
}

View File

@ -20,6 +20,8 @@
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/error": ["ember__error"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/object": ["ember__object"],
"@ember/object/*": ["ember__object/*"],
"@ember/test-helpers": ["ember__test-helpers"]

View File

@ -1,2 +1,20 @@
import Ember from 'ember';
export default class TestAdapter extends Ember.Test.Adapter { }
/**
* The primary purpose of this class is to create hooks that can be implemented
* by an adapter for various test frameworks.
*/
export default class Adapter {
/**
* This callback will be called whenever an async operation is about to start.
*/
asyncStart(): any;
/**
* This callback will be called whenever an async operation has completed.
*/
asyncEnd(): any;
/**
* Override this method with your testing framework's false assertion.
* This function is called whenever an exception occurs causing the testing
* promise to fail.
*/
exception(error: string): any;
}

View File

@ -4,9 +4,50 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import Ember from 'ember';
export const registerAsyncHelper: typeof Ember.Test.registerAsyncHelper;
export const registerHelper: typeof Ember.Test.registerHelper;
export const registerWaiter: typeof Ember.Test.registerWaiter;
export const unregisterHelper: typeof Ember.Test.unregisterHelper;
export const unregisterWaiter: typeof Ember.Test.unregisterWaiter;
import Application from '@ember/application';
/**
* `registerHelper` is used to register a test helper that will be injected
* when `App.injectTestHelpers` is called.
*/
export function registerHelper(
name: string,
helperMethod: (app: Application, ...args: any[]) => any,
options?: object
): any;
/**
* `registerAsyncHelper` is used to register an async test helper that will be injected
* when `App.injectTestHelpers` is called.
*/
export function registerAsyncHelper(
name: string,
helperMethod: (app: Application, ...args: any[]) => any
): void;
/**
* Remove a previously added helper method.
*/
export function unregisterHelper(name: string): void;
/**
* This allows ember-testing to play nicely with other asynchronous
* events, such as an application that is waiting for a CSS3
* transition or an IndexDB transaction. The waiter runs periodically
* after each async helper (i.e. `click`, `andThen`, `visit`, etc) has executed,
* until the returning result is truthy. After the waiters finish, the next async helper
* is executed and the process repeats.
*/
export function registerWaiter(callback: () => boolean): any;
export function registerWaiter<Context>(
context: Context,
callback: (this: Context) => boolean
): any;
/**
* `unregisterWaiter` is used to unregister a callback that was
* registered with `registerWaiter`.
*/
export function unregisterWaiter(callback: () => boolean): any;
export function unregisterWaiter<Context>(
context: Context,
callback: (this: Context) => boolean
): any;

View File

@ -15,6 +15,10 @@
"../"
],
"paths": {
"@ember/engine": ["ember__engine"],
"@ember/engine/*": ["ember__engine/*"],
"@ember/application": ["ember__application"],
"@ember/application/*": ["ember__application/*"],
"@ember/test": ["ember__test"],
"@ember/test/*": ["ember__test/*"]
},

View File

@ -40,7 +40,8 @@ import {
Location,
Updates,
MediaLibrary,
Haptic
Haptic,
Constants
} from 'expo';
const reverseGeocode: Promise<Location.GeocodeData[]> = Location.reverseGeocodeAsync({
@ -874,3 +875,22 @@ Haptic.notification(Haptic.NotificationType.Error);
Haptic.selection();
// #endregion
// #region Constants
async () => {
const appOwnerShip = Constants.appOwnership;
const expoVersion = Constants.expoVersion;
const installationId = Constants.installationId;
const deviceId = Constants.deviceId;
const deviceName = Constants.deviceName;
const deviceYearClass = Constants.deviceYearClass;
const isDevice = Constants.isDevice;
const platform = Constants.platform;
const sessionId = Constants.sessionId;
const statusBarHeight = Constants.statusBarHeight;
const systemFonts = Constants.systemFonts;
const manifest = Constants.manifest;
const linkingUri = Constants.linkingUri;
const userAgent: string = await Constants.getWebViewUserAgentAsync();
};
// #endregion

View File

@ -877,6 +877,7 @@ export class Camera extends Component<CameraProps> {
export namespace Constants {
const appOwnership: 'expo' | 'standalone' | 'guest';
const expoVersion: string;
const installationId: string;
const deviceId: string;
const deviceName: string;
const deviceYearClass: number;
@ -991,6 +992,8 @@ export namespace Constants {
}
const manifest: Manifest;
const linkingUri: string;
function getWebViewUserAgentAsync(): Promise<string>;
}
/**

View File

@ -70,7 +70,7 @@ outVec2 = vec2.negate(outVec2, vec2A);
outVec2 = vec2.inverse(outVec2, vec2A);
outVec2 = vec2.normalize(outVec2, vec2A);
outVal = vec2.dot(vec2A, vec2B);
outVec2 = vec2.cross(outVec3, vec2A, vec2B);
outVec3 = vec2.cross(outVec3, vec2A, vec2B);
outVec2 = vec2.lerp(outVec2, vec2A, vec2B, 0.5);
outVec2 = vec2.random(outVec2);
outVec2 = vec2.random(outVec2, 5.0);
@ -435,7 +435,7 @@ outVec2 = _vec2.negate(outVec2, vec2A);
outVec2 = _vec2.inverse(outVec2, vec2A);
outVec2 = _vec2.normalize(outVec2, vec2A);
outVal = _vec2.dot(vec2A, vec2B);
outVec2 = _vec2.cross(outVec3, vec2A, vec2B);
outVec3 = _vec2.cross(outVec3, vec2A, vec2B);
outVec2 = _vec2.lerp(outVec2, vec2A, vec2B, 0.5);
outVec2 = _vec2.random(outVec2);
outVec2 = _vec2.random(outVec2, 5.0);

View File

@ -344,7 +344,7 @@ declare module 'gl-matrix' {
* @param b the second operand
* @returns out
*/
public static cross(out: vec3, a: vec2 | number[], b: vec2 | number[]): vec2;
public static cross(out: vec3, a: vec2 | number[], b: vec2 | number[]): vec3;
/**
* Performs a linear interpolation between two vec2's

View File

@ -59,7 +59,7 @@ export class GraphQLError extends Error {
/**
* The original error thrown from a field resolver during execution.
*/
readonly originalError: Maybe<Error> & { readonly extensions: any };
readonly originalError: Maybe<Error>;
/**
* Extension fields to add to the formatted error.

View File

@ -58,13 +58,21 @@ function contentSecurityPolicyTest() {
disableAndroid: false
};
function reportUriCb(req: express.Request, res: express.Response) { return '/some-uri'; }
function reportOnlyCb(req: express.Request, res: express.Response) { return false; }
app.use(helmet.contentSecurityPolicy());
app.use(helmet.contentSecurityPolicy({}));
app.use(helmet.contentSecurityPolicy(config));
app.use(helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"]
defaultSrc: ["'self'"],
reportUri: reportUriCb,
'report-uri': reportUriCb,
reportTo: reportUriCb,
'report-to': reportUriCb
},
reportOnly: reportOnlyCb,
loose: false,
setAllHeaders: true
}));

View File

@ -69,8 +69,8 @@ declare namespace helmet {
objectSrc?: HelmetCspDirectiveValue[];
pluginTypes?: HelmetCspDirectiveValue[];
prefetchSrc?: HelmetCspDirectiveValue[];
reportTo?: string;
reportUri?: string;
reportTo?: HelmetCspDirectiveValue;
reportUri?: HelmetCspDirectiveValue;
requireSriFor?: HelmetCspRequireSriForValue[];
sandbox?: HelmetCspSandboxDirective[];
scriptSrc?: HelmetCspDirectiveValue[];
@ -95,8 +95,8 @@ declare namespace helmet {
'object-src'?: HelmetCspDirectiveValue[];
'plugin-types'?: HelmetCspDirectiveValue[];
'prefetch-src'?: HelmetCspDirectiveValue[];
'report-to'?: string;
'report-uri'?: string;
'report-to'?: HelmetCspDirectiveValue;
'report-uri'?: HelmetCspDirectiveValue;
'require-sri-for'?: HelmetCspRequireSriForValue[];
'sandbox'?: HelmetCspSandboxDirective[];
'script-src'?: HelmetCspDirectiveValue;
@ -106,7 +106,7 @@ declare namespace helmet {
}
export interface IHelmetContentSecurityPolicyConfiguration {
reportOnly?: boolean;
reportOnly?: boolean | ((req: express.Request, res: express.Response) => boolean);
setAllHeaders?: boolean;
disableAndroid?: boolean;
browserSniff?: boolean;

View File

@ -1,6 +1,6 @@
// Type definitions for in-app-purchase 1.9
// Type definitions for in-app-purchase 1.10
// Project: https://github.com/voltrue2/in-app-purchase#readme
// Definitions by: Jonas Lochmann <https://github.com/l-jonas>
// Definitions by: Jonas Lochmann <https://github.com/l-jonas>, Dennis Kugelmann <https://github.com/IchordeDionysos>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@ -26,6 +26,7 @@ export function validateOnce(service: Service, secretOrPubKey: any, receipt: Rec
export function isValidated(response: ValidationResponse): boolean;
export function isExpired(item: PurchasedItem): boolean;
export function isCanceled(item: PurchasedItem): boolean;
export function getPurchaseData(purchaseData?: ValidationResponse, options?: {
ignoreCanceled: boolean;
ignoreExpired: boolean;
@ -94,10 +95,15 @@ export interface ValidationResponse {
export interface PurchasedItem {
bundleId?: string; // only Apple
appItemId?: string;
orderId?: string; // only Google
originalTransactionId?: string; // only Apple
transactionId: string;
productId: string;
purchaseDate: number;
originalPurchaseDate?: string; // only Apple
purchaseDate: number | string;
isTrial?: boolean; // only Apple
cancellationDate?: number; // only Apple/Google
// iTunes, windows and amazon subscription only
// Google subscriptions only with google play store api info
expirationDate?: number;

View File

@ -43,7 +43,8 @@ declare namespace Intercom_ {
| 'onShow'
| 'onUnreadCountChange'
| 'onActivatorClick'
| 'trackEvent';
| 'trackEvent'
| 'getVisitorId';
interface IntercomStatic {
(command: 'boot', param: IntercomSettings): void;
@ -53,6 +54,7 @@ declare namespace Intercom_ {
(command: 'onHide' | 'onShow' | 'onActivatorClick', param?: () => void): void;
(command: 'trackEvent', tag?: string, metadata?: any): void;
(command: 'onUnreadCountChange', cb: (unreadCount: number) => void): void;
(command: 'getVisitorId'): string;
(command: IntercomCommand, param1?: any, param2?: any): void;
}
}

View File

@ -26,6 +26,7 @@ Intercom('onHide', () => { /* Do stuff */ });
Intercom('onUnreadCountChange', (unreadCount: number) => { /* Do stuff */ });
Intercom('onActivatorClick', () => { /* Do stuff */ });
Intercom('trackEvent', 'invited-friend');
const visitorId = Intercom('getVisitorId');
const metadata = {
invitee_email: 'pi@example.org',

View File

@ -861,13 +861,13 @@ interface JQueryStatic {
*/
post(url_settings?: string | JQuery.UrlAjaxSettings): JQuery.jqXHR;
// region proxy
// #region proxy
// region (fn, null | undefined)
// #region (fn, null | undefined)
// region 0 to 7 arguments
// #region 0 to 7 arguments
// region 0 parameters
// #region 0 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -981,9 +981,9 @@ interface JQueryStatic {
proxy<TReturn>(fn: () => TReturn,
context: null | undefined): () => TReturn;
// endregion
// #endregion
// region 1 parameters
// #region 1 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1111,9 +1111,9 @@ interface JQueryStatic {
T>(fn: (t: T) => TReturn,
context: null | undefined): (t: T) => TReturn;
// endregion
// #endregion
// region 2 parameters
// #region 2 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1241,9 +1241,9 @@ interface JQueryStatic {
T, U>(fn: (t: T, u: U) => TReturn,
context: null | undefined): (t: T, u: U) => TReturn;
// endregion
// #endregion
// region 3 parameters
// #region 3 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1371,9 +1371,9 @@ interface JQueryStatic {
T, U, V>(fn: (t: T, u: U, v: V) => TReturn,
context: null | undefined): (t: T, u: U, v: V) => TReturn;
// endregion
// #endregion
// region 4 parameters
// #region 4 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1501,9 +1501,9 @@ interface JQueryStatic {
T, U, V, W>(fn: (t: T, u: U, v: V, w: W) => TReturn,
context: null | undefined): (t: T, u: U, v: V, w: W) => TReturn;
// endregion
// #endregion
// region 5 parameters
// #region 5 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1631,9 +1631,9 @@ interface JQueryStatic {
T, U, V, W, X>(fn: (t: T, u: U, v: V, w: W, x: X) => TReturn,
context: null | undefined): (t: T, u: U, v: V, w: W, x: X) => TReturn;
// endregion
// #endregion
// region 6 parameters
// #region 6 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1761,9 +1761,9 @@ interface JQueryStatic {
T, U, V, W, X, Y>(fn: (t: T, u: U, v: V, w: W, x: X, y: Y) => TReturn,
context: null | undefined): (t: T, u: U, v: V, w: W, x: X, y: Y) => TReturn;
// endregion
// #endregion
// region 7+ parameters
// #region 7+ parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1891,11 +1891,11 @@ interface JQueryStatic {
T, U, V, W, X, Y, Z>(fn: (t: T, u: U, v: V, w: W, x: X, y: Y, z: Z, ...args: any[]) => TReturn,
context: null | undefined): (t: T, u: U, v: V, w: W, x: X, y: Y, z: Z, ...args: any[]) => TReturn;
// endregion
// #endregion
// endregion
// #endregion
// region 8+ arguments
// #region 8+ arguments
/**
* Takes a function and returns a new one that will always have a particular context.
@ -1912,15 +1912,15 @@ interface JQueryStatic {
context: null | undefined,
...additionalArguments: any[]): (...args: any[]) => TReturn;
// endregion
// #endregion
// endregion
// #endregion
// region (fn, context)
// #region (fn, context)
// region 0 to 7 arguments
// #region 0 to 7 arguments
// region 0 parameters
// #region 0 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2049,9 +2049,9 @@ interface JQueryStatic {
TReturn>(fn: () => TReturn,
context: TContext): (this: TContext) => TReturn;
// endregion
// #endregion
// region 1 parameters
// #region 1 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2195,9 +2195,9 @@ interface JQueryStatic {
T>(fn: (t: T) => TReturn,
context: TContext): (this: TContext, t: T) => TReturn;
// endregion
// #endregion
// region 2 parameters
// #region 2 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2341,9 +2341,9 @@ interface JQueryStatic {
T, U>(fn: (t: T, u: U) => TReturn,
context: TContext): (this: TContext, t: T, u: U) => TReturn;
// endregion
// #endregion
// region 3 parameters
// #region 3 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2487,9 +2487,9 @@ interface JQueryStatic {
T, U, V>(fn: (t: T, u: U, v: V) => TReturn,
context: TContext): (this: TContext, t: T, u: U, v: V) => TReturn;
// endregion
// #endregion
// region 4 parameters
// #region 4 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2633,9 +2633,9 @@ interface JQueryStatic {
T, U, V, W>(fn: (t: T, u: U, v: V, w: W) => TReturn,
context: TContext): (this: TContext, t: T, u: U, v: V, w: W) => TReturn;
// endregion
// #endregion
// region 5 parameters
// #region 5 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2779,9 +2779,9 @@ interface JQueryStatic {
T, U, V, W, X>(fn: (t: T, u: U, v: V, w: W, x: X) => TReturn,
context: TContext): (this: TContext, t: T, u: U, v: V, w: W, x: X) => TReturn;
// endregion
// #endregion
// region 6 parameters
// #region 6 parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -2925,9 +2925,9 @@ interface JQueryStatic {
T, U, V, W, X, Y>(fn: (t: T, u: U, v: V, w: W, x: X, y: Y) => TReturn,
context: TContext): (this: TContext, t: T, u: U, v: V, w: W, x: X, y: Y) => TReturn;
// endregion
// #endregion
// region 7+ parameters
// #region 7+ parameters
/**
* Takes a function and returns a new one that will always have a particular context.
@ -3071,11 +3071,11 @@ interface JQueryStatic {
T, U, V, W, X, Y, Z>(fn: (t: T, u: U, v: V, w: W, x: X, y: Y, z: Z, ...args: any[]) => TReturn,
context: TContext): (this: TContext, t: T, u: U, v: V, w: W, x: X, y: Y, z: Z, ...args: any[]) => TReturn;
// endregion
// #endregion
// endregion
// #endregion
// region 8+ arguments
// #region 8+ arguments
/**
* Takes a function and returns a new one that will always have a particular context.
@ -3094,11 +3094,11 @@ interface JQueryStatic {
context: TContext,
...additionalArguments: any[]): (this: TContext, ...args: any[]) => TReturn;
// endregion
// #endregion
// endregion
// #endregion
// region (context, name)
// #region (context, name)
/**
* Takes a function and returns a new one that will always have a particular context.
@ -3116,9 +3116,9 @@ interface JQueryStatic {
name: keyof TContext,
...additionalArguments: any[]): (this: TContext, ...args: any[]) => any;
// endregion
// #endregion
// endregion
// #endregion
/**
* Manipulate the queue of functions to be executed on the matched element.
@ -5900,7 +5900,7 @@ declare namespace JQuery {
[key: string]: T;
}
// region Ajax
// #region Ajax
interface AjaxSettings<TContext = any> extends Ajax.AjaxSettingsBase<TContext> {
/**
@ -6205,7 +6205,7 @@ declare namespace JQuery {
}
type StatusCodeCallbacks<TContext> = {
// region Success Status Codes
// #region Success Status Codes
// jQuery treats 2xx and 304 status codes as a success
@ -6311,9 +6311,9 @@ declare namespace JQuery {
299?: SuccessCallback<TContext>;
304?: SuccessCallback<TContext>;
// endregion
// #endregion
// region Error Status Codes
// #region Error Status Codes
300?: ErrorCallback<TContext>;
301?: ErrorCallback<TContext>;
@ -6615,7 +6615,7 @@ declare namespace JQuery {
598?: ErrorCallback<TContext>;
599?: ErrorCallback<TContext>;
// endregion
// #endregion
} & {
// Status codes not listed require type annotations when defining the callback
[index: number]: SuccessCallback<TContext> | ErrorCallback<TContext>;
@ -6667,9 +6667,9 @@ declare namespace JQuery {
interface AlwaysCallback<TResolve = any, TjqXHR = jqXHR<TResolve>> extends Deferred.Callback3<TResolve | TjqXHR, Ajax.TextStatus, TjqXHR | string> { }
}
// endregion
// #endregion
// region Callbacks
// #region Callbacks
// tslint:disable-next-line:ban-types
interface Callbacks<T extends Function = Function> {
@ -6760,18 +6760,18 @@ declare namespace JQuery {
remove(...callbacks: T[]): this;
}
// endregion
// #endregion
// region CSS
// #region CSS
interface CSSHook<TElement> {
get(this: this, elem: TElement, computed: any, extra: any): any;
set(this: this, elem: TElement, value: any): void;
}
// endregion
// #endregion
// region Deferred
// #region Deferred
/**
* Any object that has a then method.
@ -6890,7 +6890,7 @@ declare namespace JQuery {
*/
state(): 'pending' | 'resolved' | 'rejected';
// region pipe
// #region pipe
/**
* Utility method to filter and/or chain Deferreds.
@ -7103,9 +7103,9 @@ declare namespace JQuery {
CRD, CJD, CND,
RRD, RJD, RND>;
// endregion
// #endregion
// region then
// #region then
/**
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
@ -7297,7 +7297,7 @@ declare namespace JQuery {
CRD, CJD, CND,
RRD, RJD, RND>;
// endregion
// #endregion
/**
* Add handlers to be called when the Deferred object is rejected.
@ -7478,7 +7478,7 @@ declare namespace JQuery {
*/
state(): 'pending' | 'resolved' | 'rejected';
// region pipe
// #region pipe
/**
* Utility method to filter and/or chain Deferreds.
@ -7691,9 +7691,9 @@ declare namespace JQuery {
CRD, CJD, CND,
RRD, RJD, RND>;
// endregion
// #endregion
// region then
// #region then
/**
* Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
@ -7885,7 +7885,7 @@ declare namespace JQuery {
CRD, CJD, CND,
RRD, RJD, RND>;
// endregion
// #endregion
/**
* Add handlers to be called when the Deferred object is rejected.
@ -7939,9 +7939,9 @@ declare namespace JQuery {
interface ProgressCallback<TNotify> extends Callback<TNotify> { }
}
// endregion
// #endregion
// region Effects
// #region Effects
type Duration = number | 'fast' | 'slow';
// TODO: Is the first element always a string or is that specific to the 'fx' queue?
@ -8043,11 +8043,11 @@ declare namespace JQuery {
(fx: Tween<TElement>): void;
}
// endregion
// #endregion
// region Events
// #region Events
// region Event
// #region Event
// This should be a class but doesn't work correctly under the JQuery namespace. Event should be an inner class of jQuery.
@ -8213,7 +8213,7 @@ declare namespace JQuery {
type: string;
}
// endregion
// #endregion
interface EventHandler<TCurrentTarget, TData = null> extends EventHandlerBase<TCurrentTarget, Event<TCurrentTarget, TData>> { }
@ -8222,134 +8222,7 @@ declare namespace JQuery {
(this: TContext, t: T, ...args: any[]): void | false | any;
}
// Provided for convenience for use with jQuery.Event.which
// tslint:disable-next-line:no-const-enum
const enum Mouse {
None = 0,
Left = 1,
Middle = 2,
Right = 3
}
// Provided for convenience for use with jQuery.Event.which
// tslint:disable-next-line:no-const-enum
const enum Key {
Backspace = 8,
Tab = 9,
Enter = 13,
Shift = 16,
Control = 17,
Alt = 18,
CapsLock = 20,
Escape = 27,
Space = 32,
PageUp = 33,
PageDown = 34,
End = 35,
Home = 36,
ArrowLeft = 37,
ArrowUp = 38,
ArrowRight = 39,
ArrowDown = 40,
Semicolon = 186,
Colon = 186,
EqualsSign = 187,
Plus = 187,
Comma = 188,
LessThanSign = 188,
Minus = 189,
Underscore = 189,
Period = 190,
GreaterThanSign = 190,
ForwardSlash = 191,
QuestionMark = 191,
Backtick = 192,
Tilde = 192,
OpeningSquareBracket = 219,
OpeningCurlyBrace = 219,
Backslash = 220,
Pipe = 220,
ClosingSquareBracket = 221,
ClosingCurlyBrace = 221,
SingleQuote = 222,
DoubleQuote = 222,
Pause = 19,
PrintScreen = 44,
Insert = 45,
Delete = 46,
Num0 = 48,
Num1 = 49,
Num2 = 50,
Num3 = 51,
Num4 = 52,
Num5 = 53,
Num6 = 54,
Num7 = 55,
Num8 = 56,
Num9 = 57,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
MetaLeft = 91,
MetaRight = 92,
ContextMenu = 93,
Numpad0 = 96,
Numpad1 = 97,
Numpad2 = 98,
Numpad3 = 99,
Numpad4 = 100,
Numpad5 = 101,
Numpad6 = 102,
Numpad7 = 103,
Numpad8 = 104,
Numpad9 = 105,
NumpadMultiply = 106,
NumpadAdd = 107,
NumpadSubtract = 109,
NumpadDecimal = 110,
NumpadDivide = 111,
F1 = 112,
F2 = 113,
F3 = 114,
F4 = 115,
F5 = 116,
F6 = 117,
F7 = 118,
F8 = 119,
F9 = 120,
F10 = 121,
F11 = 122,
F12 = 123,
NumLock = 144,
ScrollLock = 145
}
// endregion
// #endregion
interface NameValuePair {
name: string;
@ -8373,7 +8246,7 @@ declare namespace JQuery {
}
}
// region Legacy types
// #region Legacy types
// tslint:disable-next-line:no-empty-interface
interface JQueryCallback extends JQuery.Callbacks { }
@ -8572,4 +8445,4 @@ interface JQueryEasingFunctions {
swing: JQueryEasingFunction;
}
// endregion
// #endregion

View File

@ -1,7 +1,8 @@
// Type definitions for KeyboardJS v2.2.0
// Type definitions for KeyboardJS v2.4.1
// Project: https://github.com/RobertWHurst/KeyboardJS
// Definitions by: Vincent Bortone <https://github.com/vbortone>,
// David Asmuth <https://github.com/piranha771>
// David Asmuth <https://github.com/piranha771>,
// Tanasoaia Teodor <https://github.com/teoxoy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// KeyboardJS is a library for use in the browser (node.js compatible).
@ -19,6 +20,7 @@ declare namespace keyboardjs {
*/
interface KeyEvent extends KeyboardEvent {
preventRepeat(): void;
pressedKeys: string[];
}
/**

View File

@ -21,10 +21,15 @@ declare class Mailgen {
declare namespace Mailgen {
interface Option {
theme: string;
theme: string | CustomTheme;
product: Product;
}
interface CustomTheme {
path: string;
plaintextPath?: string;
}
interface Product {
name: string;
link: string;

8
types/next/app.d.ts vendored
View File

@ -13,7 +13,7 @@ export type AppComponentContext = NextAppContext;
*
* @template Q Query object schema.
*/
export interface NextAppContext<Q = DefaultQuery> {
export interface NextAppContext<Q extends DefaultQuery = DefaultQuery> {
Component: NextComponentType<any, any, NextContext<Q>>;
router: RouterProps<Q>;
ctx: NextContext<Q>;
@ -25,7 +25,7 @@ export interface NextAppContext<Q = DefaultQuery> {
*
* @template Q Query object schema.
*/
export interface AppProps<Q = DefaultQuery> {
export interface AppProps<Q extends DefaultQuery = DefaultQuery> {
Component: NextComponentType<any, any, NextContext<Q>>;
router: RouterProps<Q>;
pageProps: any;
@ -41,6 +41,6 @@ export interface AppProps<Q = DefaultQuery> {
export type AppComponentType<IP = {}, C = NextAppContext> = NextComponentType<IP & AppProps, IP, C>;
export class Container extends React.Component {}
export default class App<IP = {}, C = NextAppContext> extends React.Component<IP & AppProps> {
getInitialProps(context: C): Promise<IP> | IP;
export default class App<P = {}> extends React.Component<P & AppProps> {
static getInitialProps(context: NextAppContext): Promise<{ pageProps: any }>;
}

View File

@ -30,7 +30,7 @@ export type Enhancer<E extends PageProps = AnyPageProps, P extends any = E> = (
*
* @template Q Query object schema.
*/
export interface NextDocumentContext<Q = DefaultQuery> extends NextContext<Q> {
export interface NextDocumentContext<Q extends DefaultQuery = DefaultQuery> extends NextContext<Q> {
/** A callback that executes the actual React rendering logic (synchronously) */
renderPage<E extends PageProps = AnyPageProps, P extends any = E>(
enhancer?: Enhancer<E, P> // tslint:disable-line no-unnecessary-generics
@ -86,8 +86,6 @@ export type DocumentComponentType<IP = {}, C = NextDocumentContext> = NextCompon
export class Head extends React.Component<HeadProps> {}
export class Main extends React.Component {}
export class NextScript extends React.Component<NextScriptProps> {}
export default class Document<IP = {}, C = NextDocumentContext> extends React.Component<
IP & DocumentProps
> {
getInitialProps(context: C): Promise<IP> | IP;
export default class Document<P = {}> extends React.Component<P & DocumentProps> {
static getInitialProps(context: NextDocumentContext): DocumentProps;
}

View File

@ -33,7 +33,7 @@ declare namespace next {
*
* @template Q Query object schema.
*/
interface NextContext<Q = DefaultQuery> {
interface NextContext<Q extends DefaultQuery = DefaultQuery> {
/** path section of URL */
pathname: string;
/** query string section of URL parsed as an object */

View File

@ -1,11 +1,12 @@
import * as React from "react";
import App, { Container, NextAppContext, AppProps, AppComponentType } from "next/app";
import { DefaultQuery } from "next/router";
interface NextComponentProps {
example: string;
}
interface TypedQuery {
interface TypedQuery extends DefaultQuery {
id?: string;
}
@ -32,11 +33,12 @@ class TestAppWithProps extends App<NextComponentProps> {
}
}
class TestAppWithTypedQuery extends App<{}, NextAppContext<TypedQuery>> {
class TestAppWithTypedQuery extends App {
static async getInitialProps({ ctx }: NextAppContext<TypedQuery>) {
const { id } = ctx.query;
const processQuery = (id?: string) => id;
processQuery(id);
return { pageProps: id };
}
}

View File

@ -1,11 +1,12 @@
import * as React from "react";
import { NextStatelessComponent, NextContext, NextComponentType } from "next";
import { DefaultQuery } from "next/router";
interface NextComponentProps {
example: string;
}
interface TypedQuery {
interface TypedQuery extends DefaultQuery {
id?: string;
}

View File

@ -1220,10 +1220,10 @@ export interface NightwatchAPI {
* browser.pause();
* };
* ```
* @param ms: The number of milliseconds to wait.
* @param ms: Optional - The number of milliseconds to wait.
* @param callback: Optional callback function to be called when the command finishes.
*/
pause(ms: number, callback?: (result: NightwatchCallbackResult) => void): this;
pause(ms?: number, callback?: (result: NightwatchCallbackResult) => void): this;
/**
* A simple perform command which allows access to the "api" in a callback. Can be useful if you want to read variables set by other commands.

79
types/node/index.d.ts vendored
View File

@ -1,34 +1,35 @@
// Type definitions for Node.js 10.10.x
// Type definitions for Node.js 10.11.x
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
// Parambir Singh <https://github.com/parambirs>
// Christian Vaagland Tellnes <https://github.com/tellnes>
// Wilco Bakker <https://github.com/WilcoBakker>
// Nicolas Voigt <https://github.com/octo-sniffle>
// Chigozirim C. <https://github.com/smac89>
// Flarna <https://github.com/Flarna>
// Mariusz Wiktorczyk <https://github.com/mwiktorczyk>
// wwwy3y3 <https://github.com/wwwy3y3>
// Deividas Bakanas <https://github.com/DeividasBakanas>
// Kelvin Jin <https://github.com/kjin>
// Alvis HT Tang <https://github.com/alvis>
// Sebastian Silbermann <https://github.com/eps1lon>
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Alberto Schiabel <https://github.com/jkomyno>
// Klaus Meinhardt <https://github.com/ajafff>
// Huw <https://github.com/hoo29>
// Nicolas Even <https://github.com/n-e>
// Bruno Scheufler <https://github.com/brunoscheufler>
// Mohsen Azimi <https://github.com/mohsen1>
// Hoàng Văn Khải <https://github.com/KSXGitHub>
// Alexander T. <https://github.com/a-tarasyuk>
// Lishude <https://github.com/islishude>
// Alvis HT Tang <https://github.com/alvis>
// Andrew Makarov <https://github.com/r3nya>
// Zane Hannan AU <https://github.com/ZaneHannanAU>
// Thomas den Hollander <https://github.com/ThomasdenH>
// Bruno Scheufler <https://github.com/brunoscheufler>
// Chigozirim C. <https://github.com/smac89>
// Christian Vaagland Tellnes <https://github.com/tellnes>
// Deividas Bakanas <https://github.com/DeividasBakanas>
// Eugene Y. Q. Shen <https://github.com/eyqs>
// Flarna <https://github.com/Flarna>
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Hoàng Văn Khải <https://github.com/KSXGitHub>
// Huw <https://github.com/hoo29>
// Kelvin Jin <https://github.com/kjin>
// Klaus Meinhardt <https://github.com/ajafff>
// Lishude <https://github.com/islishude>
// Mariusz Wiktorczyk <https://github.com/mwiktorczyk>
// Matthieu Sieben <https://github.com/matthieusieben>
// Mohsen Azimi <https://github.com/mohsen1>
// Nicolas Even <https://github.com/n-e>
// Nicolas Voigt <https://github.com/octo-sniffle>
// Parambir Singh <https://github.com/parambirs>
// Sebastian Silbermann <https://github.com/eps1lon>
// Simon Schick <https://github.com/SimonSchick>
// Thomas den Hollander <https://github.com/ThomasdenH>
// Wilco Bakker <https://github.com/WilcoBakker>
// wwwy3y3 <https://github.com/wwwy3y3>
// Zane Hannan AU <https://github.com/ZaneHannanAU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/** inspector module types */
@ -2955,7 +2956,6 @@ declare module "net" {
connect(port: number, connectionListener?: Function): this;
connect(path: string, connectionListener?: Function): this;
bufferSize: number;
setEncoding(encoding?: string): this;
pause(): this;
resume(): this;
@ -2966,15 +2966,16 @@ declare module "net" {
unref(): void;
ref(): void;
remoteAddress?: string;
remoteFamily?: string;
remotePort?: number;
localAddress: string;
localPort: number;
bytesRead: number;
bytesWritten: number;
connecting: boolean;
destroyed: boolean;
readonly bufferSize: number;
readonly bytesRead: number;
readonly bytesWritten: number;
readonly connecting: boolean;
readonly destroyed: boolean;
readonly localAddress: string;
readonly localPort: number;
readonly remoteAddress?: string;
readonly remoteFamily?: string;
readonly remotePort?: number;
// Extended base methods
end(): void;
@ -6553,6 +6554,7 @@ declare module "util" {
export function isArrayBuffer(object: any): object is ArrayBuffer;
export function isAsyncFunction(object: any): boolean;
export function isBooleanObject(object: any): object is Boolean;
export function isBoxedPrimitive(object: any): object is (Number | Boolean | String | Symbol /* BigInt */);
export function isDataView(object: any): object is DataView;
export function isDate(object: any): object is Date;
export function isExternal(object: any): boolean;
@ -7238,15 +7240,20 @@ declare module "http2" {
export interface Http2Stream extends stream.Duplex {
readonly aborted: boolean;
close(code?: number, callback?: () => void): void;
readonly closed: boolean;
readonly destroyed: boolean;
readonly pending: boolean;
priority(options: StreamPriorityOptions): void;
readonly rstCode: number;
readonly session: Http2Session;
setTimeout(msecs: number, callback?: () => void): void;
readonly state: StreamState;
/**
* Set the true if the END_STREAM flag was set in the request or response HEADERS frame received,
* indicating that no additional data should be received and the readable side of the Http2Stream will be closed.
*/
readonly endAfterHeaders: boolean;
close(code?: number, callback?: () => void): void;
priority(options: StreamPriorityOptions): void;
setTimeout(msecs: number, callback?: () => void): void;
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "aborted", listener: () => void): this;

View File

@ -197,11 +197,11 @@ namespace fs_tests {
}
{
var content: string;
var buffer: Buffer;
var stringOrBuffer: string | Buffer;
var nullEncoding: string | null = null;
var stringEncoding: string | null = 'utf8';
let content: string;
let buffer: Buffer;
let stringOrBuffer: string | Buffer;
let nullEncoding: string | null = null;
let stringEncoding: string | null = 'utf8';
content = fs.readFileSync('testfile', 'utf8');
content = fs.readFileSync('testfile', { encoding: 'utf8' });
@ -239,7 +239,7 @@ namespace fs_tests {
}
{
var errno: number;
let errno: number;
fs.readFile('testfile', (err, data) => {
if (err && err.errno) {
errno = err.errno;
@ -277,7 +277,7 @@ namespace fs_tests {
}
{
var tempDir: string;
let tempDir: string;
tempDir = fs.mkdtempSync('/tmp/foo-');
}
@ -421,18 +421,18 @@ namespace fs_tests {
///////////////////////////////////////////////////////
function bufferTests() {
var utf8Buffer = new Buffer('test');
var base64Buffer = new Buffer('', 'base64');
var octets: Uint8Array = null;
var octetBuffer = new Buffer(octets);
var sharedBuffer = new Buffer(octets.buffer);
var copiedBuffer = new Buffer(utf8Buffer);
let utf8Buffer = new Buffer('test');
let base64Buffer = new Buffer('', 'base64');
let octets: Uint8Array = null;
let octetBuffer = new Buffer(octets);
let sharedBuffer = new Buffer(octets.buffer);
let copiedBuffer = new Buffer(utf8Buffer);
console.log(Buffer.isBuffer(octetBuffer));
console.log(Buffer.isEncoding('utf8'));
console.log(Buffer.byteLength('xyz123'));
console.log(Buffer.byteLength('xyz123', 'ascii'));
var result1 = Buffer.concat([utf8Buffer, base64Buffer]);
var result2 = Buffer.concat([utf8Buffer, base64Buffer], 9999999);
let result1 = Buffer.concat([utf8Buffer, base64Buffer]);
let result2 = Buffer.concat([utf8Buffer, base64Buffer], 9999999);
// Class Methods: Buffer.swap16(), Buffer.swa32(), Buffer.swap64()
{
@ -524,15 +524,15 @@ function bufferTests() {
// Test that TS 1.6 works with the 'as Buffer' annotation
// on isBuffer.
var a: Buffer | number;
let a: Buffer | number;
a = new Buffer(10);
if (Buffer.isBuffer(a)) {
a.writeUInt8(3, 4);
}
// write* methods return offsets.
var b = new Buffer(16);
var result: number = b.writeUInt32LE(0, 0);
let b = new Buffer(16);
let result: number = b.writeUInt32LE(0, 0);
result = b.writeUInt16LE(0, 4);
result = b.writeUInt8(0, 6);
result = b.writeInt8(0, 7);
@ -848,14 +848,14 @@ namespace util_tests {
}
static test(): void {
var cfn = util.callbackify(this.fn);
var cfnE = util.callbackify(this.fnE);
var cfnT1 = util.callbackify(this.fnT1);
var cfnT1E = util.callbackify(this.fnT1E);
var cfnTResult = util.callbackify(this.fnTResult);
var cfnTResultE = util.callbackify(this.fnTResultE);
var cfnT1TResult = util.callbackify(this.fnT1TResult);
var cfnT1TResultE = util.callbackify(this.fnT1TResultE);
let cfn = util.callbackify(this.fn);
let cfnE = util.callbackify(this.fnE);
let cfnT1 = util.callbackify(this.fnT1);
let cfnT1E = util.callbackify(this.fnT1E);
let cfnTResult = util.callbackify(this.fnTResult);
let cfnTResultE = util.callbackify(this.fnTResultE);
let cfnT1TResult = util.callbackify(this.fnT1TResult);
let cfnT1TResultE = util.callbackify(this.fnT1TResultE);
cfn((err: NodeJS.ErrnoException, ...args: string[]) => assert(err === null && args.length === 1 && args[0] === undefined));
cfnE((err: NodeJS.ErrnoException, ...args: string[]) => assert(err.message === 'fail' && args.length === 0));
@ -870,13 +870,13 @@ namespace util_tests {
callbackifyTest.test();
// util.promisify
var readPromised = util.promisify(fs.readFile);
var sampleRead: Promise<any> = readPromised(__filename).then((data: Buffer): void => { }).catch((error: Error): void => { });
var arg0: () => Promise<number> = util.promisify((cb: (err: Error, result: number) => void): void => { });
var arg0NoResult: () => Promise<any> = util.promisify((cb: (err: Error) => void): void => { });
var arg1: (arg: string) => Promise<number> = util.promisify((arg: string, cb: (err: Error, result: number) => void): void => { });
var arg1NoResult: (arg: string) => Promise<any> = util.promisify((arg: string, cb: (err: Error) => void): void => { });
var cbOptionalError: () => Promise<void | {}> = util.promisify((cb: (err?: Error | null) => void): void => { cb(); }); // tslint:disable-line void-return
let readPromised = util.promisify(fs.readFile);
let sampleRead: Promise<any> = readPromised(__filename).then((data: Buffer): void => { }).catch((error: Error): void => { });
let arg0: () => Promise<number> = util.promisify((cb: (err: Error, result: number) => void): void => { });
let arg0NoResult: () => Promise<any> = util.promisify((cb: (err: Error) => void): void => { });
let arg1: (arg: string) => Promise<number> = util.promisify((arg: string, cb: (err: Error, result: number) => void): void => { });
let arg1NoResult: (arg: string) => Promise<any> = util.promisify((arg: string, cb: (err: Error) => void): void => { });
let cbOptionalError: () => Promise<void | {}> = util.promisify((cb: (err?: Error | null) => void): void => { cb(); }); // tslint:disable-line void-return
assert(typeof util.promisify.custom === 'symbol');
// util.deprecate
const foo = () => {};
@ -889,13 +889,13 @@ namespace util_tests {
util.isDeepStrictEqual({foo: 'bar'}, {foo: 'bar'});
// util.TextDecoder()
var td = new util.TextDecoder();
let td = new util.TextDecoder();
new util.TextDecoder("utf-8");
new util.TextDecoder("utf-8", { fatal: true });
new util.TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
var ignoreBom: boolean = td.ignoreBOM;
var fatal: boolean = td.fatal;
var encoding: string = td.encoding;
let ignoreBom: boolean = td.ignoreBOM;
let fatal: boolean = td.fatal;
let encoding: string = td.encoding;
td.decode(new Int8Array(1));
td.decode(new Int16Array(1));
td.decode(new Int32Array(1));
@ -910,12 +910,24 @@ namespace util_tests {
td.decode(null);
td.decode(null, { stream: true });
td.decode(new Int8Array(1), { stream: true });
var decode: string = td.decode(new Int8Array(1));
let decode: string = td.decode(new Int8Array(1));
// util.TextEncoder()
var te = new util.TextEncoder();
var teEncoding: string = te.encoding;
var teEncodeRes: Uint8Array = te.encode("TextEncoder");
let te = new util.TextEncoder();
let teEncoding: string = te.encoding;
let teEncodeRes: Uint8Array = te.encode("TextEncoder");
// util.types
// tslint:disable-next-line:no-construct
const maybeBoxed: number | Number = new Number(1);
if (util.types.isBoxedPrimitive(maybeBoxed)) {
const boxed: Number = maybeBoxed;
}
const maybeBoxed2: number | Number = 1;
if (!util.types.isBoxedPrimitive(maybeBoxed2)) {
const boxed: number = maybeBoxed2;
}
}
}
@ -925,10 +937,10 @@ namespace util_tests {
// http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
function stream_readable_pipe_test() {
var rs = fs.createReadStream(Buffer.from('file.txt'));
var r = fs.createReadStream('file.txt');
var z = zlib.createGzip({ finishFlush: zlib.constants.Z_FINISH });
var w = fs.createWriteStream('file.txt.gz');
let rs = fs.createReadStream(Buffer.from('file.txt'));
let r = fs.createReadStream('file.txt');
let z = zlib.createGzip({ finishFlush: zlib.constants.Z_FINISH });
let w = fs.createWriteStream('file.txt.gz');
assert(typeof z.bytesRead === 'number');
assert(typeof r.bytesRead === 'number');
@ -1145,47 +1157,47 @@ async function asyncStreamPipelineFinished() {
namespace crypto_tests {
{
// crypto_hash_string_test
var hashResult: string = crypto.createHash('md5').update('world').digest('hex');
let hashResult: string = crypto.createHash('md5').update('world').digest('hex');
}
{
// crypto_hash_buffer_test
var hashResult: string = crypto.createHash('md5')
let hashResult: string = crypto.createHash('md5')
.update(new Buffer('world')).digest('hex');
}
{
// crypto_hash_dataview_test
var hashResult: string = crypto.createHash('md5')
let hashResult: string = crypto.createHash('md5')
.update(new DataView(new Buffer('world').buffer)).digest('hex');
}
{
// crypto_hash_int8array_test
var hashResult: string = crypto.createHash('md5')
let hashResult: string = crypto.createHash('md5')
.update(new Int8Array(new Buffer('world').buffer)).digest('hex');
}
{
// crypto_hmac_string_test
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
let hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
}
{
// crypto_hmac_buffer_test
var hmacResult: string = crypto.createHmac('md5', 'hello')
let hmacResult: string = crypto.createHmac('md5', 'hello')
.update(new Buffer('world')).digest('hex');
}
{
// crypto_hmac_dataview_test
var hmacResult: string = crypto.createHmac('md5', 'hello')
let hmacResult: string = crypto.createHmac('md5', 'hello')
.update(new DataView(new Buffer('world').buffer)).digest('hex');
}
{
// crypto_hmac_int8array_test
var hmacResult: string = crypto.createHmac('md5', 'hello')
let hmacResult: string = crypto.createHmac('md5', 'hello')
.update(new Int8Array(new Buffer('world').buffer)).digest('hex');
}
@ -1467,17 +1479,17 @@ namespace crypto_tests {
namespace tls_tests {
{
var ctx: tls.SecureContext = tls.createSecureContext({
let ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
let blah = ctx.context;
var connOpts: tls.ConnectionOptions = {
let connOpts: tls.ConnectionOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(connOpts);
let tlsSocket = tls.connect(connOpts);
const ciphers: string[] = tls.getCiphers();
const curve: string = tls.DEFAULT_ECDH_CURVE;
@ -1676,7 +1688,7 @@ namespace tls_tests {
namespace http_tests {
// http Server
{
var server: http.Server = new http.Server();
let server: http.Server = new http.Server();
// test public props
const maxHeadersCount: number = server.maxHeadersCount;
@ -1690,7 +1702,7 @@ namespace http_tests {
// http ServerResponse
{
// incoming
var incoming: http.IncomingMessage = new http.IncomingMessage(new net.Socket());
let incoming: http.IncomingMessage = new http.IncomingMessage(new net.Socket());
incoming.setEncoding('utf8');
@ -1699,12 +1711,12 @@ namespace http_tests {
incoming.resume();
// response
var res: http.ServerResponse = new http.ServerResponse(incoming);
let res: http.ServerResponse = new http.ServerResponse(incoming);
// test headers
res.setHeader('Content-Type', 'text/plain');
var bool: boolean = res.hasHeader('Content-Type');
var headers: string[] = res.getHeaderNames();
let bool: boolean = res.hasHeader('Content-Type');
let headers: string[] = res.getHeaderNames();
// trailers
res.addTrailers([
@ -1724,7 +1736,7 @@ namespace http_tests {
res.write('Part of my res.');
// write buffer
const chunk = Buffer.alloc(16390, 'Й');
req.write(chunk);
res.write(chunk);
res.write(chunk, 'hex');
// end
@ -1738,14 +1750,14 @@ namespace http_tests {
// http ClientRequest
{
var req: http.ClientRequest = new http.ClientRequest("https://www.google.com");
var req: http.ClientRequest = new http.ClientRequest(new url.URL("https://www.google.com"));
var req: http.ClientRequest = new http.ClientRequest({ path: 'http://0.0.0.0' });
let req: http.ClientRequest = new http.ClientRequest("https://www.google.com");
req = new http.ClientRequest(new url.URL("https://www.google.com"));
req = new http.ClientRequest({ path: 'http://0.0.0.0' });
// header
req.setHeader('Content-Type', 'text/plain');
var bool: boolean = req.hasHeader('Content-Type');
var headers: string[] = req.getHeaderNames();
let bool: boolean = req.hasHeader('Content-Type');
let headers: string[] = req.getHeaderNames();
req.removeHeader('Date');
// write
@ -1766,12 +1778,12 @@ namespace http_tests {
{
// Status codes
var codeMessage = http.STATUS_CODES['400'];
var codeMessage = http.STATUS_CODES[400];
let codeMessage: string = http.STATUS_CODES['400'];
codeMessage = http.STATUS_CODES[400];
}
{
var agent: http.Agent = new http.Agent({
let agent: http.Agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 10000,
maxSockets: Infinity,
@ -1779,7 +1791,7 @@ namespace http_tests {
timeout: 15000
});
var agent: http.Agent = http.globalAgent;
agent = http.globalAgent;
http.request({ agent: false });
http.request({ agent });
@ -1815,7 +1827,7 @@ namespace http_tests {
}
{
var request = http.request({ path: 'http://0.0.0.0' });
let request = http.request({ path: 'http://0.0.0.0' });
request.once('error', () => { });
request.setNoDelay(true);
request.abort();
@ -1846,7 +1858,7 @@ namespace http_tests {
//////////////////////////////////////////////////////
namespace https_tests {
var agent: https.Agent = new https.Agent({
let agent: https.Agent = new https.Agent({
keepAlive: true,
keepAliveMsecs: 10000,
maxSockets: Infinity,
@ -1855,7 +1867,7 @@ namespace https_tests {
timeout: 15000
});
var agent: https.Agent = https.globalAgent;
agent = https.globalAgent;
https.request({
agent: false
@ -1922,7 +1934,7 @@ namespace tty_tests {
namespace dgram_tests {
{
var ds: dgram.Socket = dgram.createSocket("udp4", (msg: Buffer, rinfo: dgram.RemoteInfo): void => {
let ds: dgram.Socket = dgram.createSocket("udp4", (msg: Buffer, rinfo: dgram.RemoteInfo): void => {
});
ds.bind();
ds.bind(41234);
@ -2710,11 +2722,11 @@ namespace child_process_tests {
console.log(process.stdin instanceof net.Socket);
console.log(process.stdout instanceof fs.ReadStream);
var stdin: stream.Readable = process.stdin;
let stdin: stream.Readable = process.stdin;
console.log(stdin instanceof net.Socket);
console.log(stdin instanceof fs.ReadStream);
var stdout: stream.Writable = process.stdout;
let stdout: stream.Writable = process.stdout;
console.log(stdout instanceof net.Socket);
console.log(stdout instanceof fs.WriteStream);
}
@ -2951,7 +2963,7 @@ namespace vm_tests {
console.log(util.inspect(sandboxes));
var localVar = 'initial value';
let localVar = 'initial value';
vm.runInThisContext('localVar = "vm";');
console.log(localVar);
@ -3053,17 +3065,17 @@ namespace errors_tests {
import * as p from "process";
namespace process_tests {
{
var eventEmitter: events.EventEmitter;
let eventEmitter: events.EventEmitter;
eventEmitter = process; // Test that process implements EventEmitter...
var _p: NodeJS.Process = process;
let _p: NodeJS.Process = process;
_p = p;
}
{
assert(process.argv[0] === process.argv0);
}
{
var module: NodeModule | undefined;
let module: NodeModule | undefined;
module = process.mainModule;
}
{
@ -3103,12 +3115,12 @@ namespace process_tests {
import * as c from "console";
namespace console_tests {
{
var _c: Console = console;
let _c: Console = console;
_c = c;
}
{
var writeStream = fs.createWriteStream('./index.d.ts');
var consoleInstance = new console.Console(writeStream);
let writeStream = fs.createWriteStream('./index.d.ts');
let consoleInstance = new console.Console(writeStream);
}
}
@ -3562,8 +3574,8 @@ namespace dns_tests {
import * as constants from 'constants';
import { PerformanceObserver, PerformanceObserverCallback } from "perf_hooks";
namespace constants_tests {
var str: string;
var num: number;
let str: string;
let num: number;
num = constants.SIGHUP;
num = constants.SIGINT;
num = constants.SIGQUIT;

View File

@ -22693,7 +22693,7 @@ declare namespace Excel {
*
* [Api set: ExcelApi 1.8]
*/
splitType: Excel.ChartSplitStype | "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";
splitType: "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";
/**
*
* True if Microsoft Excel assigns a different color or pattern to each data marker. The chart must contain only one series. Read/Write.
@ -30268,15 +30268,6 @@ declare namespace Excel {
rows = "Rows",
columns = "Columns",
}
/**
* [Api set: ExcelApi 1.8]
*/
enum ChartSplitStype {
splitByPosition = "SplitByPosition",
splitByValue = "SplitByValue",
splitByPercentValue = "SplitByPercentValue",
splitByCustomSplit = "SplitByCustomSplit",
}
/**
* [Api set: ExcelApi 1.8]
*/
@ -36094,7 +36085,7 @@ declare namespace Excel {
*
* [Api set: ExcelApi 1.8]
*/
splitType?: Excel.ChartSplitStype | "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";
splitType?: "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";
/**
*
* True if Microsoft Excel assigns a different color or pattern to each data marker. The chart must contain only one series. Read/Write.
@ -39781,7 +39772,7 @@ declare namespace Excel {
*
* [Api set: ExcelApi 1.8]
*/
splitType?: Excel.ChartSplitStype | "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";
splitType?: "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";
/**
*
* True if Microsoft Excel assigns a different color or pattern to each data marker. The chart must contain only one series. Read/Write.

35
types/permit/index.d.ts vendored Normal file
View File

@ -0,0 +1,35 @@
// Type definitions for permit 0.2
// Project: https://github.com/ianstormtaylor/permit#readme
// Definitions by: My Self <https://github.com/jannikkeye>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { IncomingMessage, ServerResponse } from "http";
export interface PermitOptions {
scheme?: string;
proxy?: string;
realm?: string;
}
export interface BearerOptions extends PermitOptions {
basic?: string;
header?: string;
query?: string;
}
export class Permit {
constructor(options: PermitOptions);
check(req: IncomingMessage): void;
fail(res: ServerResponse): void;
}
export class Bearer extends Permit {
constructor(options: BearerOptions);
check(req: IncomingMessage): string;
}
export class Basic extends Permit {
check(req: IncomingMessage): [string, string];
}

View File

@ -0,0 +1,61 @@
import { IncomingMessage, ServerResponse } from "http";
import { Permit, Basic, Bearer } from 'permit';
const permit = new Permit({
scheme: "some-scheme",
proxy: "some-proxy",
realm: "auth"
});
const basic = new Basic({
scheme: "some-scheme",
proxy: "some-proxy",
realm: "auth"
});
const bearer = new Bearer({
basic: 'username',
query: 'access_token',
});
function permitHandler(req: IncomingMessage, res: ServerResponse) {
permit.check(req);
permit.fail(res);
}
function basichHndler(req: IncomingMessage, res: ServerResponse) {
const token = basic.check(req);
if (!token) {
basic.fail(res);
throw new Error(`Authentication required!`);
}
const user = "some-user";
if (!user) {
basic.fail(res);
throw new Error(`Authentication invalid!`);
}
return 'Success!';
}
function bearerHandler(req: IncomingMessage, res: ServerResponse) {
const token = bearer.check(req);
if (!token) {
bearer.fail(res);
throw new Error(`Authentication required!`);
}
const user = "some-user";
if (!user) {
bearer.fail(res);
throw new Error(`Authentication invalid!`);
}
return 'Success!';
}

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",
"permit-tests.ts"
]
}

3
types/permit/tslint.json Normal file
View File

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

View File

@ -289,6 +289,12 @@ declare namespace Pikaday {
*/
formatStrict?: boolean;
/**
* Function which will be used for formatting date object to string.
* This function will take precedence over moment.
*/
toString?(date: Date, format?: string): string;
/**
* Function which will be used for parsing input string and getting a date object from it.
* This function will take precedence over moment.

View File

@ -87,6 +87,7 @@ new Pikaday({field: $('#datepicker')[0]});
mainCalendar: 'right',
theme: 'myTheme',
formatStrict: true,
toString: (date) => '2017-08-23',
parse: () => new Date('2017-08-23'),
onSelect: () => {},
onOpen: () => {},
@ -97,6 +98,7 @@ new Pikaday({field: $('#datepicker')[0]});
(() => {
new Pikaday({
yearRange: 5
yearRange: 5,
toString: (date, format) => '2017-08-23'
});
})();

View File

@ -1,6 +1,7 @@
// Type definitions for react-is 16.3
// Type definitions for react-is 16.5
// Project: https://reactjs.org/
// Definitions by: Avi Vahl <https://github.com/AviVahl>
// Christian Chown <https://github.com/christianchown>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -10,17 +11,22 @@ import { ReactElement, ReactType } from 'react';
export function typeOf(value: any): symbol | undefined;
export function isValidElementType(value: any): value is ReactType;
export function isAsyncMode(value: any): value is ReactElement<any>;
export function isContextConsumer(value: any): value is ReactElement<any>;
export function isContextProvider(value: any): value is ReactElement<any>;
export function isElement(value: any): value is ReactElement<any>;
export function isForwardRef(value: any): value is ReactElement<any>;
export function isFragment(value: any): value is ReactElement<any>;
export function isProfiler(value: any): value is ReactElement<any>;
export function isPortal(value: any): value is ReactElement<any>;
export function isStrictMode(value: any): value is ReactElement<any>;
export const AsyncMode: symbol;
export const ContextProvider: symbol;
export const ContextConsumer: symbol;
export const Element: symbol;
export const ForwardRef: symbol;
export const Fragment: symbol;
export const Portal: symbol;
export const Profiler: symbol;
export const StrictMode: symbol;

View File

@ -72,3 +72,7 @@ ReactIs.typeOf(123) === undefined;
ReactIs.typeOf({}) === undefined;
ReactIs.typeOf(null) === undefined;
ReactIs.typeOf(undefined) === undefined;
// ForwardRef
const forwardRef = React.forwardRef((props, ref) => <div />);
ReactIs.isForwardRef(forwardRef); // true

View File

@ -13,6 +13,7 @@
// Tanguy Krotoff <https://github.com/tkrotoff>
// Alexander T. <https://github.com/a-tarasyuk>
// Martin van Dam <https://github.com/mvdam>
// Kacper Wiszczuk <https://github.com/esemesek>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -4810,7 +4811,7 @@ export interface ModalPropsIOS {
* 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.
*/
onOrientationChange?: (event?: NativeSyntheticEvent<any>) => void;
onOrientationChange?: (event: NativeSyntheticEvent<any>) => void;
}
export interface ModalPropsAndroid {
@ -6301,27 +6302,27 @@ export interface ScrollViewProps
* Fires at most once per frame during scrolling.
* The frequency of the events can be contolled using the scrollEventThrottle prop.
*/
onScroll?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void;
onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* Fires if a user initiates a scroll gesture.
*/
onScrollBeginDrag?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void;
onScrollBeginDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* Fires when a user has finished scrolling.
*/
onScrollEndDrag?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void;
onScrollEndDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* Fires when scroll view has finished moving
*/
onMomentumScrollEnd?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void;
onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* Fires when scroll view has begun moving
*/
onMomentumScrollBegin?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void;
onMomentumScrollBegin?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* When true the scroll view stops on multiples of the scroll view's size
@ -8484,7 +8485,7 @@ export namespace Animated {
type Mapping = { [key: string]: Mapping } | AnimatedValue;
interface EventConfig<T> {
listener?: (event?: NativeSyntheticEvent<T>) => void;
listener?: (event: NativeSyntheticEvent<T>) => void;
useNativeDriver?: boolean;
}

View File

@ -63,6 +63,7 @@ import {
InputAccessoryView,
StatusBar,
NativeSyntheticEvent,
NativeScrollEvent,
GestureResponderEvent,
TextInputScrollEventData,
TextInputSelectionChangeEventData,
@ -388,7 +389,14 @@ export class CapsLockComponent extends React.Component<TextProps> {
}
}
class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListViewDataSource }> {
class ScrollerListComponentTest extends React.Component<
{},
{ dataSource: ListViewDataSource }
> {
eventHandler = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
console.log(event);
};
render() {
const scrollViewStyle1 = StyleSheet.create({
scrollView: {
@ -406,11 +414,27 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi
throw new Error("Expected scroll to be enabled.");
}
return <ScrollView horizontal={true} nestedScrollEnabled={true} contentOffset={{x: 0, y: 0}} {...props} style={[scrollViewStyle1.scrollView, scrollViewStyle2]} />;
return (
<ScrollView
horizontal={true}
nestedScrollEnabled={true}
contentOffset={{ x: 0, y: 0 }}
{...props}
style={[
scrollViewStyle1.scrollView,
scrollViewStyle2
]}
/>
);
}}
renderRow={({ type, data }, _, row) => {
return <Text>Filler</Text>;
}}
onScroll={this.eventHandler}
onScrollBeginDrag={this.eventHandler}
onScrollEndDrag={this.eventHandler}
onMomentumScrollBegin={this.eventHandler}
onMomentumScrollEnd={this.eventHandler}
/>
);
}

View File

@ -1238,9 +1238,9 @@ export interface NavigationInjectedProps<P = NavigationParams> {
navigation: NavigationScreenProp<NavigationState, P>;
}
export function withNavigation<T = {}>(
Component: React.ComponentType<T & NavigationInjectedProps>
): React.ComponentType<T & { onRef?: React.Ref<React.Component<T & NavigationInjectedProps>> }>;
export function withNavigation<T = {}, P = NavigationParams>(
Component: React.ComponentType<T & NavigationInjectedProps<P>>
): React.ComponentType<T & { onRef?: React.Ref<React.Component<T & NavigationInjectedProps<P>>> }>;
export interface NavigationFocusInjectedProps extends NavigationInjectedProps {
isFocused: boolean;

View File

@ -1,6 +1,6 @@
// Type definitions for react-tabs 1.0.0
// Type definitions for react-tabs 2.3.0
// Project: https://github.com/reactjs/react-tabs/
// Definitions by: Yuu Igarashi <https://github.com/yu-i9/>, Daniel Tschinder <https://github.com/danez>
// Definitions by: Yuu Igarashi <https://github.com/yu-i9/>, Daniel Tschinder <https://github.com/danez>, Ummon Karpe <https://github.com/Equationist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -11,6 +11,7 @@ export interface TabsProps {
defaultFocus?: boolean;
defaultIndex?: number;
disabledTabClassName?: string;
domRef?: (node?: HTMLElement) => void;
forceRenderTabPanel?: boolean;
onSelect?: (index: number, last: number, event: Event) => boolean | void;
selectedIndex?: number;
@ -27,6 +28,7 @@ export interface TabProps {
disabled?: boolean;
disabledClassName?: string;
selectedClassName?: string;
tabIndex?: string;
}
export interface TabPanelProps {
@ -35,9 +37,9 @@ export interface TabPanelProps {
selectedClassName?: string;
}
export declare class Tabs extends React.Component<TabsProps> {}
export declare class TabList extends React.Component<TabListProps> {}
export declare class Tab extends React.Component<TabProps> {}
export declare class TabPanel extends React.Component<TabPanelProps> {}
export declare class Tabs extends React.Component<TabsProps> { }
export declare class TabList extends React.Component<TabListProps> { }
export declare class Tab extends React.Component<TabProps> { }
export declare class TabPanel extends React.Component<TabPanelProps> { }
export declare function resetIdCounter(): void;

View File

@ -2,6 +2,7 @@
// Project: https://github.com/ondras/rot.js
// Definitions by: Roger Ostrander <https://github.com/atiaxi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// Extensions (thanks, https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html )
declare global {
@ -353,7 +354,7 @@ export interface RNGable {
getUniformInt(lowerBound: number, upperBound: number): number;
getNormal(mean?: number, stddev?: number): number;
getPercentage(): number;
getWeightedValue<T>(data: { T: number }): T;
getWeightedValue<K extends string>(data: Record<K, number>): K;
getState(): [number, number, number, number];
setState(state: [number, number, number, number]): RNGable;
clone(): RNGable;

View File

@ -160,6 +160,9 @@ ROT.RNG.setSeed(123);
SHOW(ROT.RNG.getUniform());
SHOW(clone.getUniform());
clone.getWeightedValue({} as any); // $ExpectType string
clone.getWeightedValue({ a: 1, b: 2 }); // $ExpectType "a" | "b"
// RNG / Picking a weighted value
const monsters = {
orc: 3,

View File

@ -5233,8 +5233,17 @@ declare namespace sequelize {
* `this.constructor.prototype.find.apply(this, arguments)`
*/
classMethods?: Object;
/**
* Change the database schema. PG only feature, but also works with other dialects.
*/
schema?: string;
/**
* Change the database schema delimiter. Defaults to "." on PG but for other dialects can be also changed to "_".
*/
schemaDelimiter?: string;
/**
* You can also change the database engine, e.g. to MyISAM. InnoDB is the default.

View File

@ -4,9 +4,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as winston from 'winston';
import Transport = require("winston-transport");
export interface SlackTransportOptions extends winston.WinstonModuleTransportOptions {
export interface SlackTransportOptions extends Transport.TransportStreamOptions {
domain: string;
token: string;
webhook_url: string;
@ -18,6 +18,6 @@ export interface SlackTransportOptions extends winston.WinstonModuleTransportOpt
queueDelay?: number;
}
export class Slack extends winston.Transport implements winston.TransportInstance {
export class Slack extends Transport {
constructor(options?: SlackTransportOptions);
}

View File

@ -1,4 +1,4 @@
// Type definitions for storybook-addon-jsx 5.3
// Type definitions for storybook-addon-jsx 5.4
// Project: https://github.com/storybooks/storybook
// Definitions by: James Newell <https://github.com/jameslnewell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -8,7 +8,13 @@ import '@storybook/react';
import { ReactNode } from 'react';
declare module '@storybook/react' {
interface Options {
skip?: number;
enableBeautify?: boolean;
onBeforeRender?: (domString: string) => string;
}
interface Story {
addWithJSX(kind: string, fn: () => ReactNode): Story;
addWithJSX(kind: string, fn: () => ReactNode, options?: Options): Story;
}
}

Some files were not shown because too many files have changed in this diff Show More