mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Merge branch 'master' of github.com:DefinitelyTyped/DefinitelyTyped into ember-array
This commit is contained in:
@@ -60,3 +60,6 @@ Object.keys(insertGlobals.vars).forEach((x) => {
|
||||
var b = browserify('./browser/main.js', {
|
||||
insertGlobalVars: insertGlobalVars
|
||||
});
|
||||
|
||||
declare const file: string | string[];
|
||||
b.add(file);
|
||||
|
||||
Vendored
+5
-3
@@ -1,6 +1,9 @@
|
||||
// Type definitions for Browserify 12.0
|
||||
// Project: http://browserify.org/
|
||||
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar>, John Vilk <https://github.com/jvilk>, Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar>
|
||||
// John Vilk <https://github.com/jvilk>
|
||||
// Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -102,8 +105,7 @@ interface BrowserifyObject extends NodeJS.EventEmitter {
|
||||
* Add an entry file from file that will be executed when the bundle loads.
|
||||
* If file is an array, each item in file will be added as an entry file.
|
||||
*/
|
||||
add(file: InputFile[], opts?: FileOptions): BrowserifyObject;
|
||||
add(file: InputFile, opts?: FileOptions): BrowserifyObject;
|
||||
add(file: InputFile | InputFile[], opts?: FileOptions): BrowserifyObject;
|
||||
/**
|
||||
* Make file available from outside the bundle with require(file).
|
||||
* The file param is anything that can be resolved by require.resolve().
|
||||
|
||||
@@ -13,6 +13,7 @@ function test() {
|
||||
expect(testElement).to.have.id('id');
|
||||
expect(testElement).to.have.html('foo');
|
||||
expect(testElement).to.have.text('foo');
|
||||
expect(testElement).to.have.trimmed.text('foo');
|
||||
expect(testElement).to.have.text(['foo', 'bar']);
|
||||
expect(testElement).to.have.value('foo');
|
||||
expect(testElement).to.be.empty;
|
||||
|
||||
Vendored
+2
@@ -35,6 +35,8 @@ declare namespace Chai {
|
||||
|
||||
displayed: Assertion;
|
||||
|
||||
trimmed: Assertion;
|
||||
|
||||
}
|
||||
|
||||
interface Include {
|
||||
|
||||
@@ -5,8 +5,8 @@ import { Chart, ChartData, Point } from "chart.js";
|
||||
// => chartjs.Chart
|
||||
|
||||
const plugin = {
|
||||
afterDraw: (chartInstance: Chart, easing: string, options?: any) => {
|
||||
}
|
||||
afterDraw: (chartInstance: Chart, easing: string, options?: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
|
||||
@@ -82,6 +82,18 @@ if (chart.chartArea) {
|
||||
console.log(chart.chartArea.left);
|
||||
}
|
||||
|
||||
// Testing custom legends
|
||||
chart.config.options = {
|
||||
...chart.config.options,
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
legendCallback: () => 'legend replacement'
|
||||
};
|
||||
chart.update();
|
||||
const customLegend = chart.generateLegend();
|
||||
console.log(customLegend === 'legend replacement');
|
||||
|
||||
// Testing radial chart
|
||||
const tickOptions: Chart.LinearTickOptions = {
|
||||
max: 100,
|
||||
@@ -107,14 +119,14 @@ const chartConfig: Chart.ChartConfiguration = {
|
||||
data: {
|
||||
labels: ['#apples', '#pears', '#apricots', '#acorns', '#amigas', "#orics"],
|
||||
datasets: [{
|
||||
label: "test",
|
||||
lineTension: 0.15,
|
||||
data: [1, 1, 2, 3, 5],
|
||||
backgroundColor: '#37738353',
|
||||
borderColor: '#37738353',
|
||||
borderWidth: 3,
|
||||
fill: true
|
||||
}]
|
||||
label: "test",
|
||||
lineTension: 0.15,
|
||||
data: [1, 1, 2, 3, 5],
|
||||
backgroundColor: '#37738353',
|
||||
borderColor: '#37738353',
|
||||
borderWidth: 3,
|
||||
fill: true
|
||||
}]
|
||||
},
|
||||
options: radarChartOptions
|
||||
};
|
||||
|
||||
Vendored
+3
-1
@@ -14,6 +14,7 @@
|
||||
// Francesco Benedetto <https://github.com/frabnt>
|
||||
// Alexandros Dorodoulis <https://github.com/alexdor>
|
||||
// Manuel Heidrich <https://github.com/mahnuh>
|
||||
// Conrad Holtzhausen <https://github.com/Conrad777>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -163,7 +164,7 @@ interface Model {
|
||||
}
|
||||
|
||||
declare namespace Chart {
|
||||
type ChartType = 'line' | 'bar' | 'horizontalBar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble' | 'pie';
|
||||
type ChartType = 'line' | 'bar' | 'horizontalBar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble' | 'pie' | 'scatter';
|
||||
|
||||
type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
||||
|
||||
@@ -264,6 +265,7 @@ declare namespace Chart {
|
||||
aspectRatio?: number;
|
||||
maintainAspectRatio?: boolean;
|
||||
events?: string[];
|
||||
legendCallback?(chart: Chart): string;
|
||||
onHover?(this: Chart, event: MouseEvent, activeElements: Array<{}>): any;
|
||||
onClick?(event?: MouseEvent, activeElements?: Array<{}>): any;
|
||||
onResize?(this: Chart, newSize: ChartSize): void;
|
||||
|
||||
+11
@@ -9,6 +9,13 @@ office-js
|
||||
Copyright (c) Microsoft Corporation
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//////////////////// Begin custom-functions-runtime ////////////
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Enables you to map your own name that uses lowercase letters to a function.
|
||||
*/
|
||||
declare let CustomFunctionMappings: { [key: string]: Function };
|
||||
|
||||
declare namespace CustomFunctions {
|
||||
@@ -28,3 +35,7 @@ declare namespace CustomFunctions {
|
||||
onCanceled: () => void;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//////////////////// End custom-functions-runtime ////////////
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
|
||||
Vendored
+194
-193
@@ -208,11 +208,10 @@ declare module 'ember' {
|
||||
const ViewMixin: EmberMixin<ViewMixin>;
|
||||
|
||||
/**
|
||||
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.
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
class CoreView extends Ember.Object.extend(Ember.Evented, Ember.ActionHandler) {}
|
||||
interface ActionSupport {
|
||||
sendAction(action: string, ...params: any[]): void;
|
||||
@@ -221,17 +220,17 @@ declare module 'ember' {
|
||||
|
||||
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.
|
||||
*/
|
||||
* 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
|
||||
@@ -248,11 +247,11 @@ declare module 'ember' {
|
||||
actionContext?: Ember.Object;
|
||||
}
|
||||
/**
|
||||
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.
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
interface TargetActionSupport {
|
||||
triggerAction(opts: TriggerActionOptions): boolean;
|
||||
}
|
||||
@@ -327,7 +326,7 @@ declare module 'ember' {
|
||||
/**
|
||||
* Given a fullName return the corresponding factory.
|
||||
*/
|
||||
resolveRegistration(fullName: string): Function;
|
||||
resolveRegistration(fullName: string): (...args: any[]) => any;
|
||||
/**
|
||||
* Registers a factory or value that can be used for dependency injection (with
|
||||
* `inject`) or for service lookup. Each factory is registered with
|
||||
@@ -374,111 +373,111 @@ declare module 'ember' {
|
||||
}
|
||||
const _RegistryProxyMixin: EmberMixin<_RegistryProxyMixin>;
|
||||
/**
|
||||
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.)
|
||||
**/
|
||||
* 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.
|
||||
**/
|
||||
* 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.
|
||||
**/
|
||||
* The collection of functions, keyed by name, available on this ActionHandler as action targets.
|
||||
*/
|
||||
actions: ActionsHash;
|
||||
}
|
||||
const ActionHandler: EmberMixin<ActionHandler>;
|
||||
/**
|
||||
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.
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
* 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
|
||||
**/
|
||||
* 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.
|
||||
**/
|
||||
* 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: Function, options?: {}): 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.
|
||||
**/
|
||||
* 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 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).
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
* The DOM events for which the event dispatcher should listen.
|
||||
*/
|
||||
customEvents: EventDispatcherEvents;
|
||||
/**
|
||||
The Ember.EventDispatcher responsible for delegating events to this application's views.
|
||||
**/
|
||||
* The Ember.EventDispatcher responsible for delegating events to this application's views.
|
||||
*/
|
||||
eventDispatcher: EventDispatcher;
|
||||
/**
|
||||
Set this to provide an alternate class to Ember.DefaultResolver
|
||||
**/
|
||||
* 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.
|
||||
**/
|
||||
* 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: Function;
|
||||
* 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.
|
||||
**/
|
||||
* Application's router.
|
||||
*/
|
||||
Router: Router;
|
||||
registry: Registry;
|
||||
/**
|
||||
@@ -492,21 +491,21 @@ declare module 'ember' {
|
||||
buildInstance(options?: object): ApplicationInstance;
|
||||
}
|
||||
/**
|
||||
The `ApplicationInstance` encapsulates all of the stateful aspects of a
|
||||
running `Application`.
|
||||
**/
|
||||
* The `ApplicationInstance` encapsulates all of the stateful aspects of a
|
||||
* running `Application`.
|
||||
*/
|
||||
class ApplicationInstance extends EngineInstance {}
|
||||
|
||||
/**
|
||||
AutoLocation will select the best location option based off browser support with the priority order: history, hash, none.
|
||||
**/
|
||||
* AutoLocation will select the best location option based off browser support with the priority order: history, hash, none.
|
||||
*/
|
||||
class AutoLocation extends Object {}
|
||||
/**
|
||||
* Connects the properties of two objects so that whenever the value of one property changes,
|
||||
* the other property will be changed also.
|
||||
*
|
||||
* @deprecated https://emberjs.com/deprecations/v2.x#toc_ember-binding
|
||||
**/
|
||||
*/
|
||||
class Binding {
|
||||
constructor(toPath: string, fromPath: string);
|
||||
connect(obj: any): Binding;
|
||||
@@ -517,9 +516,9 @@ declare module 'ember' {
|
||||
toString(): string;
|
||||
}
|
||||
/**
|
||||
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.
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
class Checkbox extends Component {}
|
||||
/**
|
||||
* Implements some standard methods for comparing objects. Add this mixin to
|
||||
@@ -530,10 +529,10 @@ declare module 'ember' {
|
||||
}
|
||||
const Comparable: EmberMixin<Comparable>;
|
||||
/**
|
||||
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.
|
||||
**/
|
||||
* 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.
|
||||
*/
|
||||
class Component extends CoreView.extend(ViewMixin, ActionSupport, ClassNamesSupport) {
|
||||
// methods
|
||||
readDOMAttr(name: string): string;
|
||||
@@ -616,9 +615,9 @@ declare module 'ember' {
|
||||
factoryFor(fullName: string, options?: {}): any;
|
||||
}
|
||||
/**
|
||||
The ContainerDebugAdapter helps the container and resolver interface
|
||||
with tools that debug Ember such as the Ember Inspector for Chrome and Firefox.
|
||||
**/
|
||||
* The ContainerDebugAdapter helps the container and resolver interface
|
||||
* with tools that debug Ember such as the Ember Inspector for Chrome and Firefox.
|
||||
*/
|
||||
class ContainerDebugAdapter extends Object {
|
||||
resolver: Resolver;
|
||||
canCatalogEntriesByType(type: string): boolean;
|
||||
@@ -636,7 +635,7 @@ declare module 'ember' {
|
||||
scope?: QueryParamScopeTypes,
|
||||
as?: string
|
||||
}}>;
|
||||
target: Object;
|
||||
target: object;
|
||||
}
|
||||
const ControllerMixin: EmberMixin<ControllerMixin>;
|
||||
class Controller extends Object.extend(ControllerMixin) {}
|
||||
@@ -792,8 +791,8 @@ declare module 'ember' {
|
||||
}
|
||||
|
||||
/**
|
||||
A subclass of the JavaScript Error object for use in Ember.
|
||||
**/
|
||||
* A subclass of the JavaScript Error object for use in Ember.
|
||||
*/
|
||||
const Error: ErrorConstructor;
|
||||
/**
|
||||
* `Ember.EventDispatcher` handles delegating browser events to their
|
||||
@@ -859,7 +858,7 @@ declare module 'ember' {
|
||||
* for Ember.
|
||||
*/
|
||||
const Instrumentation: {
|
||||
instrument(name: string, payload: any, callback: Function, binding: any): void;
|
||||
instrument(name: string, payload: any, callback: (...args: any[]) => any, binding: any): void;
|
||||
reset(): void;
|
||||
subscribe(pattern: string, object: any): void;
|
||||
unsubscribe(subscriber: any): void;
|
||||
@@ -952,7 +951,7 @@ declare module 'ember' {
|
||||
class Map {
|
||||
copy(): Map;
|
||||
static create(): Map;
|
||||
forEach(callback: Function, self: any): void;
|
||||
forEach(callback: (...args: any[]) => any, self: any): void;
|
||||
get(key: any): any;
|
||||
has(key: any): boolean;
|
||||
set(key: any, value: any): void;
|
||||
@@ -993,7 +992,7 @@ declare module 'ember' {
|
||||
clear(): void;
|
||||
copy(): OrderedSet;
|
||||
static create(): OrderedSet;
|
||||
forEach(fn: Function, self: any): void;
|
||||
forEach(fn: (...args: any[]) => any, self: any): void;
|
||||
has(obj: any): boolean;
|
||||
isEmpty(): boolean;
|
||||
toArray(): any[];
|
||||
@@ -1012,41 +1011,41 @@ declare module 'ember' {
|
||||
}
|
||||
class Resolver extends Ember.Object {}
|
||||
/**
|
||||
The `Ember.Route` class is used to define individual routes. Refer to
|
||||
the [routing guide](http://emberjs.com/guides/routing/) for documentation.
|
||||
*/
|
||||
* The `Ember.Route` class is used to define individual routes. Refer to
|
||||
* the [routing guide](http://emberjs.com/guides/routing/) for documentation.
|
||||
*/
|
||||
class Route extends Object.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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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;
|
||||
|
||||
/**
|
||||
@@ -1394,11 +1393,11 @@ declare module 'ember' {
|
||||
* in as the only argument.
|
||||
*/
|
||||
interface TextSupport extends TargetActionSupport {
|
||||
cancel(event: Function): void;
|
||||
focusIn(event: Function): void;
|
||||
focusOut(event: Function): void;
|
||||
insertNewLine(event: Function): void;
|
||||
keyPress(event: Function): void;
|
||||
cancel(event: (...args: any[]) => any): void;
|
||||
focusIn(event: (...args: any[]) => any): void;
|
||||
focusOut(event: (...args: any[]) => any): void;
|
||||
insertNewLine(event: (...args: any[]) => any): void;
|
||||
keyPress(event: (...args: any[]) => any): void;
|
||||
action: string;
|
||||
bubbles: boolean;
|
||||
onEvent: string;
|
||||
@@ -1406,15 +1405,15 @@ declare module 'ember' {
|
||||
const TextSupport: Mixin<TextSupport, Ember.Component>;
|
||||
interface Transition {
|
||||
/**
|
||||
Aborts the Transition. Note you can also implicitly abort a transition
|
||||
by initiating another transition while a previous one is underway.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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;
|
||||
}
|
||||
interface ViewTargetActionSupport {
|
||||
@@ -1582,7 +1581,7 @@ declare module 'ember' {
|
||||
const String: boolean;
|
||||
}
|
||||
namespace Handlebars {
|
||||
function compile(string: string): Function;
|
||||
function compile(string: string): (...args: any[]) => any;
|
||||
function compile(environment: any, options?: any, context?: any, asObject?: any): any;
|
||||
function precompile(string: string, options: any): void;
|
||||
class Compiler {}
|
||||
@@ -2005,7 +2004,7 @@ declare module 'ember' {
|
||||
* Detects when a specific package of Ember (e.g. 'Ember.Application')
|
||||
* has fully loaded and is available for extension.
|
||||
*/
|
||||
function onLoad(name: string, callback: Function): any;
|
||||
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.
|
||||
@@ -2098,44 +2097,44 @@ declare module 'ember' {
|
||||
export class RouterService extends Ember.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`
|
||||
*/
|
||||
* 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`
|
||||
*/
|
||||
* 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;
|
||||
//
|
||||
/**
|
||||
@@ -2292,6 +2291,7 @@ declare module '@ember/controller' {
|
||||
|
||||
// A type registry for Ember `Controller`s. Meant to be declaration-merged
|
||||
// so string lookups resolve to the correct type.
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
export interface Registry {}
|
||||
}
|
||||
|
||||
@@ -2403,6 +2403,7 @@ declare module '@ember/service' {
|
||||
|
||||
// A type registry for Ember `Service`s. Meant to be declaration-merged so
|
||||
// string lookups resolve to the correct type.
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface Registry {}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,6 @@ appInstance.lookup('route:basic');
|
||||
|
||||
appInstance.boot();
|
||||
|
||||
(async function() {
|
||||
(async () => {
|
||||
await appInstance.boot();
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
import { assertType } from "./lib/assert";
|
||||
|
||||
let BaseApp = Ember.Application.extend({
|
||||
const BaseApp = Ember.Application.extend({
|
||||
modulePrefix: 'my-app'
|
||||
});
|
||||
|
||||
@@ -19,14 +19,14 @@ BaseApp.instanceInitializer({
|
||||
}
|
||||
});
|
||||
|
||||
let App1 = BaseApp.create({
|
||||
const App1 = BaseApp.create({
|
||||
rootElement: '#app-one',
|
||||
customEvents: {
|
||||
paste: 'paste'
|
||||
}
|
||||
});
|
||||
|
||||
let App2 = BaseApp.create({
|
||||
const App2 = BaseApp.create({
|
||||
rootElement: '#app-two',
|
||||
customEvents: {
|
||||
mouseenter: null,
|
||||
@@ -34,8 +34,8 @@ let App2 = BaseApp.create({
|
||||
}
|
||||
});
|
||||
|
||||
let App3 = BaseApp.create();
|
||||
const App3 = BaseApp.create();
|
||||
|
||||
let App3Instance1 = App3.buildInstance();
|
||||
const App3Instance1 = App3.buildInstance();
|
||||
|
||||
let App3Instance2 = App3.buildInstance({ foo: 'bar' });
|
||||
const App3Instance2 = App3.buildInstance({ foo: 'bar' });
|
||||
|
||||
@@ -21,6 +21,6 @@ class MyNewProxy<T> extends Ember.ArrayProxy<T> {
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
let x = MyNewProxy.create({ content: Ember.A([1, 2, 3]) }) as MyNewProxy<number>;
|
||||
const x = MyNewProxy.create({ content: Ember.A([1, 2, 3]) }) as MyNewProxy<number>;
|
||||
assertType<number | undefined>(x.get('firstObject'));
|
||||
assertType<boolean>(x.isNew);
|
||||
|
||||
@@ -42,7 +42,7 @@ const codes: number[] = letters.map((item, index, enumerable) => {
|
||||
return item.charCodeAt(0);
|
||||
});
|
||||
|
||||
let value = '1,2,3';
|
||||
let filters = Ember.A(value.split(','));
|
||||
const value = '1,2,3';
|
||||
const filters = Ember.A(value.split(','));
|
||||
filters.push('4');
|
||||
filters.sort();
|
||||
|
||||
@@ -23,7 +23,7 @@ const Person = Ember.Object.extend({
|
||||
return this.get('fullName');
|
||||
},
|
||||
set(key, value) {
|
||||
let [first, last] = value.split(' ');
|
||||
const [first, last] = value.split(' ');
|
||||
this.set('firstName', first);
|
||||
this.set('lastName', last);
|
||||
return value;
|
||||
@@ -38,7 +38,7 @@ const Person = Ember.Object.extend({
|
||||
|
||||
fullNameSetOnly: Ember.computed<string>('firstName', 'lastName', {
|
||||
set(key, value) {
|
||||
let [first, last] = value.split(' ');
|
||||
const [first, last] = value.split(' ');
|
||||
this.set('firstName', first);
|
||||
this.set('lastName', last);
|
||||
return value;
|
||||
|
||||
@@ -12,7 +12,7 @@ const {
|
||||
* @ember/debug tests
|
||||
*/
|
||||
runInDebug(); // $ExpectError
|
||||
let x = runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void
|
||||
runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void
|
||||
|
||||
// Log a warning if we have more than 3 tomsters
|
||||
const tomsterCount = 2;
|
||||
|
||||
@@ -9,7 +9,7 @@ class ES6Class extends Ember.Object {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
let testObject = null;
|
||||
const testObject = null;
|
||||
|
||||
if (ExtendClass.detectInstance(testObject)) {
|
||||
assertType<string>(testObject.foo);
|
||||
|
||||
@@ -9,7 +9,7 @@ class ES6Class extends Ember.Object {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
let TestClass = Ember.Object;
|
||||
const TestClass = Ember.Object;
|
||||
|
||||
if (ExtendClass.detect(TestClass)) {
|
||||
assertType<string>(TestClass.create().foo);
|
||||
|
||||
@@ -136,7 +136,7 @@ people2.isAny('isHappy', 'true');
|
||||
people2.isAny('isHappy');
|
||||
|
||||
// Examples taken from http://emberjs.com/api/classes/Em.RSVP.Promise.html
|
||||
const promise = new Ember.RSVP.Promise<string>((resolve: Function, reject: Function) => {
|
||||
const promise = new Ember.RSVP.Promise<string>((resolve: (...args: any[]) => any, reject: (...args: any[]) => any) => {
|
||||
// on success
|
||||
resolve('ok!');
|
||||
|
||||
|
||||
@@ -21,6 +21,6 @@ engineInstance.lookup('route:basic');
|
||||
|
||||
engineInstance.boot();
|
||||
|
||||
(async function() {
|
||||
(async () => {
|
||||
await engineInstance.boot();
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
import { assertType } from "./lib/assert";
|
||||
|
||||
let BaseEngine = Ember.Engine.extend({
|
||||
const BaseEngine = Ember.Engine.extend({
|
||||
modulePrefix: 'my-engine'
|
||||
});
|
||||
|
||||
@@ -19,14 +19,14 @@ BaseEngine.instanceInitializer({
|
||||
}
|
||||
});
|
||||
|
||||
let Engine1 = BaseEngine.create({
|
||||
const Engine1 = BaseEngine.create({
|
||||
rootElement: '#engine-one',
|
||||
customEvents: {
|
||||
paste: 'paste'
|
||||
}
|
||||
});
|
||||
|
||||
let Engine2 = BaseEngine.create({
|
||||
const Engine2 = BaseEngine.create({
|
||||
rootElement: '#engine-two',
|
||||
customEvents: {
|
||||
mouseenter: null,
|
||||
@@ -34,8 +34,8 @@ let Engine2 = BaseEngine.create({
|
||||
}
|
||||
});
|
||||
|
||||
let Engine3 = BaseEngine.create();
|
||||
const Engine3 = BaseEngine.create();
|
||||
|
||||
let Engine3Instance1 = Engine3.buildInstance();
|
||||
const Engine3Instance1 = Engine3.buildInstance();
|
||||
|
||||
let Engine3Instance2 = Engine3.buildInstance({ foo: 'bar' });
|
||||
const Engine3Instance2 = Engine3.buildInstance({ foo: 'bar' });
|
||||
|
||||
+10
-10
@@ -1,42 +1,42 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
function testOn() {
|
||||
let Job = Ember.Object.extend({
|
||||
logCompleted: Ember.on('completed', function() {
|
||||
const Job = Ember.Object.extend({
|
||||
logCompleted: Ember.on('completed', () => {
|
||||
console.log('Job completed!');
|
||||
})
|
||||
});
|
||||
|
||||
let job = Job.create();
|
||||
const job = Job.create();
|
||||
|
||||
Ember.sendEvent(job, 'completed'); // Logs 'Job completed!'
|
||||
}
|
||||
|
||||
function testEvented() {
|
||||
let Person = Ember.Object.extend(Ember.Evented, {
|
||||
const Person = Ember.Object.extend(Ember.Evented, {
|
||||
greet() {
|
||||
this.trigger('greet');
|
||||
}
|
||||
});
|
||||
|
||||
let person = Person.create();
|
||||
const person = Person.create();
|
||||
|
||||
person.on('greet', function() {
|
||||
person.on('greet', () => {
|
||||
console.log('Our person has greeted');
|
||||
});
|
||||
|
||||
person.on('greet', function() {
|
||||
person.on('greet', () => {
|
||||
console.log('Our person has greeted');
|
||||
}).one('greet', function() {
|
||||
}).one('greet', () => {
|
||||
console.log('Offer one-time special');
|
||||
}).off('event', {}, function() {});
|
||||
}).off('event', {}, () => {});
|
||||
|
||||
person.greet();
|
||||
}
|
||||
|
||||
function testObserver() {
|
||||
Ember.Object.extend({
|
||||
valueObserver: Ember.observer('value', function() {
|
||||
valueObserver: Ember.observer('value', () => {
|
||||
// Executes whenever the "value" property changes
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
declare global {
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface Function extends Ember.FunctionPrototypeExtensions {}
|
||||
}
|
||||
|
||||
Ember.Object.extend({
|
||||
foo: '',
|
||||
|
||||
// tslint:disable-next-line:only-arrow-functions
|
||||
arr: function() {
|
||||
return [];
|
||||
}.property(),
|
||||
@@ -15,7 +17,9 @@ Ember.Object.extend({
|
||||
return this.get('foo');
|
||||
}.property('foo', 'bar.@each.baz'),
|
||||
|
||||
// tslint:disable-next-line:only-arrow-functions
|
||||
observer: function() {}.observes('foo', 'bar'),
|
||||
|
||||
// tslint:disable-next-line:only-arrow-functions
|
||||
on: function() {}.on('foo', 'bar'),
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const FormatCurrencyHelper = Ember.Helper.helper(function(params, hash: { currency: string }) {
|
||||
let cents = params[0];
|
||||
let currency = hash.currency;
|
||||
const FormatCurrencyHelper = Ember.Helper.helper((params, hash: { currency: string }) => {
|
||||
const cents = params[0];
|
||||
const currency = hash.currency;
|
||||
return `${currency}${cents * 0.01}`;
|
||||
});
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ class Foo extends Ember.Object.extend({
|
||||
}) {
|
||||
b = 5;
|
||||
baz() {
|
||||
let y = this.b; // $ExpectType number
|
||||
let z = this.a; // $ExpectType ComputedProperty<string, string>
|
||||
const y = this.b; // $ExpectType number
|
||||
const z = this.a; // $ExpectType ComputedProperty<string, string>
|
||||
this.b = 10;
|
||||
this.get('b').toFixed(4); // $ExpectType string
|
||||
this.set('a', 'abc').split(','); // $ExpectType string[]
|
||||
@@ -54,10 +54,10 @@ export class Foo2 extends Ember.Object {
|
||||
name!: string;
|
||||
|
||||
changeName(name: string) {
|
||||
let a: string = this.set('name', name);
|
||||
let b: number = this.set('name', name); // $ExpectError
|
||||
let x: string = Ember.set(this, 'name', name);
|
||||
let y: number = Ember.set(this, 'name', name); // $ExpectError
|
||||
const a: string = this.set('name', name);
|
||||
const b: number = this.set('name', name); // $ExpectError
|
||||
const x: string = Ember.set(this, 'name', name);
|
||||
const y: number = Ember.set(this, 'name', name); // $ExpectError
|
||||
this.setProperties({
|
||||
name
|
||||
});
|
||||
|
||||
@@ -21,13 +21,13 @@ class Example1 extends Ember.Object.extend({
|
||||
fullName!: Ember.ComputedProperty<string>;
|
||||
}
|
||||
|
||||
let unwrappedGetters1: UnwrapComputedPropertyGetters<Example1> = {} as any;
|
||||
const unwrappedGetters1: UnwrapComputedPropertyGetters<Example1> = {} as any;
|
||||
unwrappedGetters1.firstName; // $ExpectType string
|
||||
unwrappedGetters1.lastName; // $ExpectType string
|
||||
unwrappedGetters1.fullName; // $ExpectType string
|
||||
unwrappedGetters1.allNames; // $ExpectType string[]
|
||||
|
||||
let unwrappedSetters1: UnwrapComputedPropertySetters<Example1> = {} as any;
|
||||
const unwrappedSetters1: UnwrapComputedPropertySetters<Example1> = {} as any;
|
||||
unwrappedSetters1.firstName; // $ExpectType string
|
||||
unwrappedSetters1.lastName; // $ExpectType string
|
||||
unwrappedSetters1.fullName; // $ExpectType string
|
||||
@@ -55,17 +55,15 @@ class Example2 extends Ember.Object.extend({
|
||||
this.get('lastName').split(','); // $ExpectType string[]
|
||||
}
|
||||
}
|
||||
let ex2 = new Example2();
|
||||
const ex2 = new Example2();
|
||||
|
||||
let unwrappedGetters2: UnwrapComputedPropertyGetters<
|
||||
typeof ex2
|
||||
> = (ex2 as any) as UnwrapComputedPropertyGetters<typeof ex2>;
|
||||
const unwrappedGetters2: UnwrapComputedPropertyGetters<typeof ex2> = (ex2 as any) as UnwrapComputedPropertyGetters<typeof ex2>;
|
||||
assertType<string>(unwrappedGetters2.firstName); // $ExpectType string
|
||||
assertType<string>(unwrappedGetters2.lastName); // $ExpectType string
|
||||
assertType<string>(unwrappedGetters2.fullName); // $ExpectType string
|
||||
assertType<string[]>(unwrappedGetters2.allNames); // $ExpectType string[]
|
||||
|
||||
let unwrappedSetters2: UnwrapComputedPropertySetters<typeof ex2> = null as any;
|
||||
const unwrappedSetters2: UnwrapComputedPropertySetters<typeof ex2> = null as any;
|
||||
assertType<string>(unwrappedSetters2.firstName); // $ExpectType string
|
||||
assertType<string>(unwrappedSetters2.lastName); // $ExpectType string
|
||||
assertType<string>(unwrappedSetters2.fullName); // $ExpectType string
|
||||
|
||||
@@ -12,7 +12,7 @@ const Person = Ember.Object.extend({
|
||||
assertType<Person>(Person.reopen());
|
||||
|
||||
assertType<string>(Person.create().name);
|
||||
assertType<void>(Person.create().sayHello());
|
||||
Person.create().sayHello(); // $ExpectType void
|
||||
|
||||
const Person2 = Person.reopenClass({
|
||||
species: 'Homo sapiens',
|
||||
@@ -23,16 +23,16 @@ const Person2 = Person.reopenClass({
|
||||
});
|
||||
|
||||
assertType<string>(Person2.create().name);
|
||||
assertType<void>(Person2.create().sayHello());
|
||||
Person2.create().sayHello(); // $ExpectType void
|
||||
assertType<string>(Person2.species);
|
||||
|
||||
let tom = Person2.create({
|
||||
const tom = Person2.create({
|
||||
name: 'Tom Dale'
|
||||
});
|
||||
|
||||
let badTom = Person2.create({ name: 99 }); // $ExpectError
|
||||
const badTom = Person2.create({ name: 99 }); // $ExpectError
|
||||
|
||||
let yehuda = Person2.createPerson('Yehuda Katz');
|
||||
const yehuda = Person2.createPerson('Yehuda Katz');
|
||||
|
||||
tom.sayHello(); // "Hello. My name is Tom Dale"
|
||||
yehuda.sayHello(); // "Hello. My name is Yehuda Katz"
|
||||
|
||||
@@ -3,7 +3,9 @@ import Object from '@ember/object';
|
||||
import Array from '@ember/array';
|
||||
import Ember from 'ember'; // currently needed for Transition
|
||||
|
||||
interface Post extends Ember.Object {}
|
||||
interface Post extends Ember.Object {
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface Posts extends Array<Post> {}
|
||||
|
||||
|
||||
+21
-21
@@ -6,7 +6,7 @@ import { assertType } from "./lib/assert";
|
||||
assertType<string[]>(Ember.run.queues);
|
||||
|
||||
function testRun() {
|
||||
let r = run(function() {
|
||||
const r = run(() => {
|
||||
// code to be executed within a RunLoop
|
||||
return 123;
|
||||
});
|
||||
@@ -38,43 +38,43 @@ function testBind() {
|
||||
function testCancel() {
|
||||
const myContext = {};
|
||||
|
||||
let runNext = run.next(myContext, function() {
|
||||
const runNext = run.next(myContext, () => {
|
||||
// will not be executed
|
||||
});
|
||||
|
||||
run.cancel(runNext);
|
||||
|
||||
let runLater = run.later(myContext, function() {
|
||||
const runLater = run.later(myContext, () => {
|
||||
// will not be executed
|
||||
}, 500);
|
||||
|
||||
run.cancel(runLater);
|
||||
|
||||
let runScheduleOnce = run.scheduleOnce('afterRender', myContext, function() {
|
||||
const runScheduleOnce = run.scheduleOnce('afterRender', myContext, () => {
|
||||
// will not be executed
|
||||
});
|
||||
|
||||
run.cancel(runScheduleOnce);
|
||||
|
||||
let runOnce = run.once(myContext, function() {
|
||||
const runOnce = run.once(myContext, () => {
|
||||
// will not be executed
|
||||
});
|
||||
|
||||
run.cancel(runOnce);
|
||||
|
||||
let throttle = run.throttle(myContext, function() {
|
||||
const throttle = run.throttle(myContext, () => {
|
||||
// will not be executed
|
||||
}, 1, false);
|
||||
|
||||
run.cancel(throttle);
|
||||
|
||||
let debounce = run.debounce(myContext, function() {
|
||||
const debounce = run.debounce(myContext, () => {
|
||||
// will not be executed
|
||||
}, 1);
|
||||
|
||||
run.cancel(debounce);
|
||||
|
||||
let debounceImmediate = run.debounce(myContext, function() {
|
||||
const debounceImmediate = run.debounce(myContext, () => {
|
||||
// will be executed since we passed in true (immediate)
|
||||
}, 100, true);
|
||||
|
||||
@@ -86,7 +86,7 @@ function testDebounce() {
|
||||
function runIt() {
|
||||
}
|
||||
|
||||
let myContext = { name: 'debounce' };
|
||||
const myContext = { name: 'debounce' };
|
||||
|
||||
run.debounce(runIt, 150);
|
||||
run.debounce(myContext, runIt, 150);
|
||||
@@ -112,20 +112,20 @@ function testBegin() {
|
||||
}
|
||||
|
||||
function testJoin() {
|
||||
run.join(function() {
|
||||
run.join(() => {
|
||||
// creates a new run-loop
|
||||
});
|
||||
|
||||
run(function() {
|
||||
run(() => {
|
||||
// creates a new run-loop
|
||||
run.join(function() {
|
||||
run.join(() => {
|
||||
// joins with the existing run-loop, and queues for invocation on
|
||||
// the existing run-loops action queue.
|
||||
});
|
||||
});
|
||||
|
||||
new RSVP.Promise(function(resolve) {
|
||||
Ember.run.later(function() {
|
||||
new RSVP.Promise((resolve) => {
|
||||
Ember.run.later(() => {
|
||||
resolve({ msg: 'Hold Your Horses' });
|
||||
}, 3000);
|
||||
});
|
||||
@@ -133,14 +133,14 @@ function testJoin() {
|
||||
|
||||
function testLater() {
|
||||
const myContext = {};
|
||||
run.later(myContext, function() {
|
||||
run.later(myContext, () => {
|
||||
// code here will execute within a RunLoop in about 500ms with this == myContext
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function testNext() {
|
||||
const myContext = {};
|
||||
run.next(myContext, function() {
|
||||
run.next(myContext, () => {
|
||||
// code to be executed in the next run loop,
|
||||
// which will be scheduled after the current one
|
||||
});
|
||||
@@ -160,12 +160,12 @@ function testOnce() {
|
||||
function testSchedule() {
|
||||
Ember.Component.extend({
|
||||
init() {
|
||||
run.schedule('sync', this, function() {
|
||||
run.schedule('sync', this, () => {
|
||||
// this will be executed in the first RunLoop queue, when bindings are synced
|
||||
console.log('scheduled on sync queue');
|
||||
});
|
||||
|
||||
run.schedule('actions', this, function() {
|
||||
run.schedule('actions', this, () => {
|
||||
// this will be executed in the 'actions' queue, after bindings have synced.
|
||||
console.log('scheduled on actions queue');
|
||||
});
|
||||
@@ -183,12 +183,12 @@ function testScheduleOnce() {
|
||||
}
|
||||
|
||||
const myContext = {};
|
||||
run(function() {
|
||||
run(() => {
|
||||
run.scheduleOnce('afterRender', myContext, sayHi);
|
||||
run.scheduleOnce('afterRender', myContext, sayHi);
|
||||
// sayHi will only be executed once, in the afterRender queue of the RunLoop
|
||||
});
|
||||
run.scheduleOnce('actions', myContext, function() {
|
||||
run.scheduleOnce('actions', myContext, () => {
|
||||
console.log('Closure');
|
||||
});
|
||||
}
|
||||
@@ -197,7 +197,7 @@ function testThrottle() {
|
||||
function runIt() {
|
||||
}
|
||||
|
||||
let myContext = { name: 'throttle' };
|
||||
const myContext = { name: 'throttle' };
|
||||
|
||||
run.throttle(runIt, 150);
|
||||
run.throttle(myContext, runIt, 150);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
declare global {
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface String extends Ember.StringPrototypeExtensions {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
let pending = 0;
|
||||
const pending = 0;
|
||||
Ember.Test.registerWaiter(() => pending !== 0);
|
||||
|
||||
declare const MyDb: {
|
||||
@@ -8,15 +8,15 @@ declare const MyDb: {
|
||||
};
|
||||
Ember.Test.registerWaiter(MyDb, MyDb.hasPendingTransactions);
|
||||
|
||||
Ember.Test.promise(function(resolve) {
|
||||
Ember.Test.promise((resolve) => {
|
||||
window.setTimeout(resolve, 500);
|
||||
});
|
||||
|
||||
Ember.Test.registerHelper('boot', function(app) {
|
||||
Ember.Test.registerHelper('boot', (app) => {
|
||||
Ember.run(app, app.advanceReadiness);
|
||||
});
|
||||
|
||||
Ember.Test.registerAsyncHelper('boot', function(app) {
|
||||
Ember.Test.registerAsyncHelper('boot', (app) => {
|
||||
Ember.run(app, app.advanceReadiness);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Ember.Controller.extend({
|
||||
actions: {
|
||||
login() {
|
||||
// Log the user in, then reattempt previous transition if it exists.
|
||||
let previousTransition = this.get('previousTransition');
|
||||
const previousTransition = this.get('previousTransition');
|
||||
if (previousTransition) {
|
||||
this.set('previousTransition', null);
|
||||
previousTransition.retry();
|
||||
|
||||
@@ -53,7 +53,7 @@ function testAssign() {
|
||||
}
|
||||
|
||||
function testOnError() {
|
||||
Ember.onerror = function(error) {
|
||||
Ember.onerror = (error) => {
|
||||
Ember.$.post('/report-error', {
|
||||
stack: error.stack,
|
||||
otherInformation: 'whatever app state you want to provide'
|
||||
@@ -66,7 +66,7 @@ function testDeprecateFunc() {
|
||||
return '';
|
||||
}
|
||||
|
||||
let oldMethod = Ember.deprecateFunc('Please use the new method', { id: 'deprecated.id', until: '6.0' }, newMethod);
|
||||
const oldMethod = Ember.deprecateFunc('Please use the new method', { id: 'deprecated.id', until: '6.0' }, newMethod);
|
||||
assertType<string>(newMethod('first', 123));
|
||||
assertType<string>(oldMethod('first', 123));
|
||||
}
|
||||
@@ -119,9 +119,8 @@ function testTryInvoke() {
|
||||
Ember.tryInvoke(new Foo(), 'add', ['4', 3]); // $ExpectType undefined
|
||||
}
|
||||
|
||||
(function() {
|
||||
(() => {
|
||||
/** typeOf */
|
||||
// TODO: more specific return type in @types/ember https://github.com/typed-ember/ember-cli-typescript/issues/259
|
||||
Ember.typeOf(); // $ExpectType "undefined"
|
||||
Ember.typeOf(null); // $ExpectType "null"
|
||||
Ember.typeOf(undefined); // $ExpectType "undefined"
|
||||
@@ -145,7 +144,7 @@ function testTryInvoke() {
|
||||
Ember.typeOf((new Date()) as RegExp | Date); // "regexp" | "date"
|
||||
})();
|
||||
|
||||
(function() { /* assign */
|
||||
(() => { /* assign */
|
||||
Ember.assign({}, { a: 'b'});
|
||||
Ember.assign({}, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.assign({ a: 6 }, { a: 'b'}).a; // $ExpectType string
|
||||
@@ -156,12 +155,12 @@ function testTryInvoke() {
|
||||
Ember.assign({ a: 'hello' }, { b: 6 }, { a: true }).a; // $ExpectType boolean
|
||||
Ember.assign({ a: 'hello' }, '', { a: true }).a; // $ExpectError
|
||||
Ember.assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }, { a: true }).d; // $ExpectType string[]
|
||||
}());
|
||||
})();
|
||||
|
||||
(function() { /* merge */
|
||||
(() => { /* merge */
|
||||
Ember.merge({}, { a: 'b'});
|
||||
Ember.merge({}, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.merge({ a: 6 }, { a: 'b'}).a; // $ExpectType string
|
||||
Ember.merge({ a: 6 }, {}).a; // $ExpectType number
|
||||
Ember.merge({ b: 6 }, {}).a; // $ExpectError
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1,28 +1,12 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// Heavy use of Function type in this older package.
|
||||
"ban-types": false,
|
||||
"jsdoc-format": false,
|
||||
"no-misused-new": false,
|
||||
|
||||
// these are disabled because of rfc176 module exports
|
||||
"strict-export-declare-modifiers": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-self-import": false,
|
||||
|
||||
// We use interfaces in a number of places to express things (including
|
||||
// mixins in particular, but also including extending a global
|
||||
// interface) which TS currently can't express correctly.
|
||||
"no-empty-interface": false,
|
||||
|
||||
"no-duplicate-imports": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"prefer-const": false,
|
||||
"no-void-expression": false,
|
||||
"only-arrow-functions": false,
|
||||
"no-submodule-imports": false,
|
||||
|
||||
// false positives
|
||||
"unified-signatures": false
|
||||
|
||||
@@ -74,6 +74,7 @@ outVec2 = vec2.cross(outVec3, vec2A, vec2B);
|
||||
outVec2 = vec2.lerp(outVec2, vec2A, vec2B, 0.5);
|
||||
outVec2 = vec2.random(outVec2);
|
||||
outVec2 = vec2.random(outVec2, 5.0);
|
||||
outVec2 = vec2.rotate(outVec2, vec2A, vec2B, Math.PI * 0.5);
|
||||
outVec2 = vec2.transformMat2(outVec2, vec2A, mat2A);
|
||||
outVec2 = vec2.transformMat2d(outVec2, vec2A, mat2dA);
|
||||
outVec2 = vec2.transformMat3(outVec2, vec2A, mat3A);
|
||||
|
||||
Vendored
+16
-5
@@ -374,6 +374,17 @@ declare module 'gl-matrix' {
|
||||
*/
|
||||
public static random(out: vec2, scale: number): vec2;
|
||||
|
||||
/**
|
||||
* Rotate a 2D vector
|
||||
*
|
||||
* @param out The receiving vec2
|
||||
* @param a The vec2 point to rotate
|
||||
* @param b The origin of the rotation
|
||||
* @param c The angle of rotation
|
||||
* @returns out
|
||||
*/
|
||||
public static rotate(out: vec2, a: vec2, b: vec2, c: number): vec2;
|
||||
|
||||
/**
|
||||
* Transforms the vec2 with a mat2
|
||||
*
|
||||
@@ -1959,13 +1970,13 @@ declare module 'gl-matrix' {
|
||||
* @returns out
|
||||
*/
|
||||
public static transpose(out: mat3, a: mat3): mat3;
|
||||
|
||||
|
||||
/**
|
||||
* Generates a 2D projection matrix with the given bounds
|
||||
*
|
||||
* @param out the receiving matrix
|
||||
* @param width width of your gl context
|
||||
* @param height height of gl context
|
||||
* @param height height of gl context
|
||||
* @returns out
|
||||
*/
|
||||
public static projection(out: mat3, width: number, height: number): mat3;
|
||||
@@ -2510,9 +2521,9 @@ declare module 'gl-matrix' {
|
||||
public static getTranslation(out: vec3, mat: mat4): vec3;
|
||||
|
||||
/**
|
||||
* Returns the scaling factor component of a transformation matrix.
|
||||
* If a matrix is built with fromRotationTranslationScale with a
|
||||
* normalized Quaternion parameter, the returned vector will be
|
||||
* Returns the scaling factor component of a transformation matrix.
|
||||
* If a matrix is built with fromRotationTranslationScale with a
|
||||
* normalized Quaternion parameter, the returned vector will be
|
||||
* the same as the scaling vector originally supplied.
|
||||
* @param {vec3} out Vector to receive scaling factor component
|
||||
* @param {mat4} mat Matrix to be decomposed (input)
|
||||
|
||||
@@ -19,7 +19,7 @@ declare namespace GoogleAppsScript {
|
||||
deleteProperty(key: string): Properties;
|
||||
getKeys(): string[];
|
||||
getProperties(): Object;
|
||||
getProperty(key: string): string;
|
||||
getProperty(key: string): string | null;
|
||||
setProperties(properties: Object): Properties;
|
||||
setProperties(properties: Object, deleteAllOthers: boolean): Properties;
|
||||
setProperty(key: string, value: string): Properties;
|
||||
@@ -56,7 +56,7 @@ declare namespace GoogleAppsScript {
|
||||
deleteProperty(key: string): ScriptProperties;
|
||||
getKeys(): string[];
|
||||
getProperties(): Object;
|
||||
getProperty(key: string): string;
|
||||
getProperty(key: string): string | null;
|
||||
setProperties(properties: Object): ScriptProperties;
|
||||
setProperties(properties: Object, deleteAllOthers: boolean): ScriptProperties;
|
||||
setProperty(key: string, value: string): ScriptProperties;
|
||||
@@ -73,7 +73,7 @@ declare namespace GoogleAppsScript {
|
||||
deleteProperty(key: string): UserProperties;
|
||||
getKeys(): string[];
|
||||
getProperties(): Object;
|
||||
getProperty(key: string): string;
|
||||
getProperty(key: string): string | null;
|
||||
setProperties(properties: Object): UserProperties;
|
||||
setProperties(properties: Object, deleteAllOthers: boolean): UserProperties;
|
||||
setProperty(key: string, value: string): UserProperties;
|
||||
|
||||
@@ -258,3 +258,5 @@ got('todomvc', {
|
||||
got(new url.URL('http://todomvc.com'));
|
||||
|
||||
got(url.parse('http://todomvc.com'));
|
||||
|
||||
got('https://todomvc.com', { rejectUnauthorized: false });
|
||||
|
||||
Vendored
+2
-2
@@ -75,7 +75,7 @@ declare const got: got.GotFn &
|
||||
CancelError: typeof CancelError;
|
||||
};
|
||||
|
||||
interface InternalRequestOptions extends http.RequestOptions {
|
||||
interface InternalRequestOptions extends https.RequestOptions {
|
||||
// Redeclare options with `any` type for allow specify types incompatible with http.RequestOptions.
|
||||
timeout?: any;
|
||||
agent?: any;
|
||||
@@ -93,7 +93,7 @@ declare namespace got {
|
||||
|
||||
type GotStreamFn = (url: GotUrl, options?: GotOptions<string | null>) => GotEmitter & nodeStream.Duplex;
|
||||
|
||||
type GotUrl = string | http.RequestOptions | Url | URL;
|
||||
type GotUrl = string | https.RequestOptions | Url | URL;
|
||||
|
||||
interface GotBodyOptions<E extends string | null> extends GotOptions<E> {
|
||||
body?: string | Buffer | nodeStream.Readable;
|
||||
|
||||
Vendored
+7
-1
@@ -2,7 +2,8 @@
|
||||
// Project: http://www.highcharts.com/
|
||||
|
||||
// Definitions by: David Deutsch <http://github.com/DavidKDeutsch>
|
||||
// Definitions by: Dave Baumann <https://github.com/route2Dev>
|
||||
// Dave Baumann <https://github.com/route2Dev>
|
||||
// Richard Ison <https://github.com/richardison>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as Highcharts from "highcharts";
|
||||
@@ -31,11 +32,16 @@ declare namespace Highstock {
|
||||
yAxis?: Highcharts.AxisOptions;
|
||||
}
|
||||
|
||||
interface RangeSelectorButtonEvent {
|
||||
click?(event: Event): void;
|
||||
}
|
||||
|
||||
interface RangeSelectorButton {
|
||||
type: string; // Defines the timespan, can be one of 'millisecond', 'second', 'minute', 'day', 'week', 'month', 'ytd' (year to date), 'year' and 'all'.
|
||||
count?: number;
|
||||
text: string;
|
||||
dataGrouping?: any; // not sure how this works
|
||||
events?: RangeSelectorButtonEvent;
|
||||
}
|
||||
|
||||
interface RangeSelectorOptions {
|
||||
|
||||
Vendored
+349
-2
@@ -59,6 +59,8 @@ declare namespace Highcharts {
|
||||
value: any;
|
||||
isFirst: number;
|
||||
isLast: number;
|
||||
chart: ChartObject;
|
||||
axis: AxisObject;
|
||||
}
|
||||
|
||||
interface AxisLabels {
|
||||
@@ -103,7 +105,8 @@ declare namespace Highcharts {
|
||||
format?: string;
|
||||
/**
|
||||
* Callback JavaScript function to format the label. The value is given by this.value. Additional properties for
|
||||
* this are axis, chart, isFirst and isLast.
|
||||
* this are axis, chart, isFirst and isLast. The value of the default label formatter can be retrieved by calling
|
||||
* this.axis.defaultLabelFormatter.call(this) within the function.
|
||||
* @default function() {return this.value;}
|
||||
*/
|
||||
formatter?(this: AxisLabelFormatterOptions): string;
|
||||
@@ -376,6 +379,316 @@ declare namespace Highcharts {
|
||||
zIndex?: number;
|
||||
}
|
||||
|
||||
interface AnnotationsPoint {
|
||||
/**
|
||||
* The x position of the point. Units can be either in axis or chart pixel coordinates.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* This number defines which xAxis the point is connected to.
|
||||
* It refers to either the axis id or the index of the axis in the xAxis array.
|
||||
* If the option is not configured or the axis is not found the point's x coordinate refers to the chart pixels.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
xAxis?: number | string;
|
||||
/**
|
||||
* The y position of the point. Units can be either in axis or chart pixel coordinates.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* This number defines which yAxis the point is connected to.
|
||||
* It refers to either the axis id or the index of the axis in the yAxis array.
|
||||
* If the option is not configured or the axis is not found the point's y coordinate refers to the chart pixels.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
yAxis?: number;
|
||||
}
|
||||
|
||||
interface AnnotationsLabelOptions {
|
||||
/**
|
||||
* The alignment of the annotation's label. If right, the right side of the label should be touching the point.
|
||||
* @default "center"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
align?: "left" | "center" | "right";
|
||||
/**
|
||||
* The alignment of the annotation's label. If right, the right side of the label should be touching the point.
|
||||
* @default false
|
||||
* @since 6.0.0
|
||||
*/
|
||||
allowOverlap?: boolean;
|
||||
/**
|
||||
* The background color or gradient for the annotation's label.
|
||||
* @default rgba(0, 0, 0, 0.75)
|
||||
* @since 6.0.0
|
||||
*/
|
||||
backgroundColor?: string | Gradient;
|
||||
/**
|
||||
* The border color for the annotation's label.
|
||||
* @default "black"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
borderColor?: string | Gradient;
|
||||
/**
|
||||
* The border radius in pixels for the annotation's label.
|
||||
* @default 1
|
||||
* @since 6.0.0
|
||||
*/
|
||||
borderRadius?: number;
|
||||
/**
|
||||
* The border width in pixels for the annotation's label.
|
||||
* @default 1
|
||||
* @since 6.0.0
|
||||
*/
|
||||
borderWidth?: number;
|
||||
/**
|
||||
* Whether to hide the annotation's label that is outside the plot area.
|
||||
* @default false
|
||||
* @since 6.0.0
|
||||
*/
|
||||
crop?: boolean;
|
||||
/**
|
||||
* The label's pixel distance from the point.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
distance?: number;
|
||||
/**
|
||||
* A format string for the data label.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
format?: string;
|
||||
/**
|
||||
* Callback JavaScript function to format the annotation's label.
|
||||
* Note that if a format or text are defined, the format or text take precedence and the formatter is ignored.
|
||||
* This refers to a point object.
|
||||
* @default function () { return defined(this.y) ? this.y : 'Annotation label'; }
|
||||
* @since 6.0.0
|
||||
*/
|
||||
formatter?: Function;
|
||||
/**
|
||||
* How to handle the annotation's label that flow outside the plot area.
|
||||
* The justify option aligns the label inside the plot area.
|
||||
* @default "justify
|
||||
* @since 6.0.0
|
||||
*/
|
||||
overflow?: "justify" | "none";
|
||||
/**
|
||||
* When either the borderWidth or the backgroundColor is set, this is the padding within the box.
|
||||
* @default 5
|
||||
* @since 6.0.0
|
||||
*/
|
||||
padding?: number;
|
||||
/**
|
||||
* The shadow of the box. The shadow can be an object configuration containing color, offsetX, offsetY, opacity and width.
|
||||
* @default false
|
||||
* @since 6.0.0
|
||||
*/
|
||||
shadow?:
|
||||
| boolean
|
||||
| {
|
||||
color?: string | Gradient;
|
||||
offsetX?: number;
|
||||
offsetY?: number;
|
||||
opacity?: number;
|
||||
width?: number;
|
||||
};
|
||||
/**
|
||||
* The name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object.
|
||||
* @default "callout"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
shape?: "connector" | "rect" | "circle" | "diamond" | "triangle";
|
||||
/**
|
||||
* Styles for the annotation's label.
|
||||
* @default "callout"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
style?: {
|
||||
/**
|
||||
* @default "contrast"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
color?: string;
|
||||
fontFamily?: string;
|
||||
/**
|
||||
* @default "11px"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
fontSize?: string;
|
||||
/**
|
||||
* @default "normal"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
fontWeight?: string;
|
||||
textAlign?: string;
|
||||
};
|
||||
/**
|
||||
* Alias for the format option.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
text?: string;
|
||||
/**
|
||||
* Whether to use HTML to render the annotation's label.
|
||||
* @default false
|
||||
* @since 6.0.0
|
||||
*/
|
||||
useHTML?: boolean;
|
||||
/**
|
||||
* The vertical alignment of the annotation's label.
|
||||
* @default "bottom"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
verticalAlign?: "bottom" | "middle" | "top";
|
||||
/**
|
||||
* The x position offset of the label relative to the point.
|
||||
* Note that if a distance is defined, the distance takes precedence over x and y options.
|
||||
* @default 0
|
||||
* @since 6.0.0
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* The y position offset of the label relative to the point.
|
||||
* Note that if a distance is defined, the distance takes precedence over x and y options.
|
||||
* @default -16
|
||||
* @since 6.0.0
|
||||
*/
|
||||
y?: number;
|
||||
}
|
||||
|
||||
interface AnnotationsLabel extends AnnotationsLabelOptions {
|
||||
/**
|
||||
* This option defines the point to which the label will be connected.
|
||||
* It can be either the point which exists in the series - it is referenced by the point's id
|
||||
* - or a new point with defined x, y properties and optionally axes.
|
||||
* @since 6.0.0
|
||||
*/
|
||||
point?: string | AnnotationsPoint;
|
||||
}
|
||||
|
||||
interface AnnotationsShapeOptions {
|
||||
/**
|
||||
* The color of the shape's fill.
|
||||
* @default rgba(0, 0, 0, 0.75)
|
||||
* @since 6.0.0
|
||||
*/
|
||||
fill: string;
|
||||
/**
|
||||
* The height of the shape.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
height: number;
|
||||
/**
|
||||
* The radius of the shape.
|
||||
* @default 0
|
||||
* @since 6.0.0
|
||||
*/
|
||||
r: number;
|
||||
/**
|
||||
* The color of the shape's stroke.
|
||||
* @default rgba(0, 0, 0, 0.75)
|
||||
* @since 6.0.0
|
||||
*/
|
||||
stroke: string;
|
||||
/**
|
||||
* The pixel stroke width of the shape.
|
||||
* @default 1
|
||||
* @since 6.0.0
|
||||
*/
|
||||
strokeWidth: number;
|
||||
/**
|
||||
* The type of the shape, e.g. circle or rectangle.
|
||||
* @default "rect"
|
||||
* @since 6.0.0
|
||||
*/
|
||||
type: "circle" | "path" | "rect";
|
||||
/**
|
||||
* The width of the shape.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
width: number;
|
||||
}
|
||||
|
||||
interface AnnotationsShape extends AnnotationsShapeOptions {
|
||||
/**
|
||||
* Id of the marker which will be drawn at the final vertex of the path. Custom markers can be defined in defs property.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
markerEnd: string;
|
||||
/**
|
||||
* Id of the marker which will be drawn at the final vertex of the path. Custom markers can be defined in defs property.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
markerStart: string;
|
||||
/**
|
||||
* This option defines the point to which the shape will be connected.
|
||||
* It can be either the point which exists in the series - it is referenced by the point's id
|
||||
* - or a new point with defined x, y properties and optionally axes.
|
||||
* @since 6.0.0
|
||||
*/
|
||||
point?: string | AnnotationsPoint;
|
||||
/**
|
||||
* An array of points for the shape. This option is available for shapes which can use multiple points such as path.
|
||||
* A point can be either a point object or a point's id.
|
||||
* @default undefined
|
||||
* @since 6.0.0
|
||||
*/
|
||||
points?: Array<string | AnnotationsPoint>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for configuring annotations, for example labels, arrows or shapes. Annotations can be tied to points,
|
||||
* axis coordinates or chart pixel coordinates.
|
||||
*/
|
||||
interface AnnotationsOptions {
|
||||
/**
|
||||
* Options for annotation's labels. Each label inherits options from the labelOptions object.
|
||||
* An option from the labelOptions can be overwritten by config for a specific label.
|
||||
* @since 6.0.0
|
||||
*/
|
||||
labelOptions?: AnnotationsLabelOptions;
|
||||
/**
|
||||
* An array of labels for the annotation. For options that apply to multiple labels, they can be added to the labelOptions.
|
||||
* @since 6.0.0
|
||||
*/
|
||||
labels?: AnnotationsLabel[];
|
||||
/**
|
||||
* Options for annotation's shapes. Each shape inherits options from the shapeOptions object.
|
||||
* An option from the shapeOptions can be overwritten by config for a specific shape.
|
||||
* @since 6.0.0
|
||||
*/
|
||||
shapeOptions?: AnnotationsShapeOptions;
|
||||
/**
|
||||
* An array of shapes for the annotation. For options that apply to multiple shapes, they can be added to the shapeOptions.
|
||||
* @since 6.0.0
|
||||
*/
|
||||
shapes?: AnnotationsShape[];
|
||||
/**
|
||||
* Whether the annotation is visible.
|
||||
* @default true
|
||||
* @since 6.0.0
|
||||
*/
|
||||
visible?: boolean;
|
||||
/**
|
||||
* The Z index of the annotation.
|
||||
* @default 6
|
||||
* @since 6.0.0
|
||||
*/
|
||||
zIndex?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for configuring accessibility for the chart. Requires the accessibility module to be loaded.
|
||||
* For a description of the module and information on its features, see Highcharts Accessibility.
|
||||
@@ -5557,6 +5870,12 @@ declare namespace Highcharts {
|
||||
* Individual data label for each point. The options are the same as the ones for plotOptions.series.dataLabels
|
||||
*/
|
||||
dataLabels?: DataLabels;
|
||||
/**
|
||||
* A description of the point to add to the screen reader information about the point.
|
||||
* @default undefined
|
||||
* @since 5.0.0
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* The id of a series in the drilldown.series array to use for a drilldown for this point.
|
||||
* @since 3.0.8
|
||||
@@ -5923,6 +6242,16 @@ declare namespace Highcharts {
|
||||
* The y value.
|
||||
*/
|
||||
formatter?(): boolean | string;
|
||||
/**
|
||||
* Whether to allow the tooltip to render outside the chart's SVG element box.
|
||||
* By default (false), the tooltip is rendered within the chart's SVG element, which results in
|
||||
* the tooltip being aligned inside the chart area. For small charts, this may result in
|
||||
* clipping or overlapping. When true, a separate SVG element is created and overlaid on the
|
||||
* page, allowing the tooltip to be aligned inside the page itself.
|
||||
* @default false
|
||||
* @since 6.1.1
|
||||
*/
|
||||
outside?: boolean;
|
||||
/**
|
||||
* Padding inside the tooltip, in pixels.
|
||||
* @since 5.0.0
|
||||
@@ -6079,6 +6408,10 @@ declare namespace Highcharts {
|
||||
* @since 5.0.0
|
||||
*/
|
||||
accessibility?: AccessibilityOptions;
|
||||
/**
|
||||
* Options for configuring annotations, for example labels, arrows or shapes.
|
||||
*/
|
||||
annotations?: AnnotationsOptions;
|
||||
/**
|
||||
* Options regarding the chart area and plot area as well as general chart options.
|
||||
*/
|
||||
@@ -6167,7 +6500,7 @@ declare namespace Highcharts {
|
||||
* Allows setting a set of rules to apply for different screen or chart sizes. Each rule specifies additional chart options.
|
||||
* @since 5.0.0
|
||||
*/
|
||||
responsive?: ResponsiveOptions[];
|
||||
responsive?: ResponsiveOptions;
|
||||
/**
|
||||
* The actual series to append to the chart. In addition to the members listed below, any member of the plotOptions
|
||||
* for that specific type of plot can be added to a series individually. For example, even though a general
|
||||
@@ -6236,6 +6569,13 @@ declare namespace Highcharts {
|
||||
* Configuration options for the axes are given in options.xAxis and options.yAxis.
|
||||
*/
|
||||
interface AxisObject {
|
||||
dataMin: number;
|
||||
dataMax: number;
|
||||
userMin: number;
|
||||
userMax: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
width: number;
|
||||
/**
|
||||
* Add a plot band after render time.
|
||||
* @param options A configuration object consisting of the same members as options.xAxis.plotBands
|
||||
@@ -6248,6 +6588,7 @@ declare namespace Highcharts {
|
||||
* @since 1.2.0
|
||||
*/
|
||||
addPlotLine(options: PlotLines): void;
|
||||
defaultLabelFormatter(this: AxisLabelFormatterOptions): string;
|
||||
/**
|
||||
* Get the current extremes for the axis.
|
||||
* @since 1.2.0
|
||||
@@ -6370,6 +6711,8 @@ declare namespace Highcharts {
|
||||
* @since 3.0.8
|
||||
*/
|
||||
addSeriesAsDrilldown(point: PointObject, seriesOptions: IndividualSeriesOptions): void;
|
||||
chartHeight?: number;
|
||||
chartWidth?: number;
|
||||
/**
|
||||
* A reference to the containing HTML element, dynamically inserted into the element given in chart.renderTo.
|
||||
* @since 1.2.5
|
||||
@@ -6479,6 +6822,10 @@ declare namespace Highcharts {
|
||||
* @since 1.2.0
|
||||
*/
|
||||
options: Options;
|
||||
plotLeft?: number;
|
||||
plotSizeX?: number;
|
||||
plotSizeY?: number;
|
||||
plotTop?: number;
|
||||
/**
|
||||
* Exporting module required. Clears away other elements in the page and prints the chart as it is displayed. By
|
||||
* default, when the exporting module is enabled, a button at the upper left calls this method.
|
||||
|
||||
@@ -25,6 +25,14 @@ $(() => {
|
||||
rangeSelector: {
|
||||
allButtonsEnabled: true,
|
||||
selected: 1,
|
||||
buttons: [{
|
||||
type: 'month',
|
||||
count: 1,
|
||||
text: '1m',
|
||||
events: {
|
||||
click: () => { }
|
||||
}
|
||||
}],
|
||||
buttonTheme: { // styles for the buttons
|
||||
fill: 'none',
|
||||
stroke: 'none',
|
||||
|
||||
Vendored
+44
-6
@@ -1,8 +1,9 @@
|
||||
// Type definitions for i18next 8.4
|
||||
// Type definitions for i18next 11.9
|
||||
// Project: http://i18next.com
|
||||
// Definitions by: Michael Ledin <https://github.com/mxl>
|
||||
// Budi Irawan <https://github.com/deerawan>
|
||||
// Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -15,6 +16,18 @@ declare namespace i18next {
|
||||
|
||||
type FormatFunction = (value: string, format?: string, lng?: string) => string;
|
||||
|
||||
/* tslint:disable-next-line:no-empty-interface */
|
||||
interface DetectionPluginOptions {
|
||||
}
|
||||
|
||||
/* tslint:disable-next-line:no-empty-interface */
|
||||
interface BackendPluginOptions {
|
||||
}
|
||||
|
||||
/* tslint:disable-next-line:no-empty-interface */
|
||||
interface CachePluginOptions {
|
||||
}
|
||||
|
||||
interface InterpolationOptions {
|
||||
/**
|
||||
* format function see formatting for details
|
||||
@@ -37,6 +50,11 @@ declare namespace i18next {
|
||||
* @default true
|
||||
*/
|
||||
escapeValue?: boolean;
|
||||
/**
|
||||
* If true, then value passed into escape function is not casted to string, use with custom escape function that does its own type check
|
||||
* @default false
|
||||
*/
|
||||
useRawValueToEscape?: boolean;
|
||||
/**
|
||||
* prefix for interpolation
|
||||
* @default '{{'
|
||||
@@ -91,7 +109,12 @@ declare namespace i18next {
|
||||
* global variables to use in interpolation replacements
|
||||
* @default undefined
|
||||
*/
|
||||
defaultVariables?: any;
|
||||
defaultVariables?: { [index: string]: any };
|
||||
/**
|
||||
* after how many interpolation runs to break out before throwing a stack overflow
|
||||
* @default 1000
|
||||
*/
|
||||
maxReplaces?: number;
|
||||
}
|
||||
|
||||
interface ReactOptions {
|
||||
@@ -204,6 +227,15 @@ declare namespace i18next {
|
||||
*/
|
||||
saveMissing?: boolean;
|
||||
|
||||
/**
|
||||
* experimental: enable to update default values using the saveMissing
|
||||
* (Works only if defaultValue different from translated value.
|
||||
* Only useful on initial development or when keeping code as source of truth not changing values outside of code.
|
||||
* Only supported if backend supports it already)
|
||||
* @default false
|
||||
*/
|
||||
updateMissing?: boolean;
|
||||
|
||||
/**
|
||||
* @default 'fallback'
|
||||
*/
|
||||
@@ -213,7 +245,7 @@ declare namespace i18next {
|
||||
* Used for custom missing key handling (needs saveMissing set to true!)
|
||||
* @default false
|
||||
*/
|
||||
missingKeyHandler?: false | ((lng: string, ns: string, key: string, fallbackValue: string) => void);
|
||||
missingKeyHandler?: false | ((lngs: string[], ns: string, key: string, fallbackValue: string) => void);
|
||||
|
||||
/**
|
||||
* receives a key that was not found in `t()` and returns a value, that will be returned by `t()`
|
||||
@@ -227,6 +259,12 @@ declare namespace i18next {
|
||||
*/
|
||||
appendNamespaceToMissingKey?: boolean;
|
||||
|
||||
/**
|
||||
* gets called in case a interpolation value is undefined. This method will not be called if the value is empty string or null
|
||||
* @default noop
|
||||
*/
|
||||
missingInterpolationHandler?: (text: string, value: any) => any;
|
||||
|
||||
/**
|
||||
* will use 'plural' as suffix for languages only having 1 plural form, setting it to false will suffix all with numbers
|
||||
* @default true
|
||||
@@ -284,19 +322,19 @@ declare namespace i18next {
|
||||
* options for language detection - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
detection?: object;
|
||||
detection?: DetectionPluginOptions;
|
||||
|
||||
/**
|
||||
* options for backend - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
backend?: object;
|
||||
backend?: BackendPluginOptions;
|
||||
|
||||
/**
|
||||
* options for cache layer - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
cache?: object;
|
||||
cache?: CachePluginOptions;
|
||||
|
||||
/**
|
||||
* options for react - check documentation of plugin
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
import * as i18next from 'i18next';
|
||||
|
||||
i18next.init({
|
||||
lng: "en",
|
||||
debug: true,
|
||||
resources: {
|
||||
en: {
|
||||
translation: {
|
||||
key: "hello world"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
// initialized and ready to go!
|
||||
const value: string = i18next.t('key');
|
||||
});
|
||||
|
||||
i18next.init({ initImmediate: false });
|
||||
|
||||
i18next.init({
|
||||
lng: 'en',
|
||||
debug: true,
|
||||
resources: {
|
||||
en: {
|
||||
translation: {
|
||||
key: "hello world"
|
||||
}
|
||||
},
|
||||
de: {
|
||||
translation: {
|
||||
key: "hello welt"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
// init set content
|
||||
updateContent();
|
||||
});
|
||||
|
||||
i18next.init({
|
||||
ns: ['common', 'moduleA', 'moduleB'],
|
||||
defaultNS: 'moduleA'
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
i18next.t('myKey'); // key in moduleA namespace (defined default)
|
||||
i18next.t('common:myKey'); // key in common namespace
|
||||
});
|
||||
|
||||
i18next.loadNamespaces('anotherNamespace', (err: any, t: i18next.TranslationFunction) => { /* ... */ });
|
||||
|
||||
// fallback to one language
|
||||
i18next.init({
|
||||
lng: 'en-GB'
|
||||
}, () => {
|
||||
i18next.t('i18n'); // -> "Internationalisation"
|
||||
i18next.t('i18n_short'); // -> "i18n" (from en.json)
|
||||
|
||||
// force loading en
|
||||
i18next.t('i18n', { lng: 'en' }); // -> "Internationalization"
|
||||
});
|
||||
|
||||
// fallback to one language
|
||||
i18next.init({
|
||||
fallbackLng: 'en'
|
||||
});
|
||||
|
||||
// fallback ordered
|
||||
i18next.init({
|
||||
fallbackLng: ['fr', 'en']
|
||||
});
|
||||
|
||||
// fallback depending on user language
|
||||
i18next.init({
|
||||
fallbackLng: {
|
||||
'de-CH': ['fr', 'it'],
|
||||
'zh-HANT': ['zh-HANS', 'en'],
|
||||
es: ['fr'],
|
||||
default: ['en']
|
||||
}
|
||||
});
|
||||
|
||||
const updateContent = () => {
|
||||
const value: string = i18next.t('key');
|
||||
};
|
||||
|
||||
const changeLng = (lng: string) => {
|
||||
i18next.changeLanguage(lng);
|
||||
};
|
||||
|
||||
i18next.init({
|
||||
// files to load
|
||||
ns: ['app', 'common'],
|
||||
|
||||
// default namespace (needs no prefix on calling t)
|
||||
defaultNS: 'app',
|
||||
|
||||
// fallback, can be a string or an array of namespaces
|
||||
fallbackNS: 'common'
|
||||
}, () => {
|
||||
i18next.t('title'); // -> "i18next"
|
||||
|
||||
i18next.t('button.save'); // -> "save" (fallback from common)
|
||||
|
||||
// without fallbackNS you would have to prefix namespace
|
||||
// to access keys in that namespace
|
||||
i18next.t('common:button.save'); // -> "save"
|
||||
});
|
||||
|
||||
i18next.init({
|
||||
lng: 'de',
|
||||
|
||||
// allow keys to be phrases having `:`, `.`
|
||||
nsSeparator: false,
|
||||
keySeparator: false,
|
||||
|
||||
// do not load a fallback
|
||||
fallbackLng: false
|
||||
});
|
||||
|
||||
const error404 = '404';
|
||||
i18next.t([`error.${error404}`, 'error.unspecific']); // -> "The page was not found"
|
||||
|
||||
const error502 = '502';
|
||||
i18next.t([`error.${error502}`, 'error.unspecific']); // -> "Something went wrong"
|
||||
|
||||
i18next.t('No one says a key can not be the fallback.');
|
||||
// -> "Niemand sagt ein key kann nicht als Ersatz dienen."
|
||||
|
||||
i18next.t('This will be shown if the current loaded translations to not have this.');
|
||||
// -> "This will be shown if the current loaded translations to not have this."
|
||||
|
||||
const languageChangedCallback = () => {
|
||||
updateContent();
|
||||
};
|
||||
|
||||
i18next.on('languageChanged', languageChangedCallback);
|
||||
i18next.off('languageChanged', languageChangedCallback);
|
||||
|
||||
i18next
|
||||
.init({
|
||||
fallbackLng: 'en',
|
||||
debug: true,
|
||||
ns: ['special', 'common'],
|
||||
defaultNS: 'special',
|
||||
backend: {
|
||||
// load from i18next-gitbook repo
|
||||
loadPath: 'https://raw.githubusercontent.com/i18next/i18next-gitbook/master/locales/{{lng}}/{{ns}}.json',
|
||||
crossDomain: true
|
||||
}
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
// init set content
|
||||
updateContent2();
|
||||
});
|
||||
|
||||
// just set some content and react to language changes
|
||||
// could be optimized using vue-i18next, jquery-i18next, react-i18next, ...
|
||||
const updateContent2 = () => {
|
||||
const value: string = i18next.t('title', { what: 'i18next' });
|
||||
const value2: string = i18next.t('common:button.save', { count: Math.floor(Math.random() * 2 + 1) });
|
||||
const value3 = `detected user language: "${i18next.language}" --> loaded languages: "${i18next.languages.join(', ')}"`;
|
||||
};
|
||||
|
||||
i18next.init({
|
||||
fallbackLng: 'en',
|
||||
ns: ['file1', 'file2'],
|
||||
defaultNS: 'file1',
|
||||
debug: true
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
// with only callback
|
||||
i18next.init((err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
const v: string = i18next.t('my.key');
|
||||
const a: boolean = i18next.exists('my.key');
|
||||
|
||||
// fix language to german
|
||||
const de = i18next.getFixedT('de');
|
||||
const z: string = de('myKey');
|
||||
|
||||
// or fix the namespace to anotherNamespace
|
||||
const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace');
|
||||
const x: string = anotherNamespace('anotherNamespaceKey'); // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey');
|
||||
|
||||
i18next.changeLanguage('en', (err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
i18next.loadNamespaces('myNamespace', (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
|
||||
i18next.loadNamespaces(['myNamespace1', 'myNamespace2'], (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
|
||||
|
||||
i18next.loadLanguages('de', (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
|
||||
i18next.loadLanguages(['de', 'fr'], (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
|
||||
|
||||
// reload all
|
||||
i18next.reloadResources();
|
||||
|
||||
// reload languages
|
||||
i18next.reloadResources(['de', 'fr']);
|
||||
|
||||
// reload namespaces for all languages
|
||||
i18next.reloadResources(null, ['ns1', 'ns2']);
|
||||
|
||||
// reload namespaces in languages
|
||||
i18next.reloadResources(['de', 'fr'], ['ns1', 'ns2']);
|
||||
|
||||
// for current language
|
||||
i18next.dir();
|
||||
|
||||
// for another language
|
||||
i18next.dir('en-US'); // -> "ltr";
|
||||
i18next.dir('ar'); // -> "rtl";
|
||||
|
||||
// key = 'hello {{what}}'
|
||||
i18next.t('key', { what: i18next.format('world', 'uppercase') }); // -> hello WORLD
|
||||
|
||||
const newInstance = i18next.createInstance({
|
||||
fallbackLng: 'en',
|
||||
ns: ['file1', 'file2'],
|
||||
defaultNS: 'file1',
|
||||
debug: true
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
// is the same as
|
||||
newInstance.init({
|
||||
fallbackLng: 'en',
|
||||
ns: ['file1', 'file2'],
|
||||
defaultNS: 'file1',
|
||||
debug: true
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
const newInstance2 = i18next.cloneInstance({
|
||||
fallbackLng: 'en',
|
||||
ns: ['file1', 'file2'],
|
||||
defaultNS: 'file1',
|
||||
debug: true
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
// is the same as
|
||||
const newInstance3 = i18next.cloneInstance();
|
||||
newInstance.init({
|
||||
fallbackLng: 'en',
|
||||
ns: ['file1', 'file2'],
|
||||
defaultNS: 'file1',
|
||||
debug: true
|
||||
}, (err: any, t: i18next.TranslationFunction) => {
|
||||
if (err) {
|
||||
console.log('something went wrong loading', err);
|
||||
return;
|
||||
}
|
||||
t('key'); // -> same as i18next.t
|
||||
});
|
||||
|
||||
i18next.on('initialized', options => { });
|
||||
i18next.on('loaded', loaded => { });
|
||||
i18next.on('failedLoading', (lng: string, ns: string, msg: string) => { });
|
||||
i18next.on('missingKey', (lngs: string[], namespace: string, key: string, res: string) => { });
|
||||
i18next.on('added', (lng: string, ns: string) => { });
|
||||
i18next.on('removed', (lng: string, ns: string) => { });
|
||||
i18next.on('languageChanged', (lng: string) => { });
|
||||
i18next.on("customEvent", () => { });
|
||||
|
||||
i18next.getResource("en", "test", "key");
|
||||
i18next.getResource("en", "test", "key", { keySeparator: "-" });
|
||||
|
||||
i18next.addResource("en", "test", "key", "value");
|
||||
i18next.addResource("en", "test", "key", "value", { keySeparator: "-", silent: false });
|
||||
|
||||
i18next.addResources("en", "test", { key: "value" });
|
||||
|
||||
i18next.addResourceBundle('en', 'translations', {
|
||||
key: 'value',
|
||||
}, true, true);
|
||||
|
||||
const has: boolean = i18next.hasResourceBundle("en", "test");
|
||||
|
||||
i18next.getResourceBundle("en", "test");
|
||||
|
||||
i18next.removeResourceBundle("en", "test");
|
||||
|
||||
i18next
|
||||
.init({
|
||||
resources: {
|
||||
en: {
|
||||
namespace1: {
|
||||
key: 'hello from namespace 1'
|
||||
},
|
||||
namespace2: {
|
||||
key: 'hello from namespace 2'
|
||||
}
|
||||
},
|
||||
de: {
|
||||
namespace1: {
|
||||
key: 'hallo von namespace 1'
|
||||
},
|
||||
namespace2: {
|
||||
key: 'hallo von namespace 2'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
i18next.init();
|
||||
|
||||
i18next.addResourceBundle("en", 'namespace1', {
|
||||
key: 'hello from namespace 1'
|
||||
});
|
||||
|
||||
i18next
|
||||
.init({
|
||||
backend: {
|
||||
// for all available options read the backend's repository readme file
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json'
|
||||
}
|
||||
});
|
||||
|
||||
i18next.init({
|
||||
ns: ['common', 'moduleA'],
|
||||
defaultNS: 'moduleA'
|
||||
});
|
||||
|
||||
i18next.t('key', { what: 'i18next', how: 'great' });
|
||||
|
||||
const author = {
|
||||
name: 'Jan',
|
||||
github: 'jamuhl'
|
||||
};
|
||||
i18next.t('key', { author });
|
||||
|
||||
i18next.t('keyEscaped', { myVar: '<img />' });
|
||||
// -> "no danger <img />"
|
||||
|
||||
i18next.t('keyUnescaped', { myVar: '<img />' });
|
||||
// -> "dangerous <img />"
|
||||
|
||||
i18next.t('keyEscaped', { myVar: '<img />', interpolation: { escapeValue: false } });
|
||||
// -> "no danger <img />" (obviously could be dangerous)
|
||||
|
||||
i18next
|
||||
.init({
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
|
||||
resources: {
|
||||
en: {
|
||||
translation: {
|
||||
key1: 'test',
|
||||
interpolateKey: 'add {{insert}} {{up, uppercase}}',
|
||||
interpolateKey2: '<strong>add</strong> {{insert}} {{up, uppercase}}'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false, // not needed for react!!
|
||||
formatSeparator: ',',
|
||||
format: (value: string, format: string, lng: string) => {
|
||||
if (format === 'uppercase') return value.toUpperCase();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
i18next.t('key', { count: 0 }); // -> "items"
|
||||
i18next.t('key', { count: 1 }); // -> "item"
|
||||
i18next.t('key', { count: 5 }); // -> "items"
|
||||
i18next.t('key', { count: 100 }); // -> "items"
|
||||
i18next.t('keyWithCount', { count: 0 }); // -> "0 items"
|
||||
i18next.t('keyWithCount', { count: 1 }); // -> "1 item"
|
||||
i18next.t('keyWithCount', { count: 5 }); // -> "5 items"
|
||||
i18next.t('keyWithCount', { count: 100 }); // -> "100 items"
|
||||
|
||||
i18next.t('key1_interval', { postProcess: 'interval', count: 1 }); // -> "one item"
|
||||
i18next.t('key1_interval', { postProcess: 'interval', count: 4 }); // -> "a few items"
|
||||
i18next.t('key1_interval', { postProcess: 'interval', count: 100 }); // -> "a lot of items"
|
||||
|
||||
// not matching into a range it will fallback to
|
||||
// the regular plural form
|
||||
i18next.t('key2_interval', { postProcess: 'interval', count: 1 }); // -> "one item"
|
||||
i18next.t('key2_interval', { postProcess: 'interval', count: 4 }); // -> "a few items"
|
||||
i18next.t('key2_interval', { postProcess: 'interval', count: 100 }); // -> "100 items"
|
||||
i18next.t('friend', { context: 'male', count: 1 }); // -> "A boyfriend"
|
||||
i18next.t('friend', { context: 'male', count: 1 }); // -> "A boyfriend"
|
||||
i18next.t('friend', { context: 'female', count: 100 }); // -> "100 girlfriends"
|
||||
i18next.t('friend', { context: 'female', count: 100 }); // -> "100 girlfriends"
|
||||
i18next.t('tree', { returnObjects: true, something: 'gold' });
|
||||
// -> { res: 'added gold' }
|
||||
|
||||
i18next.t('array', { returnObjects: true });
|
||||
// -> ['a', 'b', 'c']
|
||||
i18next.t('arrayJoin', { joinArrays: '+' });
|
||||
// -> "line1+line2+line3"
|
||||
|
||||
i18next.t('arrayJoinWithInterpolation', { myVar: 'interpolate', joinArrays: ' ' });
|
||||
// -> "you can interpolate"
|
||||
|
||||
i18next.t('arrayOfObjects.0.name');
|
||||
// -> "tom"
|
||||
|
||||
type KeyList = "friend" | "tree";
|
||||
|
||||
interface CustomOptions {
|
||||
myVar: string;
|
||||
}
|
||||
|
||||
i18next.t("friend");
|
||||
i18next.t(["friend", "tree"]);
|
||||
i18next.t("friend", { myVar: "someValue" });
|
||||
i18next.t(["friend", "tree"], { myVar: "someValue" });
|
||||
i18next.t("friend", { myVar: "someValue" });
|
||||
i18next.t(["friend", "tree"], { myVar: "someValue" });
|
||||
|
||||
const t1: i18next.TranslationFunction = (key: string, options: i18next.TranslationOptions) => "";
|
||||
const t2: i18next.TranslationFunction<{ value: string }> = (key: string, options: i18next.TranslationOptions) => ({ value: "asd" });
|
||||
const t3: i18next.TranslationFunction<string, CustomOptions> = (key: string | string[], options: i18next.TranslationOptions<CustomOptions>) => "";
|
||||
const t4: i18next.TranslationFunction<string, object, KeyList> = (key: KeyList | KeyList[], options: i18next.TranslationOptions) => "";
|
||||
|
||||
i18next.exists("friend");
|
||||
i18next.exists(["friend", "tree"]);
|
||||
i18next.exists("friend", { myVar: "someValue" });
|
||||
i18next.exists(["friend", "tree"], { myVar: "someValue" });
|
||||
i18next.exists("friend", { myVar: "someValue" });
|
||||
i18next.exists(["friend", "tree"], { myVar: "someValue" });
|
||||
Vendored
+619
@@ -0,0 +1,619 @@
|
||||
// Type definitions for i18next 8.4
|
||||
// Project: http://i18next.com
|
||||
// Definitions by: Michael Ledin <https://github.com/mxl>
|
||||
// Budi Irawan <https://github.com/deerawan>
|
||||
// Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare namespace i18next {
|
||||
interface FallbackLngObjList {
|
||||
[language: string]: string[];
|
||||
}
|
||||
|
||||
type FallbackLng = string | string[] | FallbackLngObjList;
|
||||
|
||||
type FormatFunction = (value: string, format?: string, lng?: string) => string;
|
||||
|
||||
interface InterpolationOptions {
|
||||
/**
|
||||
* format function see formatting for details
|
||||
* @default noop
|
||||
*/
|
||||
format?: FormatFunction;
|
||||
/**
|
||||
* used to separate format from interpolation value
|
||||
* @default ','
|
||||
*/
|
||||
formatSeparator?: string;
|
||||
/**
|
||||
* escape function
|
||||
* @default str => str
|
||||
*/
|
||||
escape?(str: string): string;
|
||||
|
||||
/**
|
||||
* escape passed in values to avoid xss injection
|
||||
* @default true
|
||||
*/
|
||||
escapeValue?: boolean;
|
||||
/**
|
||||
* prefix for interpolation
|
||||
* @default '{{'
|
||||
*/
|
||||
prefix?: string;
|
||||
/**
|
||||
* suffix for interpolation
|
||||
* @default '}}'
|
||||
*/
|
||||
suffix?: string;
|
||||
/**
|
||||
* escaped prefix for interpolation (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
prefixEscaped?: string;
|
||||
/**
|
||||
* escaped suffix for interpolation (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
suffixEscaped?: string;
|
||||
/**
|
||||
* suffix to unescaped mode
|
||||
* @default undefined
|
||||
*/
|
||||
unescapeSuffix?: string;
|
||||
/**
|
||||
* prefix to unescaped mode
|
||||
* @default '-'
|
||||
*/
|
||||
unescapePrefix?: string;
|
||||
/**
|
||||
* prefix for nesting
|
||||
* @default '$t('
|
||||
*/
|
||||
nestingPrefix?: string;
|
||||
/**
|
||||
* suffix for nesting
|
||||
* @default ')'
|
||||
*/
|
||||
nestingSuffix?: string;
|
||||
/**
|
||||
* escaped prefix for nesting (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
nestingPrefixEscaped?: string;
|
||||
/**
|
||||
* escaped suffix for nesting (regexSafe)
|
||||
* @default undefined
|
||||
*/
|
||||
nestingSuffixEscaped?: string;
|
||||
/**
|
||||
* global variables to use in interpolation replacements
|
||||
* @default undefined
|
||||
*/
|
||||
defaultVariables?: any;
|
||||
}
|
||||
|
||||
interface ReactOptions {
|
||||
/**
|
||||
* set to true if you like to wait for loaded in every translated hoc
|
||||
* @default false
|
||||
*/
|
||||
wait?: boolean;
|
||||
/**
|
||||
* set it to fallback to let passed namespaces to translated hoc act as fallbacks
|
||||
* @default 'default'
|
||||
*/
|
||||
nsMode?: 'default' | 'fallback';
|
||||
/**
|
||||
* set it to the default parent element created by the Trans component.
|
||||
* @default 'div'
|
||||
*/
|
||||
defaultTransParent?: string;
|
||||
/**
|
||||
* set which events trigger a rerender, can be set to false or string of events
|
||||
* @default 'languageChanged loaded'
|
||||
*/
|
||||
bindI18n?: string | false;
|
||||
/**
|
||||
* set which events on store trigger a rerender, can be set to false or string of events
|
||||
* @default 'added removed'
|
||||
*/
|
||||
bindStore?: string | false;
|
||||
}
|
||||
|
||||
interface InitOptions {
|
||||
/**
|
||||
* logs info level to console output. Helps finding issues with loading not working.
|
||||
* @default false
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* resources to initialize with (if not using loading or not appending using addResourceBundle)
|
||||
* @default undefined
|
||||
*/
|
||||
resources?: Resource;
|
||||
|
||||
/**
|
||||
* language to use (overrides language detection)
|
||||
* @default undefined
|
||||
*/
|
||||
lng?: string;
|
||||
|
||||
/**
|
||||
* language to use if translations in user language are not available.
|
||||
* @default 'dev'
|
||||
*/
|
||||
fallbackLng?: false | FallbackLng;
|
||||
|
||||
/**
|
||||
* array of allowed languages
|
||||
* @default false
|
||||
*/
|
||||
whitelist?: false | string[];
|
||||
|
||||
/**
|
||||
* if true will pass eg. en-US if finding en in whitelist
|
||||
* @default false
|
||||
*/
|
||||
nonExplicitWhitelist?: boolean;
|
||||
|
||||
/**
|
||||
* language codes to lookup, given set language is
|
||||
* 'en-US': 'all' --> ['en-US', 'en', 'dev'],
|
||||
* 'currentOnly' --> 'en-US',
|
||||
* 'languageOnly' --> 'en'
|
||||
* @default 'all'
|
||||
*/
|
||||
load?: "all" | "currentOnly" | "languageOnly";
|
||||
|
||||
/**
|
||||
* array of languages to preload. Important on serverside to assert translations are loaded before rendering views.
|
||||
* @default false
|
||||
*/
|
||||
preload?: false | string[];
|
||||
|
||||
/**
|
||||
* language will be lowercased eg. en-US --> en-us
|
||||
* @default false
|
||||
*/
|
||||
lowerCaseLng?: boolean;
|
||||
|
||||
/**
|
||||
* string or array of namespaces to load
|
||||
* @default 'translation'
|
||||
*/
|
||||
ns?: string | string[];
|
||||
|
||||
/**
|
||||
* default namespace used if not passed to translation function
|
||||
* @default 'translation'
|
||||
*/
|
||||
defaultNS?: string;
|
||||
|
||||
/**
|
||||
* string or array of namespaces to lookup key if not found in given namespace.
|
||||
* @default false
|
||||
*/
|
||||
fallbackNS?: false | string | string[];
|
||||
|
||||
/**
|
||||
* calls save missing key function on backend if key not found
|
||||
* @default false
|
||||
*/
|
||||
saveMissing?: boolean;
|
||||
|
||||
/**
|
||||
* @default 'fallback'
|
||||
*/
|
||||
saveMissingTo?: "current" | "all" | "fallback";
|
||||
|
||||
/**
|
||||
* Used for custom missing key handling (needs saveMissing set to true!)
|
||||
* @default false
|
||||
*/
|
||||
missingKeyHandler?: false | ((lng: string, ns: string, key: string, fallbackValue: string) => void);
|
||||
|
||||
/**
|
||||
* receives a key that was not found in `t()` and returns a value, that will be returned by `t()`
|
||||
* @default noop
|
||||
*/
|
||||
parseMissingKeyHandler?(key: string): any;
|
||||
|
||||
/**
|
||||
* appends namespace to missing key
|
||||
* @default false
|
||||
*/
|
||||
appendNamespaceToMissingKey?: boolean;
|
||||
|
||||
/**
|
||||
* will use 'plural' as suffix for languages only having 1 plural form, setting it to false will suffix all with numbers
|
||||
* @default true
|
||||
*/
|
||||
simplifyPluralSuffix?: boolean;
|
||||
|
||||
/**
|
||||
* string or array of postProcessors to apply per default
|
||||
* @default false
|
||||
*/
|
||||
postProcess?: false | string | string[];
|
||||
|
||||
/**
|
||||
* allows null values as valid translation
|
||||
* @default true
|
||||
*/
|
||||
returnNull?: boolean;
|
||||
|
||||
/**
|
||||
* allows empty string as valid translation
|
||||
* @default true
|
||||
*/
|
||||
returnEmptyString?: boolean;
|
||||
|
||||
/**
|
||||
* allows objects as valid translation result
|
||||
* @default false
|
||||
*/
|
||||
returnObjects?: boolean;
|
||||
|
||||
/**
|
||||
* Gets called if object was passed in as key but returnObjects was set to false
|
||||
* @default noop
|
||||
*/
|
||||
returnedObjectHandler?(key: string, value: string, options: any): void;
|
||||
|
||||
/**
|
||||
* char, eg. '\n' that arrays will be joined by
|
||||
* @default false
|
||||
*/
|
||||
joinArrays?: false | string;
|
||||
|
||||
/**
|
||||
* default: sets defaultValue
|
||||
* @default args => ({ defaultValue: args[1] })
|
||||
*/
|
||||
overloadTranslationOptionHandler?(args: string[]): TranslationOptions;
|
||||
|
||||
/**
|
||||
* @see https://www.i18next.com/interpolation.html
|
||||
*/
|
||||
interpolation?: InterpolationOptions;
|
||||
|
||||
/**
|
||||
* options for language detection - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
detection?: object;
|
||||
|
||||
/**
|
||||
* options for backend - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
backend?: object;
|
||||
|
||||
/**
|
||||
* options for cache layer - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
cache?: object;
|
||||
|
||||
/**
|
||||
* options for react - check documentation of plugin
|
||||
* @default undefined
|
||||
*/
|
||||
react?: ReactOptions;
|
||||
|
||||
/**
|
||||
* triggers resource loading in init function inside a setTimeout (default async behaviour).
|
||||
* Set it to false if your backend loads resources sync - that way calling i18next.t after
|
||||
* init is possible without relaying on the init callback.
|
||||
* @default true
|
||||
*/
|
||||
initImmediate?: boolean;
|
||||
|
||||
/**
|
||||
* char to separate keys
|
||||
* @default '.'
|
||||
*/
|
||||
keySeparator?: false | string;
|
||||
|
||||
/**
|
||||
* char to split namespace from key
|
||||
* @default ':'
|
||||
*/
|
||||
nsSeparator?: false | string;
|
||||
|
||||
/**
|
||||
* char to split plural from key
|
||||
* @default '_'
|
||||
*/
|
||||
pluralSeparator?: string;
|
||||
|
||||
/**
|
||||
* char to split context from key
|
||||
* @default '_'
|
||||
*/
|
||||
contextSeparator?: string;
|
||||
|
||||
/**
|
||||
* prefixes the namespace to the returned key when using cimode
|
||||
* @default false
|
||||
*/
|
||||
appendNamespaceToCIMode?: boolean;
|
||||
|
||||
/**
|
||||
* Compatibility JSON version
|
||||
*/
|
||||
compatibilityJSON?: string;
|
||||
}
|
||||
|
||||
// Add an indexer to assure that interpolation arguments can be passed
|
||||
type TranslationOptions<TCustomOptions extends object = object> = TranslationOptionsBase & TCustomOptions & { [key: string]: any };
|
||||
|
||||
interface TranslationOptionsBase {
|
||||
/**
|
||||
* defaultValue to return if a translation was not found
|
||||
*/
|
||||
defaultValue?: any;
|
||||
/**
|
||||
* count value used for plurals
|
||||
*/
|
||||
count?: number;
|
||||
/**
|
||||
* used for contexts (eg. male\female)
|
||||
*/
|
||||
context?: any;
|
||||
/**
|
||||
* object with vars for interpolation - or put them directly in options
|
||||
*/
|
||||
replace?: any;
|
||||
/**
|
||||
* override language to use
|
||||
*/
|
||||
lng?: string;
|
||||
/**
|
||||
* override languages to use
|
||||
*/
|
||||
lngs?: string[];
|
||||
/**
|
||||
* override language to lookup key if not found see fallbacks for details
|
||||
*/
|
||||
fallbackLng?: FallbackLng;
|
||||
/**
|
||||
* override namespaces (string or array)
|
||||
*/
|
||||
ns?: string | string[];
|
||||
/**
|
||||
* override char to separate keys
|
||||
*/
|
||||
keySeparator?: string;
|
||||
/**
|
||||
* override char to split namespace from key
|
||||
*/
|
||||
nsSeparator?: string;
|
||||
/**
|
||||
* accessing an object not a translation string (can be set globally too)
|
||||
*/
|
||||
returnObjects?: boolean;
|
||||
/**
|
||||
* char, eg. '\n' that arrays will be joined by (can be set globally too)
|
||||
*/
|
||||
joinArrays?: string;
|
||||
/**
|
||||
* string or array of postProcessors to apply see interval plurals as a sample
|
||||
*/
|
||||
postProcess?: string | string[];
|
||||
/**
|
||||
* override interpolation options
|
||||
*/
|
||||
interpolation?: InterpolationOptions;
|
||||
}
|
||||
|
||||
type Callback = (error: any, t: TranslationFunction) => void;
|
||||
|
||||
type TranslationFunction<TResult = any, TValues extends object = object, TKeys extends string = string> =
|
||||
(key: TKeys | TKeys[], options?: TranslationOptions<TValues>) => TResult;
|
||||
|
||||
interface Resource {
|
||||
[language: string]: ResourceLanguage;
|
||||
}
|
||||
|
||||
interface ResourceLanguage {
|
||||
[namespace: string]: ResourceKey;
|
||||
}
|
||||
|
||||
interface ResourceKey {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface i18n {
|
||||
/**
|
||||
* The default export of the i18next module is an i18next instance ready to be initialized by calling init.
|
||||
* You can create additional instances using the createInstance function.
|
||||
*
|
||||
* @param options - Initial options.
|
||||
* @param callback - will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
||||
*/
|
||||
init(options: InitOptions, callback?: Callback): i18n;
|
||||
init(callback?: Callback): i18n;
|
||||
|
||||
loadResources(callback?: (err: any) => void): void;
|
||||
|
||||
/**
|
||||
* The use function is there to load additional plugins to i18next.
|
||||
* For available module see the plugins page and don't forget to read the documentation of the plugin.
|
||||
*/
|
||||
use(module: any): i18n;
|
||||
|
||||
/**
|
||||
* Please have a look at the translation functions like interpolation, formatting and plurals for more details on using it.
|
||||
*/
|
||||
t: TranslationFunction;
|
||||
|
||||
/**
|
||||
* Uses the same resolve functionality as the t function and returns true if a key exists.
|
||||
*/
|
||||
exists: TranslationFunction<boolean>;
|
||||
|
||||
/**
|
||||
* Returns a t function that defaults to given language or namespace.
|
||||
* Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case.
|
||||
* On the returned function you can like in the t function override the languages or namespaces by passing them in options or by prepending namespace.
|
||||
*/
|
||||
getFixedT(lng: string | string[], ns?: string | string[]): TranslationFunction;
|
||||
getFixedT(lng: null, ns: string | string[]): TranslationFunction;
|
||||
|
||||
/**
|
||||
* Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
|
||||
* HINT: For easy testing - setting lng to 'cimode' will set t function to always return the key.
|
||||
*/
|
||||
changeLanguage(lng: string, callback?: Callback): void;
|
||||
|
||||
/**
|
||||
* Is set to the current detected or set language.
|
||||
* If you need the primary used language depending on your configuration (whilelist, load) you will prefer using i18next.languages[0].
|
||||
*/
|
||||
language: string;
|
||||
|
||||
/**
|
||||
* Is set to an array of language-codes that will be used it order to lookup the translation value.
|
||||
*/
|
||||
languages: string[];
|
||||
|
||||
/**
|
||||
* Loads additional namespaces not defined in init options.
|
||||
*/
|
||||
loadNamespaces(ns: string | string[], callback: Callback): void;
|
||||
|
||||
/**
|
||||
* Loads additional languages not defined in init options (preload).
|
||||
*/
|
||||
loadLanguages(lngs: string | string[], callback: Callback): void;
|
||||
|
||||
/**
|
||||
* Reloads resources on given state. Optionally you can pass an array of languages and namespaces as params if you don't want to reload all.
|
||||
*/
|
||||
reloadResources(lngs?: string[], ns?: string[]): void;
|
||||
reloadResources(lngs: null, ns: string[]): void;
|
||||
|
||||
/**
|
||||
* Changes the default namespace.
|
||||
*/
|
||||
setDefaultNamespace(ns: string): void;
|
||||
|
||||
/**
|
||||
* Returns rtl or ltr depending on languages read direction.
|
||||
*/
|
||||
dir(lng?: string): "ltr" | "rtl";
|
||||
|
||||
/**
|
||||
* Exposes interpolation.format function added on init.
|
||||
*/
|
||||
format: FormatFunction;
|
||||
|
||||
/**
|
||||
* Will return a new i18next instance.
|
||||
* Please read the options page for details on configuration options.
|
||||
* Providing a callback will automatically call init.
|
||||
* The callback will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
||||
*/
|
||||
createInstance(options?: InitOptions, callback?: Callback): i18n;
|
||||
|
||||
/**
|
||||
* Creates a clone of the current instance. Shares store, plugins and initial configuration.
|
||||
* Can be used to create an instance sharing storage but being independent on set language or namespaces.
|
||||
*/
|
||||
cloneInstance(options?: InitOptions, callback?: Callback): i18n;
|
||||
|
||||
/**
|
||||
* Gets fired after initialization.
|
||||
*/
|
||||
on(event: "initialized", callback: (options: InitOptions) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired on loaded resources.
|
||||
*/
|
||||
on(event: "loaded", callback: (loaded: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired if loading resources failed.
|
||||
*/
|
||||
on(event: "failedLoading", callback: (lng: string, ns: string, msg: string) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired on accessing a key not existing.
|
||||
*/
|
||||
on(event: "missingKey", callback: (lngs: string[], namespace: string, key: string, res: string) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired when resources got added or removed.
|
||||
*/
|
||||
on(event: "added" | "removed", callback: (lng: string, ns: string) => void): void;
|
||||
|
||||
/**
|
||||
* Gets fired when changeLanguage got called.
|
||||
*/
|
||||
on(event: "languageChanged", callback: (lng: string) => void): void;
|
||||
|
||||
/**
|
||||
* Event listener
|
||||
*/
|
||||
on(event: string, listener: (...args: any[]) => void): void;
|
||||
|
||||
/**
|
||||
* Remove event listener
|
||||
*/
|
||||
off(event: string, listener: (...args: any[]) => void): void;
|
||||
|
||||
/**
|
||||
* Gets one value by given key.
|
||||
*/
|
||||
getResource(lng: string, ns: string, key: string, options?: { keySeparator?: string }): any;
|
||||
|
||||
/**
|
||||
* Adds one key/value.
|
||||
*/
|
||||
addResource(lng: string, ns: string, key: string, value: string, options?: { keySeparator?: string, silent?: boolean }): void;
|
||||
|
||||
/**
|
||||
* Adds multiple key/values.
|
||||
*/
|
||||
addResources(lng: string, ns: string, resources: any): void;
|
||||
|
||||
/**
|
||||
* Adds a complete bundle.
|
||||
* Setting deep param to true will extend existing translations in that file.
|
||||
* Setting overwrite to true it will overwrite existing translations in that file.
|
||||
*/
|
||||
addResourceBundle(lng: string, ns: string, resources: any, deep?: boolean, overwrite?: boolean): void;
|
||||
|
||||
/**
|
||||
* Checks if a resource bundle exists.
|
||||
*/
|
||||
hasResourceBundle(lng: string, ns: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns a resource bundle.
|
||||
*/
|
||||
getResourceBundle(lng: string, ns: string): any;
|
||||
|
||||
/**
|
||||
* Removes an existing bundle.
|
||||
*/
|
||||
removeResourceBundle(lng: string, ns: string): void;
|
||||
|
||||
/**
|
||||
* Current options
|
||||
*/
|
||||
options: InitOptions;
|
||||
|
||||
/**
|
||||
* Is initialized
|
||||
*/
|
||||
isInitialized: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const i18next: i18next.i18n;
|
||||
export = i18next;
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"i18next-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"i18next": [
|
||||
"i18next/v8"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+34
-28
@@ -214,6 +214,7 @@ export type JSONSchema6Type = any[] | boolean | number | null | object | string
|
||||
* JSON Schema V6
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01
|
||||
*/
|
||||
export type JSONSchema6Definition = JSONSchema6 | boolean;
|
||||
export interface JSONSchema6 {
|
||||
$id?: string
|
||||
$ref?: string
|
||||
@@ -281,7 +282,7 @@ export interface JSONSchema6 {
|
||||
* Omitting this keyword has the same behavior as an empty schema.
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9
|
||||
*/
|
||||
items?: boolean | JSONSchema6 | JSONSchema6[]
|
||||
items?: JSONSchema6Definition | JSONSchema6Definition[]
|
||||
|
||||
/**
|
||||
* This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.
|
||||
@@ -292,7 +293,7 @@ export interface JSONSchema6 {
|
||||
* Omitting this keyword has the same behavior as an empty schema.
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10
|
||||
*/
|
||||
additionalItems?: boolean | JSONSchema6
|
||||
additionalItems?: JSONSchema6Definition
|
||||
|
||||
/**
|
||||
* Must be a non-negative integer.
|
||||
@@ -321,7 +322,7 @@ export interface JSONSchema6 {
|
||||
* An array instance is valid against "contains" if at least one of its elements is valid against the given schema.
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14
|
||||
*/
|
||||
contains?: boolean | JSONSchema6
|
||||
contains?: JSONSchema6Definition
|
||||
|
||||
/**
|
||||
* Must be a non-negative integer.
|
||||
@@ -356,7 +357,7 @@ export interface JSONSchema6 {
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18
|
||||
*/
|
||||
properties?: {
|
||||
[k: string]: boolean | JSONSchema6
|
||||
[k: string]: JSONSchema6Definition
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,7 +369,7 @@ export interface JSONSchema6 {
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19
|
||||
*/
|
||||
patternProperties?: {
|
||||
[k: string]: boolean | JSONSchema6
|
||||
[k: string]: JSONSchema6Definition
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,7 +379,7 @@ export interface JSONSchema6 {
|
||||
* The default value is an empty schema which allows any value for additional properties.
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20
|
||||
*/
|
||||
additionalProperties?: boolean | JSONSchema6
|
||||
additionalProperties?: JSONSchema6Definition
|
||||
|
||||
/**
|
||||
* This keyword specifies rules that are evaluated if the instance is an object and contains a certain property.
|
||||
@@ -388,7 +389,7 @@ export interface JSONSchema6 {
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21
|
||||
*/
|
||||
dependencies?: {
|
||||
[k: string]: boolean | JSONSchema6 | string[]
|
||||
[k: string]: JSONSchema6Definition | string[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +398,7 @@ export interface JSONSchema6 {
|
||||
* Omitting this keyword has the same behavior as an empty schema.
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22
|
||||
*/
|
||||
propertyNames?: boolean | JSONSchema6
|
||||
propertyNames?: JSONSchema6Definition
|
||||
|
||||
/**
|
||||
* This provides an enumeration of all possible values that are valid
|
||||
@@ -425,28 +426,28 @@ export interface JSONSchema6 {
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26
|
||||
*/
|
||||
allOf?: JSONSchema6[]
|
||||
allOf?: JSONSchema6Definition[]
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27
|
||||
*/
|
||||
anyOf?: JSONSchema6[]
|
||||
anyOf?: JSONSchema6Definition[]
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
|
||||
*/
|
||||
oneOf?: JSONSchema6[]
|
||||
oneOf?: JSONSchema6Definition[]
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29
|
||||
*/
|
||||
not?: boolean | JSONSchema6
|
||||
not?: JSONSchema6Definition
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1
|
||||
*/
|
||||
definitions?: {
|
||||
[k: string]: boolean | JSONSchema6
|
||||
[k: string]: JSONSchema6Definition
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,6 +509,11 @@ export type JSONSchema7Version = 'http://json-schema.org/schema#'
|
||||
| 'http://json-schema.org/draft-07/schema#'
|
||||
| 'http://json-schema.org/draft-07/hyper-schema#';
|
||||
|
||||
/**
|
||||
* JSON Schema v7
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
||||
*/
|
||||
export type JSONSchema7Definition = JSONSchema7 | boolean;
|
||||
export interface JSONSchema7 {
|
||||
$id?: string;
|
||||
$ref?: string;
|
||||
@@ -540,8 +546,8 @@ export interface JSONSchema7 {
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
||||
*/
|
||||
items?: JSONSchema7 | JSONSchema7[];
|
||||
additionalItems?: JSONSchema7;
|
||||
items?: JSONSchema7Definition | JSONSchema7Definition[];
|
||||
additionalItems?: JSONSchema7Definition;
|
||||
maxItems?: number;
|
||||
minItems?: number;
|
||||
uniqueItems?: boolean;
|
||||
@@ -554,31 +560,31 @@ export interface JSONSchema7 {
|
||||
minProperties?: number;
|
||||
required?: string[];
|
||||
properties?: {
|
||||
[key: string]: JSONSchema7;
|
||||
[key: string]: JSONSchema7Definition;
|
||||
};
|
||||
patternProperties?: {
|
||||
[key: string]: JSONSchema7;
|
||||
[key: string]: JSONSchema7Definition;
|
||||
};
|
||||
additionalProperties?: JSONSchema7;
|
||||
additionalProperties?: JSONSchema7Definition;
|
||||
dependencies?: {
|
||||
[key: string]: JSONSchema7 | string[];
|
||||
[key: string]: JSONSchema7Definition | string[];
|
||||
};
|
||||
propertyNames?: JSONSchema7;
|
||||
propertyNames?: JSONSchema7Definition;
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
||||
*/
|
||||
if?: JSONSchema7;
|
||||
then?: JSONSchema7;
|
||||
else?: JSONSchema7;
|
||||
if?: JSONSchema7Definition;
|
||||
then?: JSONSchema7Definition;
|
||||
else?: JSONSchema7Definition;
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
||||
*/
|
||||
allOf?: JSONSchema7[];
|
||||
anyOf?: JSONSchema7[];
|
||||
oneOf?: JSONSchema7[];
|
||||
not?: JSONSchema7;
|
||||
allOf?: JSONSchema7Definition[];
|
||||
anyOf?: JSONSchema7Definition[];
|
||||
oneOf?: JSONSchema7Definition[];
|
||||
not?: JSONSchema7Definition;
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
||||
@@ -595,7 +601,7 @@ export interface JSONSchema7 {
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
||||
*/
|
||||
definitions?: {
|
||||
[key: string]: JSONSchema7;
|
||||
[key: string]: JSONSchema7Definition;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,9 @@ import {
|
||||
JSONSchema7,
|
||||
JSONSchema7Array,
|
||||
JSONSchema7Type,
|
||||
JSONSchema7TypeName
|
||||
JSONSchema7TypeName,
|
||||
JSONSchema6Definition,
|
||||
JSONSchema7Definition
|
||||
} from 'json-schema'
|
||||
|
||||
/* JSON Schema 4 */
|
||||
@@ -80,6 +82,10 @@ import {
|
||||
}
|
||||
}
|
||||
|
||||
// Class
|
||||
class Schema4 implements JSONSchema4 {
|
||||
}
|
||||
|
||||
/* JSON Schema 6 */
|
||||
|
||||
// SimpleType
|
||||
@@ -96,10 +102,10 @@ import {
|
||||
const c: JSONSchema6Type = [1, 2]
|
||||
}
|
||||
|
||||
// JSONSchema6
|
||||
// JSONSchema6Definition
|
||||
() => {
|
||||
const a: JSONSchema6 = {}
|
||||
const b: JSONSchema6 = {
|
||||
const a: JSONSchema6Definition = {}
|
||||
const b: JSONSchema6Definition = {
|
||||
$id: 'foo',
|
||||
$ref: 'foo/bar',
|
||||
$schema: 'http://json-schema.org/schema#',
|
||||
@@ -149,6 +155,11 @@ import {
|
||||
propertyNames: {},
|
||||
format: 'date-time'
|
||||
}
|
||||
const c: JSONSchema6Definition = false;
|
||||
}
|
||||
|
||||
// Class
|
||||
class Schema6 implements JSONSchema6 {
|
||||
}
|
||||
|
||||
/* JSON Schema 7 */
|
||||
@@ -167,10 +178,10 @@ import {
|
||||
const c: JSONSchema7Type = [1, 2]
|
||||
}
|
||||
|
||||
// JSONSchema4
|
||||
// JSONSchema7Definition
|
||||
() => {
|
||||
const a: JSONSchema7 = {}
|
||||
const b: JSONSchema7 = {
|
||||
const a: JSONSchema7Definition = {}
|
||||
const b: JSONSchema7Definition = {
|
||||
$id: 'foo',
|
||||
$ref: 'foo/bar',
|
||||
$schema: 'http://json-schema.org/schema#',
|
||||
@@ -228,4 +239,9 @@ import {
|
||||
if: {},
|
||||
then: {}
|
||||
}
|
||||
const c: JSONSchema7Definition = false;
|
||||
}
|
||||
|
||||
// Class
|
||||
class Schema7 implements JSONSchema7 {
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -77,7 +77,7 @@ export interface StyleSheet<RuleName extends string = any> {
|
||||
export type GenerateClassName<Name extends string = any> = (rule: Rule, sheet?: StyleSheet<Name>) => string;
|
||||
|
||||
export interface JSSPlugin {
|
||||
[key: string]: () => Partial<{
|
||||
[key: string]: Partial<{
|
||||
onCreateRule(name: string, style: Style, options: RuleOptions): Rule;
|
||||
onProcessRule(rule: Rule, sheet: StyleSheet): void;
|
||||
onProcessStyle(style: Style, rule: Rule, sheet: StyleSheet): Style;
|
||||
|
||||
Vendored
+3
-3
@@ -19,8 +19,8 @@ export function sendError(req: IncomingMessage, res: ServerResponse, info: { sta
|
||||
|
||||
export function createError(code: number, msg: string, orig?: Error): Error & { statusCode: number, originalError?: Error };
|
||||
|
||||
export function buffer(req: IncomingMessage, info?: { limit?: string, encoding?: string }): Promise<Buffer | string>;
|
||||
export function buffer(req: IncomingMessage, info?: { limit?: string | number, encoding?: string }): Promise<Buffer | string>;
|
||||
|
||||
export function text(req: IncomingMessage, info?: { limit?: string, encoding?: string }): Promise<string>;
|
||||
export function text(req: IncomingMessage, info?: { limit?: string | number, encoding?: string }): Promise<string>;
|
||||
|
||||
export function json(req: IncomingMessage, info?: { limit?: string, encoding?: string }): Promise<object>;
|
||||
export function json(req: IncomingMessage, info?: { limit?: string | number, encoding?: string }): Promise<object>;
|
||||
|
||||
Vendored
+26
@@ -2832,6 +2832,32 @@ declare module "mongoose" {
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findOneAndDelete command.
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the
|
||||
* callback. Executes immediately if callback is passed.
|
||||
*/
|
||||
findOneAndDelete(): DocumentQuery<T | null, T>;
|
||||
findOneAndDelete(conditions: any,
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findOneAndDelete(conditions: any, options: {
|
||||
/**
|
||||
* if multiple docs are found by the conditions, sets the sort order to choose
|
||||
* which doc to update
|
||||
*/
|
||||
sort?: any;
|
||||
/** puts a time limit on the query - requires mongodb >= 2.6.0 */
|
||||
maxTimeMS?: number;
|
||||
/** sets the document fields to return */
|
||||
select?: any;
|
||||
/** like select, it determines which fields to return */
|
||||
projection?: any;
|
||||
/** if true, returns the raw result from the MongoDB driver */
|
||||
rawResult?: boolean;
|
||||
/** overwrites the schema's strict mode option for this update */
|
||||
strict?: boolean|string;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify update command.
|
||||
|
||||
Vendored
+37
-10
@@ -1,19 +1,46 @@
|
||||
import * as React from "react";
|
||||
import { NextContext } from ".";
|
||||
import { NextContext, NextComponentType } from ".";
|
||||
import { RouterProps, DefaultQuery } from "./router";
|
||||
|
||||
export interface AppComponentProps<Q = DefaultQuery> {
|
||||
Component: React.ComponentType<any>;
|
||||
router: RouterProps<Q>;
|
||||
pageProps: any;
|
||||
}
|
||||
// Deprecated
|
||||
export type AppComponentProps = AppProps;
|
||||
export type AppComponentContext = NextAppContext;
|
||||
// End Deprecated
|
||||
|
||||
export interface AppComponentContext<Q = DefaultQuery> {
|
||||
Component: React.ComponentType<any>;
|
||||
/**
|
||||
* Context passed to App.getInitialProps.
|
||||
* Component is dynamic - cannot infer type.
|
||||
*
|
||||
* @template Q Query object schema.
|
||||
*/
|
||||
export interface NextAppContext<Q = DefaultQuery> {
|
||||
Component: NextComponentType<any, any, NextContext<Q>>;
|
||||
router: RouterProps<Q>;
|
||||
ctx: NextContext<Q>;
|
||||
}
|
||||
|
||||
export class Container extends React.Component { }
|
||||
/**
|
||||
* Props passed to the App component.
|
||||
* Component and pageProps are dynamic - cannot infer type.
|
||||
*
|
||||
* @template Q Query object schema.
|
||||
*/
|
||||
export interface AppProps<Q = DefaultQuery> {
|
||||
Component: NextComponentType<any, any, NextContext<Q>>;
|
||||
router: RouterProps<Q>;
|
||||
pageProps: any;
|
||||
}
|
||||
|
||||
export default class App<TProps = {}, Q = DefaultQuery> extends React.Component<TProps & AppComponentProps<Q>> { }
|
||||
/**
|
||||
* App component type. Differs from the default type because the context it passes
|
||||
* to getInitialProps and the props is passes to the component are different.
|
||||
*
|
||||
* @template IP Initial props returned from getInitialProps.
|
||||
* @template C Context passed to getInitialProps.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
Vendored
+39
-8
@@ -1,6 +1,6 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { NextContext } from ".";
|
||||
import { NextContext, NextComponentType } from ".";
|
||||
import { DefaultQuery } from "./router";
|
||||
|
||||
export interface RenderPageResponse {
|
||||
buildManifest: { [key: string]: any };
|
||||
@@ -21,16 +21,25 @@ export interface AnyPageProps extends PageProps {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type Enhancer<E extends PageProps = AnyPageProps, P extends any = E> = (page: React.ComponentType<P>) => React.ComponentType<E>;
|
||||
export type Enhancer<E extends PageProps = AnyPageProps, P extends any = E> = (
|
||||
page: React.ComponentType<P>
|
||||
) => React.ComponentType<E>;
|
||||
|
||||
/**
|
||||
* Context object used inside `Document`
|
||||
* Context passed to Document.getInitialProps.
|
||||
*
|
||||
* @template Q Query object schema.
|
||||
*/
|
||||
export interface NextDocumentContext extends NextContext {
|
||||
export interface NextDocumentContext<Q = 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>): RenderPageResponse; // tslint:disable-line:no-unnecessary-generics
|
||||
renderPage<E extends PageProps = AnyPageProps, P extends any = E>(
|
||||
enhancer?: Enhancer<E, P> // tslint:disable-line no-unnecessary-generics
|
||||
): RenderPageResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Props passed to the Document component.
|
||||
*/
|
||||
export interface DocumentProps {
|
||||
__NEXT_DATA__?: any;
|
||||
dev?: boolean;
|
||||
@@ -45,18 +54,40 @@ export interface DocumentProps {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Props supported by the Head component.
|
||||
*/
|
||||
export interface HeadProps {
|
||||
nonce?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Props supported by the NextScript component.
|
||||
*/
|
||||
export interface NextScriptProps {
|
||||
nonce?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Document component type. Differs from the default type because the context it passes
|
||||
* to getInitialProps and the props is passes to the component are different.
|
||||
*
|
||||
* @template IP Initial props returned from getInitialProps.
|
||||
* @template C Context passed to getInitialProps.
|
||||
*/
|
||||
export type DocumentComponentType<IP = {}, C = NextDocumentContext> = NextComponentType<
|
||||
IP & DocumentProps,
|
||||
IP,
|
||||
C
|
||||
>;
|
||||
|
||||
export class Head extends React.Component<HeadProps> {}
|
||||
export class Main extends React.Component {}
|
||||
export class NextScript extends React.Component<NextScriptProps> {}
|
||||
export default class Document<TProps = {}> extends React.Component<TProps & DocumentProps> {
|
||||
static getInitialProps(ctx: NextDocumentContext): Promise<DocumentProps> | DocumentProps;
|
||||
export default class Document<IP = {}, C = NextDocumentContext> extends React.Component<
|
||||
IP & DocumentProps
|
||||
> {
|
||||
getInitialProps(context: C): Promise<IP> | IP;
|
||||
}
|
||||
|
||||
Vendored
+55
-18
@@ -16,16 +16,22 @@ import * as url from "url";
|
||||
|
||||
import { Response as NodeResponse } from "node-fetch";
|
||||
|
||||
import { SingletonRouter, DefaultQuery } from './router';
|
||||
import { SingletonRouter, DefaultQuery } from "./router";
|
||||
|
||||
declare namespace next {
|
||||
// Deprecated
|
||||
type QueryStringMapObject = DefaultQuery;
|
||||
type ServerConfig = NextConfig;
|
||||
// End Deprecated
|
||||
|
||||
type UrlLike = url.UrlObject | url.Url;
|
||||
|
||||
/**
|
||||
* Context object used in methods like `getInitialProps()`
|
||||
* https://github.com/zeit/next.js/blob/6.1.1/server/render.js#L77
|
||||
* https://github.com/zeit/next.js/blob/6.1.1/readme.md#fetching-data-and-component-lifecycle
|
||||
*
|
||||
* @template Q Query object schema.
|
||||
*/
|
||||
interface NextContext<Q = DefaultQuery> {
|
||||
/** path section of URL */
|
||||
@@ -44,19 +50,11 @@ declare namespace next {
|
||||
err?: Error;
|
||||
}
|
||||
|
||||
type NextSFC<TProps = {}, Q = DefaultQuery> = NextStatelessComponent<TProps, Q>;
|
||||
interface NextStatelessComponent<TProps = {}, Q = DefaultQuery>
|
||||
extends React.StatelessComponent<TProps> {
|
||||
getInitialProps?: (ctx: NextContext<Q>) => Promise<TProps>;
|
||||
}
|
||||
|
||||
type UrlLike = url.UrlObject | url.Url;
|
||||
|
||||
/**
|
||||
* Next.js config schema.
|
||||
* https://github.com/zeit/next.js/blob/6.1.1/server/config.js#L10
|
||||
*/
|
||||
interface ServerConfig {
|
||||
interface NextConfig {
|
||||
webpack?: any;
|
||||
webpackDevMiddleware?: any;
|
||||
poweredByHeader?: boolean;
|
||||
@@ -83,7 +81,7 @@ declare namespace next {
|
||||
dev?: boolean;
|
||||
staticMarkup?: boolean;
|
||||
quiet?: boolean;
|
||||
conf?: ServerConfig;
|
||||
conf?: NextConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +95,7 @@ declare namespace next {
|
||||
quiet: boolean;
|
||||
router: SingletonRouter;
|
||||
http: null | http.Server;
|
||||
nextConfig: ServerConfig;
|
||||
nextConfig: NextConfig;
|
||||
distDir: string;
|
||||
buildId: string;
|
||||
hotReloader: any;
|
||||
@@ -114,7 +112,7 @@ declare namespace next {
|
||||
|
||||
getHotReloader(
|
||||
dir: string,
|
||||
options: { quiet: boolean; config: ServerConfig; buildId: string }
|
||||
options: { quiet: boolean; config: NextConfig; buildId: string }
|
||||
): any;
|
||||
handleRequest(
|
||||
req: http.IncomingMessage,
|
||||
@@ -132,11 +130,7 @@ declare namespace next {
|
||||
close(): Promise<void>;
|
||||
defineRoutes(): Promise<void>;
|
||||
start(): Promise<void>;
|
||||
run(
|
||||
req: http.IncomingMessage,
|
||||
res: http.ServerResponse,
|
||||
parsedUrl: UrlLike
|
||||
): Promise<void>;
|
||||
run(req: http.IncomingMessage, res: http.ServerResponse, parsedUrl: UrlLike): Promise<void>;
|
||||
|
||||
render(
|
||||
req: http.IncomingMessage,
|
||||
@@ -182,6 +176,49 @@ declare namespace next {
|
||||
getCompilationError(): Promise<any>;
|
||||
send404(res: http.ServerResponse): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next.js counterpart of React.ComponentType.
|
||||
* Specially useful in HOCs that receive Next.js components.
|
||||
*
|
||||
* @template P Component props.
|
||||
* @template IP Initial props returned from getInitialProps.
|
||||
* @template C Context passed to getInitialProps.
|
||||
*/
|
||||
type NextComponentType<P = {}, IP = P, C = NextContext> =
|
||||
| NextComponentClass<P, IP, C>
|
||||
| NextStatelessComponent<P, IP, C>;
|
||||
|
||||
/**
|
||||
* Next.js counterpart of React.SFC/React.StatelessComponent.
|
||||
*
|
||||
* @template P Component props.
|
||||
* @template IP Initial props returned from getInitialProps.
|
||||
* @template C Context passed to getInitialProps.
|
||||
*/
|
||||
type NextSFC<P = {}, IP = P, C = NextContext> = NextStatelessComponent<P, IP, C>;
|
||||
type NextStatelessComponent<P = {}, IP = P, C = NextContext> = React.StatelessComponent<P> &
|
||||
NextStaticLifecycle<IP, C>;
|
||||
|
||||
/**
|
||||
* Next.js counterpart of React.ComponentClass.
|
||||
*
|
||||
* @template P Component props.
|
||||
* @template IP Initial props returned from getInitialProps.
|
||||
* @template C Context passed to getInitialProps.
|
||||
*/
|
||||
type NextComponentClass<P = {}, IP = P, C = NextContext> = React.ComponentClass<P> &
|
||||
NextStaticLifecycle<IP, C>;
|
||||
|
||||
/**
|
||||
* Next.js specific lifecycle methods.
|
||||
*
|
||||
* @template IP Initial props returned from getInitialProps and passed to the component.
|
||||
* @template C Context passed to getInitialProps.
|
||||
*/
|
||||
interface NextStaticLifecycle<IP, C> {
|
||||
getInitialProps?: (ctx: C) => Promise<IP> | IP;
|
||||
}
|
||||
}
|
||||
|
||||
declare function next(options?: next.ServerOptions): next.Server;
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
import * as React from "react";
|
||||
import App, { Container, AppComponentContext } from "next/app";
|
||||
import { NextStatelessComponent } from "next";
|
||||
import App, { Container, NextAppContext, AppProps, AppComponentType } from "next/app";
|
||||
|
||||
interface NextComponentProps {
|
||||
example: string;
|
||||
}
|
||||
|
||||
class TestApp extends App<NextComponentProps> {
|
||||
static async getInitialProps({ Component, router, ctx }: AppComponentContext) {
|
||||
let pageProps = {};
|
||||
// TODO: fix AppComponentContext to return NextComponentType instead of React.ComponentType
|
||||
const Page = Component as NextStatelessComponent;
|
||||
|
||||
if (Page.getInitialProps) {
|
||||
pageProps = await Page.getInitialProps(ctx);
|
||||
}
|
||||
|
||||
return { pageProps };
|
||||
}
|
||||
interface TypedQuery {
|
||||
id?: string;
|
||||
}
|
||||
|
||||
class TestApp extends App {
|
||||
render() {
|
||||
const { Component, router, pageProps } = this.props;
|
||||
return (
|
||||
@@ -28,3 +19,78 @@ class TestApp extends App<NextComponentProps> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestAppWithProps extends App<NextComponentProps> {
|
||||
static async getInitialProps({ Component, router, ctx }: NextAppContext) {
|
||||
const pageProps = Component.getInitialProps && (await Component.getInitialProps(ctx));
|
||||
return { pageProps, example: "foobar" };
|
||||
}
|
||||
|
||||
render() {
|
||||
const { Component, router, pageProps, example } = this.props;
|
||||
return <Component {...pageProps} example={example} />;
|
||||
}
|
||||
}
|
||||
|
||||
class TestAppWithTypedQuery extends App<{}, NextAppContext<TypedQuery>> {
|
||||
static async getInitialProps({ ctx }: NextAppContext<TypedQuery>) {
|
||||
const { id } = ctx.query;
|
||||
const processQuery = (id?: string) => id;
|
||||
processQuery(id);
|
||||
}
|
||||
}
|
||||
|
||||
interface WithExampleProps {
|
||||
example: string;
|
||||
}
|
||||
|
||||
interface WithExampleHocProps {
|
||||
test: string;
|
||||
}
|
||||
|
||||
interface TestProps {
|
||||
ownProp: boolean;
|
||||
}
|
||||
|
||||
// Stateful HOC that adds props to wrapped component. Similar to what withRedux does.
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const withExample = <P extends {}>(App: AppComponentType<P & WithExampleProps>) =>
|
||||
class extends React.Component<P & AppProps & WithExampleHocProps> {
|
||||
test: string;
|
||||
|
||||
static async getInitialProps(context: NextAppContext) {
|
||||
const pageProps = App.getInitialProps && (await App.getInitialProps(context));
|
||||
|
||||
// tslint:disable-next-line prefer-object-spread
|
||||
return Object.assign({}, pageProps, { test: "test" });
|
||||
}
|
||||
|
||||
constructor(props: P & AppProps & WithExampleHocProps) {
|
||||
super(props);
|
||||
this.test = props.test;
|
||||
}
|
||||
|
||||
render() {
|
||||
return <App {...this.props} example={this.test} />;
|
||||
}
|
||||
};
|
||||
|
||||
// Basic stateless HOC. Similar to what withAuth would do.
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const withBasic = <P extends {}, C extends {}>(App: AppComponentType<P, C>) =>
|
||||
class extends React.Component<P & AppProps> {
|
||||
static async getInitialProps(context: C) {
|
||||
const pageProps = App.getInitialProps && (await App.getInitialProps(context));
|
||||
|
||||
// tslint:disable-next-line prefer-object-spread
|
||||
return Object.assign({}, pageProps);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <App {...this.props} />;
|
||||
}
|
||||
};
|
||||
|
||||
withExample(TestAppWithProps);
|
||||
|
||||
withBasic(TestAppWithTypedQuery);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from "react";
|
||||
import { NextStatelessComponent, NextContext } from "next";
|
||||
import { NextStatelessComponent, NextContext, NextComponentType } from "next";
|
||||
|
||||
interface NextComponentProps {
|
||||
example: string;
|
||||
@@ -12,13 +12,11 @@ interface TypedQuery {
|
||||
class ClassNext extends React.Component<NextComponentProps> {
|
||||
static async getInitialProps(ctx: NextContext) {
|
||||
const { example } = ctx.query;
|
||||
return { example };
|
||||
return { example: example as string };
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>I'm a class component! {this.props.example}</div>
|
||||
);
|
||||
return <div>I'm a class component! {this.props.example}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,3 +36,87 @@ StatelessNext.getInitialProps = async ({ query }: NextContext) => {
|
||||
const { example } = query;
|
||||
return { example: example as string };
|
||||
};
|
||||
|
||||
interface WithExampleProps {
|
||||
example: string;
|
||||
}
|
||||
|
||||
interface WithExampleHocProps {
|
||||
test: string;
|
||||
}
|
||||
|
||||
interface TestProps {
|
||||
ownProp: boolean;
|
||||
}
|
||||
|
||||
// Stateful HOC that adds props to wrapped component. Similar to what withRedux does.
|
||||
// tslint:disable-next-line use-default-type-parameter
|
||||
const withExample = <P extends {}>(Page: NextComponentType<P & WithExampleProps, P>) =>
|
||||
class extends React.Component<P & WithExampleHocProps> {
|
||||
test: string;
|
||||
|
||||
static async getInitialProps(ctx: NextContext) {
|
||||
const pageProps = Page.getInitialProps && (await Page.getInitialProps(ctx));
|
||||
|
||||
// tslint:disable-next-line prefer-object-spread
|
||||
return Object.assign({}, pageProps, { test: "test" });
|
||||
}
|
||||
|
||||
constructor(props: P & WithExampleHocProps) {
|
||||
super(props);
|
||||
this.test = props.test;
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Page {...this.props} example={this.test} />;
|
||||
}
|
||||
};
|
||||
|
||||
// Basic stateless HOC. Similar to what withAuth would do.
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const withBasic = <P extends {}>(Page: NextComponentType<P>) =>
|
||||
class extends React.Component<P> {
|
||||
static async getInitialProps(ctx: NextContext) {
|
||||
const pageProps = Page.getInitialProps && (await Page.getInitialProps(ctx));
|
||||
|
||||
// tslint:disable-next-line prefer-object-spread
|
||||
const props = Object.assign({}, pageProps);
|
||||
|
||||
if (ctx.query.example === "bar") {
|
||||
// Redirect
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Page {...this.props} />;
|
||||
}
|
||||
};
|
||||
|
||||
class NextWithExample extends React.Component<TestProps & WithExampleProps> {
|
||||
static async getInitialProps(ctx: NextContext<TypedQuery>) {
|
||||
const { id } = ctx.query;
|
||||
const processQuery = (id?: string) => id;
|
||||
processQuery(id);
|
||||
return { ownProp: true };
|
||||
}
|
||||
|
||||
render() {
|
||||
const { ownProp, example } = this.props;
|
||||
return (
|
||||
<div>
|
||||
I'm wrapped in a HOC that gives me an example prop! {example} {ownProp}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// P template is inferred as <TestProps>.
|
||||
withExample(NextWithExample);
|
||||
|
||||
// P template inferred as <NextComponentProps>.
|
||||
withBasic(ClassNext);
|
||||
|
||||
// P template inferred as <TestProps & WithExampleProps>
|
||||
withBasic(withExample(NextWithExample));
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for obj-str 1.0
|
||||
// Project: https://github.com/lukeed/obj-str#readme
|
||||
// Definitions by: Sascha Englert <https://github.com/saenglert>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = objstr;
|
||||
|
||||
declare function objstr(obj: { [name: string]: boolean }): string;
|
||||
@@ -0,0 +1,6 @@
|
||||
import objstr = require('obj-str');
|
||||
|
||||
const isTrue = () => true;
|
||||
|
||||
objstr({ foo: true, bar: false, baz: isTrue() });
|
||||
// => 'foo baz'
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"strictFunctionTypes": true,
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "obj-str-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+6267
-40
File diff suppressed because it is too large
Load Diff
Vendored
+1
-2
@@ -290,8 +290,7 @@ declare namespace PIXI {
|
||||
|
||||
protected onChildrenChange: (...args: any[]) => void;
|
||||
addChild<T extends DisplayObject>(
|
||||
child: T,
|
||||
...additionalChildren: DisplayObject[]
|
||||
...children: T[]
|
||||
): T;
|
||||
addChildAt<T extends DisplayObject>(child: T, index: number): T;
|
||||
swapChildren(child: DisplayObject, child2: DisplayObject): void;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface Source {
|
||||
fileName: string;
|
||||
lineNumber: number;
|
||||
}
|
||||
-130
@@ -1,130 +0,0 @@
|
||||
import { Source } from './ReactElementType';
|
||||
import { ExpirationTime } from './ReactFiberExpirationTime';
|
||||
import { ContextDependency } from './ReactFiberNewContext';
|
||||
import { SideEffectTag } from './ReactSideEffectTags';
|
||||
import { TypeOfMode } from './ReactTypeOfMode';
|
||||
import { RefObject } from './ReactTypes';
|
||||
import { UpdateQueue } from './ReactUpdateQueue';
|
||||
import { WorkTag } from './ReactWorkTags';
|
||||
|
||||
// A Fiber is work on a Component that needs to be done or was done. There can
|
||||
// be more than one per component.
|
||||
export interface Fiber {
|
||||
// These first fields are conceptually members of an Instance. This used to
|
||||
// be split into a separate type and intersected with the other Fiber fields,
|
||||
// but until Flow fixes its intersection bugs, we've merged them into a
|
||||
// single type.
|
||||
|
||||
// An Instance is shared between all versions of a component. We can easily
|
||||
// break this out into a separate object to avoid copying so much to the
|
||||
// alternate versions of the tree. We put this on a single object for now to
|
||||
// minimize the number of objects created during the initial render.
|
||||
|
||||
// Tag identifying the type of fiber.
|
||||
tag: WorkTag;
|
||||
|
||||
// Unique identifier of this child.
|
||||
key: null | string;
|
||||
|
||||
// The function/class/module associated with this fiber.
|
||||
type: any;
|
||||
|
||||
// The local state associated with this fiber.
|
||||
stateNode: any;
|
||||
|
||||
// Conceptual aliases
|
||||
// parent : Instance -> return The parent happens to be the same as the
|
||||
// return fiber since we've merged the fiber and instance.
|
||||
|
||||
// Remaining fields belong to Fiber
|
||||
|
||||
// The Fiber to return to after finishing processing this one.
|
||||
// This is effectively the parent, but there can be multiple parents (two)
|
||||
// so this is only the parent of the thing we're currently processing.
|
||||
// It is conceptually the same as the return address of a stack frame.
|
||||
return: Fiber | null;
|
||||
|
||||
// Singly Linked List Tree Structure.
|
||||
child: Fiber | null;
|
||||
sibling: Fiber | null;
|
||||
index: number;
|
||||
|
||||
// The ref last used to attach this node.
|
||||
// I'll avoid adding an owner field for prod and model that as functions.
|
||||
ref: null | (((handle: any) => void) & { _stringRef: string | null | undefined }) | RefObject;
|
||||
|
||||
// Input is the data coming into process this fiber. Arguments. Props.
|
||||
pendingProps: any; // This type will be more specific once we overload the tag.
|
||||
memoizedProps: any; // The props used to create the output.
|
||||
|
||||
// A queue of state updates and callbacks.
|
||||
updateQueue: UpdateQueue<any> | null;
|
||||
|
||||
// The state used to create the output
|
||||
memoizedState: any;
|
||||
|
||||
// A linked-list of contexts that this fiber depends on
|
||||
firstContextDependency: ContextDependency<any> | null;
|
||||
|
||||
// Bitfield that describes properties about the fiber and its subtree. E.g.
|
||||
// the AsyncMode flag indicates whether the subtree should be async-by-
|
||||
// default. When a fiber is created, it inherits the mode of its
|
||||
// parent. Additional flags can be set at creation time, but after that the
|
||||
// value should remain unchanged throughout the fiber's lifetime, particularly
|
||||
// before its child fibers are created.
|
||||
mode: TypeOfMode;
|
||||
|
||||
// Effect
|
||||
effectTag: SideEffectTag;
|
||||
|
||||
// Singly linked list fast path to the next fiber with side-effects.
|
||||
nextEffect: Fiber | null;
|
||||
|
||||
// The first and last fiber with side-effect within this subtree. This allows
|
||||
// us to reuse a slice of the linked list when we reuse the work done within
|
||||
// this fiber.
|
||||
firstEffect: Fiber | null;
|
||||
lastEffect: Fiber | null;
|
||||
|
||||
// Represents a time in the future by which this work should be completed.
|
||||
// Does not include work found in its subtree.
|
||||
expirationTime: ExpirationTime;
|
||||
|
||||
// This is used to quickly determine if a subtree has no pending changes.
|
||||
childExpirationTime: ExpirationTime;
|
||||
|
||||
// This is a pooled version of a Fiber. Every fiber that gets updated will
|
||||
// eventually have a pair. There are cases when we can clean up pairs to save
|
||||
// memory if we need to.
|
||||
alternate: Fiber | null;
|
||||
|
||||
// Time spent rendering this Fiber and its descendants for the current update.
|
||||
// This tells us how well the tree makes use of sCU for memoization.
|
||||
// It is reset to 0 each time we render and only updated when we don't bailout.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
actualDuration?: number;
|
||||
|
||||
// If the Fiber is currently active in the "render" phase,
|
||||
// This marks the time at which the work began.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
actualStartTime?: number;
|
||||
|
||||
// Duration of the most recent render time for this Fiber.
|
||||
// This value is not updated when we bailout for memoization purposes.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
selfBaseDuration?: number;
|
||||
|
||||
// Sum of base times for all descedents of this Fiber.
|
||||
// This value bubbles up during the "complete" phase.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
treeBaseDuration?: number;
|
||||
|
||||
// Conceptual aliases
|
||||
// workInProgress : Fiber -> alternate The alternate used for reuse happens
|
||||
// to be the same as work in progress.
|
||||
// __DEV__ only
|
||||
_debugID?: number;
|
||||
_debugSource?: Source | null;
|
||||
_debugOwner?: Fiber | null;
|
||||
_debugIsCurrentlyTiming?: boolean;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export type ExpirationTime = number;
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ReactContext } from './ReactTypes';
|
||||
|
||||
export interface ContextDependency<T> {
|
||||
context: ReactContext<T>;
|
||||
observedBits: number;
|
||||
next: ContextDependency<any> | null;
|
||||
}
|
||||
-255
@@ -1,255 +0,0 @@
|
||||
import { Component } from 'react';
|
||||
import { Fiber } from './ReactFiber';
|
||||
import { ExpirationTime } from './ReactFiberExpirationTime';
|
||||
import { FiberRoot } from './ReactFiberRoot';
|
||||
import { Deadline } from './ReactFiberScheduler';
|
||||
import { ReactNodeList } from './ReactTypes';
|
||||
|
||||
export type OpaqueHandle = Fiber;
|
||||
export type OpaqueRoot = FiberRoot;
|
||||
|
||||
export interface HostConfig<Type, Props, Container, Instance, TextInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout> {
|
||||
getPublicInstance(instance: Instance | TextInstance): PublicInstance;
|
||||
getRootHostContext(rootContainerInstance: Container): HostContext;
|
||||
getChildHostContext(parentHostContext: HostContext, type: Type, rootContainerInstance: Container): HostContext;
|
||||
|
||||
prepareForCommit(containerInfo: Container): void;
|
||||
resetAfterCommit(containerInfo: Container): void;
|
||||
|
||||
createInstance(
|
||||
type: Type,
|
||||
props: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): Instance;
|
||||
appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
|
||||
finalizeInitialChildren(
|
||||
parentInstance: Instance,
|
||||
type: Type,
|
||||
props: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
): boolean;
|
||||
|
||||
prepareUpdate(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
): null | UpdatePayload;
|
||||
|
||||
shouldSetTextContent(type: Type, props: Props): boolean;
|
||||
shouldDeprioritizeSubtree(type: Type, props: Props): boolean;
|
||||
|
||||
createTextInstance(
|
||||
text: string,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): TextInstance;
|
||||
|
||||
scheduleDeferredCallback(
|
||||
callback: (deadline: Deadline) => void,
|
||||
options?: { timeout: number },
|
||||
): any;
|
||||
cancelDeferredCallback(callbackID: any): void;
|
||||
|
||||
setTimeout(handler: (...args: any[]) => void, timeout: number): TimeoutHandle | NoTimeout;
|
||||
clearTimeout(handle: TimeoutHandle | NoTimeout): void;
|
||||
noTimeout: NoTimeout;
|
||||
|
||||
now(): number;
|
||||
|
||||
// Temporary workaround for scenario where multiple renderers concurrently
|
||||
// render using the same context objects. E.g. React DOM and React ART on the
|
||||
// same page. DOM is the primary renderer; ART is the secondary renderer.
|
||||
isPrimaryRenderer: boolean;
|
||||
|
||||
supportsMutation: boolean;
|
||||
supportsPersistence: boolean;
|
||||
supportsHydration: boolean;
|
||||
|
||||
// -------------------
|
||||
// Mutation
|
||||
// (optional)
|
||||
// -------------------
|
||||
appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
|
||||
appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
|
||||
commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
|
||||
commitMount?(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): void;
|
||||
commitUpdate?(
|
||||
instance: Instance,
|
||||
updatePayload: UpdatePayload,
|
||||
type: Type,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): void;
|
||||
insertBefore?(parentInstance: Instance, child: Instance | TextInstance, beforeChild: Instance | TextInstance): void;
|
||||
insertInContainerBefore?(
|
||||
container: Container,
|
||||
child: Instance | TextInstance,
|
||||
beforeChild: Instance | TextInstance,
|
||||
): void;
|
||||
removeChild?(parentInstance: Instance, child: Instance | TextInstance): void;
|
||||
removeChildFromContainer?(container: Container, child: Instance | TextInstance): void;
|
||||
resetTextContent?(instance: Instance): void;
|
||||
|
||||
// -------------------
|
||||
// Persistence
|
||||
// (optional)
|
||||
// -------------------
|
||||
cloneInstance?(
|
||||
instance: Instance,
|
||||
updatePayload: null | UpdatePayload,
|
||||
type: Type,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
keepChildren: boolean,
|
||||
recyclableInstance: Instance,
|
||||
): Instance;
|
||||
|
||||
createContainerChildSet?(container: Container): ChildSet;
|
||||
|
||||
appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
|
||||
finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
|
||||
|
||||
replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
|
||||
|
||||
// -------------------
|
||||
// Hydration
|
||||
// (optional)
|
||||
// -------------------
|
||||
canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
|
||||
canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
|
||||
getNextHydratableSibling?(instance: Instance | TextInstance | HydratableInstance): null | HydratableInstance;
|
||||
getFirstHydratableChild?(parentInstance: Instance | Container): null | HydratableInstance;
|
||||
hydrateInstance?(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
props: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): null | UpdatePayload;
|
||||
hydrateTextInstance?(
|
||||
textInstance: TextInstance,
|
||||
text: string,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): boolean;
|
||||
didNotMatchHydratedContainerTextInstance?(
|
||||
parentContainer: Container,
|
||||
textInstance: TextInstance,
|
||||
text: string,
|
||||
): void;
|
||||
didNotMatchHydratedTextInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
textInstance: TextInstance,
|
||||
text: string,
|
||||
): void;
|
||||
didNotHydrateContainerInstance?(parentContainer: Container, instance: Instance | TextInstance): void;
|
||||
didNotHydrateInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
instance: Instance | TextInstance,
|
||||
): void;
|
||||
didNotFindHydratableContainerInstance?(
|
||||
parentContainer: Container,
|
||||
type: Type,
|
||||
props: Props,
|
||||
): void;
|
||||
didNotFindHydratableContainerTextInstance?(
|
||||
parentContainer: Container,
|
||||
text: string,
|
||||
): void;
|
||||
didNotFindHydratableInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
type: Type,
|
||||
props: Props,
|
||||
): void;
|
||||
didNotFindHydratableTextInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
text: string,
|
||||
): void;
|
||||
}
|
||||
|
||||
// 0 is PROD, 1 is DEV.
|
||||
// Might add PROFILE later.
|
||||
export type BundleType = 0 | 1;
|
||||
|
||||
export interface DevToolsConfig<Instance, TextInstance> {
|
||||
bundleType: BundleType;
|
||||
version: string;
|
||||
rendererPackageName: string;
|
||||
// Note: this actually *does* depend on Fiber internal fields.
|
||||
// Used by "inspect clicked DOM element" in React DevTools.
|
||||
findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber;
|
||||
// Used by RN in-app inspector.
|
||||
// This API is unfortunately RN-specific.
|
||||
// TODO: Change it to accept Fiber instead and type it properly.
|
||||
getInspectorDataForViewTag?: (tag: number) => object;
|
||||
}
|
||||
|
||||
export interface Reconciler<Instance, TextInstance, Container, PublicInstance> {
|
||||
updateContainerAtExpirationTime(
|
||||
element: ReactNodeList,
|
||||
container: OpaqueRoot,
|
||||
parentComponent: Component<any, any> | null | undefined,
|
||||
expirationTime: ExpirationTime,
|
||||
callback: () => void | null | undefined,
|
||||
): ExpirationTime;
|
||||
createContainer(
|
||||
containerInfo: Container,
|
||||
isAsync: boolean,
|
||||
hydrate: boolean,
|
||||
): OpaqueRoot;
|
||||
updateContainer(
|
||||
element: ReactNodeList,
|
||||
container: OpaqueRoot,
|
||||
parentComponent: Component<any, any> | null | undefined,
|
||||
callback: () => void | null | undefined,
|
||||
): ExpirationTime;
|
||||
flushRoot(root: OpaqueRoot, expirationTime: ExpirationTime): void;
|
||||
requestWork(root: OpaqueRoot, expirationTime: ExpirationTime): void;
|
||||
computeUniqueAsyncExpiration(): ExpirationTime;
|
||||
batchedUpdates<A>(fn: () => A): A;
|
||||
unbatchedUpdates<A>(fn: () => A): A;
|
||||
deferredUpdates<A>(fn: () => A): A;
|
||||
syncUpdates<A>(fn: () => A): A;
|
||||
interactiveUpdates<A>(fn: () => A): A;
|
||||
flushInteractiveUpdates(): void;
|
||||
flushControlled(fn: () => any): void;
|
||||
flushSync<A>(fn: () => A): A;
|
||||
|
||||
// Used to extract the return value from the initial render. Legacy API.
|
||||
getPublicRootInstance(
|
||||
container: OpaqueRoot,
|
||||
): Component<any, any> | PublicInstance | null;
|
||||
|
||||
// Use for findDOMNode/findHostNode. Legacy API.
|
||||
findHostInstance(component: object): PublicInstance | null;
|
||||
|
||||
// Used internally for filtering out portals. Legacy API.
|
||||
findHostInstanceWithNoPortals(component: Fiber): PublicInstance | null;
|
||||
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance>): boolean;
|
||||
}
|
||||
|
||||
export default function <Type, Props, Container, Instance, TextInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>(
|
||||
config: HostConfig<Type, Props, Container, Instance, TextInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>,
|
||||
): Reconciler<Instance, TextInstance, Container, PublicInstance>;
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
import { Fiber } from './ReactFiber';
|
||||
import { ExpirationTime } from './ReactFiberExpirationTime';
|
||||
import { Interaction } from './Tracking';
|
||||
|
||||
// TODO: This should be lifted into the renderer.
|
||||
export interface Batch {
|
||||
_defer: boolean;
|
||||
_expirationTime: ExpirationTime;
|
||||
_onComplete: () => any;
|
||||
_next: Batch | null;
|
||||
}
|
||||
|
||||
export type PendingInteractionMap = Map<ExpirationTime, Set<Interaction>>;
|
||||
|
||||
export interface BaseFiberRootProperties {
|
||||
// Any additional information from the host associated with this root.
|
||||
containerInfo: any;
|
||||
// Used only by persistent updates.
|
||||
pendingChildren: any;
|
||||
// The currently active root fiber. This is the mutable root of the tree.
|
||||
current: Fiber;
|
||||
|
||||
// The following priority levels are used to distinguish between 1)
|
||||
// uncommitted work, 2) uncommitted work that is suspended, and 3) uncommitted
|
||||
// work that may be unsuspended. We choose not to track each individual
|
||||
// pending level, trading granularity for performance.
|
||||
//
|
||||
// The earliest and latest priority levels that are suspended from committing.
|
||||
earliestSuspendedTime: ExpirationTime;
|
||||
latestSuspendedTime: ExpirationTime;
|
||||
// The earliest and latest priority levels that are not known to be suspended.
|
||||
earliestPendingTime: ExpirationTime;
|
||||
latestPendingTime: ExpirationTime;
|
||||
// The latest priority level that was pinged by a resolved promise and can
|
||||
// be retried.
|
||||
latestPingedTime: ExpirationTime;
|
||||
|
||||
// If an error is thrown, and there are no more updates in the queue, we try
|
||||
// rendering from the root one more time, synchronously, before handling
|
||||
// the error.
|
||||
didError: boolean;
|
||||
|
||||
pendingCommitExpirationTime: ExpirationTime;
|
||||
// A finished work-in-progress HostRoot that's ready to be committed.
|
||||
finishedWork: Fiber | null;
|
||||
// Timeout handle returned by setTimeout. Used to cancel a pending timeout, if
|
||||
// it's superseded by a new one.
|
||||
timeoutHandle: any;
|
||||
// Top context object, used by renderSubtreeIntoContainer
|
||||
context: object | null;
|
||||
pendingContext: object | null;
|
||||
// Determines if we should attempt to hydrate on the initial mount
|
||||
readonly hydrate: boolean;
|
||||
// Remaining expiration time on this root.
|
||||
// TODO: Lift this into the renderer
|
||||
nextExpirationTimeToWorkOn: ExpirationTime;
|
||||
expirationTime: ExpirationTime;
|
||||
// List of top-level batches. This list indicates whether a commit should be
|
||||
// deferred. Also contains completion callbacks.
|
||||
// TODO: Lift this into the renderer
|
||||
firstBatch: Batch | null;
|
||||
// Linked-list of roots
|
||||
nextScheduledRoot: FiberRoot | null;
|
||||
}
|
||||
|
||||
// The following attributes are only used by interaction tracking builds.
|
||||
// They enable interactions to be associated with their async work,
|
||||
// And expose interaction metadata to the React DevTools Profiler plugin.
|
||||
// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled.
|
||||
export interface ProfilingOnlyFiberRootProperties {
|
||||
interactionThreadID: number;
|
||||
memoizedInteractions: Set<Interaction>;
|
||||
pendingInteractionMap: PendingInteractionMap;
|
||||
}
|
||||
|
||||
export type FiberRoot = BaseFiberRootProperties & ProfilingOnlyFiberRootProperties;
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface Deadline {
|
||||
timeRemaining: () => number;
|
||||
didTimeout: boolean;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export type SideEffectTag = number;
|
||||
-1
@@ -1 +0,0 @@
|
||||
export type TypeOfMode = number;
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
export type ReactEmpty = null | undefined | boolean;
|
||||
|
||||
export type ReactNodeList = ReactEmpty | ReactNode;
|
||||
|
||||
export interface ReactProviderType<T> {
|
||||
$$typeof: symbol | number;
|
||||
_context: ReactContext<T>;
|
||||
}
|
||||
|
||||
export interface ReactContext<T> {
|
||||
$$typeof: symbol | number;
|
||||
Consumer: ReactContext<T>;
|
||||
Provider: ReactProviderType<T>;
|
||||
unstable_read: () => T;
|
||||
|
||||
_calculateChangedBits: ((a: T, b: T) => number) | null;
|
||||
|
||||
_currentValue: T;
|
||||
_currentValue2: T;
|
||||
|
||||
// DEV only
|
||||
_currentRenderer?: object | null;
|
||||
_currentRenderer2?: object | null;
|
||||
}
|
||||
|
||||
export interface RefObject {
|
||||
current: any;
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
import { ExpirationTime } from './ReactFiberExpirationTime';
|
||||
|
||||
export interface Update<State> {
|
||||
expirationTime: ExpirationTime;
|
||||
|
||||
tag: 0 | 1 | 2 | 3;
|
||||
payload: any;
|
||||
callback: (() => any) | null;
|
||||
|
||||
next: Update<State> | null;
|
||||
nextEffect: Update<State> | null;
|
||||
}
|
||||
|
||||
export interface UpdateQueue<State> {
|
||||
baseState: State;
|
||||
|
||||
firstUpdate: Update<State> | null;
|
||||
lastUpdate: Update<State> | null;
|
||||
|
||||
firstCapturedUpdate: Update<State> | null;
|
||||
lastCapturedUpdate: Update<State> | null;
|
||||
|
||||
firstEffect: Update<State> | null;
|
||||
lastEffect: Update<State> | null;
|
||||
|
||||
firstCapturedEffect: Update<State> | null;
|
||||
lastCapturedEffect: Update<State> | null;
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
export type WorkTag =
|
||||
| 0
|
||||
| 1
|
||||
| 2
|
||||
| 3
|
||||
| 4
|
||||
| 5
|
||||
| 6
|
||||
| 7
|
||||
| 8
|
||||
| 9
|
||||
| 10
|
||||
| 11
|
||||
| 12
|
||||
| 13
|
||||
| 14
|
||||
| 15
|
||||
| 16;
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
export interface Interaction {
|
||||
__count: number;
|
||||
id: number;
|
||||
name: string;
|
||||
timestamp: number;
|
||||
}
|
||||
Vendored
+579
-13
@@ -4,17 +4,583 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export { default } from './ReactFiberReconciler';
|
||||
import { Component, ReactNode } from 'react';
|
||||
|
||||
export * from './ReactElementType';
|
||||
export * from './ReactFiber';
|
||||
export * from './ReactFiberNewContext';
|
||||
export * from './ReactFiberReconciler';
|
||||
export * from './ReactFiberRoot';
|
||||
export * from './ReactFiberScheduler';
|
||||
export * from './ReactSideEffectTags';
|
||||
export * from './ReactTypeOfMode';
|
||||
export * from './ReactTypes';
|
||||
export * from './ReactUpdateQueue';
|
||||
export * from './ReactWorkTags';
|
||||
export * from './Tracking';
|
||||
declare function ReactReconciler<Type, Props, Container, Instance, TextInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>(
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
config: ReactReconciler.HostConfig<Type, Props, Container, Instance, TextInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>,
|
||||
): ReactReconciler.Reconciler<Instance, TextInstance, Container, PublicInstance>;
|
||||
|
||||
declare namespace ReactReconciler {
|
||||
// react-ronciler/ReactFiber
|
||||
|
||||
// A Fiber is work on a Component that needs to be done or was done. There can
|
||||
// be more than one per component.
|
||||
interface Fiber {
|
||||
// These first fields are conceptually members of an Instance. This used to
|
||||
// be split into a separate type and intersected with the other Fiber fields,
|
||||
// but until Flow fixes its intersection bugs, we've merged them into a
|
||||
// single type.
|
||||
|
||||
// An Instance is shared between all versions of a component. We can easily
|
||||
// break this out into a separate object to avoid copying so much to the
|
||||
// alternate versions of the tree. We put this on a single object for now to
|
||||
// minimize the number of objects created during the initial render.
|
||||
|
||||
// Tag identifying the type of fiber.
|
||||
tag: WorkTag;
|
||||
|
||||
// Unique identifier of this child.
|
||||
key: null | string;
|
||||
|
||||
// The function/class/module associated with this fiber.
|
||||
type: any;
|
||||
|
||||
// The local state associated with this fiber.
|
||||
stateNode: any;
|
||||
|
||||
// Conceptual aliases
|
||||
// parent : Instance -> return The parent happens to be the same as the
|
||||
// return fiber since we've merged the fiber and instance.
|
||||
|
||||
// Remaining fields belong to Fiber
|
||||
|
||||
// The Fiber to return to after finishing processing this one.
|
||||
// This is effectively the parent, but there can be multiple parents (two)
|
||||
// so this is only the parent of the thing we're currently processing.
|
||||
// It is conceptually the same as the return address of a stack frame.
|
||||
return: Fiber | null;
|
||||
|
||||
// Singly Linked List Tree Structure.
|
||||
child: Fiber | null;
|
||||
sibling: Fiber | null;
|
||||
index: number;
|
||||
|
||||
// The ref last used to attach this node.
|
||||
// I'll avoid adding an owner field for prod and model that as functions.
|
||||
ref: null | (((handle: any) => void) & { _stringRef: string | null | undefined }) | RefObject;
|
||||
|
||||
// Input is the data coming into process this fiber. Arguments. Props.
|
||||
pendingProps: any; // This type will be more specific once we overload the tag.
|
||||
memoizedProps: any; // The props used to create the output.
|
||||
|
||||
// A queue of state updates and callbacks.
|
||||
updateQueue: UpdateQueue<any> | null;
|
||||
|
||||
// The state used to create the output
|
||||
memoizedState: any;
|
||||
|
||||
// A linked-list of contexts that this fiber depends on
|
||||
firstContextDependency: ContextDependency<any> | null;
|
||||
|
||||
// Bitfield that describes properties about the fiber and its subtree. E.g.
|
||||
// the AsyncMode flag indicates whether the subtree should be async-by-
|
||||
// default. When a fiber is created, it inherits the mode of its
|
||||
// parent. Additional flags can be set at creation time, but after that the
|
||||
// value should remain unchanged throughout the fiber's lifetime, particularly
|
||||
// before its child fibers are created.
|
||||
mode: TypeOfMode;
|
||||
|
||||
// Effect
|
||||
effectTag: SideEffectTag;
|
||||
|
||||
// Singly linked list fast path to the next fiber with side-effects.
|
||||
nextEffect: Fiber | null;
|
||||
|
||||
// The first and last fiber with side-effect within this subtree. This allows
|
||||
// us to reuse a slice of the linked list when we reuse the work done within
|
||||
// this fiber.
|
||||
firstEffect: Fiber | null;
|
||||
lastEffect: Fiber | null;
|
||||
|
||||
// Represents a time in the future by which this work should be completed.
|
||||
// Does not include work found in its subtree.
|
||||
expirationTime: ExpirationTime;
|
||||
|
||||
// This is used to quickly determine if a subtree has no pending changes.
|
||||
childExpirationTime: ExpirationTime;
|
||||
|
||||
// This is a pooled version of a Fiber. Every fiber that gets updated will
|
||||
// eventually have a pair. There are cases when we can clean up pairs to save
|
||||
// memory if we need to.
|
||||
alternate: Fiber | null;
|
||||
|
||||
// Time spent rendering this Fiber and its descendants for the current update.
|
||||
// This tells us how well the tree makes use of sCU for memoization.
|
||||
// It is reset to 0 each time we render and only updated when we don't bailout.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
actualDuration?: number;
|
||||
|
||||
// If the Fiber is currently active in the "render" phase,
|
||||
// This marks the time at which the work began.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
actualStartTime?: number;
|
||||
|
||||
// Duration of the most recent render time for this Fiber.
|
||||
// This value is not updated when we bailout for memoization purposes.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
selfBaseDuration?: number;
|
||||
|
||||
// Sum of base times for all descedents of this Fiber.
|
||||
// This value bubbles up during the "complete" phase.
|
||||
// This field is only set when the enableProfilerTimer flag is enabled.
|
||||
treeBaseDuration?: number;
|
||||
|
||||
// Conceptual aliases
|
||||
// workInProgress : Fiber -> alternate The alternate used for reuse happens
|
||||
// to be the same as work in progress.
|
||||
// __DEV__ only
|
||||
_debugID?: number;
|
||||
_debugSource?: Source | null;
|
||||
_debugOwner?: Fiber | null;
|
||||
_debugIsCurrentlyTiming?: boolean;
|
||||
}
|
||||
|
||||
// react-reconciler/ReactFiberExpirationTime
|
||||
|
||||
type ExpirationTime = number;
|
||||
|
||||
// react-reconciler/ReactFiberNewContext
|
||||
|
||||
interface ContextDependency<T> {
|
||||
context: ReactContext<T>;
|
||||
observedBits: number;
|
||||
next: ContextDependency<any> | null;
|
||||
}
|
||||
|
||||
// react-reconciler/ReactFiberReconciler
|
||||
|
||||
type OpaqueHandle = Fiber;
|
||||
type OpaqueRoot = FiberRoot;
|
||||
|
||||
interface HostConfig<Type, Props, Container, Instance, TextInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout> {
|
||||
getPublicInstance(instance: Instance | TextInstance): PublicInstance;
|
||||
getRootHostContext(rootContainerInstance: Container): HostContext;
|
||||
getChildHostContext(parentHostContext: HostContext, type: Type, rootContainerInstance: Container): HostContext;
|
||||
|
||||
prepareForCommit(containerInfo: Container): void;
|
||||
resetAfterCommit(containerInfo: Container): void;
|
||||
|
||||
createInstance(
|
||||
type: Type,
|
||||
props: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): Instance;
|
||||
appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
|
||||
finalizeInitialChildren(
|
||||
parentInstance: Instance,
|
||||
type: Type,
|
||||
props: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
): boolean;
|
||||
|
||||
prepareUpdate(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
): null | UpdatePayload;
|
||||
|
||||
shouldSetTextContent(type: Type, props: Props): boolean;
|
||||
shouldDeprioritizeSubtree(type: Type, props: Props): boolean;
|
||||
|
||||
createTextInstance(
|
||||
text: string,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): TextInstance;
|
||||
|
||||
scheduleDeferredCallback(
|
||||
callback: (deadline: Deadline) => void,
|
||||
options?: { timeout: number },
|
||||
): any;
|
||||
cancelDeferredCallback(callbackID: any): void;
|
||||
|
||||
setTimeout(handler: (...args: any[]) => void, timeout: number): TimeoutHandle | NoTimeout;
|
||||
clearTimeout(handle: TimeoutHandle | NoTimeout): void;
|
||||
noTimeout: NoTimeout;
|
||||
|
||||
now(): number;
|
||||
|
||||
// Temporary workaround for scenario where multiple renderers concurrently
|
||||
// render using the same context objects. E.g. React DOM and React ART on the
|
||||
// same page. DOM is the primary renderer; ART is the secondary renderer.
|
||||
isPrimaryRenderer: boolean;
|
||||
|
||||
supportsMutation: boolean;
|
||||
supportsPersistence: boolean;
|
||||
supportsHydration: boolean;
|
||||
|
||||
// -------------------
|
||||
// Mutation
|
||||
// (optional)
|
||||
// -------------------
|
||||
appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
|
||||
appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
|
||||
commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
|
||||
commitMount?(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): void;
|
||||
commitUpdate?(
|
||||
instance: Instance,
|
||||
updatePayload: UpdatePayload,
|
||||
type: Type,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): void;
|
||||
insertBefore?(parentInstance: Instance, child: Instance | TextInstance, beforeChild: Instance | TextInstance): void;
|
||||
insertInContainerBefore?(
|
||||
container: Container,
|
||||
child: Instance | TextInstance,
|
||||
beforeChild: Instance | TextInstance,
|
||||
): void;
|
||||
removeChild?(parentInstance: Instance, child: Instance | TextInstance): void;
|
||||
removeChildFromContainer?(container: Container, child: Instance | TextInstance): void;
|
||||
resetTextContent?(instance: Instance): void;
|
||||
|
||||
// -------------------
|
||||
// Persistence
|
||||
// (optional)
|
||||
// -------------------
|
||||
cloneInstance?(
|
||||
instance: Instance,
|
||||
updatePayload: null | UpdatePayload,
|
||||
type: Type,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
keepChildren: boolean,
|
||||
recyclableInstance: Instance,
|
||||
): Instance;
|
||||
|
||||
createContainerChildSet?(container: Container): ChildSet;
|
||||
|
||||
appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
|
||||
finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
|
||||
|
||||
replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
|
||||
|
||||
// -------------------
|
||||
// Hydration
|
||||
// (optional)
|
||||
// -------------------
|
||||
canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
|
||||
canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
|
||||
getNextHydratableSibling?(instance: Instance | TextInstance | HydratableInstance): null | HydratableInstance;
|
||||
getFirstHydratableChild?(parentInstance: Instance | Container): null | HydratableInstance;
|
||||
hydrateInstance?(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
props: Props,
|
||||
rootContainerInstance: Container,
|
||||
hostContext: HostContext,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): null | UpdatePayload;
|
||||
hydrateTextInstance?(
|
||||
textInstance: TextInstance,
|
||||
text: string,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): boolean;
|
||||
didNotMatchHydratedContainerTextInstance?(
|
||||
parentContainer: Container,
|
||||
textInstance: TextInstance,
|
||||
text: string,
|
||||
): void;
|
||||
didNotMatchHydratedTextInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
textInstance: TextInstance,
|
||||
text: string,
|
||||
): void;
|
||||
didNotHydrateContainerInstance?(parentContainer: Container, instance: Instance | TextInstance): void;
|
||||
didNotHydrateInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
instance: Instance | TextInstance,
|
||||
): void;
|
||||
didNotFindHydratableContainerInstance?(
|
||||
parentContainer: Container,
|
||||
type: Type,
|
||||
props: Props,
|
||||
): void;
|
||||
didNotFindHydratableContainerTextInstance?(
|
||||
parentContainer: Container,
|
||||
text: string,
|
||||
): void;
|
||||
didNotFindHydratableInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
type: Type,
|
||||
props: Props,
|
||||
): void;
|
||||
didNotFindHydratableTextInstance?(
|
||||
parentType: Type,
|
||||
parentProps: Props,
|
||||
parentInstance: Instance,
|
||||
text: string,
|
||||
): void;
|
||||
}
|
||||
|
||||
// 0 is PROD, 1 is DEV.
|
||||
// Might add PROFILE later.
|
||||
type BundleType = 0 | 1;
|
||||
|
||||
interface DevToolsConfig<Instance, TextInstance> {
|
||||
bundleType: BundleType;
|
||||
version: string;
|
||||
rendererPackageName: string;
|
||||
// Note: this actually *does* depend on Fiber internal fields.
|
||||
// Used by "inspect clicked DOM element" in React DevTools.
|
||||
findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber;
|
||||
// Used by RN in-app inspector.
|
||||
// This API is unfortunately RN-specific.
|
||||
// TODO: Change it to accept Fiber instead and type it properly.
|
||||
getInspectorDataForViewTag?: (tag: number) => object;
|
||||
}
|
||||
|
||||
interface Reconciler<Instance, TextInstance, Container, PublicInstance> {
|
||||
updateContainerAtExpirationTime(
|
||||
element: ReactNodeList,
|
||||
container: OpaqueRoot,
|
||||
parentComponent: Component<any, any> | null | undefined,
|
||||
expirationTime: ExpirationTime,
|
||||
callback: () => void | null | undefined,
|
||||
): ExpirationTime;
|
||||
createContainer(
|
||||
containerInfo: Container,
|
||||
isAsync: boolean,
|
||||
hydrate: boolean,
|
||||
): OpaqueRoot;
|
||||
updateContainer(
|
||||
element: ReactNodeList,
|
||||
container: OpaqueRoot,
|
||||
parentComponent: Component<any, any> | null | undefined,
|
||||
callback: () => void | null | undefined,
|
||||
): ExpirationTime;
|
||||
flushRoot(root: OpaqueRoot, expirationTime: ExpirationTime): void;
|
||||
requestWork(root: OpaqueRoot, expirationTime: ExpirationTime): void;
|
||||
computeUniqueAsyncExpiration(): ExpirationTime;
|
||||
batchedUpdates<A>(fn: () => A): A;
|
||||
unbatchedUpdates<A>(fn: () => A): A;
|
||||
deferredUpdates<A>(fn: () => A): A;
|
||||
syncUpdates<A>(fn: () => A): A;
|
||||
interactiveUpdates<A>(fn: () => A): A;
|
||||
flushInteractiveUpdates(): void;
|
||||
flushControlled(fn: () => any): void;
|
||||
flushSync<A>(fn: () => A): A;
|
||||
|
||||
// Used to extract the return value from the initial render. Legacy API.
|
||||
getPublicRootInstance(
|
||||
container: OpaqueRoot,
|
||||
): Component<any, any> | PublicInstance | null;
|
||||
|
||||
// Use for findDOMNode/findHostNode. Legacy API.
|
||||
findHostInstance(component: object): PublicInstance | null;
|
||||
|
||||
// Used internally for filtering out portals. Legacy API.
|
||||
findHostInstanceWithNoPortals(component: Fiber): PublicInstance | null;
|
||||
injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance>): boolean;
|
||||
}
|
||||
|
||||
// react-reconciler/ReactFiberRoot
|
||||
|
||||
// TODO: This should be lifted into the renderer.
|
||||
interface Batch {
|
||||
_defer: boolean;
|
||||
_expirationTime: ExpirationTime;
|
||||
_onComplete: () => any;
|
||||
_next: Batch | null;
|
||||
}
|
||||
|
||||
type PendingInteractionMap = Map<ExpirationTime, Set<Interaction>>;
|
||||
|
||||
interface BaseFiberRootProperties {
|
||||
// Any additional information from the host associated with this root.
|
||||
containerInfo: any;
|
||||
// Used only by persistent updates.
|
||||
pendingChildren: any;
|
||||
// The currently active root fiber. This is the mutable root of the tree.
|
||||
current: Fiber;
|
||||
|
||||
// The following priority levels are used to distinguish between 1)
|
||||
// uncommitted work, 2) uncommitted work that is suspended, and 3) uncommitted
|
||||
// work that may be unsuspended. We choose not to track each individual
|
||||
// pending level, trading granularity for performance.
|
||||
//
|
||||
// The earliest and latest priority levels that are suspended from committing.
|
||||
earliestSuspendedTime: ExpirationTime;
|
||||
latestSuspendedTime: ExpirationTime;
|
||||
// The earliest and latest priority levels that are not known to be suspended.
|
||||
earliestPendingTime: ExpirationTime;
|
||||
latestPendingTime: ExpirationTime;
|
||||
// The latest priority level that was pinged by a resolved promise and can
|
||||
// be retried.
|
||||
latestPingedTime: ExpirationTime;
|
||||
|
||||
// If an error is thrown, and there are no more updates in the queue, we try
|
||||
// rendering from the root one more time, synchronously, before handling
|
||||
// the error.
|
||||
didError: boolean;
|
||||
|
||||
pendingCommitExpirationTime: ExpirationTime;
|
||||
// A finished work-in-progress HostRoot that's ready to be committed.
|
||||
finishedWork: Fiber | null;
|
||||
// Timeout handle returned by setTimeout. Used to cancel a pending timeout, if
|
||||
// it's superseded by a new one.
|
||||
timeoutHandle: any;
|
||||
// Top context object, used by renderSubtreeIntoContainer
|
||||
context: object | null;
|
||||
pendingContext: object | null;
|
||||
// Determines if we should attempt to hydrate on the initial mount
|
||||
readonly hydrate: boolean;
|
||||
// Remaining expiration time on this root.
|
||||
// TODO: Lift this into the renderer
|
||||
nextExpirationTimeToWorkOn: ExpirationTime;
|
||||
expirationTime: ExpirationTime;
|
||||
// List of top-level batches. This list indicates whether a commit should be
|
||||
// deferred. Also contains completion callbacks.
|
||||
// TODO: Lift this into the renderer
|
||||
firstBatch: Batch | null;
|
||||
// Linked-list of roots
|
||||
nextScheduledRoot: FiberRoot | null;
|
||||
}
|
||||
|
||||
// The following attributes are only used by interaction tracking builds.
|
||||
// They enable interactions to be associated with their async work,
|
||||
// And expose interaction metadata to the React DevTools Profiler plugin.
|
||||
// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled.
|
||||
interface ProfilingOnlyFiberRootProperties {
|
||||
interactionThreadID: number;
|
||||
memoizedInteractions: Set<Interaction>;
|
||||
pendingInteractionMap: PendingInteractionMap;
|
||||
}
|
||||
|
||||
type FiberRoot = BaseFiberRootProperties & ProfilingOnlyFiberRootProperties;
|
||||
|
||||
// react-reconciler/ReactFiberScheduler
|
||||
|
||||
interface Deadline {
|
||||
timeRemaining: () => number;
|
||||
didTimeout: boolean;
|
||||
}
|
||||
|
||||
// react-reconciler/ReactTypeOfMode
|
||||
|
||||
type TypeOfMode = number;
|
||||
|
||||
// react-reconciler/ReactUpdateQueue
|
||||
|
||||
interface Update<State> {
|
||||
expirationTime: ExpirationTime;
|
||||
|
||||
tag: 0 | 1 | 2 | 3;
|
||||
payload: any;
|
||||
callback: (() => any) | null;
|
||||
|
||||
next: Update<State> | null;
|
||||
nextEffect: Update<State> | null;
|
||||
}
|
||||
|
||||
interface UpdateQueue<State> {
|
||||
baseState: State;
|
||||
|
||||
firstUpdate: Update<State> | null;
|
||||
lastUpdate: Update<State> | null;
|
||||
|
||||
firstCapturedUpdate: Update<State> | null;
|
||||
lastCapturedUpdate: Update<State> | null;
|
||||
|
||||
firstEffect: Update<State> | null;
|
||||
lastEffect: Update<State> | null;
|
||||
|
||||
firstCapturedEffect: Update<State> | null;
|
||||
lastCapturedEffect: Update<State> | null;
|
||||
}
|
||||
|
||||
// schedule/Tracking
|
||||
|
||||
interface Interaction {
|
||||
__count: number;
|
||||
id: number;
|
||||
name: string;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
// shared/ReactElementType
|
||||
|
||||
interface Source {
|
||||
fileName: string;
|
||||
lineNumber: number;
|
||||
}
|
||||
|
||||
// shared/ReactSideEffectTags
|
||||
|
||||
type SideEffectTag = number;
|
||||
|
||||
// shared/ReactTypes
|
||||
|
||||
type ReactEmpty = null | undefined | boolean;
|
||||
|
||||
type ReactNodeList = ReactEmpty | ReactNode;
|
||||
|
||||
interface ReactProviderType<T> {
|
||||
$$typeof: symbol | number;
|
||||
_context: ReactContext<T>;
|
||||
}
|
||||
|
||||
interface ReactContext<T> {
|
||||
$$typeof: symbol | number;
|
||||
Consumer: ReactContext<T>;
|
||||
Provider: ReactProviderType<T>;
|
||||
unstable_read: () => T;
|
||||
|
||||
_calculateChangedBits: ((a: T, b: T) => number) | null;
|
||||
|
||||
_currentValue: T;
|
||||
_currentValue2: T;
|
||||
|
||||
// DEV only
|
||||
_currentRenderer?: object | null;
|
||||
_currentRenderer2?: object | null;
|
||||
}
|
||||
|
||||
interface RefObject {
|
||||
current: any;
|
||||
}
|
||||
|
||||
// shared/ReactWorkTags
|
||||
|
||||
type WorkTag =
|
||||
| 0
|
||||
| 1
|
||||
| 2
|
||||
| 3
|
||||
| 4
|
||||
| 5
|
||||
| 6
|
||||
| 7
|
||||
| 8
|
||||
| 9
|
||||
| 10
|
||||
| 11
|
||||
| 12
|
||||
| 13
|
||||
| 14
|
||||
| 15
|
||||
| 16;
|
||||
}
|
||||
|
||||
export = ReactReconciler;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ReactFiberReconciler from 'react-reconciler';
|
||||
import ReactFiberReconciler = require("react-reconciler");
|
||||
import * as ReactTestHostConfig from './ReactTestHostConfig';
|
||||
|
||||
// $ExpectType Reconciler<Instance, TextInstance, Container, HydratableInstance>
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// Type definitions for react-visibility-sensor 3.11
|
||||
// Project: https://github.com/joshwnj/react-visibility-sensor#readme
|
||||
// Definitions by: Rasmus Bergström <https://github.com/JRasmusBm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export as namespace ReactVisibilitySensor;
|
||||
|
||||
interface Shape {
|
||||
top?: number;
|
||||
left?: number;
|
||||
bottom?: number;
|
||||
right?: number;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
onChange: (isVisible: boolean, visibilityRect?: Shape) => void;
|
||||
active?: boolean;
|
||||
partialVisibility?: boolean;
|
||||
offset?: Shape;
|
||||
minTopValue?: number;
|
||||
intervalCheck?: boolean;
|
||||
intervalDelay?: number;
|
||||
scrollCheck?: boolean;
|
||||
scrollDelay?: number;
|
||||
scrollThrottle?: number;
|
||||
resizeCheck?: boolean;
|
||||
resizeDelay?: number;
|
||||
resizeThrottle?: number;
|
||||
delayedCall?: boolean;
|
||||
children?: (
|
||||
args: { isVisible: boolean; visibilityRect?: Shape }
|
||||
) => React.ReactNode;
|
||||
}
|
||||
|
||||
declare const ReactVisibilitySensor: React.StatelessComponent<Props>;
|
||||
|
||||
export = ReactVisibilitySensor;
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as React from "react";
|
||||
|
||||
import * as ReactVisibilitySensor from "react-visibility-sensor";
|
||||
|
||||
const num = 1;
|
||||
const bool = true;
|
||||
const shape = { top: num, left: num, bottom: num, right: num };
|
||||
|
||||
const component = (
|
||||
<ReactVisibilitySensor
|
||||
onChange={(bool, shape) => {}}
|
||||
active={bool}
|
||||
partialVisibility={bool}
|
||||
offset={shape}
|
||||
minTopValue={num}
|
||||
intervalCheck={bool}
|
||||
intervalDelay={num}
|
||||
scrollCheck={bool}
|
||||
scrollDelay={num}
|
||||
scrollThrottle={num}
|
||||
resizeCheck={bool}
|
||||
resizeDelay={num}
|
||||
resizeThrottle={num}
|
||||
delayedCall={bool}>
|
||||
{({ isVisible: bool, visibilityRect: shape }) => <div />}
|
||||
</ReactVisibilitySensor>
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es7", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"jsx": "react",
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "react-visibility-sensor-tests.tsx"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+16
@@ -112,6 +112,14 @@ interface Select2Plugin {
|
||||
* @params triggerChange Should a change event be triggered
|
||||
*/
|
||||
(method: 'data', value: any, triggerChange?: boolean): any;
|
||||
/**
|
||||
* Whether it is open
|
||||
*/
|
||||
(method: 'opened'): boolean;
|
||||
/**
|
||||
* Whether it is in focus
|
||||
*/
|
||||
(method: 'isFocused'): boolean;
|
||||
/**
|
||||
* Reverts changes to DOM done by Select2. Any selection done via Select2 will be preserved.
|
||||
*/
|
||||
@@ -124,11 +132,19 @@ interface Select2Plugin {
|
||||
* Closes the dropdown
|
||||
*/
|
||||
(method: 'close'): JQuery;
|
||||
/**
|
||||
* Disables Select2
|
||||
*/
|
||||
(method: 'disable'): JQuery;
|
||||
/**
|
||||
* Enables or disables Select2 and its underlying form component
|
||||
* @param value True if it should be enabled false if it should be disabled
|
||||
*/
|
||||
(method: 'enable', value?: boolean): JQuery;
|
||||
/**
|
||||
* Enable its focus
|
||||
*/
|
||||
(method: 'focus'): JQuery;
|
||||
/**
|
||||
* Toggles readonly mode on Select2 and its underlying form component
|
||||
* @param value True if it should be readonly false if it should be read write
|
||||
|
||||
@@ -220,6 +220,10 @@ $("#e8").select2("data");
|
||||
$("#e8").select2("data", { id: "CA", text: "Califoria" });
|
||||
$("#e8").select2("destroy");
|
||||
$("#e8").select2("open");
|
||||
$("#e8").select2("opened");
|
||||
$("#e8").select2("focus");
|
||||
$("#e8").select2("isFocused");
|
||||
$("#e8").select2("disable");
|
||||
$("#e8").select2("enable", false);
|
||||
$("#e8").select2("readonly", false);
|
||||
$("#e8").select2('container');
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import withTypescript = require('@zeit/next-typescript');
|
||||
|
||||
withTypescript({}); // $ExpectType ServerConfig
|
||||
withTypescript({}); // $ExpectType NextConfig
|
||||
|
||||
Reference in New Issue
Block a user