From 7c0c4e8419f82c5ab1db88e24372d39cfcc97a3b Mon Sep 17 00:00:00 2001 From: Anton Vasin Date: Wed, 19 Dec 2018 16:35:06 +0300 Subject: [PATCH 01/69] Update styled-system types to 3.1 --- types/styled-system/dist/util.d.ts | 2 +- types/styled-system/index.d.ts | 13 ++----------- types/styled-system/styled-system-tests.tsx | 10 +++++++++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/types/styled-system/dist/util.d.ts b/types/styled-system/dist/util.d.ts index 445bb81567..8fa2642e62 100644 --- a/types/styled-system/dist/util.d.ts +++ b/types/styled-system/dist/util.d.ts @@ -12,7 +12,7 @@ export function merge(a: any, b: any): any; export function compose(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; -export function createMediaQuery(n: string): string; +export function createMediaQuery(n: any): string; export interface LowLevelStylefunctionArguments { prop: string; diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index 2511fbb99c..4eaf0e8a84 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for styled-system 3.0 +// Type definitions for styled-system 3.1 // Project: https://github.com/jxnblk/styled-system#readme // Definitions by: Marshall Bowers // Ben McCormick @@ -11,16 +11,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as util from './dist/util'; - -export { util }; -export { - style, - themeGet, - merge, - compose, -} from './dist/util'; - +export * from './dist/util'; export * from './dist/styles'; export * from './dist/variant'; export * from './dist/mixed'; diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index 756dd0c039..4608aeebec 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -122,12 +122,20 @@ import { ButtonStyleProps, MixedProps, VerticalAlignProps, - verticalAlign + verticalAlign, + px, + createMediaQuery } from "styled-system"; // tslint:disable-next-line:strict-export-declare-modifiers declare const styled: (...props: any[]) => React.ComponentType; +const breakpoints = [480, 960]; + +const breakpointsPx = breakpoints.map(px); + +const mediaQueries = breakpoints.map(createMediaQuery); + const boxStyle = variant({ prop: 'boxStyle', key: 'box', From 82691532741fb0b5c8485111ae44c2de9d7f802f Mon Sep 17 00:00:00 2001 From: Anton Vasin Date: Wed, 19 Dec 2018 17:04:43 +0300 Subject: [PATCH 02/69] Move styled-system into single file to reflect actual package structure --- types/styled-system/dist/mixed.d.ts | 7 - types/styled-system/dist/space.d.ts | 46 -- types/styled-system/dist/styles.d.ts | 836 ----------------------- types/styled-system/dist/util.d.ts | 26 - types/styled-system/dist/variant.d.ts | 7 - types/styled-system/index.d.ts | 936 +++++++++++++++++++++++++- 6 files changed, 932 insertions(+), 926 deletions(-) delete mode 100644 types/styled-system/dist/mixed.d.ts delete mode 100644 types/styled-system/dist/space.d.ts delete mode 100644 types/styled-system/dist/styles.d.ts delete mode 100644 types/styled-system/dist/util.d.ts delete mode 100644 types/styled-system/dist/variant.d.ts diff --git a/types/styled-system/dist/mixed.d.ts b/types/styled-system/dist/mixed.d.ts deleted file mode 100644 index 25f115aa55..0000000000 --- a/types/styled-system/dist/mixed.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface MixedProps { - key?: any; - // Defaults to "variant" - prop?: string; -} - -export function mixed(...args: any[]): any; diff --git a/types/styled-system/dist/space.d.ts b/types/styled-system/dist/space.d.ts deleted file mode 100644 index 9632ed7e45..0000000000 --- a/types/styled-system/dist/space.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as CSS from 'csstype'; -export type TLengthStyledSystem = string | 0 | number; -export type ResponsiveValue = T | Array; - -/** - * Converts shorthand margin and padding props to margin and padding CSS declarations - * - * - Numbers from 0-4 (or the length of theme.space) are converted to values on the spacing scale. - * - Negative values can be used for negative margins. - * - Numbers greater than the length of the theme.space array are converted to raw pixel values. - * - String values are passed as raw CSS values. - * - Array values are converted into responsive values. - */ - -export interface SpaceProps { - /** Margin on top, left, bottom and right */ - m?: ResponsiveValue>; - /** Margin for the top */ - mt?: ResponsiveValue>; - /** Margin for the right */ - mr?: ResponsiveValue>; - /** Margin for the bottom */ - mb?: ResponsiveValue>; - /** Margin for the left */ - ml?: ResponsiveValue>; - /** Margin for the left and right */ - mx?: ResponsiveValue>; - /** Margin for the top and bottom */ - my?: ResponsiveValue>; - /** Padding on top, left, bottom and right */ - p?: ResponsiveValue>; - /** Padding for the top */ - pt?: ResponsiveValue>; - /** Padding for the right */ - pr?: ResponsiveValue>; - /** Padding for the bottom */ - pb?: ResponsiveValue>; - /** Padding for the left */ - pl?: ResponsiveValue>; - /** Padding for the left and right */ - px?: ResponsiveValue>; - /** Padding for the top and bottom */ - py?: ResponsiveValue>; -} - -export function space(...args: any[]): any; diff --git a/types/styled-system/dist/styles.d.ts b/types/styled-system/dist/styles.d.ts deleted file mode 100644 index 59f8077ec9..0000000000 --- a/types/styled-system/dist/styles.d.ts +++ /dev/null @@ -1,836 +0,0 @@ -import * as CSS from 'csstype'; -import { ResponsiveValue, TLengthStyledSystem } from './space'; - -export * from './space'; - -export interface BaseTheme { - breakpoints?: number[]; - space?: number[]; - fontSizes?: number[]; - colors?: { - [name: string]: string; - }; -} - -/** - * Font Size - */ - -export interface FontSizeProps { - /** - * The fontSize utility parses a component's `fontSize` prop and converts it into a CSS font-size declaration. - * - * - Numbers from 0-8 (or `theme.fontSizes.length`) are converted to values on the [font size scale](#default-theme). - * - Numbers greater than `theme.fontSizes.length` are converted to raw pixel values. - * - String values are passed as raw CSS values. - * - And array values are converted into responsive values. - * - */ - fontSize?: ResponsiveValue>; -} - -export function fontSize(...args: any[]): any; - -/** - * Color - */ - -export interface TextColorProps { - /** - * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. - * By default the raw value of the prop is returned. - * - * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. - * Array values are converted into responsive values. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/color) - */ - color?: ResponsiveValue; -} - -export function textColor(...args: any[]): any; - -export interface BgColorProps { - /** - * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. - * By default the raw value of the prop is returned. - * - * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. - * Array values are converted into responsive values. - * - * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) - */ - bg?: ResponsiveValue>; -} - -export function bgColor(...args: any[]): any; - -export interface ColorProps extends TextColorProps, BgColorProps {} - -export function color(...args: any[]): any; - -/** - * Typography - */ -export interface FontFamilyProps { - fontFamily?: ResponsiveValue; -} -export function fontFamily(...args: any[]): any; - -export interface TextAlignProps { - /** - * The text-align CSS property specifies the horizontal alignment of an inline or table-cell box. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) - */ - textAlign?: ResponsiveValue; -} - -export function textAlign(...args: any[]): any; - -export interface LineHeightProps { - /** - * The line-height CSS property sets the amount of space used for lines, such as in text. On block-level elements, - * it specifies the minimum height of line boxes within the element. - * - * On non-replaced inline elements, it specifies the height that is used to calculate line box height. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) - */ - lineHeight?: ResponsiveValue>; -} -export function lineHeight(...args: any[]): any; - -export interface FontWeightProps { - /** - * The font-weight CSS property specifies the weight (or boldness) of the font. - * - * The font weights available to you will depend on the font-family you are using. Some fonts are only available in normal and bold. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) - */ - fontWeight?: ResponsiveValue; -} - -export function fontWeight(...args: any[]): any; - -export interface FontStyleProps { - /** - * The font-style CSS property specifies whether a font should be styled with a normal, italic, - * or oblique face from its font-family. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) - */ - fontStyle?: ResponsiveValue; -} -export function fontStyle(...args: any[]): any; - -export interface LetterSpacingProps { - /** - * The letter-spacing CSS property sets the spacing behavior between text characters. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) - */ - letterSpacing?: ResponsiveValue>; -} -export function letterSpacing(...args: any[]): any; - -/** - * Layout - */ - -export interface DisplayProps { - /** - * The display CSS property defines the display type of an element, which consists of the two basic qualities - * of how an element generates boxes — the outer display type defining how the box participates in flow layout, - * and the inner display type defining how the children of the box are laid out. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) - */ - display?: ResponsiveValue; -} - -export function display(...args: any[]): any; - -export interface MaxWidthProps { - /** - * The max-width CSS property sets the maximum width of an element. - * It prevents the used value of the width property from becoming larger than the value specified by max-width. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) - */ - maxWidth?: ResponsiveValue>; -} - -export function maxWidth(...args: any[]): any; - -export interface MinWidthProps { - /** - * The min-width CSS property sets the minimum width of an element. - * It prevents the used value of the width property from becoming smaller than the value specified for min-width. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) - */ - minWidth?: ResponsiveValue>; -} - -export function minWidth(...args: any[]): any; - -export interface WidthProps { - /** - * The width utility parses a component's `width` prop and converts it into a CSS width declaration. - * - * - Numbers from 0-1 are converted to percentage widths. - * - Numbers greater than 1 are converted to pixel values. - * - String values are passed as raw CSS values. - * - And arrays are converted to responsive width styles. - */ - width?: ResponsiveValue>; -} - -export function width(...args: any[]): any; - -export interface MaxHeightProps { - /** - * The max-height CSS property sets the maximum height of an element. It prevents the used value of the height - * property from becoming larger than the value specified for max-height. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) - */ - maxHeight?: ResponsiveValue>; -} - -export function maxHeight(...args: any[]): any; - -export interface MinHeightProps { - /** - * The min-height CSS property sets the minimum height of an element. It prevents the used value of the height - * property from becoming smaller than the value specified for min-height. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) - */ - minHeight?: ResponsiveValue>; -} - -export function minHeight(...args: any[]): any; - -export interface HeightProps { - /** - * The height CSS property specifies the height of an element. By default, the property defines the height of the - * content area. If box-sizing is set to border-box, however, it instead determines the height of the border area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/height) - */ - height?: ResponsiveValue>; -} - -export function height(...args: any[]): any; - -// TODO: Document, I couldn't find any info on these two properties... - -export interface SizeWidthProps { - size?: ResponsiveValue>; -} - -export function sizeWidth(...args: any[]): any; - -export interface SizeHeightProps { - size?: ResponsiveValue>; -} - -export function sizeHeight(...args: any[]): any; - -export interface SizeProps extends SizeHeightProps, SizeWidthProps {} - -export function size(...args: any[]): any; - -export interface RatioProps { - /** - * The ration is height: 0 & paddingBottom - */ - ratio?: ResponsiveValue; -} - -export function ratio(...args: any[]): any; - -export interface VerticalAlignProps { - /** - * The vertical-align CSS property specifies sets vertical alignment of an inline or table-cell box. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) - */ - verticalAlign?: ResponsiveValue>; -} - -export function verticalAlign(...args: any[]): any; - -/** - * Flexbox - */ - -export interface AlignItemsProps { - /** - * The CSS align-items property sets the align-self value on all direct children as a group. The align-self - * property sets the alignment of an item within its containing block. - * - * In Flexbox it controls the alignment of items on the Cross Axis, in Grid Layout it controls the alignment - * of items on the Block Axis within their grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) - */ - alignItems?: ResponsiveValue; -} - -export function alignItems(...args: any[]): any; - -export interface AlignContentProps { - /** - * The CSS align-content property sets how the browser distributes space between and around content items - * along the cross-axis of a flexbox container, and the main-axis of a grid container. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) - */ - alignContent?: ResponsiveValue; -} - -export function alignContent(...args: any[]): any; - -export interface JustifyItemsProps { - /** - * The CSS justify-items property defines the default justify-self for all items of the box, giving them all - * a default way of justifying each box along the appropriate axis. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) - */ - justifyItems?: ResponsiveValue; -} - -export interface JustifyContentProps { - /** - * The CSS justify-content property defines how the browser distributes space between and around content items - * along the main-axis of a flex container, and the inline axis of a grid container. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) - */ - justifyContent?: ResponsiveValue; -} - -export function justifyContent(...args: any[]): any; - -export interface FlexWrapProps { - /** - * The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. - * If wrapping is allowed, it sets the direction that lines are stacked. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) - */ - flexWrap?: ResponsiveValue; -} - -export function flexWrap(...args: any[]): any; - -export interface FlexBasisProps { - // TODO: The FlexBasisValue currently really only exists for documentation - // purposes, because flex-basis also accepts `Nem` and `Npx` strings. - // Not sure there’s a way to still have the union values show up as - // auto-completion results. - flexBasis?: ResponsiveValue>; -} - -export function flexBasis(...args: any[]): any; - -export interface FlexDirectionProps { - /** - * The flex-direction CSS property specifies how flex items are placed in the flex container defining the main - * axis and the direction (normal or reversed). - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) - */ - flexDirection?: ResponsiveValue; -} - -export function flexDirection(...args: any[]): any; - -export interface FlexProps { - /** - * The flex CSS property specifies how a flex item will grow or shrink so as to fit the space available in - * its flex container. This is a shorthand property that sets flex-grow, flex-shrink, and flex-basis. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) - */ - flex?: ResponsiveValue>; -} - -export function flex(...args: any[]): any; - -export interface JustifySelfProps { - /** - * The CSS justify-self property set the way a box is justified inside its alignment container along - * the appropriate axis. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) - */ - justifySelf?: ResponsiveValue; -} - -export function justifySelf(...args: any[]): any; - -export interface AlignSelfProps { - /** - * The align-self CSS property aligns flex items of the current flex line overriding the align-items value. - * - * If any of the item's cross-axis margin is set to auto, then align-self is ignored. In Grid layout align-self - * aligns the item inside the grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) - */ - alignSelf?: ResponsiveValue; -} - -export function alignSelf(...args: any[]): any; - -export interface OrderProps { - /** - * The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container - * are sorted by ascending order value and then by their source code order. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/order) - */ - order?: ResponsiveValue; -} - -export function order(...args: any[]): any; - -/** - * Grid Layout - */ - -export interface GridGapProps { - /** - * The gap CSS property sets the gaps (gutters) between rows and columns. It is a shorthand for row-gap - * and column-gap. - * - * @deprecated use gap - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) - */ - gridGap?: ResponsiveValue>; -} - -export function gridGap(...args: any[]): any; - -export interface GridColumnGapProps { - /** - * The column-gap CSS property sets the size of the gap (gutter) between an element's columns. - * - * @deprecated use column-gap - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) - */ - gridColumnGap?: ResponsiveValue>; -} - -export function gridColumnGap(...args: any[]): any; - -export interface GridRowGapProps { - /** - * The row-gap CSS property sets the size of the gap (gutter) between an element's rows. - * - * @deprecated use row-gap - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) - */ - gridRowGap?: ResponsiveValue>; -} - -export function gridRowGap(...args: any[]): any; - -export interface GridColumnProps { - /** - * The grid-column CSS property is a shorthand property for grid-column-start and grid-column-end specifying - * a grid item's size and location within the grid column by contributing a line, a span, or nothing (automatic) - * to its grid placement, thereby specifying the inline-start and inline-end edge of its grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column) - */ - gridColumn?: ResponsiveValue; -} - -export function gridColumn(...args: any[]): any; - -export interface GridRowProps { - /** - * The grid-row CSS property is a shorthand property for grid-row-start and grid-row-end specifying a grid item’s - * size and location within the grid row by contributing a line, a span, or nothing (automatic) to its grid - * placement, thereby specifying the inline-start and inline-end edge of its grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) - */ - gridRow?: ResponsiveValue; -} - -export function gridRow(...args: any[]): any; - -export interface GridAutoFlowProps { - /** - * The grid-auto-flow CSS property controls how the auto-placement algorithm works, specifying exactly - * how auto-placed items get flowed into the grid. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) - */ - gridAutoFlow?: ResponsiveValue; -} - -export function gridAutoFlow(...args: any[]): any; - -export interface GridAutoColumnsProps { - /** - * The grid-auto-columns CSS property specifies the size of an implicitly-created grid column track. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) - */ - gridAutoColumns?: ResponsiveValue>; -} - -export function gridAutoColumns(...args: any[]): any; - -export interface GridAutoRowsProps { - /** - * The grid-auto-rows CSS property specifies the size of an implicitly-created grid row track. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) - */ - gridAutoRows?: ResponsiveValue>; -} - -export function gridAutoRows(...args: any[]): any; - -export interface GridTemplatesColumnsProps { - /** - * The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) - */ - gridTemplateColumns?: ResponsiveValue>; -} - -export function gridTemplateColumns(...args: any[]): any; - -export interface GridTemplatesRowsProps { - /** - * The grid-template-rows CSS property defines the line names and track sizing functions of the grid rows. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-template-rows) - */ - gridTemplateRows?: ResponsiveValue>; -} - -export function gridTemplateRows(...args: any[]): any; - -export interface GridTemplatesAreasProps { - /** - * The grid-template-areas CSS property specifies named grid areas. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) - */ - gridTemplateAreas?: ResponsiveValue; -} - -export function gridTemplateAreas(...args: any[]): any; - -export interface GridAreaProps { - /** - * The grid-area CSS property is a shorthand property for grid-row-start, grid-column-start, grid-row-end - * and grid-column-end, specifying a grid item’s size and location within the grid row by contributing a line, - * a span, or nothing (automatic) to its grid placement, thereby specifying the edges of its grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) - */ - gridArea?: ResponsiveValue; -} - -export function gridArea(...args: any[]): any; - -/** - * Borders - */ - -export interface BorderProps { - /** - * The border CSS property sets an element's border. It's a shorthand for border-width, border-style, - * and border-color. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border) - */ - border?: ResponsiveValue>; -} - -export function border(...args: any[]): any; - -export interface BorderTopProps { - /** - * The border-top CSS property is a shorthand that sets the values of border-top-width, border-top-style, - * and border-top-color. These properties describe an element's top border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top) - */ - borderTop?: ResponsiveValue>; -} - -export function borderTop(...args: any[]): any; - -export interface BorderRightProps { - /** - * The border-right CSS property is a shorthand that sets border-right-width, border-right-style, - * and border-right-color. These properties set an element's right border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right) - */ - borderRight?: ResponsiveValue>; -} - -export function borderRight(...args: any[]): any; - -export interface BorderBottomProps { - /** - * The border-bottom CSS property sets an element's bottom border. It's a shorthand for - * border-bottom-width, border-bottom-style and border-bottom-color. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom) - */ - borderBottom?: ResponsiveValue>; -} - -export function borderBottom(...args: any[]): any; - -export interface BorderLeftProps { - /** - * The border-left CSS property is a shorthand that sets the values of border-left-width, - * border-left-style, and border-left-color. These properties describe an element's left border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left) - */ - borderLeft?: ResponsiveValue>; -} - -export function borderLeft(...args: any[]): any; - -export interface BordersProps extends BorderTopProps, BorderRightProps, BorderBottomProps, BorderLeftProps {} - -export function borders(...args: any[]): any; - -export interface BorderColorProps { - /** - * The border-color shorthand CSS property sets the color of all sides of an element's border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-color) - */ - borderColor?: ResponsiveValue; -} - -export function borderColor(...args: any[]): any; - -export interface BorderRadiusProps { - /** - * The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single - * radius to make circular corners, or two radii to make elliptical corners. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) - */ - borderRadius?: ResponsiveValue>; -} - -export function borderRadius(...args: any[]): any; - -export interface BoxShadowProps { - /** - * The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects - * separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread - * radii, and color. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) - */ - boxShadow?: ResponsiveValue; -} - -export function boxShadow(...arg: any[]): any; - -export interface OpacityProps { - /** - * The opacity CSS property sets the transparency of an element or the degree to which content - * behind an element is visible. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) - */ - opacity?: ResponsiveValue; -} - -export function opacity(...arg: any[]): any; - -export interface OverflowProps { - /** - * The overflow CSS property sets what to do when an element's content is too big to fit in its block - * formatting context. It is a shorthand for overflow-x and overflow-y. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow) - */ - overflow?: ResponsiveValue; -} - -export function overflow(...arg: any[]): any; -/** - * Background - */ - -export interface BackgroundProps { - /** - * The background shorthand CSS property sets all background style properties at once, - * such as color, image, origin and size, repeat method, and others. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background) - */ - background?: ResponsiveValue>; -} - -export function background(...args: any[]): any; - -export interface BackgroundImageProps { - /** - * The background-image CSS property sets one or more background images on an element. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) - */ - backgroundImage?: ResponsiveValue; -} - -export function backgroundImage(...args: any[]): any; - -export interface BackgroundSizeProps { - /** - * The background-size CSS property sets the size of the element's background image. The - * image can be left to its natural size, stretched, or constrained to fit the available space. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) - */ - backgroundSize?: ResponsiveValue>; -} - -export function backgroundSize(...args: any[]): any; - -export interface BackgroundPositionProps { - /** - * The background-position CSS property sets the initial position for each background image. The - * position is relative to the position layer set by background-origin. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) - */ - backgroundPosition?: ResponsiveValue>; -} - -export function backgroundPosition(...args: any[]): any; - -export interface BackgroundRepeatProps { - /** - * The background-repeat CSS property sets how background images are repeated. A background - * image can be repeated along the horizontal and vertical axes, or not repeated at all. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) - */ - backgroundRepeat?: ResponsiveValue; -} - -export function backgroundRepeat(...args: any[]): any; - -/** - * Position - */ - -export interface PositionProps { - /** - * The position CSS property specifies how an element is positioned in a document. - * The top, right, bottom, and left properties determine the final location of positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/position) - */ - position?: ResponsiveValue; -} - -export function position(...args: any[]): any; - -export interface ZIndexProps { - /** - * The z-index CSS property sets the z-order of a positioned element and its descendants or - * flex items. Overlapping elements with a larger z-index cover those with a smaller one. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index) - */ - zIndex?: ResponsiveValue; -} - -export function zIndex(...args: any[]): any; - -export interface TopProps { - /** - * The top CSS property participates in specifying the vertical position of a - * positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) - */ - top?: ResponsiveValue>; -} - -export function top(...args: any[]): any; - -export interface RightProps { - /** - * The right CSS property participates in specifying the horizontal position of a - * positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/right) - */ - right?: ResponsiveValue>; -} - -export function right(...args: any[]): any; - -export interface BottomProps { - /** - * The bottom CSS property participates in specifying the vertical position of a - * positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) - */ - bottom?: ResponsiveValue>; -} - -export function bottom(...args: any[]): any; - -export interface LeftProps { - /** - * The left CSS property participates in specifying the horizontal position - * of a positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/left) - */ - left?: ResponsiveValue>; -} - -export function left(...args: any[]): any; - -export interface TextStyleProps { - textStyle?: ResponsiveValue; -} - -export function textStyle(...args: any[]): any; - -export interface ColorStyleProps { - colors?: ResponsiveValue; -} - -export function colorStyle(...args: any[]): any; - -export interface ButtonStyleProps { - variant?: ResponsiveValue; -} - -export function buttonStyle(...args: any[]): any; diff --git a/types/styled-system/dist/util.d.ts b/types/styled-system/dist/util.d.ts deleted file mode 100644 index 8fa2642e62..0000000000 --- a/types/styled-system/dist/util.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const defaultBreakpoints: string[]; -export function is(n: any): boolean; -export function num(n: any): boolean; -export function px(n: any): string; - -export function get(obj: any, ...paths: Array): any; - -export function themeGet(keys: string, fallback?: string): any; -export function cloneFunc(fn: (...args: any[]) => any): (...args: any[]) => any; - -export function merge(a: any, b: any): any; - -export function compose(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; - -export function createMediaQuery(n: any): string; - -export interface LowLevelStylefunctionArguments { - prop: string; - cssProperty?: string; - key?: string; - getter?: () => any; - transformValue?: (n: string|number) => any; - scale?: Array; -} - -export function style(args: LowLevelStylefunctionArguments): any; diff --git a/types/styled-system/dist/variant.d.ts b/types/styled-system/dist/variant.d.ts deleted file mode 100644 index 8a3f8b15ec..0000000000 --- a/types/styled-system/dist/variant.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface VariantArgs { - key?: string; - // Defaults to "variant" - prop?: string; -} - -export function variant(props: VariantArgs): (...args: any[]) => any; diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index 4eaf0e8a84..495df8a6d3 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -11,7 +11,935 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -export * from './dist/util'; -export * from './dist/styles'; -export * from './dist/variant'; -export * from './dist/mixed'; +import * as CSS from "csstype"; + +export const defaultBreakpoints: string[]; +export function is(n: any): boolean; +export function num(n: any): boolean; +export function px(n: any): string; + +export function get(obj: any, ...paths: Array): any; + +export function themeGet(keys: string, fallback?: string): any; +export function cloneFunc(fn: (...args: any[]) => any): (...args: any[]) => any; + +export function merge(a: any, b: any): any; + +export function compose( + ...funcs: Array<(...args: any[]) => any> +): (...args: any[]) => any; + +export function createMediaQuery(n: number | string): string; + +export interface LowLevelStylefunctionArguments { + prop: string; + cssProperty?: string; + key?: string; + getter?: () => any; + transformValue?: (n: string | number) => any; + scale?: Array; +} + +export function style(args: LowLevelStylefunctionArguments): any; + +export type TLengthStyledSystem = string | 0 | number; +export type ResponsiveValue = T | Array; + +/** + * Converts shorthand margin and padding props to margin and padding CSS declarations + * + * - Numbers from 0-4 (or the length of theme.space) are converted to values on the spacing scale. + * - Negative values can be used for negative margins. + * - Numbers greater than the length of the theme.space array are converted to raw pixel values. + * - String values are passed as raw CSS values. + * - Array values are converted into responsive values. + */ + +export interface SpaceProps { + /** Margin on top, left, bottom and right */ + m?: ResponsiveValue>; + /** Margin for the top */ + mt?: ResponsiveValue>; + /** Margin for the right */ + mr?: ResponsiveValue>; + /** Margin for the bottom */ + mb?: ResponsiveValue>; + /** Margin for the left */ + ml?: ResponsiveValue>; + /** Margin for the left and right */ + mx?: ResponsiveValue>; + /** Margin for the top and bottom */ + my?: ResponsiveValue>; + /** Padding on top, left, bottom and right */ + p?: ResponsiveValue>; + /** Padding for the top */ + pt?: ResponsiveValue>; + /** Padding for the right */ + pr?: ResponsiveValue>; + /** Padding for the bottom */ + pb?: ResponsiveValue>; + /** Padding for the left */ + pl?: ResponsiveValue>; + /** Padding for the left and right */ + px?: ResponsiveValue>; + /** Padding for the top and bottom */ + py?: ResponsiveValue>; +} + +export function space(...args: any[]): any; + +export interface VariantArgs { + key?: string; + // Defaults to "variant" + prop?: string; +} + +export function variant(props: VariantArgs): (...args: any[]) => any; + +export interface BaseTheme { + breakpoints?: number[]; + space?: number[]; + fontSizes?: number[]; + colors?: { + [name: string]: string; + }; +} + +/** + * Font Size + */ + +export interface FontSizeProps { + /** + * The fontSize utility parses a component's `fontSize` prop and converts it into a CSS font-size declaration. + * + * - Numbers from 0-8 (or `theme.fontSizes.length`) are converted to values on the [font size scale](#default-theme). + * - Numbers greater than `theme.fontSizes.length` are converted to raw pixel values. + * - String values are passed as raw CSS values. + * - And array values are converted into responsive values. + * + */ + fontSize?: ResponsiveValue>; +} + +export function fontSize(...args: any[]): any; + +/** + * Color + */ + +export interface TextColorProps { + /** + * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. + * By default the raw value of the prop is returned. + * + * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. + * Array values are converted into responsive values. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/color) + */ + color?: ResponsiveValue; +} + +export function textColor(...args: any[]): any; + +export interface BgColorProps { + /** + * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. + * By default the raw value of the prop is returned. + * + * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. + * Array values are converted into responsive values. + * + * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) + */ + bg?: ResponsiveValue>; +} + +export function bgColor(...args: any[]): any; + +export interface ColorProps extends TextColorProps, BgColorProps {} + +export function color(...args: any[]): any; + +/** + * Typography + */ +export interface FontFamilyProps { + fontFamily?: ResponsiveValue; +} +export function fontFamily(...args: any[]): any; + +export interface TextAlignProps { + /** + * The text-align CSS property specifies the horizontal alignment of an inline or table-cell box. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) + */ + textAlign?: ResponsiveValue; +} + +export function textAlign(...args: any[]): any; + +export interface LineHeightProps { + /** + * The line-height CSS property sets the amount of space used for lines, such as in text. On block-level elements, + * it specifies the minimum height of line boxes within the element. + * + * On non-replaced inline elements, it specifies the height that is used to calculate line box height. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) + */ + lineHeight?: ResponsiveValue>; +} +export function lineHeight(...args: any[]): any; + +export interface FontWeightProps { + /** + * The font-weight CSS property specifies the weight (or boldness) of the font. + * + * The font weights available to you will depend on the font-family you are using. Some fonts are only available in normal and bold. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) + */ + fontWeight?: ResponsiveValue; +} + +export function fontWeight(...args: any[]): any; + +export interface FontStyleProps { + /** + * The font-style CSS property specifies whether a font should be styled with a normal, italic, + * or oblique face from its font-family. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) + */ + fontStyle?: ResponsiveValue; +} +export function fontStyle(...args: any[]): any; + +export interface LetterSpacingProps { + /** + * The letter-spacing CSS property sets the spacing behavior between text characters. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) + */ + letterSpacing?: ResponsiveValue>; +} +export function letterSpacing(...args: any[]): any; + +/** + * Layout + */ + +export interface DisplayProps { + /** + * The display CSS property defines the display type of an element, which consists of the two basic qualities + * of how an element generates boxes — the outer display type defining how the box participates in flow layout, + * and the inner display type defining how the children of the box are laid out. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) + */ + display?: ResponsiveValue; +} + +export function display(...args: any[]): any; + +export interface MaxWidthProps { + /** + * The max-width CSS property sets the maximum width of an element. + * It prevents the used value of the width property from becoming larger than the value specified by max-width. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) + */ + maxWidth?: ResponsiveValue>; +} + +export function maxWidth(...args: any[]): any; + +export interface MinWidthProps { + /** + * The min-width CSS property sets the minimum width of an element. + * It prevents the used value of the width property from becoming smaller than the value specified for min-width. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) + */ + minWidth?: ResponsiveValue>; +} + +export function minWidth(...args: any[]): any; + +export interface WidthProps { + /** + * The width utility parses a component's `width` prop and converts it into a CSS width declaration. + * + * - Numbers from 0-1 are converted to percentage widths. + * - Numbers greater than 1 are converted to pixel values. + * - String values are passed as raw CSS values. + * - And arrays are converted to responsive width styles. + */ + width?: ResponsiveValue>; +} + +export function width(...args: any[]): any; + +export interface MaxHeightProps { + /** + * The max-height CSS property sets the maximum height of an element. It prevents the used value of the height + * property from becoming larger than the value specified for max-height. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) + */ + maxHeight?: ResponsiveValue>; +} + +export function maxHeight(...args: any[]): any; + +export interface MinHeightProps { + /** + * The min-height CSS property sets the minimum height of an element. It prevents the used value of the height + * property from becoming smaller than the value specified for min-height. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) + */ + minHeight?: ResponsiveValue>; +} + +export function minHeight(...args: any[]): any; + +export interface HeightProps { + /** + * The height CSS property specifies the height of an element. By default, the property defines the height of the + * content area. If box-sizing is set to border-box, however, it instead determines the height of the border area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/height) + */ + height?: ResponsiveValue>; +} + +export function height(...args: any[]): any; + +// TODO: Document, I couldn't find any info on these two properties... + +export interface SizeWidthProps { + size?: ResponsiveValue>; +} + +export function sizeWidth(...args: any[]): any; + +export interface SizeHeightProps { + size?: ResponsiveValue>; +} + +export function sizeHeight(...args: any[]): any; + +export interface SizeProps extends SizeHeightProps, SizeWidthProps {} + +export function size(...args: any[]): any; + +export interface RatioProps { + /** + * The ration is height: 0 & paddingBottom + */ + ratio?: ResponsiveValue; +} + +export function ratio(...args: any[]): any; + +export interface VerticalAlignProps { + /** + * The vertical-align CSS property specifies sets vertical alignment of an inline or table-cell box. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) + */ + verticalAlign?: ResponsiveValue>; +} + +export function verticalAlign(...args: any[]): any; + +/** + * Flexbox + */ + +export interface AlignItemsProps { + /** + * The CSS align-items property sets the align-self value on all direct children as a group. The align-self + * property sets the alignment of an item within its containing block. + * + * In Flexbox it controls the alignment of items on the Cross Axis, in Grid Layout it controls the alignment + * of items on the Block Axis within their grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) + */ + alignItems?: ResponsiveValue; +} + +export function alignItems(...args: any[]): any; + +export interface AlignContentProps { + /** + * The CSS align-content property sets how the browser distributes space between and around content items + * along the cross-axis of a flexbox container, and the main-axis of a grid container. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) + */ + alignContent?: ResponsiveValue; +} + +export function alignContent(...args: any[]): any; + +export interface JustifyItemsProps { + /** + * The CSS justify-items property defines the default justify-self for all items of the box, giving them all + * a default way of justifying each box along the appropriate axis. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) + */ + justifyItems?: ResponsiveValue; +} + +export interface JustifyContentProps { + /** + * The CSS justify-content property defines how the browser distributes space between and around content items + * along the main-axis of a flex container, and the inline axis of a grid container. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) + */ + justifyContent?: ResponsiveValue; +} + +export function justifyContent(...args: any[]): any; + +export interface FlexWrapProps { + /** + * The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. + * If wrapping is allowed, it sets the direction that lines are stacked. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) + */ + flexWrap?: ResponsiveValue; +} + +export function flexWrap(...args: any[]): any; + +export interface FlexBasisProps { + // TODO: The FlexBasisValue currently really only exists for documentation + // purposes, because flex-basis also accepts `Nem` and `Npx` strings. + // Not sure there’s a way to still have the union values show up as + // auto-completion results. + flexBasis?: ResponsiveValue>; +} + +export function flexBasis(...args: any[]): any; + +export interface FlexDirectionProps { + /** + * The flex-direction CSS property specifies how flex items are placed in the flex container defining the main + * axis and the direction (normal or reversed). + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) + */ + flexDirection?: ResponsiveValue; +} + +export function flexDirection(...args: any[]): any; + +export interface FlexProps { + /** + * The flex CSS property specifies how a flex item will grow or shrink so as to fit the space available in + * its flex container. This is a shorthand property that sets flex-grow, flex-shrink, and flex-basis. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) + */ + flex?: ResponsiveValue>; +} + +export function flex(...args: any[]): any; + +export interface JustifySelfProps { + /** + * The CSS justify-self property set the way a box is justified inside its alignment container along + * the appropriate axis. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) + */ + justifySelf?: ResponsiveValue; +} + +export function justifySelf(...args: any[]): any; + +export interface AlignSelfProps { + /** + * The align-self CSS property aligns flex items of the current flex line overriding the align-items value. + * + * If any of the item's cross-axis margin is set to auto, then align-self is ignored. In Grid layout align-self + * aligns the item inside the grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) + */ + alignSelf?: ResponsiveValue; +} + +export function alignSelf(...args: any[]): any; + +export interface OrderProps { + /** + * The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container + * are sorted by ascending order value and then by their source code order. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/order) + */ + order?: ResponsiveValue; +} + +export function order(...args: any[]): any; + +/** + * Grid Layout + */ + +export interface GridGapProps { + /** + * The gap CSS property sets the gaps (gutters) between rows and columns. It is a shorthand for row-gap + * and column-gap. + * + * @deprecated use gap + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) + */ + gridGap?: ResponsiveValue>; +} + +export function gridGap(...args: any[]): any; + +export interface GridColumnGapProps { + /** + * The column-gap CSS property sets the size of the gap (gutter) between an element's columns. + * + * @deprecated use column-gap + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) + */ + gridColumnGap?: ResponsiveValue>; +} + +export function gridColumnGap(...args: any[]): any; + +export interface GridRowGapProps { + /** + * The row-gap CSS property sets the size of the gap (gutter) between an element's rows. + * + * @deprecated use row-gap + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) + */ + gridRowGap?: ResponsiveValue>; +} + +export function gridRowGap(...args: any[]): any; + +export interface GridColumnProps { + /** + * The grid-column CSS property is a shorthand property for grid-column-start and grid-column-end specifying + * a grid item's size and location within the grid column by contributing a line, a span, or nothing (automatic) + * to its grid placement, thereby specifying the inline-start and inline-end edge of its grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column) + */ + gridColumn?: ResponsiveValue; +} + +export function gridColumn(...args: any[]): any; + +export interface GridRowProps { + /** + * The grid-row CSS property is a shorthand property for grid-row-start and grid-row-end specifying a grid item’s + * size and location within the grid row by contributing a line, a span, or nothing (automatic) to its grid + * placement, thereby specifying the inline-start and inline-end edge of its grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) + */ + gridRow?: ResponsiveValue; +} + +export function gridRow(...args: any[]): any; + +export interface GridAutoFlowProps { + /** + * The grid-auto-flow CSS property controls how the auto-placement algorithm works, specifying exactly + * how auto-placed items get flowed into the grid. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) + */ + gridAutoFlow?: ResponsiveValue; +} + +export function gridAutoFlow(...args: any[]): any; + +export interface GridAutoColumnsProps { + /** + * The grid-auto-columns CSS property specifies the size of an implicitly-created grid column track. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) + */ + gridAutoColumns?: ResponsiveValue>; +} + +export function gridAutoColumns(...args: any[]): any; + +export interface GridAutoRowsProps { + /** + * The grid-auto-rows CSS property specifies the size of an implicitly-created grid row track. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) + */ + gridAutoRows?: ResponsiveValue>; +} + +export function gridAutoRows(...args: any[]): any; + +export interface GridTemplatesColumnsProps { + /** + * The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) + */ + gridTemplateColumns?: ResponsiveValue< + CSS.GridTemplateColumnsProperty + >; +} + +export function gridTemplateColumns(...args: any[]): any; + +export interface GridTemplatesRowsProps { + /** + * The grid-template-rows CSS property defines the line names and track sizing functions of the grid rows. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-template-rows) + */ + gridTemplateRows?: ResponsiveValue>; +} + +export function gridTemplateRows(...args: any[]): any; + +export interface GridTemplatesAreasProps { + /** + * The grid-template-areas CSS property specifies named grid areas. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) + */ + gridTemplateAreas?: ResponsiveValue; +} + +export function gridTemplateAreas(...args: any[]): any; + +export interface GridAreaProps { + /** + * The grid-area CSS property is a shorthand property for grid-row-start, grid-column-start, grid-row-end + * and grid-column-end, specifying a grid item’s size and location within the grid row by contributing a line, + * a span, or nothing (automatic) to its grid placement, thereby specifying the edges of its grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) + */ + gridArea?: ResponsiveValue; +} + +export function gridArea(...args: any[]): any; + +/** + * Borders + */ + +export interface BorderProps { + /** + * The border CSS property sets an element's border. It's a shorthand for border-width, border-style, + * and border-color. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border) + */ + border?: ResponsiveValue>; +} + +export function border(...args: any[]): any; + +export interface BorderTopProps { + /** + * The border-top CSS property is a shorthand that sets the values of border-top-width, border-top-style, + * and border-top-color. These properties describe an element's top border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top) + */ + borderTop?: ResponsiveValue>; +} + +export function borderTop(...args: any[]): any; + +export interface BorderRightProps { + /** + * The border-right CSS property is a shorthand that sets border-right-width, border-right-style, + * and border-right-color. These properties set an element's right border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right) + */ + borderRight?: ResponsiveValue>; +} + +export function borderRight(...args: any[]): any; + +export interface BorderBottomProps { + /** + * The border-bottom CSS property sets an element's bottom border. It's a shorthand for + * border-bottom-width, border-bottom-style and border-bottom-color. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom) + */ + borderBottom?: ResponsiveValue>; +} + +export function borderBottom(...args: any[]): any; + +export interface BorderLeftProps { + /** + * The border-left CSS property is a shorthand that sets the values of border-left-width, + * border-left-style, and border-left-color. These properties describe an element's left border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left) + */ + borderLeft?: ResponsiveValue>; +} + +export function borderLeft(...args: any[]): any; + +export interface BordersProps + extends BorderTopProps, + BorderRightProps, + BorderBottomProps, + BorderLeftProps {} + +export function borders(...args: any[]): any; + +export interface BorderColorProps { + /** + * The border-color shorthand CSS property sets the color of all sides of an element's border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-color) + */ + borderColor?: ResponsiveValue; +} + +export function borderColor(...args: any[]): any; + +export interface BorderRadiusProps { + /** + * The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single + * radius to make circular corners, or two radii to make elliptical corners. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) + */ + borderRadius?: ResponsiveValue>; +} + +export function borderRadius(...args: any[]): any; + +export interface BoxShadowProps { + /** + * The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects + * separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread + * radii, and color. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) + */ + boxShadow?: ResponsiveValue; +} + +export function boxShadow(...arg: any[]): any; + +export interface OpacityProps { + /** + * The opacity CSS property sets the transparency of an element or the degree to which content + * behind an element is visible. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) + */ + opacity?: ResponsiveValue; +} + +export function opacity(...arg: any[]): any; + +export interface OverflowProps { + /** + * The overflow CSS property sets what to do when an element's content is too big to fit in its block + * formatting context. It is a shorthand for overflow-x and overflow-y. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow) + */ + overflow?: ResponsiveValue; +} + +export function overflow(...arg: any[]): any; +/** + * Background + */ + +export interface BackgroundProps { + /** + * The background shorthand CSS property sets all background style properties at once, + * such as color, image, origin and size, repeat method, and others. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background) + */ + background?: ResponsiveValue>; +} + +export function background(...args: any[]): any; + +export interface BackgroundImageProps { + /** + * The background-image CSS property sets one or more background images on an element. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) + */ + backgroundImage?: ResponsiveValue; +} + +export function backgroundImage(...args: any[]): any; + +export interface BackgroundSizeProps { + /** + * The background-size CSS property sets the size of the element's background image. The + * image can be left to its natural size, stretched, or constrained to fit the available space. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) + */ + backgroundSize?: ResponsiveValue>; +} + +export function backgroundSize(...args: any[]): any; + +export interface BackgroundPositionProps { + /** + * The background-position CSS property sets the initial position for each background image. The + * position is relative to the position layer set by background-origin. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) + */ + backgroundPosition?: ResponsiveValue< + CSS.BackgroundPositionProperty + >; +} + +export function backgroundPosition(...args: any[]): any; + +export interface BackgroundRepeatProps { + /** + * The background-repeat CSS property sets how background images are repeated. A background + * image can be repeated along the horizontal and vertical axes, or not repeated at all. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) + */ + backgroundRepeat?: ResponsiveValue; +} + +export function backgroundRepeat(...args: any[]): any; + +/** + * Position + */ + +export interface PositionProps { + /** + * The position CSS property specifies how an element is positioned in a document. + * The top, right, bottom, and left properties determine the final location of positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/position) + */ + position?: ResponsiveValue; +} + +export function position(...args: any[]): any; + +export interface ZIndexProps { + /** + * The z-index CSS property sets the z-order of a positioned element and its descendants or + * flex items. Overlapping elements with a larger z-index cover those with a smaller one. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index) + */ + zIndex?: ResponsiveValue; +} + +export function zIndex(...args: any[]): any; + +export interface TopProps { + /** + * The top CSS property participates in specifying the vertical position of a + * positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) + */ + top?: ResponsiveValue>; +} + +export function top(...args: any[]): any; + +export interface RightProps { + /** + * The right CSS property participates in specifying the horizontal position of a + * positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/right) + */ + right?: ResponsiveValue>; +} + +export function right(...args: any[]): any; + +export interface BottomProps { + /** + * The bottom CSS property participates in specifying the vertical position of a + * positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) + */ + bottom?: ResponsiveValue>; +} + +export function bottom(...args: any[]): any; + +export interface LeftProps { + /** + * The left CSS property participates in specifying the horizontal position + * of a positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/left) + */ + left?: ResponsiveValue>; +} + +export function left(...args: any[]): any; + +export interface TextStyleProps { + textStyle?: ResponsiveValue; +} + +export function textStyle(...args: any[]): any; + +export interface ColorStyleProps { + colors?: ResponsiveValue; +} + +export function colorStyle(...args: any[]): any; + +export interface ButtonStyleProps { + variant?: ResponsiveValue; +} + +export function buttonStyle(...args: any[]): any; + +export interface MixedProps { + key?: any; + // Defaults to "variant" + prop?: string; +} + +export function mixed(...args: any[]): any; From 171d143b8fd881e44d04452ea77bfbd9dbd5174a Mon Sep 17 00:00:00 2001 From: Tegan Churchill Date: Wed, 26 Dec 2018 16:42:44 -0800 Subject: [PATCH 03/69] Spectacle - Slide and Deck component prop updates (#31599) * Add and {}} /> * Update Spectacle version number --- types/spectacle/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/spectacle/index.d.ts b/types/spectacle/index.d.ts index 621f08f67e..df79658c76 100644 --- a/types/spectacle/index.d.ts +++ b/types/spectacle/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Spectacle 5.2.2 +// Type definitions for Spectacle 5.3.0 // Project: https://github.com/FormidableLabs/spectacle // Definitions by: Zachary Maybury // Kylie Stewart @@ -164,6 +164,7 @@ declare module "spectacle" { controls?: boolean; globalStyles?: boolean; history?: any; // Needs a type, see https://github.com/ReactTraining/history + onStateChange?: (previousState?: string, nextState?: string) => void progress?: progressType; theme?: Theme; transition?: transitionType[]; @@ -229,6 +230,7 @@ declare module "spectacle" { notes?: string; onActive?: (slideIndex: string | number) => void; slideIndex?: number; + state?: string; transition?: transitionType[]; transitionDuration?: number; transitionIn?: transitionType[]; From b1a2d8dc639db54a29e30b8da1431f3bd1032622 Mon Sep 17 00:00:00 2001 From: Alexander Madyankin Date: Sat, 29 Dec 2018 12:31:23 +0600 Subject: [PATCH 04/69] [react-native] Add missing definitions for PushNotification --- types/react-native/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 3090285ecc..865a46eefa 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7687,11 +7687,21 @@ export interface PushNotification { */ getSound(): string; + /** + * Gets the category string from the `aps` object + */ + getCategory(): string; + /** * Gets the notification's main message from the `aps` object */ getAlert(): string | Object; + /** + * Gets the content-available number from the `aps` object + */ + getContentAvailable(): number; + /** * Gets the badge count number from the `aps` object */ From 3acf952289778cc44cac27cd5d6e34e0cb4584fc Mon Sep 17 00:00:00 2001 From: denisname Date: Mon, 31 Dec 2018 16:48:01 +0100 Subject: [PATCH 05/69] Add new toast component and touch support in carousel (#31748) --- types/bootstrap/bootstrap-tests.ts | 21 ++++++++++++ types/bootstrap/index.d.ts | 54 +++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/types/bootstrap/bootstrap-tests.ts b/types/bootstrap/bootstrap-tests.ts index 94de3fcd79..9344423cfb 100755 --- a/types/bootstrap/bootstrap-tests.ts +++ b/types/bootstrap/bootstrap-tests.ts @@ -52,6 +52,7 @@ $("#carousel").carousel({ slide: false, pause: "hover", wrap: true, + touch: false, }); $("#carousel").carousel({ @@ -245,6 +246,26 @@ $("a[data-toggle=\"list\"]").on("shown.bs.tab", (e) => { const previousActiveTab: HTMLElement = e.relatedTarget; }); +// -------------------------------------------------------------------------------------- +// Toast +// -------------------------------------------------------------------------------------- + +// $ExpectType JQuery +$("#toast").toast(); + +// $ExpectType JQuery +$("#toast").toast("show"); + +$("#toast").on("shown.bs.toast", () => {}); + +$("#toast").toast({ + animation: false, + autohide: false, + delay: 100, +}); + +$("#toast").toast({}); + // -------------------------------------------------------------------------------------- // Tooltip // -------------------------------------------------------------------------------------- diff --git a/types/bootstrap/index.d.ts b/types/bootstrap/index.d.ts index cb425f17e2..e8cea54f58 100755 --- a/types/bootstrap/index.d.ts +++ b/types/bootstrap/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Bootstrap 4.1 +// Type definitions for Bootstrap 4.2 // Project: https://github.com/twbs/bootstrap/ // Definitions by: denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -64,9 +64,10 @@ export interface CarouselOption { slide?: "next" | "prev" | false; /** - * If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. + * If set to "hover", pauses the cycling of the carousel on `mouseenter` and resumes the cycling of the carousel on `mouseleave`. * If set to false, hovering over the carousel won't pause it. - * On touch-enabled devices, when set to "hover", cycling will pause on touchend (once the user finished interacting with the carousel) + * + * On touch-enabled devices, when set to "hover", cycling will pause on `touchend` (once the user finished interacting with the carousel) * for two intervals, before automatically resuming. Note that this is in addition to the above mouse behavior. * * @default "hover" @@ -79,6 +80,13 @@ export interface CarouselOption { * @default true */ wrap?: boolean; + + /** + * Whether the carousel should support left/right swipe interactions on touchscreen devices. + * + * @default true + */ + touch?: boolean; } export interface CollapseOption { @@ -210,6 +218,29 @@ export interface ScrollspyOption { target?: string | Element; } +export interface ToastOption { + /** + * Apply a CSS fade transition to the toast. + * + * @default true + */ + animation?: boolean; + + /** + * Auto hide the toast. + * + * @default true + */ + autohide?: boolean; + + /** + * Delay hiding the toast in millisecond. + * + * @default 500 + */ + delay?: number; +} + export interface TooltipOption { /** * Apply a CSS fade transition to the tooltip or popover. @@ -401,6 +432,7 @@ export type ModalEvent = "show.bs.modal" | "shown.bs.modal" | "hide.bs.modal" | export type PopoverEvent = "show.bs.popover" | "shown.bs.popover" | "hide.bs.popover" | "hidden.bs.popover" | "inserted.bs.popover"; export type ScrollspyEvent = "activate.bs.scrollspy"; export type TapEvent = "show.bs.tab" | "shown.bs.tab" | "hide.bs.tab" | "hidden.bs.tab"; +export type ToastEvent = "show.bs.toast" | "shown.bs.toast" | "hide.bs.toast" | "hidden.bs.toast"; export type TooltipEvent = "show.bs.tooltip" | "shown.bs.tooltip" | "hide.bs.tooltip" | "hidden.bs.tooltip" | "inserted.bs.tooltip"; // -------------------------------------------------------------------------------------- @@ -538,6 +570,20 @@ $('[data-spy="scroll"]').each(function () { */ tab(action: "show" | "dispose"): this; + /** + * Call a method on the toast element: + * * `show` – Reveals an element's toast. You have to manually call this method, instead your toast won't show. + * * `hide` – Hides an element's toast. You have to manually call this method if you made `autohide` to false. + * * `dispose` – Hides an element's toast. Your toast will remain on the DOM but won't show anymore. + * + * Returns to the caller before the toast has actually been shown or hidden (i.e. before the `shown.bs.toast` or `hidden.bs.toast` event occurs). + */ + toast(action: "show" | "hide" | "dispose"): this; + /** + * Attaches a toast handler to an element collection. + */ + toast(options?: ToastOption): this; + /** * Call a method on the tooltip element: * * `show` – Reveals an element's tooltip. @@ -564,7 +610,7 @@ $('[data-spy="scroll"]').each(function () { on(events: ModalEvent, handler: JQuery.EventHandlerBase>): this; on(events: TapEvent, handler: JQuery.EventHandlerBase>): this; on( - events: AlertEvent | CollapseEvent | PopoverEvent | ScrollspyEvent | TooltipEvent, + events: AlertEvent | CollapseEvent | PopoverEvent | ScrollspyEvent | ToastEvent | TooltipEvent, handler: JQuery.EventHandler ): this; } From 5c27b227bdacec0de2b99a1cfea2a6569f60a0f4 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Mon, 31 Dec 2018 08:49:10 -0700 Subject: [PATCH 06/69] Remove Spectacle (#31744) * Remove Spectacle now that types are packaged in the library * Update asOfVersion --- notNeededPackages.json | 6 + types/spectacle/index.d.ts | 323 ------------------------ types/spectacle/package.json | 6 - types/spectacle/spectacle-tests.tsx | 377 ---------------------------- types/spectacle/tsconfig.json | 25 -- types/spectacle/tslint.json | 79 ------ 6 files changed, 6 insertions(+), 810 deletions(-) delete mode 100644 types/spectacle/index.d.ts delete mode 100644 types/spectacle/package.json delete mode 100644 types/spectacle/spectacle-tests.tsx delete mode 100644 types/spectacle/tsconfig.json delete mode 100644 types/spectacle/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index c64738aa8d..251442309d 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1512,6 +1512,12 @@ "sourceRepoURL": "https://github.com/mozilla/source-map", "asOfVersion": "0.5.7" }, + { + "libraryName": "Spectacle", + "typingsPackageName": "spectacle", + "sourceRepoURL": "http://github.com/FormidableLabs/spectacle/", + "asOfVersion": "5.2.3" + }, { "libraryName": "Spin.js", "typingsPackageName": "spin.js", diff --git a/types/spectacle/index.d.ts b/types/spectacle/index.d.ts deleted file mode 100644 index df79658c76..0000000000 --- a/types/spectacle/index.d.ts +++ /dev/null @@ -1,323 +0,0 @@ -// Type definitions for Spectacle 5.3.0 -// Project: https://github.com/FormidableLabs/spectacle -// Definitions by: Zachary Maybury -// Kylie Stewart -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 - -/// - -declare module "spectacle" { - import * as React from "react"; - import * as CSS from "csstype"; - /** - * Alignment Types for Spectacle - */ - type alignType = - | "flex-start flex-start" - | "flex-start center" - | "flex-start flex-end" - | "center flex-start" - | "center center" - | "center flex-end" - | "flex-end flex-start" - | "flex-end center" - | "flex-end flex-end"; - - /** - * Animation Types for Spectacle - */ - type easeType = - | "back" - | "backIn" - | "backOut" - | "backInOut" - | "bounce" - | "bounceIn" - | "bounceOut" - | "bounceInOut" - | "circle" - | "circleIn" - | "circleOut" - | "circleInOut" - | "linear" - | "linearIn" - | "linearOut" - | "linearInOut" - | "cubic" - | "cubicIn" - | "cubicOut" - | "cubicInOut" - | "elastic" - | "elasticIn" - | "elasticOut" - | "elasticInOut" - | "exp" - | "expIn" - | "expOut" - | "expInOut" - | "poly" - | "polyIn" - | "polyOut" - | "polyInOut" - | "quad" - | "quadIn" - | "quadOut" - | "quadInOut" - | "sin" - | "sinIn" - | "sinOut" - | "sinInOut"; - - /** - * Progress Types for Spectacle - */ - type progressType = "pacman" | "bar" | "number" | "none"; - - /** - * S Types for StyledS in Spectacle - */ - type sType = "italic" | "bold" | "line-through" | "underline"; - - /** - * Target Types for links - */ - type targetType = "_blank" | "_self" | "_parent" | "_top"; - - /** - * Theme Types for CodePane in Spectacle - */ - type themeType = "dark" | "light" | "external"; - - /** - * Transition Types for Spectacle - */ - type transitionType = "slide" | "zoom" | "fade" | "spin"; - - /** - * All available DOM style properties and their types - * https://www.npmjs.com/package/csstype - */ - export interface CSSProperties extends CSS.Properties {} - - export interface AnimProps { - easing: easeType; - fromStyle: CSSProperties | CSSProperties[]; - onAnim?: (forwards?: boolean, animIndex?: number) => void; - order?: number; - route?: object; - style?: CSSProperties; - toStyle: CSSProperties | CSSProperties[]; - transitionDuration: number; - } - - export interface AppearProps { - easing?: easeType; - endValue?: object; - fid?: string; - order?: number; - startValue?: object; - style?: BaseProps["style"]; - transitionDuration?: number; - } - - /** - * Base props for many Spectacle components - */ - export interface BaseProps { - bgColor?: string; - bgDarken?: number; - bgImage?: string; - bold?: boolean; - caps?: boolean; - className?: string; - italic?: boolean; - margin?: number | string; - padding?: number | string; - style?: CSSProperties; - textAlign?: string; - textColor?: string; - textFont?: string; - textSize?: string; - } - export interface CodePaneProps { - className?: BaseProps["className"]; - contentEditable?: boolean; - lang?: string; - source?: string; - style?: BaseProps["style"]; - theme?: themeType; - } - - export interface ComponentPlaygroundProps { - code?: string; - previewBackgroundColor?: string; - scope?: object; - theme?: themeType; - transformCode?: (code: string) => string; - } - - export interface DeckProps { - autoplay?: boolean; - autoplayDuration?: number; - autoplayLoop?: boolean; - controls?: boolean; - globalStyles?: boolean; - history?: any; // Needs a type, see https://github.com/ReactTraining/history - onStateChange?: (previousState?: string, nextState?: string) => void - progress?: progressType; - theme?: Theme; - transition?: transitionType[]; - transitionDuration?: number; - } - - export interface FillProps { - className?: string; - style?: CSSProperties; - } - - export interface FitProps extends FillProps {} - - export interface GoToActionProps { - margin?: BaseProps["margin"]; - padding?: BaseProps["padding"]; - render?: (goToSlide?: (slide: number | string) => void) => void; - slide?: number | string; - style?: BaseProps["style"]; - } - - export interface HeadingProps extends BaseProps { - fit?: boolean; - lineHeight?: number; - size?: number; - } - - export interface ImageProps { - alt?: string; - className?: BaseProps["className"]; - display?: string; - height?: number | string; - margin?: BaseProps["margin"]; - padding?: BaseProps["padding"]; - src?: string; - width?: number | string; - } - - export interface LayoutProps { - style?: CSSProperties; - } - - export interface LinkProps extends BaseProps { - href?: string; - target?: targetType; - } - - export interface MarkdownProps { - mdastConfig?: { [key: string]: number | string }; - source?: string; - } - - export interface SlideProps extends BaseProps { - align?: alignType; - contentStyles?: CSSProperties; - controlColor?: string; - dispatch?: () => void; - hash?: number | string; - progressColor?: string; - history?: any; // Needs a type, see https://github.com/ReactTraining/history - id?: string; - lastSlideIndex?: number; - notes?: string; - onActive?: (slideIndex: string | number) => void; - slideIndex?: number; - state?: string; - transition?: transitionType[]; - transitionDuration?: number; - transitionIn?: transitionType[]; - transitionOut?: transitionType[]; - } - - export interface SProps extends BaseProps { - type?: sType | sType[]; - } - - export interface TextProps extends BaseProps { - fit?: boolean; - lineHeight?: number; - } - - export type Theme = { [key: string]: number | string }; - - export class Anim extends React.Component {} - - export class Appear extends React.Component {} - - export class BlockQuote extends React.Component {} - - export class Cite extends React.Component {} - - export class Code extends React.Component {} - - export class CodePane extends React.Component {} - - export class ComponentPlayground extends React.Component< - ComponentPlaygroundProps - > {} - - export class Deck extends React.Component {} - - export class Fill extends React.Component {} - - export class Fit extends React.Component {} - - export class GoToAction extends React.Component {} - - export class Heading extends React.Component {} - - export class Image extends React.Component {} - - export class Layout extends React.Component {} - - export class Link extends React.Component {} - - export class List extends React.Component {} - - export class ListItem extends React.Component {} - - export class Markdown extends React.Component {} - - export class Notes extends React.Component {} - - export class Quote extends React.Component {} - - export class S extends React.Component {} - - export class Slide extends React.Component {} - - export class SlideSet extends React.Component {} - - export class Table extends React.Component {} - - export class TableBody extends React.Component {} - - export class TableHeader extends React.Component {} - - export class TableHeaderItem extends React.Component {} - - export class TableItem extends React.Component {} - - export class TableRow extends React.Component {} - - export class Text extends React.Component {} -} - -declare module "spectacle/lib/utils/preloader" { - const preloader: (obj: object) => void; - export default preloader; -} - -declare module "spectacle/lib/themes/default" { - import { Theme } from "spectacle"; - const createTheme: (...args: object[]) => Theme; - export default createTheme; -} diff --git a/types/spectacle/package.json b/types/spectacle/package.json deleted file mode 100644 index 9de3dd17fa..0000000000 --- a/types/spectacle/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "csstype": "^2.2.0" - } - } diff --git a/types/spectacle/spectacle-tests.tsx b/types/spectacle/spectacle-tests.tsx deleted file mode 100644 index 04c3403f41..0000000000 --- a/types/spectacle/spectacle-tests.tsx +++ /dev/null @@ -1,377 +0,0 @@ -import * as React from "react"; -import { - Anim, - Appear, - BlockQuote, - Cite, - CodePane, - ComponentPlayground, - Deck, - Fill, - GoToAction, - Heading, - Image, - Layout, - Link, - List, - ListItem, - Markdown, - Notes, - Quote, - Slide, - SlideSet, - Table, - TableBody, - TableHeader, - TableHeaderItem, - TableItem, - TableRow, - Text -} from "spectacle"; - -// Import image preloader util -import preloader from "spectacle/lib/utils/preloader"; - -// Import theme -import createTheme from "spectacle/lib/themes/default"; - -const images = { - city: "a-url", - logo: "another-url" -}; - -preloader(images); - -const theme = createTheme( - { - primary: "white", - secondary: "#1F2022", - tertiary: "#03A9FC", - quartenary: "#CECECE" - }, - { - primary: "Montserrat", - secondary: "Helvetica" - } -); - -export class SpectacleTest extends React.Component { - public render() { - return ( - - - - Spectacle - - - A ReactJS Presentation Library - - - Where You Can Write Your Decks In JSX - - - - View on Github - - - - Hit Your Right Arrow To Begin! - - - - - Wait what? - - - - - - Full Width - - - - - Adjustable Darkness - - - - - Background Imagery - - - - - - - - - This is a component playground - - - - Flexible Layouts - - - - - Left - - - - - Right - - - - - - - Inline Markdown - - - {` - You can write inline images, [Markdown Links](http://commonmark.org), paragraph text and most other markdown syntax - * Lists too! - * With ~~strikethrough~~ and _italic_ - * And let's not forget **bold** - * Add some \`inline code\` to your sldes! - `} - - - - { - /* eslint-disable */ - console.log("forwards ", forwards); - console.log("animIndex ", animIndex); - /* eslint-enable */ - }} - fromStyle={{ - opacity: 0, - transform: - "translate3d(0px, -100px, 0px) scale(1) rotate(0deg)" - }} - toStyle={[ - { - opacity: 1, - transform: - "translate3d(0px, 0px, 0px) scale(1) rotate(0deg)" - }, - { - opacity: 1, - transform: - "translate3d(0px, 0px, 0px) scale(1.6) rotate(-15deg)" - }, - { - opacity: 1, - transform: - "translate3d(0px, 0px, 0px) scale(0.8) rotate(0deg)" - } - ]} - easing={"bounceOut"} - transitionDuration={500} - > - - - Flexible -
- animations -
-
-
-
- - - Mix it up! - - - You can even jump to different slides with a standard - button or custom component! - - - Jump to Slide 8 - - ( - - )} - /> - - -
- Wonderfully formatted quotes - Ken Wheeler -
-
- -
- Wonderfully formatted quotes - Ken Wheeler -
-
- - - - - - Inline style based theme system - - - - Autofit text - - - Flexbox layout system - - - PDF export - - - And... - - - - - - You can even share styles with SlideSet - - - - - - Pizza Toppings - - - - - - - 2011 - 2013 - 2015 - - - - - None - 61.8% - 39.6% - 35.0% - - - Pineapple - 28.3% - 54.5% - 61.5% - - - Pepperoni - - 50.2% - 77.2% - - - Olives - - 24.9% - 55.9% - - -
-
-
- - - Made with love in Seattle by - - - - - -
- ); - } -} diff --git a/types/spectacle/tsconfig.json b/types/spectacle/tsconfig.json deleted file mode 100644 index 46722f9753..0000000000 --- a/types/spectacle/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "jsx": "react" - }, - "files": [ - "index.d.ts", - "spectacle-tests.tsx" - ] -} \ No newline at end of file diff --git a/types/spectacle/tslint.json b/types/spectacle/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/spectacle/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "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 - } -} From d41c7388ad92ffcf125130eb9c8201a02008e553 Mon Sep 17 00:00:00 2001 From: AlCalzone Date: Mon, 31 Dec 2018 16:50:05 +0100 Subject: [PATCH 07/69] [iobroker] Add promisified versions of the adapter methods (#31742) * Add async-ified versions of the adapter methods to ioBroker * Add two missing parameters --- types/iobroker/index.d.ts | 358 +++++++++++++++++++++++++++---- types/iobroker/iobroker-tests.ts | 54 +++-- 2 files changed, 339 insertions(+), 73 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index cee6ce75a6..314d8c8e30 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -968,6 +968,11 @@ declare global { * @param callback - gets called when a free port is found */ getPort(port: number, callback: (port: number) => void): void; + /** + * Helper function that looks for first free TCP port starting with the given one. + * @param port - The port to start with + */ + getPortAsync(port: number): Promise; /** Stops the adapter. Note: Is not always defined. */ stop?: () => void; @@ -978,16 +983,52 @@ declare global { /** Validates username and password */ checkPassword(user: string, password: string, callback: (result: boolean) => void): void; checkPassword(user: string, password: string, options: unknown, callback: (result: boolean) => void): void; + /** Validates username and password */ + checkPasswordAsync(user: string, password: string, options?: unknown): Promise; /** Sets a new password for the given user */ - setPassword(user: string, password: string, options?: unknown, callback?: (err?: any) => void): void; + setPassword(user: string, password: string, callback?: (err?: any) => void): void; + setPassword(user: string, password: string, options: unknown, callback?: (err?: any) => void): void; + /** Sets a new password for the given user */ + setPasswordAsync(user: string, password: string, options?: unknown): Promise; /** Checks if a user exists and is in the given group. */ checkGroup(user: string, group: string, callback: (result: boolean) => void): void; checkGroup(user: string, group: string, options: unknown, callback: (result: boolean) => void): void; + /** Checks if a user exists and is in the given group. */ + checkGroupAsync(user: string, group: string, options?: unknown): Promise; /** Determines the users permissions */ calculatePermissions(user: string, commandsPermissions: CommandsPermissions, callback: (result: PermissionSet) => void): void; calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: unknown, callback: (result: PermissionSet) => void): void; + /** Determines the users permissions */ + calculatePermissionsAsync(user: string, commandsPermissions: CommandsPermissions, options?: unknown): Promise; /** Returns SSL certificates by name (private key, public cert and chained certificate) for creation of HTTPS servers */ getCertificates(publicName: string, privateName: string, chainedName: string, callback: (err: string | null, certs?: Certificates, useLetsEncryptCert?: boolean) => void): void; + // TODO: getCertificates cannot be represented with promises right now + + /** + * Terminates the adapter execution but does not disable the adapter + * @param reason (optional) A message to print into the log prior to termination + */ + terminate(reason?: string): never; + + /** Restarts the adapter */ + restart(): never; + + /** + * Disables and stops the adapter instance. + * It is recommended that you leave the current method (e.g. by using `return`) after calling this. + */ + disable(): void; + + /** + * Updates the adapter config with new values. Only a subset of the configuration has to be provided, + * since merging with the existing config is done automatically. + * + * After updating the configuration, the adapter is automatically restarted. It is recommended that you + * leave the current method (e.g. by using `return`) after calling this. + * + * @param newConfig The new config values to be stored + */ + updateConfig(newConfig: Partial): void; /** * Sends a message to a specific instance or all instances of some specific adapter. @@ -999,12 +1040,26 @@ declare global { */ sendTo(instanceName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; sendTo(instanceName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - + /** + * Sends a message to a specific instance or all instances of some specific adapter. + * @param instanceName The instance to send this message to. + * If the ID of an instance is given (e.g. "admin.0"), only this instance will receive the message. + * If the name of an adapter is given (e.g. "admin"), all instances of this adapter will receive it. + * @param command (optional) Command name of the target instance. Default: "send" + * @param message The message (e.g. params) to send. + */ + sendToAsync(instanceName: string, message: string | object): Promise; + sendToAsync(instanceName: string, command: string, message: string | object): Promise; /** * Sends a message to a specific host or all hosts. */ sendToHost(hostName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; sendToHost(hostName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + /** + * Sends a message to a specific host or all hosts. + */ + sendToHostAsync(hostName: string, message: string | object): Promise; + sendToHostAsync(hostName: string, command: string, message: string | object): Promise; /** Convert ID to {device: D, channel: C, state: S} */ idToDCS(id: string): { @@ -1019,109 +1074,175 @@ declare global { /** Reads an object from the object db */ getObject(id: string, callback: GetObjectCallback): void; getObject(id: string, options: unknown, callback: GetObjectCallback): void; + /** Reads an object from the object db */ + getObjectAsync(id: string, options?: unknown): Promise>; /** Creates or overwrites an object in the object db */ setObject(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates or overwrites an object in the object db */ + setObjectAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Creates an object in the object db. Existing objects are not overwritten. */ setObjectNotExists(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setObjectNotExists(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates an object in the object db. Existing objects are not overwritten. */ + setObjectNotExistsAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Get all states, channels and devices of this adapter */ getAdapterObjects(callback: (objects: Record) => void): void; + /** Get all states, channels and devices of this adapter */ + getAdapterObjectsAsync(): Promise>; /** Extend an object and create it if it might not exist */ extendObject(id: string, objPart: PartialObject, callback?: SetObjectCallback): void; extendObject(id: string, objPart: PartialObject, options: unknown, callback?: SetObjectCallback): void; + /** Extend an object and create it if it might not exist */ + extendObjectAsync(id: string, objPart: PartialObject, options?: unknown): Promise>; /** * Deletes an object from the object db * @param id - The id of the object without namespace */ delObject(id: string, callback?: ErrorCallback): void; delObject(id: string, options: unknown, callback?: ErrorCallback): void; + /** + * Deletes an object from the object db + * @param id - The id of the object without namespace + */ + delObjectAsync(id: string, options?: unknown): Promise; // ============================== // foreign objects - // tslint:disable:unified-signatures /** Reads an object (which might not belong to this adapter) from the object db */ getForeignObject(id: string, callback: GetObjectCallback): void; getForeignObject(id: string, options: unknown, callback: GetObjectCallback): void; + /** Reads an object (which might not belong to this adapter) from the object db */ + getForeignObjectAsync(id: string, options?: unknown): Promise>; /** Get foreign objects by pattern, by specific type and resolve their enums. */ + // tslint:disable:unified-signatures getForeignObjects(pattern: string, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, options: unknown, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, options: unknown, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: unknown, callback: GetObjectsCallback): void; + // tslint:enable:unified-signatures + /** Get foreign objects by pattern, by specific type and resolve their enums. */ + getForeignObjectsAsync(pattern: string, options?: unknown): Promise>; + getForeignObjectsAsync(pattern: string, type: ObjectType, options?: unknown): Promise>; + getForeignObjectsAsync(pattern: string, type: ObjectType, enums: EnumList, options?: unknown): Promise>; /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ setForeignObject(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setForeignObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ + setForeignObjectAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ setForeignObjectNotExists(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setForeignObjectNotExists(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ + setForeignObjectNotExistsAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ extendForeignObject(id: string, objPart: PartialObject, callback?: SetObjectCallback): void; extendForeignObject(id: string, objPart: PartialObject, options: unknown, callback?: SetObjectCallback): void; - // tslint:enable:unified-signatures + /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ + extendForeignObjectAsync(id: string, objPart: PartialObject, options?: unknown): Promise>; /** * Finds an object by its ID or name * @param type - common.type of the state */ findForeignObject(idOrName: string, type: string, callback: FindObjectCallback): void; findForeignObject(idOrName: string, type: string, options: unknown, callback: FindObjectCallback): void; + /** + * Finds an object by its ID or name + * @param type - common.type of the state + */ + findForeignObjectAsync(idOrName: string, type: string): Promise<{ id: string, name: string }>; /** * Deletes an object (which might not belong to this adapter) from the object db * @param id - The id of the object including namespace */ delForeignObject(id: string, callback?: ErrorCallback): void; delForeignObject(id: string, options: unknown, callback?: ErrorCallback): void; + /** + * Deletes an object (which might not belong to this adapter) from the object db + * @param id - The id of the object including namespace + */ + delForeignObjectAsync(id: string, options?: unknown): Promise; // ============================== // states // Multiple signatures help understanding what the parameters are about - // tslint:disable:unified-signatures /** Writes a value into the states DB. */ + // tslint:disable:unified-signatures setState(id: string, state: string | number | boolean | State | Partial, callback?: SetStateCallback): void; setState(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateCallback): void; setState(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateCallback): void; setState(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateCallback): void; + /** Writes a value into the states DB. */ + setStateAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setStateAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setStateAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; /** Writes a value into the states DB only if it has changed. */ setStateChanged(id: string, state: string | number | boolean | State | Partial, callback?: SetStateChangedCallback): void; setStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateChangedCallback): void; setStateChanged(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateChangedCallback): void; setStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateChangedCallback): void; + /** Writes a value into the states DB only if it has changed. */ + setStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setStateChangedAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; /** Writes a value (which might not belong to this adapter) into the states DB. */ setForeignState(id: string, state: string | number | boolean | State | Partial, callback?: SetStateCallback): void; setForeignState(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateCallback): void; setForeignState(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateCallback): void; setForeignState(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB. */ + setForeignStateAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setForeignStateAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setForeignStateAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, callback?: SetStateChangedCallback): void; setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateChangedCallback): void; setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateChangedCallback): void; setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateChangedCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ + setForeignStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setForeignStateChangedAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setForeignStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; // tslint:enable:unified-signatures /** Read a value from the states DB. */ getState(id: string, callback: GetStateCallback): void; getState(id: string, options: unknown, callback: GetStateCallback): void; + /** Read a value from the states DB. */ + getStateAsync(id: string, options?: unknown): Promise>; /** Read a value (which might not belong to this adapter) from the states DB. */ getForeignState(id: string, callback: GetStateCallback): void; getForeignState(id: string, options: unknown, callback: GetStateCallback): void; + /** Read a value (which might not belong to this adapter) from the states DB. */ + getForeignStateAsync(id: string, options?: unknown): Promise>; /** Read all states of this adapter which match the given pattern */ getStates(pattern: string, callback: GetStatesCallback): void; getStates(pattern: string, options: unknown, callback: GetStatesCallback): void; + /** Read all states of this adapter which match the given pattern */ + getStatesAsync(pattern: string, options?: unknown): Promise>; /** Read all states (which might not belong to this adapter) which match the given pattern */ getForeignStates(pattern: string, callback: GetStatesCallback): void; getForeignStates(pattern: string, options: unknown, callback: GetStatesCallback): void; + /** Read all states (which might not belong to this adapter) which match the given pattern */ + getForeignStatesAsync(pattern: string, options?: unknown): Promise>; /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ delState(id: string, callback?: ErrorCallback): void; delState(id: string, options: unknown, callback?: ErrorCallback): void; + /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ + delStateAsync(id: string, options?: unknown): Promise; /** Deletes a state from the states DB, but not the associated object */ delForeignState(id: string, callback?: ErrorCallback): void; delForeignState(id: string, options: unknown, callback?: ErrorCallback): void; + /** Deletes a state from the states DB, but not the associated object */ + delForeignStateAsync(id: string, options?: unknown): Promise; getHistory(id: string, options: GetHistoryOptions, callback: GetHistoryCallback): void; + // TODO: getHistoryAsync // MISSING: // pushFifo and similar https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4105 @@ -1138,6 +1259,13 @@ declare global { */ setBinaryState(id: string, binary: Buffer, callback: SetStateCallback): void; setBinaryState(id: string, binary: Buffer, options: unknown, callback: SetStateCallback): void; + /** + * Writes a binary state into Redis + * @param id The id of the state + * @param binary The data to be written + * @param options (optional) Some internal options. + */ + setBinaryStateAsync(id: string, binary: Buffer, options?: unknown): Promise>; /** * Reads a binary state from Redis * @param id The id of the state @@ -1146,6 +1274,12 @@ declare global { */ getBinaryState(id: string, callback: GetBinaryStateCallback): void; getBinaryState(id: string, options: unknown, callback: GetBinaryStateCallback): void; + /** + * Reads a binary state from Redis + * @param id The id of the state + * @param options (optional) Some internal options. + */ + getBinaryStateAsync(id: string, options?: unknown): Promise>; // ============================== // enums @@ -1154,27 +1288,42 @@ declare global { getEnum(callback: GetEnumCallback): void; getEnum(name: string, callback: GetEnumCallback): void; getEnum(name: string, options: unknown, callback: GetEnumCallback): void; + /** Returns the enum tree, filtered by the optional enum name */ + getEnumAsync(name: string, options?: unknown): Promise<{ result: Record, requestEnum: string }>; + /** Returns the enum tree, filtered by the optional enum name */ getEnums(callback: GetEnumsCallback): void; getEnums(enumList: EnumList, callback: GetEnumsCallback): void; getEnums(enumList: EnumList, options: unknown, callback: GetEnumsCallback): void; + /** Returns the enum tree, filtered by the optional enum name */ + getEnumsAsync(enumList: EnumList, options?: unknown): Promise>; - addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; - deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, callback?: ErrorCallback): void; + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options: unknown, callback?: ErrorCallback): void; + addChannelToEnumAsync(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: unknown): Promise; - addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; - deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options: unknown, callback?: ErrorCallback): void; + deleteChannelFromEnumAsync(enumName: string, parentDevice: string, channelName: string, options?: unknown): Promise; + + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, callback?: ErrorCallback): void; + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options: unknown, callback?: ErrorCallback): void; + addStateToEnumAsync(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown): Promise; + + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, callback?: ErrorCallback): void; + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options: unknown, callback?: ErrorCallback): void; + deleteStateFromEnumAsync(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown): Promise; // ============================== // subscriptions /** Subscribe to changes of objects in this instance */ - subscribeObjects(pattern: string, options?: unknown): void; + subscribeObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Subscribe to changes of objects (which might not belong to this adapter) */ - subscribeForeignObjects(pattern: string, options?: unknown): void; + subscribeForeignObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Unsubscribe from changes of objects in this instance */ - unsubscribeObjects(pattern: string, options?: unknown): void; + unsubscribeObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Unsubscribe from changes of objects (which might not belong to this adapter) */ - unsubscribeForeignObjects(pattern: string, options?: unknown): void; + unsubscribeForeignObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Subscribe to changes of states in this instance */ subscribeStates(pattern: string, options?: unknown, callback?: ErrorCallback): void; @@ -1194,24 +1343,80 @@ declare global { // ============================== // devices and channels + // tslint:disable:unified-signatures /** creates an object with type device */ - createDevice(deviceName: string, common?: any, native?: any, options?: unknown, callback?: SetObjectCallback): void; + createDevice(deviceName: string, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common: Partial, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common: Partial, native: Record, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common: Partial, native: Record, options: unknown, callback?: SetObjectCallback): void; + /** creates an object with type device */ + createDeviceAsync(deviceName: string, common?: Partial): Promise>; + createDeviceAsync(deviceName: string, common: Partial, native?: Record): Promise>; + createDeviceAsync(deviceName: string, common: Partial, native: Record, options?: unknown): Promise>; /** deletes a device, its channels and states */ - deleteDevice(deviceName: string, options?: unknown, callback?: ErrorCallback): void; - /** gets the devices of this instance */ + deleteDevice(deviceName: string, callback?: ErrorCallback): void; + deleteDevice(deviceName: string, options: unknown, callback?: ErrorCallback): void; + /** deletes a device, its channels and states */ + deleteDeviceAsync(deviceName: string, options?: unknown): Promise; - /** creates an object with type channel */ - createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: unknown, callback?: SetObjectCallback): void; - /** deletes a channel and its states */ + /** Creates an object with type channel. It must be located under a device */ + createChannel(parentDevice: string, channelName: string, callback?: SetObjectCallback): void; + createChannel(parentDevice: string, channelName: string, roleOrCommon: string | Partial, callback?: SetObjectCallback): void; + createChannel(parentDevice: string, channelName: string, roleOrCommon: string | Partial, native: Record, callback?: SetObjectCallback): void; + createChannel( + parentDevice: string, channelName: string, roleOrCommon: string | Partial, + native: Record, options: unknown, callback?: SetObjectCallback + ): void; + /** Creates an object with type channel. It must be located under a device */ + createChannelAsync(parentDevice: string, channelName: string, roleOrCommon?: string | Partial): Promise>; + createChannelAsync( + parentDevice: string, channelName: string, roleOrCommon: string | Partial, native?: Record + ): Promise>; + createChannelAsync( + parentDevice: string, channelName: string, roleOrCommon: string | Partial, native: Record, + options?: unknown + ): Promise>; + /** Deletes a channel and its states. It must have been created with `createChannel` */ deleteChannel(channelName: string, options?: unknown, callback?: ErrorCallback): void; deleteChannel(parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; + /** Deletes a channel and its states. It must have been created with `createChannel` */ + deleteChannelAsync(channelName: string, options?: unknown): Promise; + deleteChannelAsync(parentDevice: string, channelName: string, options?: unknown): Promise; - /** creates a state and the corresponding object */ - createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: unknown, callback?: SetObjectCallback): void; - /** deletes a state */ + /** + * Creates a state and the corresponding object. It must be located in a channel under a device + */ + createState(parentDevice: string, parentChannel: string, stateName: string, callback?: SetObjectCallback): void; + createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, callback?: SetObjectCallback): void; + createState( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native: Record, callback?: SetObjectCallback + ): void; + createState( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native: Record, options: unknown, callback?: SetObjectCallback + ): void; + /** + * Creates a state and the corresponding object. It must be located in a channel under a device + */ + createStateAsync(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | Partial): Promise>; + createStateAsync( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native?: Record + ): Promise>; + createStateAsync( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native: Record, options?: unknown + ): Promise>; + /** Deletes a state. It must have been created with `createState` */ deleteState(stateName: string, options?: unknown, callback?: ErrorCallback): void; deleteState(parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; + /** Deletes a state. It must have been created with `createState` */ + deleteStateAsync(stateName: string, options?: unknown): Promise; + deleteStateAsync(parentChannel: string, stateName: string, options?: unknown): Promise; + deleteStateAsync(parentDevice: string, parentChannel: string, stateName: string, options?: unknown): Promise; + // tslint:enable:unified-signatures /** * Returns a list of all devices in this adapter instance @@ -1220,6 +1425,12 @@ declare global { */ getDevices(callback: GetObjectsCallback3): void; getDevices(options: unknown, callback: GetObjectsCallback3): void; + /** + * Returns a list of all devices in this adapter instance + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getDevicesAsync(options?: unknown): Promise>>; /** * Returns a list of all channels in this adapter instance @@ -1228,8 +1439,8 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getChannels(callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, options: unknown, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string, options: unknown, callback: GetObjectsCallback3): void; /** * Returns a list of all channels in this adapter instance * @param parentDevice (optional) Name of the parent device to filter the channels by @@ -1237,8 +1448,16 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getChannelsOf(callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, options: unknown, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string, options: unknown, callback: GetObjectsCallback3): void; + /** + * Returns a list of all channels in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param options (optional) Some internal options. + */ + getChannelsOfAsync(): Promise>>; + // tslint:disable-next-line:unified-signatures + getChannelsOfAsync(parentDevice: string, options?: unknown): Promise>>; /** * Returns a list of all states in this adapter instance @@ -1248,36 +1467,82 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getStatesOf(callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, options: unknown, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string, parentChannel: string, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string, parentChannel: string, options: unknown, callback: GetObjectsCallback3): void; + /** + * Returns a list of all states in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param parentChannel (optional) Name of the parent channel to filter the channels by + * @param options (optional) Some internal options. + */ + // tslint:disable:unified-signatures + getStatesOfAsync(): Promise>>; + getStatesOfAsync(parentDevice: string, parentChannel?: string): Promise>>; + getStatesOfAsync(parentDevice: string, parentChannel: string, options?: unknown): Promise>>; + // tslint:enable:unified-signatures // ============================== // filesystem /** * reads the content of directory from DB for given adapter and path - * @param adapter - adapter name. If adapter name is null, default will be the name of the current adapter. - * @param path - path to direcory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". */ - readDir(adapterName: string, path: string, callback: ReadDirCallback): void; - readDir(adapterName: string, path: string, options: unknown, callback: ReadDirCallback): void; - mkDir(adapterName: string, path: string, callback: ErrorCallback): void; - mkDir(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; + readDir(adapterName: string | null, path: string, callback: ReadDirCallback): void; + readDir(adapterName: string | null, path: string, options: unknown, callback: ReadDirCallback): void; + /** + * reads the content of directory from DB for given adapter and path + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + readDirAsync(adapterName: string | null, path: string, options?: unknown): Promise>; - readFile(adapterName: string, path: string, callback: ReadFileCallback): void; - readFile(adapterName: string, path: string, options: unknown, callback: ReadFileCallback): void; - writeFile(adapterName: string, path: string, data: Buffer | string, callback: ErrorCallback): void; + mkDir(adapterName: string | null, path: string, callback: ErrorCallback): void; + mkDir(adapterName: string | null, path: string, options: unknown, callback: ErrorCallback): void; + mkDirAsync(adapterName: string | null, path: string, options?: unknown): Promise; + + readFile(adapterName: string | null, path: string, callback: ReadFileCallback): void; + readFile(adapterName: string | null, path: string, options: unknown, callback: ReadFileCallback): void; + readFileAsync(adapterName: string | null, path: string, options?: unknown): Promise<{ file: string | Buffer, mimeType: string }>; + + writeFile(adapterName: string | null, path: string, data: Buffer | string, callback: ErrorCallback): void; // options see https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/objects/objectsInMemServer.js#L599 - writeFile(adapterName: string, path: string, data: Buffer | string, options: unknown, callback: ErrorCallback): void; + writeFile(adapterName: string | null, path: string, data: Buffer | string, options: unknown, callback: ErrorCallback): void; + writeFileAsync(adapterName: string | null, path: string, data: Buffer | string, options?: unknown): Promise; - delFile(adapterName: string, path: string, callback: ErrorCallback): void; - delFile(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + delFile(adapterName: string | null, path: string, callback: ErrorCallback): void; + delFile(adapterName: string | null, path: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + delFileAsync(adapterName: string | null, path: string, options?: unknown): Promise; - rename(adapterName: string, oldName: string, newName: string, callback: ErrorCallback): void; - rename(adapterName: string, oldName: string, newName: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + unlink(adapterName: string | null, path: string, callback: ErrorCallback): void; + unlink(adapterName: string | null, path: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + unlinkAsync(adapterName: string | null, path: string, options?: unknown): Promise; + + rename(adapterName: string | null, oldName: string, newName: string, callback: ErrorCallback): void; + rename(adapterName: string | null, oldName: string, newName: string, options: unknown, callback: ErrorCallback): void; + renameAsync(adapterName: string | null, oldName: string, newName: string, options?: unknown): Promise; /** * Changes access rights of all files in the adapter directory @@ -1287,6 +1552,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ chmodFile(adapter: string | null, path: string, options: { mode: number | string } | Record, callback: ChownFileCallback): void; + chmodFileAsync(adapter: string | null, path: string, options: { mode: number | string } | Record): Promise<{ entries: ChownFileResult[], id: string }>; // ============================== // formatting @@ -1354,6 +1620,8 @@ declare global { // This is a version used by GetDevices/GetChannelsOf/GetStatesOf type GetObjectsCallback3 = (err: string | null, result?: Array>) => void; + type SecondParameterOf any> = T extends (arg0: any, arg1: infer R, ...args: any[]) => any ? R : never; + type CallbackReturnTypeOf any> = Exclude, null | undefined>; type GetStateCallback = (err: string | null, state: State | null | undefined) => void; type GetStatesCallback = (err: string | null, states: Record) => void; /** Version of the callback used by States.getStates */ diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index 997775c76f..fcdc4d5c9e 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -1,34 +1,7 @@ -// For now, this "utils" module is necessary, as it is included in every adapter -// Once this PR is merged and @types/iobroker is available, it will become part of -// `iobroker.adapter-core`, which brings typings for it -declare const utils: { - readonly controllerDir: string; - getConfig(): string; - - // tslint:disable:unified-signatures - adapter(adapterName: string): ioBroker.Adapter; - adapter(adapterOptions: ioBroker.AdapterOptions): ioBroker.Adapter; - // tslint:enable:unified-signatures -}; - declare function assertNever(val: never): never; // Let the tests begin -let adapter: ioBroker.Adapter; - -// Test constructors -adapter = utils.adapter("my-adapter-name"); -adapter = utils.adapter({ - name: "my-adapter-name" -}); -adapter = utils.adapter({ - name: "my-adapter-name", - ready: readyHandler, - stateChange: stateChangeHandler, - objectChange: objectChangeHandler, - message: messageHandler, - unload: unloadHandler, -}); +declare let adapter: ioBroker.Adapter; // Test EventEmitter definitions adapter @@ -141,37 +114,62 @@ adapter.setState("state.name", "value", (err, id) => { }); adapter.setState("state.name", { val: "value", ack: true }); adapter.setState("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setStateAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setStateAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setStateAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setStateChanged("state.name", "value"); adapter.setStateChanged("state.name", "value", true); adapter.setStateChanged("state.name", "value", (err, id) => { }); adapter.setStateChanged("state.name", { val: "value", ack: true }); adapter.setStateChanged("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setStateChangedAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setStateChangedAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setStateChangedAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setForeignState("state.name", "value"); adapter.setForeignState("state.name", "value", true); adapter.setForeignState("state.name", "value", (err, id) => { }); adapter.setForeignState("state.name", { val: "value", ack: true }); adapter.setForeignState("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setForeignStateAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setForeignStateAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setForeignStateAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setForeignStateChanged("state.name", "value"); adapter.setForeignStateChanged("state.name", "value", true); adapter.setForeignStateChanged("state.name", "value", (err, id) => { }); adapter.setForeignStateChanged("state.name", { val: "value", ack: true }); adapter.setForeignStateChanged("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setForeignStateChangedAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setForeignStateChangedAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setForeignStateChangedAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); adapter.setForeignObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setForeignObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); +adapter.setObjectAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); +adapter.setForeignObjectAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); + adapter.setObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); adapter.setForeignObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setForeignObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); +adapter.setObjectNotExistsAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); +adapter.setForeignObjectNotExistsAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); + adapter.getObject("obj.id", (err, obj) => { }); adapter.getForeignObject("obj.id", (err, obj) => { }); +adapter.getObjectAsync("obj.id").then(obj => obj._id.toLowerCase()); +adapter.getForeignObjectAsync("obj.id").then(obj => obj._id.toLowerCase()); + adapter.subscribeObjects("*"); adapter.subscribeStates("*"); adapter.subscribeForeignObjects("*"); From 73a13ef947a066cf6fcc2c68b622703c9173c1a4 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 31 Dec 2018 11:50:25 -0400 Subject: [PATCH 08/69] add new overload for v6 of klaw-sync (#31732) --- types/klaw-sync/index.d.ts | 13 ++++++++++++- types/klaw-sync/klaw-sync-tests.ts | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/types/klaw-sync/index.d.ts b/types/klaw-sync/index.d.ts index 78ca30b2ff..707bdf094f 100644 --- a/types/klaw-sync/index.d.ts +++ b/types/klaw-sync/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for klaw-sync 5.0 +// Type definitions for klaw-sync 6.0 // Project: https://github.com/manidlou/node-klaw-sync // Definitions by: Brendan Forster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -53,6 +53,17 @@ declare namespace klawSync { * @since v2.0.0 */ filter?: Filter + + /** + * @description traverse all subdirectories, regardless of `filter` option. + * + * When set to true, traverseAll produces similar behavior to the default + * behavior prior to `v4.0.0`. The current default of `traverseAll: false` + * is equivalent to the old `noRecurseOnFailedFilter: true`). + * + * @since v6.0.0 + */ + traverseAll?: boolean } } diff --git a/types/klaw-sync/klaw-sync-tests.ts b/types/klaw-sync/klaw-sync-tests.ts index 41719734bf..1a5729ed7e 100644 --- a/types/klaw-sync/klaw-sync-tests.ts +++ b/types/klaw-sync/klaw-sync-tests.ts @@ -18,7 +18,8 @@ const options: klawSync.Options = { return item.path.indexOf('node_modules') < 0 }, depthLimit: 5, - fs + fs, + traverseAll: true } klawSync('/some/dir', options).forEach(outputMessage) From e5193ae9cf4c9f63ed1259b949d20896274cf3e3 Mon Sep 17 00:00:00 2001 From: Resi Respati Date: Mon, 31 Dec 2018 22:52:59 +0700 Subject: [PATCH 09/69] [screeps] Release 2.5.3 (#31724) --- types/screeps/index.d.ts | 153 +++++++++++++++------------------ types/screeps/screeps-tests.ts | 6 ++ 2 files changed, 77 insertions(+), 82 deletions(-) diff --git a/types/screeps/index.d.ts b/types/screeps/index.d.ts index 27ca10960d..3ae5315443 100644 --- a/types/screeps/index.d.ts +++ b/types/screeps/index.d.ts @@ -1439,6 +1439,16 @@ interface FindPathOpts { * Path to within (range) tiles of target tile. The default is to path to the tile that the target is on (0). */ range?: number; + + /** + * Cost for walking on plain positions. The default is 1. + */ + plainCost?: number; + + /** + * Cost for walking on swamp positions. The default is 5. + */ + swampCost?: number; } interface MoveToOpts extends FindPathOpts { @@ -1499,7 +1509,7 @@ interface _Constructor { } interface _ConstructorById extends _Constructor { - new (id: string): T; + new(id: string): T; (id: string): T; } /* @@ -1949,87 +1959,66 @@ type EVENT_HEAL_TYPE_RANGED = 2; type EventDestroyType = "creep" | StructureConstant; -type EventItem = - | { - type: EVENT_ATTACK; - objectId: string; - data: { - targetId: string; - damage: number; - attackType: EventAttackType; - }; - } - | { - type: EVENT_OBJECT_DESTROYED; - objectId: string; - data: { - type: EventDestroyType; - }; - } - | { - type: EVENT_ATTACK_CONTROLLER; - objectId: string; - } - | { - type: EVENT_BUILD; - objectId: string; - data: { - targetId: string; - amount: number; - energySpent: number; - }; - } - | { - type: EVENT_HARVEST; - objectId: string; - data: { - targetId: string; - amount: number; - }; - } - | { - type: EVENT_HEAL; - objectId: string; - data: { - targetId: string; - amount: number; - healType: EventHealType; - }; - } - | { - type: EVENT_REPAIR; - objectId: string; - data: { - targetId: string; - amount: number; - energySpent: number; - }; - } - | { - type: EVENT_RESERVE_CONTROLLER; - objectId: string; - data: { - amount: number; - }; - } - | { - type: EVENT_UPGRADE_CONTROLLER; - objectId: string; - data: - | { - amount: number; - energySpent: number; - } - | { - type: EVENT_EXIT; - objectId: string; - data: { - room: string; - x: number; - y: number; - }; - }; - }; +interface EventItem { + event: T; + objectId: string; + data: EventData[T]; +} + +interface EventData { + [key: number]: null | { + targetId?: string; + damage?: number; + attackType?: EventAttackType; + amount?: number; + energySpent?: number; + type?: EventDestroyType; + healType?: EventHealType; + room?: string; + x?: number; + y?: number; + }; + 1: { // EVENT_ATTACK + targetId: string; + damage: number; + attackType: EventAttackType; + }; + 2: { // EVENT_OBJECT_DESTORYED + type: EventDestroyType; + }; + 3: null; // EVENT_ATTACK_CONTROLLER + 4: { // EVENT_BUILD + targetId: string; + amount: number; + energySpent: number; + }; + 5: { // EVENT_HARVEST + targetId: string; + amount: number; + }; + 6: { // EVENT_HEAL + targetId: string; + amount: number; + healType: EventHealType; + }; + 7: { // EVENT_REPAIR + targetId: string; + amount: number; + energySpent: number; + }; + 8: { // EVENT_RESERVE_CONTROLLER + amount: number; + }; + 9: { // EVENT_UPGRADE_CONTROLLER + amount: number; + energySpent: number; + }; + 10: { // EVENT_EXIT + room: string; + x: number; + y: number; + }; +} /** * The options that can be accepted by `findRoute()` and friends. */ diff --git a/types/screeps/screeps-tests.ts b/types/screeps/screeps-tests.ts index d7befaf3bd..6a47cb3e0a 100644 --- a/types/screeps/screeps-tests.ts +++ b/types/screeps/screeps-tests.ts @@ -655,6 +655,12 @@ function keys(o: T): Array { { room.getEventLog(); room.getEventLog(true); + + const events = room.getEventLog(); + + const event = events[0] as EventItem; + + event.data.attackType; } // Room.Terrain From 6043c9f4bb483e5a970c05f2bd6e3af2acba4d76 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza <32041843+PopGoesTheWza@users.noreply.github.com> Date: Mon, 31 Dec 2018 16:53:27 +0100 Subject: [PATCH 10/69] @types/google-apps-script "December 13, 2018" update (#31702) * GAS "December 13, 2018" update * Update google-apps-script.forms.d.ts * add data-studio, rename card-service, order as per ref page --- .../google-apps-script.base.d.ts | 18 +- ...s => google-apps-script.card-service.d.ts} | 101 +++++- .../google-apps-script.charts.d.ts | 18 +- .../google-apps-script.data-studio.d.ts | 301 ++++++++++++++++++ .../google-apps-script.forms.d.ts | 4 +- .../google-apps-script.gmail.d.ts | 3 +- .../google-apps-script.groups.d.ts | 8 +- .../google-apps-script.script.d.ts | 6 +- .../google-apps-script.slides.d.ts | 97 +++++- .../google-apps-script.spreadsheet.d.ts | 135 +++++++- .../google-apps-script.utilities.d.ts | 15 +- types/google-apps-script/index.d.ts | 13 +- 12 files changed, 671 insertions(+), 48 deletions(-) rename types/google-apps-script/{google-apps-script.card.d.ts => google-apps-script.card-service.d.ts} (84%) create mode 100644 types/google-apps-script/google-apps-script.data-studio.d.ts diff --git a/types/google-apps-script/google-apps-script.base.d.ts b/types/google-apps-script/google-apps-script.base.d.ts index 7558263306..0b5236af0f 100644 --- a/types/google-apps-script/google-apps-script.base.d.ts +++ b/types/google-apps-script/google-apps-script.base.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ declare namespace GoogleAppsScript { export module Base { - /** + /** * A data interchange object for Apps Script services. */ export interface Blob { @@ -74,9 +74,10 @@ declare namespace GoogleAppsScript { } /** - * This class provides access to G Suite specific dialog boxes. + * This class provides access to dialog boxes specific to Google Sheets. * * The methods in this class are only available for use in the context of a Google Spreadsheet. + * Please use G Suite dialogs instead. * See also * * ButtonSet @@ -163,9 +164,9 @@ declare namespace GoogleAppsScript { /** * An enumeration that provides access to MIME-type declarations without typing the strings - * explicitly. Any method that expects a MIME type rendered as a string (for example, - * 'image/png') will also accept one of the values below, so long as the method - * supports the underlying MIME type. + * explicitly. Methods that expect a MIME type rendered as a string (for example, + * 'image/png') also accept any of the values below, so long as the method supports the + * underlying MIME type. * * // Use MimeType enum to log the name of every Google Doc in the user's Drive. * var docs = DriveApp.getFilesByType(MimeType.GOOGLE_DOCS); @@ -305,11 +306,15 @@ declare namespace GoogleAppsScript { * } */ export interface console { + error(): void; error(formatOrObject: Object, ...values: Object[]): void; + info(): void; info(formatOrObject: Object, ...values: Object[]): void; + log(): void; log(formatOrObject: Object, ...values: Object[]): void; time(label: string): void; timeEnd(label: string): void; + warn(): void; warn(formatOrObject: Object, ...values: Object[]): void; } @@ -321,3 +326,4 @@ declare var Logger: GoogleAppsScript.Base.Logger; // conflicts with MimeType in lib.d.ts // declare var MimeType: GoogleAppsScript.Base.MimeType; declare var Session: GoogleAppsScript.Base.Session; +declare var console: GoogleAppsScript.Base.console; diff --git a/types/google-apps-script/google-apps-script.card.d.ts b/types/google-apps-script/google-apps-script.card-service.d.ts similarity index 84% rename from types/google-apps-script/google-apps-script.card.d.ts rename to types/google-apps-script/google-apps-script.card-service.d.ts index 60a8bb9d37..64f5194595 100644 --- a/types/google-apps-script/google-apps-script.card.d.ts +++ b/types/google-apps-script/google-apps-script.card-service.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ /// declare namespace GoogleAppsScript { - export module Card { + export module Card_Service { /** * An action that enables interactivity within UI elements. The action does not happen directly on * the client but rather invokes an Apps Script callback function with optional parameters. @@ -37,7 +37,7 @@ declare namespace GoogleAppsScript { * // An action that shows a notification. * var actionResponse = CardService.newActionResponseBuilder() * .setNotification(CardService.newNotification() - * .setType(CardService.Notification.INFO) + * .setType(CardService.NotificationType.INFO) * .setText("Some info to display to user")) * .build(); * @@ -251,6 +251,7 @@ declare namespace GoogleAppsScript { */ export interface CardService { ComposedEmailType: typeof ComposedEmailType; + ContentType: typeof ContentType; Icon: typeof Icon; ImageStyle: typeof ImageStyle; LoadIndicator: typeof LoadIndicator; @@ -258,6 +259,8 @@ declare namespace GoogleAppsScript { OnClose: typeof OnClose; OpenAs: typeof OpenAs; SelectionInputType: typeof SelectionInputType; + TextButtonStyle: typeof TextButtonStyle; + UpdateDraftBodyType: typeof UpdateDraftBodyType; newAction(): Action; newActionResponseBuilder(): ActionResponseBuilder; newAuthorizationAction(): AuthorizationAction; @@ -282,11 +285,18 @@ declare namespace GoogleAppsScript { newTextInput(): TextInput; newTextParagraph(): TextParagraph; newUniversalActionResponseBuilder(): UniversalActionResponseBuilder; + newUpdateDraftActionResponseBuilder(): UpdateDraftActionResponseBuilder; + newUpdateDraftBodyAction(): UpdateDraftBodyAction; } /** * The response object that may be returned from a callback method for compose action in a Gmail add-on. * + * Note: This object isn't related to compose actions that are + * used to extend the compose UI. Rather, + * this object is a response to an Action that composes draft messages when a specific UI element is + * selected. + * * var composeActionResponse = CardService.newComposeActionResponseBuilder() * .setGmailDraft(GmailApp.createDraft("recipient", "subject", "body")) * .build(); @@ -297,6 +307,11 @@ declare namespace GoogleAppsScript { /** * A builder for ComposeActionResponse objects. + * + * Note: This object isn't related to compose actions that are + * used to extend the compose UI. Rather, + * this builder creates responses to an Action that composes draft messages when a specific + * UI element is selected. */ export interface ComposeActionResponseBuilder { build(): ComposeActionResponse; @@ -308,6 +323,11 @@ declare namespace GoogleAppsScript { */ export enum ComposedEmailType { REPLY_AS_DRAFT, STANDALONE_DRAFT } + /** + * An enum value that specifies the content type of the content generated by a UpdateDraftActionResponse. + */ + export enum ContentType { TEXT, MUTABLE_HTML, IMMUTABLE_HTML } + /** * Predefined icons that can be used in various UI objects, such as ImageButton or KeyValue widgets. */ @@ -579,13 +599,25 @@ declare namespace GoogleAppsScript { */ export interface TextButton { setAuthorizationAction(action: AuthorizationAction): TextButton; + setBackgroundColor(backgroundColor: string): TextButton; setComposeAction(action: Action, composedEmailType: ComposedEmailType): TextButton; + setDisabled(disabled: boolean): TextButton; setOnClickAction(action: Action): TextButton; setOnClickOpenLinkAction(action: Action): TextButton; setOpenLink(openLink: OpenLink): TextButton; setText(text: string): TextButton; + setTextButtonStyle(textButtonStyle: TextButtonStyle): TextButton; } + /** + * An enum that specifies the style for TextButton. + * + * TEXT is the default; it renders a simple text button with clear background. + * FILLED buttons have a background color you can set with + * TextButton.setBackgroundColor(backgroundColor). + */ + export enum TextButtonStyle { TEXT, FILLED } + /** * A input field widget that accepts text input. * @@ -648,6 +680,67 @@ declare namespace GoogleAppsScript { setOpenLink(openLink: OpenLink): UniversalActionResponseBuilder; } + /** + * Represents an action that updates the email draft that the user is currently editing. + * + * // A UpdateDraftActionResponse that inserts non-editable content (a link in this case) into an + * // email draft. + * var updateDraftActionResponse = CardService.newUpdateDraftActionResponseBuilder() + * .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction() + * .addUpdateContent( + * "Google", + * ContentType.IMMUTABLE_HTML) + * .setUpdateType(UpdateDraftBodyType.IN_PLACE_INSERT)) + * .build(); + * + * // A UpdateDraftActionResponse that inserts a link into an email draft. The added content can be + * // edited further. + * var updateDraftActionResponse = CardService.newUpdateDraftActionResponseBuilder() + * .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction() + * .addUpdateContent( + * "Google", + * ContentType.MUTABLE_HTML) + * .setUpdateType(UpdateDraftBodyType.IN_PLACE_INSERT)) + * .build(); + * + * // A UpdateDraftActionResponse that inserts multiple values of different types. + * // The example action response inserts two lines next to each other in the email + * // draft, at the cursor position. Each line contains the content added by + * // {@link UpdateDraftActionResponseBuilder#addUpdateContent}. + * var updateDraftActionResponse = CardService.newUpdateDraftActionResponseBuilder() + * .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction() + * .addUpdateContent( + * "Google", + * ContentType.MUTABLE_HTML) + * .addUpdateContent("Above is a google link.", ContentType.PLAIN_TEXT) + * .setUpdateType(UpdateDraftBodyType.IN_PLACE_INSERT)) + * .build(); + */ + export interface UpdateDraftActionResponse { + printJson(): string; + } + + /** + * A builder for UpdateDraftActionResponse objects. + */ + export interface UpdateDraftActionResponseBuilder { + build(): UpdateDraftActionResponse; + setUpdateDraftBodyAction(updateDraftBodyAction: UpdateDraftBodyAction): UpdateDraftActionResponseBuilder; + } + + /** + * Represents an action that updates the email draft body. + */ + export interface UpdateDraftBodyAction { + addUpdateContent(content: string, contentType: ContentType): UpdateDraftBodyAction; + setUpdateType(updateType: UpdateDraftBodyType): UpdateDraftBodyAction; + } + + /** + * An enum value that specifies the type of an UpdateDraftBodyAction. + */ + export enum UpdateDraftBodyType { IN_PLACE_INSERT } + /** * Base class for all widgets that can be added to a Card. */ @@ -657,4 +750,4 @@ declare namespace GoogleAppsScript { } } -declare var CardService: GoogleAppsScript.Card.CardService; +declare var CardService: GoogleAppsScript.Card_Service.CardService; diff --git a/types/google-apps-script/google-apps-script.charts.d.ts b/types/google-apps-script/google-apps-script.charts.d.ts index 50013a36d0..5898092bb4 100644 --- a/types/google-apps-script/google-apps-script.charts.d.ts +++ b/types/google-apps-script/google-apps-script.charts.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -536,7 +536,7 @@ declare namespace GoogleAppsScript { * function doGet() { * // This example creates two table charts side by side. One uses a data view definition to * // restrict the number of displayed columns. - * var app = UiApp.createApplication(); + * * // Get sample data from a spreadsheet. * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; @@ -555,9 +555,17 @@ declare namespace GoogleAppsScript { * .setDataViewDefinition(dataViewDefinition) * .build(); * - * var panel = app.createHorizontalPanel().setSpacing(15); - * panel.add(originalChart).add(limitedChart); - * return app.add(panel); + * var htmlOutput = HtmlService.createHtmlOutput(); + * var originalChartData = Utilities.base64Encode(originalChart.getAs('image/png').getBytes()); + * var originalChartUrl = "data:image/png;base64," + encodeURI(originalChartData); + * var limitedChartData = Utilities.base64Encode(limitedChart.getAs('image/png').getBytes()); + * var limitedChartUrl = "data:image/png;base64," + encodeURI(limitedChartData); + * htmlOutput.append("
"); + * htmlOutput.append(""); + * htmlOutput.append(""); + * htmlOutput.append(""); + * htmlOutput.append("
"); + * return htmlOutput; * } */ export interface DataViewDefinitionBuilder { diff --git a/types/google-apps-script/google-apps-script.data-studio.d.ts b/types/google-apps-script/google-apps-script.data-studio.d.ts new file mode 100644 index 0000000000..572e4284e1 --- /dev/null +++ b/types/google-apps-script/google-apps-script.data-studio.d.ts @@ -0,0 +1,301 @@ +// Type definitions for Google Apps Script 2018-12-26 +// Project: https://developers.google.com/apps-script/ +// Definitions by: motemen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace GoogleAppsScript { + export module Data_Studio { + /** + * An enum that defines the aggregation types that can be set for a Field. + */ + export enum AggregationType { NO_AGGREGATION, AVG, COUNT, COUNT_DISTINCT, MAX, MIN, SUM } + + /** + * Contains checkbox information for the config. Its properties determine how the checkbox is + * displayed in Data Studio. + * + * var checkbox = config.newCheckbox() + * .setId("use_https") + * .setName("Use Https?") + * .setHelpText("Whether or not https should be used.") + * .setAllowOverride(true); + */ + export interface Checkbox { + setAllowOverride(allowOverride: boolean): Checkbox; + setHelpText(helpText: string): Checkbox; + setId(id: string): Checkbox; + setName(name: string): Checkbox; + } + + /** + * CommunityConnector enables scripts to access builders and utilities to help with development of + * Community Connectors for Data Studio. Use this class to get a reference to the Fields + * object and the FieldType and AggregationType enums so they can be used in the + * construction of Fields. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var fieldType = cc.FieldType; + * var aggregationType = cc.AggregationType; + * + * var fields = cc.getFields(); + * + * fields.newMetric() + * .setAggregation(aggregationType.AVG) + * .setFieldType(fieldType.CURRENCY_USD); + */ + export interface CommunityConnector { + AggregationType: typeof AggregationType; + FieldType: typeof FieldType; + getConfig(): Config; + getFields(): Fields; + } + + /** + * Contains the configuration entries for a connector. These configuration entries define what + * questions are asked when adding a new connector. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var info_entry = config.newInfo() + * .setId("info_id") + * .setHelpText("This connector can connect to multiple data endpoints."); + */ + export interface Config { + build(): Object; + newCheckbox(): Checkbox; + newInfo(): Info; + newOptionBuilder(): OptionBuilder; + newSelectMultiple(): SelectMultiple; + newSelectSingle(): SelectSingle; + newTextArea(): TextArea; + newTextInput(): TextInput; + printJson(): string; + setDateRangeRequired(dateRangeRequired: boolean): Config; + } + + /** + * DataStudioApp allows scripts to interact with developer-oriented features for Data Studio. + */ + export interface DataStudioApp { + createCommunityConnector(): CommunityConnector; + } + + /** + * Contains field-related data. Its properties determine how the field is used in Data Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var fields = cc.getFields(); + * var types = cc.FieldType; + * + * var field1 = fields.newDimension() + * .setId('field1_id') + * .setName('Field 1 ID') + * .setDescription('The first field.') + * .setType(types.YEAR_MONTH) + * .setGroup('DATETIME'); + */ + export interface Field { + getAggregation(): AggregationType; + getDescription(): string; + getFormula(): string; + getGroup(): string; + getId(): string; + getName(): string; + getType(): FieldType; + isDefault(): boolean; + isDimension(): boolean; + isHidden(): boolean; + isMetric(): boolean; + setAggregation(aggregation: AggregationType): Field; + setDescription(description: string): Field; + setFormula(formula: string): Field; + setGroup(group: string): Field; + setId(id: string): Field; + setIsHidden(isHidden: boolean): Field; + setName(name: string): Field; + setType(type: FieldType): Field; + } + + /** + * An enum that defines the types that can be set for a Field. + */ + export enum FieldType { YEAR, YEAR_QUARTER, YEAR_MONTH, YEAR_WEEK, YEAR_MONTH_DAY, YEAR_MONTH_DAY_HOUR, QUARTER, MONTH, WEEK, MONTH_DAY, DAY_OF_WEEK, DAY, HOUR, MINUTE, DURATION, COUNTRY, COUNTRY_CODE, CONTINENT, CONTINENT_CODE, SUB_CONTINENT, SUB_CONTINENT_CODE, REGION, REGION_CODE, CITY, CITY_CODE, METRO, METRO_CODE, LATITUDE_LONGITUDE, NUMBER, PERCENT, TEXT, BOOLEAN, URL, CURRENCY_AED, CURRENCY_ALL, CURRENCY_ARS, CURRENCY_AUD, CURRENCY_BDT, CURRENCY_BGN, CURRENCY_BOB, CURRENCY_BRL, CURRENCY_CAD, CURRENCY_CDF, CURRENCY_CHF, CURRENCY_CLP, CURRENCY_CNY, CURRENCY_COP, CURRENCY_CRC, CURRENCY_CZK, CURRENCY_DKK, CURRENCY_DOP, CURRENCY_EGP, CURRENCY_ETB, CURRENCY_EUR, CURRENCY_GBP, CURRENCY_HKD, CURRENCY_HRK, CURRENCY_HUF, CURRENCY_IDR, CURRENCY_ILS, CURRENCY_INR, CURRENCY_IRR, CURRENCY_ISK, CURRENCY_JMD, CURRENCY_JPY, CURRENCY_KRW, CURRENCY_LKR, CURRENCY_LTL, CURRENCY_MNT, CURRENCY_MVR, CURRENCY_MXN, CURRENCY_MYR, CURRENCY_NOK, CURRENCY_NZD, CURRENCY_PAB, CURRENCY_PEN, CURRENCY_PHP, CURRENCY_PKR, CURRENCY_PLN, CURRENCY_RON, CURRENCY_RSD, CURRENCY_RUB, CURRENCY_SAR, CURRENCY_SEK, CURRENCY_SGD, CURRENCY_THB, CURRENCY_TRY, CURRENCY_TWD, CURRENCY_TZS, CURRENCY_UAH, CURRENCY_USD, CURRENCY_UYU, CURRENCY_VEF, CURRENCY_VND, CURRENCY_YER, CURRENCY_ZAR } + + /** + * Contains a set of Fields for a community connector. This set of fields define which + * dimensions and metrics can be used in Data Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var fields = cc.getFields(); + * var types = cc.FieldType; + * + * var field1 = fields.newDimension() + * // Set other properties as needed. + * .setId('field1_id'); + */ + export interface Fields { + asArray(): Field[]; + build(): Object[]; + forIds(ids: string[]): Fields; + getDefaultDimension(): Field; + getDefaultMetric(): Field; + getFieldById(fieldId: string): Field; + newDimension(): Field; + newMetric(): Field; + setDefaultDimension(fieldId: string): void; + setDefaultMetric(fieldId: string): void; + } + + /** + * Contains info data for the config. Its properties determine how the info is displayed in Data + * Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var info1 = config.newInfo() + * .setName("info1") + * .setText("This text gives some context on the configuration."); + */ + export interface Info { + setId(id: string): Info; + setText(text: string): Info; + } + + /** + * A builder for creating options for SelectSingles and SelectMultiples. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var option1 = config.newOptionBuilder() + * .setLabel("option label") + * .setValue("option_value"); + * + * var option2 = config.newOptionBuilder() + * .setLabel("second option label") + * .setValue("option_value_2"); + * + * var info1 = config.newSelectSingle() + * .setId("api_endpoint") + * .setName("Data Type") + * .setHelpText("Select the data type you're interested in.") + * .addOption(option1) + * .addOption(option2); + */ + export interface OptionBuilder { + setLabel(label: string): OptionBuilder; + setValue(value: string): OptionBuilder; + } + + /** + * Contains select multiple information for the config. Its properties determine how the select + * multiple is displayed in Data Studio. + * + * Usage: + * + * var option1 = config.newOptionBuilder() + * .setLabel("option label") + * .setValue("option_value"); + * + * var option2 = config.newOptionBuilder() + * .setLabel("second option label") + * .setValue("option_value_2"); + * + * var info1 = config.newSelectMultiple() + * .setId("api_endpoint") + * .setName("Data Type") + * .setHelpText("Select the data type you're interested in.") + * .setAllowOverride(true) + * .addOption(option1) + * .addOption(option2); + */ + export interface SelectMultiple { + addOption(optionBuilder: OptionBuilder): SelectMultiple; + setAllowOverride(allowOverride: boolean): SelectMultiple; + setHelpText(helpText: string): SelectMultiple; + setId(id: string): SelectMultiple; + setName(name: string): SelectMultiple; + } + + /** + * Contains select single information for the config. Its properties determine how the select single + * is displayed in Data Studio. + * + * var option1 = config.newOptionBuilder() + * .setLabel("option label") + * .setValue("option_value"); + * + * var option2 = config.newOptionBuilder() + * .setLabel("second option label") + * .setValue("option_value_2"); + * + * var info1 = config.newSelectMultiple() + * .setId("api_endpoint") + * .setName("Data Type") + * .setHelpText("Select the data type you're interested in.") + * .setAllowOverride(true) + * .addOption(option1) + * .addOption(option2); + */ + export interface SelectSingle { + addOption(optionBuilder: OptionBuilder): SelectSingle; + setAllowOverride(allowOverride: boolean): SelectSingle; + setHelpText(helpText: string): SelectSingle; + setId(id: string): SelectSingle; + setName(name: string): SelectSingle; + } + + /** + * Contains text area information for the config. Its properties determine how the text input is + * displayed in Data Studio. + * + * Usage: + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var textArea1 = config.newTextArea() + * .setId("textArea1") + * .setName("Search") + * .setHelpText("for example, Coldplay") + * .setAllowOverride(true) + * .setPlaceholder("Search for an artist for all songs."); + */ + export interface TextArea { + setAllowOverride(allowOverride: boolean): TextArea; + setHelpText(helpText: string): TextArea; + setId(id: string): TextArea; + setName(name: string): TextArea; + setPlaceholder(placeholder: string): TextArea; + } + + /** + * Contains text input information for the config. Its properties determine how the text input is + * displayed in Data Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var info1 = config.newTextInput() + * .setId("info1") + * .setName("Search") + * .setHelpText("for example, Coldplay") + * .setAllowOverride(true) + * .setPlaceholder("Search for an artist for all songs."); + */ + export interface TextInput { + setAllowOverride(allowOverride: boolean): TextInput; + setHelpText(helpText: string): TextInput; + setId(id: string): TextInput; + setName(name: string): TextInput; + setPlaceholder(placeholder: string): TextInput; + } + + } +} + +declare var DataStudioApp: GoogleAppsScript.Data_Studio.DataStudioApp; diff --git a/types/google-apps-script/google-apps-script.forms.d.ts b/types/google-apps-script/google-apps-script.forms.d.ts index df08002505..2f4508a956 100644 --- a/types/google-apps-script/google-apps-script.forms.d.ts +++ b/types/google-apps-script/google-apps-script.forms.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -671,7 +671,7 @@ declare namespace GoogleAppsScript { * item.setHelpText('Description of new section.'); * } */ - export enum ItemType { CHECKBOX, CHECKBOX_GRID, DATE, DATETIME, DURATION, GRID, IMAGE, LIST, MULTIPLE_CHOICE, PAGE_BREAK, PARAGRAPH_TEXT, SCALE, SECTION_HEADER, TEXT, TIME } + export enum ItemType { CHECKBOX, CHECKBOX_GRID, DATE, DATETIME, DURATION, GRID, IMAGE, LIST, MULTIPLE_CHOICE, PAGE_BREAK, PARAGRAPH_TEXT, SCALE, SECTION_HEADER, TEXT, TIME, VIDEO } /** * A question item that allows the respondent to select one choice from a drop-down list. Items can diff --git a/types/google-apps-script/google-apps-script.gmail.d.ts b/types/google-apps-script/google-apps-script.gmail.d.ts index db8e6ecc52..b71a7226b6 100644 --- a/types/google-apps-script/google-apps-script.gmail.d.ts +++ b/types/google-apps-script/google-apps-script.gmail.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -103,6 +103,7 @@ declare namespace GoogleAppsScript { getContentType(): string; getDataAsString(): string; getDataAsString(charset: string): string; + getHash(): string; getName(): string; getSize(): Integer; isGoogleType(): boolean; diff --git a/types/google-apps-script/google-apps-script.groups.d.ts b/types/google-apps-script/google-apps-script.groups.d.ts index 757029f044..958838de57 100644 --- a/types/google-apps-script/google-apps-script.groups.d.ts +++ b/types/google-apps-script/google-apps-script.groups.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -16,13 +16,13 @@ declare namespace GoogleAppsScript { * * function listGroupMembers() { * var group = GroupsApp.getGroupByEmail("example@googlegroups.com"); - * var s = group.getEmail() + ': '; + * var str = group.getEmail() + ': '; * var users = group.getUsers(); * for (var i = 0; i < users.length; i++) { * var user = users[i]; - * s = s + user.getEmail() + ", "; + * str = str + user.getEmail() + ", "; * } - * Logger.log(s); + * Logger.log(str); * } */ export interface Group { diff --git a/types/google-apps-script/google-apps-script.script.d.ts b/types/google-apps-script/google-apps-script.script.d.ts index fbe95deb8c..5130b54db9 100644 --- a/types/google-apps-script/google-apps-script.script.d.ts +++ b/types/google-apps-script/google-apps-script.script.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -15,8 +15,8 @@ declare namespace GoogleAppsScript { * An enumeration that identifies which categories of authorized services Apps Script is able to * execute through a triggered function. These values are exposed in triggered functions as the authMode * property of the event parameter, e. For - * more information, see the guide to the authorization - * lifecycle for add-ons. + * more information, see the guide to the + * authorization lifecycle for add-ons. * * function onOpen(e) { * var menu = SpreadsheetApp.getUi().createAddonMenu(); diff --git a/types/google-apps-script/google-apps-script.slides.d.ts b/types/google-apps-script/google-apps-script.slides.d.ts index 3d1aac9227..f1c3a6fdae 100644 --- a/types/google-apps-script/google-apps-script.slides.d.ts +++ b/types/google-apps-script/google-apps-script.slides.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -125,6 +125,14 @@ declare namespace GoogleAppsScript { */ export enum ColorType { UNSUPPORTED, RGB, THEME } + /** + * The connection site on a PageElement that can connect to a connector. + */ + export interface ConnectionSite { + getIndex(): Integer; + getPageElement(): PageElement; + } + /** * The content alignments for a Shape or TableCell. The supported alignments * correspond to predefined text anchoring types from the ECMA-376 standard. @@ -172,8 +180,11 @@ declare namespace GoogleAppsScript { */ export interface Group { alignOnPage(alignmentPosition: AlignmentPosition): Group; + bringForward(): Group; + bringToFront(): Group; duplicate(): PageElement; getChildren(): PageElement[]; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -194,9 +205,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Group; select(): void; select(replace: boolean): void; + sendBackward(): Group; + sendToBack(): Group; + setDescription(description: string): Group; setHeight(height: Number): Group; setLeft(left: Number): Group; setRotation(angle: Number): Group; + setTitle(title: string): Group; setTop(top: Number): Group; setTransform(transform: AffineTransform): Group; setWidth(width: Number): Group; @@ -208,10 +223,13 @@ declare namespace GoogleAppsScript { */ export interface Image { alignOnPage(alignmentPosition: AlignmentPosition): Image; + bringForward(): Image; + bringToFront(): Image; duplicate(): PageElement; getAs(contentType: string): Base.Blob; getBlob(): Base.Blob; getBorder(): Border; + getConnectionSites(): ConnectionSite[]; getContentUrl(): string; getDescription(): string; getHeight(): Number; @@ -240,6 +258,9 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Image; select(): void; select(replace: boolean): void; + sendBackward(): Image; + sendToBack(): Image; + setDescription(description: string): Image; setHeight(height: Number): Image; setLeft(left: Number): Image; setLinkSlide(slideIndex: Integer): Link; @@ -247,6 +268,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): Image; + setTitle(title: string): Image; setTop(top: Number): Image; setTransform(transform: AffineTransform): Image; setWidth(width: Number): Image; @@ -267,6 +289,7 @@ declare namespace GoogleAppsScript { getLines(): Line[]; getMaster(): Master; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -285,6 +308,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -313,15 +337,20 @@ declare namespace GoogleAppsScript { */ export interface Line { alignOnPage(alignmentPosition: AlignmentPosition): Line; + bringForward(): Line; + bringToFront(): Line; duplicate(): PageElement; + getConnectionSites(): ConnectionSite[]; getDashStyle(): DashStyle; getDescription(): string; getEnd(): Point; getEndArrow(): ArrowStyle; + getEndConnection(): ConnectionSite; getHeight(): Number; getInherentHeight(): Number; getInherentWidth(): Number; getLeft(): Number; + getLineCategory(): LineCategory; getLineFill(): LineFill; getLineType(): LineType; getLink(): Link; @@ -332,24 +361,32 @@ declare namespace GoogleAppsScript { getRotation(): Number; getStart(): Point; getStartArrow(): ArrowStyle; + getStartConnection(): ConnectionSite; getTitle(): string; getTop(): Number; getTransform(): AffineTransform; getWeight(): Number; getWidth(): Number; + isConnector(): boolean; preconcatenateTransform(transform: AffineTransform): Line; remove(): void; removeLink(): void; + reroute(): Line; scaleHeight(ratio: Number): Line; scaleWidth(ratio: Number): Line; select(): void; select(replace: boolean): void; + sendBackward(): Line; + sendToBack(): Line; setDashStyle(style: DashStyle): Line; + setDescription(description: string): Line; setEnd(left: Number, top: Number): Line; setEnd(point: Point): Line; setEndArrow(style: ArrowStyle): Line; + setEndConnection(connectionSite: ConnectionSite): Line; setHeight(height: Number): Line; setLeft(left: Number): Line; + setLineCategory(lineCategory: LineCategory): Line; setLinkSlide(slideIndex: Integer): Link; setLinkSlide(slide: Slide): Link; setLinkSlide(slidePosition: SlidePosition): Link; @@ -358,6 +395,8 @@ declare namespace GoogleAppsScript { setStart(left: Number, top: Number): Line; setStart(point: Point): Line; setStartArrow(style: ArrowStyle): Line; + setStartConnection(connectionSite: ConnectionSite): Line; + setTitle(title: string): Line; setTop(top: Number): Line; setTransform(transform: AffineTransform): Line; setWeight(points: Number): Line; @@ -370,7 +409,7 @@ declare namespace GoogleAppsScript { * The exact LineType created is determined based on the category and how it's routed to * connect to other page elements. */ - export enum LineCategory { STRAIGHT, BENT, CURVED } + export enum LineCategory { UNSUPPORTED, STRAIGHT, BENT, CURVED } /** * Describes the fill of a line or outline @@ -504,6 +543,7 @@ declare namespace GoogleAppsScript { getLayouts(): Layout[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -522,6 +562,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -556,6 +597,7 @@ declare namespace GoogleAppsScript { getImages(): Image[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPlaceholder(placeholderType: PlaceholderType): PageElement; getPlaceholder(placeholderType: PlaceholderType, placeholderIndex: Integer): PageElement; @@ -579,6 +621,7 @@ declare namespace GoogleAppsScript { getImages(): Image[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPlaceholder(placeholderType: PlaceholderType): PageElement; getPlaceholder(placeholderType: PlaceholderType, placeholderIndex: Integer): PageElement; @@ -606,6 +649,7 @@ declare namespace GoogleAppsScript { getImages(): Image[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -624,6 +668,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -686,7 +731,10 @@ declare namespace GoogleAppsScript { asTable(): Table; asVideo(): Video; asWordArt(): WordArt; + bringForward(): PageElement; + bringToFront(): PageElement; duplicate(): PageElement; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -707,9 +755,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): PageElement; select(): void; select(replace: boolean): void; + sendBackward(): PageElement; + sendToBack(): PageElement; + setDescription(description: string): PageElement; setHeight(height: Number): PageElement; setLeft(left: Number): PageElement; setRotation(angle: Number): PageElement; + setTitle(title: string): PageElement; setTop(top: Number): PageElement; setTransform(transform: AffineTransform): PageElement; setWidth(width: Number): PageElement; @@ -836,11 +888,11 @@ declare namespace GoogleAppsScript { getNotesMaster(): NotesMaster; getNotesPageHeight(): Number; getNotesPageWidth(): Number; - getPageElementById(id: string): PageElement; + getPageElementById(id: string): PageElement; getPageHeight(): Number; getPageWidth(): Number; getSelection(): Selection; - getSlideById(id: string): Slide; + getSlideById(id: string): Slide; getSlides(): Slide[]; getUrl(): string; getViewers(): Base.User[]; @@ -903,8 +955,11 @@ declare namespace GoogleAppsScript { */ export interface Shape { alignOnPage(alignmentPosition: AlignmentPosition): Shape; + bringForward(): Shape; + bringToFront(): Shape; duplicate(): PageElement; getBorder(): Border; + getConnectionSites(): ConnectionSite[]; getContentAlignment(): ContentAlignment; getDescription(): string; getFill(): Fill; @@ -940,7 +995,10 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Shape; select(): void; select(replace: boolean): void; + sendBackward(): Shape; + sendToBack(): Shape; setContentAlignment(contentAlignment: ContentAlignment): Shape; + setDescription(description: string): Shape; setHeight(height: Number): Shape; setLeft(left: Number): Shape; setLinkSlide(slideIndex: Integer): Link; @@ -948,6 +1006,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): Shape; + setTitle(title: string): Shape; setTop(top: Number): Shape; setTransform(transform: AffineTransform): Shape; setWidth(width: Number): Shape; @@ -968,8 +1027,11 @@ declare namespace GoogleAppsScript { export interface SheetsChart { alignOnPage(alignmentPosition: AlignmentPosition): SheetsChart; asImage(): Image; + bringForward(): SheetsChart; + bringToFront(): SheetsChart; duplicate(): PageElement; getChartId(): Integer; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getEmbedType(): SheetsChartEmbedType; getHeight(): Number; @@ -995,6 +1057,9 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): SheetsChart; select(): void; select(replace: boolean): void; + sendBackward(): SheetsChart; + sendToBack(): SheetsChart; + setDescription(description: string): SheetsChart; setHeight(height: Number): SheetsChart; setLeft(left: Number): SheetsChart; setLinkSlide(slideIndex: Integer): Link; @@ -1002,6 +1067,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): SheetsChart; + setTitle(title: string): SheetsChart; setTop(top: Number): SheetsChart; setTransform(transform: AffineTransform): SheetsChart; setWidth(width: Number): SheetsChart; @@ -1028,6 +1094,7 @@ declare namespace GoogleAppsScript { getLines(): Line[]; getNotesPage(): NotesPage; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -1046,6 +1113,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -1144,9 +1212,12 @@ declare namespace GoogleAppsScript { alignOnPage(alignmentPosition: AlignmentPosition): Table; appendColumn(): TableColumn; appendRow(): TableRow; + bringForward(): Table; + bringToFront(): Table; duplicate(): PageElement; getCell(rowIndex: Integer, columnIndex: Integer): TableCell; getColumn(columnIndex: Integer): TableColumn; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -1172,9 +1243,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Table; select(): void; select(replace: boolean): void; + sendBackward(): Table; + sendToBack(): Table; + setDescription(description: string): Table; setHeight(height: Number): Table; setLeft(left: Number): Table; setRotation(angle: Number): Table; + setTitle(title: string): Table; setTop(top: Number): Table; setTransform(transform: AffineTransform): Table; setWidth(width: Number): Table; @@ -1343,8 +1418,11 @@ declare namespace GoogleAppsScript { */ export interface Video { alignOnPage(alignmentPosition: AlignmentPosition): Video; + bringForward(): Video; + bringToFront(): Video; duplicate(): PageElement; getBorder(): Border; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -1369,9 +1447,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Video; select(): void; select(replace: boolean): void; + sendBackward(): Video; + sendToBack(): Video; + setDescription(description: string): Video; setHeight(height: Number): Video; setLeft(left: Number): Video; setRotation(angle: Number): Video; + setTitle(title: string): Video; setTop(top: Number): Video; setTransform(transform: AffineTransform): Video; setWidth(width: Number): Video; @@ -1387,7 +1469,10 @@ declare namespace GoogleAppsScript { */ export interface WordArt { alignOnPage(alignmentPosition: AlignmentPosition): WordArt; + bringForward(): WordArt; + bringToFront(): WordArt; duplicate(): PageElement; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -1411,6 +1496,9 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): WordArt; select(): void; select(replace: boolean): void; + sendBackward(): WordArt; + sendToBack(): WordArt; + setDescription(description: string): WordArt; setHeight(height: Number): WordArt; setLeft(left: Number): WordArt; setLinkSlide(slideIndex: Integer): Link; @@ -1418,6 +1506,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): WordArt; + setTitle(title: string): WordArt; setTop(top: Number): WordArt; setTransform(transform: AffineTransform): WordArt; setWidth(width: Number): WordArt; diff --git a/types/google-apps-script/google-apps-script.spreadsheet.d.ts b/types/google-apps-script/google-apps-script.spreadsheet.d.ts index 4ac5c84d6b..76a5bd5f22 100644 --- a/types/google-apps-script/google-apps-script.spreadsheet.d.ts +++ b/types/google-apps-script/google-apps-script.spreadsheet.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -99,7 +99,7 @@ declare namespace GoogleAppsScript { * var range = sheet.getRange("A1:B3"); * var rule = SpreadsheetApp.newConditionalFormatRule() * .whenNumberBetween(1, 10) - * .setBackgroundColor("#FF0000") + * .setBackground("#FF0000") * .setRanges([range]) * .build(); * var rules = sheet.getConditionalFormatRules(); @@ -268,6 +268,61 @@ declare namespace GoogleAppsScript { */ export enum DataValidationCriteria { DATE_AFTER, DATE_BEFORE, DATE_BETWEEN, DATE_EQUAL_TO, DATE_IS_VALID_DATE, DATE_NOT_BETWEEN, DATE_ON_OR_AFTER, DATE_ON_OR_BEFORE, NUMBER_BETWEEN, NUMBER_EQUAL_TO, NUMBER_GREATER_THAN, NUMBER_GREATER_THAN_OR_EQUAL_TO, NUMBER_LESS_THAN, NUMBER_LESS_THAN_OR_EQUAL_TO, NUMBER_NOT_BETWEEN, NUMBER_NOT_EQUAL_TO, TEXT_CONTAINS, TEXT_DOES_NOT_CONTAIN, TEXT_EQUAL_TO, TEXT_IS_VALID_EMAIL, TEXT_IS_VALID_URL, VALUE_IN_LIST, VALUE_IN_RANGE, CUSTOM_FORMULA, CHECKBOX } + /** + * Access and modify developer metadata. To create new developer metadata use Range.addDeveloperMetadata(key), Sheet.addDeveloperMetadata(key), or Spreadsheet.addDeveloperMetadata(key). + */ + export interface DeveloperMetadata { + getId(): Integer; + getKey(): string; + getLocation(): DeveloperMetadataLocation; + getValue(): string; + getVisibility(): DeveloperMetadataVisibility; + moveToColumn(column: Range): DeveloperMetadata; + moveToRow(row: Range): DeveloperMetadata; + moveToSheet(sheet: Sheet): DeveloperMetadata; + moveToSpreadsheet(): DeveloperMetadata; + remove(): void; + setKey(key: string): DeveloperMetadata; + setValue(value: string): DeveloperMetadata; + setVisibility(visibility: DeveloperMetadataVisibility): DeveloperMetadata; + } + + /** + * Search for developer metadata in a spreadsheet. To create new developer metadata finder use + * Range.createDeveloperMetadataFinder(), Sheet.createDeveloperMetadataFinder(), + * or Spreadsheet.createDeveloperMetadataFinder(). + */ + export interface DeveloperMetadataFinder { + find(): DeveloperMetadata[]; + onIntersectingLocations(): DeveloperMetadataFinder; + withId(id: Integer): DeveloperMetadataFinder; + withKey(key: string): DeveloperMetadataFinder; + withLocationType(locationType: DeveloperMetadataLocationType): DeveloperMetadataFinder; + withValue(value: string): DeveloperMetadataFinder; + withVisibility(visibility: DeveloperMetadataVisibility): DeveloperMetadataFinder; + } + + /** + * Access developer metadata location information. + */ + export interface DeveloperMetadataLocation { + getColumn(): Range; + getLocationType(): DeveloperMetadataLocationType; + getRow(): Range; + getSheet(): Sheet; + getSpreadsheet(): Spreadsheet; + } + + /** + * An enumeration of the types of developer metadata location types. + */ + export enum DeveloperMetadataLocationType { SPREADSHEET, SHEET, ROW, COLUMN } + + /** + * An enumeration of the types of developer metadata visibility. + */ + export enum DeveloperMetadataVisibility { DOCUMENT, PROJECT } + /** * An enumeration of possible directions along which data can be stored in a spreadsheet. */ @@ -896,6 +951,36 @@ declare namespace GoogleAppsScript { setRange(range: Range): NamedRange; } + /** + * Represents an image over the grid in a spreadsheet. + */ + export interface OverGridImage { + assignScript(functionName: string): OverGridImage; + getAltTextDescription(): string; + getAltTextTitle(): string; + getAnchorCell(): Range; + getAnchorCellXOffset(): Integer; + getAnchorCellYOffset(): Integer; + getHeight(): Integer; + getInherentHeight(): Integer; + getInherentWidth(): Integer; + getScript(): string; + getSheet(): Sheet; + getUrl(): string; + getWidth(): Integer; + remove(): void; + replace(blob: Base.BlobSource): OverGridImage; + replace(url: string): OverGridImage; + resetSize(): OverGridImage; + setAltTextDescription(description: string): OverGridImage; + setAltTextTitle(title: string): OverGridImage; + setAnchorCell(cell: Range): OverGridImage; + setAnchorCellXOffset(offset: Integer): OverGridImage; + setAnchorCellYOffset(offset: Integer): OverGridImage; + setHeight(height: Integer): OverGridImage; + setWidth(width: Integer): OverGridImage; + } + /** * * Deprecated. For spreadsheets created in the newer version of Google Sheets, use the more powerful @@ -1091,6 +1176,10 @@ declare namespace GoogleAppsScript { export interface Range { activate(): Range; activateAsCurrentCell(): Range; + addDeveloperMetadata(key: string): Range; + addDeveloperMetadata(key: string, visibility: DeveloperMetadataVisibility): Range; + addDeveloperMetadata(key: string, value: string): Range; + addDeveloperMetadata(key: string, value: string, visibility: DeveloperMetadataVisibility): Range; applyColumnBanding(): Banding; applyColumnBanding(bandingTheme: BandingTheme): Banding; applyColumnBanding(bandingTheme: BandingTheme, showHeader: boolean, showFooter: boolean): Banding; @@ -1115,6 +1204,7 @@ declare namespace GoogleAppsScript { copyTo(destination: Range, options: Object): void; copyValuesToRange(gridId: Integer, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; copyValuesToRange(sheet: Sheet, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; + createDeveloperMetadataFinder(): DeveloperMetadataFinder; createFilter(): Filter; createPivotTable(sourceData: Range): PivotTable; deleteCells(shiftDimension: Dimension): void; @@ -1130,6 +1220,7 @@ declare namespace GoogleAppsScript { getDataTable(firstRowIsHeader: boolean): Charts.DataTable; getDataValidation(): DataValidation; getDataValidations(): DataValidation[][]; + getDeveloperMetadata(): DeveloperMetadata[]; getDisplayValue(): string; getDisplayValues(): string[][]; getFilter(): Filter; @@ -1178,7 +1269,7 @@ declare namespace GoogleAppsScript { getWrap(): boolean; getWrapStrategies(): WrapStrategy[][]; getWrapStrategy(): WrapStrategy; - getWraps(): Boolean[][]; + getWraps(): boolean[][]; insertCells(shiftDimension: Dimension): Range; isBlank(): boolean; isEndColumnBounded(): boolean; @@ -1328,6 +1419,10 @@ declare namespace GoogleAppsScript { */ export interface Sheet { activate(): Sheet; + addDeveloperMetadata(key: string): Sheet; + addDeveloperMetadata(key: string, visibility: DeveloperMetadataVisibility): Sheet; + addDeveloperMetadata(key: string, value: string): Sheet; + addDeveloperMetadata(key: string, value: string, visibility: DeveloperMetadataVisibility): Sheet; appendRow(rowContents: Object[]): Sheet; autoResizeColumn(columnPosition: Integer): Sheet; autoResizeColumns(startColumn: Integer, numColumns: Integer): Sheet; @@ -1341,6 +1436,7 @@ declare namespace GoogleAppsScript { collapseAllColumnGroups(): Sheet; collapseAllRowGroups(): Sheet; copyTo(spreadsheet: Spreadsheet): Sheet; + createDeveloperMetadataFinder(): DeveloperMetadataFinder; deleteColumn(columnPosition: Integer): Sheet; deleteColumns(columnPosition: Integer, howMany: Integer): void; deleteRow(rowPosition: Integer): Sheet; @@ -1361,10 +1457,12 @@ declare namespace GoogleAppsScript { getConditionalFormatRules(): ConditionalFormatRule[]; getCurrentCell(): Range; getDataRange(): Range; + getDeveloperMetadata(): DeveloperMetadata[]; getFilter(): Filter; getFormUrl(): string; getFrozenColumns(): Integer; getFrozenRows(): Integer; + getImages(): OverGridImage[]; getIndex(): Integer; getLastColumn(): Integer; getLastRow(): Integer; @@ -1404,17 +1502,20 @@ declare namespace GoogleAppsScript { insertColumns(columnIndex: Integer, numColumns: Integer): void; insertColumnsAfter(afterPosition: Integer, howMany: Integer): Sheet; insertColumnsBefore(beforePosition: Integer, howMany: Integer): Sheet; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): void; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; - insertImage(url: string, column: Integer, row: Integer): void; - insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): OverGridImage; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; insertRowAfter(afterPosition: Integer): Sheet; insertRowBefore(beforePosition: Integer): Sheet; insertRows(rowIndex: Integer): void; insertRows(rowIndex: Integer, numRows: Integer): void; insertRowsAfter(afterPosition: Integer, howMany: Integer): Sheet; insertRowsBefore(beforePosition: Integer, howMany: Integer): Sheet; + isColumnHiddenByUser(columnPosition: Integer): boolean; isRightToLeft(): boolean; + isRowHiddenByFilter(rowPosition: Integer): boolean; + isRowHiddenByUser(rowPosition: Integer): boolean; isSheetHidden(): boolean; moveColumns(columnSpec: Range, destinationIndex: Integer): void; moveRows(rowSpec: Range, destinationIndex: Integer): void; @@ -1458,6 +1559,10 @@ declare namespace GoogleAppsScript { * collaborators. */ export interface Spreadsheet { + addDeveloperMetadata(key: string): Spreadsheet; + addDeveloperMetadata(key: string, visibility: DeveloperMetadataVisibility): Spreadsheet; + addDeveloperMetadata(key: string, value: string): Spreadsheet; + addDeveloperMetadata(key: string, value: string, visibility: DeveloperMetadataVisibility): Spreadsheet; addEditor(emailAddress: string): Spreadsheet; addEditor(user: Base.User): Spreadsheet; addEditors(emailAddresses: string[]): Spreadsheet; @@ -1468,6 +1573,7 @@ declare namespace GoogleAppsScript { appendRow(rowContents: Object[]): Sheet; autoResizeColumn(columnPosition: Integer): Sheet; copy(name: string): Spreadsheet; + createDeveloperMetadataFinder(): DeveloperMetadataFinder; deleteActiveSheet(): Sheet; deleteColumn(columnPosition: Integer): Sheet; deleteColumns(columnPosition: Integer, howMany: Integer): void; @@ -1485,11 +1591,13 @@ declare namespace GoogleAppsScript { getColumnWidth(columnPosition: Integer): Integer; getCurrentCell(): Range; getDataRange(): Range; + getDeveloperMetadata(): DeveloperMetadata[]; getEditors(): Base.User[]; getFormUrl(): string; getFrozenColumns(): Integer; getFrozenRows(): Integer; getId(): string; + getImages(): OverGridImage[]; getLastColumn(): Integer; getLastRow(): Integer; getName(): string; @@ -1517,10 +1625,10 @@ declare namespace GoogleAppsScript { insertColumnBefore(beforePosition: Integer): Sheet; insertColumnsAfter(afterPosition: Integer, howMany: Integer): Sheet; insertColumnsBefore(beforePosition: Integer, howMany: Integer): Sheet; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): void; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; - insertImage(url: string, column: Integer, row: Integer): void; - insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): OverGridImage; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; insertRowAfter(afterPosition: Integer): Sheet; insertRowBefore(beforePosition: Integer): Sheet; insertRowsAfter(afterPosition: Integer, howMany: Integer): Sheet; @@ -1533,6 +1641,9 @@ declare namespace GoogleAppsScript { insertSheet(sheetName: string, sheetIndex: Integer): Sheet; insertSheet(sheetName: string, sheetIndex: Integer, options: Object): Sheet; insertSheet(sheetName: string, options: Object): Sheet; + isColumnHiddenByUser(columnPosition: Integer): boolean; + isRowHiddenByFilter(rowPosition: Integer): boolean; + isRowHiddenByUser(rowPosition: Integer): boolean; moveActiveSheet(pos: Integer): void; removeEditor(emailAddress: string): Spreadsheet; removeEditor(user: Base.User): Spreadsheet; @@ -1582,6 +1693,8 @@ declare namespace GoogleAppsScript { BorderStyle: typeof BorderStyle; CopyPasteType: typeof CopyPasteType; DataValidationCriteria: typeof DataValidationCriteria; + DeveloperMetadataLocationType: typeof DeveloperMetadataLocationType; + DeveloperMetadataVisibility: typeof DeveloperMetadataVisibility; Dimension: typeof Dimension; Direction: typeof Direction; GroupControlTogglePosition: typeof GroupControlTogglePosition; diff --git a/types/google-apps-script/google-apps-script.utilities.d.ts b/types/google-apps-script/google-apps-script.utilities.d.ts index 272c341b6c..922e31544a 100644 --- a/types/google-apps-script/google-apps-script.utilities.d.ts +++ b/types/google-apps-script/google-apps-script.utilities.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,7 +14,7 @@ declare namespace GoogleAppsScript { export enum Charset { US_ASCII, UTF_8 } /** - * Selector of Digest algorithm + * Selector of Digest algorithm. */ export enum DigestAlgorithm { MD2, MD5, SHA_1, SHA_256, SHA_384, SHA_512 } @@ -23,6 +23,11 @@ declare namespace GoogleAppsScript { */ export enum MacAlgorithm { HMAC_MD5, HMAC_SHA_1, HMAC_SHA_256, HMAC_SHA_384, HMAC_SHA_512 } + /** + * Selector of RSA algorithm + */ + export enum RsaAlgorithm { RSA_SHA_1, RSA_SHA_256 } + /** * This service provides utilities for string encoding/decoding, date formatting, JSON manipulation, * and other miscellaneous tasks. @@ -31,6 +36,7 @@ declare namespace GoogleAppsScript { Charset: typeof Charset; DigestAlgorithm: typeof DigestAlgorithm; MacAlgorithm: typeof MacAlgorithm; + RsaAlgorithm: typeof RsaAlgorithm; base64Decode(encoded: string): Byte[]; base64Decode(encoded: string, charset: Charset): Byte[]; base64DecodeWebSafe(encoded: string): Byte[]; @@ -50,8 +56,12 @@ declare namespace GoogleAppsScript { computeHmacSignature(algorithm: MacAlgorithm, value: Byte[], key: Byte[]): Byte[]; computeHmacSignature(algorithm: MacAlgorithm, value: string, key: string): Byte[]; computeHmacSignature(algorithm: MacAlgorithm, value: string, key: string, charset: Charset): Byte[]; + computeRsaSha1Signature(value: string, key: string): Byte[]; + computeRsaSha1Signature(value: string, key: string, charset: Charset): Byte[]; computeRsaSha256Signature(value: string, key: string): Byte[]; computeRsaSha256Signature(value: string, key: string, charset: Charset): Byte[]; + computeRsaSignature(algorithm: RsaAlgorithm, value: string, key: string): Byte[]; + computeRsaSignature(algorithm: RsaAlgorithm, value: string, key: string, charset: Charset): Byte[]; formatDate(date: Date, timeZone: string, format: string): string; formatString(template: string, ...args: Object[]): string; getUuid(): string; @@ -80,4 +90,5 @@ declare namespace GoogleAppsScript { declare var Charset: GoogleAppsScript.Utilities.Charset; declare var DigestAlgorithm: GoogleAppsScript.Utilities.DigestAlgorithm; declare var MacAlgorithm: GoogleAppsScript.Utilities.MacAlgorithm; +declare var RsaAlgorithm: GoogleAppsScript.Utilities.RsaAlgorithm; declare var Utilities: GoogleAppsScript.Utilities.Utilities; diff --git a/types/google-apps-script/index.d.ts b/types/google-apps-script/index.d.ts index ae463c738b..8e565f334f 100644 --- a/types/google-apps-script/index.d.ts +++ b/types/google-apps-script/index.d.ts @@ -11,28 +11,29 @@ // Google Services (Google APIs) /// -/// -/// /// -/// +/// /// /// /// /// /// -/// +/// /// /// /// /// // Script Services (Other *App / *Service) +/// +/// +/// /// /// -/// /// -/// +/// /// +/// /// /// /// From 9c5302ea256137f34f1a3a55180c76731184492e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=90=E6=9C=A8=E5=B7=A5=E4=BA=BA?= <314313534@qq.com> Date: Mon, 31 Dec 2018 23:53:54 +0800 Subject: [PATCH 11/69] Many types of clone() and copy() methods are incorrectly defined. (#31696) * Many types of clone() and copy() methods are incorrectly defined. * Add the missing member to the SpriteMaterial type. * Changes the return type of the clone() method back to the original. --- types/three/three-core.d.ts | 65 +++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/types/three/three-core.d.ts b/types/three/three-core.d.ts index 5bc604232c..25a0f2c07a 100755 --- a/types/three/three-core.d.ts +++ b/types/three/three-core.d.ts @@ -707,7 +707,7 @@ export class BufferAttribute { setArray(array?: ArrayBufferView): void; setDynamic(dynamic: boolean): BufferAttribute; clone(): this; - copy(source: this): this; + copy(source: BufferAttribute): this; copyAt(index1: number, attribute: BufferAttribute, index2: number): BufferAttribute; copyArray(array: ArrayLike): BufferAttribute; copyColorsArray(colors: {r: number, g: number, b: number}[]): BufferAttribute; @@ -927,7 +927,7 @@ export class BufferGeometry extends EventDispatcher { toJSON(): any; clone(): this; - copy(source: this): this; + copy(source: BufferGeometry): this; /** * Disposes the object from memory. @@ -1196,7 +1196,7 @@ export class Face3 { materialIndex: number; clone(): this; - copy(source: this): this; + copy(source: Face3): this; } /** @@ -1427,7 +1427,7 @@ export class Geometry extends EventDispatcher { */ clone(): this; - copy(source: this): this; + copy(source: Geometry): this; /** * Removes The object from memory. @@ -1510,10 +1510,9 @@ export class InterleavedBuffer { setArray(array?: ArrayBufferView): void; setDynamic(dynamic: boolean): InterleavedBuffer; clone(): this; - copy(source: this): this; + copy(source: InterleavedBuffer): this; copyAt(index1: number, attribute: InterleavedBufferAttribute, index2: number): InterleavedBuffer; set(value: ArrayLike, index: number): InterleavedBuffer; - clone(): this; } /** @@ -1847,7 +1846,7 @@ export class Object3D extends EventDispatcher { * @param object * @param recursive */ - copy(source: this, recursive?: boolean): this; + copy(source: Object3D, recursive?: boolean): this; } export interface Intersection { @@ -2016,7 +2015,7 @@ export class LightShadow { map: RenderTarget; matrix: Matrix4; - copy(source: this): this; + copy(source: LightShadow): this; clone(recursive?: boolean): this; toJSON(): any; } @@ -2698,7 +2697,7 @@ export class Material extends EventDispatcher { * Copy the parameters from the passed material into this material. * @param material */ - copy(material: this): this; + copy(material: Material): this; /** * This disposes the material. Textures of a material don't get disposed. These needs to be disposed by {@link Texture}. @@ -3166,8 +3165,10 @@ export class SpriteMaterial extends Material { color: Color; map: Texture | null; rotation: number; + isSpriteMaterial: true; setValues(parameters: SpriteMaterialParameters): void; + copy(source: SpriteMaterial): this; } export class ShadowMaterial extends ShaderMaterial { @@ -3186,7 +3187,7 @@ export class Box2 { setFromPoints(points: Vector2[]): Box2; setFromCenterAndSize(center: Vector2, size: Vector2): Box2; clone(): this; - copy(box: this): this; + copy(box: Box2): this; makeEmpty(): Box2; isEmpty(): boolean; getCenter(target: Vector2): Vector2; @@ -3226,7 +3227,7 @@ export class Box3 { setFromCenterAndSize(center: Vector3, size: Vector3): this; setFromObject(object: Object3D): this; clone(): this; - copy(box: this): this; + copy(box: Box3): this; makeEmpty(): this; isEmpty(): boolean; getCenter(target: Vector3): Vector3; @@ -3335,7 +3336,7 @@ export class Color { * Copies given color. * @param color Color to copy. */ - copy(color: this): this; + copy(color: Color): this; /** * Copies given color making conversion from gamma to linear space. @@ -3553,7 +3554,7 @@ export class Euler { set(x: number, y: number, z: number, order?: string): Euler; clone(): this; - copy(euler: this): this; + copy(euler: Euler): this; setFromRotationMatrix(m: Matrix4, order?: string, update?: boolean): Euler; setFromQuaternion(q: Quaternion, order?: string, update?: boolean): Euler; setFromVector3( v: Vector3, order?: string ): Euler; @@ -3581,7 +3582,7 @@ export class Frustum { set(p0?: number, p1?: number, p2?: number, p3?: number, p4?: number, p5?: number): Frustum; clone(): this; - copy(frustum: this): this; + copy(frustum: Frustum): this; setFromMatrix(m: Matrix4): Frustum; intersectsObject(object: Object3D): boolean; intersectsObject(sprite: Sprite): boolean; @@ -3598,7 +3599,7 @@ export class Line3 { set(start?: Vector3, end?: Vector3): Line3; clone(): this; - copy(line: this): this; + copy(line: Line3): this; getCenter(target: Vector3): Vector3; delta(target: Vector3): Vector3; distanceSq(): number; @@ -3760,7 +3761,7 @@ export class Matrix3 implements Matrix { set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; identity(): Matrix3; clone(): this; - copy(m: this): this; + copy(m: Matrix3): this; setFromMatrix4(m: Matrix4): Matrix3; /** @@ -3852,7 +3853,7 @@ export class Matrix4 implements Matrix { */ identity(): Matrix4; clone(): this; - copy(m: this): this; + copy(m: Matrix4): this; copyPosition(m: Matrix4): Matrix4; extractBasis( xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; makeBasis( xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; @@ -4049,7 +4050,7 @@ export class Plane { setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; clone(): this; - copy(plane: this): this; + copy(plane: Plane): this; normalize(): Plane; negate(): Plane; distanceToPoint(point: Vector3): number; @@ -4079,7 +4080,7 @@ export class Spherical { set(radius: number, phi: number, theta: number): Spherical; clone(): this; - copy(other: this): this; + copy(other: Spherical): this; makeSafe(): void; setFromVector3(vec3: Vector3): Spherical; } @@ -4092,7 +4093,7 @@ export class Cylindrical { y: number; clone(): this; - copy(other: this): this; + copy(other: Cylindrical): this; set(radius: number, theta: number, y: number): this; setFromVector3(vec3: Vector3): this; } @@ -4133,7 +4134,7 @@ export class Quaternion { /** * Copies values of q to this quaternion. */ - copy(q: this): this; + copy(q: Quaternion): this; /** * Sets this quaternion from rotation specified by Euler angles. @@ -4216,7 +4217,7 @@ export class Ray { set(origin: Vector3, direction: Vector3): Ray; clone(): this; - copy(ray: this): this; + copy(ray: Ray): this; at(t: number, target: Vector3): Vector3; lookAt(v: Vector3): Vector3; recast(t: number): Ray; @@ -4260,7 +4261,7 @@ export class Sphere { set(center: Vector3, radius: number): Sphere; setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere; clone(): this; - copy(sphere: this): this; + copy(sphere: Sphere): this; empty(): boolean; containsPoint(point: Vector3): boolean; distanceToPoint(point: Vector3): number; @@ -4290,7 +4291,7 @@ export class Triangle { set(a: Vector3, b: Vector3, c: Vector3): Triangle; setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle; clone(): this; - copy(triangle: this): this; + copy(triangle: Triangle): this; getArea(): number; getMidpoint(target: Vector3): Vector3; getNormal(target: Vector3): Vector3; @@ -4426,7 +4427,7 @@ export interface Vector { /** * clone():T; */ - clone(): Vector; + clone(): this; } /** @@ -4476,12 +4477,12 @@ export class Vector2 implements Vector { /** * Returns a new Vector2 instance with the same `x` and `y` values. */ - clone(): Vector2; + clone(): this; /** * Copies value of v to this vector. */ - copy(v: this): this; + copy(v: Vector2): this; /** * Adds v to this vector. @@ -4795,7 +4796,7 @@ export class Vector3 implements Vector { /** * Clones this vector. */ - clone(): Vector3; + clone(): this; /** * Copies value of v to this vector. @@ -5042,12 +5043,12 @@ export class Vector4 implements Vector { /** * Clones this vector. */ - clone(): Vector4; + clone(): this; /** * Copies value of v to this vector. */ - copy(v: this): this; + copy(v: Vector4): this; /** * Adds v to this vector. @@ -5841,7 +5842,7 @@ export class WebGLRenderTarget extends EventDispatcher { setSize(width: number, height: number): void; clone(): this; - copy(source: this): this; + copy(source: WebGLRenderTarget): this; dispose(): void; } @@ -6554,7 +6555,7 @@ export class Texture extends EventDispatcher { static DEFAULT_MAPPING: any; clone(): this; - copy(source: this): this; + copy(source: Texture): this; toJSON(meta: any): any; dispose(): void; transformUv(uv: Vector): void; From 9bafcbf1316ad21ed302ca6eb5a53813fbdd3a52 Mon Sep 17 00:00:00 2001 From: geo1004 Date: Mon, 31 Dec 2018 16:54:20 +0100 Subject: [PATCH 12/69] Add definitions for IbanElement and IdealBankElement (#31703) --- types/react-stripe-elements/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/react-stripe-elements/index.d.ts b/types/react-stripe-elements/index.d.ts index 0697e4b869..27f93683d1 100644 --- a/types/react-stripe-elements/index.d.ts +++ b/types/react-stripe-elements/index.d.ts @@ -91,3 +91,9 @@ export class PostalCodeElement extends React.Component { } + +export class IbanElement extends React.Component { +} + +export class IdealBankElement extends React.Component { +} From b6b4556d6c9f931557f63e9cdffea3df20cb7ee1 Mon Sep 17 00:00:00 2001 From: Florian Keller Date: Mon, 31 Dec 2018 16:54:49 +0100 Subject: [PATCH 13/69] fix(node-rsa): Update types for version 1.0.2 (#31700) --- types/node-rsa/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/node-rsa/index.d.ts b/types/node-rsa/index.d.ts index e0730eef74..882511cc3b 100644 --- a/types/node-rsa/index.d.ts +++ b/types/node-rsa/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for node-rsa 0.4 +// Type definitions for node-rsa 1.0 // Project: https://github.com/rzcoder/node-rsa // Definitions by: Ali Taheri // Christian Moniz +// Florian Keller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -27,12 +28,12 @@ declare class NodeRSA { * @param bits Key size in bits. 2048 by default. * @param exponent public exponent. 65537 by default. */ - generateKeyPair(bits?: number, exponent?: number): void; + generateKeyPair(bits?: number, exponent?: number): NodeRSA; /** * Import key from PEM string, PEM/DER Buffer or components. */ - importKey(key: NodeRSA.Key, format?: NodeRSA.Format): void; + importKey(key: NodeRSA.Key, format?: NodeRSA.Format): NodeRSA; /** * Export key to PEM string, PEM/DER Buffer or components. @@ -120,8 +121,7 @@ declare namespace NodeRSA { type HashingAlgorithm = | 'ripemd160' | 'md4' | 'md5' - | 'sha' | 'sha1' - | 'sha224' | 'sha256' | 'sha384' | 'sha512'; + | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512'; type SigningScheme = 'pkcs1' | 'pss'; From ee64145cc5b81fa0ec538946c26a0d6663c40415 Mon Sep 17 00:00:00 2001 From: Victor Irzak <6209775+virzak@users.noreply.github.com> Date: Mon, 31 Dec 2018 10:55:32 -0500 Subject: [PATCH 14/69] [react-stripe-elements] modify onReady to accept stripe.elements.Element instead of HTMLElement (#31705) * add clear() to stripe element * changing to existing type for the stripe element --- types/react-stripe-elements/index.d.ts | 4 +++- .../react-stripe-elements-tests.tsx | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/types/react-stripe-elements/index.d.ts b/types/react-stripe-elements/index.d.ts index 27f93683d1..7fb4c934db 100644 --- a/types/react-stripe-elements/index.d.ts +++ b/types/react-stripe-elements/index.d.ts @@ -6,6 +6,7 @@ // Andrew Goh Yisheng // Thomas Chia // Piotr Dabrowski +// Victor Irzak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -19,6 +20,7 @@ export namespace ReactStripeElements { type TokenResponse = stripe.TokenResponse; type SourceResponse = stripe.SourceResponse; type SourceOptions = stripe.SourceOptions; + type HTMLStripeElement = stripe.elements.Element; /** * There's a bug in @types/stripe which defines the property as @@ -60,7 +62,7 @@ export namespace ReactStripeElements { onFocus?(event: ElementChangeResponse): void; - onReady?(el: HTMLElement): void; + onReady?(el: HTMLStripeElement): void; } } diff --git a/types/react-stripe-elements/react-stripe-elements-tests.tsx b/types/react-stripe-elements/react-stripe-elements-tests.tsx index ac801e60f7..20bb920723 100644 --- a/types/react-stripe-elements/react-stripe-elements-tests.tsx +++ b/types/react-stripe-elements/react-stripe-elements-tests.tsx @@ -16,6 +16,7 @@ import ElementChangeResponse = stripe.elements.ElementChangeResponse; import ElementsOptions = stripe.elements.ElementsOptions; import ElementsCreateOptions = stripe.elements.ElementsCreateOptions; import PatchedTokenResponse = ReactStripeElements.PatchedTokenResponse; +import HTMLStripeElement = ReactStripeElements.HTMLStripeElement; const cardElementProps: ElementsOptions = { iconStyle: 'solid', @@ -63,41 +64,46 @@ const fontElementsProps: ElementsCreateOptions = { locale: "es" }; + el.clear()} +/>; + const ElementsWithPropsTest: React.SFC = () => (
void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} />
From 3d380b4caa4764367342d8f8692d4eb79c29076e Mon Sep 17 00:00:00 2001 From: ChenNima Date: Mon, 31 Dec 2018 23:55:46 +0800 Subject: [PATCH 15/69] Add waitForBody param for flush function (#31713) --- types/fetch-mock/fetch-mock-tests.ts | 1 + types/fetch-mock/index.d.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index 594d78c127..a5dc13c348 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -120,6 +120,7 @@ const myMatcher: fetchMock.MockMatcherFunction = ( fetchMock.flush().then(resolved => resolved.forEach(console.log)); fetchMock.flush().catch(r => r); +fetchMock.flush(true).catch(r => r); fetchMock.get("http://test.com", { body: 'abc', diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index 4b2915756e..a872a824d9 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -8,6 +8,7 @@ // Quentin Bouygues // Fumiaki Matsushima // Colin Doig +// Felix Chen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -441,8 +442,10 @@ declare namespace fetchMock { /** * Returns a promise that resolves once all fetches handled by fetch-mock * have resolved. + * @param [waitForBody] Wait for all body parsing methods(res.json(), + * res.text(), etc.) to resolve too. */ - flush(): Promise; + flush(waitForBody?: boolean): Promise; /** * Returns an array of all calls to fetch matching the given filters. From 1ede73f418f0c90860b78784e919cb3429c3e03b Mon Sep 17 00:00:00 2001 From: Aziz Khambati Date: Mon, 31 Dec 2018 21:26:25 +0530 Subject: [PATCH 16/69] [react-places-autocomplete] Split v7 and v6 definitions. Improve v7 definitions. (#31698) * [react-places-autocomplete] Add definitions for children * Add Readonly * Revert to React.ReactNode * Fix link * Split v7 and v6 types --- types/react-places-autocomplete/index.d.ts | 78 ++++++++++++------- .../react-places-autocomplete-tests.tsx | 32 ++++---- types/react-places-autocomplete/v6/index.d.ts | 71 +++++++++++++++++ .../v6/react-places-autocomplete-tests.tsx | 44 +++++++++++ .../v6/tsconfig.json | 25 ++++++ .../react-places-autocomplete/v6/tslint.json | 3 + 6 files changed, 205 insertions(+), 48 deletions(-) create mode 100644 types/react-places-autocomplete/v6/index.d.ts create mode 100644 types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx create mode 100644 types/react-places-autocomplete/v6/tsconfig.json create mode 100644 types/react-places-autocomplete/v6/tslint.json diff --git a/types/react-places-autocomplete/index.d.ts b/types/react-places-autocomplete/index.d.ts index e24e479be8..f4609e9ca0 100644 --- a/types/react-places-autocomplete/index.d.ts +++ b/types/react-places-autocomplete/index.d.ts @@ -1,8 +1,9 @@ // Type definitions for react-places-autocomplete 7.2 -// Project: https://github.com/kenny-hibino/react-places-autocomplete/ +// Project: https://github.com/hibiken/react-places-autocomplete/ // Definitions by: Guilherme Hübner // Andrew Makarov // Nokky Goren +// Aziz Khambati // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 // @@ -10,35 +11,26 @@ import * as React from "react"; -export interface formattedSuggestionType { - mainText: string; - secundaryText: string; +export type AutocompletePrediction = google.maps.places.AutocompletePrediction; + +export interface Suggestion { + id: string; + active: boolean; + index: number; + description: AutocompletePrediction["description"]; + placeId: AutocompletePrediction["place_id"]; + formattedSuggestion: { + mainText: AutocompletePrediction["structured_formatting"]["main_text"]; + secondaryText: AutocompletePrediction["structured_formatting"]["secondary_text"]; + }; + matchedSubstrings: AutocompletePrediction["matched_substrings"]; + terms: AutocompletePrediction["terms"]; + types: AutocompletePrediction["types"]; } export interface PropTypes { - inputProps?: { - type?: string; - name?: string; - placeholder?: string; - disabled?: boolean; - }; onError?: (status: string, clearSuggestion: () => void) => void; onSelect?: (address: string, placeID: string) => void; - renderSuggestion?: (suggestion: string, formattedSuggestion: formattedSuggestionType) => React.ReactNode; - classNames?: { - root?: string; - input?: string; - autocompleteContainer?: string; - autocompleteItem?: string; - autocompleteItemActive?: string; - }; - styles?: { - root?: React.CSSProperties; - input?: React.CSSProperties; - autocompleteContainer?: React.CSSProperties; - autocompleteItem?: React.CSSProperties; - autocompleteItemActive?: React.CSSProperties; - }; searchOptions?: { bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral; componentRestrictions?: google.maps.GeocoderComponentRestrictions; @@ -49,18 +41,44 @@ export interface PropTypes { }; value?: string; onChange?: (value: string) => void; - onBlur?: (event: React.FocusEvent) => void; debounce?: number; highlightFirstSuggestion?: boolean; - renderFooter?: () => React.ReactNode; - shouldFetchSuggestions?: (value: string) => boolean; + shouldFetchSuggestions?: boolean; + + children: (opts: Readonly<{ + loading: boolean; + suggestions: ReadonlyArray; + getInputProps: (options?: InputProps) => { + type: 'text'; + autoComplete: 'off'; + role: 'combobox'; + 'aria-autocomplete': 'list'; + 'aria-expanded': boolean; + 'aria-activedescendant': string | null; + disabled: boolean; + onKeyDown: React.KeyboardEventHandler; + onBlur: () => void; + value: string | undefined; + onChange: (ev: { target: { value: string }}) => void; + } & InputProps; + getSuggestionItemProps: (suggestion: Suggestion, options?: SuggestionProps) => { + key: number; + id: string | null; + role: 'option'; + onMouseEnter: () => void; + onMouseLeave: () => void; + onMouseDown: React.MouseEventHandler; + onMouseUp: () => void; + onTouchStart: () => void; + onTouchEnd: () => void; + onClick: (event?: Event) => void; + } & SuggestionProps; + }>) => React.ReactNode; } -export function geocodeByAddress(address: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; export function geocodeByAddress(address: string): Promise; -export function geocodeByPlaceId(placeId: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; export function geocodeByPlaceId(placeId: string): Promise; export function getLatLng(results: google.maps.GeocoderResult): Promise; diff --git a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx index a7a7816d99..d2420edb6b 100644 --- a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx +++ b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx @@ -12,18 +12,6 @@ class Test extends React.Component { const { address, placeId } = this.state; - // Old API - geocodeByAddress(address, (results, status) => { - const latLng = getLatLng(results[0]); - console.info(latLng, status); - }); - - geocodeByPlaceId(placeId, (results, status) => { - const latLng = getLatLng(results[0]); - console.info(latLng, status); - }); - - // New API geocodeByAddress(address) .then((results) => getLatLng(results[0])) .then((latLng) => console.log('Success', latLng)) @@ -38,14 +26,22 @@ class Test extends React.Component { onChange = (address: string) => this.setState({ address }); render() { - const inputProps = { - value: this.state.address, - onChange: this.onChange, - }; - return (
- + + {({getInputProps, getSuggestionItemProps, suggestions}) => ( + <> + +
+ {suggestions.map(suggestion => ( +
+ {suggestion.description} +
+ ))} +
+ + )} +
); } diff --git a/types/react-places-autocomplete/v6/index.d.ts b/types/react-places-autocomplete/v6/index.d.ts new file mode 100644 index 0000000000..25f1907f0c --- /dev/null +++ b/types/react-places-autocomplete/v6/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for react-places-autocomplete 6.1 +// Project: https://github.com/hibiken/react-places-autocomplete/ +// Definitions by: Guilherme Hübner +// Andrew Makarov +// Nokky Goren +// Aziz Khambati +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 +// +/// + +import * as React from "react"; + +export interface formattedSuggestionType { + mainText: string; + secondaryText: string; +} + +export interface InputProps extends Pick< + React.InputHTMLAttributes, + Exclude< + keyof React.InputHTMLAttributes, + "onChange" + > +> { + value: string; + onChange: (value: string) => void; +} + +export interface PropTypes { + inputProps: InputProps; + onError?: (status: string, clearSuggestion: () => void) => void; + onSelect?: (address: string, placeID: string) => void; + renderSuggestion?: (obj: { + suggestion: string; + formattedSuggestion: formattedSuggestionType; + }) => React.ReactNode; + classNames?: { + root?: string; + input?: string; + autocompleteContainer?: string; + autocompleteItem?: string; + autocompleteItemActive?: string; + }; + styles?: { + root?: React.CSSProperties; + input?: React.CSSProperties; + autocompleteContainer?: React.CSSProperties; + autocompleteItem?: React.CSSProperties; + autocompleteItemActive?: React.CSSProperties; + }; + options?: { + bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral; + componentRestrictions?: google.maps.GeocoderComponentRestrictions; + location?: google.maps.LatLng | google.maps.LatLngLiteral; + offset?: number | string; + radius?: number | string; + types?: string[]; + }; + + debounce?: number; + highlightFirstSuggestion?: boolean; + renderFooter?: () => React.ReactNode; + shouldFetchSuggestions?: (value: string) => boolean; +} + +export function geocodeByAddress(address: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; +export function geocodeByPlaceId(placeId: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; +export function getLatLng(results: google.maps.GeocoderResult): Promise; + +export default class PlacesAutocomplete extends React.Component {} diff --git a/types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx b/types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx new file mode 100644 index 0000000000..9afea47154 --- /dev/null +++ b/types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx @@ -0,0 +1,44 @@ +import * as React from 'react'; +import PlacesAutocomplete, { geocodeByAddress, geocodeByPlaceId, getLatLng } from 'react-places-autocomplete'; + +class Test extends React.Component { + state = { + address: 'San Francisco, CA', + placeId: '12345', + }; + + handleFormSubmit = (event: any) => { + event.preventDefault(); + + const { address, placeId } = this.state; + + geocodeByAddress(address, (results, status) => { + getLatLng(results[0]).then((latLng) => { + console.info(latLng, status); + }); + }); + + geocodeByPlaceId(placeId, (results, status) => { + getLatLng(results[0]).then((latLng) => { + console.info(latLng, status); + }); + }); + } + + onChange = (address: string) => this.setState({ address }); + + render() { + const inputProps: PlacesAutocomplete["props"]["inputProps"] = { + value: this.state.address, + onChange: this.onChange, + }; + + return ( +
+ + + ); + } +} diff --git a/types/react-places-autocomplete/v6/tsconfig.json b/types/react-places-autocomplete/v6/tsconfig.json new file mode 100644 index 0000000000..f330afea6b --- /dev/null +++ b/types/react-places-autocomplete/v6/tsconfig.json @@ -0,0 +1,25 @@ +{ + "files": [ + "index.d.ts", + "react-places-autocomplete-tests.tsx" + ], + "compilerOptions": { + "baseUrl": "../../", + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "lib": ["es6", "dom"], + "module": "commonjs", + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "paths": { + "react-places-autocomplete": [ + "react-places-autocomplete/v6" + ] + }, + "strictFunctionTypes": true, + "strictNullChecks": true, + "typeRoots": ["../../"], + "types": [] + } +} diff --git a/types/react-places-autocomplete/v6/tslint.json b/types/react-places-autocomplete/v6/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/react-places-autocomplete/v6/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From b37d6a5b05eaed874f7fdcab0d3fc85e4a95df56 Mon Sep 17 00:00:00 2001 From: aludev Date: Mon, 31 Dec 2018 17:57:15 +0200 Subject: [PATCH 17/69] Fix readPkcs12 function types (#31612) --- types/pem/index.d.ts | 11 +++++++++-- types/pem/pem-tests.ts | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/types/pem/index.d.ts b/types/pem/index.d.ts index c6689a273f..bdfa3e1196 100644 --- a/types/pem/index.d.ts +++ b/types/pem/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/andris9/pem // Definitions by: Anthony Trinh , Ruslan Arkhipau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// export interface ModuleConfiguration { /** @@ -135,6 +136,12 @@ export interface CertificateSubjectReadResult { emailAddress: string; } +export interface Pkcs12ReadResult { + key: string; + cert: string; + ca: string[]; +} + export type Callback = (error: any, result: T) => any; /** @@ -244,8 +251,8 @@ export function createPkcs12(key: string, certificate: string, password: string, * @param callback Callback function with an error object and {pkcs12} * @returns the result of the callback */ -export function readPkcs12(bufferOrPath: string, options: Pkcs12ReadOptions, callback: Callback<{ pkcs12: any }>): any; -export function readPkcs12(bufferOrPath: string, callback: Callback<{ pkcs12: any }>): any; +export function readPkcs12(bufferOrPath: Buffer | string, options: Pkcs12ReadOptions, callback: Callback): any; +export function readPkcs12(bufferOrPath: Buffer | string, callback: Callback): any; /** * Verifies the signing chain of the passed certificate diff --git a/types/pem/pem-tests.ts b/types/pem/pem-tests.ts index fe409b6560..6841b568d7 100644 --- a/types/pem/pem-tests.ts +++ b/types/pem/pem-tests.ts @@ -1,4 +1,5 @@ import * as pem from 'pem'; +import * as fs from 'fs'; const tests = { 'Create default sized dhparam key': (test: any) => { @@ -557,8 +558,21 @@ const tests = { test.ok(pkcs12.pkcs12); // test.ok(fs.readdirSync('./tmp').length === 0); + const pkcs12Buffer = new Buffer(pkcs12.pkcs12); - pem.readPkcs12(pkcs12.pkcs12, (error: any, keystore: any) => { + pem.readPkcs12(pkcs12Buffer, (error: any, keystore: pem.Pkcs12ReadResult) => { + test.ifError(error); + test.ok(keystore); + + test.equal(ca.certificate, keystore.ca[0]); + test.equal(cert.certificate, keystore.cert); + test.equal(cert.clientKey, keystore.key); + }); + + const pkcs12File: string = __dirname + '/test.pkcs12'; + fs.writeFileSync(pkcs12File, pkcs12Buffer); + + pem.readPkcs12(pkcs12File, (error: any, keystore: pem.Pkcs12ReadResult) => { test.ifError(error); test.ok(keystore); From 09f738c6d5c750df75bef7e6ca8b488646f47048 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Mon, 31 Dec 2018 16:58:00 +0100 Subject: [PATCH 18/69] [graphql] Predicates can be now used as type guards (#31701) * feat(graphql): predicates as type guards Predicates in `graphql/language/predicates` are used in Flow as type guards. Now they can be used in TS too: * isDefinitionNode * isExecutableDefinitionNode * isSelectionNode * isValueNode * isTypeNode * isTypeSystemDefinitionNode * isTypeDefinitionNode * isTypeSystemExtensionNode * isTypeExtensionNode * chore(graphql): add langpavel to "Definitions by" --- types/graphql/index.d.ts | 1 + types/graphql/language/predicates.d.ts | 31 +++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 0b87d35222..abaa81294b 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -16,6 +16,7 @@ // Brad Zacher // Curtis Layne // Jonathan Cardoso +// Pavel Lang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 diff --git a/types/graphql/language/predicates.d.ts b/types/graphql/language/predicates.d.ts index 81d2e02c41..c31a87f2a5 100644 --- a/types/graphql/language/predicates.d.ts +++ b/types/graphql/language/predicates.d.ts @@ -1,19 +1,30 @@ -import { ASTNode } from "./ast"; +import { + ASTNode, + DefinitionNode, + ExecutableDefinitionNode, + SelectionNode, + ValueNode, + TypeNode, + TypeSystemDefinitionNode, + TypeDefinitionNode, + TypeSystemExtensionNode, + TypeExtensionNode, +} from "./ast"; -export function isDefinitionNode(node: ASTNode): boolean; +export function isDefinitionNode(node: ASTNode): node is DefinitionNode; -export function isExecutableDefinitionNode(node: ASTNode): boolean; +export function isExecutableDefinitionNode(node: ASTNode): node is ExecutableDefinitionNode; -export function isSelectionNode(node: ASTNode): boolean; +export function isSelectionNode(node: ASTNode): node is SelectionNode; -export function isValueNode(node: ASTNode): boolean; +export function isValueNode(node: ASTNode): node is ValueNode; -export function isTypeNode(node: ASTNode): boolean; +export function isTypeNode(node: ASTNode): node is TypeNode; -export function isTypeSystemDefinitionNode(node: ASTNode): boolean; +export function isTypeSystemDefinitionNode(node: ASTNode): node is TypeSystemDefinitionNode; -export function isTypeDefinitionNode(node: ASTNode): boolean; +export function isTypeDefinitionNode(node: ASTNode): node is TypeDefinitionNode; -export function isTypeSystemExtensionNode(node: ASTNode): boolean; +export function isTypeSystemExtensionNode(node: ASTNode): node is TypeSystemExtensionNode; -export function isTypeExtensionNode(node: ASTNode): boolean; +export function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode; From 86d7939a7df12e35141aeb00a9a55ed10b05d818 Mon Sep 17 00:00:00 2001 From: Eric Camellini Date: Mon, 31 Dec 2018 16:58:52 +0100 Subject: [PATCH 19/69] Updating declarations of openpgpjs and adding sign and verify (#31740) * Updating declarations of openpgpjs for existing methods and adding sign and verify * Fixing linter error * Fixing compilation errors * Making same changes to ts3.2 and fixing String/string typos * Adding name to authors --- package.json | 3 +- types/openpgp/index.d.ts | 179 ++++++++++++++++++++++++--- types/openpgp/openpgp-tests.ts | 25 ++++ types/openpgp/ts3.2/index.d.ts | 179 ++++++++++++++++++++++++--- types/openpgp/ts3.2/openpgp-tests.ts | 24 ++++ 5 files changed, 379 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index caf101cbc6..7fc0358f27 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,6 @@ "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "github:Microsoft/types-publisher#production" - } + }, + "dependencies": {} } diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index edbe0eb77c..d564c6df6d 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -4,6 +4,7 @@ // Errietta Kostala // Daniel Montesinos // Carlos Villavicencio +// Eric Camellini // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -27,6 +28,7 @@ export interface EncryptOptions { sessionKey?: SessionKey, compression?: enums.compression, armor?: boolean, + streaming?: 'web' | 'node' | false detached?: boolean, signature?: Signature, returnSessionKey?: boolean, @@ -39,6 +41,8 @@ export interface EncryptOptions { export interface EncryptedMessage { data?: string, message?: message.Message, + signature?: string | ReadableStream | Signature // TODO add NodeStream + sessionKey?: SessionKey } export interface DecryptOptions { @@ -48,17 +52,35 @@ export interface DecryptOptions { sessionKeys?: SessionKey | SessionKey[], publicKeys?: key.Key | key.Key[], format?: string, + streaming?: 'web' | 'node' | false, signature?: Signature, date?: Date, } +export interface SignOptions { + message: message.Message, + privateKeys?: key.Key | key.Key[], + armor?: boolean, + streaming?: 'web' | 'node' | false, + detached?: boolean + date?: Date, + fromUserIds?: UserId[] +} + +export interface SignedMessage { + signature?: string | ReadableStream | Signature, // TODO add NodeStream + data?: string | ReadableStream, // TODO add NodeStream + message?: message.Message +} + export interface KeyContainer { key: key.Key, } export interface KeyPair extends KeyContainer { privateKeyArmored: string, - publicKeyArmored: string + publicKeyArmored: string, + revocationCertificate: string } export interface KeyOptions { @@ -77,13 +99,27 @@ export interface Keyid { export interface Signature { keyid: Keyid, - valid: boolean + valid: boolean, + verified?: boolean +} + +export interface VerifyOptions { + message: message.Message, + publicKeys: key.Key | key.Key[], + streaming?: 'web' | 'node' | false, + signature?: Signature, + date?: Date } export interface VerifiedMessage { - data: Uint8Array | string, + data: Uint8Array | string | ReadableStream, // TODO add NodeStream signatures: Array, - filename: string, +} + +export interface DecryptedMessage { + data: Uint8Array | string | ReadableStream, // TODO add NodeStream + signatures: Array, + filename: string } export interface OpenPGPWorker { @@ -98,7 +134,7 @@ export interface WorkerOptions { path?: string, n?: number, workers?: OpenPGPWorker[], - config?: any, + config?: any } export class AsyncProxy { @@ -140,16 +176,23 @@ export function destroyWorker(): void; * @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String } * @param {module:enums.compression} compression (optional) which compression algorithm to compress the message with, defaults to what is specified in config * @param {Boolean} armor (optional) if the return values should be ascii armored or the message/signature objects + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Boolean} detached (optional) if the signature should be detached (if true, signature will be added to returned object) * @param {Signature} signature (optional) a detached signature to add to the encrypted message * @param {Boolean} returnSessionKey (optional) if the unencrypted session key should be added to returned object * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs - * @param {Date} date (optional) override the creation date of the message and the message signature + * @param {Date} date (optional) override the creation date of the message signature * @param {Object} fromUserId (optional) user ID to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } * @param {Object} toUserId (optional) user ID to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } - * @returns {Promise} encrypted (and optionally signed message) in the form: - * {data: ASCII armored message if 'armor' is true, - * message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true} + * @returns {Promise} Object containing encrypted (and optionally signed) message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message, (if `armor` was false) + * signature: String|ReadableStream|NodeStream, (if `detached` was true and `armor` was true) + * signature: Signature (if `detached` was true and `armor` was false) + * sessionKey: { data, algorithm, aeadAlgorithm } (if `returnSessionKey` was true) + * } * @async * @static */ @@ -164,14 +207,79 @@ export function encrypt(options: EncryptOptions): Promise; * @param {Object|Array} sessionKeys (optional) session keys in the form: { data:Uint8Array, algorithm:String } * @param {Key|Array} publicKeys (optional) array of public keys or single key, to verify signatures * @param {String} format (optional) return data format either as 'utf8' or 'binary' + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Signature} signature (optional) detached signature for verification * @param {Date} date (optional) use the given date for verification instead of the current time - * @returns {Promise} decrypted and verified message in the form: - * { data:Uint8Array|String, filename:String, signatures:[{ keyid:String, valid:Boolean }] } + * @returns {Promise} Object containing decrypted and verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if format was 'utf8', the default) + * data: Uint8Array|ReadableStream|NodeStream, (if format was 'binary') + * filename: String, + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if streaming was false) + * }, ... + * ] + * } * @async * @static */ -export function decrypt(options: DecryptOptions): Promise; +export function decrypt(options: DecryptOptions): Promise; + +/** + * Signs a cleartext message. + * @param {CleartextMessage|Message} message (cleartext) message to be signed + * @param {Key|Array} privateKeys array of keys or single key with decrypted secret key data to sign cleartext + * @param {Boolean} armor (optional) if the return value should be ascii armored or the message object + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Boolean} detached (optional) if the return value should contain a detached signature + * @param {Date} date (optional) override the creation date of the signature + * @param {Array} fromUserIds (optional) array of user IDs to sign with, one per key in `privateKeys`, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] + * @returns {Promise} Object containing signed message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message (if `armor` was false) + * } + * + * Or, if `detached` was true: + * + * { + * signature: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * signature: Signature (if `armor` was false) + * } + * @async + * @static + */ +export function sign(options: SignOptions): Promise; + +/** + * Verifies signatures of cleartext signed message + * @param {Key|Array} publicKeys array of publicKeys or single key, to verify signatures + * @param {CleartextMessage|Message} message (cleartext) message object with signatures + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Signature} signature (optional) detached signature for verification + * @param {Date} date (optional) use the given date for verification instead of the current time + * @returns {Promise} Object containing verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `message` was a CleartextMessage) + * data: Uint8Array|ReadableStream|NodeStream, (if `message` was a Message) + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if `streaming` was false) + * }, ... + * ] + * } + * @async + * @static + */ +export function verify(options: VerifyOptions): Promise; /** * Generates a new OpenPGP key pair. Supports RSA and ECC keys. Primary and subkey will be of same type. @@ -186,7 +294,7 @@ export function decrypt(options: DecryptOptions): Promise; * @param {Array} subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}] * sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -198,8 +306,9 @@ export function generateKey(options: KeyOptions): Promise; * @param {Array} userIds array of user IDs e.g. [{ name:'Phil Zimmermann', email:'phil@openpgp.org' }] * @param {String} passphrase (optional) The passphrase used to encrypt the resulting private key * @param {Number} keyExpirationTime (optional) The number of seconds after the key creation time that the key expires + * @param {Boolean} revocationCertificate (optional) Whether the returned object should include a revocation certificate to revoke the public key * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -208,6 +317,29 @@ export function reformatKey(options: { userIds?: UserId[], passphrase?: string, keyExpirationTime?: number, + revocationCertificate?: boolean +}): Promise; + +/** + * Revokes a key. Requires either a private key or a revocation certificate. + * If a revocation certificate is passed, the reasonForRevocation parameters will be ignored. + * @param {Key} key (optional) public or private key to revoke + * @param {String} revocationCertificate (optional) revocation certificate to revoke the key with + * @param {Object} reasonForRevocation (optional) object indicating the reason for revocation + * @param {module:enums.reasonForRevocation} reasonForRevocation.flag (optional) flag indicating the reason for revocation + * @param {String} reasonForRevocation.string (optional) string explaining the reason for revocation + * @returns {Promise} The revoked key object in the form: + * { privateKey:Key, privateKeyArmored:String, publicKey:Key, publicKeyArmored:String } + * (if private key is passed) or { publicKey:Key, publicKeyArmored:String } (otherwise) + * @static + */ +export function revokeKey(options: { + key?: key.Key, + revocationCertificate?: string + reasonForRevocation?: { + flag: enums.reasonForRevocation, + 'string': string + }, }): Promise; /** @@ -222,11 +354,20 @@ export function decryptKey(options: { passphrase?: string | string[], }): Promise; +/** + * Lock a private key with your passphrase. + * @param {Key} privateKey the private key that is to be decrypted + * @param {String|Array} passphrase the user's passphrase(s) chosen during key generation + * @returns {Promise} the locked key object in the form: { key:Key } + * @async + */ export function encryptKey(options: { privateKey: key.Key, - passphrase?: string + passphrase?: string | string[], }): Promise; +// TODO add typings for encryptSessionKey and decryptSessionKeys + export namespace armor { /** Armor an OpenPGP binary packet block @@ -485,6 +626,14 @@ export namespace enums { valid, no_self_cert } + + enum reasonForRevocation { + no_reason, + key_superseded, + key_compromised, + key_retired, + userid_invalid + } } export namespace key { diff --git a/types/openpgp/openpgp-tests.ts b/types/openpgp/openpgp-tests.ts index 30f9adbc8b..19e305cb26 100644 --- a/types/openpgp/openpgp-tests.ts +++ b/types/openpgp/openpgp-tests.ts @@ -110,6 +110,31 @@ openpgp.initWorker({ path:'openpgp.worker.js' }); })(); +(async () => { + const publicKey = (await openpgp.key.readArmored(spubkey)) + const privateKey = (await openpgp.key.readArmored(sprivkey)) + const signOptions: openpgp.SignOptions = { + message: openpgp.message.fromText('hello world'), + privateKeys: privateKey.keys, + detached: true + }; + + const signed = await openpgp.sign(signOptions); + + const signature = signed.signature as openpgp.Signature; + const message = signed.message; + + const verifyOptions: openpgp.VerifyOptions = { + message, + signature, + publicKeys: publicKey.keys + }; + + let verified = await openpgp.verify(verifyOptions); + + return verified.signatures[0].valid; +})(); + // Open PGP Tests diff --git a/types/openpgp/ts3.2/index.d.ts b/types/openpgp/ts3.2/index.d.ts index 0bf040bc17..428f785dbe 100644 --- a/types/openpgp/ts3.2/index.d.ts +++ b/types/openpgp/ts3.2/index.d.ts @@ -4,6 +4,7 @@ // Errietta Kostala // Daniel Montesinos // Carlos Villavicencio +// Eric Camellini // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace openpgp; @@ -26,6 +27,7 @@ export interface EncryptOptions { sessionKey?: SessionKey, compression?: enums.compression, armor?: boolean, + streaming?: 'web' | 'node' | false detached?: boolean, signature?: Signature, returnSessionKey?: boolean, @@ -38,6 +40,8 @@ export interface EncryptOptions { export interface EncryptedMessage { data?: string, message?: message.Message, + signature?: string | ReadableStream | Signature // TODO add NodeStream + sessionKey?: SessionKey } export interface DecryptOptions { @@ -47,17 +51,35 @@ export interface DecryptOptions { sessionKeys?: SessionKey | SessionKey[], publicKeys?: key.Key | key.Key[], format?: string, + streaming?: 'web' | 'node' | false, signature?: Signature, date?: Date, } +export interface SignOptions { + message: message.Message, + privateKeys?: key.Key | key.Key[], + armor?: boolean, + streaming?: 'web' | 'node' | false, + detached?: boolean + date?: Date, + fromUserIds?: UserId[] +} + +export interface SignedMessage { + signature?: string | ReadableStream | Signature, // TODO add NodeStream + data?: string | ReadableStream, // TODO add NodeStream + message?: message.Message +} + export interface KeyContainer { key: key.Key, } export interface KeyPair extends KeyContainer { privateKeyArmored: string, - publicKeyArmored: string + publicKeyArmored: string, + revocationCertificate: string } export interface KeyOptions { @@ -76,13 +98,27 @@ export interface Keyid { export interface Signature { keyid: Keyid, - valid: boolean + valid: boolean, + verified?: boolean +} + +export interface VerifyOptions { + message: message.Message, + publicKeys: key.Key | key.Key[], + streaming?: 'web' | 'node' | false, + signature?: Signature, + date?: Date } export interface VerifiedMessage { - data: Uint8Array | string, + data: Uint8Array | string | ReadableStream | ReadableStream, // TODO add NodeStream signatures: Array, - filename: string, +} + +export interface DecryptedMessage { + data: Uint8Array | string | ReadableStream | ReadableStream, // TODO add NodeStream + signatures: Array, + filename: string } export interface OpenPGPWorker { @@ -97,7 +133,7 @@ export interface WorkerOptions { path?: string, n?: number, workers?: OpenPGPWorker[], - config?: any, + config?: any } export class AsyncProxy { @@ -139,16 +175,23 @@ export function destroyWorker(): void; * @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String } * @param {module:enums.compression} compression (optional) which compression algorithm to compress the message with, defaults to what is specified in config * @param {Boolean} armor (optional) if the return values should be ascii armored or the message/signature objects + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Boolean} detached (optional) if the signature should be detached (if true, signature will be added to returned object) * @param {Signature} signature (optional) a detached signature to add to the encrypted message * @param {Boolean} returnSessionKey (optional) if the unencrypted session key should be added to returned object * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs - * @param {Date} date (optional) override the creation date of the message and the message signature + * @param {Date} date (optional) override the creation date of the message signature * @param {Object} fromUserId (optional) user ID to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } * @param {Object} toUserId (optional) user ID to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } - * @returns {Promise} encrypted (and optionally signed message) in the form: - * {data: ASCII armored message if 'armor' is true, - * message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true} + * @returns {Promise} Object containing encrypted (and optionally signed) message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message, (if `armor` was false) + * signature: String|ReadableStream|NodeStream, (if `detached` was true and `armor` was true) + * signature: Signature (if `detached` was true and `armor` was false) + * sessionKey: { data, algorithm, aeadAlgorithm } (if `returnSessionKey` was true) + * } * @async * @static */ @@ -163,14 +206,79 @@ export function encrypt(options: EncryptOptions): Promise; * @param {Object|Array} sessionKeys (optional) session keys in the form: { data:Uint8Array, algorithm:String } * @param {Key|Array} publicKeys (optional) array of public keys or single key, to verify signatures * @param {String} format (optional) return data format either as 'utf8' or 'binary' + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Signature} signature (optional) detached signature for verification * @param {Date} date (optional) use the given date for verification instead of the current time - * @returns {Promise} decrypted and verified message in the form: - * { data:Uint8Array|String, filename:String, signatures:[{ keyid:String, valid:Boolean }] } + * @returns {Promise} Object containing decrypted and verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if format was 'utf8', the default) + * data: Uint8Array|ReadableStream|NodeStream, (if format was 'binary') + * filename: String, + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if streaming was false) + * }, ... + * ] + * } * @async * @static */ -export function decrypt(options: DecryptOptions): Promise; +export function decrypt(options: DecryptOptions): Promise; + +/** + * Signs a cleartext message. + * @param {CleartextMessage|Message} message (cleartext) message to be signed + * @param {Key|Array} privateKeys array of keys or single key with decrypted secret key data to sign cleartext + * @param {Boolean} armor (optional) if the return value should be ascii armored or the message object + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Boolean} detached (optional) if the return value should contain a detached signature + * @param {Date} date (optional) override the creation date of the signature + * @param {Array} fromUserIds (optional) array of user IDs to sign with, one per key in `privateKeys`, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] + * @returns {Promise} Object containing signed message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message (if `armor` was false) + * } + * + * Or, if `detached` was true: + * + * { + * signature: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * signature: Signature (if `armor` was false) + * } + * @async + * @static + */ +export function sign(options: SignOptions): Promise; + +/** + * Verifies signatures of cleartext signed message + * @param {Key|Array} publicKeys array of publicKeys or single key, to verify signatures + * @param {CleartextMessage|Message} message (cleartext) message object with signatures + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Signature} signature (optional) detached signature for verification + * @param {Date} date (optional) use the given date for verification instead of the current time + * @returns {Promise} Object containing verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `message` was a CleartextMessage) + * data: Uint8Array|ReadableStream|NodeStream, (if `message` was a Message) + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if `streaming` was false) + * }, ... + * ] + * } + * @async + * @static + */ +export function verify(options: VerifyOptions): Promise; /** * Generates a new OpenPGP key pair. Supports RSA and ECC keys. Primary and subkey will be of same type. @@ -185,7 +293,7 @@ export function decrypt(options: DecryptOptions): Promise; * @param {Array} subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}] * sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -197,8 +305,9 @@ export function generateKey(options: KeyOptions): Promise; * @param {Array} userIds array of user IDs e.g. [{ name:'Phil Zimmermann', email:'phil@openpgp.org' }] * @param {String} passphrase (optional) The passphrase used to encrypt the resulting private key * @param {Number} keyExpirationTime (optional) The number of seconds after the key creation time that the key expires + * @param {Boolean} revocationCertificate (optional) Whether the returned object should include a revocation certificate to revoke the public key * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -207,6 +316,29 @@ export function reformatKey(options: { userIds?: UserId[], passphrase?: string, keyExpirationTime?: number, + revocationCertificate?: boolean +}): Promise; + +/** + * Revokes a key. Requires either a private key or a revocation certificate. + * If a revocation certificate is passed, the reasonForRevocation parameters will be ignored. + * @param {Key} key (optional) public or private key to revoke + * @param {String} revocationCertificate (optional) revocation certificate to revoke the key with + * @param {Object} reasonForRevocation (optional) object indicating the reason for revocation + * @param {module:enums.reasonForRevocation} reasonForRevocation.flag (optional) flag indicating the reason for revocation + * @param {String} reasonForRevocation.string (optional) string explaining the reason for revocation + * @returns {Promise} The revoked key object in the form: + * { privateKey:Key, privateKeyArmored:String, publicKey:Key, publicKeyArmored:String } + * (if private key is passed) or { publicKey:Key, publicKeyArmored:String } (otherwise) + * @static + */ +export function revokeKey(options: { + key?: key.Key, + revocationCertificate?: string + reasonForRevocation?: { + flag: enums.reasonForRevocation, + 'string': string + }, }): Promise; /** @@ -221,11 +353,20 @@ export function decryptKey(options: { passphrase?: string | string[], }): Promise; +/** + * Lock a private key with your passphrase. + * @param {Key} privateKey the private key that is to be decrypted + * @param {String|Array} passphrase the user's passphrase(s) chosen during key generation + * @returns {Promise} the locked key object in the form: { key:Key } + * @async + */ export function encryptKey(options: { privateKey: key.Key, - passphrase?: string + passphrase?: string | string[], }): Promise; +// TODO add typings for encryptSessionKey and decryptSessionKeys + export namespace armor { /** Armor an OpenPGP binary packet block @@ -484,6 +625,14 @@ export namespace enums { valid, no_self_cert } + + enum reasonForRevocation { + no_reason, + key_superseded, + key_compromised, + key_retired, + userid_invalid + } } export namespace key { diff --git a/types/openpgp/ts3.2/openpgp-tests.ts b/types/openpgp/ts3.2/openpgp-tests.ts index 30f9adbc8b..7dffc0109b 100644 --- a/types/openpgp/ts3.2/openpgp-tests.ts +++ b/types/openpgp/ts3.2/openpgp-tests.ts @@ -109,6 +109,30 @@ openpgp.initWorker({ path:'openpgp.worker.js' }); return plain.data; })(); +(async () => { + const publicKey = (await openpgp.key.readArmored(spubkey)) + const privateKey = (await openpgp.key.readArmored(sprivkey)) + const signOptions: openpgp.SignOptions = { + message: openpgp.message.fromText('hello world'), + privateKeys: privateKey.keys, + detached: true + }; + + const signed = await openpgp.sign(signOptions); + + const signature = signed.signature as openpgp.Signature; + const message = signed.message; + + const verifyOptions: openpgp.VerifyOptions = { + message, + signature, + publicKeys: publicKey.keys + }; + + let verified = await openpgp.verify(verifyOptions); + + return verified.signatures[0].valid; +})(); // Open PGP Tests From df309e0eb0e40d17f1bc94c61e1f1350ef899773 Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 31 Dec 2018 10:59:30 -0500 Subject: [PATCH 20/69] [@types/jwplayer] Add setCaptions, getVisualQuality (#31749) * Add missing setCaptions method - per docs https://developer.jwplayer.com/jw-player/docs/javascript-api-reference/#captions * Add missing getVisualQuality method - per docs https://developer.jwplayer.com/jw-player/docs/javascript-api-reference/#quality --- types/jwplayer/index.d.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/types/jwplayer/index.d.ts b/types/jwplayer/index.d.ts index 6481b59faf..1d65bca261 100644 --- a/types/jwplayer/index.d.ts +++ b/types/jwplayer/index.d.ts @@ -5,6 +5,7 @@ // Philipp Gürtler // Daniel McGraw // Benjamin Dobson +// Be Birchall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -241,6 +242,31 @@ interface Region { height: number; } +interface CaptionOptions { + color: string; + fontSize: number; + fontFamily: string; + fontOpacity: number; + backgroundColor: string; + backgroundOpacity: number; + edgeStyle: string; + windowColor: string; + windowOpacity: number; +} + +interface Level { + bitrate: number; + height: number; + width: number; + label: string; +} + +interface QualityLevel { + mode: 'auto' | 'manual'; + level: Level; + reason: 'auto' | 'api' | 'initial choice'; +} + interface JWPlayer { addButton(icon: string, label: string, handler: () => void, id: string): void; getAudioTracks(): any[]; @@ -266,6 +292,7 @@ interface JWPlayer { getContainer(): HTMLElement; getEnvironment(): Environment; getWidth(): number; + getVisualQuality(): QualityLevel | undefined; load(playlist: any[]): void; load(playlist: string): void; on(event: 'adClick', callback: EventCallback): void; @@ -469,6 +496,7 @@ interface JWPlayer { setMute(state?: boolean): void; setup(options: any): JWPlayer; setVolume(volume: number): void; + setCaptions(options: CaptionOptions): void; stop(): void; } From d77cdfe11edae54dd7a90d4ce9318316dd0b0470 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 31 Dec 2018 11:00:33 -0500 Subject: [PATCH 21/69] [@types/jest] Update `jest.fail` return type from `void` to `never`. (#31745) * Update `jest.fail` return type from `void` to `never`. This should never return, right? * Revert unrelated change --- types/jest/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index d434b5e198..6fb82e76b2 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -981,7 +981,7 @@ declare function pending(reason?: string): void; /** * Fails a test when called within one. */ -declare function fail(error?: any): void; +declare function fail(error?: any): never; declare namespace jasmine { let DEFAULT_TIMEOUT_INTERVAL: number; function clock(): Clock; From b68f2ee2ac69dbd560002718d48ff31ea358fdbe Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Mon, 31 Dec 2018 17:01:20 +0100 Subject: [PATCH 22/69] feat(sinon): Make stub factory method optionally generic (#31606) --- types/sinon/ts3.1/index.d.ts | 5 ++++- types/sinon/ts3.1/sinon-tests.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index 920b109281..119ff98137 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -626,10 +626,13 @@ declare namespace Sinon { } interface SinonStubStatic { + // Disable rule so assignment to typed stub works (see examples in tests). /** * Creates an anonymous stub function */ - (): SinonStub; + // tslint:disable-next-line no-unnecessary-generics + (): SinonStub; + /** * Stubs all the object’s methods. * Note that it’s usually better practice to stub individual methods, particularly on objects that you don’t understand or control all the methods for (e.g. library dependencies). diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index a420d9851d..2aae56dfdc 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -483,6 +483,23 @@ function testStub() { stub.withArgs('a', 2).returns(true); } +function testTypedStub() { + class Foo { + bar(baz: number, qux: string): boolean { + return true; + } + } + let stub: sinon.SinonStub<[number, string], boolean> = sinon.stub(); + let stub2 = sinon.stub<[number, string], boolean>(); + const foo = new Foo(); + stub = sinon.stub(foo, 'bar'); + stub2 = sinon.stub(foo, 'bar'); + const result: boolean = stub(42, 'qux'); + const fooStub: sinon.SinonStubbedInstance = { + bar: sinon.stub() + }; +} + function testMock() { const obj = {}; const mock = sinon.mock(obj); From 6e2b0af37afc58f967db59bc066529ddfa3033cf Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:01:45 +0000 Subject: [PATCH 23/69] [object-path] Update types to v0.11 (#31746) * [object-path] Update types to v0.11 * [object-path] Fixes after review --- types/object-path/index.d.ts | 216 +++++++------------------ types/object-path/object-path-tests.ts | 152 ++++++----------- types/object-path/tsconfig.json | 4 +- types/object-path/tslint.json | 78 +-------- 4 files changed, 106 insertions(+), 344 deletions(-) diff --git a/types/object-path/index.d.ts b/types/object-path/index.d.ts index 535fbe2878..9c3055ab5d 100644 --- a/types/object-path/index.d.ts +++ b/types/object-path/index.d.ts @@ -1,249 +1,141 @@ -// Type definitions for objectPath v0.9.x +// Type definitions for objectPath 0.11 // Project: https://github.com/mariocasciaro/object-path // Definitions by: Paulo Cesar +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -declare var objectPath: ObjectPathGlobal.IObjectPathStatic; +declare const objectPath: objectPath.ObjectPathStatic & { + withInheritedProps: objectPath.ObjectPathStatic; + create(options?: objectPath.Options): objectPath.ObjectPathStatic; +}; -declare namespace ObjectPathGlobal { +declare namespace objectPath { + interface Options { + includeInheritedProps?: boolean; + } - type IPath = Array|number|string; - type IMultiArray = Array; + type Path = Array | number | string; - interface IObjectPathStatic { + interface ObjectPathStatic { /** * Binds an object */ - (object: T): IObjectPathBound; - - /*======== Del =========*/ + (object: T): ObjectPathBound; /** * Deletes a member from object or array - * @param {object} object - * @param {string[]|string} path - * @return object */ - del(object: T, path: IPath): T; - /** - * @see objectPath.del - */ - del(object: T):T; - /** - * @see objectPath.del - */ - del():void; + del(object: object, path: Path): { [key: string]: any }; - /*======== Has =========*/ /** * Tests path existence - * @param {object} object - * @param {string[]|string} path - * @return object */ - has(object: T, path: IPath): boolean; - /** - * @see objectPath.has - */ - has(object: T): boolean; - /** - * @see objectPath.has - */ - has(): boolean; + has(object: object, path: Path): boolean; - /*======== Get =========*/ /** * Get a path from an object - * @param {object} object - * @param {string|string[]|number|number[]} path - * @param {*} [defaultValue=undefined] */ - get(object: T, path: IPath, defaultValue?: TResult): TResult; - /** - * @see objectPath.get - */ - get(object: T): T; - /** - * @see objectPath.get - */ - get():void; + get(object: object, path: Path): any; + get(object: object, path: Path, defaultValue: TResult): TResult; - /*======== Set =========*/ /** * Set a path to a value - * @param {object} object - * @param {string|string[]|number|number[]} path - * @param {*} value - * @param {boolean} [doNotReplace=false] * @return Any existing value on the path if any */ - set(object: T, path: IPath, value: any, doNotReplace?:boolean): TExisting; - /** - * @see objectPath.set - */ - set(object: T): T; - /** - * @see objectPath.set - */ - set():void; + set( + object: object, + path: Path, + value: TResult, + doNotReplace?: boolean + ): TResult | undefined; - /*======== Push =========*/ /** * Create (if path isn't an array) and push the value to it. Can push unlimited number of values - * @param {object} object */ - push(object: T, path: IPath, ...args:any[]):void; - /** - * @see objectPath.push - */ - push():void; + push(object: object, path: Path, ...items: any[]): void; - /*======== Coalesce =========*/ /** * Get the first non undefined property - * @param {object} object - * @param {string[]|string[][]|number[]|number[][]} paths - * @param {*} defaultValue - * @return {*} */ - coalesce(object: T, paths: IMultiArray, defaultValue?: TResult):TResult; + coalesce(object: object, paths: Path | Path[], defaultValue: TResult): TResult; + coalesce( + object: object, + paths: Path | Path[], + defaultValue?: TResult + ): TResult | undefined; - /*======== Empty =========*/ /** * Empty a path. Arrays are set to length 0, objects have all elements deleted, strings * are set to empty, numbers to 0, everything else is set to null - * @param {object} object - * @param {string|string[]|number[]} path */ - empty(object: T, path: IPath):TResult; - /** - * @see objectPath.empty - */ - empty(object: T):T; - /** - * @see objectPath.empty - */ - empty():void; + empty(object: object, path: Path): any; - /*======== EnsureExists =========*/ /** * Set a value if it doesn't exist, do nothing if it does - * @param {object} object - * @param {string|string[]|number|number[]} path */ - ensureExists(object: T, path: IPath, value: any):TExisting; - /** - * @see objectPath.ensureExists - */ - ensureExists(object: T): T; - /** - * @see objectPath.ensureExists - */ - ensureExists():void; + ensureExists(object: object, path: Path, defaultValue: TResult): TResult; + ensureExists( + object: object, + path: Path, + defaultValue?: TResult + ): TResult | undefined; - /*======== Insert =========*/ /** * Insert an item in an array path - * @param {object} object - * @param {string|string[]|number|number[]} path - * @param {*} value - * @param {number} [at=0] */ - insert(object: T, path: IPath, value: any, at?: number):void; + insert(object: object, path: Path, value: any, at?: number): void; } - interface IObjectPathBound { - /*======== Del =========*/ - - /** - * @see objectPath.ensureExists - */ - del(path: IPath): T; + interface ObjectPathBound { /** * @see objectPath.del */ - del(): T; + del(path: Path): { [key: string]: any }; - /*======== Has =========*/ - /** - * @see objectPath.ensureExists - */ - has(path: IPath): boolean; /** * @see objectPath.has */ - has(): boolean; + has(path: Path): boolean; - /*======== Get =========*/ - /** - * @see objectPath.ensureExists - */ - get(path: IPath, defaultValue?: TResult): TResult; /** * @see objectPath.get */ - get(): T; + get(path: Path): any; + get(path: Path, defaultValue: TResult): TResult; - /*======== Set =========*/ - /** - * @see objectPath.ensureExists - */ - set(path: IPath, value: any, doNotReplace?:boolean): TExisting; /** * @see objectPath.set */ - set(): T; + set(path: Path, value: TResult, doNotReplace?: boolean): TResult | undefined; - /*======== Push =========*/ - /** - * @see objectPath.ensureExists - */ - push(path: IPath, ...args:any[]):void; /** * @see objectPath.push */ - push():void; + push(path: Path, ...items: any[]): void; - /*======== Coalesce =========*/ /** - * @see objectPath.ensureExists + * @see objectPath.coalesce */ - coalesce(paths: IMultiArray, defaultValue?: TResult):TResult; + coalesce(paths: Path | Path[], defaultValue: TResult): TResult; + coalesce(paths: Path | Path[], defaultValue?: TResult): TResult | undefined; - /*======== Empty =========*/ - /** - * @see objectPath.ensureExists - */ - empty(path: IPath):T; /** * @see objectPath.empty */ - empty():T; + empty(path: Path): any; - /*======== EnsureExists =========*/ /** * @see objectPath.ensureExists */ - ensureExists(path: IPath, value: any):TExisting; - /** - * @see objectPath.ensureExists - */ - ensureExists(): T; + ensureExists(path: Path, defaultValue: TResult): TResult; + ensureExists(path: Path, defaultValue?: TResult): TResult | undefined; - /*======== Insert =========*/ /** * @see objectPath.insert */ - insert(path: IPath, value: any, at?: number):void; + insert(path: Path, value: any, at?: number): void; } } -// browser version -declare module 'objectPath' { - export = objectPath; -} - -// node version -declare module 'object-path' { - export = objectPath; -} +export = objectPath; diff --git a/types/object-path/object-path-tests.ts b/types/object-path/object-path-tests.ts index 4516b336a8..0515af157a 100644 --- a/types/object-path/object-path-tests.ts +++ b/types/object-path/object-path-tests.ts @@ -1,111 +1,57 @@ +import objectPath = require('object-path'); - -import ObjectPath = require('object-path'); - -var - object = { +const object = { one: 1, two: { - three: 3, - four: ['4'] - } - }, - array: any[] = [], - Null:any = null; + three: 3, + four: ['4'], + }, +}; -var obj = ObjectPath(object); +objectPath.get(object, []); +objectPath.get(object, [1, 2]); +objectPath.get(object, [1, '2']); +objectPath.get(object, 1); +objectPath.get(object, '1'); -obj.del(array); -obj.coalesce([1,2]); -obj.ensureExists('1.2', 1); -obj.push(1, 'value'); -obj.get(array); -obj.set(array, 'value'); -obj.insert(1, 10); +objectPath.del(object, 'a'); // $ExpectType { [key: string]: any; } +objectPath.has(object, 'a'); // $ExpectType boolean +objectPath.get(object, 'a'); // $ExpectType any +objectPath.get(object, 'a', 1); // $ExpectType 1 +objectPath.set(object, 'a', 1); // $ExpectType 1 | undefined +objectPath.set(object, 'a', 1, true); // $ExpectType 1 | undefined +objectPath.push(object, 'a', 1, 2); // $ExpectType void +objectPath.coalesce(object, 'a', 1); // $ExpectType 1 +objectPath.coalesce(object, 'a'); // $ExpectType any +objectPath.coalesce(object, [['a']]); // $ExpectType any +objectPath.coalesce(object, 'a'); // $ExpectType number | undefined +objectPath.empty(object, 'a'); // $ExpectType any +objectPath.ensureExists(object, 'a', 1); // $ExpectType 1 +objectPath.ensureExists(object, 'a'); // $ExpectType any +objectPath.ensureExists(object, 'a'); // $ExpectType number | undefined +objectPath.insert(object, 'a', 1); // $ExpectType void +objectPath.insert(object, 'a', 1, 2); // $ExpectType void -objectPath.del(object, array) === object; -objectPath.del(object, [1,2]) === object; -objectPath.del(object, [1,'2']) === object; -objectPath.del(object, 1) === object; -objectPath.del(object, '1') === object; -objectPath.del(object) === object; -obj.del() === object; +const obj = objectPath(object); -objectPath.has(object, ['1','2','3']) === true; -objectPath.has(object, ['1.2.3']) === false; -objectPath.has(object, [1,2,3]) === true; -objectPath.has(object, [1,'2',3]) === true; -objectPath.has(object, 1) === false; -objectPath.has(object, '1') === false; -objectPath.has() === false; +obj.del('a'); // $ExpectType { [key: string]: any; } +obj.has('a'); // $ExpectType boolean +obj.get('a'); // $ExpectType any +obj.get('a', 1); // $ExpectType 1 +obj.set('a', 1); // $ExpectType 1 | undefined +obj.set('a', 1, true); // $ExpectType 1 | undefined +obj.push('a', 1, 2); // $ExpectType void +obj.coalesce('a', 1); // $ExpectType 1 +obj.coalesce('a'); // $ExpectType any +obj.coalesce([['a']]); // $ExpectType any +obj.coalesce('a'); // $ExpectType number | undefined +obj.empty('a'); // $ExpectType any +obj.ensureExists('a', 1); // $ExpectType 1 +obj.ensureExists('a'); // $ExpectType any +obj.ensureExists('a'); // $ExpectType number | undefined +obj.insert('a', 1); // $ExpectType void +obj.insert('a', 1, 2); // $ExpectType void -objectPath.del() === void 0; -objectPath.del(object, ['1','2','3']); -objectPath.del(object, [1,2,3]); -objectPath.del(object, [1,'2',3]); -objectPath.del(object, 1); -objectPath.del(object, 'one').one === 1; -obj.del('one').one === 1; - -objectPath.coalesce(object, ['1','2']) === void 0; -objectPath.coalesce(object, ['1',['2','1']]) === void 0; -objectPath.coalesce(object, ['1',['2','1']], 1) === 1; -objectPath.coalesce(object, [1,1], 1) === 1; -objectPath.coalesce(object, [1,'1'], 1) === 1; -objectPath.coalesce(object, [1,[1,1],'1',[1,'1']], 1) === 1; -obj.coalesce([1,[1,1],'1',['1',1]], 1) === 1; - -objectPath.ensureExists(object, '1.2', 2); -objectPath.ensureExists(object, 1, 2); -objectPath.ensureExists(object, [1,2], 2); -objectPath.ensureExists(object, ['1','2'], 2); -objectPath.ensureExists(object, ['1',2], 2); -objectPath.ensureExists(object, ['1','2'], 2) === 3; -objectPath.ensureExists(object, ['1','2'], 2) === [[]]; -obj.ensureExists(['1','2'], 2) === [[]]; - -objectPath.push(object, 1, 1,2,3,4); -objectPath.push(object, 1, 1,'2', 3, false); -objectPath.push(object, 'one.four', 1,'2', 3, false); -objectPath.push(object, ['one','two'], [1,'2', 3, false]); -objectPath.push(object, [1, 'two'], [1,'2', 3, false]); -obj.push(['one','two'], [1,'2', 3, false]); -obj.push(['one', 2], [1,'2', 3, false]); - -objectPath.get(array) === array; -objectPath.get(Null) === Null; -objectPath.get() === void 0; -objectPath.get(object, 'one') === 1; -objectPath.get(object, ['two','three']) === 3; -objectPath.get(object, ['three'], 3) === 3; -objectPath.get(object, 'three', 3) === 3; -objectPath.get(object, 0, 3) === 3; -objectPath.get(object, 0, '3') === '3'; -objectPath.get(object, 0, ['1','2']) === ['1','2']; -objectPath.get(object, 0) === 10; -objectPath.get(object, 0) === 10; -obj.get(0, 10) === 10; - -objectPath.set(object, '1.2', true); -objectPath.set(object, ['1','2'], true); -objectPath.set(object, [1, 2], true); -objectPath.set(object, [1, '2'], true); -objectPath.set(object, '1.2', true, true); -objectPath.set(object, '1.2', true, false); -objectPath.set(object, '1.2', true, false) === ['string']; -objectPath.set(object, '1.2', true, false) === object; -obj.set('1.2', true, false) === object; -obj.set(['1','2'], true, false) === object; -obj.set(['1', 2], true, false) === object; - -objectPath.insert(object, '1.2', 1); -objectPath.insert(object, ['1','2'], 1); -objectPath.insert(object, 1, 1); -objectPath.insert(object, [1,2], 1); -objectPath.insert(object, '1.2', 1, 2); -objectPath.insert(object, ['1.2'], 1, 6); -objectPath.insert(object, ['1',2], 1, 6); -obj.insert(['1.2'], 1, 6); -obj.insert(1, 1, 6); -obj.insert(['1',1], 1, 6); -obj.insert('1', 1, 6); \ No newline at end of file +objectPath.withInheritedProps; // $ExpectType ObjectPathStatic +objectPath.create(); // $ExpectType ObjectPathStatic +objectPath.create({ includeInheritedProps: true }); // $ExpectType ObjectPathStatic diff --git a/types/object-path/tsconfig.json b/types/object-path/tsconfig.json index 14192cc5b0..14d40fa370 100644 --- a/types/object-path/tsconfig.json +++ b/types/object-path/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "object-path-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/object-path/tslint.json b/types/object-path/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/object-path/tslint.json +++ b/types/object-path/tslint.json @@ -1,79 +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-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 989941fb547138b43a957d012f404ddfeb143902 Mon Sep 17 00:00:00 2001 From: Gregor Menih Date: Mon, 31 Dec 2018 17:01:57 +0100 Subject: [PATCH 24/69] [chrome] add missing type and event to omnibox (#31778) * feat: add OnInputEnteredDisposition * feat: add onDeleteSuggestion --- types/chrome/index.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 060282a6ab..06daa9b62d 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -4576,7 +4576,10 @@ declare namespace chrome.omnibox { description: string; } - export interface OmniboxInputEnteredEvent extends chrome.events.Event<(text: string) => void> { } + /** The window disposition for the omnibox query. This is the recommended context to display results. */ + export type OnInputEnteredDisposition = 'currentTab' | 'newForegroundTab' | 'newBackgroundTab'; + + export interface OmniboxInputEnteredEvent extends chrome.events.Event<(text: string, disposition: OnInputEnteredDisposition) => void> { } export interface OmniboxInputChangedEvent extends chrome.events.Event<(text: string, suggest: (suggestResults: SuggestResult[]) => void) => void> { } @@ -4584,6 +4587,8 @@ declare namespace chrome.omnibox { export interface OmniboxInputCancelledEvent extends chrome.events.Event<() => void> { } + export interface OmniboxSuggestionDeletedEvent extends chrome.events.Event<(text: string) => void> { } + /** * Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar. * @param suggestion A partial SuggestResult object, without the 'content' parameter. @@ -4598,6 +4603,11 @@ declare namespace chrome.omnibox { export var onInputStarted: OmniboxInputStartedEvent; /** User has ended the keyword input session without accepting the input. */ export var onInputCancelled: OmniboxInputCancelledEvent; + /** + * User has deleted a suggested result + * @since Chrome 63. + */ + export var onDeleteSuggestion: OmniboxSuggestionDeletedEvent; } //////////////////// From a4f67d33f80f51d0049ce60a4fb63036bdd5c40e Mon Sep 17 00:00:00 2001 From: John Pinkster Date: Mon, 31 Dec 2018 11:02:17 -0500 Subject: [PATCH 25/69] [download]: Updating the options typing. Allowing headers (#31776) * Update index.d.ts You can also add in the request headers into the options that will be passed through... you can see that indicated in this closed issue by the author: https://github.com/kevva/download/issues/155 * Setting headers to an object type --- types/download/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/download/index.d.ts b/types/download/index.d.ts index 5d19321fb0..3dd8e4dea8 100644 --- a/types/download/index.d.ts +++ b/types/download/index.d.ts @@ -24,6 +24,12 @@ declare namespace download { * Proxy endpoint */ proxy?: string; + /** + * Request Headers + */ + headers?: { + [name: string]: string; + }; } } From 9ac607c9d8799be1735b9c3a3cc77e3cf383e873 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:02:39 +0000 Subject: [PATCH 26/69] [url-join] Update types to v4.0 (#31768) * [url-join] Move v0 types to sub-dir * [url-join] Update types to v4.0 --- types/url-join/index.d.ts | 18 ++++--- types/url-join/tsconfig.json | 4 +- types/url-join/tslint.json | 78 +---------------------------- types/url-join/url-join-tests.ts | 7 ++- types/url-join/v0/index.d.ts | 13 +++++ types/url-join/v0/tsconfig.json | 28 +++++++++++ types/url-join/v0/tslint.json | 3 ++ types/url-join/v0/url-join-tests.ts | 5 ++ 8 files changed, 65 insertions(+), 91 deletions(-) create mode 100644 types/url-join/v0/index.d.ts create mode 100644 types/url-join/v0/tsconfig.json create mode 100644 types/url-join/v0/tslint.json create mode 100644 types/url-join/v0/url-join-tests.ts diff --git a/types/url-join/index.d.ts b/types/url-join/index.d.ts index 3dc87d456f..c2e1e18a87 100644 --- a/types/url-join/index.d.ts +++ b/types/url-join/index.d.ts @@ -1,15 +1,17 @@ -// Type definitions for url-join v0.8.3 +// Type definitions for url-join 4.0 // Project: https://github.com/jfromaniello/url-join -// Definitions by: Rogier Schouten , Mike Deverell +// Definitions by: Rogier Schouten +// Mike Deverell +// BendingBender // Definitions: https://github.com/borisyankov/DefinitelyTyped /** * Join all arguments together and normalize the resulting url. - * This works similar to path.join but you shouldn't use path.join for urls since it will work different depending of the operative systems but also doesn't work for some cases. + * This works similar to `path.join` but you shouldn't use `path.join` for urls since it works + * differently depending on the operating system and also doesn't work for some cases. */ +declare function urljoin(...parts: string[]): string; +declare function urljoin(parts: string[]): string; -declare var urljoin: (...parts: string[]) => string; - -declare module "url-join" { - export = urljoin; -} +export = urljoin; +export as namespace urljoin; diff --git a/types/url-join/tsconfig.json b/types/url-join/tsconfig.json index fdbf7a8a9c..2ac914d2b6 100644 --- a/types/url-join/tsconfig.json +++ b/types/url-join/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "url-join-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/url-join/tslint.json b/types/url-join/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/url-join/tslint.json +++ b/types/url-join/tslint.json @@ -1,79 +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-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" } diff --git a/types/url-join/url-join-tests.ts b/types/url-join/url-join-tests.ts index 5a4afd6b80..dc42570e3a 100644 --- a/types/url-join/url-join-tests.ts +++ b/types/url-join/url-join-tests.ts @@ -1,5 +1,4 @@ -import urljoin = require("url-join"); -import urljoin2 = require("url-join"); +import urljoin = require('url-join'); -const s: string = urljoin("foo", "bar", "baz"); -const s2: string = urljoin2("foo", "bar", "baz"); +urljoin('http://www.google.com', 'a', '/b/cd', '?foo=123'); // $ExpectType string +urljoin(['http://www.google.com', 'a', '/b/cd', '?foo=123']); // $ExpectType string diff --git a/types/url-join/v0/index.d.ts b/types/url-join/v0/index.d.ts new file mode 100644 index 0000000000..a1534917d9 --- /dev/null +++ b/types/url-join/v0/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for url-join 0.8 +// Project: https://github.com/jfromaniello/url-join +// Definitions by: Rogier Schouten , Mike Deverell +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Join all arguments together and normalize the resulting url. + * This works similar to path.join but you shouldn't use path.join for urls since it will work different depending of the operative systems but also doesn't work for some cases. + */ + +declare function urljoin(...parts: string[]): string; + +export = urljoin; diff --git a/types/url-join/v0/tsconfig.json b/types/url-join/v0/tsconfig.json new file mode 100644 index 0000000000..c323d937f1 --- /dev/null +++ b/types/url-join/v0/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "url-join": [ + "url-join/v0" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "url-join-tests.ts" + ] +} diff --git a/types/url-join/v0/tslint.json b/types/url-join/v0/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/url-join/v0/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/url-join/v0/url-join-tests.ts b/types/url-join/v0/url-join-tests.ts new file mode 100644 index 0000000000..5a4afd6b80 --- /dev/null +++ b/types/url-join/v0/url-join-tests.ts @@ -0,0 +1,5 @@ +import urljoin = require("url-join"); +import urljoin2 = require("url-join"); + +const s: string = urljoin("foo", "bar", "baz"); +const s2: string = urljoin2("foo", "bar", "baz"); From b30173fbc51f86283d71ff45a6400229543b0274 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:03:34 +0000 Subject: [PATCH 27/69] [ansi-colors] Update types to v3.2 (#31763) * [ansi-colors] Move v1 types to sub-dir * [ansi-colors] Update types to v3.2 --- types/ansi-colors/ansi-colors-tests.ts | 61 +++++----- types/ansi-colors/index.d.ts | 134 +++++++++++++++++----- types/ansi-colors/tsconfig.json | 2 +- types/ansi-colors/v1/ansi-colors-tests.ts | 30 +++++ types/ansi-colors/v1/index.d.ts | 31 +++++ types/ansi-colors/v1/tsconfig.json | 28 +++++ types/ansi-colors/v1/tslint.json | 1 + 7 files changed, 231 insertions(+), 56 deletions(-) create mode 100644 types/ansi-colors/v1/ansi-colors-tests.ts create mode 100644 types/ansi-colors/v1/index.d.ts create mode 100644 types/ansi-colors/v1/tsconfig.json create mode 100644 types/ansi-colors/v1/tslint.json diff --git a/types/ansi-colors/ansi-colors-tests.ts b/types/ansi-colors/ansi-colors-tests.ts index 9a9afc43f4..c267e879eb 100644 --- a/types/ansi-colors/ansi-colors-tests.ts +++ b/types/ansi-colors/ansi-colors-tests.ts @@ -1,30 +1,35 @@ -import * as colors from 'ansi-colors'; +import colors = require('ansi-colors'); -let s: string; +colors.red('This is a red string!'); // $ExpectType string +colors.green('This is a red string!'); // $ExpectType string +colors.cyan('This is a cyan string!'); // $ExpectType string +colors.yellow('This is a yellow string!'); // $ExpectType string -s = colors.bgblack("hello"); -s = colors.bgblue("hello"); -s = colors.bgcyan("hello"); -s = colors.bggreen("hello"); -s = colors.bgmagenta("hello"); -s = colors.bgred("hello"); -s = colors.bgwhite("hello"); -s = colors.bgyellow("hello"); -s = colors.black("hello"); -s = colors.blue("hello"); -s = colors.bold("hello"); -s = colors.cyan("hello"); -s = colors.dim("hello"); -s = colors.gray("hello"); -s = colors.green("hello"); -s = colors.grey("hello"); -s = colors.hidden("hello"); -s = colors.inverse("hello"); -s = colors.italic("hello"); -s = colors.magenta("hello"); -s = colors.red("hello"); -s = colors.reset("hello"); -s = colors.strikethrough("hello"); -s = colors.underline("hello"); -s = colors.white("hello"); -s = colors.yellow("hello"); +colors.bold.red('this is a bold red message'); // $ExpectType string +colors.bold.yellow.italic('this is a bold yellow italicized message'); // $ExpectType string +colors.green.bold.underline('this is a bold green underlined message'); // $ExpectType string + +colors.yellow(`foo ${colors.red.bold('red')} bar ${colors.cyan('cyan')} baz`); // $ExpectType string +colors.bold(`foo ${colors.red.dim('bar')} baz`); // $ExpectType string + +colors.enabled = false; +colors.visible = false; + +colors.hasAnsi(colors.blue('foo')); // $ExpectType boolean +colors.hasColor(colors.blue('foo')); // $ExpectType boolean + +colors.unstyle(colors.blue.bold('foo bar baz')); // $ExpectType string +colors.stripColor(colors.blue.bold('foo bar baz')); // $ExpectType string + +colors.none('foo'); // $ExpectType string +colors.clear('foo'); // $ExpectType string +colors.noop('foo'); // $ExpectType string + +colors.define('reset', [0, 0], 'modifier'); + +colors.symbols.ballotCross; // $ExpectType string | undefined +colors.symbols.windows.ballotCross; // $ExpectError +colors.symbols.other.ballotCross; // $ExpectType string +colors.symbols.cross; // $ExpectType string +colors.symbols.windows.cross; // $ExpectType string +colors.symbols.other.cross; // $ExpectType string diff --git a/types/ansi-colors/index.d.ts b/types/ansi-colors/index.d.ts index 092c4c1f2b..0cf9cd0d9f 100644 --- a/types/ansi-colors/index.d.ts +++ b/types/ansi-colors/index.d.ts @@ -1,31 +1,111 @@ -// Type definitions for ansi-colors 1.0 +// Type definitions for ansi-colors 3.2 // Project: https://github.com/doowb/ansi-colors // Definitions by: Rogier Schouten +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -export function bgblack(s: string): string; -export function bgblue(s: string): string; -export function bgcyan(s: string): string; -export function bggreen(s: string): string; -export function bgmagenta(s: string): string; -export function bgred(s: string): string; -export function bgwhite(s: string): string; -export function bgyellow(s: string): string; -export function black(s: string): string; -export function blue(s: string): string; -export function bold(s: string): string; -export function cyan(s: string): string; -export function dim(s: string): string; -export function gray(s: string): string; -export function green(s: string): string; -export function grey(s: string): string; -export function hidden(s: string): string; -export function inverse(s: string): string; -export function italic(s: string): string; -export function magenta(s: string): string; -export function red(s: string): string; -export function reset(s: string): string; -export function strikethrough(s: string): string; -export function underline(s: string): string; -export function white(s: string): string; -export function yellow(s: string): string; +export = colors; + +declare const colors: colors.Colors; + +declare namespace colors { + type ColorFn = ((text: string) => string) & Colors; + + interface Colors { + enabled: boolean; + visible: boolean; + + reset: ColorFn; + bold: ColorFn; + dim: ColorFn; + italic: ColorFn; + underline: ColorFn; + inverse: ColorFn; + hidden: ColorFn; + strikethrough: ColorFn; + + black: ColorFn; + red: ColorFn; + green: ColorFn; + yellow: ColorFn; + blue: ColorFn; + magenta: ColorFn; + cyan: ColorFn; + white: ColorFn; + gray: ColorFn; + grey: ColorFn; + + bgBlack: ColorFn; + bgRed: ColorFn; + bgGreen: ColorFn; + bgYellow: ColorFn; + bgBlue: ColorFn; + bgMagenta: ColorFn; + bgCyan: ColorFn; + bgWhite: ColorFn; + + blackBright: ColorFn; + redBright: ColorFn; + greenBright: ColorFn; + yellowBright: ColorFn; + blueBright: ColorFn; + magentaBright: ColorFn; + cyanBright: ColorFn; + whiteBright: ColorFn; + + bgBlackBright: ColorFn; + bgRedBright: ColorFn; + bgGreenBright: ColorFn; + bgYellowBright: ColorFn; + bgBlueBright: ColorFn; + bgMagentaBright: ColorFn; + bgCyanBright: ColorFn; + bgWhiteBright: ColorFn; + + hasColor(text: string): boolean; + hasAnsi(text: string): boolean; + unstyle(text: string): string; + stripColor(text: string): string; + none(text: string): string; + clear(text: string): string; + noop(text: string): string; + + symbols: Symbols & { + windows: WindowsSymbols; + other: OtherPlatformsSymbols; + }; + + define( + name: string, + codes: [number, number], + type: 'modifier' | 'color' | 'bg' | 'bright' | 'bgBright' + ): void; + } + + interface WindowsSymbols { + bullet: string; + check: string; + cross: string; + ellipsis: string; + heart: string; + info: string; + line: string; + middot: string; + minus: string; + plus: string; + question: string; + questionSmall: string; + pointer: string; + pointerSmall: string; + warning: string; + } + + interface ExtendedSymbols { + ballotCross: string; + questionFull: string; + } + + type Symbols = WindowsSymbols & Partial; + type OtherPlatformsSymbols = WindowsSymbols & ExtendedSymbols; +} diff --git a/types/ansi-colors/tsconfig.json b/types/ansi-colors/tsconfig.json index ebd56021f9..8a0f980cbc 100644 --- a/types/ansi-colors/tsconfig.json +++ b/types/ansi-colors/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "ansi-colors-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/ansi-colors/v1/ansi-colors-tests.ts b/types/ansi-colors/v1/ansi-colors-tests.ts new file mode 100644 index 0000000000..9a9afc43f4 --- /dev/null +++ b/types/ansi-colors/v1/ansi-colors-tests.ts @@ -0,0 +1,30 @@ +import * as colors from 'ansi-colors'; + +let s: string; + +s = colors.bgblack("hello"); +s = colors.bgblue("hello"); +s = colors.bgcyan("hello"); +s = colors.bggreen("hello"); +s = colors.bgmagenta("hello"); +s = colors.bgred("hello"); +s = colors.bgwhite("hello"); +s = colors.bgyellow("hello"); +s = colors.black("hello"); +s = colors.blue("hello"); +s = colors.bold("hello"); +s = colors.cyan("hello"); +s = colors.dim("hello"); +s = colors.gray("hello"); +s = colors.green("hello"); +s = colors.grey("hello"); +s = colors.hidden("hello"); +s = colors.inverse("hello"); +s = colors.italic("hello"); +s = colors.magenta("hello"); +s = colors.red("hello"); +s = colors.reset("hello"); +s = colors.strikethrough("hello"); +s = colors.underline("hello"); +s = colors.white("hello"); +s = colors.yellow("hello"); diff --git a/types/ansi-colors/v1/index.d.ts b/types/ansi-colors/v1/index.d.ts new file mode 100644 index 0000000000..092c4c1f2b --- /dev/null +++ b/types/ansi-colors/v1/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for ansi-colors 1.0 +// Project: https://github.com/doowb/ansi-colors +// Definitions by: Rogier Schouten +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function bgblack(s: string): string; +export function bgblue(s: string): string; +export function bgcyan(s: string): string; +export function bggreen(s: string): string; +export function bgmagenta(s: string): string; +export function bgred(s: string): string; +export function bgwhite(s: string): string; +export function bgyellow(s: string): string; +export function black(s: string): string; +export function blue(s: string): string; +export function bold(s: string): string; +export function cyan(s: string): string; +export function dim(s: string): string; +export function gray(s: string): string; +export function green(s: string): string; +export function grey(s: string): string; +export function hidden(s: string): string; +export function inverse(s: string): string; +export function italic(s: string): string; +export function magenta(s: string): string; +export function red(s: string): string; +export function reset(s: string): string; +export function strikethrough(s: string): string; +export function underline(s: string): string; +export function white(s: string): string; +export function yellow(s: string): string; diff --git a/types/ansi-colors/v1/tsconfig.json b/types/ansi-colors/v1/tsconfig.json new file mode 100644 index 0000000000..8321162c90 --- /dev/null +++ b/types/ansi-colors/v1/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "ansi-colors": [ + "ansi-colors/v1" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ansi-colors-tests.ts" + ] +} diff --git a/types/ansi-colors/v1/tslint.json b/types/ansi-colors/v1/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ansi-colors/v1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 44b33a09c5dc9225870feca7aeaf953ab6479166 Mon Sep 17 00:00:00 2001 From: "J. K. Ward" Date: Mon, 31 Dec 2018 10:03:53 -0600 Subject: [PATCH 28/69] Location.geocodeAsync should return an array (#31781) According to the docs, this method returns an array of Coords: https://docs.expo.io/versions/v31.0.0/sdk/location. --- types/expo/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 602b9a3463..2cb20ae065 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -2126,7 +2126,7 @@ export namespace Location { function getProviderStatusAsync(): Promise; function getHeadingAsync(): Promise; function watchHeadingAsync(callback: (status: HeadingStatus) => void): EventSubscription; - function geocodeAsync(address: string): Promise; + function geocodeAsync(address: string): Promise; function reverseGeocodeAsync(location: LocationProps): Promise; function setApiKey(key: string): void; } From a3b7804c745c1fee7dc2d47a793b508d724d4bb9 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:04:17 +0000 Subject: [PATCH 29/69] [git-branch] Improve types (#31676) --- types/git-branch/git-branch-tests.ts | 16 ++++++++++------ types/git-branch/index.d.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/types/git-branch/git-branch-tests.ts b/types/git-branch/git-branch-tests.ts index 4b02cb5da3..79676c58ff 100644 --- a/types/git-branch/git-branch-tests.ts +++ b/types/git-branch/git-branch-tests.ts @@ -1,14 +1,18 @@ import gitBranch = require('git-branch'); gitBranch() - .then((name) => {}); + .then((name) => { + name; // $ExpectType string + }); gitBranch('cwd') - .then((name) => {}); + .then((name) => { + name; // $ExpectType string + }); -gitBranch.sync(); -gitBranch.sync('cwd'); +gitBranch.sync(); // $ExpectType string +gitBranch.sync('cwd'); // $ExpectType string -gitBranch((err, name) => {}); +gitBranch((err, name) => {}); // $ExpectType void -gitBranch('cwd', (err, name) => {}); +gitBranch('cwd', (err, name) => {}); // $ExpectType void diff --git a/types/git-branch/index.d.ts b/types/git-branch/index.d.ts index a1cecc9691..9f893ca5cd 100644 --- a/types/git-branch/index.d.ts +++ b/types/git-branch/index.d.ts @@ -8,7 +8,7 @@ export = GitBranch; declare function GitBranch(cwd?: string): Promise; declare function GitBranch(cwd?: string, callback?: (err: null | string, name: string) => void): void; -declare function GitBranch(callback?: (err: null | string, name: string) => void): void; +declare function GitBranch(callback: (err: null | string, name: string) => void): void; declare namespace GitBranch { function sync(cwd?: string): string; From 3c1b6270d0a2bc087d8d28b48af1aa68a8db8001 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 31 Dec 2018 17:05:55 +0100 Subject: [PATCH 30/69] fix: murmurhash3js.hash32 returns a number (#31761) --- types/murmurhash3js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/murmurhash3js/index.d.ts b/types/murmurhash3js/index.d.ts index 2193085d5b..0bddd535de 100644 --- a/types/murmurhash3js/index.d.ts +++ b/types/murmurhash3js/index.d.ts @@ -5,7 +5,7 @@ declare module 'murmurhash3js' { export module x86 { - function hash32(val: string, seed?: number): string; + function hash32(val: string, seed?: number): number; function hash128(val: string, seed?: number): string; } From 34b16389363fc0a2dac9a2e0d7f97c6a248cbe75 Mon Sep 17 00:00:00 2001 From: steffenvv Date: Mon, 31 Dec 2018 17:09:01 +0100 Subject: [PATCH 31/69] Fix for issue #31785, correct typing of return value when passing an argument list to yargs(). (#31791) --- types/yargs/index.d.ts | 6 +++--- types/yargs/yargs-tests.ts | 27 ++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/types/yargs/index.d.ts b/types/yargs/index.d.ts index 9ec5b0a4d5..005c05e436 100644 --- a/types/yargs/index.d.ts +++ b/types/yargs/index.d.ts @@ -33,7 +33,7 @@ declare namespace yargs { // Arguments to simplify the inferred type signature in client code. interface Argv { (): { [key in keyof Arguments]: Arguments[key] }; - (args: ReadonlyArray, cwd?: string): { [key in keyof Arguments]: Arguments[key] }; + (args: ReadonlyArray, cwd?: string): Argv; // Aliases for previously declared options can inherit the types of those options. alias(shortName: K1, longName: K2 | ReadonlyArray): Argv; @@ -167,8 +167,8 @@ declare namespace yargs { options(key: K, options: O): Argv }>; options(options: O): Argv & InferredOptionTypes>; - parse(): Arguments; - parse(arg: string | ReadonlyArray, context?: object, parseCallback?: ParseCallback): Arguments; + parse(): { [key in keyof Arguments]: Arguments[key] }; + parse(arg: string | ReadonlyArray, context?: object, parseCallback?: ParseCallback): { [key in keyof Arguments]: Arguments[key] }; pkgConf(key: string | ReadonlyArray, cwd?: string): Argv; diff --git a/types/yargs/yargs-tests.ts b/types/yargs/yargs-tests.ts index a76015dcfc..298ee9c9ef 100644 --- a/types/yargs/yargs-tests.ts +++ b/types/yargs/yargs-tests.ts @@ -73,6 +73,7 @@ function default_singles() { ; console.log(argv.x + argv.y); } + function default_hash() { const argv = yargs .default({ x: 10, y: 10 }) @@ -90,6 +91,7 @@ function boolean_single() { console.dir(argv.v); console.dir(argv._); } + function boolean_double() { const argv = yargs .boolean(['x', 'y', 'z']) @@ -120,11 +122,30 @@ function Argv$argv() { console.log("command: " + argv._[1]); } -function Argv_parsing() { +function Argv$parsing() { const argv1 = yargs.parse(); - const argv2 = yargs(['-x', '1', '-y', '2']); + const argv2 = yargs(['-x', '1', '-y', '2']).argv; const argv3 = yargs.parse(['-x', '1', '-y', '2']); - console.log(argv1.x, argv2.x, argv3.x); + const argv4 = yargs(); + console.log(argv1.x, argv2.x, argv3.x, argv4.x); + + // $ExpectType { [x: string]: unknown; _: string[]; $0: string; } + yargs.parse(); + + // $ExpectType { [x: string]: unknown; _: string[]; $0: string; } + yargs([]).argv; + + // $ExpectType { [x: string]: unknown; _: string[]; $0: string; } + yargs.argv; + + // $ExpectType { [x: string]: unknown; _: string[]; $0: string; } + yargs(); + + // $ExpectType { [x: string]: unknown; update: boolean | undefined; extern: boolean | undefined; _: string[]; $0: string; } + yargs(['--update']) + .boolean('update') + .boolean('extern') + .argv; } function Argv$options() { From ee8ee5429585c9b52afc76aa578c3dd30438a4d0 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:11:17 +0000 Subject: [PATCH 32/69] [find-cache-dir] Add types (#31800) --- types/find-cache-dir/find-cache-dir-tests.ts | 19 +++++++ types/find-cache-dir/index.d.ts | 57 ++++++++++++++++++++ types/find-cache-dir/tsconfig.json | 23 ++++++++ types/find-cache-dir/tslint.json | 1 + 4 files changed, 100 insertions(+) create mode 100644 types/find-cache-dir/find-cache-dir-tests.ts create mode 100644 types/find-cache-dir/index.d.ts create mode 100644 types/find-cache-dir/tsconfig.json create mode 100644 types/find-cache-dir/tslint.json diff --git a/types/find-cache-dir/find-cache-dir-tests.ts b/types/find-cache-dir/find-cache-dir-tests.ts new file mode 100644 index 0000000000..5836be99b6 --- /dev/null +++ b/types/find-cache-dir/find-cache-dir-tests.ts @@ -0,0 +1,19 @@ +import findCacheDir = require('find-cache-dir'); + +findCacheDir({ name: 'unicorns' }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', files: 'foo' }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', files: ['foo', 'bar'] }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', cwd: 'foo' }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', create: true }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', thunk: false }); // $ExpectType string | null +findCacheDir({}); // $ExpectError +findCacheDir(); // $ExpectError + +const thunk = findCacheDir({ name: 'unicorns', thunk: true }); +thunk; // $ExpectType ((...pathParts: string[]) => string) | null + +if (thunk) { + thunk(); // $ExpectType string + thunk('bar.js'); // $ExpectType string + thunk('baz', 'quz.js'); // $ExpectType string +} diff --git a/types/find-cache-dir/index.d.ts b/types/find-cache-dir/index.d.ts new file mode 100644 index 0000000000..4b69518e21 --- /dev/null +++ b/types/find-cache-dir/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for find-cache-dir 2.0 +// Project: https://github.com/avajs/find-cache-dir#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = findCacheDir; + +/** + * Finds the cache directory using the supplied options. The algorithm tries to find a `package.json` file, + * searching every parent directory of the `cwd` specified (or implied from other options). + * @param options + * @returns A string containing the absolute path to the cache directory, or null if package.json was never found. + */ +declare function findCacheDir( + options: findCacheDir.OptionsWithThunk +): ((...pathParts: string[]) => string) | null; +declare function findCacheDir(options: findCacheDir.Options): string | null; + +declare namespace findCacheDir { + interface Options { + /** + * Should be the same as your project name in `package.json`. + */ + name: string; + + /** + * An array of files that will be searched for a common parent directory. + * This common parent directory will be used in lieu of the `cwd` option below. + */ + files?: string | string[]; + + /** + * Directory to start searching for a `package.json` from. + */ + cwd?: string; + + /** + * If `true`, the directory will be created synchronously before returning. + * @default false + */ + create?: boolean; + + /** + * If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`. + * @default false + */ + thunk?: boolean; + } + + interface OptionsWithThunk extends Options { + /** + * If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`. + * @default false + */ + thunk: true; + } +} diff --git a/types/find-cache-dir/tsconfig.json b/types/find-cache-dir/tsconfig.json new file mode 100644 index 0000000000..68068b9343 --- /dev/null +++ b/types/find-cache-dir/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", + "find-cache-dir-tests.ts" + ] +} diff --git a/types/find-cache-dir/tslint.json b/types/find-cache-dir/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/find-cache-dir/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 76165283b4530ae8cb0f36ad55e69685f0c0f9c3 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:11:35 +0000 Subject: [PATCH 33/69] arr-diff] Add types (#31795) --- types/arr-diff/arr-diff-tests.ts | 8 ++++++++ types/arr-diff/index.d.ts | 8 ++++++++ types/arr-diff/tsconfig.json | 23 +++++++++++++++++++++++ types/arr-diff/tslint.json | 1 + 4 files changed, 40 insertions(+) create mode 100644 types/arr-diff/arr-diff-tests.ts create mode 100644 types/arr-diff/index.d.ts create mode 100644 types/arr-diff/tsconfig.json create mode 100644 types/arr-diff/tslint.json diff --git a/types/arr-diff/arr-diff-tests.ts b/types/arr-diff/arr-diff-tests.ts new file mode 100644 index 0000000000..509b2f43cc --- /dev/null +++ b/types/arr-diff/arr-diff-tests.ts @@ -0,0 +1,8 @@ +import diff = require('arr-diff'); + +const a = ['a', 'b', 'c', 'd']; +const b = [1, 2]; + +diff(['a']); // $ExpectType string[] +diff(['a'], [1]); // $ExpectType string[] +diff([1], ['a']); // $ExpectType number[] diff --git a/types/arr-diff/index.d.ts b/types/arr-diff/index.d.ts new file mode 100644 index 0000000000..3c9c5037cc --- /dev/null +++ b/types/arr-diff/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for arr-diff 4.0 +// Project: https://github.com/jonschlinkert/arr-diff +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = arrDiff; + +declare function arrDiff(first: T[], ...args: any[][]): T[]; diff --git a/types/arr-diff/tsconfig.json b/types/arr-diff/tsconfig.json new file mode 100644 index 0000000000..6ea302e0ba --- /dev/null +++ b/types/arr-diff/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", + "arr-diff-tests.ts" + ] +} diff --git a/types/arr-diff/tslint.json b/types/arr-diff/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/arr-diff/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 6e2307423f0aaa2329046b11c49b0d9071b06100 Mon Sep 17 00:00:00 2001 From: Justin Hall Date: Mon, 31 Dec 2018 09:13:16 -0700 Subject: [PATCH 34/69] [cypress-axe] Add types (#31793) --- types/cypress-axe/cypress-axe-tests.ts | 1 + types/cypress-axe/index.d.ts | 12 ++++++++++++ types/cypress-axe/tsconfig.json | 23 +++++++++++++++++++++++ types/cypress-axe/tslint.json | 1 + 4 files changed, 37 insertions(+) create mode 100644 types/cypress-axe/cypress-axe-tests.ts create mode 100644 types/cypress-axe/index.d.ts create mode 100644 types/cypress-axe/tsconfig.json create mode 100644 types/cypress-axe/tslint.json diff --git a/types/cypress-axe/cypress-axe-tests.ts b/types/cypress-axe/cypress-axe-tests.ts new file mode 100644 index 0000000000..46bfe99c37 --- /dev/null +++ b/types/cypress-axe/cypress-axe-tests.ts @@ -0,0 +1 @@ +import 'cypress-axe'; diff --git a/types/cypress-axe/index.d.ts b/types/cypress-axe/index.d.ts new file mode 100644 index 0000000000..507a5f773d --- /dev/null +++ b/types/cypress-axe/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for cypress-axe 0.3 +// Project: https://github.com/avanslaars/cypress-axe#readme +// Definitions by: Justin Hall +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +declare namespace Cypress { + interface Chainable { + injectAxe(): void; + checkA11y(): void; + } +} diff --git a/types/cypress-axe/tsconfig.json b/types/cypress-axe/tsconfig.json new file mode 100644 index 0000000000..e71d30fe7d --- /dev/null +++ b/types/cypress-axe/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", + "cypress-axe-tests.ts" + ] +} diff --git a/types/cypress-axe/tslint.json b/types/cypress-axe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cypress-axe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 6fe3320103b0432c4919c11d4613d16248801f97 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:14:41 +0000 Subject: [PATCH 35/69] [shebang-regex] Add types (#31789) --- types/shebang-regex/index.d.ts | 8 ++++++++ types/shebang-regex/shebang-regex-tests.ts | 5 +++++ types/shebang-regex/tsconfig.json | 23 ++++++++++++++++++++++ types/shebang-regex/tslint.json | 1 + 4 files changed, 37 insertions(+) create mode 100644 types/shebang-regex/index.d.ts create mode 100644 types/shebang-regex/shebang-regex-tests.ts create mode 100644 types/shebang-regex/tsconfig.json create mode 100644 types/shebang-regex/tslint.json diff --git a/types/shebang-regex/index.d.ts b/types/shebang-regex/index.d.ts new file mode 100644 index 0000000000..2bba6ec84d --- /dev/null +++ b/types/shebang-regex/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for shebang-regex 2.0 +// Project: https://github.com/sindresorhus/shebang-regex +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = shebangRegex; + +declare const shebangRegex: RegExp; diff --git a/types/shebang-regex/shebang-regex-tests.ts b/types/shebang-regex/shebang-regex-tests.ts new file mode 100644 index 0000000000..eec7893e93 --- /dev/null +++ b/types/shebang-regex/shebang-regex-tests.ts @@ -0,0 +1,5 @@ +import shebangRegex = require('shebang-regex'); + +const str = '#!/usr/bin/env node\nconsole.log("unicorns");'; + +shebangRegex.test(str); diff --git a/types/shebang-regex/tsconfig.json b/types/shebang-regex/tsconfig.json new file mode 100644 index 0000000000..0842063948 --- /dev/null +++ b/types/shebang-regex/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", + "shebang-regex-tests.ts" + ] +} diff --git a/types/shebang-regex/tslint.json b/types/shebang-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shebang-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From fb072edb3b9e9e60f7e3ef5e527313ab387c6f24 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:18:16 +0000 Subject: [PATCH 36/69] [shebang-command] Add types (#31779) --- types/shebang-command/index.d.ts | 8 +++++++ .../shebang-command/shebang-command-tests.ts | 3 +++ types/shebang-command/tsconfig.json | 23 +++++++++++++++++++ types/shebang-command/tslint.json | 1 + 4 files changed, 35 insertions(+) create mode 100644 types/shebang-command/index.d.ts create mode 100644 types/shebang-command/shebang-command-tests.ts create mode 100644 types/shebang-command/tsconfig.json create mode 100644 types/shebang-command/tslint.json diff --git a/types/shebang-command/index.d.ts b/types/shebang-command/index.d.ts new file mode 100644 index 0000000000..3dfe023617 --- /dev/null +++ b/types/shebang-command/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for shebang-command 1.2 +// Project: https://github.com/kevva/shebang-command#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = shebangCommand; + +declare function shebangCommand(str: string): string | null; diff --git a/types/shebang-command/shebang-command-tests.ts b/types/shebang-command/shebang-command-tests.ts new file mode 100644 index 0000000000..0cdf85b022 --- /dev/null +++ b/types/shebang-command/shebang-command-tests.ts @@ -0,0 +1,3 @@ +import shebangCommand = require('shebang-command'); + +shebangCommand('#!/usr/bin/env node'); // $ExpectType string | null diff --git a/types/shebang-command/tsconfig.json b/types/shebang-command/tsconfig.json new file mode 100644 index 0000000000..9ae22f761b --- /dev/null +++ b/types/shebang-command/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", + "shebang-command-tests.ts" + ] +} diff --git a/types/shebang-command/tslint.json b/types/shebang-command/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shebang-command/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 236449ab1d87207e74c2bb0ca1a5790aab6cc207 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:18:36 +0000 Subject: [PATCH 37/69] [memory-pager] Add types (#31780) --- types/memory-pager/index.d.ts | 60 ++++++++++++++++++++++++ types/memory-pager/memory-pager-tests.ts | 17 +++++++ types/memory-pager/tsconfig.json | 23 +++++++++ types/memory-pager/tslint.json | 1 + 4 files changed, 101 insertions(+) create mode 100644 types/memory-pager/index.d.ts create mode 100644 types/memory-pager/memory-pager-tests.ts create mode 100644 types/memory-pager/tsconfig.json create mode 100644 types/memory-pager/tslint.json diff --git a/types/memory-pager/index.d.ts b/types/memory-pager/index.d.ts new file mode 100644 index 0000000000..7df3c3cf7b --- /dev/null +++ b/types/memory-pager/index.d.ts @@ -0,0 +1,60 @@ +// Type definitions for memory-pager 1.4 +// Project: https://github.com/mafintosh/memory-pager +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = Pager; + +declare const Pager: Pager; + +interface Pager { + /** + * Create a new pager. + * @param pageSize defaults to 1024. + */ + (pageSize?: number): Pager.PagerInstance; + /** + * Create a new pager. + * @param pageSize defaults to 1024. + */ + new (pageSize?: number): Pager.PagerInstance; +} + +declare namespace Pager { + interface PagerInstance { + /** + * Get a page. The page will be allocated at first access. + * @param pageNumber + * @param noAllocate will make the method return `undefined` if no page has been allocated already + */ + get(pageNumber: number, noAllocate?: false): Page; + get(pageNumber: number, noAllocate: true): Page | undefined; + + /** + * Explicitly set the buffer for a page. + */ + set(pageNumber: number, buffer: Buffer): void; + + /** + * Mark a page as updated. + */ + updated(page: Page): void; + + /** + * Get the last page that was updated. + */ + lastUpdate(): Page | null; + + /** + * Concat all pages allocated pages into a single buffer. + */ + toBuffer(): Buffer; + } + + interface Page { + offset: number; + buffer: Buffer; + } +} diff --git a/types/memory-pager/memory-pager-tests.ts b/types/memory-pager/memory-pager-tests.ts new file mode 100644 index 0000000000..fb327097d0 --- /dev/null +++ b/types/memory-pager/memory-pager-tests.ts @@ -0,0 +1,17 @@ +import Pager = require('memory-pager'); + +const pages = new Pager(1024); +new Pager(); +Pager(1024); +Pager(); + +const page = pages.get(10); +page; // $ExpectType Page +page.offset; // $ExpectType number +page.buffer; // $ExpectType Buffer +pages.get(10, false); // $ExpectType Page +pages.get(10, true); // $ExpectType Page | undefined +pages.set(10, new Buffer(10)); +pages.updated(page); +pages.lastUpdate(); // $ExpectType Page | null +pages.toBuffer(); // $ExpectType Buffer diff --git a/types/memory-pager/tsconfig.json b/types/memory-pager/tsconfig.json new file mode 100644 index 0000000000..c8923c0d5e --- /dev/null +++ b/types/memory-pager/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", + "memory-pager-tests.ts" + ] +} diff --git a/types/memory-pager/tslint.json b/types/memory-pager/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/memory-pager/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e713f37fd4fa1c02fd3ec2f349d11b07feff7da8 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:18:54 +0000 Subject: [PATCH 38/69] [get-func-name] Add types (#31774) --- types/get-func-name/get-func-name-tests.ts | 12 +++++++++++ types/get-func-name/index.d.ts | 8 ++++++++ types/get-func-name/tsconfig.json | 23 ++++++++++++++++++++++ types/get-func-name/tslint.json | 1 + 4 files changed, 44 insertions(+) create mode 100644 types/get-func-name/get-func-name-tests.ts create mode 100644 types/get-func-name/index.d.ts create mode 100644 types/get-func-name/tsconfig.json create mode 100644 types/get-func-name/tslint.json diff --git a/types/get-func-name/get-func-name-tests.ts b/types/get-func-name/get-func-name-tests.ts new file mode 100644 index 0000000000..3199af25d7 --- /dev/null +++ b/types/get-func-name/get-func-name-tests.ts @@ -0,0 +1,12 @@ +import getFuncName = require('get-func-name'); + +const unknownFunction = function myCoolFunction(word: string) { + return word + 'is cool'; +}; + +const anonymousFunction = (() => { + return () => {}; +})(); + +getFuncName(unknownFunction); // $ExpectType string +getFuncName(anonymousFunction); // $ExpectType string diff --git a/types/get-func-name/index.d.ts b/types/get-func-name/index.d.ts new file mode 100644 index 0000000000..f43bf3dd2a --- /dev/null +++ b/types/get-func-name/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for get-func-name 2.0 +// Project: https://github.com/chaijs/get-func-name#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = getFuncName; + +declare function getFuncName(fn: Function): string; // tslint:disable-line:ban-types diff --git a/types/get-func-name/tsconfig.json b/types/get-func-name/tsconfig.json new file mode 100644 index 0000000000..acb6f50f0e --- /dev/null +++ b/types/get-func-name/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", + "get-func-name-tests.ts" + ] +} diff --git a/types/get-func-name/tslint.json b/types/get-func-name/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/get-func-name/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From c167f72bce6a925791ae846abc99bd6245e1717c Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:19:20 +0000 Subject: [PATCH 39/69] [cli-boxes] Add types (#31771) --- types/cli-boxes/cli-boxes-tests.ts | 17 +++++++++++++++++ types/cli-boxes/index.d.ts | 23 +++++++++++++++++++++++ types/cli-boxes/tsconfig.json | 23 +++++++++++++++++++++++ types/cli-boxes/tslint.json | 1 + 4 files changed, 64 insertions(+) create mode 100644 types/cli-boxes/cli-boxes-tests.ts create mode 100644 types/cli-boxes/index.d.ts create mode 100644 types/cli-boxes/tsconfig.json create mode 100644 types/cli-boxes/tslint.json diff --git a/types/cli-boxes/cli-boxes-tests.ts b/types/cli-boxes/cli-boxes-tests.ts new file mode 100644 index 0000000000..9885f28777 --- /dev/null +++ b/types/cli-boxes/cli-boxes-tests.ts @@ -0,0 +1,17 @@ +import cliBoxes = require('cli-boxes'); + +cliBoxes.single; // $ExpectType BoxDefinition +cliBoxes.double; // $ExpectType BoxDefinition +cliBoxes.round; // $ExpectType BoxDefinition +cliBoxes['single-double']; // $ExpectType BoxDefinition +cliBoxes['double-single']; // $ExpectType BoxDefinition +cliBoxes.classic; // $ExpectType BoxDefinition + +const single = cliBoxes.single; + +single.bottomLeft; // $ExpectType string +single.bottomRight; // $ExpectType string +single.horizontal; // $ExpectType string +single.topLeft; // $ExpectType string +single.topRight; // $ExpectType string +single.vertical; // $ExpectType string diff --git a/types/cli-boxes/index.d.ts b/types/cli-boxes/index.d.ts new file mode 100644 index 0000000000..e3b4c7be79 --- /dev/null +++ b/types/cli-boxes/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for cli-boxes 1.0 +// Project: https://github.com/sindresorhus/cli-boxes +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export = boxes; +declare const boxes: boxes.Boxes; + +declare namespace boxes { + type BoxNames = 'single' | 'double' | 'round' | 'single-double' | 'double-single' | 'classic'; + + type Boxes = Record; + + interface BoxDefinition { + topLeft: string; + topRight: string; + bottomRight: string; + bottomLeft: string; + vertical: string; + horizontal: string; + } +} diff --git a/types/cli-boxes/tsconfig.json b/types/cli-boxes/tsconfig.json new file mode 100644 index 0000000000..f8a8653c69 --- /dev/null +++ b/types/cli-boxes/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", + "cli-boxes-tests.ts" + ] +} diff --git a/types/cli-boxes/tslint.json b/types/cli-boxes/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cli-boxes/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 992612e192697ba69e2de257153d4036163728fb Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:19:40 +0000 Subject: [PATCH 40/69] [symlink-or-copy] Add types (#31770) --- types/symlink-or-copy/index.d.ts | 10 ++++++++ .../symlink-or-copy/symlink-or-copy-tests.ts | 7 ++++++ types/symlink-or-copy/tsconfig.json | 23 +++++++++++++++++++ types/symlink-or-copy/tslint.json | 1 + 4 files changed, 41 insertions(+) create mode 100644 types/symlink-or-copy/index.d.ts create mode 100644 types/symlink-or-copy/symlink-or-copy-tests.ts create mode 100644 types/symlink-or-copy/tsconfig.json create mode 100644 types/symlink-or-copy/tslint.json diff --git a/types/symlink-or-copy/index.d.ts b/types/symlink-or-copy/index.d.ts new file mode 100644 index 0000000000..d80ad54bc6 --- /dev/null +++ b/types/symlink-or-copy/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for symlink-or-copy 1.2 +// Project: https://github.com/broccolijs/node-symlink-or-copy#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function sync(srcPath: string, destPath: string): void; + +export const canSymlink: boolean; +export const canSymlinkFile: boolean; +export const canSymlinkDirectory: boolean; diff --git a/types/symlink-or-copy/symlink-or-copy-tests.ts b/types/symlink-or-copy/symlink-or-copy-tests.ts new file mode 100644 index 0000000000..314b2f2bc9 --- /dev/null +++ b/types/symlink-or-copy/symlink-or-copy-tests.ts @@ -0,0 +1,7 @@ +import * as symlinkOrCopy from 'symlink-or-copy'; + +symlinkOrCopy.sync('src_dir/some_file.txt', 'dest_dir/some_file.txt'); + +symlinkOrCopy.canSymlink; // $ExpectType boolean +symlinkOrCopy.canSymlinkDirectory; // $ExpectType boolean +symlinkOrCopy.canSymlinkFile; // $ExpectType boolean diff --git a/types/symlink-or-copy/tsconfig.json b/types/symlink-or-copy/tsconfig.json new file mode 100644 index 0000000000..cba75531dc --- /dev/null +++ b/types/symlink-or-copy/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", + "symlink-or-copy-tests.ts" + ] +} diff --git a/types/symlink-or-copy/tslint.json b/types/symlink-or-copy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/symlink-or-copy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b5e2917c01f9f97f7500fbf39406b97f925ec811 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:21:58 +0000 Subject: [PATCH 41/69] [shallowequal] Update types to v1.1 (#31765) * [shallowequal] Move v0 type to sub-dir * [shallowequal] Update types to v1.1 --- types/shallowequal/index.d.ts | 13 ++-- types/shallowequal/shallowequal-tests.ts | 33 +++++---- types/shallowequal/tsconfig.json | 4 +- types/shallowequal/tslint.json | 78 +-------------------- types/shallowequal/v0/index.d.ts | 10 +++ types/shallowequal/v0/shallowequal-tests.ts | 16 +++++ types/shallowequal/v0/tsconfig.json | 28 ++++++++ types/shallowequal/v0/tslint.json | 3 + 8 files changed, 90 insertions(+), 95 deletions(-) create mode 100644 types/shallowequal/v0/index.d.ts create mode 100644 types/shallowequal/v0/shallowequal-tests.ts create mode 100644 types/shallowequal/v0/tsconfig.json create mode 100644 types/shallowequal/v0/tslint.json diff --git a/types/shallowequal/index.d.ts b/types/shallowequal/index.d.ts index af13b55eb4..95b91d6de5 100644 --- a/types/shallowequal/index.d.ts +++ b/types/shallowequal/index.d.ts @@ -1,10 +1,15 @@ -// Type definitions for shallowequal v0.2.2 +// Type definitions for shallowequal 1.1 // Project: https://github.com/dashed/shallowequal // Definitions by: Sean Kelley +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -declare function shallowEqual(objA: any, objB: any, compare?: (objA: any, objB: any, indexOrKey?: number | string) => (boolean | undefined), compareContext?: any): boolean; - -declare namespace shallowEqual { } +declare function shallowEqual( + objA: any, + objB: any, + compare?: (this: TCtx, objA: any, objB: any, indexOrKey?: number | string) => boolean | void, + compareContext?: TCtx +): boolean; export = shallowEqual; diff --git a/types/shallowequal/shallowequal-tests.ts b/types/shallowequal/shallowequal-tests.ts index 2a8589fc32..efa5b546a5 100644 --- a/types/shallowequal/shallowequal-tests.ts +++ b/types/shallowequal/shallowequal-tests.ts @@ -1,15 +1,24 @@ -import shallowEqual_require = require('shallowequal'); -import * as shallowEqual_splat from 'shallowequal'; +import shallowEqual = require('shallowequal'); -const a = {}, b = {}; -function compare(a: any, b: any, indexOrKey?: number | string) { - return false; -} +const a = {}; +const b = {}; -shallowEqual_require(a, b); -shallowEqual_require(a, b, compare); -shallowEqual_require(a, b, compare, {}); +shallowEqual(a, b); // $ExpectType boolean +// $ExpectType boolean +shallowEqual(a, b, (a, b, indexOrKey) => { + a; // $ExpectType any + b; // $ExpectType any + indexOrKey; // $ExpectType string | number | undefined -shallowEqual_splat(a, b); -shallowEqual_splat(a, b, compare); -shallowEqual_splat(a, b, compare, {}); + return false; +}); +shallowEqual(a, b, () => {}); // $ExpectType boolean +// $ExpectType boolean +shallowEqual( + a, + b, + function() { + this; // $ExpectType { foo: string; } + }, + { foo: 'bar' } +); diff --git a/types/shallowequal/tsconfig.json b/types/shallowequal/tsconfig.json index de32c6c47b..acae2da6d5 100644 --- a/types/shallowequal/tsconfig.json +++ b/types/shallowequal/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "shallowequal-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/shallowequal/tslint.json b/types/shallowequal/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/shallowequal/tslint.json +++ b/types/shallowequal/tslint.json @@ -1,79 +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-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" } diff --git a/types/shallowequal/v0/index.d.ts b/types/shallowequal/v0/index.d.ts new file mode 100644 index 0000000000..f9eb1c460c --- /dev/null +++ b/types/shallowequal/v0/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for shallowequal 0.2 +// Project: https://github.com/dashed/shallowequal +// Definitions by: Sean Kelley +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function shallowEqual(objA: any, objB: any, compare?: (objA: any, objB: any, indexOrKey?: number | string) => (boolean | undefined), compareContext?: any): boolean; + +declare namespace shallowEqual { } + +export = shallowEqual; diff --git a/types/shallowequal/v0/shallowequal-tests.ts b/types/shallowequal/v0/shallowequal-tests.ts new file mode 100644 index 0000000000..d7192971da --- /dev/null +++ b/types/shallowequal/v0/shallowequal-tests.ts @@ -0,0 +1,16 @@ +import shallowEqual_require = require('shallowequal'); +import * as shallowEqual_splat from 'shallowequal'; + +const a = {}; +const b = {}; +function compare(a: any, b: any, indexOrKey?: number | string) { + return false; +} + +shallowEqual_require(a, b); +shallowEqual_require(a, b, compare); +shallowEqual_require(a, b, compare, {}); + +shallowEqual_splat(a, b); +shallowEqual_splat(a, b, compare); +shallowEqual_splat(a, b, compare, {}); diff --git a/types/shallowequal/v0/tsconfig.json b/types/shallowequal/v0/tsconfig.json new file mode 100644 index 0000000000..adc93ac644 --- /dev/null +++ b/types/shallowequal/v0/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "shallowequal": [ + "shallowequal/v0" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shallowequal-tests.ts" + ] +} diff --git a/types/shallowequal/v0/tslint.json b/types/shallowequal/v0/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/shallowequal/v0/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 329bd4c233188890d080394bf1305c97f57c85a3 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:22:39 +0000 Subject: [PATCH 42/69] [saslprep] Add types (#31766) --- types/saslprep/index.d.ts | 14 ++++++++++++++ types/saslprep/saslprep-tests.ts | 4 ++++ types/saslprep/tsconfig.json | 23 +++++++++++++++++++++++ types/saslprep/tslint.json | 1 + 4 files changed, 42 insertions(+) create mode 100644 types/saslprep/index.d.ts create mode 100644 types/saslprep/saslprep-tests.ts create mode 100644 types/saslprep/tsconfig.json create mode 100644 types/saslprep/tslint.json diff --git a/types/saslprep/index.d.ts b/types/saslprep/index.d.ts new file mode 100644 index 0000000000..4a5f931433 --- /dev/null +++ b/types/saslprep/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for saslprep 1.0 +// Project: https://github.com/reklatsmasters/saslprep#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = saslPrep; + +declare function saslPrep(input: string, options?: saslPrep.Options): string; + +declare namespace saslPrep { + interface Options { + allowUnassigned?: boolean; + } +} diff --git a/types/saslprep/saslprep-tests.ts b/types/saslprep/saslprep-tests.ts new file mode 100644 index 0000000000..b3dad713ca --- /dev/null +++ b/types/saslprep/saslprep-tests.ts @@ -0,0 +1,4 @@ +import saslprep = require('saslprep'); + +saslprep('password\u00AD'); // $ExpectType string +saslprep('password\u00AD', { allowUnassigned: true }); // $ExpectType string diff --git a/types/saslprep/tsconfig.json b/types/saslprep/tsconfig.json new file mode 100644 index 0000000000..19cbde2f08 --- /dev/null +++ b/types/saslprep/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", + "saslprep-tests.ts" + ] +} diff --git a/types/saslprep/tslint.json b/types/saslprep/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/saslprep/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 548be484658131e8fa16493c1c0c2c430638e427 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:23:28 +0000 Subject: [PATCH 43/69] [strip-color] Add types (#31764) --- types/strip-color/index.d.ts | 8 ++++++++ types/strip-color/strip-color-tests.ts | 3 +++ types/strip-color/tsconfig.json | 23 +++++++++++++++++++++++ types/strip-color/tslint.json | 1 + 4 files changed, 35 insertions(+) create mode 100644 types/strip-color/index.d.ts create mode 100644 types/strip-color/strip-color-tests.ts create mode 100644 types/strip-color/tsconfig.json create mode 100644 types/strip-color/tslint.json diff --git a/types/strip-color/index.d.ts b/types/strip-color/index.d.ts new file mode 100644 index 0000000000..3a3a126995 --- /dev/null +++ b/types/strip-color/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for strip-color 0.1 +// Project: https://github.com/jonschlinkert/strip-color +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = stripColor; + +declare function stripColor(text: string): string; diff --git a/types/strip-color/strip-color-tests.ts b/types/strip-color/strip-color-tests.ts new file mode 100644 index 0000000000..952c1d630c --- /dev/null +++ b/types/strip-color/strip-color-tests.ts @@ -0,0 +1,3 @@ +import strip = require('strip-color'); + +strip('abc'); // $ExpectType string diff --git a/types/strip-color/tsconfig.json b/types/strip-color/tsconfig.json new file mode 100644 index 0000000000..e5f91623bc --- /dev/null +++ b/types/strip-color/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", + "strip-color-tests.ts" + ] +} diff --git a/types/strip-color/tslint.json b/types/strip-color/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/strip-color/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4ae2869a19114d1ab2a41a1025b2ede1993ed668 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:23:48 +0000 Subject: [PATCH 44/69] [binaryextensions] Add types (#31759) --- .../binaryextensions-tests.ts | 3 +++ types/binaryextensions/index.d.ts | 8 +++++++ types/binaryextensions/tsconfig.json | 23 +++++++++++++++++++ types/binaryextensions/tslint.json | 1 + 4 files changed, 35 insertions(+) create mode 100644 types/binaryextensions/binaryextensions-tests.ts create mode 100644 types/binaryextensions/index.d.ts create mode 100644 types/binaryextensions/tsconfig.json create mode 100644 types/binaryextensions/tslint.json diff --git a/types/binaryextensions/binaryextensions-tests.ts b/types/binaryextensions/binaryextensions-tests.ts new file mode 100644 index 0000000000..c07a6b8b8a --- /dev/null +++ b/types/binaryextensions/binaryextensions-tests.ts @@ -0,0 +1,3 @@ +import extensions = require('binaryextensions'); + +extensions; // $ExpectType string[] diff --git a/types/binaryextensions/index.d.ts b/types/binaryextensions/index.d.ts new file mode 100644 index 0000000000..704e577f31 --- /dev/null +++ b/types/binaryextensions/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for binaryextensions 2.1 +// Project: https://github.com/bevry/binaryextensions +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = extensions; + +declare const extensions: string[]; diff --git a/types/binaryextensions/tsconfig.json b/types/binaryextensions/tsconfig.json new file mode 100644 index 0000000000..e666a0507c --- /dev/null +++ b/types/binaryextensions/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", + "binaryextensions-tests.ts" + ] +} diff --git a/types/binaryextensions/tslint.json b/types/binaryextensions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/binaryextensions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 91034ca24374b4ac6402c85563a4f4255bcb9493 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:24:10 +0000 Subject: [PATCH 45/69] [textextensions] Add types (#31760) --- types/textextensions/index.d.ts | 8 +++++++ types/textextensions/textextensions-tests.ts | 3 +++ types/textextensions/tsconfig.json | 23 ++++++++++++++++++++ types/textextensions/tslint.json | 1 + 4 files changed, 35 insertions(+) create mode 100644 types/textextensions/index.d.ts create mode 100644 types/textextensions/textextensions-tests.ts create mode 100644 types/textextensions/tsconfig.json create mode 100644 types/textextensions/tslint.json diff --git a/types/textextensions/index.d.ts b/types/textextensions/index.d.ts new file mode 100644 index 0000000000..bbb37873bd --- /dev/null +++ b/types/textextensions/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for textextensions 2.4 +// Project: https://github.com/bevry/textextensions +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = extensions; + +declare const extensions: string[]; diff --git a/types/textextensions/textextensions-tests.ts b/types/textextensions/textextensions-tests.ts new file mode 100644 index 0000000000..19e4b8f82a --- /dev/null +++ b/types/textextensions/textextensions-tests.ts @@ -0,0 +1,3 @@ +import extensions = require('textextensions'); + +extensions; // $ExpectType string[] diff --git a/types/textextensions/tsconfig.json b/types/textextensions/tsconfig.json new file mode 100644 index 0000000000..2ecfa340a3 --- /dev/null +++ b/types/textextensions/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", + "textextensions-tests.ts" + ] +} diff --git a/types/textextensions/tslint.json b/types/textextensions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/textextensions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From f796b740d0e44ff9429753721a00f8d7cd24f418 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:26:46 +0000 Subject: [PATCH 46/69] [istextorbinary] Add types (#31758) --- types/istextorbinary/index.d.ts | 93 ++++++++++++++++++++ types/istextorbinary/istextorbinary-tests.ts | 67 ++++++++++++++ types/istextorbinary/tsconfig.json | 23 +++++ types/istextorbinary/tslint.json | 1 + 4 files changed, 184 insertions(+) create mode 100644 types/istextorbinary/index.d.ts create mode 100644 types/istextorbinary/istextorbinary-tests.ts create mode 100644 types/istextorbinary/tsconfig.json create mode 100644 types/istextorbinary/tslint.json diff --git a/types/istextorbinary/index.d.ts b/types/istextorbinary/index.d.ts new file mode 100644 index 0000000000..d41400f89b --- /dev/null +++ b/types/istextorbinary/index.d.ts @@ -0,0 +1,93 @@ +// Type definitions for istextorbinary 2.3 +// Project: https://github.com/bevry/istextorbinary +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * Is Text (Synchronous) + * Determine whether or not a file is a text or binary file. + * Determined by extension checks first, then if unknown extension, will fallback on encoding detection. + * We do that as encoding detection cannot guarantee everything, especially for chars between utf8 and utf16. + * We use the extensions from https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions + * @param filename the filename for the file/buffer if available + * @param buffer the buffer for the file if available + */ +export function isTextSync(filename: string, buffer?: Buffer): boolean; +export function isTextSync(filename: undefined, buffer: Buffer): boolean; + +/** + * Is Text + * Uses `isTextSync` behind the scenes. + * @param filename forwarded to `isTextSync` + * @param buffer forwarded to `isTextSync` + * @param next accepts arguments: (error: Error, result: Boolean) + */ +export function isText( + filename: string, + buffer: Buffer | undefined, + next: (err: null, result: boolean) => void +): void; +export function isText( + filename: undefined, + buffer: Buffer, + next: (err: null, result: boolean) => void +): void; + +/** + * Is Binary (Synchronous) + * Uses `isTextSync` behind the scenes. + * @param filename forwarded to `isTextSync` + * @param buffer forwarded to `isTextSync` + */ +export function isBinarySync(filename: string, buffer?: Buffer): boolean; +export function isBinarySync(filename: undefined, buffer: Buffer): boolean; + +/** + * Is Binary + * Uses `isText` behind the scenes. + * @param filename forwarded to `isText` + * @param buffer forwarded to `isText` + * @param next accepts arguments: (error: Error, result: Boolean) + */ +export function isBinary( + filename: string, + buffer: Buffer | undefined, + next: (err: null, result: boolean) => void +): void; +export function isBinary( + filename: undefined, + buffer: Buffer, + next: (err: null, result: boolean) => void +): void; + +/** + * Get the encoding of a buffer. + * We fetch a bunch chars from the start, middle and end of the buffer. + * We check all three, as doing only start was not enough, and doing only middle was not enough, so better safe than sorry. + * @param buffer + * @param [opts] + * @param [opts.chunkLength = 24] + * @param [opts.chunkBegin = 0] + * @returns either an Error instance if something went wrong, or if successful "utf8" or "binary" + */ +export function getEncodingSync(buffer: Buffer, opts?: Options): 'utf8' | 'binary'; + +/** + * Get the encoding of a buffer + * Uses `getEncodingSync` behind the scenes. + * @param buffer forwarded to `getEncodingSync` + * @param opts forwarded to `getEncodingSync` + * @param next accepts arguments: (error: Error, result: Boolean) + */ +export function getEncoding( + buffer: Buffer, + opts: Options | undefined, + next: (err: null, result: 'utf8' | 'binary') => void +): void; + +export interface Options { + chunkLength?: number; + chunkBegin?: number; +} diff --git a/types/istextorbinary/istextorbinary-tests.ts b/types/istextorbinary/istextorbinary-tests.ts new file mode 100644 index 0000000000..cf9c953711 --- /dev/null +++ b/types/istextorbinary/istextorbinary-tests.ts @@ -0,0 +1,67 @@ +import { + isTextSync, + isText, + isBinarySync, + isBinary, + getEncodingSync, + getEncoding, +} from 'istextorbinary'; + +isTextSync('foo.txt'); // $ExpectType boolean +isTextSync('foo.txt', new Buffer(1)); // $ExpectType boolean +isTextSync(undefined, new Buffer(1)); // $ExpectType boolean +isTextSync(); // $ExpectError +isTextSync(undefined); // $ExpectError +isTextSync(undefined, undefined); // $ExpectError + +isText('foo.txt', undefined, (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isText('foo.txt', new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isText(undefined, new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isText(undefined, undefined, (err, result) => {}); // $ExpectError + +isBinarySync('foo.txt'); // $ExpectType boolean +isBinarySync('foo.txt', new Buffer(1)); // $ExpectType boolean +isBinarySync(undefined, new Buffer(1)); // $ExpectType boolean +isBinarySync(); // $ExpectError +isBinarySync(undefined); // $ExpectError +isBinarySync(undefined, undefined); // $ExpectError + +isBinary('foo.txt', undefined, (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isBinary('foo.txt', new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isBinary(undefined, new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isBinary(undefined, undefined, (err, result) => {}); // $ExpectError + +getEncodingSync(new Buffer(1)); // $ExpectType "utf8" | "binary" +getEncodingSync(new Buffer(1), { chunkBegin: 0 }); // $ExpectType "utf8" | "binary" +getEncodingSync(new Buffer(1), { chunkLength: 10 }); // $ExpectType "utf8" | "binary" + +getEncoding(new Buffer(1), undefined, (err, result) => { + err; // $ExpectType null + result; // $ExpectType "utf8" | "binary" +}); +getEncoding(new Buffer(1), { chunkBegin: 0 }, (err, result) => { + err; // $ExpectType null + result; // $ExpectType "utf8" | "binary" +}); +getEncoding(new Buffer(1), { chunkLength: 10 }, (err, result) => { + err; // $ExpectType null + result; // $ExpectType "utf8" | "binary" +}); diff --git a/types/istextorbinary/tsconfig.json b/types/istextorbinary/tsconfig.json new file mode 100644 index 0000000000..7e5e7e256c --- /dev/null +++ b/types/istextorbinary/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", + "istextorbinary-tests.ts" + ] +} diff --git a/types/istextorbinary/tslint.json b/types/istextorbinary/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istextorbinary/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b3e3580a662943071d2263687d14ed92ca160409 Mon Sep 17 00:00:00 2001 From: jlismore <37339984+jlismore@users.noreply.github.com> Date: Mon, 31 Dec 2018 16:30:09 +0000 Subject: [PATCH 47/69] [trie-prefix-tree] Add types for trie-prefix-tree (#31754) * Add types for trie-prefix-tree * Add TS version --- types/trie-prefix-tree/index.d.ts | 66 +++++++++++++++++++ .../trie-prefix-tree-tests.ts | 62 +++++++++++++++++ types/trie-prefix-tree/tsconfig.json | 16 +++++ types/trie-prefix-tree/tslint.json | 1 + 4 files changed, 145 insertions(+) create mode 100644 types/trie-prefix-tree/index.d.ts create mode 100644 types/trie-prefix-tree/trie-prefix-tree-tests.ts create mode 100644 types/trie-prefix-tree/tsconfig.json create mode 100644 types/trie-prefix-tree/tslint.json diff --git a/types/trie-prefix-tree/index.d.ts b/types/trie-prefix-tree/index.d.ts new file mode 100644 index 0000000000..7dcd7ec53c --- /dev/null +++ b/types/trie-prefix-tree/index.d.ts @@ -0,0 +1,66 @@ +// Type definitions for trie-prefix-tree 1.5 +// Project: https://github.com/lyndseybrowning/trie-prefix#readme +// Definitions by: James Lismore +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +export default function Trie( + strings: string[] +): { + /** + * Get a string representation of the trie + */ + dump(spacer?: number): string; + /** + * Get the generated raw trie object + */ + tree(): any; + /** + * Add a new word to the trie + */ + addWord(word: string): ReturnType; + /** + * Remove an existing word from the trie + */ + removeWord(word: string): ReturnType; + /** + * Check a prefix is valid + * @returns Boolean + */ + isPrefix(word: string): boolean; + /** + * Count the number of words with the given prefixSearch + * @returns Number + */ + countPrefix(word: string): number; + /** + * Get a list of all words in the trie with the given prefix + * @returns Array + */ + getPrefix(word: string, sort?: boolean): string[]; + /** + * Get a random word in the trie with the given prefix + * @returns Array + */ + getRandomWordWithPrefix(prefix: string): string; + /** + * Get all words in the trie + * @returns Array + */ + getWords(sorted?: boolean): string[]; + /** + * Check the existence of a word in the trie + * @returns Boolean + */ + hasWord(word: string): boolean; + /** + * Get a list of valid anagrams that can be made from the given letters + * @returns Array + */ + getAnagrams(word: string): string[]; + /** + * Get a list of all sub-anagrams that can be made from the given letters + * @returns Array + */ + getSubAnagrams(word: string): string[]; +}; diff --git a/types/trie-prefix-tree/trie-prefix-tree-tests.ts b/types/trie-prefix-tree/trie-prefix-tree-tests.ts new file mode 100644 index 0000000000..debd86871b --- /dev/null +++ b/types/trie-prefix-tree/trie-prefix-tree-tests.ts @@ -0,0 +1,62 @@ +import trie from "trie-prefix-tree"; + +// Instantiate the Trie +const test = trie(["cat", "cats", "dogs", "elephant", "tiger"]); + +// retrieve a stringified dump of the Trie object +test.dump(); + +// optionally pass in spacer parameter to format the output string +test.dump(2); + +// retrieve the Trie object instance +test.tree(); + +// add a new word to the Trie +test.addWord("lion"); + +// remove an existing word from the Trie +test.removeWord("dogs"); + +// Adding and removing words can be chained: +test.addWord("hello").removeWord("hello"); +test.removeWord("hello").addWord("hello"); + +// check if a prefix exists: +test.isPrefix("do"); +test.isPrefix("z"); + +// count prefixes +test.countPrefix("c"); + +// get an array of words with the passed in prefix +test.getPrefix("c"); + +// Pass false as the second parameter to disable +// output being sorted alphabetically +// this is useful when your dictionary is already sorted +// and will therefore save performance +test.getPrefix("c", false); + +// get a random word at a prefix +test.getRandomWordWithPrefix("c"); +test.getRandomWordWithPrefix("c"); + +// retrieve a full list of words in the Trie +// the output array is automatically sorted +test.getWords(); + +// pass false to disable the output being sorted +// this is useful when your dictionary is already sorted +// and will therefore save performance +test.getWords(false); + +// check if a word exists in the Trie +test.hasWord("elephant"); +test.hasWord("zoo"); + +// generate a list of valid anagrams from the given letters +test.getAnagrams("act"); + +// generate a list of valid sub-anagrams from the given letters +test.getSubAnagrams("ctalion"); diff --git a/types/trie-prefix-tree/tsconfig.json b/types/trie-prefix-tree/tsconfig.json new file mode 100644 index 0000000000..72f38f1616 --- /dev/null +++ b/types/trie-prefix-tree/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "trie-prefix-tree-tests.ts"] +} diff --git a/types/trie-prefix-tree/tslint.json b/types/trie-prefix-tree/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/trie-prefix-tree/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 1edbe22747f5a80675a97b67e8619b527a47aa7b Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 31 Dec 2018 16:32:14 +0000 Subject: [PATCH 48/69] [parse-passwd] Add types (#31751) --- types/parse-passwd/index.d.ts | 20 ++++++++++++++++++++ types/parse-passwd/parse-passwd-tests.ts | 14 ++++++++++++++ types/parse-passwd/tsconfig.json | 23 +++++++++++++++++++++++ types/parse-passwd/tslint.json | 1 + 4 files changed, 58 insertions(+) create mode 100644 types/parse-passwd/index.d.ts create mode 100644 types/parse-passwd/parse-passwd-tests.ts create mode 100644 types/parse-passwd/tsconfig.json create mode 100644 types/parse-passwd/tslint.json diff --git a/types/parse-passwd/index.d.ts b/types/parse-passwd/index.d.ts new file mode 100644 index 0000000000..9f74d078ce --- /dev/null +++ b/types/parse-passwd/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for parse-passwd 1.0 +// Project: https://github.com/doowb/parse-passwd +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = parsePasswd; + +declare function parsePasswd(passwdText: string): parsePasswd.PasswdEntry[]; + +declare namespace parsePasswd { + interface PasswdEntry { + username: string; + password: string; + uid: string; + gid: string; + gecos: string; + homedir: string; + shell: string; + } +} diff --git a/types/parse-passwd/parse-passwd-tests.ts b/types/parse-passwd/parse-passwd-tests.ts new file mode 100644 index 0000000000..6eb6eeb32e --- /dev/null +++ b/types/parse-passwd/parse-passwd-tests.ts @@ -0,0 +1,14 @@ +import parse = require('parse-passwd'); + +const entries = parse('doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash'); +entries; // $ExpectType PasswdEntry[] + +const entry = entries[0]; + +entry.username; // $ExpectType string +entry.password; // $ExpectType string +entry.uid; // $ExpectType string +entry.gid; // $ExpectType string +entry.gecos; // $ExpectType string +entry.homedir; // $ExpectType string +entry.shell; // $ExpectType string diff --git a/types/parse-passwd/tsconfig.json b/types/parse-passwd/tsconfig.json new file mode 100644 index 0000000000..2ed7a0a913 --- /dev/null +++ b/types/parse-passwd/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", + "parse-passwd-tests.ts" + ] +} diff --git a/types/parse-passwd/tslint.json b/types/parse-passwd/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/parse-passwd/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 524badb2afaf6785638268c33409e397b63a1553 Mon Sep 17 00:00:00 2001 From: Netto Farah Date: Mon, 31 Dec 2018 08:33:16 -0800 Subject: [PATCH 49/69] Add defintions for ui-box@1.4 (#31750) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📦 ui-box is a low level CSS-in-JS solution that focuses on being simple, fast and extensible. All CSS properties are set using simple React props, which allows you to easily create reusable components that can be enhanced with additional CSS properties. https://github.com/segmentio/ui-box --- types/ui-box/index.d.ts | 92 +++++++++++++++++++++++++++++++++++ types/ui-box/package.json | 6 +++ types/ui-box/tsconfig.json | 25 ++++++++++ types/ui-box/tslint.json | 3 ++ types/ui-box/ui-box-tests.tsx | 27 ++++++++++ 5 files changed, 153 insertions(+) create mode 100644 types/ui-box/index.d.ts create mode 100644 types/ui-box/package.json create mode 100644 types/ui-box/tsconfig.json create mode 100644 types/ui-box/tslint.json create mode 100644 types/ui-box/ui-box-tests.tsx diff --git a/types/ui-box/index.d.ts b/types/ui-box/index.d.ts new file mode 100644 index 0000000000..ee91dc72ce --- /dev/null +++ b/types/ui-box/index.d.ts @@ -0,0 +1,92 @@ +// Type definitions for ui-box 1.4 +// Project: https://github.com/segmentio/ui-box +// Definitions by: Netto Farah +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Component, ComponentClass, ReactNode } from "react"; +import * as CSS from "csstype"; + +/** Placeholder type for UI box props */ +type UIBoxProp = string | number | boolean | null | undefined; + +/** A prop defining which */ +type UIBoxIsProp = string | ReactNode; + +type CSSProps = CSS.StandardProperties; + +export interface BoxProps { + /** + * Callback that gets passed a ref to inner DOM node (or component if the is prop is set to a + * React component type). + */ + innerRef?(node: ReactNode): any; + + /** + * Lets you change the underlying element type. + * You can pass either a string to change the DOM element type, or a React component type to + * inherit another component. The component just needs to accept a className prop to work. + * A good example is inheriting the react-router Link component + */ + is?: UIBoxIsProp; + + /** + * The className prop you know and love. Internally it gets enhanced with additional class + * names for the CSS properties you specify. + */ + className?: string; + + /** Set to border - box by default. */ + boxSizing?: UIBoxProp; + + /** Sets marginLeft and marginRight to the same value */ + marginX?: UIBoxProp; + + /** Sets marginTop and marginBottom to the same value */ + marginY?: UIBoxProp; + + /** Sets paddingLeft and paddingRight to the same value */ + paddingX?: UIBoxProp; + + /** Sets paddingTop and paddingBottom to the same value */ + paddingY?: UIBoxProp; + + /** Utility property for easily adding clearfix styles to the element. */ + clearfix?: boolean; + + // accept any other arbitrary prop + [key: string]: any; +} + +export type Box = Component; +export const Box: ComponentClass; +export default Box; + +type CacheEntry = ReadonlyArray<[/** key */ string, /** value */ string]>; + +/** + * Returns a { cache, styles } object which contains the cache entries and rendered styles + * for server rendering. The styles can be output in a