From 732040440df7b3b35244b09e24c893a9151dfd0e Mon Sep 17 00:00:00 2001 From: Alec Hill Date: Mon, 29 Oct 2018 12:25:51 +0000 Subject: [PATCH 01/80] Injected navigation props were incorrectly typed to provide only non-leaf route state props. Added tests for both kinds of injected route state. --- types/react-navigation/index.d.ts | 3 +- .../react-navigation-tests.tsx | 41 ++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 1bdf43bc35..4be9671d66 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -25,6 +25,7 @@ // Denis Frezzato // Mickael Wegerich // Max Davidson +// Alec Hill // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -1240,7 +1241,7 @@ export type Omit = Pick>; export type InferProps> = T extends React.ComponentType ? P : never; export interface NavigationInjectedProps

{ - navigation: NavigationScreenProp; + navigation: NavigationScreenProp, P>; } // If the wrapped component is a class, we can get a ref to it diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 47dd7baa0e..d2ef1d522c 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -17,12 +17,14 @@ import { NavigationNavigateAction, NavigationProp, NavigationResetAction, + NavigationRoute, NavigationRouteConfigMap, NavigationScreenProp, NavigationScreenProps, NavigationSetParamsAction, NavigationStackAction, NavigationStackScreenOptions, + NavigationStateRoute, NavigationTabScreenOptions, NavigationTransitionProps, StackViewTransitionConfigs, @@ -70,10 +72,22 @@ interface StartScreenNavigationParams { */ class StartScreen extends React.Component> { render() { - // Implicit type checks. + // Injected type checks + const props: NavigationInjectedProps = this.props; + // route state... + const navigationState: NavigationRoute = this.props.navigation.state; + const index: number = navigationState.index; + const key: string = navigationState.key; + const routeName: string = navigationState.routeName; + const path: string | undefined = navigationState.path; + let routes: NavigationRoute[]; + if (isNavigationStateRoute(navigationState)) { + routes = navigationState.routes; + } + // params... const navigationStateParams: StartScreenNavigationParams | undefined = this.props.navigation.state.params; - const id = this.props.navigation.state.params && this.props.navigation.state.params.id; - const s = this.props.navigation.state.params && this.props.navigation.state.params.s; + const id: number | undefined = this.props.navigation.state.params && this.props.navigation.state.params.id; + const s: string | undefined = this.props.navigation.state.params && this.props.navigation.state.params.s; return ( @@ -107,17 +121,32 @@ interface NextScreenNavigationParams { class NextScreen extends React.Component> { render() { - // Implicit type checks. - const navigationStateParams: NextScreenNavigationParams | undefined = this.props.navigation.state.params; + // Injected type checks + const props: NavigationInjectedProps = this.props; + // route state... + const navigationState: NavigationRoute = this.props.navigation.state; + const index: number = navigationState.index; + const key: string = navigationState.key; + const routeName: string = navigationState.routeName; + const path: string | undefined = navigationState.path; + let routes: NavigationRoute[]; + if (isNavigationStateRoute(navigationState)) { + routes = navigationState.routes; + } + // params... + const navigationStateParams: NextScreenNavigationParams | undefined = navigationState.params; const id = this.props.navigation.state.params && this.props.navigation.state.params.id; const name = this.props.navigation.getParam('name', 'Peter'); - return ( ); } } +function isNavigationStateRoute

(route: NavigationRoute

): route is NavigationStateRoute

{ + return !!(route as NavigationStateRoute

).routes; +} + const navigationOptions = { headerBackTitle: null, }; From 6acfee7450ecb3a69e9c9827d337717562363f1a Mon Sep 17 00:00:00 2001 From: Alec Hill Date: Mon, 29 Oct 2018 15:47:20 +0000 Subject: [PATCH 02/80] Removed Slessi from authors on request --- types/react-navigation/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 4be9671d66..3562072601 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -14,7 +14,6 @@ // Steven Miller // Armando Assuncao // Ciaran Liedeman -// Edward Sammut Alessi // Jérémy Magrin // Luca Campana // Ullrich Schaefer From d67d2fbad20823a264384537f09af60aa2f9e1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Wed, 31 Oct 2018 15:22:57 +0100 Subject: [PATCH 03/80] intl-tel-input: moved old version to subfolder in preparation for v14 --- types/intl-tel-input/v13/index.d.ts | 260 ++++++++++++++++++ .../v13/intl-tel-input-tests.ts | 70 +++++ types/intl-tel-input/v13/tsconfig.json | 27 ++ types/intl-tel-input/v13/tslint.json | 80 ++++++ 4 files changed, 437 insertions(+) create mode 100644 types/intl-tel-input/v13/index.d.ts create mode 100644 types/intl-tel-input/v13/intl-tel-input-tests.ts create mode 100644 types/intl-tel-input/v13/tsconfig.json create mode 100644 types/intl-tel-input/v13/tslint.json diff --git a/types/intl-tel-input/v13/index.d.ts b/types/intl-tel-input/v13/index.d.ts new file mode 100644 index 0000000000..34493a8b75 --- /dev/null +++ b/types/intl-tel-input/v13/index.d.ts @@ -0,0 +1,260 @@ +// Type definitions for intl-tel-input +// Project: https://github.com/jackocnr/intl-tel-input +// Definitions by: Fidan Hakaj , Leonard Thieu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare namespace IntlTelInput { + + interface Plugin { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): CountryData[]; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; + + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + */ + (method: 'getNumber'): string; + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): intlTelInputUtils.numberType; + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): IntlTelInput.CountryData; + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.validationError + */ + (method: 'getValidationError'): intlTelInputUtils.validationError; + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; + (method: string): void; + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; + (method: string, value: string): void; + + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string; + (method: string, numberFormat: intlTelInputUtils.numberFormat): string; + + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: IntlTelInput.Options): JQueryDeferred; + } + + interface Options { + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + */ + allowDropdown?: boolean; + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + */ + autoHideDialCode?: boolean; + /** + * Set the input's placeholder to an example number for the selected country. + * You can specify the number type using the numberType option. + * If there is already a placeholder attribute set on the input then that + * will take precedence. Requires the utilsScript option. + */ + autoPlaceholder?: boolean; + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; + /** + * Specify the container for the country dropdown (use a jQuery selector + * e.g. "body"). This is useful when the input is within a scrolling element, + * or an element with overflow: hidden. Wherever you put the dropdown it + * will automatically close on the window scroll event to prevent positioning + * issues. If you want it to close when a different element is scrolled + * (such as the input's parent), simply listen for the that scroll event, + * and trigger $(window).scroll() e.g. + */ + dropdownContainer?: string; + /** + * Don't display the countries you specify. + */ + excludeCountries?: Array; + /** + * Format the input value during initialisation. + */ + formatOnInit?: boolean; + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location. Also note + * that when instantiating the plugin, we now return a deferred object, so + * you can use .done(callback) to know when initialisation requests like + * this have completed. + * Note that the callback must still be called in the event of an error. + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + */ + nationalMode?: boolean; + /** + * Display only the countries you specify. + */ + onlyCountries?: Array; + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + */ + placeholderNumberType?: + | "FIXED_LINE_OR_MOBILE" + | "FIXED_LINE" + | "MOBILE" + | "PAGER" + | "PERSONAL_NUMBER" + | "PREMIUM_RATE" + | "SHARED_COST" + | "TOLL_FREE" + | "UAN" + | "UNKNOWN" + | "VOICEMAIL" + | "VOIP"; + /** + * Specify the countries to appear at the top of the list. + */ + preferredCountries?: Array; + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + */ + separateDialCode?: boolean; + /** + * Enable formatting/validation etc. by specifying the path to the included + * utils.js script, which is fetched only when the page has finished loading + * (on window.load) to prevent blocking. When instantiating the plugin, + * we return a deferred object, so you can use .done(callback) to know when + * initialisation requests like this have finished. Note that if you're + * lazy loading the plugin script itself (intlTelInput.js) this will not + * work and you will need to use the loadUtils method instead. + */ + utilsScript?: string; + } + + interface CountryData { + name: string; + iso2: string; + dialCode: string; + } +} + +declare namespace intlTelInputUtils { + + const enum numberFormat { + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 + } + + const enum numberType { + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 + } + + const enum validationError { + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 + } +} + +interface JQuery { + intlTelInput: IntlTelInput.Plugin; +} diff --git a/types/intl-tel-input/v13/intl-tel-input-tests.ts b/types/intl-tel-input/v13/intl-tel-input-tests.ts new file mode 100644 index 0000000000..e91a5deef1 --- /dev/null +++ b/types/intl-tel-input/v13/intl-tel-input-tests.ts @@ -0,0 +1,70 @@ +$('#phone').intlTelInput(); + +$('#phone').intlTelInput({ + customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) { + return 'e.g. ' + selectedCountryPlaceholder; + } +}); + +$('#phone').intlTelInput({ + placeholderNumberType: "MOBILE", +}); + +$('#phone').intlTelInput({ + geoIpLookup: function(callback) { + $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { + let countryCode = (resp && resp.country) ? resp.country : ''; + callback(countryCode); + }); + } +}); + +$('#phone').intlTelInput('destroy'); + +let extension = $('#phone').intlTelInput('getExtension'); + +let intlNumber = $('#phone').intlTelInput('getNumber'); +let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); + +let numberType = $('#phone').intlTelInput('getNumberType'); +if (numberType === intlTelInputUtils.numberType.MOBILE) {} + +let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); + +let error = $('#phone').intlTelInput('getValidationError'); +if (error === intlTelInputUtils.validationError.TOO_SHORT) {} + +let isValid = $('#phone').intlTelInput('isValidNumber'); + +$('#phone').intlTelInput('setCountry', 'gb'); + +$('#phone').intlTelInput('setNumber', '+447733123456'); + +let countryData = $.fn.intlTelInput.getCountryData(); + +$.fn.intlTelInput.loadUtils('build/js/utils.js'); + +$('#phone').intlTelInput({ + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + initialCountry: 'auto', + geoIpLookup: function(callback) { + $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { + let countryCode = (resp && resp.country) ? resp.country : ''; + callback(countryCode); + }); + }, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + nationalMode: true, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' +}); diff --git a/types/intl-tel-input/v13/tsconfig.json b/types/intl-tel-input/v13/tsconfig.json new file mode 100644 index 0000000000..b7e1b435b1 --- /dev/null +++ b/types/intl-tel-input/v13/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "intl-tel-input": [ "intl-tel-input/v13" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "intl-tel-input-tests.ts" + ] +} \ No newline at end of file diff --git a/types/intl-tel-input/v13/tslint.json b/types/intl-tel-input/v13/tslint.json new file mode 100644 index 0000000000..b6afb8acee --- /dev/null +++ b/types/intl-tel-input/v13/tslint.json @@ -0,0 +1,80 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-const-enum": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From 244f5c736bc818e276bb49240de4eb2e4b183236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Wed, 31 Oct 2018 16:40:06 +0100 Subject: [PATCH 04/80] v14 type definition (tests still needed for new options) --- types/intl-tel-input/index.d.ts | 522 ++++++++++--------- types/intl-tel-input/intl-tel-input-tests.ts | 63 ++- types/intl-tel-input/tslint.json | 79 +-- 3 files changed, 308 insertions(+), 356 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 34493a8b75..b0752632c3 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -1,260 +1,290 @@ -// Type definitions for intl-tel-input +// Type definitions for intl-tel-input 14.0 // Project: https://github.com/jackocnr/intl-tel-input -// Definitions by: Fidan Hakaj , Leonard Thieu +// Definitions by: Fidan Hakaj , Leonard Thieu , Márton Molnár // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// +export interface IntlTelInputStatic { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): CountryData[]; -declare namespace IntlTelInput { + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; - interface Plugin { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): CountryData[]; - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; - - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - (method: 'destroy'): void; - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - (method: 'getExtension'): string; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - */ - (method: 'getNumber'): string; - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - (method: 'getNumberType'): intlTelInputUtils.numberType; - /** - * Get the country data for the currently selected flag. - */ - (method: 'getSelectedCountryData'): IntlTelInput.CountryData; - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.validationError - */ - (method: 'getValidationError'): intlTelInputUtils.validationError; - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - (method: 'isValidNumber'): boolean; - (method: string): void; - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - (method: 'setCountry', countryCode: string): void; - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - (method: 'setNumber', aNumber: string): void; - (method: string, value: string): void; - - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - (method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string; - (method: string, numberFormat: intlTelInputUtils.numberFormat): string; - - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (options?: IntlTelInput.Options): JQueryDeferred; - } - - interface Options { - /** - * Whether or not to allow the dropdown. If disabled, there is no dropdown - * arrow, and the selected flag is not clickable. Also we display the - * selected flag on the right instead because it is just a marker of state. - */ - allowDropdown?: boolean; - /** - * If there is just a dial code in the input: remove it on blur or submit, - * and re-add it on focus. This is to prevent just a dial code getting - * submitted with the form. Requires nationalMode to be set to false. - */ - autoHideDialCode?: boolean; - /** - * Set the input's placeholder to an example number for the selected country. - * You can specify the number type using the numberType option. - * If there is already a placeholder attribute set on the input then that - * will take precedence. Requires the utilsScript option. - */ - autoPlaceholder?: boolean; - /** - * Change the placeholder generated by autoPlaceholder. Must return a string. - */ - customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; - /** - * Specify the container for the country dropdown (use a jQuery selector - * e.g. "body"). This is useful when the input is within a scrolling element, - * or an element with overflow: hidden. Wherever you put the dropdown it - * will automatically close on the window scroll event to prevent positioning - * issues. If you want it to close when a different element is scrolled - * (such as the input's parent), simply listen for the that scroll event, - * and trigger $(window).scroll() e.g. - */ - dropdownContainer?: string; - /** - * Don't display the countries you specify. - */ - excludeCountries?: Array; - /** - * Format the input value during initialisation. - */ - formatOnInit?: boolean; - /** - * When setting initialCountry to "auto", you must use this option to - * specify a custom function that looks up the user's location. Also note - * that when instantiating the plugin, we now return a deferred object, so - * you can use .done(callback) to know when initialisation requests like - * this have completed. - * Note that the callback must still be called in the event of an error. - */ - geoIpLookup?: (callback: (countryCode: string) => void) => void; - /** - * Set the initial country selection by specifying it's country code. - * You can also set it to "auto", which will lookup the user's country based - * on their IP address (requires the geoIpLookup option). - * Note that the "auto" option will not update the country selection if the - * input already contains a number. If you leave initialCountry blank, - * it will default to the first country in the list. - */ - initialCountry?: string; - /** - * Allow users to enter national numbers (and not have to think about - * international dial codes). Formatting, validation and placeholders still - * work. Then you can use getNumber to extract a full international number. - * This option now defaults to true, and it is recommended that you leave it - * that way as it provides a better experience for the user. - */ - nationalMode?: boolean; - /** - * Display only the countries you specify. - */ - onlyCountries?: Array; - /** - * Specify one of the keys from the global enum intlTelInputUtils.numberType - * e.g. "FIXED_LINE" to set the number type to use for the placeholder. - */ - placeholderNumberType?: - | "FIXED_LINE_OR_MOBILE" - | "FIXED_LINE" - | "MOBILE" - | "PAGER" - | "PERSONAL_NUMBER" - | "PREMIUM_RATE" - | "SHARED_COST" - | "TOLL_FREE" - | "UAN" - | "UNKNOWN" - | "VOICEMAIL" - | "VOIP"; - /** - * Specify the countries to appear at the top of the list. - */ - preferredCountries?: Array; - /** - * Display the country dial code next to the selected flag so it's not part - * of the typed number. Note that this will disable nationalMode because - * technically we are dealing with international numbers, but with the - * dial code separated. - */ - separateDialCode?: boolean; - /** - * Enable formatting/validation etc. by specifying the path to the included - * utils.js script, which is fetched only when the page has finished loading - * (on window.load) to prevent blocking. When instantiating the plugin, - * we return a deferred object, so you can use .done(callback) to know when - * initialisation requests like this have finished. Note that if you're - * lazy loading the plugin script itself (intlTelInput.js) this will not - * work and you will need to use the loadUtils method instead. - */ - utilsScript?: string; - } - - interface CountryData { - name: string; - iso2: string; - dialCode: string; - } + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (node: Element, options?: IntlTelInputOptions): IntlTelInput; } -declare namespace intlTelInputUtils { +export interface IntlTelInput { + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + destroy(): void; - const enum numberFormat { - E164 = 0, - INTERNATIONAL = 1, - NATIONAL = 2, - RFC3966 = 3 - } + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + getExtension(): string; - const enum numberType { - FIXED_LINE = 0, - MOBILE = 1, - FIXED_LINE_OR_MOBILE = 2, - TOLL_FREE = 3, - PREMIUM_RATE = 4, - SHARED_COST = 5, - VOIP = 6, - PERSONAL_NUMBER = 7, - PAGER = 8, - UAN = 9, - VOICEMAIL = 10, - UNKNOWN = -1 - } + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + getNumber(numberFormat?: NumberFormat): string; - const enum validationError { - IS_POSSIBLE = 0, - INVALID_COUNTRY_CODE = 1, - TOO_SHORT = 2, - TOO_LONG = 3, - NOT_A_NUMBER = 4 - } + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + getNumberType(): NumberType; + + /** + * Get the country data for the currently selected flag. + */ + getSelectedCountryData(): CountryData; + + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.validationError + */ + getValidationError(): ValidationError; + + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + isValidNumber(): boolean; + + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + setCountry(countryCode: string): void; + + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + setNumber(aNumber: string): void; + + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + setPlaceholderNumberType(type: NumberType): void; } -interface JQuery { - intlTelInput: IntlTelInput.Plugin; +export interface IntlTelInputOptions { + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + * Default = true + */ + allowDropdown?: boolean; + + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + * Default = true + */ + autoHideDialCode?: boolean; + + /** + * Set the input's placeholder to an example number for the selected country, and update it if the country changes. + * You can specify the number type using the placeholderNumberType option. + * By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one. + * You can also set it to "aggressive", which will replace any existing placeholder, or "off". + * Requires the utilsScript option. + * Default = "polite" + */ + autoPlaceholder?: "off" | "polite" | "aggressive"; + + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + * Default = null + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; + + /** + * Expects a node e.g. document.body. Instead of putting the country dropdown next to the input, + * append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript. + * This is useful when the input is inside a container with overflow: hidden. + * Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event. + * Default = null + */ + dropdownContainer?: Node; + + /** + * In the dropdown, display all countries except the ones you specify here. + * Default = null + */ + excludeCountries?: string[]; + + /** + * Format the input value (according to the nationalMode option) during initialisation, and on setNumber. + * Requires the utilsScript option. + * Default = true + */ + formatOnDisplay?: boolean; + + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location, + * and then calls the success callback with the relevant country code. + * Also note that when instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can + * do something like iti.promise.then(callback) to know when initialisation requests like this have completed. + * Default = null + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; + + /** + * Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name, + * replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber). + * This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled. + * Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. + * Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation. + * Default = "" + */ + hiddenInput?: string; + + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; + + /** + * Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' } + * Default = {} + */ + localizedCountries?: object; + + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + * Default = true + */ + nationalMode?: boolean; + + /** + * In the dropdown, display only the countries you specify. + * Default = undefined + */ + onlyCountries?: string[]; + + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + * Default = MOBILE + */ + placeholderNumberType?: NumberType; + + /** + * Specify the countries to appear at the top of the list. + * Default = ["us", "gb"] + */ + preferredCountries?: string[]; + + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + * Default = false + */ + separateDialCode?: boolean; + + /** + * Enable formatting/validation etc. by specifying the URL of the included utils.js script + * (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event) + * to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can do something like + * iti.promise.then(callback) to know when initialisation requests like this have finished. + * Note that if you're lazy loading the plugin script itself (intlTelInput.js) + * this will not work and you will need to use the loadUtils method instead. + * Example: "build/js/utils.js" + * Default = "" + */ + utilsScript?: string; +} + +export interface CountryData { + name: string; + iso2: string; + dialCode: string; +} + +export enum NumberFormat { + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 +} + +export enum NumberType { + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 +} + +export enum ValidationError { + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 +} + +declare global { + interface Window { + intlTelInput: IntlTelInputStatic; + } } diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index e91a5deef1..9a84e98428 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -1,70 +1,69 @@ -$('#phone').intlTelInput(); +import IntlTelInput = require("intl-tel-input"); -$('#phone').intlTelInput({ - customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) { +const input = document.querySelector("#phone"); +window.intlTelInput(input); + +window.intlTelInput(input, { + customPlaceholder(selectedCountryPlaceholder, selectedCountryData) { return 'e.g. ' + selectedCountryPlaceholder; } }); -$('#phone').intlTelInput({ - placeholderNumberType: "MOBILE", +window.intlTelInput(input, { + placeholderNumberType: IntlTelInput.NumberType.MOBILE, }); -$('#phone').intlTelInput({ - geoIpLookup: function(callback) { - $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { - let countryCode = (resp && resp.country) ? resp.country : ''; +window.intlTelInput(input, { + geoIpLookup(callback) { + const countryCode = 'XY'; callback(countryCode); - }); } }); -$('#phone').intlTelInput('destroy'); +window.intlTelInput(input).destroy(); -let extension = $('#phone').intlTelInput('getExtension'); +const extension = window.intlTelInput(input).getExtension(); -let intlNumber = $('#phone').intlTelInput('getNumber'); -let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); +const intlNumber = window.intlTelInput(input).getNumber(); +const ntlNumber = window.intlTelInput(input).getNumber(IntlTelInput.NumberFormat.NATIONAL); -let numberType = $('#phone').intlTelInput('getNumberType'); -if (numberType === intlTelInputUtils.numberType.MOBILE) {} +const numberType = window.intlTelInput(input).getNumberType(); +if (numberType === IntlTelInput.NumberType.MOBILE) {} -let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); +const selectedCountryData = window.intlTelInput(input).getSelectedCountryData(); -let error = $('#phone').intlTelInput('getValidationError'); -if (error === intlTelInputUtils.validationError.TOO_SHORT) {} +const error = window.intlTelInput(input).getValidationError(); +if (error === IntlTelInput.ValidationError.TOO_SHORT) {} -let isValid = $('#phone').intlTelInput('isValidNumber'); +const isValid = window.intlTelInput(input).isValidNumber(); -$('#phone').intlTelInput('setCountry', 'gb'); +window.intlTelInput(input).setCountry('gb'); -$('#phone').intlTelInput('setNumber', '+447733123456'); +window.intlTelInput(input).setNumber('+447733123456'); -let countryData = $.fn.intlTelInput.getCountryData(); +const countryData = window.intlTelInput.getCountryData(); -$.fn.intlTelInput.loadUtils('build/js/utils.js'); +window.intlTelInput.loadUtils('build/js/utils.js'); -$('#phone').intlTelInput({ +window.intlTelInput(input, { utilsScript: '../../build/js/utils.js' }); -$('#phone').intlTelInput({ +window.intlTelInput(input, { initialCountry: 'auto', - geoIpLookup: function(callback) { - $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { - let countryCode = (resp && resp.country) ? resp.country : ''; + geoIpLookup: (callback) => { + const countryCode = 'XY'; callback(countryCode); - }); }, utilsScript: '../../build/js/utils.js' }); -$('#phone').intlTelInput({ +window.intlTelInput(input, { nationalMode: true, utilsScript: '../../build/js/utils.js' }); -$('#phone').intlTelInput({ +window.intlTelInput(input, { onlyCountries: ['al'], utilsScript: '../../build/js/utils.js' }); diff --git a/types/intl-tel-input/tslint.json b/types/intl-tel-input/tslint.json index b6afb8acee..f93cf8562a 100644 --- a/types/intl-tel-input/tslint.json +++ b/types/intl-tel-input/tslint.json @@ -1,80 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-const-enum": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From ed4de5dd4c9be7f22f360b7e3e801098c41f2aa8 Mon Sep 17 00:00:00 2001 From: Simon Meusel Date: Sat, 3 Nov 2018 11:44:41 +0100 Subject: [PATCH 05/80] Remove typings for gitlab --- notNeededPackages.json | 6 ++ types/gitlab/ApiBase.d.ts | 31 ----------- types/gitlab/ApiBaseHTTP.d.ts | 12 ---- types/gitlab/ApiV3.d.ts | 5 -- types/gitlab/BaseModel.d.ts | 17 ------ types/gitlab/Models/Groups.d.ts | 27 --------- types/gitlab/Models/IssueNotes.d.ts | 6 -- types/gitlab/Models/Issues.d.ts | 12 ---- types/gitlab/Models/Labels.d.ts | 5 -- types/gitlab/Models/Notes.d.ts | 5 -- types/gitlab/Models/Pipelines.d.ts | 5 -- types/gitlab/Models/ProjectBuilds.d.ts | 13 ----- types/gitlab/Models/ProjectDeployKeys.d.ts | 7 --- types/gitlab/Models/ProjectHooks.d.ts | 16 ------ types/gitlab/Models/ProjectIssues.d.ts | 9 --- types/gitlab/Models/ProjectLabels.d.ts | 6 -- types/gitlab/Models/ProjectMembers.d.ts | 12 ---- types/gitlab/Models/ProjectMergeRequests.d.ts | 11 ---- types/gitlab/Models/ProjectMilestones.d.ts | 12 ---- types/gitlab/Models/ProjectRepository.d.ts | 39 ------------- types/gitlab/Models/ProjectServices.d.ts | 9 --- types/gitlab/Models/Projects.d.ts | 55 ------------------- types/gitlab/Models/Runners.d.ts | 11 ---- types/gitlab/Models/UserKeys.d.ts | 6 -- types/gitlab/Models/Users.d.ts | 17 ------ types/gitlab/gitlab-tests.ts | 20 ------- types/gitlab/index.d.ts | 17 ------ types/gitlab/tsconfig.json | 23 -------- types/gitlab/tslint.json | 14 ----- 29 files changed, 6 insertions(+), 422 deletions(-) delete mode 100644 types/gitlab/ApiBase.d.ts delete mode 100644 types/gitlab/ApiBaseHTTP.d.ts delete mode 100644 types/gitlab/ApiV3.d.ts delete mode 100644 types/gitlab/BaseModel.d.ts delete mode 100644 types/gitlab/Models/Groups.d.ts delete mode 100644 types/gitlab/Models/IssueNotes.d.ts delete mode 100644 types/gitlab/Models/Issues.d.ts delete mode 100644 types/gitlab/Models/Labels.d.ts delete mode 100644 types/gitlab/Models/Notes.d.ts delete mode 100644 types/gitlab/Models/Pipelines.d.ts delete mode 100644 types/gitlab/Models/ProjectBuilds.d.ts delete mode 100644 types/gitlab/Models/ProjectDeployKeys.d.ts delete mode 100644 types/gitlab/Models/ProjectHooks.d.ts delete mode 100644 types/gitlab/Models/ProjectIssues.d.ts delete mode 100644 types/gitlab/Models/ProjectLabels.d.ts delete mode 100644 types/gitlab/Models/ProjectMembers.d.ts delete mode 100644 types/gitlab/Models/ProjectMergeRequests.d.ts delete mode 100644 types/gitlab/Models/ProjectMilestones.d.ts delete mode 100644 types/gitlab/Models/ProjectRepository.d.ts delete mode 100644 types/gitlab/Models/ProjectServices.d.ts delete mode 100644 types/gitlab/Models/Projects.d.ts delete mode 100644 types/gitlab/Models/Runners.d.ts delete mode 100644 types/gitlab/Models/UserKeys.d.ts delete mode 100644 types/gitlab/Models/Users.d.ts delete mode 100644 types/gitlab/gitlab-tests.ts delete mode 100644 types/gitlab/index.d.ts delete mode 100644 types/gitlab/tsconfig.json delete mode 100644 types/gitlab/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index f81984b338..5417ec227a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -624,6 +624,12 @@ "sourceRepoURL": "https://github.com/mikedeboer/node-github", "asOfVersion": "7.1.0" }, + { + "libraryName": "gitlab", + "typingsPackageName": "gitlab", + "sourceRepoURL": "https://github.com/jdalrymple/node-gitlab", + "asOfVersion": "2.0.0" + }, { "libraryName": "graphene-pk11", "typingsPackageName": "graphene-pk11", diff --git a/types/gitlab/ApiBase.d.ts b/types/gitlab/ApiBase.d.ts deleted file mode 100644 index 7187ce4352..0000000000 --- a/types/gitlab/ApiBase.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ApiBaseOptions } from './ApiBase'; -import { Labels } from './Models/Labels'; -import { Users } from './Models/Users'; -import { Notes } from './Models/Notes'; -import { Issues } from './Models/Issues'; -import { Projects } from './Models/Projects'; -import { Groups } from './Models/Groups'; - -export interface ApiBaseOptions { - url?: string; - token?: string; - oauth_token?: string; - base_url?: string; - auth?: any; - [key: string]: any; -} - -export class ApiBase { - constructor(options: ApiBaseOptions); - readonly client: this; - readonly groups: Groups - readonly projects: Projects - readonly issues: Issues - readonly notes: Notes - readonly users: Users - readonly labels: Labels - options: ApiBaseOptions; - - handleOptions(): void; - init(): object; -} diff --git a/types/gitlab/ApiBaseHTTP.d.ts b/types/gitlab/ApiBaseHTTP.d.ts deleted file mode 100644 index 7ed5fb0d69..0000000000 --- a/types/gitlab/ApiBaseHTTP.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ApiBase } from './ApiBase'; - -export class ApiBaseHTTP extends ApiBase { - prepare_opts(opts: T): T; - fn_wrapper(fn: T): T; - get(path: string, fn?: Function): any; - get(path: string, query?: object, fn?: Function): any; - delete(path: string, fn?: Function): any; - post(path: string, data?: object, fn?: Function): any; - put(path: string, data?: object, fn?: Function): any; - patch(path: string, data?: object, fn?: Function): any; -} diff --git a/types/gitlab/ApiV3.d.ts b/types/gitlab/ApiV3.d.ts deleted file mode 100644 index bd3d02557b..0000000000 --- a/types/gitlab/ApiV3.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ApiBaseHTTP } from './ApiBaseHTTP'; - -export class ApiV3 extends ApiBaseHTTP { - -} diff --git a/types/gitlab/BaseModel.d.ts b/types/gitlab/BaseModel.d.ts deleted file mode 100644 index ca6eb4e7c6..0000000000 --- a/types/gitlab/BaseModel.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -export class BaseModel { - load(model: string): object; - get(path: string, fn?: Function): any; - get(path: string, query?: object, fn?: Function): any; - delete(path: string, fn?: Function): any; - post(path: string, data?: object, fn?: Function): any; - put(path: string, data?: object, fn?: Function): any; - patch(path: string, data?: object, fn?: Function): any; -} - -export interface DefParams { - page?: number; - per_page?: number; - [key: string]: any; -} - -export type TId = number | string; diff --git a/types/gitlab/Models/Groups.d.ts b/types/gitlab/Models/Groups.d.ts deleted file mode 100644 index 1b528039f0..0000000000 --- a/types/gitlab/Models/Groups.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BaseModel, DefParams } from "../BaseModel"; - -interface IAccessLevels { - GUEST: number - REPORTER: number - DEVELOPER: number - MASTER: number - OWNER: number -} - -export class Groups extends BaseModel { - readonly access_levels: IAccessLevels; - - init(): object; - all(fn?: Function): any; - all(params?: DefParams, fn?: Function): any; - show(groupId: number, fn?: Function): any; - listProjects(groupId: number, fn?: Function): any; - listMembers(groupId: number, fn?: Function): any; - addMember(groupId: number, userId: number, accessLevel: IAccessLevels[keyof IAccessLevels], fn?: Function): any; - editMember(groupId: number, userId: number, accessLevel: IAccessLevels[keyof IAccessLevels], fn?: Function): any; - removeMember(groupId: number, userId: number, fn?: Function): any; - create(params?: object, fn?: Function): any; - addProject(groupId: number, projectId: number, fn?: Function): any; - deleteGroup(groupId: number, fn?: Function): any; - search(nameOrPath: string, fn?: Function): any; -} diff --git a/types/gitlab/Models/IssueNotes.d.ts b/types/gitlab/Models/IssueNotes.d.ts deleted file mode 100644 index de1821b1df..0000000000 --- a/types/gitlab/Models/IssueNotes.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class IssueNotes extends BaseModel{ - all(projectId: TId, issueId: number, fn?: Function): any - all(projectId: TId, issueId: number, params?: DefParams, fn?: Function): any -} diff --git a/types/gitlab/Models/Issues.d.ts b/types/gitlab/Models/Issues.d.ts deleted file mode 100644 index e751b6a002..0000000000 --- a/types/gitlab/Models/Issues.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Issues extends BaseModel { - all(fn?: Function): any; - all(params?: object, fn?: Function): any; - show(projectId: TId, issueId: TId, fn?: Function): any; - create(projectId: TId, params?: object, fn?: Function): any; - edit(projectId: TId, issueId: TId, params?: object, fn?: Function): any; - remove(projectId: TId, issueId: TId, fn?: Function): any; - subscribe(projectId: TId, issueId: TId, params?: object, fn?: Function): any; - unsubscribe(projectId: TId, issueId: TId, fn?: Function): any; -} diff --git a/types/gitlab/Models/Labels.d.ts b/types/gitlab/Models/Labels.d.ts deleted file mode 100644 index 63f1110b4d..0000000000 --- a/types/gitlab/Models/Labels.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Labels extends BaseModel { - create(projectId: TId, params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/Notes.d.ts b/types/gitlab/Models/Notes.d.ts deleted file mode 100644 index 95b9cd623e..0000000000 --- a/types/gitlab/Models/Notes.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Notes extends BaseModel { - create(projectId: TId, issueId: number, params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/Pipelines.d.ts b/types/gitlab/Models/Pipelines.d.ts deleted file mode 100644 index f65a9e7d25..0000000000 --- a/types/gitlab/Models/Pipelines.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Pipelines extends BaseModel { - all(projectId: TId, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectBuilds.d.ts b/types/gitlab/Models/ProjectBuilds.d.ts deleted file mode 100644 index df7c33c32a..0000000000 --- a/types/gitlab/Models/ProjectBuilds.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -interface IShowBuildParam { - projectId: TId; - [key: string]: any; -} - -export class ProjectBuilds extends BaseModel { - listBuilds(projectId: TId, fn?: Function): any; - listBuilds(projectId: TId, params?: DefParams, fn?: Function): any; - showBuild(projectId: TId, buildId: string, fn?: Function): any; - triggerBuild(params?: IShowBuildParam, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectDeployKeys.d.ts b/types/gitlab/Models/ProjectDeployKeys.d.ts deleted file mode 100644 index 3be9d66bc4..0000000000 --- a/types/gitlab/Models/ProjectDeployKeys.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class ProjectKeys extends BaseModel { - listKeys(projectId: TId, fn?: Function): any; - getKey(projectId: TId, keyId: number, fn?: Function): any; - addKey(projectId: TId, params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectHooks.d.ts b/types/gitlab/Models/ProjectHooks.d.ts deleted file mode 100644 index ce0878eec9..0000000000 --- a/types/gitlab/Models/ProjectHooks.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -interface IAddParam { - url: string; - [key: string]: any; -} - -type HooksCb = (hooks: any[]) => any; - -export class ProjectHooks extends BaseModel { - list(projectId: TId, fn?: HooksCb): any; - show(projectId: TId, hookId: number, fn?: Function): any; - add(projectId: TId, params: IAddParam | string, fn?: Function): any; - update(projectId: TId, hookId: number, url: string, fn?: Function): any; - remove(projectId: TId, hookId: number, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectIssues.d.ts b/types/gitlab/Models/ProjectIssues.d.ts deleted file mode 100644 index 8f7fc439a6..0000000000 --- a/types/gitlab/Models/ProjectIssues.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IssueNotes } from './IssueNotes'; -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class ProjectIssues extends BaseModel { - readonly notes: IssueNotes; - - list(projectId: TId, fn?: Function): any; - list(projectId: TId, params?: DefParams, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectLabels.d.ts b/types/gitlab/Models/ProjectLabels.d.ts deleted file mode 100644 index 2f6ca1dabc..0000000000 --- a/types/gitlab/Models/ProjectLabels.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class ProjectLabels extends BaseModel { - all(projectId: TId, fn?: Function): any; - all(projectId: TId, params?: DefParams, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectMembers.d.ts b/types/gitlab/Models/ProjectMembers.d.ts deleted file mode 100644 index 25aa87332a..0000000000 --- a/types/gitlab/Models/ProjectMembers.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -type MenberCb = (menber: any) => any; -type MenbersCb = (menbers: any[]) => any; - -export class ProjectMembers extends BaseModel { - list(projectId: TId, fn?: MenbersCb): any; - show(projectId: TId, userId: number, fn?: MenberCb): any; - add(projectId: TId, userId: number, accessLevel: number,fn?: Function): any; - update(projectId: TId, userId: number, accessLevel: number, fn?: Function): any; - remove(projectId: TId, userId: number, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectMergeRequests.d.ts b/types/gitlab/Models/ProjectMergeRequests.d.ts deleted file mode 100644 index 37b2ab33e6..0000000000 --- a/types/gitlab/Models/ProjectMergeRequests.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class ProjectMergeRequests extends BaseModel { - list(projectId: TId, fn?: Function): any; - list(projectId: TId, params?: DefParams, fn?: Function): any; - show(projectId: TId, mergerequestId: number, fn?: Function): any; - add(projectId: TId, sourceBranch: string, targetBranch: string, assigneeId: number, title: string, fn?: Function): any; - update(projectId: TId, mergerequestId: number, params: object, fn?: Function): any; - comment(projectId: TId, mergerequestId: number, note: any, fn?: Function): any; - merge(projectId: TId, mergerequestId: number, params: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectMilestones.d.ts b/types/gitlab/Models/ProjectMilestones.d.ts deleted file mode 100644 index d36d1c016a..0000000000 --- a/types/gitlab/Models/ProjectMilestones.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -type MilestonesCb = (milestones: any[]) => any; -type MilestoneCb = (milestones: any) => any; - -export class ProjectMilestones extends BaseModel { - list(projectId: TId, fn?: MilestonesCb): any; - all(projectId: TId, fn?: MilestonesCb): any; - show(projectId: TId, milestoneId: number, fn?: MilestoneCb): any; - add(projectId: TId, title: string, description: string, due_date: any, fn?: Function): any; - update(projectId: TId, milestoneId: number, title: string, description: string, due_date: any, state_event: any, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectRepository.d.ts b/types/gitlab/Models/ProjectRepository.d.ts deleted file mode 100644 index 7bef1b6212..0000000000 --- a/types/gitlab/Models/ProjectRepository.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -interface ShowFileParams { - file_path: string; - ref?: any; - file_id?: any; - [key: string]: any; -} - -interface AddTagParams { - id: TId; - tag_name: string; - ref: string; - message?: string; - release_description?: string; -} - -export class ProjectRepository extends BaseModel { - listBranches(projectId: TId, fn?: Function): any; - showBranch(projectId: TId, branchId: string, fn?: Function): any; - protectBranch(projectId: TId, branchId: string, params: object, fn?: Function): any; - unprotectBranch(projectId: TId, branchId: string, fn?: Function): any; - createBranch(params: object, fn?: Function): any; - deleteBranch(projectId: TId, branchId: string, fn?: Function): any; - addTag(params: AddTagParams, fn?: Function): any; - deleteTag(projectId: TId, tagName: string, fn?: Function): any; - showTag(projectId: TId, tagName: string, fn?: Function): any; - listTags(projectId: TId, fn?: Function): any; - listCommits(projectId: TId, fn?: Function): any; - showCommit(projectId: TId, sha: string, fn?: Function): any; - diffCommit(projectId: TId, sha: string, fn?: Function): any; - listTree(projectId: TId, fn?: Function): any; - listTree(projectId: TId, params?: object, fn?: Function): any; - showFile(projectId: TId, fn?: Function): any; - showFile(projectId: TId, params?: ShowFileParams, fn?: Function): any; - createFile(params?: object, fn?: Function): any; - updateFile(params?: object, fn?: Function): any; - compare(params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectServices.d.ts b/types/gitlab/Models/ProjectServices.d.ts deleted file mode 100644 index 25c59ae400..0000000000 --- a/types/gitlab/Models/ProjectServices.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { BaseModel, TId } from './../BaseModel'; - -type ServiceCb = (service: any) => any; - -export class ProjectServices extends BaseModel { - show(projectId: TId, serviceName: string, fn?: ServiceCb): any; - update(projectId: TId, serviceName: string, params: object, fn?: ServiceCb): any; - remove(projectId: TId, serviceName: string, fn?: ServiceCb): any; -} diff --git a/types/gitlab/Models/Projects.d.ts b/types/gitlab/Models/Projects.d.ts deleted file mode 100644 index 9ba8faa551..0000000000 --- a/types/gitlab/Models/Projects.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Runners } from './Runners'; -import { Pipelines } from './Pipelines'; -import { ProjectBuilds } from './ProjectBuilds'; -import { ProjectMergeRequests } from './ProjectMergeRequests'; -import { ProjectKeys } from './ProjectDeployKeys'; -import { ProjectMilestones } from './ProjectMilestones'; -import { ProjectRepository } from './ProjectRepository'; -import { ProjectLabels } from './ProjectLabels'; -import { ProjectIssues } from './ProjectIssues'; -import { ProjectHooks } from './ProjectHooks'; -import { ProjectMembers } from './ProjectMembers'; -import { BaseModel, DefParams, TId } from '../BaseModel'; -import { ProjectServices } from './ProjectServices'; - -type ProjectsCb = (projects: any[]) => any; - -export class Projects extends BaseModel { - - readonly members: ProjectMembers; - readonly hooks: ProjectHooks; - readonly issues: ProjectIssues; - readonly labels: ProjectLabels; - readonly repository: ProjectRepository; - readonly milestones: ProjectMilestones; - readonly deploy_keys: ProjectKeys; - readonly merge_requests: ProjectMergeRequests; - readonly services: ProjectServices; - readonly builds: ProjectBuilds; - readonly pipelines: Pipelines; - readonly runners: Runners; - - - all(fn?: ProjectsCb): any; - all(params?: DefParams, fn?: ProjectsCb): any; - allAdmin(fn?: Function): any; - allAdmin(params?: DefParams, fn?: Function): any; - show(projectId: TId, fn?: Function): any; - create(params: object, fn?: Function): any; - create_for_user(params: object, fn?: Function): any; - edit(projectId: TId, params: object, fn?: Function): any; - addMember(params?: object, fn?: Function): any; - editMember(params?: object, fn?: Function): any; - listMembers(params?: object, fn?: Function): any; - listCommits(params?: object, fn?: Function): any; - listTags(params?: object, fn?: Function): any; - remove(projectId: TId, fn?: Function): any; - fork(params?: object, fn?: Function): any; - share(params?: object, fn?: Function): any; - search(projectName: string, fn?: Function): any; - search(projectName: string, params?: object, fn?: Function): any; - listTriggers(projectId: TId, fn?: Function): any; - showTrigger(projectId: TId, token: string, fn?: Function): any; - createTrigger(params?: object, fn?: Function): any; - removeTrigger(projectId: TId, token: string, fn?: Function): any; -} diff --git a/types/gitlab/Models/Runners.d.ts b/types/gitlab/Models/Runners.d.ts deleted file mode 100644 index 1656fe0c5d..0000000000 --- a/types/gitlab/Models/Runners.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { BaseModel, DefParams, TId } from '../BaseModel'; - -export class Runners extends BaseModel { - all(projectId?: TId, fn?: Function): any; - all(projectId?: TId, params?: object, fn?: Function): any; - show(runnerId: number, fn?: Function): any; - update(runnerId: number, attributes: any, fn?: Function): any; - remove(runnerId: number, projectId: any, enable: any, fn?: Function): any; - enable(projectId: TId, runnerId: number, fn?: Function): any; - disable(projectId: TId, runnerId: number, fn?: Function): any; -} diff --git a/types/gitlab/Models/UserKeys.d.ts b/types/gitlab/Models/UserKeys.d.ts deleted file mode 100644 index 5182b5a2d1..0000000000 --- a/types/gitlab/Models/UserKeys.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseModel, DefParams, TId } from '../BaseModel'; - -export class UserKeys extends BaseModel { - all(userId?: TId, fn?: Function): any; - addKey(userId: string, title: string, key: any, fn?: Function): any; -} diff --git a/types/gitlab/Models/Users.d.ts b/types/gitlab/Models/Users.d.ts deleted file mode 100644 index e4572ac659..0000000000 --- a/types/gitlab/Models/Users.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { BaseModel, DefParams, TId } from '../BaseModel'; -import { UserKeys } from './UserKeys'; - -type UsersCb = (users: any[]) => any; -type UserCb = (user: any) => any; - -export class Users extends BaseModel { - readonly keys: UserKeys; - - all(fn?: UsersCb): any; - all(params?: DefParams, fn?: UsersCb): any; - current(fn?: Function): any; - show(userId: number, fn?: UserCb): any; - create(params?: DefParams, fn?: Function): any; - session(email: string, password: string, fn?: Function): any; - search(emailOrUsername: string, fn?: Function): any; -} diff --git a/types/gitlab/gitlab-tests.ts b/types/gitlab/gitlab-tests.ts deleted file mode 100644 index 00ab2c761e..0000000000 --- a/types/gitlab/gitlab-tests.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as lib from "gitlab"; - -const gitlab = lib({ - url: 'http://example.com', - token: 'abcdefghij123456' -}); - -const v3 = new lib.ApiV3({ }); - -// From README - -// Listing users -gitlab.users.all((users) => { }); - -// Listing projects -gitlab.projects.all((projects) => { }); - -// From examples/delet-service - -gitlab.projects.services.remove("pid", "name", (service) => { }); diff --git a/types/gitlab/index.d.ts b/types/gitlab/index.d.ts deleted file mode 100644 index 1ff52505ee..0000000000 --- a/types/gitlab/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Type definitions for gitlab 1.8 -// Project: https://github.com/node-gitlab/node-gitlab#readme -// Definitions by: sam -// AryloYeung -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - -import { ApiV3 } from "./ApiV3"; -import { ApiBaseOptions } from "./ApiBase"; - -declare namespace Gitlib { - const ApiV3: new(options: ApiBaseOptions) => ApiV3; -} - -declare function Gitlib(options: ApiBaseOptions): ApiV3; - -export = Gitlib; diff --git a/types/gitlab/tsconfig.json b/types/gitlab/tsconfig.json deleted file mode 100644 index f1297faf67..0000000000 --- a/types/gitlab/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "gitlab-tests.ts" - ] -} diff --git a/types/gitlab/tslint.json b/types/gitlab/tslint.json deleted file mode 100644 index 4d35d29327..0000000000 --- a/types/gitlab/tslint.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - // All are TODOs - "ban-types": false, - "interface-name": false, - "no-consecutive-blank-lines": false, - "no-padding": false, - "one-line": false, - "semicolon": false, - "strict-export-declare-modifiers": false, - "whitespace": false - } -} From 9cb83f7d867456ce599f0bef0f6db378150474b0 Mon Sep 17 00:00:00 2001 From: Paul Hobbel Date: Sun, 4 Nov 2018 17:51:29 +0100 Subject: [PATCH 06/80] Remove const before all enums --- types/youtube/index.d.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/types/youtube/index.d.ts b/types/youtube/index.d.ts index b04d727378..5739e4c6fd 100644 --- a/types/youtube/index.d.ts +++ b/types/youtube/index.d.ts @@ -5,6 +5,7 @@ // Josh Goldberg // Eliot Fallon // Terry Mun +// Paul Hobbel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -30,7 +31,7 @@ declare namespace YT /** * Known causes for player errors. */ - export const enum PlayerError + export enum PlayerError { /** * The request contained an invalid parameter value. @@ -61,7 +62,7 @@ declare namespace YT /** * Whether to auto-hide video controls. */ - export const enum AutoHide + export enum AutoHide { /** * Controls are visible throughout the video @@ -82,7 +83,7 @@ declare namespace YT /** * Whether to autoplay the video. */ - export const enum AutoPlay + export enum AutoPlay { /** * Video does not autoplay. @@ -98,7 +99,7 @@ declare namespace YT /** * Whether to use user-preferred or forced caption loading. */ - export const enum ClosedCaptionsLoadPolicy + export enum ClosedCaptionsLoadPolicy { /** * Defaults to the user's preferences. @@ -119,7 +120,7 @@ declare namespace YT /** * How video controls are shown. */ - export const enum Controls + export enum Controls { /** * Player controls do not display. @@ -140,7 +141,7 @@ declare namespace YT /** * Whether to allow keyboard controls. */ - export const enum KeyboardControls + export enum KeyboardControls { /** * Keyboard controls are enabled. @@ -156,7 +157,7 @@ declare namespace YT /** * Whether the JavaScript API should be enabled. */ - export const enum JsApi + export enum JsApi { /** * JavaScript API will be disabled. @@ -172,7 +173,7 @@ declare namespace YT /** * Whether to display the full-screen button. */ - export const enum FullscreenButton + export enum FullscreenButton { /** * The full screen button is hidden. @@ -188,7 +189,7 @@ declare namespace YT /** * Whether to show video annotations. */ - export const enum IvLoadPolicy + export enum IvLoadPolicy { /** * Video annotations will be shown. @@ -224,7 +225,7 @@ declare namespace YT /** * Whether a single video should be looped. */ - export const enum Loop + export enum Loop { /** * Video or playlist will be played only once. @@ -240,7 +241,7 @@ declare namespace YT /** * Comma separated list of video IDs to play after the URL path's video. */ - export const enum ModestBranding + export enum ModestBranding { /** * Player will contain full YouTube branding. @@ -256,7 +257,7 @@ declare namespace YT /** * Whether to playback video inline or full-screen in an HTML5 player on iOS */ - export const enum PlaysInline + export enum PlaysInline { /** * Playback in fullscreen. @@ -272,7 +273,7 @@ declare namespace YT /** * Whether to show related videos after the video finishes. */ - export const enum RelatedVideos + export enum RelatedVideos { /** * Hide related videos after playback is complete. @@ -288,7 +289,7 @@ declare namespace YT /** * Whether to show video information before playing. */ - export const enum ShowInfo + export enum ShowInfo { /** * Hide video title and uploader before video starts playing. From db9087e8cbb698b517a95019d2cba7ac84fc59bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Mon, 5 Nov 2018 08:51:32 +0100 Subject: [PATCH 07/80] tests for all properties in v14 --- types/intl-tel-input/index.d.ts | 6 +++--- types/intl-tel-input/intl-tel-input-tests.ts | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index b0752632c3..424c454bac 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -21,10 +21,10 @@ export interface IntlTelInputStatic { * initialise the plugin with optional options. * @param options options that can be provided during initialization. */ - (node: Element, options?: IntlTelInputOptions): IntlTelInput; + (node: Element, options?: Options): Plugin; } -export interface IntlTelInput { +export interface Plugin { /** * Remove the plugin from the input, and unbind any event listeners. */ @@ -103,7 +103,7 @@ export interface IntlTelInput { setPlaceholderNumberType(type: NumberType): void; } -export interface IntlTelInputOptions { +export interface Options { /** * Whether or not to allow the dropdown. If disabled, there is no dropdown * arrow, and the selected flag is not clickable. Also we display the diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index 9a84e98428..fdba2811e1 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -1,4 +1,5 @@ import IntlTelInput = require("intl-tel-input"); +import { NumberFormat } from "intl-tel-input"; const input = document.querySelector("#phone"); window.intlTelInput(input); @@ -41,7 +42,13 @@ window.intlTelInput(input).setCountry('gb'); window.intlTelInput(input).setNumber('+447733123456'); +window.intlTelInput(input).setPlaceholderNumberType(IntlTelInput.NumberType.FIXED_LINE); + const countryData = window.intlTelInput.getCountryData(); +const country = countryData[0]; +const dialCode = country.dialCode; +const iso2 = country.iso2; +const name = country.name; window.intlTelInput.loadUtils('build/js/utils.js'); @@ -67,3 +74,16 @@ window.intlTelInput(input, { onlyCountries: ['al'], utilsScript: '../../build/js/utils.js' }); + +window.intlTelInput(input, { + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: [ "us", "uk" ], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland"}, + preferredCountries: ["us", "gb"], + separateDialCode: false +}); From 690c89a88b72e3022ca47513dffa3ac457312ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Mon, 5 Nov 2018 09:51:02 +0100 Subject: [PATCH 08/80] definitions and tests for jQuery-wrapped version --- types/intl-tel-input/index.d.ts | 2 +- types/intl-tel-input/intl-tel-input-tests.ts | 1 - types/intl-tel-input/jquery-wrapped-tests.ts | 89 +++++++++++++++ types/intl-tel-input/jquery-wrapped.d.ts | 109 +++++++++++++++++++ types/intl-tel-input/tsconfig.json | 4 +- types/intl-tel-input/tslint.json | 5 +- 6 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 types/intl-tel-input/jquery-wrapped-tests.ts create mode 100644 types/intl-tel-input/jquery-wrapped.d.ts diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 424c454bac..ebb0de032f 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -68,7 +68,7 @@ export interface Plugin { * Get more information about a validation error. * Requires the utilsScript option. * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.validationError + * global enum ValidationError */ getValidationError(): ValidationError; diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index fdba2811e1..57d5c2f9c9 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -1,5 +1,4 @@ import IntlTelInput = require("intl-tel-input"); -import { NumberFormat } from "intl-tel-input"; const input = document.querySelector("#phone"); window.intlTelInput(input); diff --git a/types/intl-tel-input/jquery-wrapped-tests.ts b/types/intl-tel-input/jquery-wrapped-tests.ts new file mode 100644 index 0000000000..0888d7c09e --- /dev/null +++ b/types/intl-tel-input/jquery-wrapped-tests.ts @@ -0,0 +1,89 @@ +/// + +import * as IntlTelInput from "intl-tel-input"; + +$('#phone').intlTelInput(); + +$('#phone').intlTelInput({ + customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => { + return 'e.g. ' + selectedCountryPlaceholder; + } +}); + +$('#phone').intlTelInput({ + placeholderNumberType: IntlTelInput.NumberType.MOBILE, +}); + +$('#phone').intlTelInput({ + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + } +}); + +$('#phone').intlTelInput('destroy'); + +const extension = $('#phone').intlTelInput('getExtension'); + +const intlNumber = $('#phone').intlTelInput('getNumber'); +const ntlNumber = $('#phone').intlTelInput('getNumber', IntlTelInput.NumberFormat.NATIONAL); + +const numberType = $('#phone').intlTelInput('getNumberType'); +if (numberType === IntlTelInput.NumberType.MOBILE) {} + +const selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); + +const error = $('#phone').intlTelInput('getValidationError'); +if (error === IntlTelInput.ValidationError.TOO_SHORT) {} + +const isValid = $('#phone').intlTelInput('isValidNumber'); + +$('#phone').intlTelInput('setCountry', 'gb'); + +$('#phone').intlTelInput('setNumber', '+447733123456'); + +$('#phone').intlTelInput('setPlaceholderNumberType', IntlTelInput.NumberType.FIXED_LINE); + +const countryData = $.fn.intlTelInput.getCountryData(); +const country = countryData[0]; +const dialCode = country.dialCode; +const iso2 = country.iso2; +const name = country.name; + +$.fn.intlTelInput.loadUtils('build/js/utils.js'); + +$('#phone').intlTelInput({ + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + initialCountry: 'auto', + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + }, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + nationalMode: true, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: [ "us", "uk" ], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland"}, + preferredCountries: ["us", "gb"], + separateDialCode: false +}); diff --git a/types/intl-tel-input/jquery-wrapped.d.ts b/types/intl-tel-input/jquery-wrapped.d.ts new file mode 100644 index 0000000000..375fb32641 --- /dev/null +++ b/types/intl-tel-input/jquery-wrapped.d.ts @@ -0,0 +1,109 @@ +/// + +import { CountryData, NumberFormat, Options, NumberType, ValidationError } from "."; + +// Additional definitions for intl-tel-input (jQuery-wrapped) + +export interface JQueryPlugin { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): CountryData[]; + + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; + + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: Options): JQueryDeferred; + + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; + + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; + + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat?: NumberFormat): string; + (method: string, numberFormat: NumberFormat): string; + + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): NumberType; + + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): CountryData; + + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + (method: 'getValidationError'): ValidationError; + + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; + + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; + + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; + + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + (method: 'setPlaceholderNumberType', type: NumberType): void; + } + +declare global { + interface JQuery { + intlTelInput: JQueryPlugin; + } +} diff --git a/types/intl-tel-input/tsconfig.json b/types/intl-tel-input/tsconfig.json index 380d60229d..88fae013ec 100644 --- a/types/intl-tel-input/tsconfig.json +++ b/types/intl-tel-input/tsconfig.json @@ -19,6 +19,8 @@ }, "files": [ "index.d.ts", - "intl-tel-input-tests.ts" + "jquery-wrapped.d.ts", + "intl-tel-input-tests.ts", + "jquery-wrapped-tests.ts" ] } \ No newline at end of file diff --git a/types/intl-tel-input/tslint.json b/types/intl-tel-input/tslint.json index f93cf8562a..08b1465cd6 100644 --- a/types/intl-tel-input/tslint.json +++ b/types/intl-tel-input/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "unified-signatures": false + } } From 4f78b8c5e1d62afc66c43a996ab2340f48981512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Mon, 5 Nov 2018 10:26:26 +0100 Subject: [PATCH 09/80] formatting --- types/intl-tel-input/index.d.ts | 468 +++++++++--------- types/intl-tel-input/intl-tel-input-tests.ts | 62 +-- types/intl-tel-input/jquery-wrapped-tests.ts | 62 +-- types/intl-tel-input/jquery-wrapped.d.ts | 26 +- types/intl-tel-input/tsconfig.json | 2 +- types/intl-tel-input/v13/index.d.ts | 458 ++++++++--------- .../v13/intl-tel-input-tests.ts | 50 +- types/intl-tel-input/v13/tsconfig.json | 2 +- 8 files changed, 565 insertions(+), 565 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index ebb0de032f..580a27d395 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -5,286 +5,286 @@ // TypeScript Version: 2.3 export interface IntlTelInputStatic { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): CountryData[]; + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): CountryData[]; - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (node: Element, options?: Options): Plugin; + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (node: Element, options?: Options): Plugin; } export interface Plugin { - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - destroy(): void; + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + destroy(): void; - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - getExtension(): string; + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + getExtension(): string; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - getNumber(numberFormat?: NumberFormat): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + getNumber(numberFormat?: NumberFormat): string; - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - getNumberType(): NumberType; + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + getNumberType(): NumberType; - /** - * Get the country data for the currently selected flag. - */ - getSelectedCountryData(): CountryData; + /** + * Get the country data for the currently selected flag. + */ + getSelectedCountryData(): CountryData; - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum ValidationError - */ - getValidationError(): ValidationError; + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + getValidationError(): ValidationError; - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - isValidNumber(): boolean; + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + isValidNumber(): boolean; - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - setCountry(countryCode: string): void; + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + setCountry(countryCode: string): void; - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - setNumber(aNumber: string): void; + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + setNumber(aNumber: string): void; - /** - * Set the type of the placeholder number - * @param type Placeholder number type to be set - */ - setPlaceholderNumberType(type: NumberType): void; + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + setPlaceholderNumberType(type: NumberType): void; } export interface Options { - /** - * Whether or not to allow the dropdown. If disabled, there is no dropdown - * arrow, and the selected flag is not clickable. Also we display the - * selected flag on the right instead because it is just a marker of state. - * Default = true - */ - allowDropdown?: boolean; + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + * Default = true + */ + allowDropdown?: boolean; - /** - * If there is just a dial code in the input: remove it on blur or submit, - * and re-add it on focus. This is to prevent just a dial code getting - * submitted with the form. Requires nationalMode to be set to false. - * Default = true - */ - autoHideDialCode?: boolean; + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + * Default = true + */ + autoHideDialCode?: boolean; - /** - * Set the input's placeholder to an example number for the selected country, and update it if the country changes. - * You can specify the number type using the placeholderNumberType option. - * By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one. - * You can also set it to "aggressive", which will replace any existing placeholder, or "off". - * Requires the utilsScript option. - * Default = "polite" - */ - autoPlaceholder?: "off" | "polite" | "aggressive"; + /** + * Set the input's placeholder to an example number for the selected country, and update it if the country changes. + * You can specify the number type using the placeholderNumberType option. + * By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one. + * You can also set it to "aggressive", which will replace any existing placeholder, or "off". + * Requires the utilsScript option. + * Default = "polite" + */ + autoPlaceholder?: "off" | "polite" | "aggressive"; - /** - * Change the placeholder generated by autoPlaceholder. Must return a string. - * Default = null - */ - customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + * Default = null + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; - /** - * Expects a node e.g. document.body. Instead of putting the country dropdown next to the input, - * append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript. - * This is useful when the input is inside a container with overflow: hidden. - * Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event. - * Default = null - */ - dropdownContainer?: Node; + /** + * Expects a node e.g. document.body. Instead of putting the country dropdown next to the input, + * append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript. + * This is useful when the input is inside a container with overflow: hidden. + * Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event. + * Default = null + */ + dropdownContainer?: Node; - /** - * In the dropdown, display all countries except the ones you specify here. - * Default = null - */ - excludeCountries?: string[]; + /** + * In the dropdown, display all countries except the ones you specify here. + * Default = null + */ + excludeCountries?: string[]; - /** - * Format the input value (according to the nationalMode option) during initialisation, and on setNumber. - * Requires the utilsScript option. - * Default = true - */ - formatOnDisplay?: boolean; + /** + * Format the input value (according to the nationalMode option) during initialisation, and on setNumber. + * Requires the utilsScript option. + * Default = true + */ + formatOnDisplay?: boolean; - /** - * When setting initialCountry to "auto", you must use this option to - * specify a custom function that looks up the user's location, - * and then calls the success callback with the relevant country code. - * Also note that when instantiating the plugin, if the Promise object is defined, - * one of those is returned under the promise instance property, so you can - * do something like iti.promise.then(callback) to know when initialisation requests like this have completed. - * Default = null - */ - geoIpLookup?: (callback: (countryCode: string) => void) => void; + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location, + * and then calls the success callback with the relevant country code. + * Also note that when instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can + * do something like iti.promise.then(callback) to know when initialisation requests like this have completed. + * Default = null + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; - /** - * Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name, - * replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber). - * This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled. - * Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. - * Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation. - * Default = "" - */ - hiddenInput?: string; + /** + * Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name, + * replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber). + * This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled. + * Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. + * Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation. + * Default = "" + */ + hiddenInput?: string; - /** - * Set the initial country selection by specifying it's country code. - * You can also set it to "auto", which will lookup the user's country based - * on their IP address (requires the geoIpLookup option). - * Note that the "auto" option will not update the country selection if the - * input already contains a number. If you leave initialCountry blank, - * it will default to the first country in the list. - */ - initialCountry?: string; + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; - /** - * Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' } - * Default = {} - */ - localizedCountries?: object; + /** + * Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' } + * Default = {} + */ + localizedCountries?: object; - /** - * Allow users to enter national numbers (and not have to think about - * international dial codes). Formatting, validation and placeholders still - * work. Then you can use getNumber to extract a full international number. - * This option now defaults to true, and it is recommended that you leave it - * that way as it provides a better experience for the user. - * Default = true - */ - nationalMode?: boolean; + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + * Default = true + */ + nationalMode?: boolean; - /** - * In the dropdown, display only the countries you specify. - * Default = undefined - */ - onlyCountries?: string[]; + /** + * In the dropdown, display only the countries you specify. + * Default = undefined + */ + onlyCountries?: string[]; - /** - * Specify one of the keys from the global enum intlTelInputUtils.numberType - * e.g. "FIXED_LINE" to set the number type to use for the placeholder. - * Default = MOBILE - */ - placeholderNumberType?: NumberType; + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + * Default = MOBILE + */ + placeholderNumberType?: NumberType; - /** - * Specify the countries to appear at the top of the list. - * Default = ["us", "gb"] - */ - preferredCountries?: string[]; + /** + * Specify the countries to appear at the top of the list. + * Default = ["us", "gb"] + */ + preferredCountries?: string[]; - /** - * Display the country dial code next to the selected flag so it's not part - * of the typed number. Note that this will disable nationalMode because - * technically we are dealing with international numbers, but with the - * dial code separated. - * Default = false - */ - separateDialCode?: boolean; + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + * Default = false + */ + separateDialCode?: boolean; - /** - * Enable formatting/validation etc. by specifying the URL of the included utils.js script - * (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event) - * to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined, - * one of those is returned under the promise instance property, so you can do something like - * iti.promise.then(callback) to know when initialisation requests like this have finished. - * Note that if you're lazy loading the plugin script itself (intlTelInput.js) - * this will not work and you will need to use the loadUtils method instead. - * Example: "build/js/utils.js" - * Default = "" - */ - utilsScript?: string; + /** + * Enable formatting/validation etc. by specifying the URL of the included utils.js script + * (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event) + * to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can do something like + * iti.promise.then(callback) to know when initialisation requests like this have finished. + * Note that if you're lazy loading the plugin script itself (intlTelInput.js) + * this will not work and you will need to use the loadUtils method instead. + * Example: "build/js/utils.js" + * Default = "" + */ + utilsScript?: string; } export interface CountryData { - name: string; - iso2: string; - dialCode: string; + name: string; + iso2: string; + dialCode: string; } export enum NumberFormat { - E164 = 0, - INTERNATIONAL = 1, - NATIONAL = 2, - RFC3966 = 3 + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 } export enum NumberType { - FIXED_LINE = 0, - MOBILE = 1, - FIXED_LINE_OR_MOBILE = 2, - TOLL_FREE = 3, - PREMIUM_RATE = 4, - SHARED_COST = 5, - VOIP = 6, - PERSONAL_NUMBER = 7, - PAGER = 8, - UAN = 9, - VOICEMAIL = 10, - UNKNOWN = -1 + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 } export enum ValidationError { - IS_POSSIBLE = 0, - INVALID_COUNTRY_CODE = 1, - TOO_SHORT = 2, - TOO_LONG = 3, - NOT_A_NUMBER = 4 + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 } declare global { - interface Window { - intlTelInput: IntlTelInputStatic; - } + interface Window { + intlTelInput: IntlTelInputStatic; + } } diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index 57d5c2f9c9..8fcc76840b 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -4,20 +4,20 @@ const input = document.querySelector("#phone"); window.intlTelInput(input); window.intlTelInput(input, { - customPlaceholder(selectedCountryPlaceholder, selectedCountryData) { - return 'e.g. ' + selectedCountryPlaceholder; - } + customPlaceholder(selectedCountryPlaceholder, selectedCountryData) { + return 'e.g. ' + selectedCountryPlaceholder; + } }); window.intlTelInput(input, { - placeholderNumberType: IntlTelInput.NumberType.MOBILE, + placeholderNumberType: IntlTelInput.NumberType.MOBILE, }); window.intlTelInput(input, { - geoIpLookup(callback) { - const countryCode = 'XY'; - callback(countryCode); - } + geoIpLookup(callback) { + const countryCode = 'XY'; + callback(countryCode); + } }); window.intlTelInput(input).destroy(); @@ -28,12 +28,12 @@ const intlNumber = window.intlTelInput(input).getNumber(); const ntlNumber = window.intlTelInput(input).getNumber(IntlTelInput.NumberFormat.NATIONAL); const numberType = window.intlTelInput(input).getNumberType(); -if (numberType === IntlTelInput.NumberType.MOBILE) {} +if (numberType === IntlTelInput.NumberType.MOBILE) { } const selectedCountryData = window.intlTelInput(input).getSelectedCountryData(); const error = window.intlTelInput(input).getValidationError(); -if (error === IntlTelInput.ValidationError.TOO_SHORT) {} +if (error === IntlTelInput.ValidationError.TOO_SHORT) { } const isValid = window.intlTelInput(input).isValidNumber(); @@ -52,37 +52,37 @@ const name = country.name; window.intlTelInput.loadUtils('build/js/utils.js'); window.intlTelInput(input, { - utilsScript: '../../build/js/utils.js' + utilsScript: '../../build/js/utils.js' }); window.intlTelInput(input, { - initialCountry: 'auto', - geoIpLookup: (callback) => { - const countryCode = 'XY'; - callback(countryCode); - }, - utilsScript: '../../build/js/utils.js' + initialCountry: 'auto', + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + }, + utilsScript: '../../build/js/utils.js' }); window.intlTelInput(input, { - nationalMode: true, - utilsScript: '../../build/js/utils.js' + nationalMode: true, + utilsScript: '../../build/js/utils.js' }); window.intlTelInput(input, { - onlyCountries: ['al'], - utilsScript: '../../build/js/utils.js' + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' }); window.intlTelInput(input, { - allowDropdown: false, - autoHideDialCode: false, - autoPlaceholder: "aggressive", - dropdownContainer: document.body, - excludeCountries: [ "us", "uk" ], - formatOnDisplay: false, - hiddenInput: "hidden-input", - localizedCountries: { de: "Deutschland"}, - preferredCountries: ["us", "gb"], - separateDialCode: false + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: ["us", "uk"], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland" }, + preferredCountries: ["us", "gb"], + separateDialCode: false }); diff --git a/types/intl-tel-input/jquery-wrapped-tests.ts b/types/intl-tel-input/jquery-wrapped-tests.ts index 0888d7c09e..7fe6f0b3b7 100644 --- a/types/intl-tel-input/jquery-wrapped-tests.ts +++ b/types/intl-tel-input/jquery-wrapped-tests.ts @@ -5,20 +5,20 @@ import * as IntlTelInput from "intl-tel-input"; $('#phone').intlTelInput(); $('#phone').intlTelInput({ - customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => { - return 'e.g. ' + selectedCountryPlaceholder; - } + customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => { + return 'e.g. ' + selectedCountryPlaceholder; + } }); $('#phone').intlTelInput({ - placeholderNumberType: IntlTelInput.NumberType.MOBILE, + placeholderNumberType: IntlTelInput.NumberType.MOBILE, }); $('#phone').intlTelInput({ - geoIpLookup: (callback) => { - const countryCode = 'XY'; - callback(countryCode); - } + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + } }); $('#phone').intlTelInput('destroy'); @@ -29,12 +29,12 @@ const intlNumber = $('#phone').intlTelInput('getNumber'); const ntlNumber = $('#phone').intlTelInput('getNumber', IntlTelInput.NumberFormat.NATIONAL); const numberType = $('#phone').intlTelInput('getNumberType'); -if (numberType === IntlTelInput.NumberType.MOBILE) {} +if (numberType === IntlTelInput.NumberType.MOBILE) { } const selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); const error = $('#phone').intlTelInput('getValidationError'); -if (error === IntlTelInput.ValidationError.TOO_SHORT) {} +if (error === IntlTelInput.ValidationError.TOO_SHORT) { } const isValid = $('#phone').intlTelInput('isValidNumber'); @@ -53,37 +53,37 @@ const name = country.name; $.fn.intlTelInput.loadUtils('build/js/utils.js'); $('#phone').intlTelInput({ - utilsScript: '../../build/js/utils.js' + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - initialCountry: 'auto', - geoIpLookup: (callback) => { - const countryCode = 'XY'; - callback(countryCode); - }, - utilsScript: '../../build/js/utils.js' + initialCountry: 'auto', + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + }, + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - nationalMode: true, - utilsScript: '../../build/js/utils.js' + nationalMode: true, + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - onlyCountries: ['al'], - utilsScript: '../../build/js/utils.js' + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - allowDropdown: false, - autoHideDialCode: false, - autoPlaceholder: "aggressive", - dropdownContainer: document.body, - excludeCountries: [ "us", "uk" ], - formatOnDisplay: false, - hiddenInput: "hidden-input", - localizedCountries: { de: "Deutschland"}, - preferredCountries: ["us", "gb"], - separateDialCode: false + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: ["us", "uk"], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland" }, + preferredCountries: ["us", "gb"], + separateDialCode: false }); diff --git a/types/intl-tel-input/jquery-wrapped.d.ts b/types/intl-tel-input/jquery-wrapped.d.ts index 375fb32641..e83e8285a1 100644 --- a/types/intl-tel-input/jquery-wrapped.d.ts +++ b/types/intl-tel-input/jquery-wrapped.d.ts @@ -1,6 +1,6 @@ /// -import { CountryData, NumberFormat, Options, NumberType, ValidationError } from "."; +import * as IntlTelInput from "./index"; // Additional definitions for intl-tel-input (jQuery-wrapped) @@ -9,7 +9,7 @@ export interface JQueryPlugin { * Get all of the plugin's country data - either to re-use elsewhere * e.g. to populate a country dropdown. */ - getCountryData(): CountryData[]; + getCountryData(): IntlTelInput.CountryData[]; /** * Load the utils.js script (included in the lib directory) to enable @@ -21,7 +21,7 @@ export interface JQueryPlugin { * initialise the plugin with optional options. * @param options options that can be provided during initialization. */ - (options?: Options): JQueryDeferred; + (options?: IntlTelInput.Options): JQueryDeferred; /** * Remove the plugin from the input, and unbind any event listeners. @@ -45,8 +45,8 @@ export interface JQueryPlugin { * international number. * @param numberFormat the format in which the number will be returned. */ - (method: 'getNumber', numberFormat?: NumberFormat): string; - (method: string, numberFormat: NumberFormat): string; + (method: 'getNumber', numberFormat?: IntlTelInput.NumberFormat): string; + (method: string, numberFormat: IntlTelInput.NumberFormat): string; /** * Get the type (fixed-line/mobile/toll-free etc) of the current number. @@ -56,12 +56,12 @@ export interface JQueryPlugin { * Note that in the US there's no way to differentiate between fixed-line and * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. */ - (method: 'getNumberType'): NumberType; + (method: 'getNumberType'): IntlTelInput.NumberType; /** * Get the country data for the currently selected flag. */ - (method: 'getSelectedCountryData'): CountryData; + (method: 'getSelectedCountryData'): IntlTelInput.CountryData; /** * Get more information about a validation error. @@ -69,7 +69,7 @@ export interface JQueryPlugin { * Returns an integer, which you can match against the various options in the * global enum ValidationError */ - (method: 'getValidationError'): ValidationError; + (method: 'getValidationError'): IntlTelInput.ValidationError; /** * Validate the current number. Expects an internationally formatted number @@ -99,11 +99,11 @@ export interface JQueryPlugin { * Set the type of the placeholder number * @param type Placeholder number type to be set */ - (method: 'setPlaceholderNumberType', type: NumberType): void; - } + (method: 'setPlaceholderNumberType', type: IntlTelInput.NumberType): void; +} declare global { - interface JQuery { - intlTelInput: JQueryPlugin; - } + interface JQuery { + intlTelInput: JQueryPlugin; + } } diff --git a/types/intl-tel-input/tsconfig.json b/types/intl-tel-input/tsconfig.json index 88fae013ec..5409f40b10 100644 --- a/types/intl-tel-input/tsconfig.json +++ b/types/intl-tel-input/tsconfig.json @@ -23,4 +23,4 @@ "intl-tel-input-tests.ts", "jquery-wrapped-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/intl-tel-input/v13/index.d.ts b/types/intl-tel-input/v13/index.d.ts index 34493a8b75..8221c73c62 100644 --- a/types/intl-tel-input/v13/index.d.ts +++ b/types/intl-tel-input/v13/index.d.ts @@ -8,253 +8,253 @@ declare namespace IntlTelInput { - interface Plugin { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): CountryData[]; - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; + interface Plugin { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): CountryData[]; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - (method: 'destroy'): void; - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - (method: 'getExtension'): string; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - */ - (method: 'getNumber'): string; - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - (method: 'getNumberType'): intlTelInputUtils.numberType; - /** - * Get the country data for the currently selected flag. - */ - (method: 'getSelectedCountryData'): IntlTelInput.CountryData; - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.validationError - */ - (method: 'getValidationError'): intlTelInputUtils.validationError; - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - (method: 'isValidNumber'): boolean; - (method: string): void; - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - (method: 'setCountry', countryCode: string): void; - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - (method: 'setNumber', aNumber: string): void; - (method: string, value: string): void; + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + */ + (method: 'getNumber'): string; + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): intlTelInputUtils.numberType; + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): IntlTelInput.CountryData; + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.validationError + */ + (method: 'getValidationError'): intlTelInputUtils.validationError; + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; + (method: string): void; + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; + (method: string, value: string): void; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - (method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string; - (method: string, numberFormat: intlTelInputUtils.numberFormat): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string; + (method: string, numberFormat: intlTelInputUtils.numberFormat): string; - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (options?: IntlTelInput.Options): JQueryDeferred; - } + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: IntlTelInput.Options): JQueryDeferred; + } - interface Options { - /** - * Whether or not to allow the dropdown. If disabled, there is no dropdown - * arrow, and the selected flag is not clickable. Also we display the - * selected flag on the right instead because it is just a marker of state. - */ - allowDropdown?: boolean; - /** - * If there is just a dial code in the input: remove it on blur or submit, - * and re-add it on focus. This is to prevent just a dial code getting - * submitted with the form. Requires nationalMode to be set to false. - */ - autoHideDialCode?: boolean; - /** - * Set the input's placeholder to an example number for the selected country. - * You can specify the number type using the numberType option. - * If there is already a placeholder attribute set on the input then that - * will take precedence. Requires the utilsScript option. - */ - autoPlaceholder?: boolean; - /** - * Change the placeholder generated by autoPlaceholder. Must return a string. - */ - customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; - /** - * Specify the container for the country dropdown (use a jQuery selector - * e.g. "body"). This is useful when the input is within a scrolling element, - * or an element with overflow: hidden. Wherever you put the dropdown it - * will automatically close on the window scroll event to prevent positioning - * issues. If you want it to close when a different element is scrolled - * (such as the input's parent), simply listen for the that scroll event, - * and trigger $(window).scroll() e.g. - */ - dropdownContainer?: string; - /** - * Don't display the countries you specify. - */ - excludeCountries?: Array; - /** - * Format the input value during initialisation. - */ - formatOnInit?: boolean; - /** - * When setting initialCountry to "auto", you must use this option to - * specify a custom function that looks up the user's location. Also note - * that when instantiating the plugin, we now return a deferred object, so - * you can use .done(callback) to know when initialisation requests like - * this have completed. - * Note that the callback must still be called in the event of an error. - */ - geoIpLookup?: (callback: (countryCode: string) => void) => void; - /** - * Set the initial country selection by specifying it's country code. - * You can also set it to "auto", which will lookup the user's country based - * on their IP address (requires the geoIpLookup option). - * Note that the "auto" option will not update the country selection if the - * input already contains a number. If you leave initialCountry blank, - * it will default to the first country in the list. - */ - initialCountry?: string; - /** - * Allow users to enter national numbers (and not have to think about - * international dial codes). Formatting, validation and placeholders still - * work. Then you can use getNumber to extract a full international number. - * This option now defaults to true, and it is recommended that you leave it - * that way as it provides a better experience for the user. - */ - nationalMode?: boolean; - /** - * Display only the countries you specify. - */ - onlyCountries?: Array; - /** - * Specify one of the keys from the global enum intlTelInputUtils.numberType - * e.g. "FIXED_LINE" to set the number type to use for the placeholder. - */ - placeholderNumberType?: - | "FIXED_LINE_OR_MOBILE" - | "FIXED_LINE" - | "MOBILE" - | "PAGER" - | "PERSONAL_NUMBER" - | "PREMIUM_RATE" - | "SHARED_COST" - | "TOLL_FREE" - | "UAN" - | "UNKNOWN" - | "VOICEMAIL" - | "VOIP"; - /** - * Specify the countries to appear at the top of the list. - */ - preferredCountries?: Array; - /** - * Display the country dial code next to the selected flag so it's not part - * of the typed number. Note that this will disable nationalMode because - * technically we are dealing with international numbers, but with the - * dial code separated. - */ - separateDialCode?: boolean; - /** - * Enable formatting/validation etc. by specifying the path to the included - * utils.js script, which is fetched only when the page has finished loading - * (on window.load) to prevent blocking. When instantiating the plugin, - * we return a deferred object, so you can use .done(callback) to know when - * initialisation requests like this have finished. Note that if you're - * lazy loading the plugin script itself (intlTelInput.js) this will not - * work and you will need to use the loadUtils method instead. - */ - utilsScript?: string; - } + interface Options { + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + */ + allowDropdown?: boolean; + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + */ + autoHideDialCode?: boolean; + /** + * Set the input's placeholder to an example number for the selected country. + * You can specify the number type using the numberType option. + * If there is already a placeholder attribute set on the input then that + * will take precedence. Requires the utilsScript option. + */ + autoPlaceholder?: boolean; + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; + /** + * Specify the container for the country dropdown (use a jQuery selector + * e.g. "body"). This is useful when the input is within a scrolling element, + * or an element with overflow: hidden. Wherever you put the dropdown it + * will automatically close on the window scroll event to prevent positioning + * issues. If you want it to close when a different element is scrolled + * (such as the input's parent), simply listen for the that scroll event, + * and trigger $(window).scroll() e.g. + */ + dropdownContainer?: string; + /** + * Don't display the countries you specify. + */ + excludeCountries?: Array; + /** + * Format the input value during initialisation. + */ + formatOnInit?: boolean; + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location. Also note + * that when instantiating the plugin, we now return a deferred object, so + * you can use .done(callback) to know when initialisation requests like + * this have completed. + * Note that the callback must still be called in the event of an error. + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + */ + nationalMode?: boolean; + /** + * Display only the countries you specify. + */ + onlyCountries?: Array; + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + */ + placeholderNumberType?: + | "FIXED_LINE_OR_MOBILE" + | "FIXED_LINE" + | "MOBILE" + | "PAGER" + | "PERSONAL_NUMBER" + | "PREMIUM_RATE" + | "SHARED_COST" + | "TOLL_FREE" + | "UAN" + | "UNKNOWN" + | "VOICEMAIL" + | "VOIP"; + /** + * Specify the countries to appear at the top of the list. + */ + preferredCountries?: Array; + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + */ + separateDialCode?: boolean; + /** + * Enable formatting/validation etc. by specifying the path to the included + * utils.js script, which is fetched only when the page has finished loading + * (on window.load) to prevent blocking. When instantiating the plugin, + * we return a deferred object, so you can use .done(callback) to know when + * initialisation requests like this have finished. Note that if you're + * lazy loading the plugin script itself (intlTelInput.js) this will not + * work and you will need to use the loadUtils method instead. + */ + utilsScript?: string; + } - interface CountryData { - name: string; - iso2: string; - dialCode: string; - } + interface CountryData { + name: string; + iso2: string; + dialCode: string; + } } declare namespace intlTelInputUtils { const enum numberFormat { - E164 = 0, - INTERNATIONAL = 1, - NATIONAL = 2, - RFC3966 = 3 + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 } const enum numberType { - FIXED_LINE = 0, - MOBILE = 1, - FIXED_LINE_OR_MOBILE = 2, - TOLL_FREE = 3, - PREMIUM_RATE = 4, - SHARED_COST = 5, - VOIP = 6, - PERSONAL_NUMBER = 7, - PAGER = 8, - UAN = 9, - VOICEMAIL = 10, - UNKNOWN = -1 + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 } const enum validationError { - IS_POSSIBLE = 0, - INVALID_COUNTRY_CODE = 1, - TOO_SHORT = 2, - TOO_LONG = 3, - NOT_A_NUMBER = 4 + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 } } interface JQuery { - intlTelInput: IntlTelInput.Plugin; + intlTelInput: IntlTelInput.Plugin; } diff --git a/types/intl-tel-input/v13/intl-tel-input-tests.ts b/types/intl-tel-input/v13/intl-tel-input-tests.ts index e91a5deef1..497a8dff67 100644 --- a/types/intl-tel-input/v13/intl-tel-input-tests.ts +++ b/types/intl-tel-input/v13/intl-tel-input-tests.ts @@ -1,22 +1,22 @@ $('#phone').intlTelInput(); $('#phone').intlTelInput({ - customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) { - return 'e.g. ' + selectedCountryPlaceholder; - } + customPlaceholder: function (selectedCountryPlaceholder, selectedCountryData) { + return 'e.g. ' + selectedCountryPlaceholder; + } }); $('#phone').intlTelInput({ - placeholderNumberType: "MOBILE", + placeholderNumberType: "MOBILE", }); $('#phone').intlTelInput({ - geoIpLookup: function(callback) { - $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { - let countryCode = (resp && resp.country) ? resp.country : ''; - callback(countryCode); - }); - } + geoIpLookup: function (callback) { + $.get('http://ipinfo.io', function () { }, 'jsonp').always(function (resp) { + let countryCode = (resp && resp.country) ? resp.country : ''; + callback(countryCode); + }); + } }); $('#phone').intlTelInput('destroy'); @@ -27,12 +27,12 @@ let intlNumber = $('#phone').intlTelInput('getNumber'); let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); let numberType = $('#phone').intlTelInput('getNumberType'); -if (numberType === intlTelInputUtils.numberType.MOBILE) {} +if (numberType === intlTelInputUtils.numberType.MOBILE) { } let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); let error = $('#phone').intlTelInput('getValidationError'); -if (error === intlTelInputUtils.validationError.TOO_SHORT) {} +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } let isValid = $('#phone').intlTelInput('isValidNumber'); @@ -45,26 +45,26 @@ let countryData = $.fn.intlTelInput.getCountryData(); $.fn.intlTelInput.loadUtils('build/js/utils.js'); $('#phone').intlTelInput({ - utilsScript: '../../build/js/utils.js' + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - initialCountry: 'auto', - geoIpLookup: function(callback) { - $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { - let countryCode = (resp && resp.country) ? resp.country : ''; - callback(countryCode); - }); - }, - utilsScript: '../../build/js/utils.js' + initialCountry: 'auto', + geoIpLookup: function (callback) { + $.get('http://ipinfo.io', function () { }, 'jsonp').always(function (resp) { + let countryCode = (resp && resp.country) ? resp.country : ''; + callback(countryCode); + }); + }, + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - nationalMode: true, - utilsScript: '../../build/js/utils.js' + nationalMode: true, + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - onlyCountries: ['al'], - utilsScript: '../../build/js/utils.js' + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' }); diff --git a/types/intl-tel-input/v13/tsconfig.json b/types/intl-tel-input/v13/tsconfig.json index b7e1b435b1..f166c4da54 100644 --- a/types/intl-tel-input/v13/tsconfig.json +++ b/types/intl-tel-input/v13/tsconfig.json @@ -24,4 +24,4 @@ "index.d.ts", "intl-tel-input-tests.ts" ] -} \ No newline at end of file +} From 829933ef2f2a7399b0bfb2c776608d6aa6f809d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Mon, 5 Nov 2018 10:57:06 +0100 Subject: [PATCH 10/80] use original names so minimal changes are required when updating --- types/intl-tel-input/index.d.ts | 508 ++++++++++--------- types/intl-tel-input/intl-tel-input-tests.ts | 14 +- types/intl-tel-input/jquery-wrapped-tests.ts | 34 +- types/intl-tel-input/jquery-wrapped.d.ts | 180 ++++--- 4 files changed, 366 insertions(+), 370 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 580a27d395..45ffbcfb12 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -4,287 +4,289 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -export interface IntlTelInputStatic { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): CountryData[]; +declare namespace IntlTelInput { + interface Static { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): intlTelInputUtils.CountryData[]; - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (node: Element, options?: Options): Plugin; -} + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (node: Element, options?: Options): Plugin; + } -export interface Plugin { - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - destroy(): void; + interface Plugin { + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + destroy(): void; - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - getExtension(): string; + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + getExtension(): string; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - getNumber(numberFormat?: NumberFormat): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + getNumber(numberFormat?: intlTelInputUtils.numberFormat): string; - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - getNumberType(): NumberType; + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + getNumberType(): intlTelInputUtils.numberType; - /** - * Get the country data for the currently selected flag. - */ - getSelectedCountryData(): CountryData; + /** + * Get the country data for the currently selected flag. + */ + getSelectedCountryData(): intlTelInputUtils.CountryData; - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum ValidationError - */ - getValidationError(): ValidationError; + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + getValidationError(): intlTelInputUtils.validationError; - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - isValidNumber(): boolean; + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + isValidNumber(): boolean; - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - setCountry(countryCode: string): void; + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + setCountry(countryCode: string): void; - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - setNumber(aNumber: string): void; + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + setNumber(aNumber: string): void; - /** - * Set the type of the placeholder number - * @param type Placeholder number type to be set - */ - setPlaceholderNumberType(type: NumberType): void; -} + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + setPlaceholderNumberType(type: intlTelInputUtils.numberType): void; + } -export interface Options { - /** - * Whether or not to allow the dropdown. If disabled, there is no dropdown - * arrow, and the selected flag is not clickable. Also we display the - * selected flag on the right instead because it is just a marker of state. - * Default = true - */ - allowDropdown?: boolean; + interface Options { + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + * Default = true + */ + allowDropdown?: boolean; - /** - * If there is just a dial code in the input: remove it on blur or submit, - * and re-add it on focus. This is to prevent just a dial code getting - * submitted with the form. Requires nationalMode to be set to false. - * Default = true - */ - autoHideDialCode?: boolean; + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + * Default = true + */ + autoHideDialCode?: boolean; - /** - * Set the input's placeholder to an example number for the selected country, and update it if the country changes. - * You can specify the number type using the placeholderNumberType option. - * By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one. - * You can also set it to "aggressive", which will replace any existing placeholder, or "off". - * Requires the utilsScript option. - * Default = "polite" - */ - autoPlaceholder?: "off" | "polite" | "aggressive"; + /** + * Set the input's placeholder to an example number for the selected country, and update it if the country changes. + * You can specify the number type using the placeholderNumberType option. + * By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one. + * You can also set it to "aggressive", which will replace any existing placeholder, or "off". + * Requires the utilsScript option. + * Default = "polite" + */ + autoPlaceholder?: "off" | "polite" | "aggressive"; - /** - * Change the placeholder generated by autoPlaceholder. Must return a string. - * Default = null - */ - customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + * Default = null + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: intlTelInputUtils.CountryData) => string; - /** - * Expects a node e.g. document.body. Instead of putting the country dropdown next to the input, - * append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript. - * This is useful when the input is inside a container with overflow: hidden. - * Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event. - * Default = null - */ - dropdownContainer?: Node; + /** + * Expects a node e.g. document.body. Instead of putting the country dropdown next to the input, + * append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript. + * This is useful when the input is inside a container with overflow: hidden. + * Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event. + * Default = null + */ + dropdownContainer?: Node; - /** - * In the dropdown, display all countries except the ones you specify here. - * Default = null - */ - excludeCountries?: string[]; + /** + * In the dropdown, display all countries except the ones you specify here. + * Default = null + */ + excludeCountries?: string[]; - /** - * Format the input value (according to the nationalMode option) during initialisation, and on setNumber. - * Requires the utilsScript option. - * Default = true - */ - formatOnDisplay?: boolean; + /** + * Format the input value (according to the nationalMode option) during initialisation, and on setNumber. + * Requires the utilsScript option. + * Default = true + */ + formatOnDisplay?: boolean; - /** - * When setting initialCountry to "auto", you must use this option to - * specify a custom function that looks up the user's location, - * and then calls the success callback with the relevant country code. - * Also note that when instantiating the plugin, if the Promise object is defined, - * one of those is returned under the promise instance property, so you can - * do something like iti.promise.then(callback) to know when initialisation requests like this have completed. - * Default = null - */ - geoIpLookup?: (callback: (countryCode: string) => void) => void; + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location, + * and then calls the success callback with the relevant country code. + * Also note that when instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can + * do something like iti.promise.then(callback) to know when initialisation requests like this have completed. + * Default = null + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; - /** - * Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name, - * replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber). - * This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled. - * Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. - * Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation. - * Default = "" - */ - hiddenInput?: string; + /** + * Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name, + * replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber). + * This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled. + * Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. + * Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation. + * Default = "" + */ + hiddenInput?: string; - /** - * Set the initial country selection by specifying it's country code. - * You can also set it to "auto", which will lookup the user's country based - * on their IP address (requires the geoIpLookup option). - * Note that the "auto" option will not update the country selection if the - * input already contains a number. If you leave initialCountry blank, - * it will default to the first country in the list. - */ - initialCountry?: string; + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; - /** - * Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' } - * Default = {} - */ - localizedCountries?: object; + /** + * Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' } + * Default = {} + */ + localizedCountries?: object; - /** - * Allow users to enter national numbers (and not have to think about - * international dial codes). Formatting, validation and placeholders still - * work. Then you can use getNumber to extract a full international number. - * This option now defaults to true, and it is recommended that you leave it - * that way as it provides a better experience for the user. - * Default = true - */ - nationalMode?: boolean; + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + * Default = true + */ + nationalMode?: boolean; - /** - * In the dropdown, display only the countries you specify. - * Default = undefined - */ - onlyCountries?: string[]; + /** + * In the dropdown, display only the countries you specify. + * Default = undefined + */ + onlyCountries?: string[]; - /** - * Specify one of the keys from the global enum intlTelInputUtils.numberType - * e.g. "FIXED_LINE" to set the number type to use for the placeholder. - * Default = MOBILE - */ - placeholderNumberType?: NumberType; + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + * Default = MOBILE + */ + placeholderNumberType?: intlTelInputUtils.numberType; - /** - * Specify the countries to appear at the top of the list. - * Default = ["us", "gb"] - */ - preferredCountries?: string[]; + /** + * Specify the countries to appear at the top of the list. + * Default = ["us", "gb"] + */ + preferredCountries?: string[]; - /** - * Display the country dial code next to the selected flag so it's not part - * of the typed number. Note that this will disable nationalMode because - * technically we are dealing with international numbers, but with the - * dial code separated. - * Default = false - */ - separateDialCode?: boolean; + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + * Default = false + */ + separateDialCode?: boolean; - /** - * Enable formatting/validation etc. by specifying the URL of the included utils.js script - * (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event) - * to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined, - * one of those is returned under the promise instance property, so you can do something like - * iti.promise.then(callback) to know when initialisation requests like this have finished. - * Note that if you're lazy loading the plugin script itself (intlTelInput.js) - * this will not work and you will need to use the loadUtils method instead. - * Example: "build/js/utils.js" - * Default = "" - */ - utilsScript?: string; -} - -export interface CountryData { - name: string; - iso2: string; - dialCode: string; -} - -export enum NumberFormat { - E164 = 0, - INTERNATIONAL = 1, - NATIONAL = 2, - RFC3966 = 3 -} - -export enum NumberType { - FIXED_LINE = 0, - MOBILE = 1, - FIXED_LINE_OR_MOBILE = 2, - TOLL_FREE = 3, - PREMIUM_RATE = 4, - SHARED_COST = 5, - VOIP = 6, - PERSONAL_NUMBER = 7, - PAGER = 8, - UAN = 9, - VOICEMAIL = 10, - UNKNOWN = -1 -} - -export enum ValidationError { - IS_POSSIBLE = 0, - INVALID_COUNTRY_CODE = 1, - TOO_SHORT = 2, - TOO_LONG = 3, - NOT_A_NUMBER = 4 -} - -declare global { - interface Window { - intlTelInput: IntlTelInputStatic; + /** + * Enable formatting/validation etc. by specifying the URL of the included utils.js script + * (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event) + * to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can do something like + * iti.promise.then(callback) to know when initialisation requests like this have finished. + * Note that if you're lazy loading the plugin script itself (intlTelInput.js) + * this will not work and you will need to use the loadUtils method instead. + * Example: "build/js/utils.js" + * Default = "" + */ + utilsScript?: string; } } + +declare namespace intlTelInputUtils { + interface CountryData { + name: string; + iso2: string; + dialCode: string; + } + + enum numberFormat { + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 + } + + enum numberType { + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 + } + + enum validationError { + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 + } +} + +interface Window { + intlTelInput: IntlTelInput.Static; +} diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index 8fcc76840b..58c5790342 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -1,5 +1,3 @@ -import IntlTelInput = require("intl-tel-input"); - const input = document.querySelector("#phone"); window.intlTelInput(input); @@ -10,7 +8,7 @@ window.intlTelInput(input, { }); window.intlTelInput(input, { - placeholderNumberType: IntlTelInput.NumberType.MOBILE, + placeholderNumberType: intlTelInputUtils.numberType.MOBILE, }); window.intlTelInput(input, { @@ -25,15 +23,15 @@ window.intlTelInput(input).destroy(); const extension = window.intlTelInput(input).getExtension(); const intlNumber = window.intlTelInput(input).getNumber(); -const ntlNumber = window.intlTelInput(input).getNumber(IntlTelInput.NumberFormat.NATIONAL); +const ntlNumber = window.intlTelInput(input).getNumber(intlTelInputUtils.numberFormat.NATIONAL); const numberType = window.intlTelInput(input).getNumberType(); -if (numberType === IntlTelInput.NumberType.MOBILE) { } +if (numberType === intlTelInputUtils.numberType.MOBILE) { } const selectedCountryData = window.intlTelInput(input).getSelectedCountryData(); const error = window.intlTelInput(input).getValidationError(); -if (error === IntlTelInput.ValidationError.TOO_SHORT) { } +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } const isValid = window.intlTelInput(input).isValidNumber(); @@ -41,13 +39,13 @@ window.intlTelInput(input).setCountry('gb'); window.intlTelInput(input).setNumber('+447733123456'); -window.intlTelInput(input).setPlaceholderNumberType(IntlTelInput.NumberType.FIXED_LINE); +window.intlTelInput(input).setPlaceholderNumberType(intlTelInputUtils.numberType.FIXED_LINE); const countryData = window.intlTelInput.getCountryData(); const country = countryData[0]; const dialCode = country.dialCode; const iso2 = country.iso2; -const name = country.name; +const countryName = country.name; window.intlTelInput.loadUtils('build/js/utils.js'); diff --git a/types/intl-tel-input/jquery-wrapped-tests.ts b/types/intl-tel-input/jquery-wrapped-tests.ts index 7fe6f0b3b7..ad870e800b 100644 --- a/types/intl-tel-input/jquery-wrapped-tests.ts +++ b/types/intl-tel-input/jquery-wrapped-tests.ts @@ -1,7 +1,5 @@ /// -import * as IntlTelInput from "intl-tel-input"; - $('#phone').intlTelInput(); $('#phone').intlTelInput({ @@ -11,7 +9,7 @@ $('#phone').intlTelInput({ }); $('#phone').intlTelInput({ - placeholderNumberType: IntlTelInput.NumberType.MOBILE, + placeholderNumberType: intlTelInputUtils.numberType.MOBILE, }); $('#phone').intlTelInput({ @@ -23,32 +21,32 @@ $('#phone').intlTelInput({ $('#phone').intlTelInput('destroy'); -const extension = $('#phone').intlTelInput('getExtension'); +const jqueryExtension = $('#phone').intlTelInput('getExtension'); -const intlNumber = $('#phone').intlTelInput('getNumber'); -const ntlNumber = $('#phone').intlTelInput('getNumber', IntlTelInput.NumberFormat.NATIONAL); +const jqueryIntlNumber = $('#phone').intlTelInput('getNumber'); +const jqueryNtlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); -const numberType = $('#phone').intlTelInput('getNumberType'); -if (numberType === IntlTelInput.NumberType.MOBILE) { } +const jqueryNumberType = $('#phone').intlTelInput('getNumberType'); +if (numberType === intlTelInputUtils.numberType.MOBILE) { } -const selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); +const jquerySelectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); -const error = $('#phone').intlTelInput('getValidationError'); -if (error === IntlTelInput.ValidationError.TOO_SHORT) { } +const jqueryError = $('#phone').intlTelInput('getValidationError'); +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } -const isValid = $('#phone').intlTelInput('isValidNumber'); +const jqueryIsValid = $('#phone').intlTelInput('isValidNumber'); $('#phone').intlTelInput('setCountry', 'gb'); $('#phone').intlTelInput('setNumber', '+447733123456'); -$('#phone').intlTelInput('setPlaceholderNumberType', IntlTelInput.NumberType.FIXED_LINE); +$('#phone').intlTelInput('setPlaceholderNumberType', intlTelInputUtils.numberType.FIXED_LINE); -const countryData = $.fn.intlTelInput.getCountryData(); -const country = countryData[0]; -const dialCode = country.dialCode; -const iso2 = country.iso2; -const name = country.name; +const jqueryCountryData = $.fn.intlTelInput.getCountryData(); +const jqueryCountry = countryData[0]; +const jqueryDialCode = country.dialCode; +const jqueryIso2 = country.iso2; +const jqueryName = country.name; $.fn.intlTelInput.loadUtils('build/js/utils.js'); diff --git a/types/intl-tel-input/jquery-wrapped.d.ts b/types/intl-tel-input/jquery-wrapped.d.ts index e83e8285a1..6a69404221 100644 --- a/types/intl-tel-input/jquery-wrapped.d.ts +++ b/types/intl-tel-input/jquery-wrapped.d.ts @@ -1,109 +1,107 @@ /// -import * as IntlTelInput from "./index"; - // Additional definitions for intl-tel-input (jQuery-wrapped) -export interface JQueryPlugin { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): IntlTelInput.CountryData[]; +declare namespace IntlTelInput { + interface JQueryPlugin { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): intlTelInputUtils.CountryData[]; - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (options?: IntlTelInput.Options): JQueryDeferred; + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: Options): JQueryDeferred; - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - (method: 'destroy'): void; + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - (method: 'getExtension'): string; + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - (method: 'getNumber', numberFormat?: IntlTelInput.NumberFormat): string; - (method: string, numberFormat: IntlTelInput.NumberFormat): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat?: intlTelInputUtils.numberFormat): string; + (method: string, numberFormat: intlTelInputUtils.numberFormat): string; - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - (method: 'getNumberType'): IntlTelInput.NumberType; + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): intlTelInputUtils.numberType; - /** - * Get the country data for the currently selected flag. - */ - (method: 'getSelectedCountryData'): IntlTelInput.CountryData; + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): intlTelInputUtils.CountryData; - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum ValidationError - */ - (method: 'getValidationError'): IntlTelInput.ValidationError; + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + (method: 'getValidationError'): intlTelInputUtils.validationError; - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - (method: 'isValidNumber'): boolean; + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - (method: 'setCountry', countryCode: string): void; + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - (method: 'setNumber', aNumber: string): void; + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; - /** - * Set the type of the placeholder number - * @param type Placeholder number type to be set - */ - (method: 'setPlaceholderNumberType', type: IntlTelInput.NumberType): void; -} - -declare global { - interface JQuery { - intlTelInput: JQueryPlugin; + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + (method: 'setPlaceholderNumberType', type: intlTelInputUtils.numberType): void; } } + +interface JQuery { + intlTelInput: IntlTelInput.JQueryPlugin; +} From c4d1c5251066a1fce23ff7e7d2abe4fa056ad5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Mon, 5 Nov 2018 11:56:30 +0100 Subject: [PATCH 11/80] fixed statics --- types/intl-tel-input/index.d.ts | 19 ++++++++++++------- types/intl-tel-input/intl-tel-input-tests.ts | 4 ++-- types/intl-tel-input/jquery-wrapped-tests.ts | 4 ++-- types/intl-tel-input/jquery-wrapped.d.ts | 12 ------------ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 45ffbcfb12..84f7bed50a 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -6,6 +6,11 @@ declare namespace IntlTelInput { interface Static { + /** + * Default options for all instances + */ + defaults: Options; + /** * Get all of the plugin's country data - either to re-use elsewhere * e.g. to populate a country dropdown. @@ -17,12 +22,6 @@ declare namespace IntlTelInput { * formatting/validation etc. */ loadUtils(path: string, utilsScriptDeferred?: boolean): void; - - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (node: Element, options?: Options): Plugin; } interface Plugin { @@ -288,5 +287,11 @@ declare namespace intlTelInputUtils { } interface Window { - intlTelInput: IntlTelInput.Static; + intlTelInputGlobals: IntlTelInput.Static; + + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + intlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin; } diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index 58c5790342..9a8d68ee5d 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -41,13 +41,13 @@ window.intlTelInput(input).setNumber('+447733123456'); window.intlTelInput(input).setPlaceholderNumberType(intlTelInputUtils.numberType.FIXED_LINE); -const countryData = window.intlTelInput.getCountryData(); +const countryData = window.intlTelInputGlobals.getCountryData(); const country = countryData[0]; const dialCode = country.dialCode; const iso2 = country.iso2; const countryName = country.name; -window.intlTelInput.loadUtils('build/js/utils.js'); +window.intlTelInputGlobals.loadUtils('build/js/utils.js'); window.intlTelInput(input, { utilsScript: '../../build/js/utils.js' diff --git a/types/intl-tel-input/jquery-wrapped-tests.ts b/types/intl-tel-input/jquery-wrapped-tests.ts index ad870e800b..cd8eae1704 100644 --- a/types/intl-tel-input/jquery-wrapped-tests.ts +++ b/types/intl-tel-input/jquery-wrapped-tests.ts @@ -42,13 +42,13 @@ $('#phone').intlTelInput('setNumber', '+447733123456'); $('#phone').intlTelInput('setPlaceholderNumberType', intlTelInputUtils.numberType.FIXED_LINE); -const jqueryCountryData = $.fn.intlTelInput.getCountryData(); +const jqueryCountryData = window.intlTelInputGlobals.getCountryData(); const jqueryCountry = countryData[0]; const jqueryDialCode = country.dialCode; const jqueryIso2 = country.iso2; const jqueryName = country.name; -$.fn.intlTelInput.loadUtils('build/js/utils.js'); +window.intlTelInputGlobals.loadUtils('build/js/utils.js'); $('#phone').intlTelInput({ utilsScript: '../../build/js/utils.js' diff --git a/types/intl-tel-input/jquery-wrapped.d.ts b/types/intl-tel-input/jquery-wrapped.d.ts index 6a69404221..a95cbf2ba8 100644 --- a/types/intl-tel-input/jquery-wrapped.d.ts +++ b/types/intl-tel-input/jquery-wrapped.d.ts @@ -4,18 +4,6 @@ declare namespace IntlTelInput { interface JQueryPlugin { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): intlTelInputUtils.CountryData[]; - - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; - /** * initialise the plugin with optional options. * @param options options that can be provided during initialization. From 4fa9fd98dc3fae34b8ffacfa7e7ace571680224c Mon Sep 17 00:00:00 2001 From: Ivan Lyons Date: Tue, 6 Nov 2018 14:49:09 +0800 Subject: [PATCH 12/80] [Koa] custom properties example: ``` const config = require('./config') const app = new Koa(); app.context.config = config; app.use((ctx, next) => { // use `config` object const config = ctx.config }) ``` --- types/koa/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/koa/index.d.ts b/types/koa/index.d.ts index ea6bd60a46..1cd6166f62 100644 --- a/types/koa/index.d.ts +++ b/types/koa/index.d.ts @@ -694,6 +694,7 @@ declare namespace Application { * To bypass Koa's built-in response handling, you may explicitly set `ctx.respond = false;` */ respond?: boolean; + [key: string]: any; } } From 850d8d25ec808d25db5a2e8da9a84d528f1bd9f5 Mon Sep 17 00:00:00 2001 From: Ivan Lyons Date: Tue, 6 Nov 2018 15:10:40 +0800 Subject: [PATCH 13/80] Update index.d.ts --- types/koa/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/koa/index.d.ts b/types/koa/index.d.ts index 1cd6166f62..802d6a242f 100644 --- a/types/koa/index.d.ts +++ b/types/koa/index.d.ts @@ -659,6 +659,10 @@ declare namespace Application { * Default error handling. */ onerror(err: Error): void; + /** + * Custom properties. + */ + [key: string]: any; } interface Request extends BaseRequest { @@ -694,7 +698,6 @@ declare namespace Application { * To bypass Koa's built-in response handling, you may explicitly set `ctx.respond = false;` */ respond?: boolean; - [key: string]: any; } } From c030374c27147fbfb75803a7b3a33dfed7022afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Tue, 6 Nov 2018 13:24:09 +0100 Subject: [PATCH 14/80] moved jQuery definitions into same file --- types/intl-tel-input/index.d.ts | 90 +++++++++++++++++++ types/intl-tel-input/intl-tel-input-tests.ts | 84 +++++++++++++++++ types/intl-tel-input/jquery-wrapped-tests.ts | 87 ------------------ types/intl-tel-input/jquery-wrapped.d.ts | 95 -------------------- types/intl-tel-input/tsconfig.json | 4 +- 5 files changed, 175 insertions(+), 185 deletions(-) delete mode 100644 types/intl-tel-input/jquery-wrapped-tests.ts delete mode 100644 types/intl-tel-input/jquery-wrapped.d.ts diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 84f7bed50a..0d66457479 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -103,6 +103,92 @@ declare namespace IntlTelInput { setPlaceholderNumberType(type: intlTelInputUtils.numberType): void; } + interface JQueryPlugin { + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: Options): JQueryDeferred; + + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; + + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; + + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat?: intlTelInputUtils.numberFormat): string; + (method: string, numberFormat: intlTelInputUtils.numberFormat): string; + + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): intlTelInputUtils.numberType; + + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): intlTelInputUtils.CountryData; + + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + (method: 'getValidationError'): intlTelInputUtils.validationError; + + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; + + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; + + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; + + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + (method: 'setPlaceholderNumberType', type: intlTelInputUtils.numberType): void; + } + interface Options { /** * Whether or not to allow the dropdown. If disabled, there is no dropdown @@ -295,3 +381,7 @@ interface Window { */ intlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin; } + +interface JQuery { + intlTelInput: IntlTelInput.JQueryPlugin; +} diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index 9a8d68ee5d..6dc551c626 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -1,3 +1,7 @@ +/// + +// Normal version + const input = document.querySelector("#phone"); window.intlTelInput(input); @@ -84,3 +88,83 @@ window.intlTelInput(input, { preferredCountries: ["us", "gb"], separateDialCode: false }); + +// jQuery-wrapped version + +$('#phone').intlTelInput(); + +$('#phone').intlTelInput({ + customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => { + return 'e.g. ' + selectedCountryPlaceholder; + } +}); + +$('#phone').intlTelInput({ + placeholderNumberType: intlTelInputUtils.numberType.MOBILE, +}); + +$('#phone').intlTelInput({ + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + } +}); + +$('#phone').intlTelInput('destroy'); + +const jqueryExtension = $('#phone').intlTelInput('getExtension'); + +const jqueryIntlNumber = $('#phone').intlTelInput('getNumber'); +const jqueryNtlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); + +const jqueryNumberType = $('#phone').intlTelInput('getNumberType'); +if (numberType === intlTelInputUtils.numberType.MOBILE) { } + +const jquerySelectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); + +const jqueryError = $('#phone').intlTelInput('getValidationError'); +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } + +const jqueryIsValid = $('#phone').intlTelInput('isValidNumber'); + +$('#phone').intlTelInput('setCountry', 'gb'); + +$('#phone').intlTelInput('setNumber', '+447733123456'); + +$('#phone').intlTelInput('setPlaceholderNumberType', intlTelInputUtils.numberType.FIXED_LINE); + +$('#phone').intlTelInput({ + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + initialCountry: 'auto', + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + }, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + nationalMode: true, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: ["us", "uk"], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland" }, + preferredCountries: ["us", "gb"], + separateDialCode: false +}); diff --git a/types/intl-tel-input/jquery-wrapped-tests.ts b/types/intl-tel-input/jquery-wrapped-tests.ts deleted file mode 100644 index cd8eae1704..0000000000 --- a/types/intl-tel-input/jquery-wrapped-tests.ts +++ /dev/null @@ -1,87 +0,0 @@ -/// - -$('#phone').intlTelInput(); - -$('#phone').intlTelInput({ - customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => { - return 'e.g. ' + selectedCountryPlaceholder; - } -}); - -$('#phone').intlTelInput({ - placeholderNumberType: intlTelInputUtils.numberType.MOBILE, -}); - -$('#phone').intlTelInput({ - geoIpLookup: (callback) => { - const countryCode = 'XY'; - callback(countryCode); - } -}); - -$('#phone').intlTelInput('destroy'); - -const jqueryExtension = $('#phone').intlTelInput('getExtension'); - -const jqueryIntlNumber = $('#phone').intlTelInput('getNumber'); -const jqueryNtlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); - -const jqueryNumberType = $('#phone').intlTelInput('getNumberType'); -if (numberType === intlTelInputUtils.numberType.MOBILE) { } - -const jquerySelectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); - -const jqueryError = $('#phone').intlTelInput('getValidationError'); -if (error === intlTelInputUtils.validationError.TOO_SHORT) { } - -const jqueryIsValid = $('#phone').intlTelInput('isValidNumber'); - -$('#phone').intlTelInput('setCountry', 'gb'); - -$('#phone').intlTelInput('setNumber', '+447733123456'); - -$('#phone').intlTelInput('setPlaceholderNumberType', intlTelInputUtils.numberType.FIXED_LINE); - -const jqueryCountryData = window.intlTelInputGlobals.getCountryData(); -const jqueryCountry = countryData[0]; -const jqueryDialCode = country.dialCode; -const jqueryIso2 = country.iso2; -const jqueryName = country.name; - -window.intlTelInputGlobals.loadUtils('build/js/utils.js'); - -$('#phone').intlTelInput({ - utilsScript: '../../build/js/utils.js' -}); - -$('#phone').intlTelInput({ - initialCountry: 'auto', - geoIpLookup: (callback) => { - const countryCode = 'XY'; - callback(countryCode); - }, - utilsScript: '../../build/js/utils.js' -}); - -$('#phone').intlTelInput({ - nationalMode: true, - utilsScript: '../../build/js/utils.js' -}); - -$('#phone').intlTelInput({ - onlyCountries: ['al'], - utilsScript: '../../build/js/utils.js' -}); - -$('#phone').intlTelInput({ - allowDropdown: false, - autoHideDialCode: false, - autoPlaceholder: "aggressive", - dropdownContainer: document.body, - excludeCountries: ["us", "uk"], - formatOnDisplay: false, - hiddenInput: "hidden-input", - localizedCountries: { de: "Deutschland" }, - preferredCountries: ["us", "gb"], - separateDialCode: false -}); diff --git a/types/intl-tel-input/jquery-wrapped.d.ts b/types/intl-tel-input/jquery-wrapped.d.ts deleted file mode 100644 index a95cbf2ba8..0000000000 --- a/types/intl-tel-input/jquery-wrapped.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -/// - -// Additional definitions for intl-tel-input (jQuery-wrapped) - -declare namespace IntlTelInput { - interface JQueryPlugin { - /** - * initialise the plugin with optional options. - * @param options options that can be provided during initialization. - */ - (options?: Options): JQueryDeferred; - - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - (method: 'destroy'): void; - - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - (method: 'getExtension'): string; - - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - (method: 'getNumber', numberFormat?: intlTelInputUtils.numberFormat): string; - (method: string, numberFormat: intlTelInputUtils.numberFormat): string; - - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - (method: 'getNumberType'): intlTelInputUtils.numberType; - - /** - * Get the country data for the currently selected flag. - */ - (method: 'getSelectedCountryData'): intlTelInputUtils.CountryData; - - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum ValidationError - */ - (method: 'getValidationError'): intlTelInputUtils.validationError; - - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - (method: 'isValidNumber'): boolean; - - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - (method: 'setCountry', countryCode: string): void; - - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - (method: 'setNumber', aNumber: string): void; - - /** - * Set the type of the placeholder number - * @param type Placeholder number type to be set - */ - (method: 'setPlaceholderNumberType', type: intlTelInputUtils.numberType): void; - } -} - -interface JQuery { - intlTelInput: IntlTelInput.JQueryPlugin; -} diff --git a/types/intl-tel-input/tsconfig.json b/types/intl-tel-input/tsconfig.json index 5409f40b10..e067880440 100644 --- a/types/intl-tel-input/tsconfig.json +++ b/types/intl-tel-input/tsconfig.json @@ -19,8 +19,6 @@ }, "files": [ "index.d.ts", - "jquery-wrapped.d.ts", - "intl-tel-input-tests.ts", - "jquery-wrapped-tests.ts" + "intl-tel-input-tests.ts" ] } From 749614f8af4f8911007a13f78d694c7cebed7b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Tue, 6 Nov 2018 13:28:53 +0100 Subject: [PATCH 15/80] added version header to v13 --- types/intl-tel-input/v13/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/intl-tel-input/v13/index.d.ts b/types/intl-tel-input/v13/index.d.ts index 8221c73c62..a28032e026 100644 --- a/types/intl-tel-input/v13/index.d.ts +++ b/types/intl-tel-input/v13/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for intl-tel-input +// Type definitions for intl-tel-input 13.0 // Project: https://github.com/jackocnr/intl-tel-input // Definitions by: Fidan Hakaj , Leonard Thieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 96f1baab5b469140a7be16dd94c7e8765e058dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Moln=C3=A1r?= Date: Tue, 6 Nov 2018 14:34:55 +0100 Subject: [PATCH 16/80] fixed type of placeholders: should be the keys of numberType --- types/intl-tel-input/index.d.ts | 20 +++++++++++++++++--- types/intl-tel-input/intl-tel-input-tests.ts | 8 ++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 0d66457479..667a210087 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -100,7 +100,7 @@ declare namespace IntlTelInput { * Set the type of the placeholder number * @param type Placeholder number type to be set */ - setPlaceholderNumberType(type: intlTelInputUtils.numberType): void; + setPlaceholderNumberType(type: intlTelInputUtils.placeholderNumberType): void; } interface JQueryPlugin { @@ -186,7 +186,7 @@ declare namespace IntlTelInput { * Set the type of the placeholder number * @param type Placeholder number type to be set */ - (method: 'setPlaceholderNumberType', type: intlTelInputUtils.numberType): void; + (method: 'setPlaceholderNumberType', type: intlTelInputUtils.placeholderNumberType): void; } interface Options { @@ -302,7 +302,7 @@ declare namespace IntlTelInput { * e.g. "FIXED_LINE" to set the number type to use for the placeholder. * Default = MOBILE */ - placeholderNumberType?: intlTelInputUtils.numberType; + placeholderNumberType?: intlTelInputUtils.placeholderNumberType; /** * Specify the countries to appear at the top of the list. @@ -370,6 +370,20 @@ declare namespace intlTelInputUtils { TOO_LONG = 3, NOT_A_NUMBER = 4 } + + type placeholderNumberType = + | "FIXED_LINE_OR_MOBILE" + | "FIXED_LINE" + | "MOBILE" + | "PAGER" + | "PERSONAL_NUMBER" + | "PREMIUM_RATE" + | "SHARED_COST" + | "TOLL_FREE" + | "UAN" + | "UNKNOWN" + | "VOICEMAIL" + | "VOIP"; } interface Window { diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index 6dc551c626..ab6808bbed 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -12,7 +12,7 @@ window.intlTelInput(input, { }); window.intlTelInput(input, { - placeholderNumberType: intlTelInputUtils.numberType.MOBILE, + placeholderNumberType: "MOBILE", }); window.intlTelInput(input, { @@ -43,7 +43,7 @@ window.intlTelInput(input).setCountry('gb'); window.intlTelInput(input).setNumber('+447733123456'); -window.intlTelInput(input).setPlaceholderNumberType(intlTelInputUtils.numberType.FIXED_LINE); +window.intlTelInput(input).setPlaceholderNumberType("FIXED_LINE"); const countryData = window.intlTelInputGlobals.getCountryData(); const country = countryData[0]; @@ -100,7 +100,7 @@ $('#phone').intlTelInput({ }); $('#phone').intlTelInput({ - placeholderNumberType: intlTelInputUtils.numberType.MOBILE, + placeholderNumberType: "MOBILE", }); $('#phone').intlTelInput({ @@ -131,7 +131,7 @@ $('#phone').intlTelInput('setCountry', 'gb'); $('#phone').intlTelInput('setNumber', '+447733123456'); -$('#phone').intlTelInput('setPlaceholderNumberType', intlTelInputUtils.numberType.FIXED_LINE); +$('#phone').intlTelInput('setPlaceholderNumberType', "FIXED_LINE"); $('#phone').intlTelInput({ utilsScript: '../../build/js/utils.js' From 310333cc554b11c555762e72a6cefd8e412b1261 Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Wed, 7 Nov 2018 13:24:35 +0000 Subject: [PATCH 17/80] Apply as many standard lint rules as possible. --- types/promise-polyfill/tslint.json | 74 +----------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/types/promise-polyfill/tslint.json b/types/promise-polyfill/tslint.json index a41bf5d19a..6d3cdf694a 100644 --- a/types/promise-polyfill/tslint.json +++ b/types/promise-polyfill/tslint.json @@ -1,79 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "eofline": false } } From c1517257862eb3050a06f6a18ad1e9762e4f3ddf Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Wed, 7 Nov 2018 13:29:27 +0000 Subject: [PATCH 18/80] Fix violations of 'dt-header' lint rule. --- types/promise-polyfill/index.d.ts | 2 +- types/promise-polyfill/tslint.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/promise-polyfill/index.d.ts b/types/promise-polyfill/index.d.ts index 703f7a6a8c..6d39160e4a 100644 --- a/types/promise-polyfill/index.d.ts +++ b/types/promise-polyfill/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for promise v6.0.2 +// Type definitions for promise-polyfill 6.0 // Project: https://www.npmjs.com/package/promise-polyfill // Definitions by: Steve Jenkins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/promise-polyfill/tslint.json b/types/promise-polyfill/tslint.json index 6d3cdf694a..4af897733b 100644 --- a/types/promise-polyfill/tslint.json +++ b/types/promise-polyfill/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false, "eofline": false } } From be09dd8db939cb1f71d6d6174182a53b6cc4535d Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Wed, 7 Nov 2018 13:31:07 +0000 Subject: [PATCH 19/80] Fix violations of 'eofline' lint rule. --- types/promise-polyfill/index.d.ts | 2 +- types/promise-polyfill/promise-polyfill-tests.ts | 2 +- types/promise-polyfill/tslint.json | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/types/promise-polyfill/index.d.ts b/types/promise-polyfill/index.d.ts index 6d39160e4a..930122d0fc 100644 --- a/types/promise-polyfill/index.d.ts +++ b/types/promise-polyfill/index.d.ts @@ -3,4 +3,4 @@ // Definitions by: Steve Jenkins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default Promise; \ No newline at end of file +export default Promise; diff --git a/types/promise-polyfill/promise-polyfill-tests.ts b/types/promise-polyfill/promise-polyfill-tests.ts index 280a2bebdf..1ffe55a82f 100644 --- a/types/promise-polyfill/promise-polyfill-tests.ts +++ b/types/promise-polyfill/promise-polyfill-tests.ts @@ -15,4 +15,4 @@ Promise.all([prom1, prom2]) .then(result => { console.log(result); }, (exception) => console.error(exception)) -.catch((ex) => console.error(ex)); \ No newline at end of file +.catch((ex) => console.error(ex)); diff --git a/types/promise-polyfill/tslint.json b/types/promise-polyfill/tslint.json index 4af897733b..f93cf8562a 100644 --- a/types/promise-polyfill/tslint.json +++ b/types/promise-polyfill/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "eofline": false - } + "extends": "dtslint/dt.json" } From ad6df613ec4de34581f875808842927f65d7f0b4 Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Wed, 7 Nov 2018 13:32:35 +0000 Subject: [PATCH 20/80] Add missing import to test file. The tests weren't really testing promise-polyfill at all, they were testing TypeScript's built-in Promise type. --- types/promise-polyfill/promise-polyfill-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/promise-polyfill/promise-polyfill-tests.ts b/types/promise-polyfill/promise-polyfill-tests.ts index 1ffe55a82f..3cd3dbfa3c 100644 --- a/types/promise-polyfill/promise-polyfill-tests.ts +++ b/types/promise-polyfill/promise-polyfill-tests.ts @@ -1,3 +1,5 @@ +import Promise from "promise-polyfill"; + const prom1 = new Promise((resolve, reject) => { resolve(12); }); From fd0062159977b64c63c5a74fedf8fe6dc9970564 Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Wed, 7 Nov 2018 13:35:53 +0000 Subject: [PATCH 21/80] Add definition for _immediateFn, add self to authors. --- types/promise-polyfill/index.d.ts | 7 +++++++ types/promise-polyfill/promise-polyfill-tests.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/types/promise-polyfill/index.d.ts b/types/promise-polyfill/index.d.ts index 930122d0fc..83036cf4ff 100644 --- a/types/promise-polyfill/index.d.ts +++ b/types/promise-polyfill/index.d.ts @@ -1,6 +1,13 @@ // Type definitions for promise-polyfill 6.0 // Project: https://www.npmjs.com/package/promise-polyfill // Definitions by: Steve Jenkins +// Daniel Cassidy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export interface PromisePolyfillConstructor extends PromiseConstructor { + _immediateFn?: (handler: (() => void) | string) => void; +} + +declare const Promise: PromisePolyfillConstructor; + export default Promise; diff --git a/types/promise-polyfill/promise-polyfill-tests.ts b/types/promise-polyfill/promise-polyfill-tests.ts index 3cd3dbfa3c..cfdd803126 100644 --- a/types/promise-polyfill/promise-polyfill-tests.ts +++ b/types/promise-polyfill/promise-polyfill-tests.ts @@ -18,3 +18,5 @@ Promise.all([prom1, prom2]) console.log(result); }, (exception) => console.error(exception)) .catch((ex) => console.error(ex)); + +Promise._immediateFn = setTimeout; From 95631570de6751dc7f0f8f1a0190cc0a9a62053f Mon Sep 17 00:00:00 2001 From: MaxKornilov <44263165+MaxKornilov@users.noreply.github.com> Date: Thu, 8 Nov 2018 11:23:13 +0200 Subject: [PATCH 22/80] name property added to ProcessesProcessData name property added to ProcessesProcessData interface. This allows reading the name of process. --- types/systeminformation/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/systeminformation/index.d.ts b/types/systeminformation/index.d.ts index b8ec674839..ad0100f093 100644 --- a/types/systeminformation/index.d.ts +++ b/types/systeminformation/index.d.ts @@ -367,6 +367,7 @@ export namespace Systeminformation { tty: string; user: string; command: string; + name:string; } interface ProcessesProcessLoadData { From 420e6121f3e74b93ee5e12191753650ae891e930 Mon Sep 17 00:00:00 2001 From: MaxKornilov <44263165+MaxKornilov@users.noreply.github.com> Date: Thu, 8 Nov 2018 12:06:18 +0200 Subject: [PATCH 23/80] =?UTF-8?q?=D0=90=D1=88=D1=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/systeminformation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/systeminformation/index.d.ts b/types/systeminformation/index.d.ts index ad0100f093..0ebeb16f96 100644 --- a/types/systeminformation/index.d.ts +++ b/types/systeminformation/index.d.ts @@ -367,7 +367,7 @@ export namespace Systeminformation { tty: string; user: string; command: string; - name:string; + name: string; } interface ProcessesProcessLoadData { From 41c1ba2436b475b70f6db7964be45cfd29ade9cd Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 8 Nov 2018 09:24:35 -0600 Subject: [PATCH 24/80] added findByPk function to Model def added findByPk function to Model definition --- types/sequelize/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index f80d5acc40..88ed87efae 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3908,6 +3908,7 @@ declare namespace sequelize { */ findById(identifier?: number | string | Buffer, options?: FindOptions): Promise; findByPrimary(identifier?: number | string | Buffer, options?: FindOptions): Promise; + findByPk(identifier?: number | string | Buffer, options?: FindOptions): Promise; /** * Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single From 09fe13180eebd08684018bd2090a935a2eb7bc5b Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 8 Nov 2018 09:29:42 -0600 Subject: [PATCH 25/80] added tests for Model.findByPk added tests for Model.findByPk --- types/sequelize/sequelize-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 4e0aa9a73d..6b7ea6ea0a 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -981,6 +981,10 @@ User.findByPrimary( 'a string' ); User.findByPrimary( 42 ); User.findByPrimary( Buffer.from('a buffer') ); +User.findByPk( 'a string' ); +User.findByPk( 42 ); +User.findByPk( Buffer.from('a buffer') ); + User.findOne( { where : { username : 'foo' } } ); User.findOne( { where : { id : 1 }, attributes : ['id', ['username', 'name']] } ); User.findOne( { where : { id : 1 }, attributes : ['id'] } ); From c4df5ab14f8f82fe2edee5d266d210336dfd5603 Mon Sep 17 00:00:00 2001 From: Dan Rumney Date: Thu, 8 Nov 2018 15:39:55 -0600 Subject: [PATCH 26/80] Remove dependency on Bluebird Not everybody uses Bluebird for their Promises and coupling this so tightly to Bluebird causes us problems --- types/auth0/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index ed0e9d1f3f..39d9d36fd7 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -4,8 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as Promise from 'bluebird'; - export interface ManagementClientOptions { token?: string; domain: string; From af6c0072b4bbd715bda517c99ba88a6da7ae7d86 Mon Sep 17 00:00:00 2001 From: TeamworkGuy2 Date: Fri, 9 Nov 2018 00:54:11 +0000 Subject: [PATCH 27/80] [deps-sort] Add deps-sort@2.0.0 definition --- types/deps-sort/deps-sort-tests.ts | 31 +++++++++++ types/deps-sort/index.d.ts | 85 ++++++++++++++++++++++++++++++ types/deps-sort/tsconfig.json | 23 ++++++++ types/deps-sort/tslint.json | 1 + 4 files changed, 140 insertions(+) create mode 100644 types/deps-sort/deps-sort-tests.ts create mode 100644 types/deps-sort/index.d.ts create mode 100644 types/deps-sort/tsconfig.json create mode 100644 types/deps-sort/tslint.json diff --git a/types/deps-sort/deps-sort-tests.ts b/types/deps-sort/deps-sort-tests.ts new file mode 100644 index 0000000000..e706edaefb --- /dev/null +++ b/types/deps-sort/deps-sort-tests.ts @@ -0,0 +1,31 @@ +import depsSort = require("deps-sort"); + +function browserifyTest(opts: depsSort.Options) { + const depsOpts: depsSort.Options = { + index: opts != null && opts.index, + dedupe: opts != null && opts.dedupe, + expose: opts.expose || { id: "file.txt" } + }; + + const res = depsSort(); // 'opts' are optional + res.pipe(depsSort(depsOpts)); + + res.once("error", (err: any) => { + console.error("module-deps error: ", err); + }); + + const inst: NodeJS.ReadWriteStream = depsSort({ + index: true, + expose: { id: "file.txt" } + }); + + inst.on("file", (file, id) => { + console.log("file", file, id); + }); + inst.on("package", (pkg) => { + console.log("package", pkg); + }); + inst.on("transform", (tr, file) => { + console.log("transform", tr, file); + }); +} diff --git a/types/deps-sort/index.d.ts b/types/deps-sort/index.d.ts new file mode 100644 index 0000000000..e32c826771 --- /dev/null +++ b/types/deps-sort/index.d.ts @@ -0,0 +1,85 @@ +// Type definitions for deps-sort 2.0 +// Project: https://github.com/browserify/deps-sort +// Definitions by: TeamworkGuy2 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as stream from "stream"; + +/** + * Return a new through stream that should get written module-deps objects and will output sorted objects. + */ +declare function depsSort(opts?: depsSort.Options): stream.Transform; + +/** + * Sort module-deps output for deterministic browserify bundles. + */ +declare namespace depsSort { + /** + * module-deps constructor options + */ + interface Options { + /** + * When true, for each module-deps row, insert 'row.index' with the numeric index and + * 'row.indexDeps' like 'row.deps' but mapping require strings to row indices + */ + index?: boolean; + + /** + * array of names or object mapping names to true not to mangle with integer indexes when 'index' is turned on. + * If 'expose' maps names to strings, those strings will be used to resolve the indexed references. + */ + expose?: string[] | { [name: string]: boolean | string }; + + /** + * Set 'row.dedupe' for files that match existing contents. Sets 'row.dedupeIndex' when 'index' is enabled. + * When 'row.dedupe' is set, 'row.sameDeps' will be set to a boolean of whether the dependencies at the dedupe target match (true) or just the source content (false). + */ + dedupe?: boolean; + + [prop: string]: any; + } + + /** + * Input objects are file objects in the module-deps shape. They must at least have these properties: + */ + interface InputRow { + /** + * a unique identifier for the file + */ + id: string; + /** + * the file contents + */ + source: string; + /** + * dependencies for this file, mapping strings as used in require() to row IDs + */ + deps: string[]; + } + + /** + * All the input properties, and: + */ + interface OutputRow { + /** + * when 'opts.index' is true, the sorted numeric index of the row + */ + index: number; + /** + * like 'row.deps', but mapping to 'row.index' instead of 'row.id' + */ + indexDeps: { [id: string]: number }; + /** + * when 'opts.dedupe' is true, contains the row ID of a file with identical contents + */ + dedupe: string; + /** + * like 'row.dedupe', but contains the 'row.index' instead of 'row.id' + */ + dedupeIndex: number; + } +} + +export = depsSort; diff --git a/types/deps-sort/tsconfig.json b/types/deps-sort/tsconfig.json new file mode 100644 index 0000000000..15871fb95e --- /dev/null +++ b/types/deps-sort/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "deps-sort-tests.ts" + ] +} \ No newline at end of file diff --git a/types/deps-sort/tslint.json b/types/deps-sort/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/deps-sort/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 467c41a78ce317197830e5e07cfab1b525391236 Mon Sep 17 00:00:00 2001 From: Stefan Mansson Date: Fri, 9 Nov 2018 11:05:26 +0200 Subject: [PATCH 28/80] Update flowdoc type definition --- types/flowdoc/flowdoc-tests.ts | 30 ++++++++++++++++-------- types/flowdoc/index.d.ts | 42 ++++++++++++++++++---------------- types/flowdoc/tslint.json | 2 +- 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/types/flowdoc/flowdoc-tests.ts b/types/flowdoc/flowdoc-tests.ts index 04b765f65c..0ebdb530da 100644 --- a/types/flowdoc/flowdoc-tests.ts +++ b/types/flowdoc/flowdoc-tests.ts @@ -1,13 +1,25 @@ +const TYPES = { + DOCUMENT: 'DOCUMENT', + PAGE: 'PAGE', + SCREEN: 'SCREEN', + IMAGE: 'IMAGE', + RECTANGLE: 'RECT', + ELLIPSE: 'ELLIPSE', + DIAMOND: 'DIAMOND', + HOTSPOT: 'HOTSPOT', + LAYER: 'LAYER', +} as Flow.Types; + const flowFile: Flow.File = { document: { id: 'cjo45613k00002a5p9gj6nr3b', name: 'Basic Document', - type: Flow.Type.Document, + type: TYPES.DOCUMENT, children: [ { id: 'cjo456d2700002a5p80zudiut', name: 'Page 1', - type: Flow.Type.Page, + type: TYPES.PAGE, backgroundColor: { r: 0, g: 0, @@ -18,7 +30,7 @@ const flowFile: Flow.File = { { id: 'cjo45mq7500002a5p8n8u1bfz', name: 'Sign in', - type: Flow.Type.Screen, + type: TYPES.SCREEN, source: { fileName: 'sign-in.png', dirPath: './assets', @@ -36,7 +48,7 @@ const flowFile: Flow.File = { { id: 'cjo45oi8700002a5pmpnxhfny', name: 'Sign up', - type: Flow.Type.Screen, + type: TYPES.SCREEN, source: { fileName: 'sign-up.png', dirPath: './assets', @@ -65,10 +77,10 @@ flowFile.settings = {}; flowFile.schemaVersion = 1; const document: Flow.Document = flowFile.document; -document.type = Flow.Type.Document; +document.type = TYPES.DOCUMENT; const page: Flow.Page = document.children[0]; -page.type = Flow.Type.Page; +page.type = TYPES.PAGE; page.backgroundColor = { r: 255, g: 255, @@ -79,7 +91,7 @@ page.backgroundColor = { const hotspot: Flow.Layer = { id: 'cjo5mezgg00003g5winhxc8o0', name: 'Layer', - type: Flow.Type.Hotspot, + type: TYPES.HOTSPOT, position: { x: 390, y: 390, @@ -92,10 +104,10 @@ const hotspot: Flow.Layer = { nodeID: 'cjo45mq7500002a5p8n8u1bfz', }], }; -hotspot.type = Flow.Type.Hotspot; +hotspot.type = TYPES.HOTSPOT; const screen = page.children[0] as Flow.Screen; -screen.type = Flow.Type.Screen; +screen.type = TYPES.SCREEN; screen.children.push(hotspot); screen.position = { x: 0, diff --git a/types/flowdoc/index.d.ts b/types/flowdoc/index.d.ts index 9e39a24384..23f9a93122 100644 --- a/types/flowdoc/index.d.ts +++ b/types/flowdoc/index.d.ts @@ -14,42 +14,42 @@ declare namespace Flow { interface Document { id: string; name: string; - type: Type.Document; + type: Types['DOCUMENT']; children: Page[]; } interface Page extends Node { - type: Type.Page; - children: Array<(Screen | Image | Rectangle | Ellipse | Diamond)>; + type: Types['PAGE']; + children: Array; backgroundColor: Color; startNodeID?: string; } interface Screen extends Graphic { - type: Type.Screen; + type: Types['SCREEN']; children: Layer[]; connections?: Connection[]; } interface Image extends Graphic { - type: Type.Image; + type: Types['IMAGE']; connections?: Connection[]; } interface Rectangle extends Shape { - type: Type.Rectangle; + type: Types['RECTANGLE']; } interface Ellipse extends Shape { - type: Type.Ellipse; + type: Types['ELLIPSE']; } interface Diamond extends Shape { - type: Type.Diamond; + type: Types['DIAMOND']; } interface Layer extends Node { - type: Type.Layer | Type.Hotspot; + type: Types['LAYER'] | Types['HOTSPOT']; position: Point; size: Size; connections?: Connection[]; @@ -87,25 +87,27 @@ declare namespace Flow { w: number; } - const enum Type { - Document = 'DOCUMENT', - Page = 'PAGE', - Screen = 'SCREEN', - Image = 'IMAGE', - Rectangle = 'RECT', - Ellipse = 'ELLIPSE', - Diamond = 'DIAMOND', - Hotspot = 'HOTSPOT', - Layer = 'LAYER', + interface Types { + DOCUMENT: 'DOCUMENT'; + PAGE: 'PAGE'; + SCREEN: 'SCREEN'; + IMAGE: 'IMAGE'; + RECTANGLE: 'RECT'; + ELLIPSE: 'ELLIPSE'; + DIAMOND: 'DIAMOND'; + HOTSPOT: 'HOTSPOT'; + LAYER: 'LAYER'; } type SchemaVersion = 1; } +type NodeType = 'DOCUMENT' | 'PAGE' | 'SCREEN' | 'IMAGE' | 'RECT' | 'ELLIPSE' | 'DIAMOND' | 'HOTSPOT' | 'LAYER'; + interface Node { id: string; name: string; - type: Flow.Type; + type: NodeType; } interface Shape extends Node { diff --git a/types/flowdoc/tslint.json b/types/flowdoc/tslint.json index 3224b40b8b..1061428d6e 100644 --- a/types/flowdoc/tslint.json +++ b/types/flowdoc/tslint.json @@ -1,6 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "no-const-enum": false + "no-object-literal-type-assertion": false } } From 674faabadfe0c0378181b51033ba278a17566a3d Mon Sep 17 00:00:00 2001 From: Stefan Mansson Date: Fri, 9 Nov 2018 11:23:18 +0200 Subject: [PATCH 29/80] Increment flowdoc version --- types/flowdoc/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/flowdoc/index.d.ts b/types/flowdoc/index.d.ts index 23f9a93122..8c32c6794c 100644 --- a/types/flowdoc/index.d.ts +++ b/types/flowdoc/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for flowdoc 1.0 +// Type definitions for flowdoc 1.1 // Project: https://github.com/overflowapp/Flow // Definitions by: Stefan Mansson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From ddbcb5f6a0172bd92f4b79391b81260a3a613c50 Mon Sep 17 00:00:00 2001 From: Sean Zhu Date: Fri, 9 Nov 2018 17:40:17 -0800 Subject: [PATCH 30/80] [await-timeout] Add types for await-timeout 0.3 --- types/await-timeout/await-timeout-tests.ts | 131 +++++++++++++++++++++ types/await-timeout/index.d.ts | 17 +++ types/await-timeout/tsconfig.json | 22 ++++ types/await-timeout/tslint.json | 1 + 4 files changed, 171 insertions(+) create mode 100644 types/await-timeout/await-timeout-tests.ts create mode 100644 types/await-timeout/index.d.ts create mode 100644 types/await-timeout/tsconfig.json create mode 100644 types/await-timeout/tslint.json diff --git a/types/await-timeout/await-timeout-tests.ts b/types/await-timeout/await-timeout-tests.ts new file mode 100644 index 0000000000..96dcdefdee --- /dev/null +++ b/types/await-timeout/await-timeout-tests.ts @@ -0,0 +1,131 @@ +import Timeout from "await-timeout"; + +/** + * This test is just a TS-friendly version of the await-timeout README: + * https://github.com/vitalets/await-timeout/blob/v0.3.0/README.md + * + * How to generate this file: + * 1. Paste the source code of README.md + * 2. Replace every code fence with async () => {} + * 3. Comment out all other lines + * 4. Add and remove import statements and repeated statements + * 5. Declare required globals + */ + +// -- Globals -- +declare const fetch: (url: string) => Promise; +declare const console: any; +declare const MyTimeoutError: any; + +// --- README --- + +// ## Usage +// 1. Just wait some time: +async () => { + // wait 1000 ms and resolve + await Timeout.set(1000); + + // wait 1000 ms and reject with 'Error' + await Timeout.set(1000, 'Error'); +}; + +// 2. Use `Timeout` instance inside `try...finally` block to make proper cleanup: +async () => { + const timer = new Timeout(); + try { + await Promise.race([ + fetch('https://example.com'), + timer.set(1000) + .then(() => Promise.reject('Timeout')) + ]); + } finally { + timer.clear(); + } +}; + +// ## API +// ### new Timeout() +// Constructs new timeout instance. It does not start timer but creates variable for timer manipulation. +async () => { + const timer = new Timeout(); +}; +// > Note : having separate variable is useful for clearing timeout in `finally` block + +// ### .set(ms, [message]) ⇒ `Promise` +// Starts new timer like `setTimeout()` and returns promise. The promise will be resolved after `ms` milliseconds: +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => console.log('1000 ms passed.')); +}; + +// If you need to reject after timeout: +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => {throw new Error('Timeout'); }); +}; + +// Or reject with custom error: +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => {throw new MyTimeoutError(); }); +}; +// The second parameter `message` is just convenient way to reject with `new Error(message)`: +async () => { + const timer = new Timeout(); + timer.set(1000, 'Timeout'); + // is equivalent to + timer.set(1000).then(() => {throw new Error('Timeout'); }); +}; + +// If you need to just wait some time - use static version of `.set()` : +async () => { + Timeout.set(1000).then(/*...*/); +}; + +// ### .wrap(promise, ms, [message]) ⇒ `Promise` +// Wraps existing promise with timeout: +// * promise automatically rejected after timeout +// * timeout automatically cleared if promise fulfills first +async () => { + const promise = fetch('https://example.com'); + + const timeoutedPromise = Timeout.wrap(promise, 1000, 'Timeout'); +}; +// Actually it is a shortcut for : +async () => { + const promise = fetch('https://example.com'); + + const timer = new Timeout(); + try { + const timeoutedPromise = await Promise.race([ + promise, + timer.set(1000, 'Timeout') + ]); + } finally { + timer.clear(); + } +}; + +// ### .clear() +// Clears existing timeout like `clearTimeout()`. +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => console.log('This will never be called, because timeout is cleared on the next line')); + timer.clear(); +}; + +// With [ES7 async / await ] `.clear()` can be used in `finally` block: +async () => { + async function foo() { + const timer = new Timeout(); + try { + // some async stuff + } finally { + timer.clear(); + } + } +}; diff --git a/types/await-timeout/index.d.ts b/types/await-timeout/index.d.ts new file mode 100644 index 0000000000..de6aa1a82b --- /dev/null +++ b/types/await-timeout/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for await-timeout 0.3 +// Project: https://github.com/vitalets/await-timeout +// Definitions by: Sean Zhu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default Timeout; + +declare class Timeout { + static set(delay: number): Promise; + static set(delay: number, message: string): Promise; + + static wrap(promise: Promise, delay: number, error?: string): Promise; + + set(delay: number): Promise; + set(delay: number, message: string): Promise; + clear(): void; +} diff --git a/types/await-timeout/tsconfig.json b/types/await-timeout/tsconfig.json new file mode 100644 index 0000000000..9692443f7f --- /dev/null +++ b/types/await-timeout/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "await-timeout-tests.ts" + ] +} diff --git a/types/await-timeout/tslint.json b/types/await-timeout/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/await-timeout/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 01afd7a88e431607c710f95e9f621c84cca096fb Mon Sep 17 00:00:00 2001 From: Sean Zhu Date: Fri, 9 Nov 2018 18:08:52 -0800 Subject: [PATCH 31/80] [await-timeout] "strictFunctionTypes": true --- types/await-timeout/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/await-timeout/tsconfig.json b/types/await-timeout/tsconfig.json index 9692443f7f..2ecb27e688 100644 --- a/types/await-timeout/tsconfig.json +++ b/types/await-timeout/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From fc82df4868b78ce0656ed7423f77e5312cf4a6fa Mon Sep 17 00:00:00 2001 From: Sean Zhu Date: Fri, 9 Nov 2018 18:38:23 -0800 Subject: [PATCH 32/80] [await-timeout] // TypeScript Version: 2.1 --- types/await-timeout/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/await-timeout/index.d.ts b/types/await-timeout/index.d.ts index de6aa1a82b..ce202c6024 100644 --- a/types/await-timeout/index.d.ts +++ b/types/await-timeout/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/vitalets/await-timeout // Definitions by: Sean Zhu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export default Timeout; From 6b3e525152850c94514f461fd0c8e2d673e56b6d Mon Sep 17 00:00:00 2001 From: Shrujal Shah Date: Mon, 12 Nov 2018 11:38:57 +0530 Subject: [PATCH 33/80] Add missing ignoreBounds for tooltip --- types/google.visualization/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/google.visualization/index.d.ts b/types/google.visualization/index.d.ts index 2d679583d7..2912507e08 100644 --- a/types/google.visualization/index.d.ts +++ b/types/google.visualization/index.d.ts @@ -478,6 +478,7 @@ declare namespace google { showColorCode?: boolean; textStyle?: ChartTextStyle; trigger?: string; + ignoreBounds?: boolean } export interface ChartBoundingBox { From 3c547b3a2a064cf9991d28b8511df9e5a51dff85 Mon Sep 17 00:00:00 2001 From: Javier Aviles Date: Mon, 12 Nov 2018 14:26:43 +0100 Subject: [PATCH 34/80] textLimit property missing in types The property 'textLimit' similar to jsonLimit is missing in the types :) --- types/koa-bodyparser/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/koa-bodyparser/index.d.ts b/types/koa-bodyparser/index.d.ts index deb1eb04e9..425d0883f8 100644 --- a/types/koa-bodyparser/index.d.ts +++ b/types/koa-bodyparser/index.d.ts @@ -46,6 +46,11 @@ declare namespace bodyParser { * limit of the json body. Default is 1mb */ jsonLimit?: string; + + /** + * limit of the text body. Default is 1mb. + */ + textLimit?: string; /** * when set to true, JSON parser will only accept arrays and objects. Default is true From 79d88da172903cf73338204760cc470d8d422666 Mon Sep 17 00:00:00 2001 From: "Aviles, Javier" Date: Mon, 12 Nov 2018 14:55:08 +0100 Subject: [PATCH 35/80] Forgot trailing whitespaces --- types/koa-bodyparser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/koa-bodyparser/index.d.ts b/types/koa-bodyparser/index.d.ts index 425d0883f8..3cf420ca12 100644 --- a/types/koa-bodyparser/index.d.ts +++ b/types/koa-bodyparser/index.d.ts @@ -46,7 +46,7 @@ declare namespace bodyParser { * limit of the json body. Default is 1mb */ jsonLimit?: string; - + /** * limit of the text body. Default is 1mb. */ From b2e5f8f7cf360f70d56f166692186c622ccce522 Mon Sep 17 00:00:00 2001 From: TalkTakesTime Date: Tue, 13 Nov 2018 10:39:02 +1300 Subject: [PATCH 36/80] [@types/mapbox-gl] Add support for converting from lat/lon --- types/mapbox-gl/index.d.ts | 4 ++-- types/mapbox-gl/mapbox-gl-tests.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index 33a619b9ae..91fb68cd96 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.49.0 +// Type definitions for Mapbox GL JS v0.51.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer , Patrick Reames // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -17,7 +17,7 @@ declare namespace mapboxgl { export function setRTLTextPlugin(pluginURL: string, callback: (error: Error) => void): void; - type LngLatLike = LngLat | { lng: number; lat: number; } | [number, number]; + type LngLatLike = LngLat | { lng: number; lat: number; } | { lon: number; lat: number; } | [number, number]; type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]; type PointLike = Point | [number, number]; type Expression = any[]; diff --git a/types/mapbox-gl/mapbox-gl-tests.ts b/types/mapbox-gl/mapbox-gl-tests.ts index d55cf592e5..422b255900 100644 --- a/types/mapbox-gl/mapbox-gl-tests.ts +++ b/types/mapbox-gl/mapbox-gl-tests.ts @@ -417,6 +417,7 @@ function expectType(value: T) { /* let the compiler handle things */ } expectType(new mapboxgl.LngLat(0, 0)); expectType([0, 0]); expectType({ lng: 0, lat: 0 }); +expectType({ lon: 0, lat: 0 }); /* * LngLat From 1e64869613bfe01f4b796ea07ff28109acf45d26 Mon Sep 17 00:00:00 2001 From: Pine Mizune Date: Tue, 13 Nov 2018 14:36:33 +0900 Subject: [PATCH 37/80] Fix contributor GitHub URL --- types/cookie/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/cookie/index.d.ts b/types/cookie/index.d.ts index bb7fc2cb54..cb03c91980 100644 --- a/types/cookie/index.d.ts +++ b/types/cookie/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cookie 0.3 // Project: https://github.com/jshttp/cookie -// Definitions by: Pine Mizune +// Definitions by: Pine Mizune // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface CookieSerializeOptions { From 7aef9be4cdd67b857c7349512b3090038ab8eeb3 Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Wed, 14 Nov 2018 00:40:34 +0200 Subject: [PATCH 38/80] [@ember/routing] Fix redirect hook Prior to this commit `redirect()` hook was mistakenly typed and documented the same way as `refresh()`. It's now fixed for v2 and v3 now. While v3 is provided with a positive and a negative test cases, v2 is only provided with a positive one. This is because v2 uses typescript of version 2.4 which is not able to catch the failing test case. --- types/ember/v2/index.d.ts | 32 ++++++++++++++++++------------ types/ember/v2/test/route.ts | 8 ++++++++ types/ember__routing/route.d.ts | 32 ++++++++++++++++++------------ types/ember__routing/test/route.ts | 16 +++++++++++++++ 4 files changed, 62 insertions(+), 26 deletions(-) diff --git a/types/ember/v2/index.d.ts b/types/ember/v2/index.d.ts index 93babaa0a7..54b6d2e4a9 100755 --- a/types/ember/v2/index.d.ts +++ b/types/ember/v2/index.d.ts @@ -1895,20 +1895,26 @@ declare module 'ember' { paramsFor(name: string): {}; /** - * Refresh the model on this route and any child routes, firing the - * `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - * to how routes are entered when transitioning in from other route. - * The current route params (e.g. `article_id`) will be passed in - * to the respective model hooks, and if a different model is returned, - * `setupController` and associated route hooks will re-fire as well. - * An example usage of this method is re-querying the server for the - * latest information using the same parameters as when the route - * was first entered. - * Note that this will cause `model` hooks to fire even on routes - * that were provided a model object when the route was initially - * entered. + * A hook you can implement to optionally redirect to another route. + * + * If you call `this.transitionTo` from inside of this hook, this route + * will not be entered in favor of the other hook. + * + * `redirect` and `afterModel` behave very similarly and are + * called almost at the same time, but they have an important + * distinction in the case that, from one of these hooks, a + * redirect into a child route of this route occurs: redirects + * from `afterModel` essentially invalidate the current attempt + * to enter this route, and will result in this route's `beforeModel`, + * `model`, and `afterModel` hooks being fired again within + * the new, redirecting transition. Redirects that occur within + * the `redirect` hook, on the other hand, will _not_ cause + * these hooks to be fired again the second time around; in + * other words, by the time the `redirect` hook has been called, + * both the resolved model and attempted entry into this route + * are considered to be fully validated. */ - redirect(): Transition; + redirect(model: {}, transition: Transition): void; /** * Refresh the model on this route and any child routes, firing the diff --git a/types/ember/v2/test/route.ts b/types/ember/v2/test/route.ts index 84e432dbd3..9ce18b410c 100755 --- a/types/ember/v2/test/route.ts +++ b/types/ember/v2/test/route.ts @@ -86,6 +86,14 @@ Route.extend({ }, }); +class RedirectRoute extends Route { + redirect(model: {}, a: Ember.Transition) { + if (!model) { + this.transitionTo('there'); + } + } +} + class RouteUsingClass extends Route.extend({ randomProperty: 'the .extend + extends bit type-checks properly', }) { diff --git a/types/ember__routing/route.d.ts b/types/ember__routing/route.d.ts index 118bd1f1b5..30c9654be9 100644 --- a/types/ember__routing/route.d.ts +++ b/types/ember__routing/route.d.ts @@ -79,20 +79,26 @@ export default class Route extends EmberObject.extend(ActionHandler, Evented) { paramsFor(name: string): {}; /** - * Refresh the model on this route and any child routes, firing the - * `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - * to how routes are entered when transitioning in from other route. - * The current route params (e.g. `article_id`) will be passed in - * to the respective model hooks, and if a different model is returned, - * `setupController` and associated route hooks will re-fire as well. - * An example usage of this method is re-querying the server for the - * latest information using the same parameters as when the route - * was first entered. - * Note that this will cause `model` hooks to fire even on routes - * that were provided a model object when the route was initially - * entered. + * A hook you can implement to optionally redirect to another route. + * + * If you call `this.transitionTo` from inside of this hook, this route + * will not be entered in favor of the other hook. + * + * `redirect` and `afterModel` behave very similarly and are + * called almost at the same time, but they have an important + * distinction in the case that, from one of these hooks, a + * redirect into a child route of this route occurs: redirects + * from `afterModel` essentially invalidate the current attempt + * to enter this route, and will result in this route's `beforeModel`, + * `model`, and `afterModel` hooks being fired again within + * the new, redirecting transition. Redirects that occur within + * the `redirect` hook, on the other hand, will _not_ cause + * these hooks to be fired again the second time around; in + * other words, by the time the `redirect` hook has been called, + * both the resolved model and attempted entry into this route + * are considered to be fully validated. */ - redirect(): Transition; + redirect(model: {}, transition: Transition): void; /** * Refresh the model on this route and any child routes, firing the diff --git a/types/ember__routing/test/route.ts b/types/ember__routing/test/route.ts index 7e2279d8c4..b347768301 100755 --- a/types/ember__routing/test/route.ts +++ b/types/ember__routing/test/route.ts @@ -80,6 +80,22 @@ Route.extend({ }, }); +class RedirectRoute extends Route { + redirect(model: {}, a: Transition) { + if (!model) { + this.transitionTo('there'); + } + } +} + +class InvalidRedirect extends Route { + redirect(model: {}, a: Transition, anOddArg: any) { // $ExpectError + if (!model) { + this.transitionTo('there'); + } + } +} + class ApplicationController extends Controller {} declare module '@ember/controller' { interface Registry { From c58729090bbb9b82e26640db3b1255ce482f529d Mon Sep 17 00:00:00 2001 From: Matthias Dailey Date: Wed, 14 Nov 2018 00:57:17 -0500 Subject: [PATCH 39/80] Update dts-bundle typings --- types/dts-bundle/index.d.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/types/dts-bundle/index.d.ts b/types/dts-bundle/index.d.ts index ffdbed678f..87be2e5c7d 100644 --- a/types/dts-bundle/index.d.ts +++ b/types/dts-bundle/index.d.ts @@ -8,15 +8,21 @@ interface Options { name: string; main: string; baseDir?: string; - exclude?: RegExp; - externals?: boolean; - indent?: string; - newLine?: string; out?: string; - prefix?: string; + externals?: boolean; + referenceExternals?: boolean; + exclude?: RegExp | ((file: string, external: boolean) => boolean); removeSource?: boolean; + newLine?: string; + indent?: string; + prefix?: string; separator?: string; verbose?: boolean; + emitOnIncludedFileNotFound?: boolean; + emitOnNoIncludedFileNotFound?: boolean; + outputAsModuleFolder?: boolean; + headerPath?: string; + headerText?: string; } export declare function bundle(opts: Options): void; From 46b0ea8eb9e6af05ebdef638db5ea7c98166f737 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Wed, 14 Nov 2018 00:20:14 -0700 Subject: [PATCH 40/80] Fix `equal` function when passing in an array For example, `expect([1, 2, 3]).to.equal([1, 2, 3])` previously would give the compilation error: > Argument of type 'number[]' is not assignable to parameter of type 'number'. --- types/code/code-tests.ts | 1 + types/code/index.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/code/code-tests.ts b/types/code/code-tests.ts index 9e5f12645f..f9b55ca72e 100644 --- a/types/code/code-tests.ts +++ b/types/code/code-tests.ts @@ -103,6 +103,7 @@ expect("abcd").to.have.length(4); expect(5).to.equal(5); expect({ a: 1 }).to.equal({ a: 1 }); +expect([1, 2, 3]).to.equal([1, 2, 3]); expect(Object.create(null)).to.equal({}, { prototype: false }); diff --git a/types/code/index.d.ts b/types/code/index.d.ts index 3bdca4be9a..7047fc0702 100644 --- a/types/code/index.d.ts +++ b/types/code/index.d.ts @@ -125,9 +125,9 @@ export interface Values { /** Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys. */ length(size: number): AssertionChain; /** Asserts that the reference value equals the provided value. */ - equal(value: T, options?: any): AssertionChain; + equal(value: T | T[], options?: any): AssertionChain; /** Asserts that the reference value equals the provided value. */ - equals(value: T, options?: any): AssertionChain; + equals(value: T | T[], options?: any): AssertionChain; /** Asserts that the reference value is greater than (>) the provided value. */ above(value: T): AssertionChain; /** Asserts that the reference value is greater than (>) the provided value. */ From 70a1a0ad862bf4510c8d7bea3705a7d70e9958cf Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 14 Nov 2018 13:40:28 +0100 Subject: [PATCH 41/80] Add type definition for the component Documentation here: https://www.npmjs.com/package/@storybook/addon-links#linkto-component-react-only --- types/storybook__addon-links/react.d.ts | 6 ++++++ .../storybook__addon-links/storybook__addon-links-tests.tsx | 4 ++++ types/storybook__addon-links/tsconfig.json | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 types/storybook__addon-links/react.d.ts diff --git a/types/storybook__addon-links/react.d.ts b/types/storybook__addon-links/react.d.ts new file mode 100644 index 0000000000..862753ec9c --- /dev/null +++ b/types/storybook__addon-links/react.d.ts @@ -0,0 +1,6 @@ +import * as React from 'react'; + +export default class LinkTo extends React.PureComponent< + React.DetailedHTMLProps, HTMLAnchorElement> & + { story: string, kind?: string } +> {} diff --git a/types/storybook__addon-links/storybook__addon-links-tests.tsx b/types/storybook__addon-links/storybook__addon-links-tests.tsx index e922b0fc00..29c1969d0f 100644 --- a/types/storybook__addon-links/storybook__addon-links-tests.tsx +++ b/types/storybook__addon-links/storybook__addon-links-tests.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { storiesOf } from '@storybook/react'; import { hrefTo, linkTo } from '@storybook/addon-links'; +import LinkTo from '@storybook/addon-links/react'; storiesOf('Button', module) .add('First', () => ( @@ -11,6 +12,9 @@ storiesOf('Button', module) )) .add('With function', () => ( + )) + .add('With component', () => ( + )); hrefTo('Button', 'First').then(link => link); diff --git a/types/storybook__addon-links/tsconfig.json b/types/storybook__addon-links/tsconfig.json index bb3183eaec..eaedb278f0 100644 --- a/types/storybook__addon-links/tsconfig.json +++ b/types/storybook__addon-links/tsconfig.json @@ -17,6 +17,9 @@ "@storybook/addon-links": [ "storybook__addon-links" ], + "@storybook/addon-links/react": [ + "storybook__addon-links/react" + ], "@storybook/react": [ "storybook__react" ] @@ -27,6 +30,7 @@ }, "files": [ "index.d.ts", + "react.d.ts", "storybook__addon-links-tests.tsx" ] } \ No newline at end of file From b173143c7ced8d6cebc1bc56c55334f9e9568605 Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Wed, 14 Nov 2018 14:50:06 +0000 Subject: [PATCH 42/80] Add a commandable interface that both Slate Editor and Slate React Editor implement --- types/slate-react/index.d.ts | 301 +++++++++- types/slate-react/slate-react-tests.tsx | 256 +++++++- types/slate/index.d.ts | 738 ++++++++++++++++-------- 3 files changed, 1050 insertions(+), 245 deletions(-) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 3d6d0e40df..31e0766172 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -22,6 +22,14 @@ import { Stack, Value, Operation, + MarkProperties, + BlockProperties, + InlineProperties, + Path, + RangeProperties, + NodeProperties, + Commandable, + Range } from "slate"; import * as Immutable from "immutable"; import * as React from "react"; @@ -118,7 +126,7 @@ export interface EditorState { stack: Stack; } -export class Editor extends React.Component { +export class Editor extends React.Component implements Commandable { controller: Controller; schema: Schema; stack: Stack; @@ -128,16 +136,287 @@ export class Editor extends React.Component { readonly readOnly: boolean; readonly value: Value; - // Instance Methods - applyOperation(...args: any[]): Controller; - blur(): void; - command(...args: any[]): Controller; - focus(): void; - normalize(...args: any[]): Controller; - query(...args: any[]): Controller; - resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; - run(...args: any[]): any; - withoutNormalizing(...args: any[]): Controller; + // Commandable + applyOperation(operation: Operation): Editor; + flush(): Editor; + command(name: string, ...args: any[]): void; + query(query: string, ...args: any[]): any; + registerCommand(command: string): void; + registerQuery(query: string): void; + run(key: string, ...args: any[]): any; + setReadOnly(readOnly: boolean): Editor; + setValue(value: Value, options?: { normalize: boolean }): Editor; + addMark(mark: Mark | MarkProperties | string): Editor; + delete(): Editor; + deleteBackward(n: number): Editor; + deleteForward(n: number): Editor; + insertBlock(block: Block | BlockProperties | string): Editor; + insertFragment(fragment: Document): Editor; + insertInline(inline: Inline | InlineProperties): Editor; + insertText(text: string): Editor; + setBlocks(properties: BlockProperties | string): Editor; + setInlines(properties: InlineProperties | string): Editor; + splitBlock(depth: number): Editor; + splitInline(depth: number): Editor; + removeMark(mark: Mark | MarkProperties | string): Editor; + replaceMark( + mark: Mark | MarkProperties | string, + newMark: Mark | MarkProperties | string + ): Editor; + toggleMark(mark: Mark | MarkProperties | string): Editor; + unwrapBlock(properties: BlockProperties | string): Editor; + unwrapInline(properties: InlineProperties | string): Editor; + wrapBlock(properties: BlockProperties | string): Editor; + wrapInline(properties: InlineProperties | string): Editor; + wrapText(prefix: string, suffix?: string): Editor; + blur(): Editor; + deselect(): Editor; + flip(): Editor; + focus(): Editor; + moveAnchorBackward(n?: number): Editor; + moveAnchorForward(n?: number): Editor; + moveAnchorTo(path: Path, offset?: number): Editor; + moveAnchorToEndOfBlock(): Editor; + moveAnchorToEndOfInline(): Editor; + moveAnchorToEndOfDocument(): Editor; + moveAnchorToEndOfNextBlock(): Editor; + moveAnchorToEndOfNextInline(): Editor; + moveAnchorToEndOfNextText(): Editor; + moveAnchorEndOfNode(node: Node): Editor; + moveAnchorToEndOfPreviousBlock(): Editor; + moveAnchorToEndOfPreviousInline(): Editor; + moveAnchorToEndOfPreviousText(): Editor; + moveAnchorToEndOfText(): Editor; + moveAnchorToStartOfBlock(): Editor; + moveAnchorToStartOfDocument(): Editor; + moveAnchorToStartOfInline(): Editor; + moveAnchorToStartOfNextBlock(): Editor; + moveAnchorToStartOfNextInline(): Editor; + moveAnchorToStartOfNextText(): Editor; + moveAnchorToStartOfNode(node: Node): Editor; + moveAnchorToStartOfPreviousBlock(): Editor; + moveAnchorToStartOfPreviousInline(): Editor; + moveAnchorToStartOfPreviousText(): Editor; + moveAnchorToStartOfText(): Editor; + moveEndBackward(n?: number): Editor; + moveEndForward(n?: number): Editor; + moveEndTo(path: Path, offset?: number): Editor; + moveEndToEndOfBlock(): Editor; + moveEndToEndOfDocument(): Editor; + moveEndToEndOfInline(): Editor; + moveEndToEndOfNextBlock(): Editor; + moveEndToEndOfNextInline(): Editor; + moveEndToEndOfNextText(): Editor; + moveEndToEndOfNode(node: Node): Editor; + moveEndToEndOfPreviousBlock(): Editor; + moveEndToEndOfPreviousInline(): Editor; + moveEndToEndOfPreviousText(): Editor; + moveEndToEndOfText(): Editor; + moveEndToStartOfBlock(): Editor; + moveEndToStartOfDocument(): Editor; + moveEndToStartOfInline(): Editor; + moveEndToStartOfNextBlock(): Editor; + moveEndToStartOfNextInline(): Editor; + moveEndToStartOfNextText(): Editor; + moveEndToStartOfNode(node: Node): Editor; + moveEndToStartOfPreviousBlock(): Editor; + moveEndToStartOfPreviousInline(): Editor; + moveEndToStartOfPreviousText(): Editor; + moveEndToStartOfText(): Editor; + moveFocusBackward(n?: number): Editor; + moveFocusForward(n?: number): Editor; + moveFocusTo(path: Path, offset?: number): Editor; + moveFocusToEndOfBlock(): Editor; + moveFocusToEndOfDocument(): Editor; + moveFocusToEndOfInline(): Editor; + moveFocusToEndOfNextBlock(): Editor; + moveFocusToEndOfNextInline(): Editor; + moveFocusToEndOfNextText(): Editor; + moveFocusToEndOfNode(node: Node): Editor; + moveFocusToEndOfPreviousBlock(): Editor; + moveFocusToEndOfPreviousInline(): Editor; + moveFocusToEndOfPreviousText(): Editor; + moveFocusToEndOfText(): Editor; + moveFocusToStartOfBlock(): Editor; + moveFocusToStartOfDocument(): Editor; + moveFocusToStartOfInline(): Editor; + moveFocusToStartOfNextBlock(): Editor; + moveFocusToStartOfNextInline(): Editor; + moveFocusToStartOfNextText(): Editor; + moveFocusToStartOfNode(node: Node): Editor; + moveFocusToStartOfPreviousBlock(): Editor; + moveFocusToStartOfPreviousInline(): Editor; + moveFocusToStartOfPreviousText(): Editor; + moveFocusToStartOfText(): Editor; + moveStartForward(n?: number): Editor; + moveStartBackward(n?: number): Editor; + moveStartTo(path: Path, n?: number): Editor; + moveStartToEndOfBlock(): Editor; + moveStartToEndOfDocument(): Editor; + moveStartToEndOfInline(): Editor; + moveStartToEndOfNextBlock(): Editor; + moveStartToEndOfNextInline(): Editor; + moveStartToEndOfNextText(): Editor; + moveStartToEndOfNode(node: Node): Editor; + moveStartToEndOfPreviousBlock(): Editor; + moveStartToEndOfPreviousInline(): Editor; + moveStartToEndOfPreviousText(): Editor; + moveStartToEndOfText(): Editor; + moveStartToStartOfBlock(): Editor; + moveStartToStartOfDocument(): Editor; + moveStartToStartOfInline(): Editor; + moveStartToStartOfNextBlock(): Editor; + moveStartToStartOfNextInline(): Editor; + moveStartToStartOfNextText(): Editor; + moveStartToStartOfNode(node: Node): Editor; + moveStartToStartOfPreviousBlock(): Editor; + moveStartToStartOfPreviousInline(): Editor; + moveStartToStartOfPreviousText(): Editor; + moveStartToStartOfText(): Editor; + moveBackward(n?: number): Editor; + moveForward(n?: number): Editor; + moveTo(path: Path, offset?: number): Editor; + moveToAnchor(): Editor; + moveToFocus(): Editor; + moveToStart(): Editor; + moveToEnd(): Editor; + moveToEndOfBlock(): Editor; + moveToEndOfDocument(): Editor; + moveToEndOfInline(): Editor; + moveToEndOfNextBlock(): Editor; + moveToEndOfNextInline(): Editor; + moveToEndOfNextText(): Editor; + moveToEndOfNode(node: Node): Editor; + moveToEndOfPreviousBlock(): Editor; + moveToEndOfPreviousInline(): Editor; + moveToEndOfPreviousText(): Editor; + moveToEndOfText(): Editor; + moveToStartOfBlock(): Editor; + moveToStartOfDocument(): Editor; + moveToStartOfInline(): Editor; + moveToStartOfNextBlock(): Editor; + moveToStartOfNextInline(): Editor; + moveToStartOfNextText(): Editor; + moveToStartOfNode(node: Node): Editor; + moveToStartOfPreviousBlock(): Editor; + moveToStartOfPreviousInline(): Editor; + moveToStartOfPreviousText(): Editor; + moveToStartOfText(): Editor; + moveToRangeOfDocument(): Editor; + moveToRangeOf(node: Node): Editor; + select(properties: Range | RangeProperties): Editor; + addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + deleteAtRange(range: Range): Editor; + deleteCharBackwardAtRange(range: Range): Editor; + deleteLineBackwardAtRange(range: Range): Editor; + deleteWordBackwardAtRange(range: Range): Editor; + deleteBackwardAtRange(range: Range, n: number): Editor; + deleteCharForwardAtRange(range: Range): Editor; + deleteLineForwardAtRange(range: Range): Editor; + deleteWordForwardAtRange(range: Range): Editor; + deleteForwardAtRange(range: Range, n: number): Editor; + insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Editor; + insertFragmentAtRange(range: Range, fragment: Document): Editor; + insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Editor; + insertTextAtRange(range: Range, text: string): Editor; + setBlocksAtRange(range: Range, properties: BlockProperties | string): Editor; + setInlinesAtRange(range: Range, properties: InlineProperties | string): Editor; + splitBlockAtRange(range: Range, depth: number): Editor; + splitInlineAtRange(range: Range, depth: number): Editor; + removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + wrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapTextAtRange(range: Range, prefix: string, suffix?: string): Editor; + addMarkByKey( + key: string, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + addMarkByPath( + path: Path, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + insertNodeByKey(key: string, index: number, node: Node): Editor; + insertNodeByPath(path: Path, index: number, node: Node): Editor; + insertFragmentByKey(key: string, index: number, fragment: Document): Editor; + insertFragmentByPath(path: Path, index: number, fragment: Document): Editor; + insertTextByKey( + key: string, + offset: number, + text: string, + marks?: Immutable.Set | Mark[] + ): Editor; + insertTextByPath( + path: Path, + offset: number, + text: string, + marks?: Immutable.Set | Mark[] + ): Editor; + mergeNodeByKey(key: string): Editor; + mergeNodeByPath(path: Path): Editor; + moveNodeByKey(key: string, newKey: string, newIndex: number): Editor; + moveNodeByPath(path: Path, newPath: Path, newIndex: number): Editor; + removeMarkByKey( + key: string, + offset: number, + length: number, + mark: Mark | Mark | string + ): Editor; + removeMarkByPath( + path: Path, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + removeNodeByKey(key: string): Editor; + removeNodeByPath(path: Path): Editor; + replaceNodeByKey(key: string, node: Node): Editor; + replaceNodeByPath(path: Path, newNode: Node): Editor; + removeTextByKey(key: string, offset: number, length: number): Editor; + removeTextByPath(path: Path, offset: number, length: number): Editor; + setMarkByKey( + key: string, + offset: number, + length: number, + mark: Mark, + properties: MarkProperties + ): Editor; + setMarksByPath( + path: Path, + offset: number, + length: number, + mark: Mark, + properties: MarkProperties + ): Editor; + setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Editor; + setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Editor; + splitNodeByKey(key: string, offset: number): Editor; + splitNodeByPath(path: Path, position: number): Editor; + unwrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + unwrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + unwrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + unwrapBlockByPath(path: Path, properties: BlockProperties | string): Editor; + unwrapNodeByKey(key: string): Editor; + unwrapNodeByPath(path: Path): Editor; + wrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + wrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + wrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + wrapBlockByPath(path: Path, block: Block | string): Editor; + wrapNodeByKey(key: string, parent: Node): Editor; + wrapNodeByPath(path: Path, parent: Node): Editor; + normalize(): Editor; + withoutNormalizing(fn: () => void): Editor; + withoutSaving(fn: () => void): Editor; + withoutMerging(fn: () => void): Editor; + redo(): Editor; + undo(): Editor; + snapshotSelection(): Editor; } export type SlateType = diff --git a/types/slate-react/slate-react-tests.tsx b/types/slate-react/slate-react-tests.tsx index d8ef3b29be..851debf0f1 100644 --- a/types/slate-react/slate-react-tests.tsx +++ b/types/slate-react/slate-react-tests.tsx @@ -1,5 +1,5 @@ import { Editor, Plugin, EditorProps, RenderNodeProps } from "slate-react"; -import { Value, Editor as Controller, Operation } from "slate"; +import { Value, Editor as Controller, Operation, Point, Range, Inline, Mark, Document } from "slate"; import * as React from "react"; import * as Immutable from "immutable"; @@ -28,11 +28,13 @@ interface MyEditorState { value: Value; } +const value = Value.create(); + class MyEditor extends React.Component { constructor(props: EditorProps) { super(props); this.state = { - value: Value.create() + value }; } render() { @@ -42,3 +44,253 @@ class MyEditor extends React.Component { onChange={ myPlugin.onChange }/>; } } + +const editor = new Editor({ value }); +const point = Point.create({ key: "a", offset: 0 }); +const range = Range.create({ anchor: point, focus: point }); +const inline = Inline.create("text"); +const mark = Mark.create("bold"); +const doc = Document.fromJSON({ + object: "document", + data: {}, + nodes: [] +}); + +editor +.addMark("bold") +.addMarkAtRange(range, "italic") +.addMarkByKey("a", 0, 1, "bold") +.addMarkByPath("a", 0, 1, "bold") +.blur() +.delete() +.deleteAtRange(range) +.deleteBackward(0) +.deleteBackwardAtRange(range, 0) +.deleteCharBackwardAtRange(range) +.deleteCharForwardAtRange(range) +.deleteForward(0) +.deleteForwardAtRange(range, 0) +.deleteLineBackwardAtRange(range) +.deleteLineForwardAtRange(range) +.deleteWordBackwardAtRange(range) +.deleteWordForwardAtRange(range) +.deselect() +.flip() +.flush() +.focus() +.insertBlock({ + type: "image", + key: "b", + data: { + src: "http://placekitten.com/200/300", + alt: "Kittens", + className: "img-responsive" + } +}) +.insertBlockAtRange(range, "text") +.insertFragment(doc) +.insertFragmentAtRange(range, doc) +.insertFragmentByKey("a", 0, doc) +.insertFragmentByPath("a", 0, doc) +.insertInline(inline) +.insertInlineAtRange(range, inline) +.insertNodeByKey("a", 0, inline) +.insertNodeByPath("a", 0, inline) +.insertText("A bit of rich text, followed by...") +.insertTextAtRange(range, "More text") +.insertTextByKey("a", 0, "text") +.insertTextByPath("a", 0, "text") +.mergeNodeByKey("b") +.mergeNodeByPath("b") +.moveAnchorBackward() +.moveAnchorEndOfNode(inline) +.moveAnchorForward() +.moveAnchorTo("a", 0) +.moveAnchorToEndOfBlock() +.moveAnchorToEndOfDocument() +.moveAnchorToEndOfInline() +.moveAnchorToEndOfNextBlock() +.moveAnchorToEndOfNextInline() +.moveAnchorToEndOfNextText() +.moveAnchorToEndOfPreviousBlock() +.moveAnchorToEndOfPreviousInline() +.moveAnchorToEndOfPreviousText() +.moveAnchorToEndOfText() +.moveAnchorToStartOfBlock() +.moveAnchorToStartOfDocument() +.moveAnchorToStartOfInline() +.moveAnchorToStartOfNextBlock() +.moveAnchorToStartOfNextInline() +.moveAnchorToStartOfNextText() +.moveAnchorToStartOfNode(inline) +.moveAnchorToStartOfPreviousBlock() +.moveAnchorToStartOfPreviousInline() +.moveAnchorToStartOfPreviousText() +.moveAnchorToStartOfText() +.moveBackward() +.moveEndBackward() +.moveEndForward() +.moveEndTo("a", 0) +.moveEndToEndOfBlock() +.moveEndToEndOfDocument() +.moveEndToEndOfInline() +.moveEndToEndOfNextBlock() +.moveEndToEndOfNextInline() +.moveEndToEndOfNextText() +.moveEndToEndOfNode(inline) +.moveEndToEndOfPreviousBlock() +.moveEndToEndOfPreviousInline() +.moveEndToEndOfPreviousText() +.moveEndToEndOfText() +.moveEndToStartOfBlock() +.moveEndToStartOfDocument() +.moveEndToStartOfInline() +.moveEndToStartOfNextBlock() +.moveEndToStartOfNextInline() +.moveEndToStartOfNextText() +.moveEndToStartOfNode(inline) +.moveEndToStartOfPreviousBlock() +.moveEndToStartOfPreviousInline() +.moveEndToStartOfPreviousText() +.moveEndToStartOfText() +.moveFocusBackward() +.moveFocusForward() +.moveFocusTo("a", 0) +.moveFocusToEndOfBlock() +.moveFocusToEndOfDocument() +.moveFocusToEndOfInline() +.moveFocusToEndOfNextBlock() +.moveFocusToEndOfNextInline() +.moveFocusToEndOfNextText() +.moveFocusToEndOfNode(inline) +.moveFocusToEndOfPreviousBlock() +.moveFocusToEndOfPreviousInline() +.moveFocusToEndOfPreviousText() +.moveFocusToEndOfText() +.moveFocusToStartOfBlock() +.moveFocusToStartOfDocument() +.moveFocusToStartOfInline() +.moveFocusToStartOfNextBlock() +.moveFocusToStartOfNextInline() +.moveFocusToStartOfNextText() +.moveFocusToStartOfNode(inline) +.moveFocusToStartOfPreviousBlock() +.moveFocusToStartOfPreviousInline() +.moveFocusToStartOfPreviousText() +.moveFocusToStartOfText() +.moveForward() +.moveNodeByKey("b", "c", 2) +.moveNodeByPath("c", "b", 1) +.moveStartBackward() +.moveStartForward() +.moveStartTo("a", 0) +.moveStartToEndOfBlock() +.moveStartToEndOfDocument() +.moveStartToEndOfInline() +.moveStartToEndOfNextBlock() +.moveStartToEndOfNextInline() +.moveStartToEndOfNextText() +.moveStartToEndOfNode(inline) +.moveStartToEndOfPreviousBlock() +.moveStartToEndOfPreviousInline() +.moveStartToEndOfPreviousText() +.moveStartToEndOfText() +.moveStartToStartOfBlock() +.moveStartToStartOfDocument() +.moveStartToStartOfInline() +.moveStartToStartOfNextBlock() +.moveStartToStartOfNextInline() +.moveStartToStartOfNextText() +.moveStartToStartOfNode(inline) +.moveStartToStartOfPreviousBlock() +.moveStartToStartOfPreviousInline() +.moveStartToStartOfPreviousText() +.moveStartToStartOfText() +.moveTo("a", 0) +.moveToAnchor() +.moveToEnd() +.moveToEndOfBlock() +.moveToEndOfDocument() +.moveToEndOfInline() +.moveToEndOfNextBlock() +.moveToEndOfNextInline() +.moveToEndOfNextText() +.moveToEndOfNode(inline) +.moveToEndOfPreviousBlock() +.moveToEndOfPreviousInline() +.moveToEndOfPreviousText() +.moveToEndOfText() +.moveToFocus() +.moveToRangeOf(inline) +.moveToRangeOfDocument() +.moveToStart() +.moveToStartOfBlock() +.moveToStartOfDocument() +.moveToStartOfInline() +.moveToStartOfNextBlock() +.moveToStartOfNextInline() +.moveToStartOfNextText() +.moveToStartOfNode(inline) +.moveToStartOfPreviousBlock() +.moveToStartOfPreviousInline() +.moveToStartOfPreviousText() +.moveToStartOfText() +.normalize() +.redo() +.removeMark("bold") +.removeMarkAtRange(range, "bold") +.removeMarkByKey("a", 0, 1, "bold") +.removeMarkByPath("a", 0, 1, "bold") +.removeNodeByKey("b") +.removeNodeByPath("b") +.removeTextByKey("a", 0, 1) +.removeTextByPath("a", 0, 1) +.replaceMark("bold", "italic") +.replaceNodeByKey("a", inline) +.replaceNodeByPath("a", inline) +.select(range) +.setBlocks("paragraph") +.setBlocksAtRange(range, "paragraph") +.setInlines("paragraph") +.setInlinesAtRange(range, "paragraph") +.setMarkByKey("a", 0, 1, mark, { type: "bold" }) +.setMarksByPath("a", 0, 1, mark, { type: "bold" }) +.setNodeByKey("a", "paragraph") +.setNodeByPath("a", "paragraph") +.setReadOnly(true) +.setValue(value) +.snapshotSelection() +.splitBlock(0) +.splitBlockAtRange(range, 0) +.splitInline(0) +.splitInlineAtRange(range, 0) +.splitNodeByKey("a", 0) +.splitNodeByPath("a", 0) +.toggleMark("bold") +.toggleMarkAtRange(range, "bold") +.undo() +.unwrapBlock("paragraph") +.unwrapBlockAtRange(range, "paragraph") +.unwrapBlockByKey("a", "paragraph") +.unwrapBlockByPath("a", "paragraph") +.unwrapInline("paragraph") +.unwrapInlineAtRange(range, "paragraph") +.unwrapInlineByKey("a", "paragraph") +.unwrapInlineByPath("a", "paragraph") +.unwrapNodeByKey("a") +.unwrapNodeByPath("a") +.withoutMerging(() => { /* noop */ }) +.withoutNormalizing(() => { /* noop */ }) +.withoutSaving(() => { /* noop */ }) +.wrapBlock("paragraph") +.wrapBlockAtRange(range, "paragraph") +.wrapBlockByKey("a", "paragraph") +.wrapBlockByPath("a", "paragraph") +.wrapInline("paragraph") +.wrapInlineAtRange(range, "paragraph") +.wrapInlineByKey("a", "paragraph") +.wrapInlineByPath("a", "paragraph") +.wrapNodeByKey("a", inline) +.wrapNodeByPath("a", inline) +.wrapText("a", "b") +.wrapTextAtRange(range, "a"); diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 3ea0d97817..2d61a6d074 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -1054,7 +1054,7 @@ export interface EditorProperties { value?: Value; } -export class Editor { +export class Editor implements Commandable { object: "editor"; onChange: (change: { operations: Immutable.List, value: Value }) => void; plugins: any[]; @@ -1063,7 +1063,7 @@ export class Editor { constructor(attributes: EditorProperties) /** - * Apply an `operation` to the editor, updating its value. + * Apply an `operation` to the Editor, updating its value. */ applyOperation(operation: Operation): Editor; @@ -1100,81 +1100,355 @@ export class Editor { */ setValue(value: Value, options?: { normalize: boolean }): Editor; - // Built in Command Operations // + // Commandable + addMark(mark: Mark | MarkProperties | string): Editor; + delete(): Editor; + deleteBackward(n: number): Editor; + deleteForward(n: number): Editor; + insertBlock(block: Block | BlockProperties | string): Editor; + insertFragment(fragment: Document): Editor; + insertInline(inline: Inline | InlineProperties): Editor; + insertText(text: string): Editor; + setBlocks(properties: BlockProperties | string): Editor; + setInlines(properties: InlineProperties | string): Editor; + splitBlock(depth: number): Editor; + splitInline(depth: number): Editor; + removeMark(mark: Mark | MarkProperties | string): Editor; + replaceMark( + mark: Mark | MarkProperties | string, + newMark: Mark | MarkProperties | string + ): Editor; + toggleMark(mark: Mark | MarkProperties | string): Editor; + unwrapBlock(properties: BlockProperties | string): Editor; + unwrapInline(properties: InlineProperties | string): Editor; + wrapBlock(properties: BlockProperties | string): Editor; + wrapInline(properties: InlineProperties | string): Editor; + wrapText(prefix: string, suffix?: string): Editor; + blur(): Editor; + deselect(): Editor; + flip(): Editor; + focus(): Editor; + moveAnchorBackward(n?: number): Editor; + moveAnchorForward(n?: number): Editor; + moveAnchorTo(path: Path, offset?: number): Editor; + moveAnchorToEndOfBlock(): Editor; + moveAnchorToEndOfInline(): Editor; + moveAnchorToEndOfDocument(): Editor; + moveAnchorToEndOfNextBlock(): Editor; + moveAnchorToEndOfNextInline(): Editor; + moveAnchorToEndOfNextText(): Editor; + moveAnchorEndOfNode(node: Node): Editor; + moveAnchorToEndOfPreviousBlock(): Editor; + moveAnchorToEndOfPreviousInline(): Editor; + moveAnchorToEndOfPreviousText(): Editor; + moveAnchorToEndOfText(): Editor; + moveAnchorToStartOfBlock(): Editor; + moveAnchorToStartOfDocument(): Editor; + moveAnchorToStartOfInline(): Editor; + moveAnchorToStartOfNextBlock(): Editor; + moveAnchorToStartOfNextInline(): Editor; + moveAnchorToStartOfNextText(): Editor; + moveAnchorToStartOfNode(node: Node): Editor; + moveAnchorToStartOfPreviousBlock(): Editor; + moveAnchorToStartOfPreviousInline(): Editor; + moveAnchorToStartOfPreviousText(): Editor; + moveAnchorToStartOfText(): Editor; + moveEndBackward(n?: number): Editor; + moveEndForward(n?: number): Editor; + moveEndTo(path: Path, offset?: number): Editor; + moveEndToEndOfBlock(): Editor; + moveEndToEndOfDocument(): Editor; + moveEndToEndOfInline(): Editor; + moveEndToEndOfNextBlock(): Editor; + moveEndToEndOfNextInline(): Editor; + moveEndToEndOfNextText(): Editor; + moveEndToEndOfNode(node: Node): Editor; + moveEndToEndOfPreviousBlock(): Editor; + moveEndToEndOfPreviousInline(): Editor; + moveEndToEndOfPreviousText(): Editor; + moveEndToEndOfText(): Editor; + moveEndToStartOfBlock(): Editor; + moveEndToStartOfDocument(): Editor; + moveEndToStartOfInline(): Editor; + moveEndToStartOfNextBlock(): Editor; + moveEndToStartOfNextInline(): Editor; + moveEndToStartOfNextText(): Editor; + moveEndToStartOfNode(node: Node): Editor; + moveEndToStartOfPreviousBlock(): Editor; + moveEndToStartOfPreviousInline(): Editor; + moveEndToStartOfPreviousText(): Editor; + moveEndToStartOfText(): Editor; + moveFocusBackward(n?: number): Editor; + moveFocusForward(n?: number): Editor; + moveFocusTo(path: Path, offset?: number): Editor; + moveFocusToEndOfBlock(): Editor; + moveFocusToEndOfDocument(): Editor; + moveFocusToEndOfInline(): Editor; + moveFocusToEndOfNextBlock(): Editor; + moveFocusToEndOfNextInline(): Editor; + moveFocusToEndOfNextText(): Editor; + moveFocusToEndOfNode(node: Node): Editor; + moveFocusToEndOfPreviousBlock(): Editor; + moveFocusToEndOfPreviousInline(): Editor; + moveFocusToEndOfPreviousText(): Editor; + moveFocusToEndOfText(): Editor; + moveFocusToStartOfBlock(): Editor; + moveFocusToStartOfDocument(): Editor; + moveFocusToStartOfInline(): Editor; + moveFocusToStartOfNextBlock(): Editor; + moveFocusToStartOfNextInline(): Editor; + moveFocusToStartOfNextText(): Editor; + moveFocusToStartOfNode(node: Node): Editor; + moveFocusToStartOfPreviousBlock(): Editor; + moveFocusToStartOfPreviousInline(): Editor; + moveFocusToStartOfPreviousText(): Editor; + moveFocusToStartOfText(): Editor; + moveStartForward(n?: number): Editor; + moveStartBackward(n?: number): Editor; + moveStartTo(path: Path, n?: number): Editor; + moveStartToEndOfBlock(): Editor; + moveStartToEndOfDocument(): Editor; + moveStartToEndOfInline(): Editor; + moveStartToEndOfNextBlock(): Editor; + moveStartToEndOfNextInline(): Editor; + moveStartToEndOfNextText(): Editor; + moveStartToEndOfNode(node: Node): Editor; + moveStartToEndOfPreviousBlock(): Editor; + moveStartToEndOfPreviousInline(): Editor; + moveStartToEndOfPreviousText(): Editor; + moveStartToEndOfText(): Editor; + moveStartToStartOfBlock(): Editor; + moveStartToStartOfDocument(): Editor; + moveStartToStartOfInline(): Editor; + moveStartToStartOfNextBlock(): Editor; + moveStartToStartOfNextInline(): Editor; + moveStartToStartOfNextText(): Editor; + moveStartToStartOfNode(node: Node): Editor; + moveStartToStartOfPreviousBlock(): Editor; + moveStartToStartOfPreviousInline(): Editor; + moveStartToStartOfPreviousText(): Editor; + moveStartToStartOfText(): Editor; + moveBackward(n?: number): Editor; + moveForward(n?: number): Editor; + moveTo(path: Path, offset?: number): Editor; + moveToAnchor(): Editor; + moveToFocus(): Editor; + moveToStart(): Editor; + moveToEnd(): Editor; + moveToEndOfBlock(): Editor; + moveToEndOfDocument(): Editor; + moveToEndOfInline(): Editor; + moveToEndOfNextBlock(): Editor; + moveToEndOfNextInline(): Editor; + moveToEndOfNextText(): Editor; + moveToEndOfNode(node: Node): Editor; + moveToEndOfPreviousBlock(): Editor; + moveToEndOfPreviousInline(): Editor; + moveToEndOfPreviousText(): Editor; + moveToEndOfText(): Editor; + moveToStartOfBlock(): Editor; + moveToStartOfDocument(): Editor; + moveToStartOfInline(): Editor; + moveToStartOfNextBlock(): Editor; + moveToStartOfNextInline(): Editor; + moveToStartOfNextText(): Editor; + moveToStartOfNode(node: Node): Editor; + moveToStartOfPreviousBlock(): Editor; + moveToStartOfPreviousInline(): Editor; + moveToStartOfPreviousText(): Editor; + moveToStartOfText(): Editor; + moveToRangeOfDocument(): Editor; + moveToRangeOf(node: Node): Editor; + select(properties: Range | RangeProperties): Editor; + addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + deleteAtRange(range: Range): Editor; + deleteCharBackwardAtRange(range: Range): Editor; + deleteLineBackwardAtRange(range: Range): Editor; + deleteWordBackwardAtRange(range: Range): Editor; + deleteBackwardAtRange(range: Range, n: number): Editor; + deleteCharForwardAtRange(range: Range): Editor; + deleteLineForwardAtRange(range: Range): Editor; + deleteWordForwardAtRange(range: Range): Editor; + deleteForwardAtRange(range: Range, n: number): Editor; + insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Editor; + insertFragmentAtRange(range: Range, fragment: Document): Editor; + insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Editor; + insertTextAtRange(range: Range, text: string): Editor; + setBlocksAtRange(range: Range, properties: BlockProperties | string): Editor; + setInlinesAtRange(range: Range, properties: InlineProperties | string): Editor; + splitBlockAtRange(range: Range, depth: number): Editor; + splitInlineAtRange(range: Range, depth: number): Editor; + removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + wrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapTextAtRange(range: Range, prefix: string, suffix?: string): Editor; + addMarkByKey( + key: string, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + addMarkByPath( + path: Path, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + insertNodeByKey(key: string, index: number, node: Node): Editor; + insertNodeByPath(path: Path, index: number, node: Node): Editor; + insertFragmentByKey(key: string, index: number, fragment: Document): Editor; + insertFragmentByPath(path: Path, index: number, fragment: Document): Editor; + insertTextByKey( + key: string, + offset: number, + text: string, + marks?: Immutable.Set | Mark[] + ): Editor; + insertTextByPath( + path: Path, + offset: number, + text: string, + marks?: Immutable.Set | Mark[] + ): Editor; + mergeNodeByKey(key: string): Editor; + mergeNodeByPath(path: Path): Editor; + moveNodeByKey(key: string, newKey: string, newIndex: number): Editor; + moveNodeByPath(path: Path, newPath: Path, newIndex: number): Editor; + removeMarkByKey( + key: string, + offset: number, + length: number, + mark: Mark | Mark | string + ): Editor; + removeMarkByPath( + path: Path, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + removeNodeByKey(key: string): Editor; + removeNodeByPath(path: Path): Editor; + replaceNodeByKey(key: string, node: Node): Editor; + replaceNodeByPath(path: Path, newNode: Node): Editor; + removeTextByKey(key: string, offset: number, length: number): Editor; + removeTextByPath(path: Path, offset: number, length: number): Editor; + setMarkByKey( + key: string, + offset: number, + length: number, + mark: Mark, + properties: MarkProperties + ): Editor; + setMarksByPath( + path: Path, + offset: number, + length: number, + mark: Mark, + properties: MarkProperties + ): Editor; + setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Editor; + setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Editor; + splitNodeByKey(key: string, offset: number): Editor; + splitNodeByPath(path: Path, position: number): Editor; + unwrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + unwrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + unwrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + unwrapBlockByPath(path: Path, properties: BlockProperties | string): Editor; + unwrapNodeByKey(key: string): Editor; + unwrapNodeByPath(path: Path): Editor; + wrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + wrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + wrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + wrapBlockByPath(path: Path, block: Block | string): Editor; + wrapNodeByKey(key: string, parent: Node): Editor; + wrapNodeByPath(path: Path, parent: Node): Editor; + normalize(): Editor; + withoutNormalizing(fn: () => void): Editor; + withoutSaving(fn: () => void): Editor; + withoutMerging(fn: () => void): Editor; + redo(): Editor; + undo(): Editor; + snapshotSelection(): Editor; +} + +export interface Commandable { // Current Selection Commands // /** * Add a mark to the characters in the current selection */ - addMark(mark: Mark | MarkProperties | string): Editor; + addMark(mark: Mark | MarkProperties | string): Commandable; /** * Delete everything in the current selection. */ - delete(): Editor; + delete(): Commandable; /** * Delete backward n characters at the current cursor. * If the selection is expanded, behaviour is equivalent to delete() */ - deleteBackward(n: number): Editor; + deleteBackward(n: number): Commandable; /** * Delete backward n characters at the current cursor. * If the selection is expanded, behaviour is equivalent to delete() */ - deleteForward(n: number): Editor; + deleteForward(n: number): Commandable; /** * Insert a new block at the same level as the current block, splitting the current block to make room if it is non-empty. * If the selection is expanded, it will be deleted first. */ - insertBlock(block: Block | BlockProperties | string): Editor; + insertBlock(block: Block | BlockProperties | string): Commandable; /** * Insert a document fragment at the current selection. If the selection is expanded, it will be deleted first. */ - insertFragment(fragment: Document): Editor; + insertFragment(fragment: Document): Commandable; /** * Insert a new inline at the current cursor position, splitting the text to make room if it is non-empty. * If the selection is expanded, it will be deleted first. */ - insertInline(inline: Inline | InlineProperties): Editor; + insertInline(inline: Inline | InlineProperties): Commandable; /** * Insert a string of text at the current selection. If the selection is expanded, it will be deleted first */ - insertText(text: string): Editor; + insertText(text: string): Commandable; /** * Set the properties of the Blocks in the current selection. * Passing a string will set the blocks' type only. */ - setBlocks(properties: BlockProperties | string): Editor; + setBlocks(properties: BlockProperties | string): Commandable; /** * Set the properties of the Inlines nodes in the current selection. * Passing a string will set the nodes' type only. */ - setInlines(properties: InlineProperties | string): Editor; + setInlines(properties: InlineProperties | string): Commandable; /** * Split the Block in the current selection by depth levels. * If the selection is expanded, it will be deleted first. */ - splitBlock(depth: number): Editor; + splitBlock(depth: number): Commandable; /** * Split the Inline node in the current selection by depth levels. * If the selection is expanded, it will be deleted first */ - splitInline(depth: number): Editor; + splitInline(depth: number): Commandable; /** * Remove a mark from the characters in the current selection. * Passing a string will implicitly create a Mark of that type for removal. */ - removeMark(mark: Mark | MarkProperties | string): Editor; + removeMark(mark: Mark | MarkProperties | string): Commandable; /** * Remove a mark from the characters in the current selection. @@ -1183,595 +1457,595 @@ export class Editor { replaceMark( mark: Mark | MarkProperties | string, newMark: Mark | MarkProperties | string - ): Editor; + ): Commandable; /** * Add or remove a mark from the characters in the current selection, depending on it already exists on any or not. * Passing a string will implicitly create a Mark of that type to toggle. */ - toggleMark(mark: Mark | MarkProperties | string): Editor; + toggleMark(mark: Mark | MarkProperties | string): Commandable; /** * Unwrap all Block nodes in the current selection that match a type and/or data */ - unwrapBlock(properties: BlockProperties | string): Editor; + unwrapBlock(properties: BlockProperties | string): Commandable; /** * Unwrap all Inline nodes in the current selection that match a type and/or data */ - unwrapInline(properties: InlineProperties | string): Editor; + unwrapInline(properties: InlineProperties | string): Commandable; /** * Wrap the Block nodes in the current selection with a new Block */ - wrapBlock(properties: BlockProperties | string): Editor; + wrapBlock(properties: BlockProperties | string): Commandable; /** * Wrap the Block nodes in the current selection with a new Inline */ - wrapInline(properties: InlineProperties | string): Editor; + wrapInline(properties: InlineProperties | string): Commandable; /** * Surround the text in the current selection with prefix and suffix strings. * If the suffix is ommitted, the prefix will be used instead. */ - wrapText(prefix: string, suffix?: string): Editor; + wrapText(prefix: string, suffix?: string): Commandable; // Selection Commands // /** * Blur the current selection */ - blur(): Editor; + blur(): Commandable; /** * Unset the selection */ - deselect(): Editor; + deselect(): Commandable; /** * Flip the selection */ - flip(): Editor; + flip(): Commandable; /** * Focus the current selection */ - focus(): Editor; + focus(): Commandable; /** * Move the anchor of the current selection backward n characters */ - moveAnchorBackward(n?: number): Editor; + moveAnchorBackward(n?: number): Commandable; /** * Move the anchor of the current selection forward n characters */ - moveAnchorForward(n?: number): Editor; + moveAnchorForward(n?: number): Commandable; /** * Move the anchor of the current selection to a new path and offset */ - moveAnchorTo(path: Path, offset?: number): Editor; + moveAnchorTo(path: Path, offset?: number): Commandable; /** * Move the anchor of the current selection to the end of the closest block parent. */ - moveAnchorToEndOfBlock(): Editor; + moveAnchorToEndOfBlock(): Commandable; /** * Move the anchor of the current selection to the end of the closest inline parent. */ - moveAnchorToEndOfInline(): Editor; + moveAnchorToEndOfInline(): Commandable; /** * Move the anchor of the current selection to the end of the document. */ - moveAnchorToEndOfDocument(): Editor; + moveAnchorToEndOfDocument(): Commandable; /** * Move the anchor of the current selection to the end of the next block. */ - moveAnchorToEndOfNextBlock(): Editor; + moveAnchorToEndOfNextBlock(): Commandable; /** * Move the anchor of the current selection to the end of the next inline. */ - moveAnchorToEndOfNextInline(): Editor; + moveAnchorToEndOfNextInline(): Commandable; /** * Move the anchor of the current selection to the end of the next text. */ - moveAnchorToEndOfNextText(): Editor; + moveAnchorToEndOfNextText(): Commandable; /** * Move the anchor of the current selection to the end of the provided node. */ - moveAnchorEndOfNode(node: Node): Editor; + moveAnchorEndOfNode(node: Node): Commandable; /** * Move the anchor of the current selection to the end of the previous block. */ - moveAnchorToEndOfPreviousBlock(): Editor; + moveAnchorToEndOfPreviousBlock(): Commandable; /** * Move the anchor of the current selection to the end of the previous inline. */ - moveAnchorToEndOfPreviousInline(): Editor; + moveAnchorToEndOfPreviousInline(): Commandable; /** * Move the anchor of the current selection to the end of the previous text. */ - moveAnchorToEndOfPreviousText(): Editor; + moveAnchorToEndOfPreviousText(): Commandable; /** * Move the anchor of the current selection to the end of the current text node. */ - moveAnchorToEndOfText(): Editor; + moveAnchorToEndOfText(): Commandable; /** * Move the anchor of the current selection to the start of the closest block parent. */ - moveAnchorToStartOfBlock(): Editor; + moveAnchorToStartOfBlock(): Commandable; /** * Move the anchor of the current selection to the start of the document. */ - moveAnchorToStartOfDocument(): Editor; + moveAnchorToStartOfDocument(): Commandable; /** * Move the anchor of the current selection to the start of the closest inline parent. */ - moveAnchorToStartOfInline(): Editor; + moveAnchorToStartOfInline(): Commandable; /** * Move the anchor of the current selection to the start of the next block. */ - moveAnchorToStartOfNextBlock(): Editor; + moveAnchorToStartOfNextBlock(): Commandable; /** * Move the anchor of the current selection to the start of the next inline. */ - moveAnchorToStartOfNextInline(): Editor; + moveAnchorToStartOfNextInline(): Commandable; /** * Move the anchor of the current selection to the start of the next text node. */ - moveAnchorToStartOfNextText(): Editor; + moveAnchorToStartOfNextText(): Commandable; /** * Move the anchor of the current selection to the start of the provided node. */ - moveAnchorToStartOfNode(node: Node): Editor; + moveAnchorToStartOfNode(node: Node): Commandable; /** * Move the anchor of the current selection to the start of the previous block. */ - moveAnchorToStartOfPreviousBlock(): Editor; + moveAnchorToStartOfPreviousBlock(): Commandable; /** * Move the anchor of the current selection to the start of the previous inline. */ - moveAnchorToStartOfPreviousInline(): Editor; + moveAnchorToStartOfPreviousInline(): Commandable; /** * Move the anchor of the current selection to the start of the previous text node. */ - moveAnchorToStartOfPreviousText(): Editor; + moveAnchorToStartOfPreviousText(): Commandable; /** * Move the anchor of the current selection to the start of the current text node. */ - moveAnchorToStartOfText(): Editor; + moveAnchorToStartOfText(): Commandable; /** * Move the end of the selection backward n characters */ - moveEndBackward(n?: number): Editor; + moveEndBackward(n?: number): Commandable; /** * Move the end of the selection foward n characters */ - moveEndForward(n?: number): Editor; + moveEndForward(n?: number): Commandable; /** * Move the end of the selection to a new path and offset */ - moveEndTo(path: Path, offset?: number): Editor; + moveEndTo(path: Path, offset?: number): Commandable; /** * Move the end of the current selection to the end of the closest block parent. */ - moveEndToEndOfBlock(): Editor; + moveEndToEndOfBlock(): Commandable; /** * Move the end of the current selection to the end of the document. */ - moveEndToEndOfDocument(): Editor; + moveEndToEndOfDocument(): Commandable; /** * Move the end of the current selection to the end of the closest inline parent. */ - moveEndToEndOfInline(): Editor; + moveEndToEndOfInline(): Commandable; /** * Move the anchor of the current selection to the end of the next block. */ - moveEndToEndOfNextBlock(): Editor; + moveEndToEndOfNextBlock(): Commandable; /** * Move the end of the current selection to the end of the next inline. */ - moveEndToEndOfNextInline(): Editor; + moveEndToEndOfNextInline(): Commandable; /** * Move the end of the current selection to the end of the next text. */ - moveEndToEndOfNextText(): Editor; + moveEndToEndOfNextText(): Commandable; /** * Move the end of the current selection to the end of the provided node. */ - moveEndToEndOfNode(node: Node): Editor; + moveEndToEndOfNode(node: Node): Commandable; /** * Move the end of the current selection to the end of the previous block. */ - moveEndToEndOfPreviousBlock(): Editor; + moveEndToEndOfPreviousBlock(): Commandable; /** * Move the end of the current selection to the end of the previous inline. */ - moveEndToEndOfPreviousInline(): Editor; + moveEndToEndOfPreviousInline(): Commandable; /** - * Move the editor of the current selection to the end of the previous text. + * Move the commandable of the current selection to the end of the previous text. */ - moveEndToEndOfPreviousText(): Editor; + moveEndToEndOfPreviousText(): Commandable; /** * Move the end of the current selection to the end of the current text node. */ - moveEndToEndOfText(): Editor; + moveEndToEndOfText(): Commandable; /** * Move the end of the current selection to the start of the closest block parent. */ - moveEndToStartOfBlock(): Editor; + moveEndToStartOfBlock(): Commandable; /** * Move the end of the current selection to the start of the document. */ - moveEndToStartOfDocument(): Editor; + moveEndToStartOfDocument(): Commandable; /** * Move the end of the current selection to the start of the closest inline parent. */ - moveEndToStartOfInline(): Editor; + moveEndToStartOfInline(): Commandable; /** * Move the end of the current selection to the start of the next block. */ - moveEndToStartOfNextBlock(): Editor; + moveEndToStartOfNextBlock(): Commandable; /** * Move the end of the current selection to the start of the next inline. */ - moveEndToStartOfNextInline(): Editor; + moveEndToStartOfNextInline(): Commandable; /** * Move the end of the current selection to the start of the next text node. */ - moveEndToStartOfNextText(): Editor; + moveEndToStartOfNextText(): Commandable; /** * Move the end of the current selection to the start of the provided node. */ - moveEndToStartOfNode(node: Node): Editor; + moveEndToStartOfNode(node: Node): Commandable; /** * Move the end of the current selection to the start of the previous block. */ - moveEndToStartOfPreviousBlock(): Editor; + moveEndToStartOfPreviousBlock(): Commandable; /** * Move the end of the current selection to the start of the previous inline. */ - moveEndToStartOfPreviousInline(): Editor; + moveEndToStartOfPreviousInline(): Commandable; /** * Move the end of the current selection to the start of the previous text node. */ - moveEndToStartOfPreviousText(): Editor; + moveEndToStartOfPreviousText(): Commandable; /** * Move the end of the current selection to the start of the current text node. */ - moveEndToStartOfText(): Editor; + moveEndToStartOfText(): Commandable; /** * Move the focus of the current selection backward n characters */ - moveFocusBackward(n?: number): Editor; + moveFocusBackward(n?: number): Commandable; /** * Move the focus of the current selection forward n characters */ - moveFocusForward(n?: number): Editor; + moveFocusForward(n?: number): Commandable; /** * Move the focus of the current selection to a new path and offset */ - moveFocusTo(path: Path, offset?: number): Editor; + moveFocusTo(path: Path, offset?: number): Commandable; /** * Move the focus of the current selection to the end of the closest block parent. */ - moveFocusToEndOfBlock(): Editor; + moveFocusToEndOfBlock(): Commandable; /** * Move the focus of the current selection to the end of the document. */ - moveFocusToEndOfDocument(): Editor; + moveFocusToEndOfDocument(): Commandable; /** * Move the focus of the current selection to the end of the closest inline parent. */ - moveFocusToEndOfInline(): Editor; + moveFocusToEndOfInline(): Commandable; /** * Move the focus of the current selection to the end of the next block. */ - moveFocusToEndOfNextBlock(): Editor; + moveFocusToEndOfNextBlock(): Commandable; /** * Move the focus of the current selection to the end of the next inline. */ - moveFocusToEndOfNextInline(): Editor; + moveFocusToEndOfNextInline(): Commandable; /** * Move the focus of the current selection to the end of the next text. */ - moveFocusToEndOfNextText(): Editor; + moveFocusToEndOfNextText(): Commandable; /** * Move the focus of the current selection to the end of the provided node. */ - moveFocusToEndOfNode(node: Node): Editor; + moveFocusToEndOfNode(node: Node): Commandable; /** * Move the focus of the current selection to the end of the previous block. */ - moveFocusToEndOfPreviousBlock(): Editor; + moveFocusToEndOfPreviousBlock(): Commandable; /** * Move the focus of the current selection to the end of the previous inline. */ - moveFocusToEndOfPreviousInline(): Editor; + moveFocusToEndOfPreviousInline(): Commandable; /** * Move the focus of the current selection to the end of the previous text. */ - moveFocusToEndOfPreviousText(): Editor; + moveFocusToEndOfPreviousText(): Commandable; /** * Move the focus of the current selection to the end of the current text node. */ - moveFocusToEndOfText(): Editor; + moveFocusToEndOfText(): Commandable; /** * Move the focus of the current selection to the start of the closest block parent. */ - moveFocusToStartOfBlock(): Editor; + moveFocusToStartOfBlock(): Commandable; /** * Move the focus of the current selection to the start of the document. */ - moveFocusToStartOfDocument(): Editor; + moveFocusToStartOfDocument(): Commandable; /** * Move the focus of the current selection to the start of the closest inline parent. */ - moveFocusToStartOfInline(): Editor; + moveFocusToStartOfInline(): Commandable; /** * Move the focus of the current selection to the start of the next block. */ - moveFocusToStartOfNextBlock(): Editor; + moveFocusToStartOfNextBlock(): Commandable; /** * Move the focus of the current selection to the start of the next inline. */ - moveFocusToStartOfNextInline(): Editor; + moveFocusToStartOfNextInline(): Commandable; /** * Move the focus of the current selection to the start of the next text node. */ - moveFocusToStartOfNextText(): Editor; + moveFocusToStartOfNextText(): Commandable; /** * Move the focus of the current selection to the start of the provided node. */ - moveFocusToStartOfNode(node: Node): Editor; + moveFocusToStartOfNode(node: Node): Commandable; /** * Move the focus of the current selection to the start of the previous block. */ - moveFocusToStartOfPreviousBlock(): Editor; + moveFocusToStartOfPreviousBlock(): Commandable; /** * Move the focus of the current selection to the start of the previous inline. */ - moveFocusToStartOfPreviousInline(): Editor; + moveFocusToStartOfPreviousInline(): Commandable; /** * Move the focus of the current selection to the start of the previous text node. */ - moveFocusToStartOfPreviousText(): Editor; + moveFocusToStartOfPreviousText(): Commandable; /** * Move the focus of the current selection to the start of the current text node. */ - moveFocusToStartOfText(): Editor; + moveFocusToStartOfText(): Commandable; /** * Move the start of the current selection backward n characters */ - moveStartForward(n?: number): Editor; + moveStartForward(n?: number): Commandable; /** * Move the start of the current selection forward n characters */ - moveStartBackward(n?: number): Editor; + moveStartBackward(n?: number): Commandable; /** * Move the start of the current selection to a new path and offset */ - moveStartTo(path: Path, n?: number): Editor; + moveStartTo(path: Path, n?: number): Commandable; /** * Move the start of the current selection to the end of the closest block parent. */ - moveStartToEndOfBlock(): Editor; + moveStartToEndOfBlock(): Commandable; /** * Move the start of the current selection to the end of the document. */ - moveStartToEndOfDocument(): Editor; + moveStartToEndOfDocument(): Commandable; /** * Move the start of the current selection to the end of the closest inline parent. */ - moveStartToEndOfInline(): Editor; + moveStartToEndOfInline(): Commandable; /** * Move the start of the current selection to the end of the next block. */ - moveStartToEndOfNextBlock(): Editor; + moveStartToEndOfNextBlock(): Commandable; /** * Move the start of the current selection to the end of the next inline. */ - moveStartToEndOfNextInline(): Editor; + moveStartToEndOfNextInline(): Commandable; /** * Move the start of the current selection to the end of the next text. */ - moveStartToEndOfNextText(): Editor; + moveStartToEndOfNextText(): Commandable; /** * Move the start of the current selection to the end of the provided node. */ - moveStartToEndOfNode(node: Node): Editor; + moveStartToEndOfNode(node: Node): Commandable; /** * Move the start of the current selection to the end of the previous block. */ - moveStartToEndOfPreviousBlock(): Editor; + moveStartToEndOfPreviousBlock(): Commandable; /** * Move the start of the current selection to the end of the previous inline. */ - moveStartToEndOfPreviousInline(): Editor; + moveStartToEndOfPreviousInline(): Commandable; /** * Move the start of the current selection to the end of the previous text. */ - moveStartToEndOfPreviousText(): Editor; + moveStartToEndOfPreviousText(): Commandable; /** * Move the start of the current selection to the end of the current text node. */ - moveStartToEndOfText(): Editor; + moveStartToEndOfText(): Commandable; /** * Move the start of the current selection to the start of the closest block parent. */ - moveStartToStartOfBlock(): Editor; + moveStartToStartOfBlock(): Commandable; /** * Move the start of the current selection to the start of the document. */ - moveStartToStartOfDocument(): Editor; + moveStartToStartOfDocument(): Commandable; /** * Move the start of the current selection to the start of the closest inline parent. */ - moveStartToStartOfInline(): Editor; + moveStartToStartOfInline(): Commandable; /** * Move the start of the current selection to the start of the next block. */ - moveStartToStartOfNextBlock(): Editor; + moveStartToStartOfNextBlock(): Commandable; /** * Move the start of the current selection to the start of the next inline. */ - moveStartToStartOfNextInline(): Editor; + moveStartToStartOfNextInline(): Commandable; /** * Move the start of the current selection to the start of the next text node. */ - moveStartToStartOfNextText(): Editor; + moveStartToStartOfNextText(): Commandable; /** * Move the start of the current selection to the start of the provided node. */ - moveStartToStartOfNode(node: Node): Editor; + moveStartToStartOfNode(node: Node): Commandable; /** * Move the start of the current selection to the start of the previous block. */ - moveStartToStartOfPreviousBlock(): Editor; + moveStartToStartOfPreviousBlock(): Commandable; /** * Move the start of the current selection to the start of the previous inline. */ - moveStartToStartOfPreviousInline(): Editor; + moveStartToStartOfPreviousInline(): Commandable; /** * Move the start of the current selection to the start of the previous text node. */ - moveStartToStartOfPreviousText(): Editor; + moveStartToStartOfPreviousText(): Commandable; /** * Move the start of the current selection to the start of the current text node. */ - moveStartToStartOfText(): Editor; + moveStartToStartOfText(): Commandable; /** * Move the anchor and focus of the selection backward n characters. */ - moveBackward(n?: number): Editor; + moveBackward(n?: number): Commandable; /** * Move the anchor and focus of the selection forward n characters. */ - moveForward(n?: number): Editor; + moveForward(n?: number): Commandable; /** * Collapse the current selection at the provided new path and offset. */ - moveTo(path: Path, offset?: number): Editor; + moveTo(path: Path, offset?: number): Commandable; /** * Collapse the current selection at the anchor. */ - moveToAnchor(): Editor; + moveToAnchor(): Commandable; /** * Collapse the current selection at the focus. */ - moveToFocus(): Editor; + moveToFocus(): Commandable; /** * Collapse the current selection at the start. */ - moveToStart(): Editor; + moveToStart(): Commandable; /** * Collapse the current selection at the end. */ - moveToEnd(): Editor; + moveToEnd(): Commandable; /** * Collapse the current selection at the end of the closest block parent. */ - moveToEndOfBlock(): Editor; + moveToEndOfBlock(): Commandable; /** * Collapse the current selection at the end of the document. */ - moveToEndOfDocument(): Editor; + moveToEndOfDocument(): Commandable; /** * Collapse the current selection at the end of the closest inline parent. */ - moveToEndOfInline(): Editor; + moveToEndOfInline(): Commandable; /** * Collapse the current selection at the end of the next block. */ - moveToEndOfNextBlock(): Editor; + moveToEndOfNextBlock(): Commandable; /** * Collapse the current selection at the end of the inline. */ - moveToEndOfNextInline(): Editor; + moveToEndOfNextInline(): Commandable; /** * Collapse the current selection at the end of the next text node. */ - moveToEndOfNextText(): Editor; + moveToEndOfNextText(): Commandable; /** * Collapse the current selection at the end of the provided node. */ - moveToEndOfNode(node: Node): Editor; + moveToEndOfNode(node: Node): Commandable; /** * Collapse the current selection at the end of the previous block. */ - moveToEndOfPreviousBlock(): Editor; + moveToEndOfPreviousBlock(): Commandable; /** * Collapse the current selection at the end of the previous inline. */ - moveToEndOfPreviousInline(): Editor; + moveToEndOfPreviousInline(): Commandable; /** * Collapse the current selection at the end of the previous text node. */ - moveToEndOfPreviousText(): Editor; + moveToEndOfPreviousText(): Commandable; /** * Collapse the current selection at the end of the current text node. */ - moveToEndOfText(): Editor; + moveToEndOfText(): Commandable; /** * Collapse the current selection at the start of the nearest block parent. */ - moveToStartOfBlock(): Editor; + moveToStartOfBlock(): Commandable; /** * Collapse the current selection at the start of the document. */ - moveToStartOfDocument(): Editor; + moveToStartOfDocument(): Commandable; /** * Collapse the current selection at the start of the nearest inline parent. */ - moveToStartOfInline(): Editor; + moveToStartOfInline(): Commandable; /** * Collapse the current selection at the start of the next block. */ - moveToStartOfNextBlock(): Editor; + moveToStartOfNextBlock(): Commandable; /** * Collapse the current selection at the start of the next inline. */ - moveToStartOfNextInline(): Editor; + moveToStartOfNextInline(): Commandable; /** * Collapse the current selection at the start of the next text node. */ - moveToStartOfNextText(): Editor; + moveToStartOfNextText(): Commandable; /** * Collapse the current selection at the start of the provided node. */ - moveToStartOfNode(node: Node): Editor; + moveToStartOfNode(node: Node): Commandable; /** * Collapse the current selection at the start of the previous block. */ - moveToStartOfPreviousBlock(): Editor; + moveToStartOfPreviousBlock(): Commandable; /** * Collapse the current selection at the start of the previous inline. */ - moveToStartOfPreviousInline(): Editor; + moveToStartOfPreviousInline(): Commandable; /** * Collapse the current selection at the start of the previous text node. */ - moveToStartOfPreviousText(): Editor; + moveToStartOfPreviousText(): Commandable; /** * Collapse the current selection at the start of the current text node. */ - moveToStartOfText(): Editor; + moveToStartOfText(): Commandable; /** * Move the current selection's anchor to the start of the document and its focus to the end of it, selecting everything. */ - moveToRangeOfDocument(): Editor; + moveToRangeOfDocument(): Commandable; /** * Move the current selection's anchor to the start of the provided node and its focus to the end of it. */ - moveToRangeOf(node: Node): Editor; + moveToRangeOf(node: Node): Commandable; /** * Merge the current selection with the provided properties */ - select(properties: Range | RangeProperties): Editor; + select(properties: Range | RangeProperties): Commandable; // Document Range Commands // @@ -1779,111 +2053,111 @@ export class Editor { * Add a mark to the characters in the range. * Passing a string as `mark` will implicitly create a mark with that `type` */ - addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Commandable; /** * Delete everything in the range */ - deleteAtRange(range: Range): Editor; + deleteAtRange(range: Range): Commandable; /** * Delete backward until the char boundary at a range */ - deleteCharBackwardAtRange(range: Range): Editor; + deleteCharBackwardAtRange(range: Range): Commandable; /** * Delete backward until the line boundary at a range */ - deleteLineBackwardAtRange(range: Range): Editor; + deleteLineBackwardAtRange(range: Range): Commandable; /** * Delete backward until the word boundary at a range */ - deleteWordBackwardAtRange(range: Range): Editor; + deleteWordBackwardAtRange(range: Range): Commandable; /** * Delete backward n characters at a range */ - deleteBackwardAtRange(range: Range, n: number): Editor; + deleteBackwardAtRange(range: Range, n: number): Commandable; /** * Delete forward until the char boundary at a range */ - deleteCharForwardAtRange(range: Range): Editor; + deleteCharForwardAtRange(range: Range): Commandable; /** * Delete forward until the line boundary at a range */ - deleteLineForwardAtRange(range: Range): Editor; + deleteLineForwardAtRange(range: Range): Commandable; /** * Delete forward until the word boundary at a range */ - deleteWordForwardAtRange(range: Range): Editor; + deleteWordForwardAtRange(range: Range): Commandable; /** * Delete forward n characters at a range */ - deleteForwardAtRange(range: Range, n: number): Editor; + deleteForwardAtRange(range: Range, n: number): Commandable; /** * Insert a block node at range, splitting text to make room if it is non-empty. * If the range is expanded, it will be deleted first. */ - insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Editor; + insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Commandable; /** * Insert a document fragment at a range, if the range is expanded, it will be deleted first. */ - insertFragmentAtRange(range: Range, fragment: Document): Editor; + insertFragmentAtRange(range: Range, fragment: Document): Commandable; /** * Insert a new inline at range, splitting text to make room if it is non-empty. * If the range is expanded, it will be deleted first. */ - insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Editor; + insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Commandable; /** * Insert text at range. If the range is expanded it will be deleted first */ - insertTextAtRange(range: Range, text: string): Editor; + insertTextAtRange(range: Range, text: string): Commandable; /** * Set the properties of the block nodes in a range. * Passing a string will set the nodes' type only */ - setBlocksAtRange(range: Range, properties: BlockProperties | string): Editor; + setBlocksAtRange(range: Range, properties: BlockProperties | string): Commandable; /** * Set the properties of the inline nodes in a range. * Passing a string will set the nodes' type only */ - setInlinesAtRange(range: Range, properties: InlineProperties | string): Editor; + setInlinesAtRange(range: Range, properties: InlineProperties | string): Commandable; /** * Split the block in a range by depth levels. If the range is expanded it will be deleted first. */ - splitBlockAtRange(range: Range, depth: number): Editor; + splitBlockAtRange(range: Range, depth: number): Commandable; /** * Split the inline in a range by depth levels. If the range is expanded it will be deleted first. */ - splitInlineAtRange(range: Range, depth: number): Editor; + splitInlineAtRange(range: Range, depth: number): Commandable; /** * Remove a mark from characters in the range. Passing a string will * implicitly create a mark of that type for deletion. */ - removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Commandable; /** * Add or remove a mark from characters in the range. Passing a string will * implicitly create a mark of that type for deletion. */ - toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Commandable; /** * Unwrap all block nodes in a range that match properties */ - unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Commandable; /** * Unwrap all inline nodes in a range that match properties */ - unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Commandable; /** * wrap all block nodes in a range with a new block node with the provided properties */ - wrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + wrapBlockAtRange(range: Range, properties: BlockProperties | string): Commandable; /** * wrap all inline nodes in a range with a new inline node with the provided properties */ - wrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapInlineAtRange(range: Range, properties: InlineProperties | string): Commandable; /** * Surround the text in a range with a prefix and suffix. If the suffix is ommitted, * the prefix will be used instead. */ - wrapTextAtRange(range: Range, prefix: string, suffix?: string): Editor; + wrapTextAtRange(range: Range, prefix: string, suffix?: string): Commandable; // Node commands // /** @@ -1894,7 +2168,7 @@ export class Editor { offset: number, length: number, mark: MarkProperties | Mark | string - ): Editor; + ): Commandable; /** * Add a mark to length characters starting at an offset in a node by path */ @@ -1903,23 +2177,23 @@ export class Editor { offset: number, length: number, mark: MarkProperties | Mark | string - ): Editor; + ): Commandable; /** * Insert a node at index inside a parent node by key */ - insertNodeByKey(key: string, index: number, node: Node): Editor; + insertNodeByKey(key: string, index: number, node: Node): Commandable; /** * Insert a node at index inside a parent node by apth */ - insertNodeByPath(path: Path, index: number, node: Node): Editor; + insertNodeByPath(path: Path, index: number, node: Node): Commandable; /** * Insert a document fragment at index inside a parent node by key */ - insertFragmentByKey(key: string, index: number, fragment: Document): Editor; + insertFragmentByKey(key: string, index: number, fragment: Document): Commandable; /** * Insert a document fragment at index inside a parent node by path */ - insertFragmentByPath(path: Path, index: number, fragment: Document): Editor; + insertFragmentByPath(path: Path, index: number, fragment: Document): Commandable; /** * Insert text at an offset in a text node by its key with optional marks */ @@ -1928,7 +2202,7 @@ export class Editor { offset: number, text: string, marks?: Immutable.Set | Mark[] - ): Editor; + ): Commandable; /** * Insert text at an offset in a text node by its path with optional marks */ @@ -1937,23 +2211,23 @@ export class Editor { offset: number, text: string, marks?: Immutable.Set | Mark[] - ): Editor; + ): Commandable; /** * Merge a node by its key with its previous sibling */ - mergeNodeByKey(key: string): Editor; + mergeNodeByKey(key: string): Commandable; /** * Merge a node by its path with its previous sibling */ - mergeNodeByPath(path: Path): Editor; + mergeNodeByPath(path: Path): Commandable; /** * Move a node by its key to a new parent node with with newkey at newindex */ - moveNodeByKey(key: string, newKey: string, newIndex: number): Editor; + moveNodeByKey(key: string, newKey: string, newIndex: number): Commandable; /** * Move a node by its path to a new parent node with with newpath at newindex */ - moveNodeByPath(path: Path, newPath: Path, newIndex: number): Editor; + moveNodeByPath(path: Path, newPath: Path, newIndex: number): Commandable; /** * Remove a mark from length characters starting at an offset in a node by key */ @@ -1962,7 +2236,7 @@ export class Editor { offset: number, length: number, mark: Mark | Mark | string - ): Editor; + ): Commandable; /** * Remove a mark from length characters starting at an offset in a node by path */ @@ -1971,31 +2245,31 @@ export class Editor { offset: number, length: number, mark: MarkProperties | Mark | string - ): Editor; + ): Commandable; /** * Remove a node from the document by its key */ - removeNodeByKey(key: string): Editor; + removeNodeByKey(key: string): Commandable; /** * Remove a node from the document by its path */ - removeNodeByPath(path: Path): Editor; + removeNodeByPath(path: Path): Commandable; /** * Replace a node in the document with a new node by key */ - replaceNodeByKey(key: string, node: Node): Editor; + replaceNodeByKey(key: string, node: Node): Commandable; /** * Replace a node in the document with a new node by path */ - replaceNodeByPath(path: Path, newNode: Node): Editor; + replaceNodeByPath(path: Path, newNode: Node): Commandable; /** * Remove length characters of text starting at an offset in a node by key */ - removeTextByKey(key: string, offset: number, length: number): Editor; + removeTextByKey(key: string, offset: number, length: number): Commandable; /** * Remove length characters of text starting at an offset in a node by path */ - removeTextByPath(path: Path, offset: number, length: number): Editor; + removeTextByPath(path: Path, offset: number, length: number): Commandable; /** * Set a dictionary of properties on a mark by its key. */ @@ -2005,7 +2279,7 @@ export class Editor { length: number, mark: Mark, properties: MarkProperties - ): Editor; + ): Commandable; /** * Set a dictionary of properties on a mark by its path. */ @@ -2015,111 +2289,111 @@ export class Editor { length: number, mark: Mark, properties: MarkProperties - ): Editor; + ): Commandable; /** * Set a dictionary of properties on a node by its key. */ - setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Editor; + setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Commandable; /** * Set a dictionary of properties on a node by its key. */ - setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Editor; + setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Commandable; /** * Split a node by its key at an offset */ - splitNodeByKey(key: string, offset: number): Editor; + splitNodeByKey(key: string, offset: number): Commandable; /** * Split a node by its path at an offset */ - splitNodeByPath(path: Path, position: number): Editor; + splitNodeByPath(path: Path, position: number): Commandable; /** * Unwrap all inner content of an inline node by its key that match properties */ - unwrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + unwrapInlineByKey(key: string, properties: InlineProperties | string): Commandable; /** * Unwrap all inner content of an inline node by its path that match properties */ - unwrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + unwrapInlineByPath(path: Path, properties: InlineProperties | string): Commandable; /** * Unwrap all inner content of a block node by its key that match properties */ - unwrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + unwrapBlockByKey(key: string, properties: BlockProperties | string): Commandable; /** * Unwrap all inner content of a block node by its path that match properties */ - unwrapBlockByPath(path: Path, properties: BlockProperties | string): Editor; + unwrapBlockByPath(path: Path, properties: BlockProperties | string): Commandable; /** * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split. * If the node is an only child, it will replace the parent */ - unwrapNodeByKey(key: string): Editor; + unwrapNodeByKey(key: string): Commandable; /** * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split. * If the node is an only child, it will replace the parent */ - unwrapNodeByPath(path: Path): Editor; + unwrapNodeByPath(path: Path): Commandable; /** * Wrap the given node by key in an Inline node that matches properties. */ - wrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + wrapInlineByKey(key: string, properties: InlineProperties | string): Commandable; /** * Wrap the given node by path in an Inline node that matches properties. */ - wrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + wrapInlineByPath(path: Path, properties: InlineProperties | string): Commandable; /** * Wrap the given node by key in a block node that matches properties. */ - wrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + wrapBlockByKey(key: string, properties: BlockProperties | string): Commandable; /** * Wrap the given node by path in a block node that matches properties. */ - wrapBlockByPath(path: Path, block: Block | string): Editor; + wrapBlockByPath(path: Path, block: Block | string): Commandable; /** * Wrap the node with the specified key with the parent node, this will clear all children of the parent. */ - wrapNodeByKey(key: string, parent: Node): Editor; + wrapNodeByKey(key: string, parent: Node): Commandable; /** * Wrap the node with the specified key with the parent node, this will clear all children of the parent. */ - wrapNodeByPath(path: Path, parent: Node): Editor; + wrapNodeByPath(path: Path, parent: Node): Commandable; // Miscellaneous Commands // /** * Normalizes the document with the value's schema. Run automatically unless manually disabled. * Use it sparingly and strategically, as it can be very expensive. */ - normalize(): Editor; + normalize(): Commandable; /** - * Calls the provided function with the current editor as the first argument. + * Calls the provided function with the current commandable as the first argument. * Normalization does not occur while the function is executing and is deferred to execute immediately after completion. * * This allows for sequence change operations to not be interrupted by normalization */ - withoutNormalizing(fn: () => void): Editor; + withoutNormalizing(fn: () => void): Commandable; /** - * By default all operations are saved to the editor's history. If you have + * By default all operations are saved to the commandable's history. If you have * changes that you don't want to show up in history, use this function. */ - withoutSaving(fn: () => void): Editor; + withoutSaving(fn: () => void): Commandable; /** * Usually all command operations are merged into a single save point in history, * if more control is desired, create single save points using this function. */ - withoutMerging(fn: () => void): Editor; + withoutMerging(fn: () => void): Commandable; // History Commands // /** * Move forward one step in the history */ - redo(): Editor; + redo(): Commandable; /** * Move backward one step in the history */ - undo(): Editor; + undo(): Commandable; /** * Snapshot the current selection for undo purposes. */ - snapshotSelection(): Editor; + snapshotSelection(): Commandable; } export {}; From 6339f36f6cab235f9490738fa6f38705214dc23e Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Wed, 14 Nov 2018 16:15:53 +0000 Subject: [PATCH 43/80] Re-Add missing methods --- types/slate-react/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 31e0766172..754b070f4b 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -136,6 +136,11 @@ export class Editor extends React.Component implements readonly readOnly: boolean; readonly value: Value; + // Instance methods + blur(): void; + focus(): void; + resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; + // Commandable applyOperation(operation: Operation): Editor; flush(): Editor; From 04a754692fbba78ac72ea6eb12d71b4ede9d199a Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Wed, 14 Nov 2018 16:18:01 +0000 Subject: [PATCH 44/80] Remove redundant methods --- types/slate-react/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 754b070f4b..bfb74b7a72 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -137,8 +137,6 @@ export class Editor extends React.Component implements readonly value: Value; // Instance methods - blur(): void; - focus(): void; resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; // Commandable From 1037be5f8b6087971c543c4c3390bc1b082539d8 Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Wed, 14 Nov 2018 17:12:17 +0000 Subject: [PATCH 45/80] Feedback --- types/slate-react/index.d.ts | 38 +-- types/slate/index.d.ts | 504 ++++++++++++++++++----------------- 2 files changed, 275 insertions(+), 267 deletions(-) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index bfb74b7a72..5f55b21041 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -12,7 +12,7 @@ // TypeScript Version: 2.8 import { Document, - Editor as Controller, + Editor as EditorController, Mark, Node, Block, @@ -28,8 +28,8 @@ import { Path, RangeProperties, NodeProperties, - Commandable, - Range + Range, + Controller } from "slate"; import * as Immutable from "immutable"; import * as React from "react"; @@ -42,7 +42,7 @@ export interface RenderAttributes { export interface RenderMarkProps { attributes: RenderAttributes; children: React.ReactNode; - editor: Controller; + editor: EditorController; mark: Mark; marks: Immutable.Set; node: Node; @@ -53,7 +53,7 @@ export interface RenderMarkProps { export interface RenderNodeProps { attributes: RenderAttributes; children: React.ReactNode; - editor: Controller; + editor: EditorController; isFocused: boolean; isSelected: boolean; key: string; @@ -63,23 +63,23 @@ export interface RenderNodeProps { } export interface RenderPlaceholderProps { - editor: Controller; + editor: EditorController; readOnly: boolean; } export type EventHook = ( event: Event, - editor: Controller, + editor: EditorController, next: () => any ) => any; export interface Plugin { - decorateNode?: (node: Node, editor: Controller, next: () => any) => any; - renderEditor?: (props: EditorProps, editor: Controller, next: () => any) => any; - renderMark?: (props: RenderMarkProps, editor: Controller, next: () => any) => any; - renderNode?: (props: RenderNodeProps, editor: Controller, next: () => any) => any; - renderPlaceholder?: (props: RenderPlaceholderProps, editor: Controller, next: () => any) => any; - shouldNodeComponentUpdate?: (previousProps: RenderNodeProps, props: RenderNodeProps, editor: Controller, next: () => any) => any; + decorateNode?: (node: Node, editor: EditorController, next: () => any) => any; + renderEditor?: (props: EditorProps, editor: EditorController, next: () => any) => any; + renderMark?: (props: RenderMarkProps, editor: EditorController, next: () => any) => any; + renderNode?: (props: RenderNodeProps, editor: EditorController, next: () => any) => any; + renderPlaceholder?: (props: RenderPlaceholderProps, editor: EditorController, next: () => any) => any; + shouldNodeComponentUpdate?: (previousProps: RenderNodeProps, props: RenderNodeProps, editor: EditorController, next: () => any) => any; onBeforeInput?: EventHook; onBlur?: EventHook; @@ -126,8 +126,8 @@ export interface EditorState { stack: Stack; } -export class Editor extends React.Component implements Commandable { - controller: Controller; +export class Editor extends React.Component implements Controller { + controller: EditorController; schema: Schema; stack: Stack; @@ -139,7 +139,7 @@ export class Editor extends React.Component implements // Instance methods resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; - // Commandable + // Controller applyOperation(operation: Operation): Editor; flush(): Editor; command(name: string, ...args: any[]): void; @@ -420,6 +420,12 @@ export class Editor extends React.Component implements redo(): Editor; undo(): Editor; snapshotSelection(): Editor; + command(name: string, ...args: any[]): Editor; + query(query: string, ...args: any[]): Editor; + registerCommand(command: string): Editor; + registerQuery(query: string): Editor; + applyOperation(operation: Operation): Editor; + run(key: string, ...args: any[]): Editor; } export type SlateType = diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 2d61a6d074..a8ed67d541 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -1054,7 +1054,7 @@ export interface EditorProperties { value?: Value; } -export class Editor implements Commandable { +export class Editor implements Controller { object: "editor"; onChange: (change: { operations: Immutable.List, value: Value }) => void; plugins: any[]; @@ -1062,35 +1062,12 @@ export class Editor implements Commandable { value: Value; constructor(attributes: EditorProperties) - /** - * Apply an `operation` to the Editor, updating its value. - */ - applyOperation(operation: Operation): Editor; - /** * Synchronously flush the current changes to editor, calling onChange. * In normal operation you never need to use this method! Reserved for testing. */ flush(): Editor; - command(name: string, ...args: any[]): void; - query(query: string, ...args: any[]): any; - - /** - * Add a new command by type with the editor. This will make the command available as a top-level method on the editor - */ - registerCommand(command: string): void; - - /** - * Add a new query by type with the editor. This will make the query available as a top-level method on the editor. - */ - registerQuery(query: string): void; - - /** - * Run the middleware stack by key with args, returning its result. - * In normal operation you never need to use this method! Reserved for testing. - */ - run(key: string, ...args: any[]): any; setReadOnly(readOnly: boolean): Editor; /** @@ -1372,83 +1349,89 @@ export class Editor implements Commandable { redo(): Editor; undo(): Editor; snapshotSelection(): Editor; + command(name: string, ...args: any[]): Editor; + query(query: string, ...args: any[]): Editor; + registerCommand(command: string): Editor; + registerQuery(query: string): Editor; + applyOperation(operation: Operation): Editor; + run(key: string, ...args: any[]): Editor; } -export interface Commandable { +export interface Controller { // Current Selection Commands // /** * Add a mark to the characters in the current selection */ - addMark(mark: Mark | MarkProperties | string): Commandable; + addMark(mark: Mark | MarkProperties | string): Controller; /** * Delete everything in the current selection. */ - delete(): Commandable; + delete(): Controller; /** * Delete backward n characters at the current cursor. * If the selection is expanded, behaviour is equivalent to delete() */ - deleteBackward(n: number): Commandable; + deleteBackward(n: number): Controller; /** * Delete backward n characters at the current cursor. * If the selection is expanded, behaviour is equivalent to delete() */ - deleteForward(n: number): Commandable; + deleteForward(n: number): Controller; /** * Insert a new block at the same level as the current block, splitting the current block to make room if it is non-empty. * If the selection is expanded, it will be deleted first. */ - insertBlock(block: Block | BlockProperties | string): Commandable; + insertBlock(block: Block | BlockProperties | string): Controller; /** * Insert a document fragment at the current selection. If the selection is expanded, it will be deleted first. */ - insertFragment(fragment: Document): Commandable; + insertFragment(fragment: Document): Controller; /** * Insert a new inline at the current cursor position, splitting the text to make room if it is non-empty. * If the selection is expanded, it will be deleted first. */ - insertInline(inline: Inline | InlineProperties): Commandable; + insertInline(inline: Inline | InlineProperties): Controller; /** * Insert a string of text at the current selection. If the selection is expanded, it will be deleted first */ - insertText(text: string): Commandable; + insertText(text: string): Controller; /** * Set the properties of the Blocks in the current selection. * Passing a string will set the blocks' type only. */ - setBlocks(properties: BlockProperties | string): Commandable; + setBlocks(properties: BlockProperties | string): Controller; /** * Set the properties of the Inlines nodes in the current selection. * Passing a string will set the nodes' type only. */ - setInlines(properties: InlineProperties | string): Commandable; + setInlines(properties: InlineProperties | string): Controller; /** * Split the Block in the current selection by depth levels. * If the selection is expanded, it will be deleted first. */ - splitBlock(depth: number): Commandable; + splitBlock(depth: number): Controller; /** * Split the Inline node in the current selection by depth levels. * If the selection is expanded, it will be deleted first */ - splitInline(depth: number): Commandable; + splitInline(depth: number): Controller; /** * Remove a mark from the characters in the current selection. * Passing a string will implicitly create a Mark of that type for removal. */ - removeMark(mark: Mark | MarkProperties | string): Commandable; + removeMark(mark: Mark | MarkProperties | string): Controller; /** * Remove a mark from the characters in the current selection. @@ -1457,595 +1440,595 @@ export interface Commandable { replaceMark( mark: Mark | MarkProperties | string, newMark: Mark | MarkProperties | string - ): Commandable; + ): Controller; /** * Add or remove a mark from the characters in the current selection, depending on it already exists on any or not. * Passing a string will implicitly create a Mark of that type to toggle. */ - toggleMark(mark: Mark | MarkProperties | string): Commandable; + toggleMark(mark: Mark | MarkProperties | string): Controller; /** * Unwrap all Block nodes in the current selection that match a type and/or data */ - unwrapBlock(properties: BlockProperties | string): Commandable; + unwrapBlock(properties: BlockProperties | string): Controller; /** * Unwrap all Inline nodes in the current selection that match a type and/or data */ - unwrapInline(properties: InlineProperties | string): Commandable; + unwrapInline(properties: InlineProperties | string): Controller; /** * Wrap the Block nodes in the current selection with a new Block */ - wrapBlock(properties: BlockProperties | string): Commandable; + wrapBlock(properties: BlockProperties | string): Controller; /** * Wrap the Block nodes in the current selection with a new Inline */ - wrapInline(properties: InlineProperties | string): Commandable; + wrapInline(properties: InlineProperties | string): Controller; /** * Surround the text in the current selection with prefix and suffix strings. * If the suffix is ommitted, the prefix will be used instead. */ - wrapText(prefix: string, suffix?: string): Commandable; + wrapText(prefix: string, suffix?: string): Controller; // Selection Commands // /** * Blur the current selection */ - blur(): Commandable; + blur(): Controller; /** * Unset the selection */ - deselect(): Commandable; + deselect(): Controller; /** * Flip the selection */ - flip(): Commandable; + flip(): Controller; /** * Focus the current selection */ - focus(): Commandable; + focus(): Controller; /** * Move the anchor of the current selection backward n characters */ - moveAnchorBackward(n?: number): Commandable; + moveAnchorBackward(n?: number): Controller; /** * Move the anchor of the current selection forward n characters */ - moveAnchorForward(n?: number): Commandable; + moveAnchorForward(n?: number): Controller; /** * Move the anchor of the current selection to a new path and offset */ - moveAnchorTo(path: Path, offset?: number): Commandable; + moveAnchorTo(path: Path, offset?: number): Controller; /** * Move the anchor of the current selection to the end of the closest block parent. */ - moveAnchorToEndOfBlock(): Commandable; + moveAnchorToEndOfBlock(): Controller; /** * Move the anchor of the current selection to the end of the closest inline parent. */ - moveAnchorToEndOfInline(): Commandable; + moveAnchorToEndOfInline(): Controller; /** * Move the anchor of the current selection to the end of the document. */ - moveAnchorToEndOfDocument(): Commandable; + moveAnchorToEndOfDocument(): Controller; /** * Move the anchor of the current selection to the end of the next block. */ - moveAnchorToEndOfNextBlock(): Commandable; + moveAnchorToEndOfNextBlock(): Controller; /** * Move the anchor of the current selection to the end of the next inline. */ - moveAnchorToEndOfNextInline(): Commandable; + moveAnchorToEndOfNextInline(): Controller; /** * Move the anchor of the current selection to the end of the next text. */ - moveAnchorToEndOfNextText(): Commandable; + moveAnchorToEndOfNextText(): Controller; /** * Move the anchor of the current selection to the end of the provided node. */ - moveAnchorEndOfNode(node: Node): Commandable; + moveAnchorEndOfNode(node: Node): Controller; /** * Move the anchor of the current selection to the end of the previous block. */ - moveAnchorToEndOfPreviousBlock(): Commandable; + moveAnchorToEndOfPreviousBlock(): Controller; /** * Move the anchor of the current selection to the end of the previous inline. */ - moveAnchorToEndOfPreviousInline(): Commandable; + moveAnchorToEndOfPreviousInline(): Controller; /** * Move the anchor of the current selection to the end of the previous text. */ - moveAnchorToEndOfPreviousText(): Commandable; + moveAnchorToEndOfPreviousText(): Controller; /** * Move the anchor of the current selection to the end of the current text node. */ - moveAnchorToEndOfText(): Commandable; + moveAnchorToEndOfText(): Controller; /** * Move the anchor of the current selection to the start of the closest block parent. */ - moveAnchorToStartOfBlock(): Commandable; + moveAnchorToStartOfBlock(): Controller; /** * Move the anchor of the current selection to the start of the document. */ - moveAnchorToStartOfDocument(): Commandable; + moveAnchorToStartOfDocument(): Controller; /** * Move the anchor of the current selection to the start of the closest inline parent. */ - moveAnchorToStartOfInline(): Commandable; + moveAnchorToStartOfInline(): Controller; /** * Move the anchor of the current selection to the start of the next block. */ - moveAnchorToStartOfNextBlock(): Commandable; + moveAnchorToStartOfNextBlock(): Controller; /** * Move the anchor of the current selection to the start of the next inline. */ - moveAnchorToStartOfNextInline(): Commandable; + moveAnchorToStartOfNextInline(): Controller; /** * Move the anchor of the current selection to the start of the next text node. */ - moveAnchorToStartOfNextText(): Commandable; + moveAnchorToStartOfNextText(): Controller; /** * Move the anchor of the current selection to the start of the provided node. */ - moveAnchorToStartOfNode(node: Node): Commandable; + moveAnchorToStartOfNode(node: Node): Controller; /** * Move the anchor of the current selection to the start of the previous block. */ - moveAnchorToStartOfPreviousBlock(): Commandable; + moveAnchorToStartOfPreviousBlock(): Controller; /** * Move the anchor of the current selection to the start of the previous inline. */ - moveAnchorToStartOfPreviousInline(): Commandable; + moveAnchorToStartOfPreviousInline(): Controller; /** * Move the anchor of the current selection to the start of the previous text node. */ - moveAnchorToStartOfPreviousText(): Commandable; + moveAnchorToStartOfPreviousText(): Controller; /** * Move the anchor of the current selection to the start of the current text node. */ - moveAnchorToStartOfText(): Commandable; + moveAnchorToStartOfText(): Controller; /** * Move the end of the selection backward n characters */ - moveEndBackward(n?: number): Commandable; + moveEndBackward(n?: number): Controller; /** * Move the end of the selection foward n characters */ - moveEndForward(n?: number): Commandable; + moveEndForward(n?: number): Controller; /** * Move the end of the selection to a new path and offset */ - moveEndTo(path: Path, offset?: number): Commandable; + moveEndTo(path: Path, offset?: number): Controller; /** * Move the end of the current selection to the end of the closest block parent. */ - moveEndToEndOfBlock(): Commandable; + moveEndToEndOfBlock(): Controller; /** * Move the end of the current selection to the end of the document. */ - moveEndToEndOfDocument(): Commandable; + moveEndToEndOfDocument(): Controller; /** * Move the end of the current selection to the end of the closest inline parent. */ - moveEndToEndOfInline(): Commandable; + moveEndToEndOfInline(): Controller; /** * Move the anchor of the current selection to the end of the next block. */ - moveEndToEndOfNextBlock(): Commandable; + moveEndToEndOfNextBlock(): Controller; /** * Move the end of the current selection to the end of the next inline. */ - moveEndToEndOfNextInline(): Commandable; + moveEndToEndOfNextInline(): Controller; /** * Move the end of the current selection to the end of the next text. */ - moveEndToEndOfNextText(): Commandable; + moveEndToEndOfNextText(): Controller; /** * Move the end of the current selection to the end of the provided node. */ - moveEndToEndOfNode(node: Node): Commandable; + moveEndToEndOfNode(node: Node): Controller; /** * Move the end of the current selection to the end of the previous block. */ - moveEndToEndOfPreviousBlock(): Commandable; + moveEndToEndOfPreviousBlock(): Controller; /** * Move the end of the current selection to the end of the previous inline. */ - moveEndToEndOfPreviousInline(): Commandable; + moveEndToEndOfPreviousInline(): Controller; /** * Move the commandable of the current selection to the end of the previous text. */ - moveEndToEndOfPreviousText(): Commandable; + moveEndToEndOfPreviousText(): Controller; /** * Move the end of the current selection to the end of the current text node. */ - moveEndToEndOfText(): Commandable; + moveEndToEndOfText(): Controller; /** * Move the end of the current selection to the start of the closest block parent. */ - moveEndToStartOfBlock(): Commandable; + moveEndToStartOfBlock(): Controller; /** * Move the end of the current selection to the start of the document. */ - moveEndToStartOfDocument(): Commandable; + moveEndToStartOfDocument(): Controller; /** * Move the end of the current selection to the start of the closest inline parent. */ - moveEndToStartOfInline(): Commandable; + moveEndToStartOfInline(): Controller; /** * Move the end of the current selection to the start of the next block. */ - moveEndToStartOfNextBlock(): Commandable; + moveEndToStartOfNextBlock(): Controller; /** * Move the end of the current selection to the start of the next inline. */ - moveEndToStartOfNextInline(): Commandable; + moveEndToStartOfNextInline(): Controller; /** * Move the end of the current selection to the start of the next text node. */ - moveEndToStartOfNextText(): Commandable; + moveEndToStartOfNextText(): Controller; /** * Move the end of the current selection to the start of the provided node. */ - moveEndToStartOfNode(node: Node): Commandable; + moveEndToStartOfNode(node: Node): Controller; /** * Move the end of the current selection to the start of the previous block. */ - moveEndToStartOfPreviousBlock(): Commandable; + moveEndToStartOfPreviousBlock(): Controller; /** * Move the end of the current selection to the start of the previous inline. */ - moveEndToStartOfPreviousInline(): Commandable; + moveEndToStartOfPreviousInline(): Controller; /** * Move the end of the current selection to the start of the previous text node. */ - moveEndToStartOfPreviousText(): Commandable; + moveEndToStartOfPreviousText(): Controller; /** * Move the end of the current selection to the start of the current text node. */ - moveEndToStartOfText(): Commandable; + moveEndToStartOfText(): Controller; /** * Move the focus of the current selection backward n characters */ - moveFocusBackward(n?: number): Commandable; + moveFocusBackward(n?: number): Controller; /** * Move the focus of the current selection forward n characters */ - moveFocusForward(n?: number): Commandable; + moveFocusForward(n?: number): Controller; /** * Move the focus of the current selection to a new path and offset */ - moveFocusTo(path: Path, offset?: number): Commandable; + moveFocusTo(path: Path, offset?: number): Controller; /** * Move the focus of the current selection to the end of the closest block parent. */ - moveFocusToEndOfBlock(): Commandable; + moveFocusToEndOfBlock(): Controller; /** * Move the focus of the current selection to the end of the document. */ - moveFocusToEndOfDocument(): Commandable; + moveFocusToEndOfDocument(): Controller; /** * Move the focus of the current selection to the end of the closest inline parent. */ - moveFocusToEndOfInline(): Commandable; + moveFocusToEndOfInline(): Controller; /** * Move the focus of the current selection to the end of the next block. */ - moveFocusToEndOfNextBlock(): Commandable; + moveFocusToEndOfNextBlock(): Controller; /** * Move the focus of the current selection to the end of the next inline. */ - moveFocusToEndOfNextInline(): Commandable; + moveFocusToEndOfNextInline(): Controller; /** * Move the focus of the current selection to the end of the next text. */ - moveFocusToEndOfNextText(): Commandable; + moveFocusToEndOfNextText(): Controller; /** * Move the focus of the current selection to the end of the provided node. */ - moveFocusToEndOfNode(node: Node): Commandable; + moveFocusToEndOfNode(node: Node): Controller; /** * Move the focus of the current selection to the end of the previous block. */ - moveFocusToEndOfPreviousBlock(): Commandable; + moveFocusToEndOfPreviousBlock(): Controller; /** * Move the focus of the current selection to the end of the previous inline. */ - moveFocusToEndOfPreviousInline(): Commandable; + moveFocusToEndOfPreviousInline(): Controller; /** * Move the focus of the current selection to the end of the previous text. */ - moveFocusToEndOfPreviousText(): Commandable; + moveFocusToEndOfPreviousText(): Controller; /** * Move the focus of the current selection to the end of the current text node. */ - moveFocusToEndOfText(): Commandable; + moveFocusToEndOfText(): Controller; /** * Move the focus of the current selection to the start of the closest block parent. */ - moveFocusToStartOfBlock(): Commandable; + moveFocusToStartOfBlock(): Controller; /** * Move the focus of the current selection to the start of the document. */ - moveFocusToStartOfDocument(): Commandable; + moveFocusToStartOfDocument(): Controller; /** * Move the focus of the current selection to the start of the closest inline parent. */ - moveFocusToStartOfInline(): Commandable; + moveFocusToStartOfInline(): Controller; /** * Move the focus of the current selection to the start of the next block. */ - moveFocusToStartOfNextBlock(): Commandable; + moveFocusToStartOfNextBlock(): Controller; /** * Move the focus of the current selection to the start of the next inline. */ - moveFocusToStartOfNextInline(): Commandable; + moveFocusToStartOfNextInline(): Controller; /** * Move the focus of the current selection to the start of the next text node. */ - moveFocusToStartOfNextText(): Commandable; + moveFocusToStartOfNextText(): Controller; /** * Move the focus of the current selection to the start of the provided node. */ - moveFocusToStartOfNode(node: Node): Commandable; + moveFocusToStartOfNode(node: Node): Controller; /** * Move the focus of the current selection to the start of the previous block. */ - moveFocusToStartOfPreviousBlock(): Commandable; + moveFocusToStartOfPreviousBlock(): Controller; /** * Move the focus of the current selection to the start of the previous inline. */ - moveFocusToStartOfPreviousInline(): Commandable; + moveFocusToStartOfPreviousInline(): Controller; /** * Move the focus of the current selection to the start of the previous text node. */ - moveFocusToStartOfPreviousText(): Commandable; + moveFocusToStartOfPreviousText(): Controller; /** * Move the focus of the current selection to the start of the current text node. */ - moveFocusToStartOfText(): Commandable; + moveFocusToStartOfText(): Controller; /** * Move the start of the current selection backward n characters */ - moveStartForward(n?: number): Commandable; + moveStartForward(n?: number): Controller; /** * Move the start of the current selection forward n characters */ - moveStartBackward(n?: number): Commandable; + moveStartBackward(n?: number): Controller; /** * Move the start of the current selection to a new path and offset */ - moveStartTo(path: Path, n?: number): Commandable; + moveStartTo(path: Path, n?: number): Controller; /** * Move the start of the current selection to the end of the closest block parent. */ - moveStartToEndOfBlock(): Commandable; + moveStartToEndOfBlock(): Controller; /** * Move the start of the current selection to the end of the document. */ - moveStartToEndOfDocument(): Commandable; + moveStartToEndOfDocument(): Controller; /** * Move the start of the current selection to the end of the closest inline parent. */ - moveStartToEndOfInline(): Commandable; + moveStartToEndOfInline(): Controller; /** * Move the start of the current selection to the end of the next block. */ - moveStartToEndOfNextBlock(): Commandable; + moveStartToEndOfNextBlock(): Controller; /** * Move the start of the current selection to the end of the next inline. */ - moveStartToEndOfNextInline(): Commandable; + moveStartToEndOfNextInline(): Controller; /** * Move the start of the current selection to the end of the next text. */ - moveStartToEndOfNextText(): Commandable; + moveStartToEndOfNextText(): Controller; /** * Move the start of the current selection to the end of the provided node. */ - moveStartToEndOfNode(node: Node): Commandable; + moveStartToEndOfNode(node: Node): Controller; /** * Move the start of the current selection to the end of the previous block. */ - moveStartToEndOfPreviousBlock(): Commandable; + moveStartToEndOfPreviousBlock(): Controller; /** * Move the start of the current selection to the end of the previous inline. */ - moveStartToEndOfPreviousInline(): Commandable; + moveStartToEndOfPreviousInline(): Controller; /** * Move the start of the current selection to the end of the previous text. */ - moveStartToEndOfPreviousText(): Commandable; + moveStartToEndOfPreviousText(): Controller; /** * Move the start of the current selection to the end of the current text node. */ - moveStartToEndOfText(): Commandable; + moveStartToEndOfText(): Controller; /** * Move the start of the current selection to the start of the closest block parent. */ - moveStartToStartOfBlock(): Commandable; + moveStartToStartOfBlock(): Controller; /** * Move the start of the current selection to the start of the document. */ - moveStartToStartOfDocument(): Commandable; + moveStartToStartOfDocument(): Controller; /** * Move the start of the current selection to the start of the closest inline parent. */ - moveStartToStartOfInline(): Commandable; + moveStartToStartOfInline(): Controller; /** * Move the start of the current selection to the start of the next block. */ - moveStartToStartOfNextBlock(): Commandable; + moveStartToStartOfNextBlock(): Controller; /** * Move the start of the current selection to the start of the next inline. */ - moveStartToStartOfNextInline(): Commandable; + moveStartToStartOfNextInline(): Controller; /** * Move the start of the current selection to the start of the next text node. */ - moveStartToStartOfNextText(): Commandable; + moveStartToStartOfNextText(): Controller; /** * Move the start of the current selection to the start of the provided node. */ - moveStartToStartOfNode(node: Node): Commandable; + moveStartToStartOfNode(node: Node): Controller; /** * Move the start of the current selection to the start of the previous block. */ - moveStartToStartOfPreviousBlock(): Commandable; + moveStartToStartOfPreviousBlock(): Controller; /** * Move the start of the current selection to the start of the previous inline. */ - moveStartToStartOfPreviousInline(): Commandable; + moveStartToStartOfPreviousInline(): Controller; /** * Move the start of the current selection to the start of the previous text node. */ - moveStartToStartOfPreviousText(): Commandable; + moveStartToStartOfPreviousText(): Controller; /** * Move the start of the current selection to the start of the current text node. */ - moveStartToStartOfText(): Commandable; + moveStartToStartOfText(): Controller; /** * Move the anchor and focus of the selection backward n characters. */ - moveBackward(n?: number): Commandable; + moveBackward(n?: number): Controller; /** * Move the anchor and focus of the selection forward n characters. */ - moveForward(n?: number): Commandable; + moveForward(n?: number): Controller; /** * Collapse the current selection at the provided new path and offset. */ - moveTo(path: Path, offset?: number): Commandable; + moveTo(path: Path, offset?: number): Controller; /** * Collapse the current selection at the anchor. */ - moveToAnchor(): Commandable; + moveToAnchor(): Controller; /** * Collapse the current selection at the focus. */ - moveToFocus(): Commandable; + moveToFocus(): Controller; /** * Collapse the current selection at the start. */ - moveToStart(): Commandable; + moveToStart(): Controller; /** * Collapse the current selection at the end. */ - moveToEnd(): Commandable; + moveToEnd(): Controller; /** * Collapse the current selection at the end of the closest block parent. */ - moveToEndOfBlock(): Commandable; + moveToEndOfBlock(): Controller; /** * Collapse the current selection at the end of the document. */ - moveToEndOfDocument(): Commandable; + moveToEndOfDocument(): Controller; /** * Collapse the current selection at the end of the closest inline parent. */ - moveToEndOfInline(): Commandable; + moveToEndOfInline(): Controller; /** * Collapse the current selection at the end of the next block. */ - moveToEndOfNextBlock(): Commandable; + moveToEndOfNextBlock(): Controller; /** * Collapse the current selection at the end of the inline. */ - moveToEndOfNextInline(): Commandable; + moveToEndOfNextInline(): Controller; /** * Collapse the current selection at the end of the next text node. */ - moveToEndOfNextText(): Commandable; + moveToEndOfNextText(): Controller; /** * Collapse the current selection at the end of the provided node. */ - moveToEndOfNode(node: Node): Commandable; + moveToEndOfNode(node: Node): Controller; /** * Collapse the current selection at the end of the previous block. */ - moveToEndOfPreviousBlock(): Commandable; + moveToEndOfPreviousBlock(): Controller; /** * Collapse the current selection at the end of the previous inline. */ - moveToEndOfPreviousInline(): Commandable; + moveToEndOfPreviousInline(): Controller; /** * Collapse the current selection at the end of the previous text node. */ - moveToEndOfPreviousText(): Commandable; + moveToEndOfPreviousText(): Controller; /** * Collapse the current selection at the end of the current text node. */ - moveToEndOfText(): Commandable; + moveToEndOfText(): Controller; /** * Collapse the current selection at the start of the nearest block parent. */ - moveToStartOfBlock(): Commandable; + moveToStartOfBlock(): Controller; /** * Collapse the current selection at the start of the document. */ - moveToStartOfDocument(): Commandable; + moveToStartOfDocument(): Controller; /** * Collapse the current selection at the start of the nearest inline parent. */ - moveToStartOfInline(): Commandable; + moveToStartOfInline(): Controller; /** * Collapse the current selection at the start of the next block. */ - moveToStartOfNextBlock(): Commandable; + moveToStartOfNextBlock(): Controller; /** * Collapse the current selection at the start of the next inline. */ - moveToStartOfNextInline(): Commandable; + moveToStartOfNextInline(): Controller; /** * Collapse the current selection at the start of the next text node. */ - moveToStartOfNextText(): Commandable; + moveToStartOfNextText(): Controller; /** * Collapse the current selection at the start of the provided node. */ - moveToStartOfNode(node: Node): Commandable; + moveToStartOfNode(node: Node): Controller; /** * Collapse the current selection at the start of the previous block. */ - moveToStartOfPreviousBlock(): Commandable; + moveToStartOfPreviousBlock(): Controller; /** * Collapse the current selection at the start of the previous inline. */ - moveToStartOfPreviousInline(): Commandable; + moveToStartOfPreviousInline(): Controller; /** * Collapse the current selection at the start of the previous text node. */ - moveToStartOfPreviousText(): Commandable; + moveToStartOfPreviousText(): Controller; /** * Collapse the current selection at the start of the current text node. */ - moveToStartOfText(): Commandable; + moveToStartOfText(): Controller; /** * Move the current selection's anchor to the start of the document and its focus to the end of it, selecting everything. */ - moveToRangeOfDocument(): Commandable; + moveToRangeOfDocument(): Controller; /** * Move the current selection's anchor to the start of the provided node and its focus to the end of it. */ - moveToRangeOf(node: Node): Commandable; + moveToRangeOf(node: Node): Controller; /** * Merge the current selection with the provided properties */ - select(properties: Range | RangeProperties): Commandable; + select(properties: Range | RangeProperties): Controller; // Document Range Commands // @@ -2053,111 +2036,111 @@ export interface Commandable { * Add a mark to the characters in the range. * Passing a string as `mark` will implicitly create a mark with that `type` */ - addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Commandable; + addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Controller; /** * Delete everything in the range */ - deleteAtRange(range: Range): Commandable; + deleteAtRange(range: Range): Controller; /** * Delete backward until the char boundary at a range */ - deleteCharBackwardAtRange(range: Range): Commandable; + deleteCharBackwardAtRange(range: Range): Controller; /** * Delete backward until the line boundary at a range */ - deleteLineBackwardAtRange(range: Range): Commandable; + deleteLineBackwardAtRange(range: Range): Controller; /** * Delete backward until the word boundary at a range */ - deleteWordBackwardAtRange(range: Range): Commandable; + deleteWordBackwardAtRange(range: Range): Controller; /** * Delete backward n characters at a range */ - deleteBackwardAtRange(range: Range, n: number): Commandable; + deleteBackwardAtRange(range: Range, n: number): Controller; /** * Delete forward until the char boundary at a range */ - deleteCharForwardAtRange(range: Range): Commandable; + deleteCharForwardAtRange(range: Range): Controller; /** * Delete forward until the line boundary at a range */ - deleteLineForwardAtRange(range: Range): Commandable; + deleteLineForwardAtRange(range: Range): Controller; /** * Delete forward until the word boundary at a range */ - deleteWordForwardAtRange(range: Range): Commandable; + deleteWordForwardAtRange(range: Range): Controller; /** * Delete forward n characters at a range */ - deleteForwardAtRange(range: Range, n: number): Commandable; + deleteForwardAtRange(range: Range, n: number): Controller; /** * Insert a block node at range, splitting text to make room if it is non-empty. * If the range is expanded, it will be deleted first. */ - insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Commandable; + insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Controller; /** * Insert a document fragment at a range, if the range is expanded, it will be deleted first. */ - insertFragmentAtRange(range: Range, fragment: Document): Commandable; + insertFragmentAtRange(range: Range, fragment: Document): Controller; /** * Insert a new inline at range, splitting text to make room if it is non-empty. * If the range is expanded, it will be deleted first. */ - insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Commandable; + insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Controller; /** * Insert text at range. If the range is expanded it will be deleted first */ - insertTextAtRange(range: Range, text: string): Commandable; + insertTextAtRange(range: Range, text: string): Controller; /** * Set the properties of the block nodes in a range. * Passing a string will set the nodes' type only */ - setBlocksAtRange(range: Range, properties: BlockProperties | string): Commandable; + setBlocksAtRange(range: Range, properties: BlockProperties | string): Controller; /** * Set the properties of the inline nodes in a range. * Passing a string will set the nodes' type only */ - setInlinesAtRange(range: Range, properties: InlineProperties | string): Commandable; + setInlinesAtRange(range: Range, properties: InlineProperties | string): Controller; /** * Split the block in a range by depth levels. If the range is expanded it will be deleted first. */ - splitBlockAtRange(range: Range, depth: number): Commandable; + splitBlockAtRange(range: Range, depth: number): Controller; /** * Split the inline in a range by depth levels. If the range is expanded it will be deleted first. */ - splitInlineAtRange(range: Range, depth: number): Commandable; + splitInlineAtRange(range: Range, depth: number): Controller; /** * Remove a mark from characters in the range. Passing a string will * implicitly create a mark of that type for deletion. */ - removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Commandable; + removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Controller; /** * Add or remove a mark from characters in the range. Passing a string will * implicitly create a mark of that type for deletion. */ - toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Commandable; + toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Controller; /** * Unwrap all block nodes in a range that match properties */ - unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Commandable; + unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Controller; /** * Unwrap all inline nodes in a range that match properties */ - unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Commandable; + unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Controller; /** * wrap all block nodes in a range with a new block node with the provided properties */ - wrapBlockAtRange(range: Range, properties: BlockProperties | string): Commandable; + wrapBlockAtRange(range: Range, properties: BlockProperties | string): Controller; /** * wrap all inline nodes in a range with a new inline node with the provided properties */ - wrapInlineAtRange(range: Range, properties: InlineProperties | string): Commandable; + wrapInlineAtRange(range: Range, properties: InlineProperties | string): Controller; /** * Surround the text in a range with a prefix and suffix. If the suffix is ommitted, * the prefix will be used instead. */ - wrapTextAtRange(range: Range, prefix: string, suffix?: string): Commandable; + wrapTextAtRange(range: Range, prefix: string, suffix?: string): Controller; // Node commands // /** @@ -2168,7 +2151,7 @@ export interface Commandable { offset: number, length: number, mark: MarkProperties | Mark | string - ): Commandable; + ): Controller; /** * Add a mark to length characters starting at an offset in a node by path */ @@ -2177,23 +2160,23 @@ export interface Commandable { offset: number, length: number, mark: MarkProperties | Mark | string - ): Commandable; + ): Controller; /** * Insert a node at index inside a parent node by key */ - insertNodeByKey(key: string, index: number, node: Node): Commandable; + insertNodeByKey(key: string, index: number, node: Node): Controller; /** * Insert a node at index inside a parent node by apth */ - insertNodeByPath(path: Path, index: number, node: Node): Commandable; + insertNodeByPath(path: Path, index: number, node: Node): Controller; /** * Insert a document fragment at index inside a parent node by key */ - insertFragmentByKey(key: string, index: number, fragment: Document): Commandable; + insertFragmentByKey(key: string, index: number, fragment: Document): Controller; /** * Insert a document fragment at index inside a parent node by path */ - insertFragmentByPath(path: Path, index: number, fragment: Document): Commandable; + insertFragmentByPath(path: Path, index: number, fragment: Document): Controller; /** * Insert text at an offset in a text node by its key with optional marks */ @@ -2202,7 +2185,7 @@ export interface Commandable { offset: number, text: string, marks?: Immutable.Set | Mark[] - ): Commandable; + ): Controller; /** * Insert text at an offset in a text node by its path with optional marks */ @@ -2211,23 +2194,23 @@ export interface Commandable { offset: number, text: string, marks?: Immutable.Set | Mark[] - ): Commandable; + ): Controller; /** * Merge a node by its key with its previous sibling */ - mergeNodeByKey(key: string): Commandable; + mergeNodeByKey(key: string): Controller; /** * Merge a node by its path with its previous sibling */ - mergeNodeByPath(path: Path): Commandable; + mergeNodeByPath(path: Path): Controller; /** * Move a node by its key to a new parent node with with newkey at newindex */ - moveNodeByKey(key: string, newKey: string, newIndex: number): Commandable; + moveNodeByKey(key: string, newKey: string, newIndex: number): Controller; /** * Move a node by its path to a new parent node with with newpath at newindex */ - moveNodeByPath(path: Path, newPath: Path, newIndex: number): Commandable; + moveNodeByPath(path: Path, newPath: Path, newIndex: number): Controller; /** * Remove a mark from length characters starting at an offset in a node by key */ @@ -2236,7 +2219,7 @@ export interface Commandable { offset: number, length: number, mark: Mark | Mark | string - ): Commandable; + ): Controller; /** * Remove a mark from length characters starting at an offset in a node by path */ @@ -2245,31 +2228,31 @@ export interface Commandable { offset: number, length: number, mark: MarkProperties | Mark | string - ): Commandable; + ): Controller; /** * Remove a node from the document by its key */ - removeNodeByKey(key: string): Commandable; + removeNodeByKey(key: string): Controller; /** * Remove a node from the document by its path */ - removeNodeByPath(path: Path): Commandable; + removeNodeByPath(path: Path): Controller; /** * Replace a node in the document with a new node by key */ - replaceNodeByKey(key: string, node: Node): Commandable; + replaceNodeByKey(key: string, node: Node): Controller; /** * Replace a node in the document with a new node by path */ - replaceNodeByPath(path: Path, newNode: Node): Commandable; + replaceNodeByPath(path: Path, newNode: Node): Controller; /** * Remove length characters of text starting at an offset in a node by key */ - removeTextByKey(key: string, offset: number, length: number): Commandable; + removeTextByKey(key: string, offset: number, length: number): Controller; /** * Remove length characters of text starting at an offset in a node by path */ - removeTextByPath(path: Path, offset: number, length: number): Commandable; + removeTextByPath(path: Path, offset: number, length: number): Controller; /** * Set a dictionary of properties on a mark by its key. */ @@ -2279,7 +2262,7 @@ export interface Commandable { length: number, mark: Mark, properties: MarkProperties - ): Commandable; + ): Controller; /** * Set a dictionary of properties on a mark by its path. */ @@ -2289,111 +2272,130 @@ export interface Commandable { length: number, mark: Mark, properties: MarkProperties - ): Commandable; + ): Controller; /** * Set a dictionary of properties on a node by its key. */ - setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Commandable; + setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Controller; /** * Set a dictionary of properties on a node by its key. */ - setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Commandable; + setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Controller; /** * Split a node by its key at an offset */ - splitNodeByKey(key: string, offset: number): Commandable; + splitNodeByKey(key: string, offset: number): Controller; /** * Split a node by its path at an offset */ - splitNodeByPath(path: Path, position: number): Commandable; + splitNodeByPath(path: Path, position: number): Controller; /** * Unwrap all inner content of an inline node by its key that match properties */ - unwrapInlineByKey(key: string, properties: InlineProperties | string): Commandable; + unwrapInlineByKey(key: string, properties: InlineProperties | string): Controller; /** * Unwrap all inner content of an inline node by its path that match properties */ - unwrapInlineByPath(path: Path, properties: InlineProperties | string): Commandable; + unwrapInlineByPath(path: Path, properties: InlineProperties | string): Controller; /** * Unwrap all inner content of a block node by its key that match properties */ - unwrapBlockByKey(key: string, properties: BlockProperties | string): Commandable; + unwrapBlockByKey(key: string, properties: BlockProperties | string): Controller; /** * Unwrap all inner content of a block node by its path that match properties */ - unwrapBlockByPath(path: Path, properties: BlockProperties | string): Commandable; + unwrapBlockByPath(path: Path, properties: BlockProperties | string): Controller; /** * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split. * If the node is an only child, it will replace the parent */ - unwrapNodeByKey(key: string): Commandable; + unwrapNodeByKey(key: string): Controller; /** * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split. * If the node is an only child, it will replace the parent */ - unwrapNodeByPath(path: Path): Commandable; + unwrapNodeByPath(path: Path): Controller; /** * Wrap the given node by key in an Inline node that matches properties. */ - wrapInlineByKey(key: string, properties: InlineProperties | string): Commandable; + wrapInlineByKey(key: string, properties: InlineProperties | string): Controller; /** * Wrap the given node by path in an Inline node that matches properties. */ - wrapInlineByPath(path: Path, properties: InlineProperties | string): Commandable; + wrapInlineByPath(path: Path, properties: InlineProperties | string): Controller; /** * Wrap the given node by key in a block node that matches properties. */ - wrapBlockByKey(key: string, properties: BlockProperties | string): Commandable; + wrapBlockByKey(key: string, properties: BlockProperties | string): Controller; /** * Wrap the given node by path in a block node that matches properties. */ - wrapBlockByPath(path: Path, block: Block | string): Commandable; + wrapBlockByPath(path: Path, block: Block | string): Controller; /** * Wrap the node with the specified key with the parent node, this will clear all children of the parent. */ - wrapNodeByKey(key: string, parent: Node): Commandable; + wrapNodeByKey(key: string, parent: Node): Controller; /** * Wrap the node with the specified key with the parent node, this will clear all children of the parent. */ - wrapNodeByPath(path: Path, parent: Node): Commandable; + wrapNodeByPath(path: Path, parent: Node): Controller; // Miscellaneous Commands // /** * Normalizes the document with the value's schema. Run automatically unless manually disabled. * Use it sparingly and strategically, as it can be very expensive. */ - normalize(): Commandable; + normalize(): Controller; /** * Calls the provided function with the current commandable as the first argument. * Normalization does not occur while the function is executing and is deferred to execute immediately after completion. * * This allows for sequence change operations to not be interrupted by normalization */ - withoutNormalizing(fn: () => void): Commandable; + withoutNormalizing(fn: () => void): Controller; /** * By default all operations are saved to the commandable's history. If you have * changes that you don't want to show up in history, use this function. */ - withoutSaving(fn: () => void): Commandable; + withoutSaving(fn: () => void): Controller; /** * Usually all command operations are merged into a single save point in history, * if more control is desired, create single save points using this function. */ - withoutMerging(fn: () => void): Commandable; + withoutMerging(fn: () => void): Controller; // History Commands // /** * Move forward one step in the history */ - redo(): Commandable; + redo(): Controller; /** * Move backward one step in the history */ - undo(): Commandable; + undo(): Controller; /** * Snapshot the current selection for undo purposes. */ - snapshotSelection(): Commandable; + snapshotSelection(): Controller; + command(name: string, ...args: any[]): Controller; + query(query: string, ...args: any[]): Controller; + /** + * Add a new command by type to the controller. This will make the command available as a top-level method on the controller + */ + registerCommand(command: string): Controller; + /** + * Add a new query by type to the controller. This will make the query available as a top-level method on the controller. + */ + registerQuery(query: string): Controller; + /** + * Apply an `operation` to the controller, updating its value. + */ + applyOperation(operation: Operation): Controller; + /** + * Run the middleware stack by key with args, returning its result. + * In normal operation you never need to use this method! Reserved for testing. + */ + run(key: string, ...args: any[]): Controller; } export {}; From bfc49319ae289b6d93d525a59c0622f045f31b01 Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Wed, 14 Nov 2018 17:16:19 +0000 Subject: [PATCH 46/80] fixes --- types/slate-react/index.d.ts | 9 --------- types/slate-react/slate-react-tests.tsx | 3 --- 2 files changed, 12 deletions(-) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 5f55b21041..6ff1237ad3 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -140,15 +140,6 @@ export class Editor extends React.Component implements resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; // Controller - applyOperation(operation: Operation): Editor; - flush(): Editor; - command(name: string, ...args: any[]): void; - query(query: string, ...args: any[]): any; - registerCommand(command: string): void; - registerQuery(query: string): void; - run(key: string, ...args: any[]): any; - setReadOnly(readOnly: boolean): Editor; - setValue(value: Value, options?: { normalize: boolean }): Editor; addMark(mark: Mark | MarkProperties | string): Editor; delete(): Editor; deleteBackward(n: number): Editor; diff --git a/types/slate-react/slate-react-tests.tsx b/types/slate-react/slate-react-tests.tsx index 851debf0f1..4f8f55b47b 100644 --- a/types/slate-react/slate-react-tests.tsx +++ b/types/slate-react/slate-react-tests.tsx @@ -76,7 +76,6 @@ editor .deleteWordForwardAtRange(range) .deselect() .flip() -.flush() .focus() .insertBlock({ type: "image", @@ -257,8 +256,6 @@ editor .setMarksByPath("a", 0, 1, mark, { type: "bold" }) .setNodeByKey("a", "paragraph") .setNodeByPath("a", "paragraph") -.setReadOnly(true) -.setValue(value) .snapshotSelection() .splitBlock(0) .splitBlockAtRange(range, 0) From 6541521ec996de5082b1a4b9b9d8a581bff93115 Mon Sep 17 00:00:00 2001 From: Mathieu Masy Date: Thu, 15 Nov 2018 00:03:49 -0500 Subject: [PATCH 47/80] Add recompose/toRenderProps & fromRenderProps --- types/recompose/index.d.ts | 23 ++++++++++++++ types/recompose/recompose-tests.tsx | 48 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/types/recompose/index.d.ts b/types/recompose/index.d.ts index 7a7bf3a411..4a430a7ef5 100644 --- a/types/recompose/index.d.ts +++ b/types/recompose/index.d.ts @@ -266,6 +266,17 @@ declare module 'recompose' { // toClass: https://github.com/acdlite/recompose/blob/master/docs/API.md#toClass export const toClass: InferableComponentEnhancer<{}>; + // toRenderProps: https://github.com/acdlite/recompose/blob/master/docs/API.md#torenderprops + export function toRenderProps( + hoc: InferableComponentEnhancerWithProps + ): StatelessComponent React.ReactElement }>; + + // fromRenderProps: https://github.com/acdlite/recompose/blob/master/docs/API.md#fromrenderprops + export function fromRenderProps( + RenderPropsComponent: StatelessComponent, + propsMapper: (props: TRenderProps) => Partial, + renderPropName?: string + ): ComponentEnhancer; // Static property helpers: https://github.com/acdlite/recompose/blob/master/docs/API.md#static-property-helpers @@ -587,6 +598,18 @@ declare module 'recompose/toClass' { export default toClass; } +// https://github.com/acdlite/recompose/blob/master/docs/API.md#torenderprops +declare module 'recompose/toRenderProps' { + import { toRenderProps } from 'recompose'; + export default toRenderProps; +} + +// https://github.com/acdlite/recompose/blob/master/docs/API.md#fromrenderprops +declare module 'recompose/fromRenderProps' { + import { fromRenderProps } from 'recompose'; + export default fromRenderProps; +} + // https://github.com/acdlite/recompose/blob/master/docs/API.md#setstatic declare module 'recompose/setStatic' { import { setStatic } from 'recompose'; diff --git a/types/recompose/recompose-tests.tsx b/types/recompose/recompose-tests.tsx index 4958f32e48..a0ba38a87a 100644 --- a/types/recompose/recompose-tests.tsx +++ b/types/recompose/recompose-tests.tsx @@ -7,7 +7,7 @@ import { withState, withReducer, branch, renderComponent, renderNothing, shouldUpdate, pure, onlyUpdateForKeys, onlyUpdateForPropTypes, withContext, getContext, - lifecycle, toClass, withStateHandlers, + lifecycle, toClass, toRenderProps, fromRenderProps, withStateHandlers, // Static property helpers setStatic, setPropTypes, setDisplayName, // Utilities @@ -51,6 +51,8 @@ import withContextStandalone from "recompose/withContext"; import getContextStandalone from "recompose/getContext"; import lifecycleStandalone from "recompose/lifecycle"; import toClassStandalone from "recompose/toClass"; +import toRenderPropsStandalone from "recompose/toRenderProps"; +import fromRenderPropsStandalone from "recompose/fromRenderProps"; import setStaticStandalone from "recompose/setStatic"; import setPropTypesStandalone from "recompose/setPropTypes"; import setDisplayNameStandalone from "recompose/setDisplayName"; @@ -496,3 +498,47 @@ function testSetDisplayName() { ClassResult = hoc(ClassComp); ClassResult = hoc(SfcComp); // $ExpectError } + +function testToRenderProps() { + interface OutterProps { + foo: number; + } + + interface InnerProps { + fooPlusOne: number; + } + + const enhance = withProps(({ foo }) => ({ fooPlusOne: foo + 1 })); + const Enhanced = toRenderProps(enhance); + + return {({ fooPlusOne }) =>

{fooPlusOne}

}; +} + +function testFromRenderProps() { + interface RenderProps { + value: string; + } + + interface InnerProps { + renderValue: string; + outterValue: number; + } + + interface OutterProps { + outterValue: number; + } + + const RenderPropComponent: React.StatelessComponent<{ + render: (renderProps: RenderProps) => React.ReactElement; + }> = ({ render }) => render({ value: 'test' }); + + const component: React.StatelessComponent = ({ renderValue }) =>
{renderValue}
; + + const Enhanced = fromRenderProps( + RenderPropComponent, + ({ value }) => ({ renderValue: value }), + 'render' + )(component); + + return ; +} From 71ad01c972a6fe35871462c61a2db14d5b078f9d Mon Sep 17 00:00:00 2001 From: Mathieu Masy Date: Thu, 15 Nov 2018 00:52:35 -0500 Subject: [PATCH 48/80] Update recompose@0.30 --- types/recompose/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/recompose/index.d.ts b/types/recompose/index.d.ts index 4a430a7ef5..d3ef2ab85b 100644 --- a/types/recompose/index.d.ts +++ b/types/recompose/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Recompose 0.27 +// Type definitions for Recompose 0.30 // Project: https://github.com/acdlite/recompose // Definitions by: Iskander Sierra // Samuel DeSota @@ -6,6 +6,7 @@ // Rasmus Eneman // Lucas Terra // Brian Adams +// Mathieu Masy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 From 127d343b5ab86710d034f68a889d4db03d2d67fb Mon Sep 17 00:00:00 2001 From: Kai-Uwe Humpert Date: Thu, 15 Nov 2018 10:10:17 +0100 Subject: [PATCH 49/80] Revert "Adjusting version number" This reverts commit d5e9fe1676aa903ce5cee7e40a4600261d906e28. Mistake in #26161. `karma-fixture` as of today is still `0.2.6`. The changes of #26161 are not related to a release of `karma-fixture`. --- types/karma-fixture/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/karma-fixture/index.d.ts b/types/karma-fixture/index.d.ts index 42af1d5d60..32614e1e7d 100644 --- a/types/karma-fixture/index.d.ts +++ b/types/karma-fixture/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for karma-fixture 0.2.7 +// Type definitions for karma-fixture 0.2.6 // Project: https://github.com/billtrik/karma-fixture // Definitions by: Ezekiel Victor // Afshawn Lotfi From a3fea312479b7bf034bd14b829b7cf6124c1e053 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Humpert Date: Thu, 15 Nov 2018 10:12:35 +0100 Subject: [PATCH 50/80] Revert " Fixed index.d.ts to be used as a module" This reverts commit ec2fbc378c821185cf88782f424c413a9ecc11c1. Reason: `karma-fixture` is NOT a module. It installs a the global `fixture` using `karma`'s framework. There is nothing that gets exported. Neither `import { fixture } from 'karma-fixture'` nor `import fixture from `karma-fixture` works at runtime, because e.g. `fixture.load` will simply be undefined. It is not only that the import does not work. Additionally, the global `fixture` is not declared anymore. The reason is, that the introduced `export` statements had converted the `index.d.ts` from "script" (aka defines some globals) into "module". From https://www.typescriptlang.org/docs/handbook/modules.html: > In TypeScript, just as in ECMAScript 2015, any file containing a > top-level import or export is considered a module. Conversely, a file > without any top-level import or export declarations is treated as a > script whose contents are available in the global scope (and therefore > to modules as well). Therefore, once you upgrade from `0.2.3` to `0.2.4`, typescript reports > 'fixture' refers to a UMD global, but the current file is a module. > Consider adding an import instead. But as stated above, an import does not work. --- types/karma-fixture/index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/types/karma-fixture/index.d.ts b/types/karma-fixture/index.d.ts index 32614e1e7d..75212799c1 100644 --- a/types/karma-fixture/index.d.ts +++ b/types/karma-fixture/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for karma-fixture 0.2.6 // Project: https://github.com/billtrik/karma-fixture // Definitions by: Ezekiel Victor -// Afshawn Lotfi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace fixture { @@ -26,6 +25,3 @@ declare namespace fixture { export function setBase(fixtureBasePath: string): void; } - -export = fixture; -export as namespace fixture; From d34455058b14b784c07406cca7d37af728403624 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Humpert Date: Thu, 15 Nov 2018 10:24:05 +0100 Subject: [PATCH 51/80] Do not revert list of authors --- types/karma-fixture/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/karma-fixture/index.d.ts b/types/karma-fixture/index.d.ts index 75212799c1..d89172b65f 100644 --- a/types/karma-fixture/index.d.ts +++ b/types/karma-fixture/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for karma-fixture 0.2.6 // Project: https://github.com/billtrik/karma-fixture // Definitions by: Ezekiel Victor +// Afshawn Lotfi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace fixture { From aa58604c7a94afab0c99a4c97fae9969b90ddfab Mon Sep 17 00:00:00 2001 From: Rafal Witczak Date: Thu, 15 Nov 2018 11:14:43 +0100 Subject: [PATCH 52/80] Fix privateKey/publicKey casing in ssh2-streams --- types/ssh2-streams/index.d.ts | 4 ++-- types/ssh2-streams/ssh2-streams-tests.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/types/ssh2-streams/index.d.ts b/types/ssh2-streams/index.d.ts index a7ff80243b..a780273591 100644 --- a/types/ssh2-streams/index.d.ts +++ b/types/ssh2-streams/index.d.ts @@ -659,8 +659,8 @@ export interface HostKeys { } export interface HostKey { - privatekey: ParsedKey; - publickey: ParsedKey; + privateKey: ParsedKey; + publicKey: ParsedKey; } /** diff --git a/types/ssh2-streams/ssh2-streams-tests.ts b/types/ssh2-streams/ssh2-streams-tests.ts index 7f140b4bbd..9ae121a454 100644 --- a/types/ssh2-streams/ssh2-streams-tests.ts +++ b/types/ssh2-streams/ssh2-streams-tests.ts @@ -2,16 +2,17 @@ import * as stream from "stream"; import * as ssh2 from "ssh2-streams"; declare const SERVER_KEY: string; -declare const HOST_KEYS: { 'ssh-rsa': ssh2.HostKey }; +declare const HOST_KEY: { publicKey: ssh2.ParsedKey; privateKey: ssh2.ParsedKey }; declare const clientBufStream: stream.Transform & { buffer: string; }; declare const serverBufStream: stream.Transform & { buffer: string; }; declare const parsedKey: ssh2.ParsedKey; declare const prompts: ssh2.Prompt[]; declare const buffer: Buffer; +const hostKeys = { 'ssh-rsa': HOST_KEY }; const algos = ['ssh-dss', 'ssh-rsa', 'ecdsa-sha2-nistp521']; const client = new ssh2.SSH2Stream({ algorithms: { serverHostKey: algos } }); -const server = new ssh2.SSH2Stream({ server: true, hostKeys: HOST_KEYS }); +const server = new ssh2.SSH2Stream({ server: true, hostKeys: hostKeys }); client .pipe(server) From 891bb6ce5daeb25ce03ce1088fc29cd284ec79df Mon Sep 17 00:00:00 2001 From: feinoujc Date: Thu, 15 Nov 2018 19:18:21 -0500 Subject: [PATCH 53/80] types for @pollyjs monorepo * @pollyjs/core * @pollyjs/utils * @pollyjs/adapter * @pollyjs/persister * @pollyjs/persister-fs * @pollyjs/adapter-fetch --- types/pollyjs__adapter-fetch/index.d.ts | 9 + .../pollyjs__adapter-fetch-tests.ts | 8 + types/pollyjs__adapter-fetch/tsconfig.json | 40 +++++ types/pollyjs__adapter-fetch/tslint.json | 1 + types/pollyjs__adapter/index.d.ts | 10 ++ .../pollyjs__adapter-tests.ts | 4 + types/pollyjs__adapter/tsconfig.json | 37 ++++ types/pollyjs__adapter/tslint.json | 1 + types/pollyjs__core/index.d.ts | 167 ++++++++++++++++++ types/pollyjs__core/pollyjs__core-tests.ts | 64 +++++++ types/pollyjs__core/tsconfig.json | 37 ++++ types/pollyjs__core/tslint.json | 1 + types/pollyjs__persister-fs/index.d.ts | 9 + .../pollyjs__persister-fs-tests.ts | 8 + types/pollyjs__persister-fs/tsconfig.json | 41 +++++ types/pollyjs__persister-fs/tslint.json | 1 + types/pollyjs__persister/index.d.ts | 10 ++ .../pollyjs__persister-tests.ts | 4 + types/pollyjs__persister/tsconfig.json | 31 ++++ types/pollyjs__persister/tslint.json | 1 + types/pollyjs__utils/index.d.ts | 12 ++ types/pollyjs__utils/pollyjs__utils-tests.ts | 6 + types/pollyjs__utils/tsconfig.json | 28 +++ types/pollyjs__utils/tslint.json | 1 + 24 files changed, 531 insertions(+) create mode 100644 types/pollyjs__adapter-fetch/index.d.ts create mode 100644 types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts create mode 100644 types/pollyjs__adapter-fetch/tsconfig.json create mode 100644 types/pollyjs__adapter-fetch/tslint.json create mode 100644 types/pollyjs__adapter/index.d.ts create mode 100644 types/pollyjs__adapter/pollyjs__adapter-tests.ts create mode 100644 types/pollyjs__adapter/tsconfig.json create mode 100644 types/pollyjs__adapter/tslint.json create mode 100644 types/pollyjs__core/index.d.ts create mode 100644 types/pollyjs__core/pollyjs__core-tests.ts create mode 100644 types/pollyjs__core/tsconfig.json create mode 100644 types/pollyjs__core/tslint.json create mode 100644 types/pollyjs__persister-fs/index.d.ts create mode 100644 types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts create mode 100644 types/pollyjs__persister-fs/tsconfig.json create mode 100644 types/pollyjs__persister-fs/tslint.json create mode 100644 types/pollyjs__persister/index.d.ts create mode 100644 types/pollyjs__persister/pollyjs__persister-tests.ts create mode 100644 types/pollyjs__persister/tsconfig.json create mode 100644 types/pollyjs__persister/tslint.json create mode 100644 types/pollyjs__utils/index.d.ts create mode 100644 types/pollyjs__utils/pollyjs__utils-tests.ts create mode 100644 types/pollyjs__utils/tsconfig.json create mode 100644 types/pollyjs__utils/tslint.json diff --git a/types/pollyjs__adapter-fetch/index.d.ts b/types/pollyjs__adapter-fetch/index.d.ts new file mode 100644 index 0000000000..3d93435d51 --- /dev/null +++ b/types/pollyjs__adapter-fetch/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for @pollyjs/adapter-fetch 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-fetch +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import Adapter from '@pollyjs/adapter'; + +export default class FetchAdapter extends Adapter {} diff --git a/types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts b/types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts new file mode 100644 index 0000000000..61b8ef734d --- /dev/null +++ b/types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts @@ -0,0 +1,8 @@ +import FetchAdapter from '@pollyjs/adapter-fetch'; +import { Polly } from '@pollyjs/core'; + +Polly.register(FetchAdapter); + +new Polly('', { + adapters: ['xhr', FetchAdapter] +}); diff --git a/types/pollyjs__adapter-fetch/tsconfig.json b/types/pollyjs__adapter-fetch/tsconfig.json new file mode 100644 index 0000000000..03d3076b3c --- /dev/null +++ b/types/pollyjs__adapter-fetch/tsconfig.json @@ -0,0 +1,40 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ], + "@pollyjs/adapter-fetch": [ + "pollyjs__adapter-fetch" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__adapter-fetch-tests.ts" + ] +} diff --git a/types/pollyjs__adapter-fetch/tslint.json b/types/pollyjs__adapter-fetch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__adapter-fetch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__adapter/index.d.ts b/types/pollyjs__adapter/index.d.ts new file mode 100644 index 0000000000..b3810a67bb --- /dev/null +++ b/types/pollyjs__adapter/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @pollyjs/adapter 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export default class Adapter { + static readonly name: string; + static readonly type: string; + connect(): void; + disconnect(): void; +} diff --git a/types/pollyjs__adapter/pollyjs__adapter-tests.ts b/types/pollyjs__adapter/pollyjs__adapter-tests.ts new file mode 100644 index 0000000000..1e5c82a586 --- /dev/null +++ b/types/pollyjs__adapter/pollyjs__adapter-tests.ts @@ -0,0 +1,4 @@ +import Adapter from '@pollyjs/adapter'; + +Adapter.name; +Adapter.type; diff --git a/types/pollyjs__adapter/tsconfig.json b/types/pollyjs__adapter/tsconfig.json new file mode 100644 index 0000000000..ad121d2d9d --- /dev/null +++ b/types/pollyjs__adapter/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__adapter-tests.ts" + ] +} diff --git a/types/pollyjs__adapter/tslint.json b/types/pollyjs__adapter/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__adapter/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__core/index.d.ts b/types/pollyjs__core/index.d.ts new file mode 100644 index 0000000000..83b6b933b9 --- /dev/null +++ b/types/pollyjs__core/index.d.ts @@ -0,0 +1,167 @@ +// Type definitions for @pollyjs/core 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/core +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { MODES } from '@pollyjs/utils'; +import Adapter from '@pollyjs/adapter'; +import Persister from '@pollyjs/persister'; + +export const Timing: { + fixed(ms: number): () => Promise; + relative(ratio: number): (ms: number) => Promise; +}; +export interface PollyConfig { + mode?: MODES; + + adapters?: Array; + adapterOptions?: any; + + persister?: string | typeof Persister; + persisterOptions?: { + keepUnusedRequests?: boolean; + [key: string]: any; + }; + + logging?: boolean; + + recordIfMissing?: boolean; + recordIfExpired?: boolean; + recordFailedRequests?: boolean; + + expiresIn?: string | null; + timing?: ((ms: number) => Promise) | (() => Promise); + + matchRequestsBy?: { + method?: boolean; + headers?: any; + body?: boolean; + order?: boolean; + + url?: { + protocol?: boolean; + username?: boolean; + password?: boolean; + hostname?: boolean; + port?: boolean; + pathname?: boolean; + query?: boolean; + hash?: boolean; + }; + }; +} +export interface Request { + getHeader(name: string): string | null; + setHeader(name: string, value: string): Request; + setHeaders(headers: any): Request; + hasHeader(name: string): boolean; + type(contentType: string): Request; + send(body: any): Request; + json(body: any): Request; + jsonBody(): any; + + method: string; + url: string; + protocol: string; + hostname: string; + port: string; + pathname: string; + hash: string; + headers: Record; + body: any; + query: any; + params: any; + recordingName: string; + responseTime?: number; +} +export interface Response { + statusCode?: number; + headers: Record; + body: any; + status(status: number): Response; + getHeader(name: string): string | null; + setHeader(name: string, value: string): Response; + setHeaders(headers: any): Response; + hasHeader(name: string): boolean; + type(contentType: string): Response; + send(body: any): Response; + sendStatus(status: number): Response; + json(body: any): Response; + jsonBody(): any; + end(): Readonly; +} +export interface Intercept { + abort(): void; + passthrough(): void; +} +export type RequestRouteEvent = 'request'; +export type RecordingRouteEvent = 'beforeReplay' | 'beforePersist'; +export type ResponseRouteEvent = 'beforeResponse' | 'response'; + +export type EventListenerResponse = any; +export type RequestEventListener = (req: Request) => EventListenerResponse; +export type RecordingEventListener = (req: Request, recording: any) => EventListenerResponse; +export type ResponseEventListener = (req: Request, res: Response) => EventListenerResponse; +export type InterceptHandler = ( + req: Request, + res: Response, + intercept: Intercept +) => EventListenerResponse; +export class RouteHandler { + on(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler; + on(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; + on(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; + off(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler; + off(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; + off(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; + once(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler; + once(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; + once(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; + + passthrough(value?: boolean): RouteHandler; + intercept( + fn: (req: Request, res: Response, intercept: Intercept) => EventListenerResponse + ): RouteHandler; + recordingName(recordingName: string): RouteHandler; + configure(config: PollyConfig): RouteHandler; +} +export class PollyServer { + timeout: (ms: number) => Promise; + get: (...args: any[]) => RouteHandler; + put: (...args: any[]) => RouteHandler; + post: (...args: any[]) => RouteHandler; + delete: (...args: any[]) => RouteHandler; + patch: (...args: any[]) => RouteHandler; + head: (...args: any[]) => RouteHandler; + options: (...args: any[]) => RouteHandler; + any: (...args: any[]) => RouteHandler; + host(host: string, callback: () => void): void; + namespace(path: string, callback: () => void): void; +} +export type PollyEvent = 'create' | 'stop' | 'register'; +export type PollyEventListener = (poll: Polly) => void; +export class Polly { + static register(Factory: typeof Adapter | typeof Persister): void; + static on(event: PollyEvent, listener: PollyEventListener): void; + static off(event: PollyEvent, listener: PollyEventListener): void; + static once(event: PollyEvent, listener: PollyEventListener): void; + + constructor(name: string, options?: PollyConfig); + + readonly recordingName: string | null; + mode: MODES; + server: PollyServer; + persister: Persister; + + pause: () => void; + play: () => void; + replay: () => void; + record: () => void; + stop: () => Promise; + flush: () => Promise; + configure(config: PollyConfig): void; + connectTo(name: string | typeof Adapter): void; + disconnectFrom(name: string | typeof Adapter): void; + disconnect(): void; +} diff --git a/types/pollyjs__core/pollyjs__core-tests.ts b/types/pollyjs__core/pollyjs__core-tests.ts new file mode 100644 index 0000000000..22f5516646 --- /dev/null +++ b/types/pollyjs__core/pollyjs__core-tests.ts @@ -0,0 +1,64 @@ +import { Polly, Timing } from '@pollyjs/core'; +import { MODES } from '@pollyjs/utils'; + +const polly = new Polly('test recording', { + mode: MODES.PASSTHROUGH, + recordFailedRequests: true, + adapters: ['xhr', 'fetch'], + persister: 'rest', + timing: Timing.relative(3) +}); + +function log(_: string) { + // no op +} + +async function test() { + polly.pause(); + polly.play(); + const { server } = polly; + server.get('/session').on('request', req => { + req.headers['X-AUTH'] = ''; + req.query.email = 'test@app.com'; + }); + server.get('/session').on('beforeResponse', (req, res) => { + res.setHeader('X-AUTH', ''); + }); + server.get('/session').on('response', (req, res) => { + log(`${req.url} took ${req.responseTime}ms with a status of ${res.statusCode}.`); + }); + + polly.configure({ + adapterOptions: { + fetch: { + context: null + } + } + }); + + server + .get('/session') + .once('request', req => { + req.headers['X-AUTH'] = ''; + req.query.email = 'test@app.com'; + }) + .once('request', () => { + /* Do something else */ + }); + + /* Intercept all Google Analytic requests and respond with a 200 */ + server.get('/google-analytics/*path').intercept((req, res, intercept) => { + if (req.pathname === 'test') { + intercept.abort(); + } else { + res.sendStatus(200); + } + }); + + /* Pass-through all GET requests to /coverage */ + server.get('/coverage') + .configure({ expiresIn: '5d' }) + .passthrough(); + + await polly.flush(); +} diff --git a/types/pollyjs__core/tsconfig.json b/types/pollyjs__core/tsconfig.json new file mode 100644 index 0000000000..4b91defc70 --- /dev/null +++ b/types/pollyjs__core/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__core-tests.ts" + ] +} diff --git a/types/pollyjs__core/tslint.json b/types/pollyjs__core/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__core/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__persister-fs/index.d.ts b/types/pollyjs__persister-fs/index.d.ts new file mode 100644 index 0000000000..3d97b382f7 --- /dev/null +++ b/types/pollyjs__persister-fs/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for @pollyjs/persister-fs 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/persister-fs +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import Persister from '@pollyjs/persister'; + +export default class FSPersister extends Persister {} diff --git a/types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts b/types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts new file mode 100644 index 0000000000..2d624a0f8d --- /dev/null +++ b/types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts @@ -0,0 +1,8 @@ +import FSPersister from '@pollyjs/persister-fs'; +import { Polly } from '@pollyjs/core'; + +Polly.register(FSPersister); + +new Polly('', { + persister: FSPersister +}); diff --git a/types/pollyjs__persister-fs/tsconfig.json b/types/pollyjs__persister-fs/tsconfig.json new file mode 100644 index 0000000000..7a7eb6733c --- /dev/null +++ b/types/pollyjs__persister-fs/tsconfig.json @@ -0,0 +1,41 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/persister-fs": [ + "pollyjs__persister-fs" + ], + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ] + } + + }, + "files": [ + "index.d.ts", + "pollyjs__persister-fs-tests.ts" + ] +} diff --git a/types/pollyjs__persister-fs/tslint.json b/types/pollyjs__persister-fs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__persister-fs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__persister/index.d.ts b/types/pollyjs__persister/index.d.ts new file mode 100644 index 0000000000..45fc1fc250 --- /dev/null +++ b/types/pollyjs__persister/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @pollyjs/persister 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/persister +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default class Persister { + static readonly name: string; + static readonly type: string; + persist(): Promise; +} diff --git a/types/pollyjs__persister/pollyjs__persister-tests.ts b/types/pollyjs__persister/pollyjs__persister-tests.ts new file mode 100644 index 0000000000..7e9448aae0 --- /dev/null +++ b/types/pollyjs__persister/pollyjs__persister-tests.ts @@ -0,0 +1,4 @@ +import Persister from '@pollyjs/persister'; + +Persister.name; +Persister.type; diff --git a/types/pollyjs__persister/tsconfig.json b/types/pollyjs__persister/tsconfig.json new file mode 100644 index 0000000000..b47bfbaa9f --- /dev/null +++ b/types/pollyjs__persister/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__persister-tests.ts" + ] +} diff --git a/types/pollyjs__persister/tslint.json b/types/pollyjs__persister/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__persister/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__utils/index.d.ts b/types/pollyjs__utils/index.d.ts new file mode 100644 index 0000000000..e87392fcee --- /dev/null +++ b/types/pollyjs__utils/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for @pollyjs/utils 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/utils +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export enum MODES { + RECORD = 'record', + REPLAY = 'replay', + PASSTHROUGH = 'passthrough', + STOPPED = 'stopped' +} diff --git a/types/pollyjs__utils/pollyjs__utils-tests.ts b/types/pollyjs__utils/pollyjs__utils-tests.ts new file mode 100644 index 0000000000..463a4b4329 --- /dev/null +++ b/types/pollyjs__utils/pollyjs__utils-tests.ts @@ -0,0 +1,6 @@ +import { MODES } from '@pollyjs/utils'; + +MODES.PASSTHROUGH; +MODES.RECORD; +MODES.REPLAY; +MODES.STOPPED; diff --git a/types/pollyjs__utils/tsconfig.json b/types/pollyjs__utils/tsconfig.json new file mode 100644 index 0000000000..7b5421a32f --- /dev/null +++ b/types/pollyjs__utils/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/utils": [ + "pollyjs__utils" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__utils-tests.ts" + ] +} diff --git a/types/pollyjs__utils/tslint.json b/types/pollyjs__utils/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__utils/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d468471c9f44145e289e974ed297ff6457f5a334 Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Fri, 16 Nov 2018 10:43:40 +0000 Subject: [PATCH 54/80] Use slate editor definitions of controller methods --- types/slate-react/index.d.ts | 533 ++++++++++++++++------------------- 1 file changed, 244 insertions(+), 289 deletions(-) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 6ff1237ad3..540316befc 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -12,7 +12,7 @@ // TypeScript Version: 2.8 import { Document, - Editor as EditorController, + Editor as CoreEditor, Mark, Node, Block, @@ -42,7 +42,7 @@ export interface RenderAttributes { export interface RenderMarkProps { attributes: RenderAttributes; children: React.ReactNode; - editor: EditorController; + editor: CoreEditor; mark: Mark; marks: Immutable.Set; node: Node; @@ -53,7 +53,7 @@ export interface RenderMarkProps { export interface RenderNodeProps { attributes: RenderAttributes; children: React.ReactNode; - editor: EditorController; + editor: CoreEditor; isFocused: boolean; isSelected: boolean; key: string; @@ -63,23 +63,23 @@ export interface RenderNodeProps { } export interface RenderPlaceholderProps { - editor: EditorController; + editor: CoreEditor; readOnly: boolean; } export type EventHook = ( event: Event, - editor: EditorController, + editor: CoreEditor, next: () => any ) => any; export interface Plugin { - decorateNode?: (node: Node, editor: EditorController, next: () => any) => any; - renderEditor?: (props: EditorProps, editor: EditorController, next: () => any) => any; - renderMark?: (props: RenderMarkProps, editor: EditorController, next: () => any) => any; - renderNode?: (props: RenderNodeProps, editor: EditorController, next: () => any) => any; - renderPlaceholder?: (props: RenderPlaceholderProps, editor: EditorController, next: () => any) => any; - shouldNodeComponentUpdate?: (previousProps: RenderNodeProps, props: RenderNodeProps, editor: EditorController, next: () => any) => any; + decorateNode?: (node: Node, editor: CoreEditor, next: () => any) => any; + renderEditor?: (props: EditorProps, editor: CoreEditor, next: () => any) => any; + renderMark?: (props: RenderMarkProps, editor: CoreEditor, next: () => any) => any; + renderNode?: (props: RenderNodeProps, editor: CoreEditor, next: () => any) => any; + renderPlaceholder?: (props: RenderPlaceholderProps, editor: CoreEditor, next: () => any) => any; + shouldNodeComponentUpdate?: (previousProps: RenderNodeProps, props: RenderNodeProps, editor: CoreEditor, next: () => any) => any; onBeforeInput?: EventHook; onBlur?: EventHook; @@ -127,7 +127,7 @@ export interface EditorState { } export class Editor extends React.Component implements Controller { - controller: EditorController; + controller: CoreEditor; schema: Schema; stack: Stack; @@ -140,283 +140,238 @@ export class Editor extends React.Component implements resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; // Controller - addMark(mark: Mark | MarkProperties | string): Editor; - delete(): Editor; - deleteBackward(n: number): Editor; - deleteForward(n: number): Editor; - insertBlock(block: Block | BlockProperties | string): Editor; - insertFragment(fragment: Document): Editor; - insertInline(inline: Inline | InlineProperties): Editor; - insertText(text: string): Editor; - setBlocks(properties: BlockProperties | string): Editor; - setInlines(properties: InlineProperties | string): Editor; - splitBlock(depth: number): Editor; - splitInline(depth: number): Editor; - removeMark(mark: Mark | MarkProperties | string): Editor; - replaceMark( - mark: Mark | MarkProperties | string, - newMark: Mark | MarkProperties | string - ): Editor; - toggleMark(mark: Mark | MarkProperties | string): Editor; - unwrapBlock(properties: BlockProperties | string): Editor; - unwrapInline(properties: InlineProperties | string): Editor; - wrapBlock(properties: BlockProperties | string): Editor; - wrapInline(properties: InlineProperties | string): Editor; - wrapText(prefix: string, suffix?: string): Editor; - blur(): Editor; - deselect(): Editor; - flip(): Editor; - focus(): Editor; - moveAnchorBackward(n?: number): Editor; - moveAnchorForward(n?: number): Editor; - moveAnchorTo(path: Path, offset?: number): Editor; - moveAnchorToEndOfBlock(): Editor; - moveAnchorToEndOfInline(): Editor; - moveAnchorToEndOfDocument(): Editor; - moveAnchorToEndOfNextBlock(): Editor; - moveAnchorToEndOfNextInline(): Editor; - moveAnchorToEndOfNextText(): Editor; - moveAnchorEndOfNode(node: Node): Editor; - moveAnchorToEndOfPreviousBlock(): Editor; - moveAnchorToEndOfPreviousInline(): Editor; - moveAnchorToEndOfPreviousText(): Editor; - moveAnchorToEndOfText(): Editor; - moveAnchorToStartOfBlock(): Editor; - moveAnchorToStartOfDocument(): Editor; - moveAnchorToStartOfInline(): Editor; - moveAnchorToStartOfNextBlock(): Editor; - moveAnchorToStartOfNextInline(): Editor; - moveAnchorToStartOfNextText(): Editor; - moveAnchorToStartOfNode(node: Node): Editor; - moveAnchorToStartOfPreviousBlock(): Editor; - moveAnchorToStartOfPreviousInline(): Editor; - moveAnchorToStartOfPreviousText(): Editor; - moveAnchorToStartOfText(): Editor; - moveEndBackward(n?: number): Editor; - moveEndForward(n?: number): Editor; - moveEndTo(path: Path, offset?: number): Editor; - moveEndToEndOfBlock(): Editor; - moveEndToEndOfDocument(): Editor; - moveEndToEndOfInline(): Editor; - moveEndToEndOfNextBlock(): Editor; - moveEndToEndOfNextInline(): Editor; - moveEndToEndOfNextText(): Editor; - moveEndToEndOfNode(node: Node): Editor; - moveEndToEndOfPreviousBlock(): Editor; - moveEndToEndOfPreviousInline(): Editor; - moveEndToEndOfPreviousText(): Editor; - moveEndToEndOfText(): Editor; - moveEndToStartOfBlock(): Editor; - moveEndToStartOfDocument(): Editor; - moveEndToStartOfInline(): Editor; - moveEndToStartOfNextBlock(): Editor; - moveEndToStartOfNextInline(): Editor; - moveEndToStartOfNextText(): Editor; - moveEndToStartOfNode(node: Node): Editor; - moveEndToStartOfPreviousBlock(): Editor; - moveEndToStartOfPreviousInline(): Editor; - moveEndToStartOfPreviousText(): Editor; - moveEndToStartOfText(): Editor; - moveFocusBackward(n?: number): Editor; - moveFocusForward(n?: number): Editor; - moveFocusTo(path: Path, offset?: number): Editor; - moveFocusToEndOfBlock(): Editor; - moveFocusToEndOfDocument(): Editor; - moveFocusToEndOfInline(): Editor; - moveFocusToEndOfNextBlock(): Editor; - moveFocusToEndOfNextInline(): Editor; - moveFocusToEndOfNextText(): Editor; - moveFocusToEndOfNode(node: Node): Editor; - moveFocusToEndOfPreviousBlock(): Editor; - moveFocusToEndOfPreviousInline(): Editor; - moveFocusToEndOfPreviousText(): Editor; - moveFocusToEndOfText(): Editor; - moveFocusToStartOfBlock(): Editor; - moveFocusToStartOfDocument(): Editor; - moveFocusToStartOfInline(): Editor; - moveFocusToStartOfNextBlock(): Editor; - moveFocusToStartOfNextInline(): Editor; - moveFocusToStartOfNextText(): Editor; - moveFocusToStartOfNode(node: Node): Editor; - moveFocusToStartOfPreviousBlock(): Editor; - moveFocusToStartOfPreviousInline(): Editor; - moveFocusToStartOfPreviousText(): Editor; - moveFocusToStartOfText(): Editor; - moveStartForward(n?: number): Editor; - moveStartBackward(n?: number): Editor; - moveStartTo(path: Path, n?: number): Editor; - moveStartToEndOfBlock(): Editor; - moveStartToEndOfDocument(): Editor; - moveStartToEndOfInline(): Editor; - moveStartToEndOfNextBlock(): Editor; - moveStartToEndOfNextInline(): Editor; - moveStartToEndOfNextText(): Editor; - moveStartToEndOfNode(node: Node): Editor; - moveStartToEndOfPreviousBlock(): Editor; - moveStartToEndOfPreviousInline(): Editor; - moveStartToEndOfPreviousText(): Editor; - moveStartToEndOfText(): Editor; - moveStartToStartOfBlock(): Editor; - moveStartToStartOfDocument(): Editor; - moveStartToStartOfInline(): Editor; - moveStartToStartOfNextBlock(): Editor; - moveStartToStartOfNextInline(): Editor; - moveStartToStartOfNextText(): Editor; - moveStartToStartOfNode(node: Node): Editor; - moveStartToStartOfPreviousBlock(): Editor; - moveStartToStartOfPreviousInline(): Editor; - moveStartToStartOfPreviousText(): Editor; - moveStartToStartOfText(): Editor; - moveBackward(n?: number): Editor; - moveForward(n?: number): Editor; - moveTo(path: Path, offset?: number): Editor; - moveToAnchor(): Editor; - moveToFocus(): Editor; - moveToStart(): Editor; - moveToEnd(): Editor; - moveToEndOfBlock(): Editor; - moveToEndOfDocument(): Editor; - moveToEndOfInline(): Editor; - moveToEndOfNextBlock(): Editor; - moveToEndOfNextInline(): Editor; - moveToEndOfNextText(): Editor; - moveToEndOfNode(node: Node): Editor; - moveToEndOfPreviousBlock(): Editor; - moveToEndOfPreviousInline(): Editor; - moveToEndOfPreviousText(): Editor; - moveToEndOfText(): Editor; - moveToStartOfBlock(): Editor; - moveToStartOfDocument(): Editor; - moveToStartOfInline(): Editor; - moveToStartOfNextBlock(): Editor; - moveToStartOfNextInline(): Editor; - moveToStartOfNextText(): Editor; - moveToStartOfNode(node: Node): Editor; - moveToStartOfPreviousBlock(): Editor; - moveToStartOfPreviousInline(): Editor; - moveToStartOfPreviousText(): Editor; - moveToStartOfText(): Editor; - moveToRangeOfDocument(): Editor; - moveToRangeOf(node: Node): Editor; - select(properties: Range | RangeProperties): Editor; - addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; - deleteAtRange(range: Range): Editor; - deleteCharBackwardAtRange(range: Range): Editor; - deleteLineBackwardAtRange(range: Range): Editor; - deleteWordBackwardAtRange(range: Range): Editor; - deleteBackwardAtRange(range: Range, n: number): Editor; - deleteCharForwardAtRange(range: Range): Editor; - deleteLineForwardAtRange(range: Range): Editor; - deleteWordForwardAtRange(range: Range): Editor; - deleteForwardAtRange(range: Range, n: number): Editor; - insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Editor; - insertFragmentAtRange(range: Range, fragment: Document): Editor; - insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Editor; - insertTextAtRange(range: Range, text: string): Editor; - setBlocksAtRange(range: Range, properties: BlockProperties | string): Editor; - setInlinesAtRange(range: Range, properties: InlineProperties | string): Editor; - splitBlockAtRange(range: Range, depth: number): Editor; - splitInlineAtRange(range: Range, depth: number): Editor; - removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; - toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; - unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; - unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; - wrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; - wrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; - wrapTextAtRange(range: Range, prefix: string, suffix?: string): Editor; - addMarkByKey( - key: string, - offset: number, - length: number, - mark: MarkProperties | Mark | string - ): Editor; - addMarkByPath( - path: Path, - offset: number, - length: number, - mark: MarkProperties | Mark | string - ): Editor; - insertNodeByKey(key: string, index: number, node: Node): Editor; - insertNodeByPath(path: Path, index: number, node: Node): Editor; - insertFragmentByKey(key: string, index: number, fragment: Document): Editor; - insertFragmentByPath(path: Path, index: number, fragment: Document): Editor; - insertTextByKey( - key: string, - offset: number, - text: string, - marks?: Immutable.Set | Mark[] - ): Editor; - insertTextByPath( - path: Path, - offset: number, - text: string, - marks?: Immutable.Set | Mark[] - ): Editor; - mergeNodeByKey(key: string): Editor; - mergeNodeByPath(path: Path): Editor; - moveNodeByKey(key: string, newKey: string, newIndex: number): Editor; - moveNodeByPath(path: Path, newPath: Path, newIndex: number): Editor; - removeMarkByKey( - key: string, - offset: number, - length: number, - mark: Mark | Mark | string - ): Editor; - removeMarkByPath( - path: Path, - offset: number, - length: number, - mark: MarkProperties | Mark | string - ): Editor; - removeNodeByKey(key: string): Editor; - removeNodeByPath(path: Path): Editor; - replaceNodeByKey(key: string, node: Node): Editor; - replaceNodeByPath(path: Path, newNode: Node): Editor; - removeTextByKey(key: string, offset: number, length: number): Editor; - removeTextByPath(path: Path, offset: number, length: number): Editor; - setMarkByKey( - key: string, - offset: number, - length: number, - mark: Mark, - properties: MarkProperties - ): Editor; - setMarksByPath( - path: Path, - offset: number, - length: number, - mark: Mark, - properties: MarkProperties - ): Editor; - setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Editor; - setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Editor; - splitNodeByKey(key: string, offset: number): Editor; - splitNodeByPath(path: Path, position: number): Editor; - unwrapInlineByKey(key: string, properties: InlineProperties | string): Editor; - unwrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; - unwrapBlockByKey(key: string, properties: BlockProperties | string): Editor; - unwrapBlockByPath(path: Path, properties: BlockProperties | string): Editor; - unwrapNodeByKey(key: string): Editor; - unwrapNodeByPath(path: Path): Editor; - wrapInlineByKey(key: string, properties: InlineProperties | string): Editor; - wrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; - wrapBlockByKey(key: string, properties: BlockProperties | string): Editor; - wrapBlockByPath(path: Path, block: Block | string): Editor; - wrapNodeByKey(key: string, parent: Node): Editor; - wrapNodeByPath(path: Path, parent: Node): Editor; - normalize(): Editor; - withoutNormalizing(fn: () => void): Editor; - withoutSaving(fn: () => void): Editor; - withoutMerging(fn: () => void): Editor; - redo(): Editor; - undo(): Editor; - snapshotSelection(): Editor; - command(name: string, ...args: any[]): Editor; - query(query: string, ...args: any[]): Editor; - registerCommand(command: string): Editor; - registerQuery(query: string): Editor; - applyOperation(operation: Operation): Editor; - run(key: string, ...args: any[]): Editor; + addMark: CoreEditor['addMark']; + delete: CoreEditor['delete']; + deleteBackward: CoreEditor['deleteBackward']; + deleteForward: CoreEditor['deleteForward']; + insertBlock: CoreEditor['insertBlock']; + insertFragment: CoreEditor['insertFragment']; + insertInline: CoreEditor['insertInline']; + insertText: CoreEditor['insertText']; + setBlocks: CoreEditor['setBlocks']; + setInlines: CoreEditor['setInlines']; + splitBlock: CoreEditor['splitBlock']; + splitInline: CoreEditor['splitInline']; + removeMark: CoreEditor['removeMark']; + replaceMark: CoreEditor['replaceMark']; + toggleMark: CoreEditor['toggleMark']; + unwrapBlock: CoreEditor['unwrapBlock']; + unwrapInline: CoreEditor['unwrapInline']; + wrapBlock: CoreEditor['wrapBlock']; + wrapInline: CoreEditor['wrapInline']; + wrapText: CoreEditor['wrapText']; + blur: CoreEditor['blur']; + deselect: CoreEditor['deselect']; + flip: CoreEditor['flip']; + focus: CoreEditor['focus']; + moveAnchorBackward: CoreEditor['moveAnchorBackward']; + moveAnchorForward: CoreEditor['moveAnchorForward']; + moveAnchorTo: CoreEditor['moveAnchorTo']; + moveAnchorToEndOfBlock: CoreEditor['moveAnchorToEndOfBlock']; + moveAnchorToEndOfInline: CoreEditor['moveAnchorToEndOfInline']; + moveAnchorToEndOfDocument: CoreEditor['moveAnchorToEndOfDocument']; + moveAnchorToEndOfNextBlock: CoreEditor['moveAnchorToEndOfNextBlock']; + moveAnchorToEndOfNextInline: CoreEditor['moveAnchorToEndOfNextInline']; + moveAnchorToEndOfNextText: CoreEditor['moveAnchorToEndOfNextText']; + moveAnchorEndOfNode: CoreEditor['moveAnchorEndOfNode']; + moveAnchorToEndOfPreviousBlock: CoreEditor['moveAnchorToEndOfPreviousBlock']; + moveAnchorToEndOfPreviousInline: CoreEditor['moveAnchorToEndOfPreviousInline']; + moveAnchorToEndOfPreviousText: CoreEditor['moveAnchorToEndOfPreviousText']; + moveAnchorToEndOfText: CoreEditor['moveAnchorToEndOfText']; + moveAnchorToStartOfBlock: CoreEditor['moveAnchorToStartOfBlock']; + moveAnchorToStartOfDocument: CoreEditor['moveAnchorToStartOfDocument']; + moveAnchorToStartOfInline: CoreEditor['moveAnchorToStartOfInline']; + moveAnchorToStartOfNextBlock: CoreEditor['moveAnchorToStartOfNextBlock']; + moveAnchorToStartOfNextInline: CoreEditor['moveAnchorToStartOfNextInline']; + moveAnchorToStartOfNextText: CoreEditor['moveAnchorToStartOfNextText']; + moveAnchorToStartOfNode: CoreEditor['moveAnchorToStartOfNode']; + moveAnchorToStartOfPreviousBlock: CoreEditor['moveAnchorToStartOfPreviousBlock']; + moveAnchorToStartOfPreviousInline: CoreEditor['moveAnchorToStartOfPreviousInline']; + moveAnchorToStartOfPreviousText: CoreEditor['moveAnchorToStartOfPreviousText']; + moveAnchorToStartOfText: CoreEditor['moveAnchorToStartOfText']; + moveEndBackward: CoreEditor['moveEndBackward']; + moveEndForward: CoreEditor['moveEndForward']; + moveEndTo: CoreEditor['moveEndTo']; + moveEndToEndOfBlock: CoreEditor['moveEndToEndOfBlock']; + moveEndToEndOfDocument: CoreEditor['moveEndToEndOfDocument']; + moveEndToEndOfInline: CoreEditor['moveEndToEndOfInline']; + moveEndToEndOfNextBlock: CoreEditor['moveEndToEndOfNextBlock']; + moveEndToEndOfNextInline: CoreEditor['moveEndToEndOfNextInline']; + moveEndToEndOfNextText: CoreEditor['moveEndToEndOfNextText']; + moveEndToEndOfNode: CoreEditor['moveEndToEndOfNode']; + moveEndToEndOfPreviousBlock: CoreEditor['moveEndToEndOfPreviousBlock']; + moveEndToEndOfPreviousInline: CoreEditor['moveEndToEndOfPreviousInline']; + moveEndToEndOfPreviousText: CoreEditor['moveEndToEndOfPreviousText']; + moveEndToEndOfText: CoreEditor['moveEndToEndOfText']; + moveEndToStartOfBlock: CoreEditor['moveEndToStartOfBlock']; + moveEndToStartOfDocument: CoreEditor['moveEndToStartOfDocument']; + moveEndToStartOfInline: CoreEditor['moveEndToStartOfInline']; + moveEndToStartOfNextBlock: CoreEditor['moveEndToStartOfNextBlock']; + moveEndToStartOfNextInline: CoreEditor['moveEndToStartOfNextInline']; + moveEndToStartOfNextText: CoreEditor['moveEndToStartOfNextText']; + moveEndToStartOfNode: CoreEditor['moveEndToStartOfNode']; + moveEndToStartOfPreviousBlock: CoreEditor['moveEndToStartOfPreviousBlock']; + moveEndToStartOfPreviousInline: CoreEditor['moveEndToStartOfPreviousInline']; + moveEndToStartOfPreviousText: CoreEditor['moveEndToStartOfPreviousText']; + moveEndToStartOfText: CoreEditor['moveEndToStartOfText']; + moveFocusBackward: CoreEditor['moveFocusBackward']; + moveFocusForward: CoreEditor['moveFocusForward']; + moveFocusTo: CoreEditor['moveFocusTo']; + moveFocusToEndOfBlock: CoreEditor['moveFocusToEndOfBlock']; + moveFocusToEndOfDocument: CoreEditor['moveFocusToEndOfDocument']; + moveFocusToEndOfInline: CoreEditor['moveFocusToEndOfInline']; + moveFocusToEndOfNextBlock: CoreEditor['moveFocusToEndOfNextBlock']; + moveFocusToEndOfNextInline: CoreEditor['moveFocusToEndOfNextInline']; + moveFocusToEndOfNextText: CoreEditor['moveFocusToEndOfNextText']; + moveFocusToEndOfNode: CoreEditor['moveFocusToEndOfNode']; + moveFocusToEndOfPreviousBlock: CoreEditor['moveFocusToEndOfPreviousBlock']; + moveFocusToEndOfPreviousInline: CoreEditor['moveFocusToEndOfPreviousInline']; + moveFocusToEndOfPreviousText: CoreEditor['moveFocusToEndOfPreviousText']; + moveFocusToEndOfText: CoreEditor['moveFocusToEndOfText']; + moveFocusToStartOfBlock: CoreEditor['moveFocusToStartOfBlock']; + moveFocusToStartOfDocument: CoreEditor['moveFocusToStartOfDocument']; + moveFocusToStartOfInline: CoreEditor['moveFocusToStartOfInline']; + moveFocusToStartOfNextBlock: CoreEditor['moveFocusToStartOfNextBlock']; + moveFocusToStartOfNextInline: CoreEditor['moveFocusToStartOfNextInline']; + moveFocusToStartOfNextText: CoreEditor['moveFocusToStartOfNextText']; + moveFocusToStartOfNode: CoreEditor['moveFocusToStartOfNode']; + moveFocusToStartOfPreviousBlock: CoreEditor['moveFocusToStartOfPreviousBlock']; + moveFocusToStartOfPreviousInline: CoreEditor['moveFocusToStartOfPreviousInline']; + moveFocusToStartOfPreviousText: CoreEditor['moveFocusToStartOfPreviousText']; + moveFocusToStartOfText: CoreEditor['moveFocusToStartOfText']; + moveStartForward: CoreEditor['moveStartForward']; + moveStartBackward: CoreEditor['moveStartBackward']; + moveStartTo: CoreEditor['moveStartTo']; + moveStartToEndOfBlock: CoreEditor['moveStartToEndOfBlock']; + moveStartToEndOfDocument: CoreEditor['moveStartToEndOfDocument']; + moveStartToEndOfInline: CoreEditor['moveStartToEndOfInline']; + moveStartToEndOfNextBlock: CoreEditor['moveStartToEndOfNextBlock']; + moveStartToEndOfNextInline: CoreEditor['moveStartToEndOfNextInline']; + moveStartToEndOfNextText: CoreEditor['moveStartToEndOfNextText']; + moveStartToEndOfNode: CoreEditor['moveStartToEndOfNode']; + moveStartToEndOfPreviousBlock: CoreEditor['moveStartToEndOfPreviousBlock']; + moveStartToEndOfPreviousInline: CoreEditor['moveStartToEndOfPreviousInline']; + moveStartToEndOfPreviousText: CoreEditor['moveStartToEndOfPreviousText']; + moveStartToEndOfText: CoreEditor['moveStartToEndOfText']; + moveStartToStartOfBlock: CoreEditor['moveStartToStartOfBlock']; + moveStartToStartOfDocument: CoreEditor['moveStartToStartOfDocument']; + moveStartToStartOfInline: CoreEditor['moveStartToStartOfInline']; + moveStartToStartOfNextBlock: CoreEditor['moveStartToStartOfNextBlock']; + moveStartToStartOfNextInline: CoreEditor['moveStartToStartOfNextInline']; + moveStartToStartOfNextText: CoreEditor['moveStartToStartOfNextText']; + moveStartToStartOfNode: CoreEditor['moveStartToStartOfNode']; + moveStartToStartOfPreviousBlock: CoreEditor['moveStartToStartOfPreviousBlock']; + moveStartToStartOfPreviousInline: CoreEditor['moveStartToStartOfPreviousInline']; + moveStartToStartOfPreviousText: CoreEditor['moveStartToStartOfPreviousText']; + moveStartToStartOfText: CoreEditor['moveStartToStartOfText']; + moveBackward: CoreEditor['moveBackward']; + moveForward: CoreEditor['moveForward']; + moveTo: CoreEditor['moveTo']; + moveToAnchor: CoreEditor['moveToAnchor']; + moveToFocus: CoreEditor['moveToFocus']; + moveToStart: CoreEditor['moveToStart']; + moveToEnd: CoreEditor['moveToEnd']; + moveToEndOfBlock: CoreEditor['moveToEndOfBlock']; + moveToEndOfDocument: CoreEditor['moveToEndOfDocument']; + moveToEndOfInline: CoreEditor['moveToEndOfInline']; + moveToEndOfNextBlock: CoreEditor['moveToEndOfNextBlock']; + moveToEndOfNextInline: CoreEditor['moveToEndOfNextInline']; + moveToEndOfNextText: CoreEditor['moveToEndOfNextText']; + moveToEndOfNode: CoreEditor['moveToEndOfNode']; + moveToEndOfPreviousBlock: CoreEditor['moveToEndOfPreviousBlock']; + moveToEndOfPreviousInline: CoreEditor['moveToEndOfPreviousInline']; + moveToEndOfPreviousText: CoreEditor['moveToEndOfPreviousText']; + moveToEndOfText: CoreEditor['moveToEndOfText']; + moveToStartOfBlock: CoreEditor['moveToStartOfBlock']; + moveToStartOfDocument: CoreEditor['moveToStartOfDocument']; + moveToStartOfInline: CoreEditor['moveToStartOfInline']; + moveToStartOfNextBlock: CoreEditor['moveToStartOfNextBlock']; + moveToStartOfNextInline: CoreEditor['moveToStartOfNextInline']; + moveToStartOfNextText: CoreEditor['moveToStartOfNextText']; + moveToStartOfNode: CoreEditor['moveToStartOfNode']; + moveToStartOfPreviousBlock: CoreEditor['moveToStartOfPreviousBlock']; + moveToStartOfPreviousInline: CoreEditor['moveToStartOfPreviousInline']; + moveToStartOfPreviousText: CoreEditor['moveToStartOfPreviousText']; + moveToStartOfText: CoreEditor['moveToStartOfText']; + moveToRangeOfDocument: CoreEditor['moveToRangeOfDocument']; + moveToRangeOf: CoreEditor['moveToRangeOf']; + select: CoreEditor['select']; + addMarkAtRange: CoreEditor['addMarkAtRange']; + deleteAtRange: CoreEditor['deleteAtRange']; + deleteCharBackwardAtRange: CoreEditor['deleteCharBackwardAtRange']; + deleteLineBackwardAtRange: CoreEditor['deleteLineBackwardAtRange']; + deleteWordBackwardAtRange: CoreEditor['deleteWordBackwardAtRange']; + deleteBackwardAtRange: CoreEditor['deleteBackwardAtRange']; + deleteCharForwardAtRange: CoreEditor['deleteCharForwardAtRange']; + deleteLineForwardAtRange: CoreEditor['deleteLineForwardAtRange']; + deleteWordForwardAtRange: CoreEditor['deleteWordForwardAtRange']; + deleteForwardAtRange: CoreEditor['deleteForwardAtRange']; + insertBlockAtRange: CoreEditor['insertBlockAtRange']; + insertFragmentAtRange: CoreEditor['insertFragmentAtRange']; + insertInlineAtRange: CoreEditor['insertInlineAtRange']; + insertTextAtRange: CoreEditor['insertTextAtRange']; + setBlocksAtRange: CoreEditor['setBlocksAtRange']; + setInlinesAtRange: CoreEditor['setInlinesAtRange']; + splitBlockAtRange: CoreEditor['splitBlockAtRange']; + splitInlineAtRange: CoreEditor['splitInlineAtRange']; + removeMarkAtRange: CoreEditor['removeMarkAtRange']; + toggleMarkAtRange: CoreEditor['toggleMarkAtRange']; + unwrapBlockAtRange: CoreEditor['unwrapBlockAtRange']; + unwrapInlineAtRange: CoreEditor['unwrapInlineAtRange']; + wrapBlockAtRange: CoreEditor['wrapBlockAtRange']; + wrapInlineAtRange: CoreEditor['wrapInlineAtRange']; + wrapTextAtRange: CoreEditor['wrapTextAtRange']; + addMarkByKey: CoreEditor['addMarkByKey']; + addMarkByPath: CoreEditor['addMarkByPath']; + insertNodeByKey: CoreEditor['insertNodeByKey']; + insertNodeByPath: CoreEditor['insertNodeByPath']; + insertFragmentByKey: CoreEditor['insertFragmentByKey']; + insertFragmentByPath: CoreEditor['insertFragmentByPath']; + insertTextByKey: CoreEditor['insertTextByKey']; + insertTextByPath: CoreEditor['insertTextByPath']; + mergeNodeByKey: CoreEditor['mergeNodeByKey']; + mergeNodeByPath: CoreEditor['mergeNodeByPath']; + moveNodeByKey: CoreEditor['moveNodeByKey']; + moveNodeByPath: CoreEditor['moveNodeByPath']; + removeMarkByKey: CoreEditor['removeMarkByKey']; + removeMarkByPath: CoreEditor['removeMarkByPath']; + removeNodeByKey: CoreEditor['removeNodeByKey']; + removeNodeByPath: CoreEditor['removeNodeByPath']; + replaceNodeByKey: CoreEditor['replaceNodeByKey']; + replaceNodeByPath: CoreEditor['replaceNodeByPath']; + removeTextByKey: CoreEditor['removeTextByKey']; + removeTextByPath: CoreEditor['removeTextByPath']; + setMarkByKey: CoreEditor['setMarkByKey']; + setMarksByPath: CoreEditor['setMarksByPath']; + setNodeByKey: CoreEditor['setNodeByKey']; + setNodeByPath: CoreEditor['setNodeByPath']; + splitNodeByKey: CoreEditor['splitNodeByKey']; + splitNodeByPath: CoreEditor['splitNodeByPath']; + unwrapInlineByKey: CoreEditor['unwrapInlineByKey']; + unwrapInlineByPath: CoreEditor['unwrapInlineByPath']; + unwrapBlockByKey: CoreEditor['unwrapBlockByKey']; + unwrapBlockByPath: CoreEditor['unwrapBlockByPath']; + unwrapNodeByKey: CoreEditor['unwrapNodeByKey']; + unwrapNodeByPath: CoreEditor['unwrapNodeByPath']; + wrapInlineByKey: CoreEditor['wrapInlineByKey']; + wrapInlineByPath: CoreEditor['wrapInlineByPath']; + wrapBlockByKey: CoreEditor['wrapBlockByKey']; + wrapBlockByPath: CoreEditor['wrapBlockByPath']; + wrapNodeByKey: CoreEditor['wrapNodeByKey']; + wrapNodeByPath: CoreEditor['wrapNodeByPath']; + normalize: CoreEditor['normalize']; + withoutNormalizing: CoreEditor['withoutNormalizing']; + withoutSaving: CoreEditor['withoutSaving']; + withoutMerging: CoreEditor['withoutMerging']; + redo: CoreEditor['redo']; + undo: CoreEditor['undo']; + snapshotSelection: CoreEditor['snapshotSelection']; + command: CoreEditor['command']; + query: CoreEditor['query']; + registerCommand: CoreEditor['registerCommand']; + registerQuery: CoreEditor['registerQuery']; + applyOperation: CoreEditor['applyOperation']; + run: CoreEditor['run']; } export type SlateType = From edbb9d5fb0cf452120fc6fdc5e58624e91046035 Mon Sep 17 00:00:00 2001 From: Konch Roman <300konya@gmail.com> Date: Fri, 16 Nov 2018 14:22:42 +0300 Subject: [PATCH 55/80] Fix element-resize-detector options --- types/element-resize-detector/index.d.ts | 47 +++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/types/element-resize-detector/index.d.ts b/types/element-resize-detector/index.d.ts index 5b6c1f00aa..096c99200d 100644 --- a/types/element-resize-detector/index.d.ts +++ b/types/element-resize-detector/index.d.ts @@ -7,14 +7,51 @@ declare function elementResizeDetectorMaker(options?: elementResizeDetectorMaker declare namespace elementResizeDetectorMaker { interface ErdmOptions { - strategy?: 'scroll' | 'object'; + strategy?: 'scroll' | 'object'; + + /** + * Determines if listeners should be called when they are getting added. + * If true, the listener is guaranteed to be called when it has been added. + * If false, the listener will not be guarenteed to be called when + * it has been added (does not prevent it from being called). + * + * @default true + */ + callOnAdd?: boolean; + + /** + * If set to true, the the system will report debug messages as default + * for the listenTo method. + */ + debug?: boolean; + + /** + * A custom id handler that is responsible for generating, + * setting and retrieving id's for elements. + * If not provided, a default id handler will be used. + */ + idHandler?: { + get(element: HTMLElement, readonly: boolean): any; + set(element: HTMLElement): any; + }; + + /** + * A custom reporter that handles reporting logs, warnings and errors. + * If not provided, a default id handler will be used. + * If set to false, then nothing will be reported. + */ + reporter?: false | { + log?: (idOrText: string, textOrId: string, element?: HTMLElement) => void; + warn?(text: string, element?: HTMLElement): void; + error?(text: string): void; + }; } interface Erd { - listenTo(element: HTMLElement, callback: (elem: HTMLElement) => void): void; - removeListener(element: HTMLElement, callback: (elem: HTMLElement) => void): void; - removeAllListeners(element: HTMLElement): void; - uninstall(element: HTMLElement): void; + listenTo(element: HTMLElement, callback: (elem: HTMLElement) => void): void; + removeListener(element: HTMLElement, callback: (elem: HTMLElement) => void): void; + removeAllListeners(element: HTMLElement): void; + uninstall(element: HTMLElement): void; } } export = elementResizeDetectorMaker; From 2641b36c8d291b7f9c756fcbe78525fe6cad86b1 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 13 Nov 2018 14:23:03 -0800 Subject: [PATCH 56/80] adds typings for koa-ratelimit-lru package --- types/koa-ratelimit-lru/index.d.ts | 28 +++++++++++++++++++ .../koa-ratelimit-lru-tests.ts | 12 ++++++++ types/koa-ratelimit-lru/tsconfig.json | 23 +++++++++++++++ types/koa-ratelimit-lru/tslint.json | 3 ++ 4 files changed, 66 insertions(+) create mode 100644 types/koa-ratelimit-lru/index.d.ts create mode 100644 types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts create mode 100644 types/koa-ratelimit-lru/tsconfig.json create mode 100644 types/koa-ratelimit-lru/tslint.json diff --git a/types/koa-ratelimit-lru/index.d.ts b/types/koa-ratelimit-lru/index.d.ts new file mode 100644 index 0000000000..f6c560f16a --- /dev/null +++ b/types/koa-ratelimit-lru/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for koa-ratelimit-lru 1.0 +// Project: https://github.com/Dreamacro/koa-ratelimit-lru +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Middleware } from 'koa'; + +declare namespace rateLimit { + interface Options { + readonly duration?: number; + readonly max?: number; + readonly prefix?: string; + readonly store?: any; // lru-cache ? + readonly rate?: number; + readonly id?: string; + readonly headers?: { + readonly remaining?: string; + readonly reset?: string; + readonly total?: string; + }; + readonly errorMessage?: string; + } + } + +declare function rateLimit(options?: rateLimit.Options): Middleware; + +export = rateLimit; diff --git a/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts b/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts new file mode 100644 index 0000000000..84759cb43b --- /dev/null +++ b/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts @@ -0,0 +1,12 @@ +import Koa = require('koa'); +import rateLimit = require('koa-ratelimit-lru'); + +const app = new Koa(); + +app.use(rateLimit({})); + +app.use(async context => { + context.body = "Hello"; +}); + +app.listen(2000); diff --git a/types/koa-ratelimit-lru/tsconfig.json b/types/koa-ratelimit-lru/tsconfig.json new file mode 100644 index 0000000000..7f285be8e3 --- /dev/null +++ b/types/koa-ratelimit-lru/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-ratelimit-lru-tests.ts" + ] +} diff --git a/types/koa-ratelimit-lru/tslint.json b/types/koa-ratelimit-lru/tslint.json new file mode 100644 index 0000000000..6fafe521cb --- /dev/null +++ b/types/koa-ratelimit-lru/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" + } From 2a6415fdbde0b406816240525aa5008ee19a418c Mon Sep 17 00:00:00 2001 From: licui Date: Fri, 16 Nov 2018 15:53:18 -0500 Subject: [PATCH 57/80] Fix openfin typings broken when used globally --- types/openfin/index.d.ts | 4 ---- types/openfin/openfin-tests.ts | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts index 41e35c0c45..04342ada0c 100644 --- a/types/openfin/index.d.ts +++ b/types/openfin/index.d.ts @@ -49,10 +49,6 @@ import Bounds from './_v2/api/window/bounds'; import { Transition, TransitionOptions } from './_v2/api/window/transition'; import { WindowOption } from './_v2/api/window/windowOption'; -// tslint:disable-next-line:export-just-namespace -export = fin; -export as namespace fin; - declare namespace fin { var Application: import('./_v2/api/application/application').default; var Clipboard: import('./_v2/api/clipboard/clipboard').default; diff --git a/types/openfin/openfin-tests.ts b/types/openfin/openfin-tests.ts index 167a6c86be..c02700f2fb 100644 --- a/types/openfin/openfin-tests.ts +++ b/types/openfin/openfin-tests.ts @@ -1,3 +1,5 @@ +import { fin } from "openfin"; + function test_application() { let application: fin.OpenFinApplication; // constructor From 3c52def4ab0dc44f20242beeb94797955db780c9 Mon Sep 17 00:00:00 2001 From: Jasmin Bom Date: Sat, 17 Nov 2018 13:43:04 +0100 Subject: [PATCH 58/80] Update firefox-webext-browser to FF v64b10 --- types/firefox-webext-browser/index.d.ts | 221 ++++++++++++++++++++++-- 1 file changed, 202 insertions(+), 19 deletions(-) diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts index 2497d3b53d..84dc4f15e7 100644 --- a/types/firefox-webext-browser/index.d.ts +++ b/types/firefox-webext-browser/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for WebExtension Development in FireFox 63.0 +// Type definitions for WebExtension Development in FireFox 64.0 // Project: https://developer.mozilla.org/en-US/Add-ons/WebExtensions // Definitions by: Jasmin Bom // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -141,6 +141,9 @@ declare namespace browser._manifest { }; hidden?: boolean; theme_experiment?: ThemeExperiment; + user_scripts?: { + api_script?: ExtensionURL; + }; browser_action?: { default_title?: string; default_icon?: IconPath; @@ -163,8 +166,10 @@ declare namespace browser._manifest { instant_url?: string; /** @deprecated Unsupported on Firefox at this time. */ image_url?: string; - /** @deprecated Unsupported on Firefox at this time. */ + /** POST parameters to the search_url as a query string. */ search_url_post_params?: string; + /** POST parameters to the suggest_url as a query string. */ + suggest_url_post_params?: string; /** @deprecated Unsupported on Firefox at this time. */ instant_url_post_params?: string; /** @deprecated Unsupported on Firefox at this time. */ @@ -175,6 +180,22 @@ declare namespace browser._manifest { prepopulated_id?: number; /** Sets the default engine to a built-in engine only. */ is_default?: boolean; + /** + * A list of optional search url parameters. This allows the additon of search url parameters based on + * how the search is performed in Firefox. + */ + params?: Array<{ + /** A url parameter name */ + name: string; + /** The type of param can be either "purpose" or "pref". */ + condition?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition; + /** The preference to retreive the value from. */ + pref?: string; + /** The context that initiates a search, required if condition is "purpose". */ + purpose?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose; + /** A url parameter value. */ + value?: string; + }>; }; }; commands?: { @@ -202,6 +223,7 @@ declare namespace browser._manifest { browser_style?: boolean; show_matches?: MatchPattern[]; hide_matches?: MatchPatternRestricted[]; + pinned?: boolean; }; sidebar_action?: { default_title?: string; @@ -363,9 +385,6 @@ declare namespace browser._manifest { */ type MatchPatternUnestricted = string; - /** Same as MatchPattern above, but includes moz-extension protocol */ - type MatchPatternInternal = string | _MatchPatternInternal; - /** * Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be * set at the same time. Based on InjectDetails, but using underscore rather than camel case naming conventions. @@ -475,6 +494,7 @@ declare namespace browser._manifest { ntp_background?: ThemeColor; ntp_text?: ThemeColor; sidebar?: ThemeColor; + sidebar_border?: ThemeColor; sidebar_text?: ThemeColor; sidebar_highlight?: ThemeColor; sidebar_highlight_text?: ThemeColor; @@ -596,6 +616,7 @@ declare namespace browser._manifest { | "bookmarks" | "find" | "history" + | "menus.overrideContext" | "search" | "activeTab" | "tabs" @@ -632,6 +653,17 @@ declare namespace browser._manifest { | "tabstrip" | "personaltoolbar"; + /** The type of param can be either "purpose" or "pref". */ + type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition = "purpose" | "pref"; + + /** The context that initiates a search, required if condition is "purpose". */ + type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose = + "contextmenu" + | "searchbar" + | "homepage" + | "keyword" + | "newtab"; + type _ProtocolHandlerProtocol = "bitcoin" | "dat" @@ -661,8 +693,6 @@ declare namespace browser._manifest { type _MatchPattern = ""; - type _MatchPatternInternal = ""; - type _ThemeTypeAdditionalBackgroundsAlignment = "bottom" | "center" @@ -785,12 +815,6 @@ declare namespace browser.clipboard { /** Not allowed in: Content scripts, Devtools pages */ declare namespace browser.contentScripts { /* contentScripts types */ - type ExtensionFileOrCode = { - file: _manifest.ExtensionURL; - } | { - code: string; - }; - /** Details of a content script registered programmatically */ interface RegisteredContentScriptOptions { matches: _manifest.MatchPattern[]; @@ -798,9 +822,9 @@ declare namespace browser.contentScripts { includeGlobs?: string[]; excludeGlobs?: string[]; /** The list of CSS files to inject */ - css?: ExtensionFileOrCode[]; + css?: extensionTypes.ExtensionFileOrCode[]; /** The list of JS files to inject */ - js?: ExtensionFileOrCode[]; + js?: extensionTypes.ExtensionFileOrCode[]; /** * If allFrames is `true`, implies that the JavaScript or CSS should be injected into all frames of current * page. By default, it's `false` and is only injected into the top frame. @@ -1912,6 +1936,22 @@ declare namespace browser.extensionTypes { } type Date = string | number | object/*Date*/; + + type ExtensionFileOrCode = { + file: _manifest.ExtensionURL; + } | { + code: string; + }; + + /** A plain JSON value */ + type PlainJSONValue = null | string | number | boolean | _PlainJSONArray | _PlainJSONObject; + + interface _PlainJSONArray extends Array { + } + + interface _PlainJSONObject { + [key: string]: PlainJSONValue; + } } /** @@ -2403,7 +2443,7 @@ declare namespace browser.permissions { interface AnyPermissions { permissions?: _manifest.Permission[]; - origins?: _manifest.MatchPatternInternal[]; + origins?: _manifest.MatchPattern[]; } /* permissions functions */ @@ -2524,7 +2564,8 @@ declare namespace browser.privacy.websites { "allow_all" | "reject_all" | "reject_third_party" - | "allow_visited"; + | "allow_visited" + | "reject_trackers"; /* privacy.websites properties */ /** @@ -3456,6 +3497,64 @@ declare namespace browser.types { } } +/** + * Manifest keys: `user_scripts`, `user_scripts` + * + * Not allowed in: Devtools pages + */ +declare namespace browser.userScripts { + /* userScripts types */ + /** Details of a user script */ + interface UserScriptOptions { + /** The list of JS files to inject */ + js?: extensionTypes.ExtensionFileOrCode[]; + /** An opaque user script metadata value */ + scriptMetadata?: extensionTypes.PlainJSONValue; + matches: _manifest.MatchPattern[]; + excludeMatches?: _manifest.MatchPattern[]; + includeGlobs?: string[]; + excludeGlobs?: string[]; + /** + * If allFrames is `true`, implies that the JavaScript should be injected into all frames of current page. By + * default, it's `false` and is only injected into the top frame. + */ + allFrames?: boolean; + /** + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your + * extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default + * it is `false`. + */ + matchAboutBlank?: boolean; + /** The soonest that the JavaScript will be injected into the tab. Defaults to "document_idle". */ + runAt?: extensionTypes.RunAt; + } + + /** An object that represents a user script registered programmatically */ + interface RegisteredUserScript { + /** Unregister a user script registered programmatically */ + unregister(): Promise; + } + + /** A set of API methods provided by the extensions to its userScripts */ + interface ExportedAPIMethods { + [key: string]: (...args: any[]) => any; + } + + /* userScripts functions */ + /** + * Register a user script programmatically given its `userScripts.UserScriptOptions`, and resolves to a + * `userScripts.RegisteredUserScript` instance + */ + function register(userScriptOptions: UserScriptOptions): Promise; + + /** + * Provides a set of custom API methods available to the registered userScripts + * + * Allowed in: Content scripts only + */ + function setScriptAPIs(exportedAPIMethods: ExportedAPIMethods): void; +} + /** * Use the `browser.webNavigation` API to receive notifications about the status of navigation requests in-flight. * @@ -5302,9 +5401,8 @@ declare namespace browser.devtools.panels { /** * Sets an HTML page to be displayed in the sidebar pane. * @param path Relative path of an extension page to display within the sidebar. - * @deprecated Unsupported on Firefox at this time. */ - setPage?(path: string): void; + setPage(path: _manifest.ExtensionURL): Promise; /** * Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it. @@ -5706,6 +5804,8 @@ declare namespace browser.contextMenus { menuItemId: number | string; /** The parent ID, if any, for the item clicked. */ parentMenuItemId?: number | string; + /** The type of view where the menu is clicked. May be unset if the menu is not associated with a view. */ + viewType?: extension.ViewType; /** * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. */ @@ -5735,6 +5835,8 @@ declare namespace browser.contextMenus { bookmarkId: string; /** An array of keyboard modifiers that were held while the menu item was clicked. */ modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number; /** * An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the * corresponding element. @@ -5749,6 +5851,12 @@ declare namespace browser.contextMenus { | "Ctrl" | "MacCtrl"; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and + * 'tab' are supported. showDefaults cannot be used with this option. + */ + type _OverrideContextContext = "bookmark" | "tab"; + /* contextMenus properties */ /** * The maximum number of top level extension items that can be added to an extension action context menu. Any items @@ -5789,6 +5897,11 @@ declare namespace browser.contextMenus { checked?: boolean; /** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ contexts?: ContextType[]; + /** + * List of view types where the menu item will be shown. Defaults to any view, including those without a + * viewType. + */ + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -5827,9 +5940,13 @@ declare namespace browser.contextMenus { */ function update(id: number | string, updateProperties: { type?: ItemType; + icons?: { + [key: number]: string; + }; title?: string; checked?: boolean; contexts?: ContextType[]; + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -5853,6 +5970,24 @@ declare namespace browser.contextMenus { /** Removes all context menu items added by this extension. */ function removeAll(): Promise; + /** + * Show the matching menu items from this extension instead of the default menu. This should be called during a + * 'contextmenu' DOM event handler, and only applies to the menu that opens after this event. + */ + function overrideContext(contextOptions: { + /** Whether to also include default menu items in the menu. */ + showDefaults?: boolean; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' + * and 'tab' are supported. showDefaults cannot be used with this option. + */ + context?: _OverrideContextContext; + /** Required when context is 'bookmark'. Requires 'bookmark' permission. */ + bookmarkId?: string; + /** Required when context is 'tab'. Requires 'tabs' permission. */ + tabId?: number; + }): void; + /** * Updates the extension items in the shown menu, including changes that have been made since the menu was shown. * Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method @@ -5889,6 +6024,7 @@ declare namespace browser.contextMenus { menuIds: number | string[]; /** A list of all contexts that apply to the menu. */ contexts: ContextType[]; + viewType?: extension.ViewType; editable: boolean; mediaType?: string; linkUrl?: string; @@ -5947,6 +6083,8 @@ declare namespace browser.menus { menuItemId: number | string; /** The parent ID, if any, for the item clicked. */ parentMenuItemId?: number | string; + /** The type of view where the menu is clicked. May be unset if the menu is not associated with a view. */ + viewType?: extension.ViewType; /** * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. */ @@ -5976,6 +6114,8 @@ declare namespace browser.menus { bookmarkId: string; /** An array of keyboard modifiers that were held while the menu item was clicked. */ modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number; /** * An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the * corresponding element. @@ -5990,6 +6130,12 @@ declare namespace browser.menus { | "Ctrl" | "MacCtrl"; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and + * 'tab' are supported. showDefaults cannot be used with this option. + */ + type _OverrideContextContext = "bookmark" | "tab"; + /* menus properties */ /** * The maximum number of top level extension items that can be added to an extension action context menu. Any items @@ -6030,6 +6176,11 @@ declare namespace browser.menus { checked?: boolean; /** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ contexts?: ContextType[]; + /** + * List of view types where the menu item will be shown. Defaults to any view, including those without a + * viewType. + */ + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -6068,9 +6219,13 @@ declare namespace browser.menus { */ function update(id: number | string, updateProperties: { type?: ItemType; + icons?: { + [key: number]: string; + }; title?: string; checked?: boolean; contexts?: ContextType[]; + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -6094,6 +6249,24 @@ declare namespace browser.menus { /** Removes all context menu items added by this extension. */ function removeAll(): Promise; + /** + * Show the matching menu items from this extension instead of the default menu. This should be called during a + * 'contextmenu' DOM event handler, and only applies to the menu that opens after this event. + */ + function overrideContext(contextOptions: { + /** Whether to also include default menu items in the menu. */ + showDefaults?: boolean; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' + * and 'tab' are supported. showDefaults cannot be used with this option. + */ + context?: _OverrideContextContext; + /** Required when context is 'bookmark'. Requires 'bookmark' permission. */ + bookmarkId?: string; + /** Required when context is 'tab'. Requires 'tabs' permission. */ + tabId?: number; + }): void; + /** * Updates the extension items in the shown menu, including changes that have been made since the menu was shown. * Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method @@ -6130,6 +6303,7 @@ declare namespace browser.menus { menuIds: number | string[]; /** A list of all contexts that apply to the menu. */ contexts: ContextType[]; + viewType?: extension.ViewType; editable: boolean; mediaType?: string; linkUrl?: string; @@ -7108,6 +7282,13 @@ declare namespace browser.tabs { function highlight(highlightInfo: { /** The window that contains the tabs. */ windowId?: number; + /** + * If true, the `windows.Window` returned will have a `tabs` property that contains a list of the `tabs.Tab` + * objects. The `Tab` objects only contain the `url`, `title` and `favIconUrl` properties if the extension's + * manifest file includes the `"tabs"` permission. If false, the `windows.Window` won't have the `tabs` + * property. + */ + populate?: boolean; /** One or more tab indices to highlight. */ tabs: number[] | number; }): Promise; @@ -7632,6 +7813,8 @@ declare namespace browser.windows { state?: WindowState; /** Allow scripts to close the window. */ allowScriptsToClose?: boolean; + /** The CookieStoreId to use for all tabs that were created when the window is opened. */ + cookieStoreId?: string; /** A string to add to the beginning of the window title. */ titlePreface?: string; }): Promise; From 316a8c7525ffb36d0fd74f3f0e10c1e8ceb5e80b Mon Sep 17 00:00:00 2001 From: igl00 Date: Sun, 18 Nov 2018 14:34:28 +1300 Subject: [PATCH 59/80] Add declarations for storage modules to store --- types/store/index.d.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/types/store/index.d.ts b/types/store/index.d.ts index 8f46bb9f59..e859491aa0 100644 --- a/types/store/index.d.ts +++ b/types/store/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Vincent Bortone // harry0000 // Roman Nuritdinov (Ky6uk) +// Johnny Edwards (igl00) // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Cross-browser storage for all use cases, used across the web. @@ -25,6 +26,15 @@ interface StoreJsEngine { createStore(storages: any[], plugins?: any[], namespace?: string): StoreJsAPI; } +interface StoreJsStorage { + name: string; + read: (key: string) => string | null; + write: (key: string, data: string) => void; + each: (callback: (val: string, key: string) => any) => void; + remove: (key: string) => void; + clearAll: () => void; +} + declare const store: StoreJsAPI; declare module 'store' { export = store; @@ -73,3 +83,23 @@ declare module 'store/plugins/update' { declare module 'store/plugins/v1-backcompat' { export = Function; } + +declare const storage: StoreJsStorage; +declare module 'store/storages/cookieStorage' { + export = storage; +} +declare module 'store/storages/localStorage' { + export = storage; +} +declare module 'store/storages/memoryStorage' { + export = storage; +} +declare module 'store/storages/oldFF-globalStorage' { + export = storage; +} +declare module 'store/storages/oldIE-userDataStorage' { + export = storage; +} +declare module 'store/storages/sessionStorage' { + export = storage; +} From c3bb846fcd1a179e0d7bce1073ccdcb41c8536c0 Mon Sep 17 00:00:00 2001 From: Alexandre Ferrando Date: Sun, 18 Nov 2018 18:58:17 +0100 Subject: [PATCH 60/80] Add redact to pino options --- types/pino/index.d.ts | 20 ++++++++++++++++++++ types/pino/pino-tests.ts | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index fed6c45253..bea9987832 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -173,6 +173,20 @@ declare namespace P { * Warning: this option may not be supported by downstream transports. */ useOnlyCustomLevels?: boolean; + + /** + * As an array, the redact option specifies paths that should have their values redacted from any log output. + * + * Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation. + * + * If an object is supplied, three options can be specified: + * + * paths (String[]): Required. An array of paths + * censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]' + * remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false + */ + redact?: string[] | redactOptions; + /** * When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`. */ @@ -420,4 +434,10 @@ declare namespace P { (msg: string, ...args: any[]): void; (obj: object, msg?: string, ...args: any[]): void; } + + interface redactOptions { + paths: string[]; + censor?: string; + remove?: boolean; + } } diff --git a/types/pino/pino-tests.ts b/types/pino/pino-tests.ts index c85f2f6873..d3203b5dd4 100644 --- a/types/pino/pino-tests.ts +++ b/types/pino/pino-tests.ts @@ -102,3 +102,24 @@ const handler = pino.final(logExtreme, (err: Error, finalLogger: pino.BaseLogger }); handler(new Error('error')); + +const redacted = pino({ + redact: ['path'] +}); + +redacted.info({ + msg: 'logged with redacted properties', + path: 'Not shown' +}); + +const anotherRedacted = pino({ + redact: { + paths: ['anotherPath'], + censor: 'Not the log you\re looking for' + } +}); + +anotherRedacted.info({ + msg: 'another logged with redacted properties', + anotherPath: 'Not shown' +}); From 4969fe975d1c6cbae81ae2e686b0ed030c990b01 Mon Sep 17 00:00:00 2001 From: Guanyunhan Date: Mon, 19 Nov 2018 14:32:34 +0800 Subject: [PATCH 61/80] update dplayer definition --- types/dplayer/index.d.ts | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/types/dplayer/index.d.ts b/types/dplayer/index.d.ts index a8fbd9e162..048f75904d 100644 --- a/types/dplayer/index.d.ts +++ b/types/dplayer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dplayer 1.24 +// Type definitions for dplayer 1.25.0 // Project: https://github.com/DIYgod/DPlayer#readme // Definitions by: Guanyunhan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -9,6 +9,7 @@ export type Preload = 'none' | 'metadata' | 'auto'; export type VideoType = 'auto' | 'hls' | 'flv' | 'dash' | 'webtorrent' | 'normal'; export type SubTitleType = 'webvtt' | 'ass'; export type DirectionType = 'top' | 'right' | 'bottom'; +export type FullScreenType = 'web' | 'browser'; export enum DPlayerEvents { abort = 'abort', @@ -98,12 +99,20 @@ export interface DPlayerHighLightItem { time: number; } +export interface DPlayerVideoQuality { + name: string; + url: string; + type?: string; +} + export interface DPlayerVideo { url: string; pic?: string; thumbnails?: string; type?: VideoType | string; customType?: any; + quality?: DPlayerVideoQuality[] + defaultQuality?: number; } export interface DPlayerSubTitle { @@ -131,8 +140,31 @@ export interface DPlayerAPIBackend { send(endpoint: any, danmakuData: DPlayerDanmakuItem, callback: () => void): void; } +interface Danmaku { + send(danmaku: DPlayerDanmakuItem, callback: () => void): void; + + draw(danmaku: DPlayerDanmakuItem): void; + + opacity(percentage: number): void; + + clear(): void; + + hide(): void; + + show(): void; +} + +interface FullScreen { + request(type: FullScreenType): void; + + cancel(type: FullScreenType): void; +} + export default class DPlayer { events: any; + video: HTMLVideoElement; + danmaku: Danmaku; + fullScreen: FullScreen; constructor(options: DPlayerOptions); From 2aeaedc61c7e10be046210ff5b7b378aaba17d95 Mon Sep 17 00:00:00 2001 From: Guanyunhan Date: Mon, 19 Nov 2018 14:43:13 +0800 Subject: [PATCH 62/80] fix missing export --- types/dplayer/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/dplayer/index.d.ts b/types/dplayer/index.d.ts index 048f75904d..38cf0e4e54 100644 --- a/types/dplayer/index.d.ts +++ b/types/dplayer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dplayer 1.25.0 +// Type definitions for dplayer 1.25 // Project: https://github.com/DIYgod/DPlayer#readme // Definitions by: Guanyunhan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -111,7 +111,7 @@ export interface DPlayerVideo { thumbnails?: string; type?: VideoType | string; customType?: any; - quality?: DPlayerVideoQuality[] + quality?: DPlayerVideoQuality[]; defaultQuality?: number; } @@ -140,7 +140,7 @@ export interface DPlayerAPIBackend { send(endpoint: any, danmakuData: DPlayerDanmakuItem, callback: () => void): void; } -interface Danmaku { +export interface Danmaku { send(danmaku: DPlayerDanmakuItem, callback: () => void): void; draw(danmaku: DPlayerDanmakuItem): void; @@ -154,7 +154,7 @@ interface Danmaku { show(): void; } -interface FullScreen { +export interface FullScreen { request(type: FullScreenType): void; cancel(type: FullScreenType): void; From a805e58dc2a1fc30163bf44696fa2d06e78f11b6 Mon Sep 17 00:00:00 2001 From: Shrujal Shah Date: Mon, 19 Nov 2018 12:46:25 +0530 Subject: [PATCH 63/80] Add missing semicolon, Add author --- types/google.visualization/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/google.visualization/index.d.ts b/types/google.visualization/index.d.ts index 2912507e08..e5e400bc44 100644 --- a/types/google.visualization/index.d.ts +++ b/types/google.visualization/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Visualisation Apis // Project: https://developers.google.com/chart/ -// Definitions by: Dan Ludwig , Gregory Moore , Dan Manastireanu , Michael Cheng , Ivan Bisultanov , Gleb Mazovetskiy +// Definitions by: Dan Ludwig , Gregory Moore , Dan Manastireanu , Michael Cheng , Ivan Bisultanov , Gleb Mazovetskiy , Shrujal Shah // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace google { @@ -478,7 +478,7 @@ declare namespace google { showColorCode?: boolean; textStyle?: ChartTextStyle; trigger?: string; - ignoreBounds?: boolean + ignoreBounds?: boolean; } export interface ChartBoundingBox { From cdd0c96d0a628ef46a31f862fe05bb39ec5330b7 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Mon, 19 Nov 2018 18:06:42 +0900 Subject: [PATCH 64/80] Fix type for react-intl HoC --- types/react-intl/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 37b652b832..17e738bb2a 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -29,8 +29,8 @@ declare namespace ReactIntl { withRef?: boolean; } - function injectIntl

(component: React.ComponentType

, options?: InjectIntlConfig): - React.ComponentClass>> & { WrappedComponent: React.ComponentType

}; + function injectIntl

(component: React.ComponentType

, options?: InjectIntlConfig): + React.ComponentClass>> & { WrappedComponent: React.ComponentType

}; function addLocaleData(data: Locale[] | Locale): void; From 75c7d2659a7930906996dbabe14230c21bb2b16f Mon Sep 17 00:00:00 2001 From: matt-sungwook Date: Mon, 19 Nov 2018 17:53:01 +0900 Subject: [PATCH 65/80] [@types/nuka-carousel] Update types for v4.4.3 - added disableKeyboardControls to CarouselProps - added pauseOnHover to CarouselProps and CarouselState - sorted props by alphabetical order --- types/nuka-carousel/index.d.ts | 79 ++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/types/nuka-carousel/index.d.ts b/types/nuka-carousel/index.d.ts index 8428f92616..97edd08a6d 100644 --- a/types/nuka-carousel/index.d.ts +++ b/types/nuka-carousel/index.d.ts @@ -1,6 +1,8 @@ -// Type definitions for nuka-carousel 4.3 +// Type definitions for nuka-carousel 4.4 // Project: https://github.com/FormidableLabs/nuka-carousel -// Definitions by: Roman Charugin , Alex Smith +// Definitions by: Roman Charugin +// Alex Smith +// matt-sungwook // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -17,38 +19,23 @@ export type CarouselSlidesToScrollProp = number | 'auto'; export type CarouselSlideWidthProp = string | number; export interface CarouselSlideRenderControlProps { + /** + * Space between slides, as an integer, but reflected as px + */ + cellSpacing: number; /** * Current slide index */ currentSlide: number; - /** - * Total amount of slides - */ - slideCount: number; /** * Current frame width (px) */ frameWidth: number; /** - * Current slide width (px) + * Go to X slide method + * @param index Slide's index to go */ - slideWidth: number; - /** - * Slides to scroll at once - */ - slidesToScroll: number; - /** - * Space between slides, as an integer, but reflected as px - */ - cellSpacing: number; - /** - * Slides to show at once - */ - slidesToShow: number; - /** - * Infinite mode enabled - */ - wrapAround: boolean; + goToSlide: (index: number) => void; /** * Go to the next slide method */ @@ -58,10 +45,25 @@ export interface CarouselSlideRenderControlProps { */ previousSlide: () => void; /** - * Go to X slide method - * @param index Slide's index to go + * Total amount of slides */ - goToSlide: (index: number) => void; + slideCount: number; + /** + * Slides to scroll at once + */ + slidesToScroll: number; + /** + * Slides to show at once + */ + slidesToShow: number; + /** + * Current slide width (px) + */ + slideWidth: number; + /** + * Infinite mode enabled + */ + wrapAround: boolean; } export type CarouselRenderControl = (props: CarouselSlideRenderControlProps) => JSX.Element; @@ -101,6 +103,11 @@ export interface CarouselProps { * Additional className */ className?: string; + /** + * When set to true, disable keyboard controls + * @default false + */ + disableKeyboardControls?: boolean; /** * Enable mouse swipe/dragging */ @@ -144,6 +151,11 @@ export interface CarouselProps { * Window onResize callback */ onResize?: () => void; + /** + * Pause autoPlay when mouse is over carousel + * @default true + */ + pauseOnHover?: boolean; /** * Function for rendering top left control */ @@ -238,6 +250,10 @@ export interface CarouselState { * Is dragging enabled */ dragging: boolean; + /** + * Easing function name + */ + easing: string; /** * Current frame width */ @@ -245,7 +261,10 @@ export interface CarouselState { /** * Current left value */ + isWrappingAround: boolean; left: number; + pauseOnHover: boolean; + resetWrapAroundPosition: boolean; /** * Total amount of slides */ @@ -262,14 +281,8 @@ export interface CarouselState { * Current top value */ top: number; - /** - * Easing function name - */ - easing: string; /** * Is infinite mode enabled */ - isWrappingAround: boolean; wrapToIndex: boolean; - resetWrapAroundPosition: boolean; } From 7d7187145597bd79e4b71be3c9badbd9e75d49c7 Mon Sep 17 00:00:00 2001 From: Keisuke Kan <9renpoto@gmail.com> Date: Mon, 19 Nov 2018 21:04:56 +0900 Subject: [PATCH 66/80] Fixed redisClient.zincrby callback --- types/redis/index.d.ts | 4 ++-- types/redis/redis-tests.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/redis/index.d.ts b/types/redis/index.d.ts index ff071e43e4..b838fcc1e9 100644 --- a/types/redis/index.d.ts +++ b/types/redis/index.d.ts @@ -1025,8 +1025,8 @@ export interface Commands { /** * Increment the score of a member in a sorted set. */ - zincrby(key: string, increment: number, member: string, cb?: Callback): R; - ZINCRBY(key: string, increment: number, member: string, cb?: Callback): R; + zincrby(key: string, increment: number, member: string, cb?: Callback): R; + ZINCRBY(key: string, increment: number, member: string, cb?: Callback): R; /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. diff --git a/types/redis/redis-tests.ts b/types/redis/redis-tests.ts index 18b9e11203..5d7d617b91 100644 --- a/types/redis/redis-tests.ts +++ b/types/redis/redis-tests.ts @@ -131,3 +131,5 @@ client.incrbyfloat('a', 1.5, (error, value) => value.startsWith('1')); client.INCRBYFLOAT('a', 1.5, (error, value) => value.startsWith('1')); client.hincrbyfloat('a', 'b', 1.5, (error, value) => value.startsWith('1')); client.HINCRBYFLOAT('a', 'b', 1.5, (error, value) => value.startsWith('1')); +client.zincrby('a', 1, 'b', strCallback); +client.ZINCRBY('a', 1, 'b', strCallback); From ebd2413635e8d9eec9e92d62ba72ae808846f529 Mon Sep 17 00:00:00 2001 From: Adam Binford Date: Mon, 19 Nov 2018 09:53:45 -0500 Subject: [PATCH 67/80] Updated country-list types to work with 2.1 --- types/country-list/country-list-tests.ts | 5 +- types/country-list/index.d.ts | 66 +++++++++++++----------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/types/country-list/country-list-tests.ts b/types/country-list/country-list-tests.ts index d96fe630e2..50952d2a87 100644 --- a/types/country-list/country-list-tests.ts +++ b/types/country-list/country-list-tests.ts @@ -1,5 +1,4 @@ -import countries from 'country-list'; -const Countries = countries(); +import * as Countries from 'country-list'; Countries.getCode('Barbados'); // BB @@ -14,3 +13,5 @@ Countries.getName('BB'); // Barbados Countries.getNameList(); Countries.getNames(); + +Countries.overwrite([{ code: 'TW', name: 'Taiwan' }]); diff --git a/types/country-list/index.d.ts b/types/country-list/index.d.ts index 6c1747ff2a..2342bf81e3 100644 --- a/types/country-list/index.d.ts +++ b/types/country-list/index.d.ts @@ -1,41 +1,45 @@ -// Type definitions for country-list 1.1 +// Type definitions for country-list 2.1 // Project: https://github.com/fannarsh/country-list // Definitions by: Kyle Roach +// Adam Binford // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default function Countries(): { - /** - * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. - */ - getName(code: string): string | undefined; +/** + * Expects an array of code and country name pairs to add to the list. Doesn't return anything. + */ +export function overwrite(countries: Array<{ code: string, name: string}>): undefined; - /** - * Expects the English country name. Returns the code for that country. If not found, it returns undefined. - */ - getCode(name: string): string | undefined; +/** + * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. + */ +export function getName(code: string): string | undefined; - /** - * Returns an array of all country names. - */ - getNames(): string[]; +/** + * Expects the English country name. Returns the code for that country. If not found, it returns undefined. + */ +export function getCode(name: string): string | undefined; - /** - * Returns an array of all country codes. - */ - getCodes(): string[]; +/** + * Returns an array of all country names. + */ +export function getNames(): string[]; - /** - * Returns a key-value object of all countries using the name as key. - */ - getNameList(): {[name: string]: string}; +/** + * Returns an array of all country codes. + */ +export function getCodes(): string[]; - /** - * Returns a key-value object of all countries using the code as key. - */ - getCodeList(): {[code: string]: string}; +/** + * Returns a key-value object of all countries using the name as key. + */ +export function getNameList(): {[name: string]: string}; - /** - * Returns an array of all country information, in the same format as it gets imported. - */ - getData(): Array<{ code: string, name: string }>; -}; +/** + * Returns a key-value object of all countries using the code as key. + */ +export function getCodeList(): {[code: string]: string}; + +/** + * Returns an array of all country information, in the same format as it gets imported. + */ +export function getData(): Array<{ code: string, name: string }>; From a6b3615198ac558b94e5f5bde6e8a6a31eec8f08 Mon Sep 17 00:00:00 2001 From: Adam Binford Date: Mon, 19 Nov 2018 12:33:59 -0500 Subject: [PATCH 68/80] Added back v1 types --- types/country-list/v1/country-list-tests.ts | 16 ++++++++ types/country-list/v1/index.d.ts | 41 +++++++++++++++++++++ types/country-list/v1/tsconfig.json | 26 +++++++++++++ types/country-list/v1/tslint.json | 1 + 4 files changed, 84 insertions(+) create mode 100644 types/country-list/v1/country-list-tests.ts create mode 100644 types/country-list/v1/index.d.ts create mode 100644 types/country-list/v1/tsconfig.json create mode 100644 types/country-list/v1/tslint.json diff --git a/types/country-list/v1/country-list-tests.ts b/types/country-list/v1/country-list-tests.ts new file mode 100644 index 0000000000..d96fe630e2 --- /dev/null +++ b/types/country-list/v1/country-list-tests.ts @@ -0,0 +1,16 @@ +import countries from 'country-list'; +const Countries = countries(); + +Countries.getCode('Barbados'); // BB + +Countries.getCodes(); + +Countries.getCodeList(); + +Countries.getData(); + +Countries.getName('BB'); // Barbados + +Countries.getNameList(); + +Countries.getNames(); diff --git a/types/country-list/v1/index.d.ts b/types/country-list/v1/index.d.ts new file mode 100644 index 0000000000..e225845bde --- /dev/null +++ b/types/country-list/v1/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for country-list 1.1 +// Project: https://github.com/fannarsh/country-list +// Definitions by: Kyle Roach +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default function Countries(): { + /** + * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. + */ + getName(code: string): string | undefined; + + /** + * Expects the English country name. Returns the code for that country. If not found, it returns undefined. + */ + getCode(name: string): string | undefined; + + /** + * Returns an array of all country names. + */ + getNames(): string[]; + + /** + * Returns an array of all country codes. + */ + getCodes(): string[]; + + /** + * Returns a key-value object of all countries using the name as key. + */ + getNameList(): {[name: string]: string}; + + /** + * Returns a key-value object of all countries using the code as key. + */ + getCodeList(): {[code: string]: string}; + + /** + * Returns an array of all country information, in the same format as it gets imported. + */ + getData(): Array<{ code: string, name: string }>; +}; diff --git a/types/country-list/v1/tsconfig.json b/types/country-list/v1/tsconfig.json new file mode 100644 index 0000000000..f10adfdde5 --- /dev/null +++ b/types/country-list/v1/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "country-list": ["country-list/v1"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "country-list-tests.ts" + ] +} \ No newline at end of file diff --git a/types/country-list/v1/tslint.json b/types/country-list/v1/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/country-list/v1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From a08b0003813d348a3e1f05d91f33786737b08dfe Mon Sep 17 00:00:00 2001 From: Hamid Date: Mon, 19 Nov 2018 23:30:47 +0330 Subject: [PATCH 69/80] Fixes missing a word in doc Fixes missing a word in `itemVisiblePercentThreshold` doc. --- types/react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index b8fa8d2af6..2386fc71c2 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3848,7 +3848,7 @@ export interface ViewabilityConfig { viewAreaCoveragePercentThreshold?: number; /** - * Similar to `viewAreaPercentThreshold`, but considers the percent of the item that is visible, + * Similar to `viewAreaCoveragePercentThreshold`, but considers the percent of the item that is visible, * rather than the fraction of the viewable area it covers. */ itemVisiblePercentThreshold?: number; From 6337d2eba3b7bc10ba6794a57b68a5f946a48039 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 19 Nov 2018 14:28:14 -0800 Subject: [PATCH 70/80] fix(sinon): stub.callsFake should accept parameters --- types/sinon/index.d.ts | 2 +- types/sinon/sinon-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 95dded91e5..5587b7c931 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -524,7 +524,7 @@ declare namespace Sinon { * Makes the stub call the provided @param func when invoked. * @param func */ - callsFake(func: () => TReturnValue): SinonStub; + callsFake(func: (...args: any[]) => TReturnValue): SinonStub; /** * Replaces a new getter for this stub. */ diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 8ae53c7d8e..cb903c1a7b 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -422,7 +422,7 @@ function testStub() { stub.callsArgOnAsync(1, instance); stub.callsArgWithAsync(1, 'a', 2); stub.callsArgOnWithAsync(1, instance, 'a', 2); - stub.callsFake(() => { }); + stub.callsFake((s1, s2, s3) => { }); stub.get(() => true); stub.set((v) => { }); stub.onCall(1).returns(true); From d57fdfb4e5cf75056b0ba85aad5024559f5c97fc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 19 Nov 2018 15:56:04 -0800 Subject: [PATCH 71/80] Fix mali dependents Mali dependents weren't updated when it was removed. This changes adds mali and its peer dependencies to package.json for mali-onerror and mali-compose. --- types/mali-compose/package.json | 8 ++++++++ types/mali-onerror/package.json | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 types/mali-compose/package.json create mode 100644 types/mali-onerror/package.json diff --git a/types/mali-compose/package.json b/types/mali-compose/package.json new file mode 100644 index 0000000000..76d151fcec --- /dev/null +++ b/types/mali-compose/package.json @@ -0,0 +1,8 @@ +{ + "private": true, + "dependencies": { + "grpc": "^1.16.1", + "mali": "^0.10.2", + "protobufjs": "^6.8.8" + } +} diff --git a/types/mali-onerror/package.json b/types/mali-onerror/package.json new file mode 100644 index 0000000000..76d151fcec --- /dev/null +++ b/types/mali-onerror/package.json @@ -0,0 +1,8 @@ +{ + "private": true, + "dependencies": { + "grpc": "^1.16.1", + "mali": "^0.10.2", + "protobufjs": "^6.8.8" + } +} From 80edf8fcad75f6299bc2a47c757a0a8577fe8866 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 19 Nov 2018 16:52:58 -0800 Subject: [PATCH 72/80] pr feedback --- types/sinon/sinon-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index cb903c1a7b..d5ae4b0eb2 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -423,6 +423,7 @@ function testStub() { stub.callsArgWithAsync(1, 'a', 2); stub.callsArgOnWithAsync(1, instance, 'a', 2); stub.callsFake((s1, s2, s3) => { }); + stub.callsFake(() => { }); stub.get(() => true); stub.set((v) => { }); stub.onCall(1).returns(true); From f95792a103afd4a56206ac9d47aff427f165b967 Mon Sep 17 00:00:00 2001 From: Adam Binford Date: Tue, 20 Nov 2018 09:06:35 -0500 Subject: [PATCH 73/80] Country-list: changed overwrite return to void --- types/country-list/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/country-list/index.d.ts b/types/country-list/index.d.ts index 2342bf81e3..ac3c80c9d5 100644 --- a/types/country-list/index.d.ts +++ b/types/country-list/index.d.ts @@ -7,7 +7,7 @@ /** * Expects an array of code and country name pairs to add to the list. Doesn't return anything. */ -export function overwrite(countries: Array<{ code: string, name: string}>): undefined; +export function overwrite(countries: Array<{ code: string, name: string}>): void; /** * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. From ef9817f42df725cc8f25e4e9540ef6ff9d6b1ac2 Mon Sep 17 00:00:00 2001 From: John Wood Date: Mon, 19 Nov 2018 09:44:29 +0000 Subject: [PATCH 74/80] Calls fake passes throught the arguments --- types/sinon/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 5587b7c931..9786e82edd 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -156,9 +156,9 @@ declare namespace Sinon { interface SinonSpy extends Pick< - SinonSpyCallApi, - Exclude, 'args'> - > { + SinonSpyCallApi, + Exclude, 'args'> + > { // Properties /** * The number of recorded calls. @@ -524,7 +524,7 @@ declare namespace Sinon { * Makes the stub call the provided @param func when invoked. * @param func */ - callsFake(func: (...args: any[]) => TReturnValue): SinonStub; + callsFake(func: (...args: TArgs) => TReturnValue): SinonStub; /** * Replaces a new getter for this stub. */ From 8c45ec4ae03d203cbf658ea168031344eb797d1f Mon Sep 17 00:00:00 2001 From: John Wood Date: Tue, 20 Nov 2018 15:41:52 +0000 Subject: [PATCH 75/80] Remove unintended format change --- types/sinon/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 9786e82edd..b5c3952e7a 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -156,9 +156,9 @@ declare namespace Sinon { interface SinonSpy extends Pick< - SinonSpyCallApi, - Exclude, 'args'> - > { + SinonSpyCallApi, + Exclude, 'args'> + > { // Properties /** * The number of recorded calls. From 0fb81a6bf872a3ff87fff855082e13bab827d7ea Mon Sep 17 00:00:00 2001 From: licui Date: Tue, 20 Nov 2018 10:50:01 -0500 Subject: [PATCH 76/80] Moving importing types into the namespace "fin" --- types/openfin/index.d.ts | 61 ++++++++++++++++++++-------------- types/openfin/openfin-tests.ts | 2 -- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts index 04342ada0c..55ee5b6741 100644 --- a/types/openfin/index.d.ts +++ b/types/openfin/index.d.ts @@ -24,31 +24,6 @@ * When running within the OpenFin Runtime your web applications have access to the "fin" namespace and all the modules within the API * without the need to include additional source files. You can treat the "fin" namespace as you would the "window", "navigator" or "documennt" objects. */ -import { Identity } from './_v2/identity'; -import { ApplicationInfo as LaunchInfo, ShortCutConfig, TrayInfo } from './_v2/api/application/application'; -import { ApplicationOption } from './_v2/api/application/applicationOption'; -import { ExternalApplicationInfo } from './_v2/api/external-application/external-application'; -import { ApplicationInfo } from './_v2/api/system/application'; -import { ClearCacheOption } from './_v2/api/system/clearCacheOption'; -import { CookieInfo, CookieOption } from './_v2/api/system/cookie'; -import { AppAssetInfo, AppAssetRequest, RuntimeDownloadOptions, RuntimeDownloadProgress } from './_v2/api/system/download-asset'; -import { DownloadPreloadInfo, DownloadPreloadOption } from './_v2/api/system/download-preload'; -import { EntityInfo } from './_v2/api/system/entity'; -import { ExternalProcessRequestType, ExternalProcessInfo } from './_v2/api/system/external-process'; -import { HostSpecs } from './_v2/api/system/host-specs'; -import { LogInfo } from './_v2/api/system/log'; -import { MonitorInfo } from './_v2/api/system/monitor'; -import { PointTopLeft } from './_v2/api/system/point'; -import { ProcessInfo } from './_v2/api/system/process'; -import { ProxyInfo } from './_v2/api/system/proxy'; -import { RegistryInfo } from './_v2/api/system/registry-info'; -import { RVMInfo} from './_v2/api/system/rvm'; -import { WindowDetail, WindowInfo } from './_v2/api/system/window'; -import { AnchorType } from './_v2/api/window/anchor-type'; -import Bounds from './_v2/api/window/bounds'; -import { Transition, TransitionOptions } from './_v2/api/window/transition'; -import { WindowOption } from './_v2/api/window/windowOption'; - declare namespace fin { var Application: import('./_v2/api/application/application').default; var Clipboard: import('./_v2/api/clipboard/clipboard').default; @@ -60,6 +35,42 @@ declare namespace fin { var System: import('./_v2/api/system/system').default; var Window: import('./_v2/api/window/window').default; + // v2 shapes + type Identity = import('./_v2/identity').Identity; + type LaunchInfo = import('./_v2/api/application/application').ApplicationInfo; + type ShortCutConfig = import('./_v2/api/application/application').ShortCutConfig; + type TrayInfo = import('./_v2/api/application/application').TrayInfo; + type ApplicationOption = import('./_v2/api/application/applicationOption').ApplicationOption; + type ExternalApplicationInfo = import('./_v2/api/external-application/external-application').ExternalApplicationInfo; + type ApplicationInfo = import('./_v2/api/system/application').ApplicationInfo; + type ClearCacheOption = import('./_v2/api/system/clearCacheOption').ClearCacheOption; + type CookieInfo = import('./_v2/api/system/cookie').CookieInfo; + type CookieOption = import('./_v2/api/system/cookie').CookieOption; + type AppAssetInfo = import('./_v2/api/system/download-asset').AppAssetInfo; + type AppAssetRequest = import('./_v2/api/system/download-asset').AppAssetRequest; + type RuntimeDownloadOptions = import('./_v2/api/system/download-asset').RuntimeDownloadOptions; + type RuntimeDownloadProgress = import('./_v2/api/system/download-asset').RuntimeDownloadProgress; + type DownloadPreloadInfo = import('./_v2/api/system/download-preload').DownloadPreloadInfo; + type DownloadPreloadOption = import('./_v2/api/system/download-preload').DownloadPreloadOption; + type EntityInfo = import('./_v2/api/system/entity').EntityInfo; + type ExternalProcessRequestType = import('./_v2/api/system/external-process').ExternalProcessRequestType; + type ExternalProcessInfo = import('./_v2/api/system/external-process').ExternalProcessInfo; + type HostSpecs = import('./_v2/api/system/host-specs').HostSpecs; + type LogInfo = import('./_v2/api/system/log').LogInfo; + type MonitorInfo = import('./_v2/api/system/monitor').MonitorInfo; + type PointTopLeft = import('./_v2/api/system/point').PointTopLeft; + type ProcessInfo = import('./_v2/api/system/process').ProcessInfo; + type ProxyInfo = import('./_v2/api/system/proxy').ProxyInfo; + type RegistryInfo = import('./_v2/api/system/registry-info').RegistryInfo; + type RVMInfo = import('./_v2/api/system/rvm').RVMInfo; + type WindowDetail = import('./_v2/api/system/window').WindowDetail; + type WindowInfo = import('./_v2/api/system/window').WindowInfo; + type AnchorType = import('./_v2/api/window/anchor-type').AnchorType; + type Bounds = import('./_v2/api/window/bounds').default; + type Transition = import('./_v2/api/window/transition').Transition; + type TransitionOptions = import('./_v2/api/window/transition').TransitionOptions; + type WindowOption = import('./_v2/api/window/windowOption').WindowOption; + const desktop: OpenFinDesktop; interface OpenFinDesktop { diff --git a/types/openfin/openfin-tests.ts b/types/openfin/openfin-tests.ts index c02700f2fb..167a6c86be 100644 --- a/types/openfin/openfin-tests.ts +++ b/types/openfin/openfin-tests.ts @@ -1,5 +1,3 @@ -import { fin } from "openfin"; - function test_application() { let application: fin.OpenFinApplication; // constructor From 0310a1b3b081987d3dfcd9b87711dbdf6cca1034 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Humpert Date: Tue, 20 Nov 2018 17:45:24 +0100 Subject: [PATCH 77/80] Definitions follow (d)tslint rules --- types/karma-fixture/index.d.ts | 34 +++++++-------- types/karma-fixture/tslint.json | 75 +-------------------------------- 2 files changed, 18 insertions(+), 91 deletions(-) diff --git a/types/karma-fixture/index.d.ts b/types/karma-fixture/index.d.ts index d89172b65f..d443359d72 100644 --- a/types/karma-fixture/index.d.ts +++ b/types/karma-fixture/index.d.ts @@ -1,28 +1,28 @@ -// Type definitions for karma-fixture 0.2.6 +// Type definitions for karma-fixture 0.2 // Project: https://github.com/billtrik/karma-fixture // Definitions by: Ezekiel Victor // Afshawn Lotfi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace fixture { - export var el: HTMLElement; - export var json: any[]; + let el: HTMLElement; + let json: any[]; - export function load(...files: string[]): any; - export function load(file1: string, append?: boolean): any; - export function load(file1: string, file2: string, append?: boolean): any; - export function load(file1: string, file2: string, file3: string, append?: boolean): any; - export function load(file1: string, file2: string, file3: string, file4: string, append?: boolean): any; - export function load(file1: string, file2: string, file3: string, file4: string, file5: string, append?: boolean): any; + function load(...files: string[]): any; + function load(file1: string, append?: boolean): any; + function load(file1: string, file2: string, append?: boolean): any; + function load(file1: string, file2: string, file3: string, append?: boolean): any; + function load(file1: string, file2: string, file3: string, file4: string, append?: boolean): any; + function load(file1: string, file2: string, file3: string, file4: string, file5: string, append?: boolean): any; - export function set(...htmlStrs: string[]): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, htmlStr5: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(...htmlStrs: string[]): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, htmlStr5: string, append?: boolean): HTMLElement|HTMLElement[]; - export function cleanup(): void; + function cleanup(): void; - export function setBase(fixtureBasePath: string): void; + function setBase(fixtureBasePath: string): void; } diff --git a/types/karma-fixture/tslint.json b/types/karma-fixture/tslint.json index a41bf5d19a..6a811499e6 100644 --- a/types/karma-fixture/tslint.json +++ b/types/karma-fixture/tslint.json @@ -1,79 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "trim-file": false } } From dde668f818721298a5062ae860a65ceb00cf0227 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 20 Nov 2018 08:54:34 -0800 Subject: [PATCH 78/80] grpc requires TS2.3 for type parameter defaults --- types/mali-compose/index.d.ts | 2 +- types/mali-onerror/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/mali-compose/index.d.ts b/types/mali-compose/index.d.ts index 87b23087d3..c70ee7557b 100644 --- a/types/mali-compose/index.d.ts +++ b/types/mali-compose/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/malijs/mali-compose // Definitions by: Daniel Byrne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 import { Context } from "mali"; diff --git a/types/mali-onerror/index.d.ts b/types/mali-onerror/index.d.ts index c9600d50f0..6fa37b9862 100644 --- a/types/mali-onerror/index.d.ts +++ b/types/mali-onerror/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/malijs/onerror // Definitions by: Daniel Byrne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 import { Context } from "mali"; From cf51044fc6a043908e01f1e90290dfd9b4270cab Mon Sep 17 00:00:00 2001 From: Kai-Uwe Humpert Date: Tue, 20 Nov 2018 17:59:27 +0100 Subject: [PATCH 79/80] Be fully tslint compliant --- types/karma-fixture/karma-fixture-tests.ts | 1 - types/karma-fixture/tslint.json | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/types/karma-fixture/karma-fixture-tests.ts b/types/karma-fixture/karma-fixture-tests.ts index d8ea8c8794..2096298eb9 100644 --- a/types/karma-fixture/karma-fixture-tests.ts +++ b/types/karma-fixture/karma-fixture-tests.ts @@ -1,4 +1,3 @@ - fixture.setBase('fixtures/base/path'); fixture.load('test1.html', 'test1.json', false); fixture.load('test1.html', 'test2.html', 'test1.json'); diff --git a/types/karma-fixture/tslint.json b/types/karma-fixture/tslint.json index 6a811499e6..f93cf8562a 100644 --- a/types/karma-fixture/tslint.json +++ b/types/karma-fixture/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "trim-file": false - } + "extends": "dtslint/dt.json" } From afd53b56ccb8e5cbd719575d34a996589fca4c12 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 20 Nov 2018 09:12:00 -0800 Subject: [PATCH 80/80] Fix unrelated lints --- types/ember/test/transition.ts | 2 +- types/ember/v2/test/transition.ts | 2 +- types/ssh2/ssh2-tests.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/ember/test/transition.ts b/types/ember/test/transition.ts index f06ee8865e..f6f3e0b4f0 100755 --- a/types/ember/test/transition.ts +++ b/types/ember/test/transition.ts @@ -11,7 +11,7 @@ Ember.Route.extend({ }); Ember.Controller.extend({ - previousTransition: null, + previousTransition: null as Transition | null, actions: { login() { diff --git a/types/ember/v2/test/transition.ts b/types/ember/v2/test/transition.ts index 3a64675c24..40057d9828 100755 --- a/types/ember/v2/test/transition.ts +++ b/types/ember/v2/test/transition.ts @@ -10,7 +10,7 @@ Ember.Route.extend({ }); Ember.Controller.extend({ - previousTransition: null, + previousTransition: null as Ember.Transition | null, actions: { login() { diff --git a/types/ssh2/ssh2-tests.ts b/types/ssh2/ssh2-tests.ts index e6d03e939f..432fad281d 100644 --- a/types/ssh2/ssh2-tests.ts +++ b/types/ssh2/ssh2-tests.ts @@ -313,7 +313,7 @@ var buffersEqual = require('buffer-equal-constant-time'), //ssh2 = require('ssh2'), utils = ssh2.utils; -var pubKey = utils.genPublicKey(utils.parseKey(fs.readFileSync('user.pub'))); +var pubKey = utils.genPublicKey(utils.parseKey(fs.readFileSync('user.pub')) as ssh2_streams.ParsedKey); new ssh2.Server({ hostKeys: [fs.readFileSync('host.key')]