From 356caac0db3b7ddc7206c270cd6b6078902894bd Mon Sep 17 00:00:00 2001 From: Fred Morel Date: Thu, 20 Oct 2016 21:15:15 -0400 Subject: [PATCH 01/19] Add types for node-hue-api npm package --- node-hue-api/index.d.ts | 1075 ++++++++++++++++++++++++++++ node-hue-api/node-hue-api-tests.ts | 22 + node-hue-api/tsconfig.json | 19 + 3 files changed, 1116 insertions(+) create mode 100644 node-hue-api/index.d.ts create mode 100644 node-hue-api/node-hue-api-tests.ts create mode 100644 node-hue-api/tsconfig.json diff --git a/node-hue-api/index.d.ts b/node-hue-api/index.d.ts new file mode 100644 index 0000000000..4d0bc36181 --- /dev/null +++ b/node-hue-api/index.d.ts @@ -0,0 +1,1075 @@ +// Type definitions for node-hue-api 2.3.0 +// Project: https://github.com/peter-murray/node-hue-api +// Definitions by: wind-rider , Frederic Morel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +// Functions that are deprecated, not working, or returning callbacks instead of promises were not documented. + +declare module "node-hue-api" { + + //Not documented because it says it's broken + //export function connect(config) : HueApi; + + //TODO: document lightState, scheduledEvent, scene, timer + //export lightState: lightState, + //export scheduledEvent: scheduledEvent, + //export scene: scene, + //export timer: timer, + + /** + * Will locate the Philips Hue Devices on the network. Depending upon the speed and size of the network the timeout + * may need to be adjusted to locate the Hue Bridge. + * + * @param timeout The maximum time to wait for Hue Devices to be located. If not specified will use the default of 5 seconds. + * @return A promise that will resolve the Hue Bridges as an Array of {"id": {String}, "ipaddress": {String}} objects. + */ + export function upnpSearch(timeout: number): IUpnpSearchResultItem[]; + //Not documented because it's deprecated + //export function searchForBridges(timeout: number): IUpnpSearchResultItem[]; + + /** + * Uses the http://www.meethue.com/api/nupnp call to search for any bridges locally on the network. This lookup can be + * significantly faster than issuing search requests in the {locateBridges} function. + * + * @param cb An option callback function that will be informed of results. + * @returns {Q.promise} A promise that will resolve the addresses of the bridges, or {null} if a callback was provided. + */ + export function nupnpSearch(): Promise; + //Not documented because it's deprecated + //export function locateBridges(): Promise; + + /* An Error Type for API related errors when calling the Philips Hue API. + + * @param error The error object returned from the request. + * @constructor + */ + export class ApiError extends Error { + + name: string; + message: string; + type: any; + address: string; + + constructor(error: Object); + } + + export class HueApi { + + /* + * Constructor used for searching for bridges and registering users + */ + constructor(); + + /** + * Creates an instance of HueApi. + * @param {string} host Address of Hue bridge + * @param {string} username Application username for Hue bridge + * @param {number} [timeout] + * @param {number} [port] + */ + constructor(host: string, username: string, timeout?: number, port?: number); + + /** + * Gets the version data for the Philips Hue Bridge. + * + * @param cb An optional callback function if you don't want to be informed via a promise. + * @returns {Q.promise} A promise will be provided that will resolve to the version data for the bridge, or {null} if a + * callback was provided. + */ + getVersion(): Promise; + //getVersion(cb: (err: NodeJS.ErrnoException, data: IBridgeVersion) => void): void; + version(): Promise; + //version(cb: (err: NodeJS.ErrnoException, data: IBridgeVersion) => void): void; + + /** + * Loads the description for the Philips Hue. + * + * @param cb An optional callback function if you don't want to be informed via a promise. + * @return {Q.promise} A promise that will be provided with a description object, or {null} if a callback was provided. + */ + description(): Promise; + //description(cb: (err: NodeJS.ErrnoException, data: IBridgeDescription) => void): void; + getDescription(): Promise; + //getDescription(cb: (err: NodeJS.ErrnoException, data: IBridgeDescription) => void): void; + + /** + * Reads the bridge configuration and returns it as a JSON object. + * + * @param cb An optional callback function to use if you do not want to use the promise for results. + * @return {Q.promise} A promise with the result, or if a callback function was provided. + */ + config(): Promise; + //config(cb: (err: NodeJS.ErrnoException, data: IBridgeConfig) => void): void; + getConfig(): Promise; + //getConfig(cb: (err: NodeJS.ErrnoException, data: IBridgeConfig) => void): void; + + /** + * Obtains the complete state for the Bridge. This is considered to be a very expensive operation and should not be invoked + * frequently. The results detail all config, users, groups, schedules and lights for the system. + * + * @param cb An optional callback function if you don't want to be informed via a promise. + * @returns {Q.promise} A promise with the result, or {null} if a callback function was provided + */ + getFullState(): Promise; + //getFullState(cb: (err: NodeJS.ErrnoException, data: IState) => void): void; + fullState(): Promise; + //fullState(cb: (err: NodeJS.ErrnoException, data: IState) => void): void; + + /** + * Allows a new user/device to be registered with the Philips Hue Bridge. This will return the name of the user that was + * created by the function call. + * + * This function does not require the HueApi to have been initialized with a host or username. It does however require + * the end user to have pressed the link button on the bridge, before invoking this function. + * + * @param host The hostname or IP Address of the Hue Bridge. + * @param deviceDescription The description for the user/device that is being registered. This is a human readable + * description of the user/device. If one is not provided then a default will be set. + * @param cb An optional callback function to use if you do not want a promise returned. + * @return {Q.promise} A promise with the result, or if a callback was provided. + */ + registerUser(host: string, deviceDescription?: string): Promise; + //registerUser(host: string, deviceDescription?: string, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + createUser(host: string, deviceDescription?: string): Promise; + //createUser(host: string, deviceDescription?: string, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + + /** + * Presses the Link Button on the Bridge (without the user actually having to do it). If successful then {true} will be + * returned as the result. + * + * @param cb An optional callback function to use if you do not want to use the promise returned. + * @return {Q.promise} A promise with the result, or if a callback was provided. + */ + pressLinkButton(): Promise; + //pressLinkButton(cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Deletes an existing user from the Phillips Hue Bridge. + * + * @param username The username of the user to delete. + * @param cb An optional callback function to use if you do not want to get the result via a promise chain. + * @returns {Q.promise} A promise with the result of the deletion, or if a callback was provided. + */ + deleteUser(username: string): Promise; + //deleteUser(username: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + unregisterUser(username: string): Promise; + //unregisterUser(username: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void + + + /** + * Obtain a list of registered "users" or "devices" that can interact with the Philips Hue. + * + * @param cb An optional callback function if you do not want to use the promise to obtain the results. + * @return A promise that will provide the results of registered users, or if a callback was provided. + */ + registeredUsers(): Promise; + //registeredUsers(cb: (err: NodeJS.ErrnoException, data: IRegisteredUser) => void): void; + getRegisteredUsers(): Promise; + //getRegisteredUsers(cb: (err: NodeJS.ErrnoException, data: IRegisteredUser) => void): void; + + + /** + * Obtains the details of the individual sensors that are attached to the Philips Hue. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the lights object, or {null} if a callback function was provided. + */ + sensors(): Promise; + //sensors(cb: (err: NodeJS.ErrnoException, data: ISensorsApiResponse) => void): void; + getSensors(): Promise; + //getSensors(cb: (err: NodeJS.ErrnoException, data: ISensorsApiResponse) => void): void; + + /** + * Obtains the details of the individual lights that are attached to the Philips Hue. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the lights object, or {null} if a callback function was provided. + */ + lights(): Promise; + //lights(cb: (err: NodeJS.ErrnoException, data: ILightsApiResponse) => void): void; + getLights(): Promise; + //getLights(cb: (err: NodeJS.ErrnoException, data: ILightsApiResponse) => void): void; + + + /** + * Obtains the status of the specified light. + * + * @param id The id of the light as an integer, this value will be parsed into an integer value so can be a {String} or + * {Number} value. + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the light status, or {null} if a callback function was provided. + */ + lightStatus(id: string | number): Promise; + //lightStatus(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + getLightStatus(id: string | number): Promise; + //getLightStatus(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + + lightStatusWithRGB(id: string | number): Promise; + //lightStatusWithRGB(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + getLightStatusWithRGB(id: string | number): Promise; + //getLightStatusWithRGB(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + + + /** + * Obtains the new lights found by the bridge, dependant upon the last search. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the new lights search result, or {null} if a callback function was provided. + */ + newLights(): Promise; + //newLights(cb: (err: NodeJS.ErrnoException, data: INewLightsResponse) => void): void; + getNewLights(): Promise; + //getNewLights(cb: (err: NodeJS.ErrnoException, data: INewLightsResponse) => void): void; + + + /** + * Starts a search for new lights. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the new lights, or {null} if a callback function was provided. + */ + searchForNewLights(): Promise; + //searchForNewLights(cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Sets the name of a light on the Bridge. + * + * @param id The ID of the light to set the name for. + * @param name The name to apply to the light. + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the results of setting the name, or {null} if a callback function was provided. + */ + setLightName(id: string | number, name: string): Promise; + //setLightName(id: string|number, name: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Sets the light state to the provided values. + * + * @param id The id of the light which is an integer or a value that can be parsed into an integer value. + * @param stateValues {lightState.State} containing the properties and values to set on the light. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will set the specified state on the light, or {null} if a callback was provided. + */ + setLightState(id: string | number, stateValues: lightState.State | Object): Promise; + //setLightState(id: string|number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Sets the light state to the provided values for an entire group. + * + * @param id The id of the group which is an integer or a value that can be parsed into an integer value. + * @param stateValues {lightState.State} containing the properties and values to set on the light. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {Q.promise} A promise that will set the specified state on the group, or {null} if a callback was provided. + */ + setGroupLightState(id: string | number, stateValues: lightState.State | Object): Promise; + //setGroupLightState(id: string|number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Obtains all the groups from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the groups, or {null} if a callback was provided. + */ + groups(): Promise; + //groups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getGroups(): Promise; + //getGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getAllGroups(): Promise; + //getAllGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + + /** + * Obtains all the Luminaires from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the luminaires, or {null} if a callback was provided. + */ + luminaires(): Promise; + //luminaires(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getLuminaires(): Promise; + //getLuminaires(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + /** + * Obtains all the LightSources from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the lightsources, or {null} if a callback was provided. + */ + lightSources(): Promise; + //lightSources(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getLightSources(): Promise; + //getLightSources(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + /** + * Obtains all the LightGroups from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the LightGroups, or {null} if a callback was provided. + */ + lightGroups(): Promise; + //lightGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getLightGroups(): Promise; + //getLightGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + + /** + * Obtains the details for a specified group in a format of {id: {*}, name: {*}, lights: [], lastAction: {*}}. + * + * @param id {Number} or {String} which is the id of the group to get the details for. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will set the specified state on the light, or {null} if a callback was provided. + */ + getGroup(id: string | number): Promise; + group(id: string | number): Promise; + + /** + * Updates a light group to the specified name and/or lights ids. The name and light ids can be specified independently or + * together when calling this function. + * + * @param id The id of the group to update the name and/or light ids associated with it. + * @param name {String} The name of the group + * @param lightIds {Array} An array of light ids to be assigned to the group. If any of the ids are not present in the + * bridge the creation will fail with an error being produced. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise with a result of if the update was successful, or null if a callback was provided. + */ + + updateGroup(id: string | number, name: string, lightIds: string[]): Promise; + updateGroup(id: string | number, name: string, lightIds: string[], cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Creates a new light Group. + * + * @param name The name of the group that we are creating, limited to 16 characters. + * @param lightIds {Array} of ids for the lights to be included in the group. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the group that was created, or null if a callback was provided. + */ + createGroup(name: string, lightIds: string[]): Promise; + //createGroup(name: string, lightIds: string[], cb: (err: NodeJS.ErrnoException, data: string) => void): void; + + /** + * Deletes a group with the specified id, returning if the action was successful. + * + * @param id The id of the group to delete. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return if the deletion was successful, or null if a callback was provided. + */ + deleteGroup(id: string | number): Promise; + //deleteGroup(id: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Gets the schedules on the Bridge, as an array of {"id": {String}, "name": {String}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the results or if a callback was provided. + */ + schedules(): Promise; + //schedules(cb: (err: NodeJS.ErrnoException, data: ISchedule[]) => void): void; + getSchedules(): Promise; + //getSchedules(cb: (err: NodeJS.ErrnoException, data: ISchedule[]) => void): void; + + /** + * Gets the specified schedule by id, which is in an identical format the the Hue API documentation, with the addition + * of an "id" value for the schedule. + * + * @param id The id of the schedule to retrieve. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @returns A promise that will return the results or if a callback was provided. + */ + schedule(id: string | number): Promise; + //schedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void; + getSchedule(id: string | number): Promise; + //getSchedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void; + + /** + * Creates a one time scheduled event. The results from this function is the id of the created schedule. The bridge only + * supports 100 schedules, so once they are triggered, they are removed from the bridge. + * + * @param schedule {ScheduledEvent} + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the id value of the schedule that was created, or if a callback was provided. + */ + scheduleEvent(schedule: ISchedule): Promise; + //scheduleEvent(schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + createSchedule(schedule: ISchedule): Promise; + //createSchedule(schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + + /** + * Deletes a schedule by id, returning {true} if the deletion was successful. + * + * @param id of the schedule + * @param cb An option callback function to use if you do not want to use a promise for the results. + * @return {Q.promise} A promise that will return the result of the deletion, or if a callback was provided. + */ + deleteSchedule(id: string | number): Promise; + //deleteSchedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: Object) => void): void; + + /** + * Updates an existing schedule event with the provided details. + * + * @param id The id of the schedule being updated. + * @param schedule The object containing the details to update for the existing schedule event. + * @param cb An optional callback function to use if you do not want to deal with a promise for the results. + * @return {Q.promise} A promise that will return the result, or if a callback was provided. + */ + updateSchedule(id: string | number, schedule: ISchedule): Promise; + //updateSchedule(id: string | number, schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void; + + /** + * Gets the scenes on the Bridge, as an array of {"id": {String}, "name": {String}, "lights": {Array}, "active": {Boolean}} + * objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the results or if a callback was provided. + */ + scenes(): Promise; + getScenes(): Promise; + + /** + * Obtains a scene by a given id. + * @param sceneId {String} The id of the scene to obtain. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the scene or if a callback was provided. + */ + scene(id: string | number): Promise; + //scene(id: string | number, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + getScene(id: string | number): Promise; + //getScene(id: string | number, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Deletes a Scene (that is stored inside the bridge, not in the lights). + * @param sceneId The ID for the scene to delete + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @returns {*} A promise that will return the result from deleting the scene or null if a callback was provided. + */ + deleteScene(id: string | number): Promise; + //deleteScene(id: string | number, cb: (err: NodeJS.ErrnoException, data: Object) => void): void; + + /** + * Creates a new Scene. + * When the scene is created, it will store the current state of the lights and will use those "current" settings + * when the scene is recalled/activated later. + * + * There are two variants to this function, one that accepts lightIds and a name and another that takes a Scene object. + * The former is to maintain backwards compatibility with the 1.2.x version of this library. + * + * @param scene Scene configuration to create + * @param lightIds {Array} of ids for the lights to be included in the scene. + * @param name {String} The name of the scene to be created. If one is not provided, then the id of the scene will become the name. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the scene that was created (as well as the values that make up the scene), + * or null if a callback was provided. + */ + createScene(scene: IScene): Promise; + createScene(lightIds: string[] | number[], name: string): Promise; + //createScene(scene: IScene, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + //createScene(lightIds: string[] | number[], cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Provides backwards compatibility for < 1.11.x versions of the Hue Bridge Firmware. + * @param lightIds Lights to include in the scene + * @param name Name to use for the scene + * @param cb An optional callback function to use if you do not want to use a promise chain for the results. + * @return {*} A promise that will return the id of the scene that was created (as well as the values that make up the scene), + * or null if a callback was provided. + */ + createBasicScene(lightIds: string[] | number[], name: string): Promise; + //createBasicScene(lightIds: string[] | number[], name: string, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Provides scene creation for >= 1.11.x firmware versions of the Hue Bridge. + * @param scene The Scene object containing the details of the scene to be created. + * @param cb An optional callback function to use if you do not want to use a promise chain for the results. + * @return {*} A promise that will return the id of the scene that was created (as well as the values that make up the scene), + * or null if a callback was provided. + */ + createAdvancedScene(scene: IScene): Promise; + //createAdvancedScene(scene: IScene, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Update the lights and/or name associated with a scene (or will create a new one if the + * sceneId is not present in the bridge). + * + * @param sceneId {String} The id for the scene in the bridge + * @param scene The configuration of the scene with the details to modify, which can be either a name or an array of + * light ids. + * @param storeLightState {Boolean} flag to save the current light state of the lights in the scene. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the scene that was updated and the light ids that are now set, + * or null if a callback was provided. + */ + updateScene(sceneId: string | number, scene: IScene, storeLightState: boolean): Promise; + //updateScene(sceneId: string | number, scene: IScene, storeLightState: boolean, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + modifyScene(sceneId: string | number, scene: IScene, storeLightState: boolean): Promise; + //modifyScene(sceneId: string | number, scene: IScene, storeLightState: boolean, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Modifies the light state of one of the lights in a scene. + * + * @param sceneId The scene id, which if it does not exist a new scene will be created. + * @param lightId integer The id of light that is having the state values set. + * @param stateValues {IState} containing the properties and values to set on the light. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the state values on the light, or {null} if a callback was provided. + */ + setSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object): Promise; + //setSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + updateSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object): Promise; + //updateSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + modifySceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object): Promise; + //modifySceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Helper-function that recalls a scene for a group using setGroupLightState. Reason for existence is simplicity for + * user. + * + * @param sceneId The id of the scene to activate, which is an integer or a value that can be parsed into an integer value. + * @param groupIdFilter An optional group filter to apply to the scene, to select a sub set of the lights in the scene. This can + * be {null} or {undefined} to not apply a filter. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will set activate the scene, or {null} if a callback was provided. + */ + activateScene(sceneId: string | number, groupIdFilter?: string | number): Promise; + //activateScene(sceneId: string|number, groupIdFilter: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + recallScene(sceneId: string | number, groupIdFilter?: string | number): Promise; + //recallScene(sceneId: string|number, groupIdFilter: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Obtains all the allowed timezones from the bridge. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the scene that was created, or null if a callback was provided. + */ + getTimezones(): Promise; + //getTimezones(cb: (err: NodeJS.ErrnoException, data: string[]) => void): void; + timezones(): Promise; + //timezones(cb: (err: NodeJS.ErrnoException, data: string[]) => void): void; + + } + + /** + * Alias for HueApi + */ + export type BridgeApi = HueApi; + + /** + * Alias for HueApi + */ + export type api = HueApi; + + /* + * Interface declarations + */ + + export interface IBridgeVersion { + name: string, + version: { + api: string, + software: string + } + } + + export interface IUpnpSearchResultItem { + id: string, + ipaddress: string + } + + export interface IBridgeIcon { + mimetype: string, + height: string, + width: string, + depth: string, + url: string + } + + export interface IBridgeDescription { + version: { + major: string, + minor: string + }, + url: string, + name: string, + manufacturer: string, + model: { + name: string, + description: string, + number: string, + serial: string, + udn: string + }, + icons?: IBridgeIcon[] + } + + export type BackupStatus = "idle" | "startmigration" | "fileready_disabled" | "prepare_restore" | "restoring"; + + export interface IBridgeConfig { + name: string, + zigbeechannel: number, + bridgeid: string, + mac: string, + dhcp: boolean, + ipaddress: string, + netmask: string, + gateway: string, + proxyaddress: string, + proxyport: number, + UTC: Date, + localtime: Date, + timezone: string, + modelid: string, + swversion: string, + apiversion: string, + swupdate: { + updatestate: number, + checkforupdate: boolean, + devicetypes: { + bridge: boolean, + lights: string[], + sensors: string[] + }, + url: string, + text: string, + notify: boolean + }, + linkbutton: boolean, + portalservices: boolean, + portalconnection: string, + portalstate: { + signedon: boolean, + incoming: boolean, + outgoing: boolean, + communication: string + }, + factorynew: boolean, + replacesbridgeid?: string, + backup: { + status: BackupStatus, + errorcode: number + }, + whitelist: { + [key: string]: { + "last use date": Date, + "create date": Date, + name: string + } + } + } + + /** + * 3 methods to set color of light, in order of precedence if multiple are set + * + * xy: Coordinates in CIE color space, + * ct: Color Temperature, + * hs: Hue and Saturation + */ + export type ColorMode = "xy" | "ct" | "hs"; + + /** + * Alert command + * + * none = stop, + * select = flash once, + * lselect = flash for 15 seconds + */ + export type LightAlert = "none" | "select" | "lselect"; + + export type LightEffect = "none" | "colorloop"; + + /** + * If not set when creating a group, default is LightGroup + */ + export type LightGroupType = "LightGroup" | "Room" | "Luminaire" | "LightSource"; + + /** + * If not set when creating a group, default is Other + */ + export type RoomType = + "Living room" | "Kitchen" | "Dining" | + "Bedroom" | "Kids bedroom" | "Bathroom" | + "Nursery" | "Recreation" | "Office" | + "Gym" | "Hallway" | "Toilet" | + "Front door" | "Garage Terrace" | "Garden" | + "Driveway" | "Carport" | "Other"; + + export interface IScene { + id: string; + name: string; + lights: number[]; + } + + export interface ILightGroup { + id: string, + name: string, + type: LightGroupType, + class?: RoomType, + action?: { + on: boolean, + bri: number, + hue: number, + sat: number, + xy: [number, number], + ct: number, + effect: LightEffect, + colormode: ColorMode + }, + lights?: string[] + + } + + export interface ILight { + id?: string, + manufacturername: string, + uniqueid: string, + state: { + rgb?: number[], + on: boolean, + bri: number, + hue?: number, + sat?: number, + xy?: [number, number], + ct?: number, + alert: LightAlert, + effect?: LightEffect, + colormode?: ColorMode, + reachable: boolean + }, + type: string, + name: string, + modelid: string, + swversion: string, + pointsymbol?: { + "1": string, + "2": string, + "3": string, + "4": string, + "5": string, + "6": string, + "7": string, + "8": string + } + } + + export interface ILightsApiResponse { + lights: ILight[] + } + + //State and config depend on sensor type + //TODO: definitions for different sensor types + export interface ISensor { + id?: string, + manufacturername: string, + uniqueid?: string, + state: { + [key: string]: number | string; + lastupdated: string; + }; + config: { + [key: string]: number | string; + }; + type: string, + name: string, + modelid: string, + swversion: string, + } + + export interface ISensorsApiResponse { + sensors: ISensor[] + } + + export interface ISchedule { + name: string, + description: string, + command: { + address: string, + body: { + on: boolean + }, + method: string + }, + time: Date + } + + export interface IState { + lights: { + [key: string]: ILight + }, + groups: { + [key: string]: ILightGroup + }, + config: IBridgeConfig, + schedules: { + [key: string]: ISchedule + } + } + + export interface IRegisteredUser { + name: string, + username: string, + created: Date, + accessed: Date + } + + export interface INewLightsResponse { + lastscan: string, + [key: string]: string | { name: string } + } + + /* + * lightState part + */ + + export module lightState { + + class State { + payload(): Object; + + /** + * Resets/Clears the properties that have been set in the light state object. + * @returns {State} + */ + reset(): State; + clear(): State; + + /** + * Creates a copy of the state object + * @returns {State} + */ + copy(): State; + + /** + * Sets the strict state for setting parameters for the light state. + * @param strict + * @returns {State} + */ + strict(): State; + + isStrict(): boolean; + + /** + * Sets the on state + * @param on The state (true for on, false for off). If this parameter is not specified, it is assumed to be true. + * @returns {State} + */ + on(on?: boolean): State; + + /** + * Adds the bri state + * @param value The hue bri value, 0 to 254. + * @return {State} + */ + bri(value: number): State; + + /** + * Adds the hue for the color desired. + * @param hue The hue value is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue. + * @returns {State} + */ + hue(hue: number): State; + + /** + * The saturation of the color for the bulb, 0 being the least saturated i.e. white. + * @param saturation The saturation value 0 to 255 + * @returns {State} + */ + sat(saturation: number): State; + + /** + * Adds the xy values + * @param x The x value ranged from 0 to 1, or an Array of [x, y] values + * @param y The y value ranged from 0 to 1 + * @return {State} + */ + xy(x: number, y: number): State; + + /** + * Adds the Mired Color Temperature + * @param colorTemp The Color Temperature between 153 to 500 inclusive. + * @returns {State} + */ + ct(colorTemp: number): State; + + /** + * Adds the alert state + * @param value A String value representing the alert state, "none", "select", "lselect". + * @return {State} + */ + alert(value: LightAlert): State; + + /** + * Adds an effect for the bulb. + * @param value The type of effect, currently supports "none" and "colorloop". + * @returns {State} + */ + effect(value: LightEffect): State; + + /** + * Adds a transition to the desired state. + * @param value This is given as a multiple of 100ms and defaults to 4 (400ms). + * @return {State} + */ + transitiontime(value: number): State; + + /** + * Increments/Decrements the brightness value for the lights. + * @param value An amount to change the current brightness by, -254 to 254. + * @returns {State} + */ + bri_inc(value: number): State; + + /** + * Increments/Decrements the saturation value for the lights. + * @param value An amount to change the current saturation by, -254 to 254. + * @returns {State} + */ + sat_inc(value: number): State; + + /** + * Increments/Decrements the Hue value for the lights. + * @param value An amount to change the current hue by, -65534 to 65534. + * @returns {State} + */ + hue_inc(value: number): State; + + /** + * Increments/Decrements the color temperature value for the lights. + * @param value An amount to change the current color temperature by, -65534 to 65534. + * @returns {State} + */ + ct_inc(value: number): State; + + /** + * Increments/Decrements the XY value for the lights. + * @param value An amount to change the current XY by, -0.5 to 0.5. + * @returns {State} + */ + xy_inc(value: number): State; + + scene(value: string): State; + + + /////////////////////////////////////////////////////////////////////// + // Convenience functions + + turnOn(): State; + + off(): State; + turnOff(): State; + + /** + * Set the brightness as a percent value + * @param percentage The brightness percentage value between 0 and 100. + * @returns {State} + */ + brightness(percentage: number): State; + + incrementBrightness(value: number): State; + + colorTemperature(value: number): State; + colourTemperature(value: number): State; + colorTemp(value: number): State; + colourTemp(value: number): State; + + incrementColorTemp(value: number): State; + incrementColorTemperature(value: number): State; + incrementColourTemp(value: number): State; + incrementColourTemperature(value: number): State; + + incrementHue(value: number): State; + + incrementXY(value: number): State; + + saturation(percentage: number): State; + + incrementSaturation(value: number): State; + + shortAlert(): State; + alertShort(): State; + + longAlert(): State; + alertLong(): State; + + transitionTime(value: number): State; + /** + * Sets the transition time in milliseconds. + * @param milliseconds The number of milliseconds for the transition + * @returns {State} + */ + transition(milliseconds: number): State; + + transitionSlow(): State; + + transitionFast(): State; + + transitionInstant(): State; + + transitionDefault(): State; + + /** + * Builds the White state for a lamp + * @param colorTemp The temperature, a value of 153-500 + * @param brightPercentage The percentage of brightness 0-100 + * @return {State} + */ + white(colorTemp: number, brightPercentage: number): State; + + /** + * Adds the HSL values + * @param hue The hue value in degrees 0-360 + * @param saturation The saturation percentage 0-100 + * @param luminosity The luminosity percentage 0-100 + * @return {State} + */ + hsl(hue: number, saturation: number, luminosity: number): State; + + /** + * Adds the HSB values + * @param hue The hue value in degrees 0-360 + * @param saturation The saturation percentage 0-100 + * @param brightness The brightness percentage 0-100 + * @return {State} + */ + hsb(hue: number, saturation: number, brightness: number): State; + + /** + * Adds the rgb color to the state. This requires knowledge of the light type to be able to convert it into + * an actual color that the map can display. + * + * @param r The amount of Red 0-255, or an {Array} or r, g, b values. + * @param g The amount of Green 0-255 + * @param b The amount of Blue 0-255 + * @return {State} + */ + rgb(r: number, g: number, b: number): State; + + hasRGB(): boolean; + + colorLoop(): State; + colourLoop(): State; + effectColorLoop(): State; + effectColourLoop(): State; + + /** + * Creates a copy of the State if there is an RGB value set. + * + * @param modelid The model ID of the light(s) to convert the rgb value for. + * + * @returns {State} If there is an RGB value set, then a copy of the state, with the rgb value applied based on the + * lamp model provided. If there is no RGB value set, then {null} will be returned. + */ + applyRGB(modelid: string): State; + } + + function create(values?: Object): State; + function isLightState(obj: Object): obj is State; + } +} \ No newline at end of file diff --git a/node-hue-api/node-hue-api-tests.ts b/node-hue-api/node-hue-api-tests.ts new file mode 100644 index 0000000000..44903fa4da --- /dev/null +++ b/node-hue-api/node-hue-api-tests.ts @@ -0,0 +1,22 @@ +/// + +import hue = require('node-hue-api'); + +hue.nupnpSearch().then(function (bridges) { + if (!bridges || !bridges[0]) { + throw "No bridge found"; + } + let ip = bridges[0].ipaddress; + //First load username from file. Register if there's no file. + let api = new hue.HueApi(); + api.registerUser(ip).then(newUser => { + console.log("Created Hue user: " + JSON.stringify(newUser)); + }).then(listScenes.bind(this, api)); +}) + + +function listScenes(api: hue.HueApi) { + return api.getScenes().then(function (scenes) { + return console.log(scenes.map(s => s.name).join(", ")); + }); +} \ No newline at end of file diff --git a/node-hue-api/tsconfig.json b/node-hue-api/tsconfig.json new file mode 100644 index 0000000000..519af60856 --- /dev/null +++ b/node-hue-api/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-hue-api-tests.ts" + ] +} \ No newline at end of file From ac7fdf1498d60ec322c24e3b2919e7282b7e221e Mon Sep 17 00:00:00 2001 From: Yu Jianrong Date: Fri, 9 Dec 2016 00:16:35 +0800 Subject: [PATCH 02/19] Add declaration for node.xml (#13093) --- xml/index.d.ts | 49 ++++++++++++++ xml/tsconfig.json | 19 ++++++ xml/tslint.json | 1 + xml/xml-tests.ts | 163 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 xml/index.d.ts create mode 100644 xml/tsconfig.json create mode 100644 xml/tslint.json create mode 100644 xml/xml-tests.ts diff --git a/xml/index.d.ts b/xml/index.d.ts new file mode 100644 index 0000000000..8c5d5179ca --- /dev/null +++ b/xml/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for xml 1.0 +// Project: http://github.com/dylang/node-xml +// Definitions by: Jianrong Yu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +interface Option { + /** + * String used for tab, defaults to no tabs (compressed) + */ + indent?: string; + /** + * Return the result as a `stream` (default false) + */ + stream?: boolean; + /** + * Add default xml declaration (default false) + */ + declaration?: boolean | { + encoding?: string; + standalone?: string; + }; +} + +interface XmlAttrs { + [attr: string]: string; +} +interface XmlDescArray { + [index: number]: { _attr: XmlAttrs } | XmlObject; +} +interface ElementObject { + push(xmlObject: XmlObject): void; + close(xmlObject?: XmlObject): void; +} + +type XmlAtom = string | number | boolean; +type XmlDesc = { _attr: XmlAttrs } | { _cdata: string } | { _attr: XmlAttrs, _cdata: string } | XmlAtom | XmlAtom[] | XmlDescArray; +type XmlObject = { [tag: string]: ElementObject | XmlDesc } | XmlDesc; + +declare namespace xml { + function element(...xmlObjects: XmlObject[]): ElementObject; + function Element(...xmlObjects: XmlObject[]): ElementObject; +} + +declare function xml(xmlObject: XmlObject | XmlObject[], options: { stream: true, indent?: string }): NodeJS.ReadableStream; +declare function xml(xmlObject?: XmlObject | XmlObject[], options?: boolean | string | Option): string; + +export = xml; diff --git a/xml/tsconfig.json b/xml/tsconfig.json new file mode 100644 index 0000000000..48e5377f30 --- /dev/null +++ b/xml/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "xml-tests.ts" + ] +} diff --git a/xml/tslint.json b/xml/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/xml/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/xml/xml-tests.ts b/xml/xml-tests.ts new file mode 100644 index 0000000000..df8acf6ef9 --- /dev/null +++ b/xml/xml-tests.ts @@ -0,0 +1,163 @@ +// Code get from the test file of http://github.com/dylang/node-xml + +import * as xml from "xml"; + +interface Tester { + is(a: any, b: any): void; + same(a: any, b: any): void; + plan(id: number): void; + ok(a: any): void; +}; + +function test(c: string, f: (t: Tester) => void) { + return; +} + + +test('no elements', t => { + t.is(xml(), ''); + t.is(xml([]), ''); + t.is(xml('test'), 'test'); + t.is(xml('scotch & whisky'), 'scotch & whisky'); + t.is(xml('bob\'s escape character'), 'bob's escape character'); +}); + +test('simple options', t => { + t.is(xml([{a: {}}]), ''); + t.is(xml([{a: null}]), ''); + t.is(xml([{a: []}]), ''); + t.is(xml([{a: -1}]), '-1'); + t.is(xml([{a: false}]), 'false'); + t.is(xml([{a: 'test'}]), 'test'); + t.is(xml({a: {}}), ''); + t.is(xml({a: null}), ''); + t.is(xml({a: []}), ''); + t.is(xml({a: -1}), '-1'); + t.is(xml({a: false}), 'false'); + t.is(xml({a: 'test'}), 'test'); + t.is(xml([{a: 'test'}, {b: 123}, {c: -0.5}]), 'test123-0.5'); +}); + +test('deeply nested objects', t => { + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}]), '123'); +}); + +test('indents property', t => { + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}], true), '\n \n 1\n 2\n 3\n \n'); + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}], ' '), '\n \n 1\n 2\n 3\n \n'); + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}], '\t'), '\n\t\n\t\t1\n\t\t2\n\t\t3\n\t\n'); + t.is(xml({guid: [{_attr: {premalink: true}}, 'content']}, true), 'content'); +}); + +test('supports xml attributes', t => { + t.is(xml([{b: {_attr: {}}}]), ''); + t.is(xml([{ + a: { + _attr: { + attribute1: 'some value', + attribute2: 12345 + } + } + }]), ''); + t.is(xml([{ + a: [{ + _attr: { + attribute1: 'some value', + attribute2: 12345 + } + }] + }]), ''); + t.is(xml([{ + a: [{ + _attr: { + attribute1: 'some value', + attribute2: 12345 + } + }, 'content'] + }]), 'content'); +}); + +test('supports cdata', t => { + t.is(xml([{a: {_cdata: 'This is some CDATA'}}]), 'CDATA]]>'); + t.is(xml([{ + a: { + _attr: {attribute1: 'some value', attribute2: 12345}, + _cdata: 'This is some CDATA' + } + }]), 'CDATA]]>'); + t.is(xml([{a: {_cdata: 'This is some CDATA with ]]> and then again ]]>'}}]), 'CDATA with ]]]]> and then again ]]]]>]]>'); +}); + +test('supports encoding', t => { + t.is(xml([{ + a: [{ + _attr: { + anglebrackets: 'this is strong', + url: 'http://google.com?s=opower&y=fun' + } + }, 'text'] + }]), 'text'); +}); + +test('supports stream interface', t => { + const elem = xml.element({_attr: {decade: '80s', locale: 'US'}}); + const xmlStream = xml({toys: elem}, {stream: true}); + const results = ['', 'Transformers', 'He-man', 'GI Joe', '']; + + elem.push({toy: 'Transformers'}); + elem.push({toy: [{name: 'He-man'}]}); + elem.push({toy: 'GI Joe'}); + elem.close(); + + xmlStream.on('data', (stanza: any[]) => { + t.is(stanza, results.shift()); + }); + + return new Promise( (resolve, reject) => { + xmlStream.on('close', () => { + t.same(results, []); + resolve(); + }); + xmlStream.on('error', reject); + }); +}); + +test('streams end properly', t => { + const elem = xml.element({ _attr: { decade: '80s', locale: 'US'} }); + const xmlStream = xml({ toys: elem }, { stream: true }); + + let gotData = false; + + t.plan(7); + + elem.push({ toy: 'Transformers' }); + elem.push({ toy: 'GI Joe' }); + elem.push({ toy: [{name:'He-man'}] }); + elem.close(); + + xmlStream.on('data', (data: any) => { + t.ok(data); + gotData = true; + }); + + xmlStream.on('end', () => { + t.ok(gotData); + }); + + return new Promise( (resolve, reject) => { + xmlStream.on('close', () => { + t.ok(gotData); + resolve(); + }); + xmlStream.on('error', reject); + }); +}); + +test('xml declaration options', t => { + t.is(xml([{a: 'test'}], {declaration: true}), 'test'); + t.is(xml([{a: 'test'}], {declaration: {encoding: 'foo'}}), 'test'); + t.is(xml([{a: 'test'}], {declaration: {standalone: 'yes'}}), 'test'); + t.is(xml([{a: 'test'}], {declaration: false}), 'test'); + t.is(xml([{a: 'test'}], {declaration: true, indent: '\n'}), '\ntest'); + t.is(xml([{a: 'test'}], {}), 'test'); +}); \ No newline at end of file From e2eff850c6aacd2c2912fd022c7d02c5b399651a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20B=C3=A9rtolo?= Date: Thu, 8 Dec 2016 16:41:41 +0000 Subject: [PATCH 03/19] fix SchemaOptions.versionKey type https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13163#issuecomment-265632279 --- mongoose/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index e7446fccc3..a0508e7223 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -717,7 +717,7 @@ declare module "mongoose" { /** defaults to true */ validateBeforeSave?: boolean; /** defaults to "__v" */ - versionKey?: string; + versionKey?: string|boolean; /** * skipVersioning allows excluding paths from * versioning (the internal revision will not be From d0c8f10aa17c6cb5af1b213cbd72d19de91d24bb Mon Sep 17 00:00:00 2001 From: Matt Martin Date: Thu, 8 Dec 2016 09:31:32 -0800 Subject: [PATCH 04/19] Adding onReadyStateChange callback to setVariables `this.props.relay.setVariables` takes an optional callback that's not currently represented in the types. Just adding that. See this answer on StackOverflow for a high-level overview: http://stackoverflow.com/questions/35471836/loading-indicator-after-this-props-relay-setvariables-triggered-fetch And the docs have more detailed information about what the callback provides: https://facebook.github.io/relay/docs/guides-ready-state.html --- react-relay/index.d.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 3731f9ca5d..5aedbf914f 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -103,8 +103,31 @@ declare module "react-relay" { renderFailure?(error: Error, retry: Function): JSX.Element } + type ReadyStateEvent = + 'ABORT' | + 'CACHE_RESTORED_REQUIRED' | + 'CACHE_RESTORE_FAILED' | + 'CACHE_RESTORE_START' | + 'NETWORK_QUERY_ERROR' | + 'NETWORK_QUERY_RECEIVED_ALL' | + 'NETWORK_QUERY_RECEIVED_REQUIRED' | + 'NETWORK_QUERY_START' | + 'STORE_FOUND_ALL' | + 'STORE_FOUND_REQUIRED'; + + interface OnReadyStateChange { + (readyState: { + ready: boolean, + done: boolean, + stale: boolean, + error?: Error, + events: Array, + aborted: boolean + }): void + } + interface RelayProp { - variables: any - setVariables(variables: Object): void + variables: any + setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void } } From b469c76ea5507a86875d98fb25d1fe59bccdbebc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Dec 2016 09:57:56 -0800 Subject: [PATCH 05/19] "types" in tsconfig should be empty. --- babel-code-frame/babel-code-frame-tests.ts | 24 ++++++++----------- babel-code-frame/tsconfig.json | 4 +--- graphql-relay/tsconfig.json | 4 +--- iconv-lite/tsconfig.json | 4 +--- incremental-dom/incremental-dom-tests.ts | 1 + incremental-dom/tsconfig.json | 4 +--- jcanvas/tsconfig.json | 4 +--- n3/tsconfig.json | 4 +--- protractor-helpers/index.d.ts | 2 -- .../protractor-helpers-tests.ts | 2 +- protractor-helpers/tsconfig.json | 2 +- protractor-http-mock/tsconfig.json | 2 +- react-daterange-picker/tsconfig.json | 2 +- react-easy-chart/tsconfig.json | 2 +- react-test-renderer/tsconfig.json | 4 +--- waterline/index.d.ts | 2 ++ waterline/tsconfig.json | 5 +--- 17 files changed, 26 insertions(+), 46 deletions(-) diff --git a/babel-code-frame/babel-code-frame-tests.ts b/babel-code-frame/babel-code-frame-tests.ts index 875af43d3a..1177570acd 100644 --- a/babel-code-frame/babel-code-frame-tests.ts +++ b/babel-code-frame/babel-code-frame-tests.ts @@ -1,18 +1,14 @@ import codeFrame from "babel-code-frame"; -describe('babel-code-frame', () => { - it('frames given code', () => { - const code = ` - const number = 1; - var string = 'foo'; +const code = ` + const number = 1; + var string = 'foo'; - function print(name: string) { - console.log(string + name); - } - `; + function print(name: string) { + console.log(string + name); + } +`; - codeFrame(code, 5, 22); - codeFrame(code, 5, 22, { forceColor: true }); - codeFrame(code, 2, 2, { highlightCode: true }); - }); -}); +codeFrame(code, 5, 22); +codeFrame(code, 5, 22, { forceColor: true }); +codeFrame(code, 2, 2, { highlightCode: true }); diff --git a/babel-code-frame/tsconfig.json b/babel-code-frame/tsconfig.json index 25631aac91..76b559d0d8 100644 --- a/babel-code-frame/tsconfig.json +++ b/babel-code-frame/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "mocha" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/graphql-relay/tsconfig.json b/graphql-relay/tsconfig.json index bf46522ecc..1dcd8abe66 100644 --- a/graphql-relay/tsconfig.json +++ b/graphql-relay/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "graphql" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/iconv-lite/tsconfig.json b/iconv-lite/tsconfig.json index a9833e3458..5c0b70bff2 100644 --- a/iconv-lite/tsconfig.json +++ b/iconv-lite/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/incremental-dom/incremental-dom-tests.ts b/incremental-dom/incremental-dom-tests.ts index 19f39e235f..2e30297e57 100644 --- a/incremental-dom/incremental-dom-tests.ts +++ b/incremental-dom/incremental-dom-tests.ts @@ -1,3 +1,4 @@ +/// declare var expect: any; import id = require('incremental-dom'); diff --git a/incremental-dom/tsconfig.json b/incremental-dom/tsconfig.json index 9e2f677265..56ffdff383 100644 --- a/incremental-dom/tsconfig.json +++ b/incremental-dom/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "mocha" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/jcanvas/tsconfig.json b/jcanvas/tsconfig.json index 6f92aa9018..e2564f5a45 100644 --- a/jcanvas/tsconfig.json +++ b/jcanvas/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/n3/tsconfig.json b/n3/tsconfig.json index 53af13b215..10bad1929f 100644 --- a/n3/tsconfig.json +++ b/n3/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/protractor-helpers/index.d.ts b/protractor-helpers/index.d.ts index 80314e8aa7..3ab4691778 100644 --- a/protractor-helpers/index.d.ts +++ b/protractor-helpers/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: John Cant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// /// // ElementArrayFinder diff --git a/protractor-helpers/protractor-helpers-tests.ts b/protractor-helpers/protractor-helpers-tests.ts index 269390080e..9b03e43005 100644 --- a/protractor-helpers/protractor-helpers-tests.ts +++ b/protractor-helpers/protractor-helpers-tests.ts @@ -1,4 +1,4 @@ - +/// import helpers = require('protractor-helpers'); diff --git a/protractor-helpers/tsconfig.json b/protractor-helpers/tsconfig.json index 897492ad71..83c6364510 100644 --- a/protractor-helpers/tsconfig.json +++ b/protractor-helpers/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", - "types": ["jasmine", "selenium-webdriver"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/protractor-http-mock/tsconfig.json b/protractor-http-mock/tsconfig.json index bad3dc76e2..e08b9ae838 100644 --- a/protractor-http-mock/tsconfig.json +++ b/protractor-http-mock/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", - "types": ["selenium-webdriver"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/react-daterange-picker/tsconfig.json b/react-daterange-picker/tsconfig.json index 658e569c10..483eb047c1 100644 --- a/react-daterange-picker/tsconfig.json +++ b/react-daterange-picker/tsconfig.json @@ -11,7 +11,7 @@ "paths": { "*": ["*", "react-daterange-picker/node_modules/*"] }, - "types": ["moment-range", "react"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, "jsx": "react" diff --git a/react-easy-chart/tsconfig.json b/react-easy-chart/tsconfig.json index fa7efaac28..36fff7f006 100644 --- a/react-easy-chart/tsconfig.json +++ b/react-easy-chart/tsconfig.json @@ -9,7 +9,7 @@ "typeRoots": [ "../" ], - "types": ["react"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/react-test-renderer/tsconfig.json b/react-test-renderer/tsconfig.json index b6bc79303e..e5ac05f506 100644 --- a/react-test-renderer/tsconfig.json +++ b/react-test-renderer/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "react" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/waterline/index.d.ts b/waterline/index.d.ts index 15c88ec8cf..6525e699b6 100644 --- a/waterline/index.d.ts +++ b/waterline/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Alexandro Libertino // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + import BluebirdPromise = require("bluebird"); declare namespace Waterline { type Adapter = Object; diff --git a/waterline/tsconfig.json b/waterline/tsconfig.json index d53e4133d4..bc53759038 100644 --- a/waterline/tsconfig.json +++ b/waterline/tsconfig.json @@ -8,10 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node", - "bluebird" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From 3a4b1cf0622f9b35788370b89b82c60948555d0f Mon Sep 17 00:00:00 2001 From: Delaney Gillilan Date: Thu, 8 Dec 2016 10:46:42 -0800 Subject: [PATCH 06/19] Include optional email and request in callback. --- passport-twitter/index.d.ts | 3 +++ passport-twitter/passport-twitter-tests.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/passport-twitter/index.d.ts b/passport-twitter/index.d.ts index ee0ad9ea4b..c4cc69c23f 100644 --- a/passport-twitter/index.d.ts +++ b/passport-twitter/index.d.ts @@ -24,6 +24,9 @@ interface IStrategyOption { consumerSecret: string; callbackURL: string; + passReqToCallback?: true; + includeEmail?: true; + reguestTokenURL?: string; accessTokenURL?: string; userAuthorizationURL?: string; diff --git a/passport-twitter/passport-twitter-tests.ts b/passport-twitter/passport-twitter-tests.ts index 815d490610..66355a2f31 100644 --- a/passport-twitter/passport-twitter-tests.ts +++ b/passport-twitter/passport-twitter-tests.ts @@ -15,7 +15,9 @@ var User = { passport.use(new twitter.Strategy({ consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY, consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET, - callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL + callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL, + passReqToCallback : true, + includeEmail: true }, function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) { User.findOrCreate(profile.id, profile.provider, function(err, user) { From 8789bb745d0cd89be97cde071ec55916e02536a3 Mon Sep 17 00:00:00 2001 From: Delaney Gillilan Date: Thu, 8 Dec 2016 10:51:14 -0800 Subject: [PATCH 07/19] update header per pull request template --- passport-twitter/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/passport-twitter/index.d.ts b/passport-twitter/index.d.ts index c4cc69c23f..387fa7ab44 100644 --- a/passport-twitter/index.d.ts +++ b/passport-twitter/index.d.ts @@ -1,5 +1,5 @@ -// Type definitions for passport-facebook 1.0.3 -// Project: https://github.com/jaredhanson/passport-facebook +// Type definitions for passport-twitter 1.0.4 +// Project: https://github.com/jaredhanson/passport-twitter // Definitions by: James Roland Cabresos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From f599b183065bf4a8074d10f86817a026498131e3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Dec 2016 14:12:51 -0800 Subject: [PATCH 08/19] Added declarations for 'is-binary-path'. (#13173) * Added declarations for 'is-binary-path'. * Ensure 'is-binary-path' returns a 'boolean'. --- is-binary-path/index.d.ts | 7 +++++++ is-binary-path/is-binary-path-tests.ts | 5 +++++ is-binary-path/tsconfig.json | 19 +++++++++++++++++++ is-binary-path/tslint.json | 1 + 4 files changed, 32 insertions(+) create mode 100644 is-binary-path/index.d.ts create mode 100644 is-binary-path/is-binary-path-tests.ts create mode 100644 is-binary-path/tsconfig.json create mode 100644 is-binary-path/tslint.json diff --git a/is-binary-path/index.d.ts b/is-binary-path/index.d.ts new file mode 100644 index 0000000000..9d825e6ae3 --- /dev/null +++ b/is-binary-path/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-binary-path 2.0 +// Project: https://github.com/sindresorhus/is-binary-path +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_binary_path; +declare function is_binary_path(filepath: string): boolean; diff --git a/is-binary-path/is-binary-path-tests.ts b/is-binary-path/is-binary-path-tests.ts new file mode 100644 index 0000000000..967346a35a --- /dev/null +++ b/is-binary-path/is-binary-path-tests.ts @@ -0,0 +1,5 @@ +import isBinaryPath = require("is-binary-path"); + +let a: boolean = isBinaryPath("src/unicorn.png"); + +let b: boolean = isBinaryPath("src/unicorn.txt"); \ No newline at end of file diff --git a/is-binary-path/tsconfig.json b/is-binary-path/tsconfig.json new file mode 100644 index 0000000000..4914ee401d --- /dev/null +++ b/is-binary-path/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-binary-path-tests.ts" + ] +} diff --git a/is-binary-path/tslint.json b/is-binary-path/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-binary-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From edfee9d9ee967be4f9d69d8293431e2d8a556ac2 Mon Sep 17 00:00:00 2001 From: Stefan Reichel Date: Thu, 8 Dec 2016 23:15:16 +0100 Subject: [PATCH 09/19] Added declarations for content-disposition (#13191) * Added declarations for content-disposition * Fixed missing semicolon * Added empty function * Made ContentDisposition an interface instead of a class * Filename may be undefined but not void --- .../content-disposition-tests.ts | 10 ++++++++ content-disposition/index.d.ts | 24 +++++++++++++++++++ content-disposition/tsconfig.json | 19 +++++++++++++++ content-disposition/tslint.json | 1 + 4 files changed, 54 insertions(+) create mode 100644 content-disposition/content-disposition-tests.ts create mode 100644 content-disposition/index.d.ts create mode 100644 content-disposition/tsconfig.json create mode 100644 content-disposition/tslint.json diff --git a/content-disposition/content-disposition-tests.ts b/content-disposition/content-disposition-tests.ts new file mode 100644 index 0000000000..4c4125fa2a --- /dev/null +++ b/content-disposition/content-disposition-tests.ts @@ -0,0 +1,10 @@ +import contentDisposition = require("content-disposition"); + +const noParams = contentDisposition(); +const withFilenameNoOptions = contentDisposition("EURO rates.txt"); +const withFilenameAndOptions = contentDisposition("€ rates.txt", { type: "attachment", fallback: "EURO rates.txt" }); +const noFilename = contentDisposition(undefined, { type: "attachment", fallback: true }); + +const res = contentDisposition.parse('attachment; filename="EURO rates.txt"'); +const type = res.type; +const parameters = res.parameters; diff --git a/content-disposition/index.d.ts b/content-disposition/index.d.ts new file mode 100644 index 0000000000..56ea66f8ca --- /dev/null +++ b/content-disposition/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for content-disposition 0.5 +// Project: https://github.com/jshttp/content-disposition +// Definitions by: Stefan Reichel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace contentDisposition { + export interface ContentDisposition { + type: string; + parameters: any; + } + + export interface Options { + type?: string; + fallback?: string | boolean; + } + + export function parse(contentDispositionHeader: string): ContentDisposition; +} + +declare function contentDisposition(): string; +declare function contentDisposition(filename: undefined, options: contentDisposition.Options): string; +declare function contentDisposition(filename: string, options?: contentDisposition.Options): string; + +export = contentDisposition; diff --git a/content-disposition/tsconfig.json b/content-disposition/tsconfig.json new file mode 100644 index 0000000000..179228e4d6 --- /dev/null +++ b/content-disposition/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "content-disposition-tests.ts" + ] +} diff --git a/content-disposition/tslint.json b/content-disposition/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/content-disposition/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From b7ca3c74bd3190bed4f3e0cf49f8de0fd0c00ccb Mon Sep 17 00:00:00 2001 From: Fred Morel Date: Thu, 8 Dec 2016 18:16:26 -0500 Subject: [PATCH 10/19] Attempt to pass review --- node-hue-api/index.d.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/node-hue-api/index.d.ts b/node-hue-api/index.d.ts index 4d0bc36181..50467da2b1 100644 --- a/node-hue-api/index.d.ts +++ b/node-hue-api/index.d.ts @@ -5,10 +5,6 @@ /// -// Functions that are deprecated, not working, or returning callbacks instead of promises were not documented. - -declare module "node-hue-api" { - //Not documented because it says it's broken //export function connect(config) : HueApi; @@ -1071,5 +1067,4 @@ declare module "node-hue-api" { function create(values?: Object): State; function isLightState(obj: Object): obj is State; - } -} \ No newline at end of file + } \ No newline at end of file From c4baa7c8393768a8b86f66c8b83ae6ae2a74898a Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 9 Dec 2016 08:37:37 -0800 Subject: [PATCH 11/19] Upgrade node version used by travis (#13234) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4db6a14a5b..c8c468a417 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - 6.9.1 + - 6.9.2 sudo: false From fd18042829bc98599cb23fd1f52e9f8661ad171d Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 9 Dec 2016 08:43:45 -0800 Subject: [PATCH 12/19] Vue provides its own typings (#13230) --- notNeededPackages.json | 6 + vue-resource/package.json | 5 + vue-router/package.json | 5 + vue/index.d.ts | 268 ------------------------------------ vue/tsconfig.json | 19 --- vue/vue-tests.ts | 276 -------------------------------------- 6 files changed, 16 insertions(+), 563 deletions(-) create mode 100644 vue-resource/package.json create mode 100644 vue-router/package.json delete mode 100644 vue/index.d.ts delete mode 100644 vue/tsconfig.json delete mode 100644 vue/vue-tests.ts diff --git a/notNeededPackages.json b/notNeededPackages.json index 472a3881ca..eee68b5219 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -94,6 +94,12 @@ "typingsPackageName": "normalizr", "sourceRepoURL": "https://github.com/paularmstrong/normalizr", "asOfVersion": "2.0.18" + }, + { + "libraryName": "vuejs", + "typingsPackageName": "vue", + "sourceRepoURL": "https://github.com/vuejs/vue", + "asOfVersion": "2.0.0" } ] } diff --git a/vue-resource/package.json b/vue-resource/package.json new file mode 100644 index 0000000000..1fe0305da3 --- /dev/null +++ b/vue-resource/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@types/vue": "^1.0.31" + } +} diff --git a/vue-router/package.json b/vue-router/package.json new file mode 100644 index 0000000000..1fe0305da3 --- /dev/null +++ b/vue-router/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@types/vue": "^1.0.31" + } +} diff --git a/vue/index.d.ts b/vue/index.d.ts deleted file mode 100644 index 02e4f70463..0000000000 --- a/vue/index.d.ts +++ /dev/null @@ -1,268 +0,0 @@ -// Type definitions for vuejs 1.0.21 -// Project: https://github.com/vuejs/vue -// Definitions by: odangosan , kaorun343 -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface Array { - $remove(item: T): Array; - $set(index: any, val: T): T; -} - -declare namespace vuejs { - - interface PropOption { - type?: { new (...args: any[]): any; } | { new (...args: any[]): any; }[]; - required?: boolean; - default?: any; - twoWay?: boolean; - validator?(value: any): boolean; - coerce?(value: any): any; - } - - interface ComputedOption { - get(): any; - set(value: any): void; - } - - interface WatchOption { - handler(val: any, oldVal: any): void; - deep?: boolean; - immidiate?: boolean; - } - - interface DirectiveOption { - bind?(): any; - update?(newVal?: any, oldVal?: any): any; - unbind?(): any; - params?: string[]; - deep?: boolean; - twoWay?: boolean; - acceptStatement?: boolean; - terminal?: boolean; - priority?: number; - [key: string]: any; - } - - interface Directive { - el: HTMLElement; - vm: Vue; - expression: string; - arg?: string; - name: string; - modifiers: { [key: string]: boolean }; - descriptor: any; - params?: { [key: string]: any }; - } - - interface FilterOption { - read?: Function; - write?: Function; - } - - interface TransitionOption { - css?: boolean; - animation?: string; - enterClass?: string; - leaveClass?: string; - beforeEnter?(el: HTMLElement): void; - enter?(el: HTMLElement, done?: () => void): void; - afterEnter?(el: HTMLElement): void; - enterCancelled?(el: HTMLElement): void; - beforeLeave?(el: HTMLElement): void; - leave?(el: HTMLElement, done?: () => void): void; - afterLeave?(el: HTMLElement): void; - leaveCancelled?(el: HTMLElement): void; - stagger?(index: number): number; - enterStagger?(index: number): number; - leaveStagger?(index: number): number; - [key: string]: any; - } - - interface ComponentOption { - data?: { [key: string]: any } | Function; - props?: string[] | { [key: string]: (PropOption | { new (...args: any[]): any; } | { new (...args: any[]): any; }[]) }; - computed?: { [key: string]: (Function | ComputedOption) }; - methods?: { [key: string]: Function }; - watch?: { [key: string]: ((val: any, oldVal: any) => void) | string | WatchOption }; - el?: string | HTMLElement | (() => HTMLElement); - template?: string; - replace?: boolean; - init?(): void; - created?(): void; - beforeCompile?(): void; - compiled?(): void; - ready?(): void; - attached?(): void; - detached?(): void; - beforeDestroy?(): void; - destroyed?(): void; - activate?: (done: () => void) => void; - directives?: { [key: string]: (DirectiveOption | Function) }; - elementDirectives?: { [key: string]: (DirectiveOption | Function) }; - filters?: { [key: string]: (Function | FilterOption) }; - components?: { [key: string]: any }; - transitions?: { [key: string]: TransitionOption }; - partials?: { [key: string]: string }; - parent?: Vue; - events?: { [key: string]: ((...args: any[]) => (boolean | void)) | string }; - mixins?: Object[]; - name?: string; - [key: string]: any; - } - - interface Vue { - $data: any; - $el: HTMLElement; - $options: Object; - $parent: Vue; - $root: Vue; - $children: Vue[]; - $refs: Object; - $els: Object; - - // instance/api/data.js - $get(exp: string, asStatement?: boolean): any; - $set(key: string | number, value: T): T; - $delete(key: string): void; - $eval(expression: string): string; - $interpolate(expression: string): string; - $log(keypath?: string): void; - $watch(expOrFn: string | Function, callback: ((newVal: any, oldVal?: any) => any) | string, options?: { deep?: boolean, immidiate?: boolean }): Function; - // instance/api/dom.js - $nextTick(callback: Function): void; - $appendTo(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; - $prependTo(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; - $before(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; - $after(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; - $remove(callback?: Function): this; - // instance/api/events.js - $on(event: string, callback: Function): this; - $once(event: string, callback: Function): this; - $off(event: string, callback?: Function): this; - $emit(event: string, ...args: any[]): this; - $broadcast(event: string, ...args: any[]): this; - $dispatch(event: string, ...args: any[]): this; - // instance/api/lifecycle.js - $mount(elementOrSelector?: (HTMLElement | string)): this; - $destroy(remove?: boolean): void; - $compile(el: Element | DocumentFragment, host?: Vue): Function; - - _init(options?: ComponentOption): void; - } - - interface VueConfig { - debug: boolean; - delimiters: [string, string]; - unsafeDelimiters: [string, string]; - silent: boolean; - async: boolean; - devtools: boolean; - } - - interface VueUtil { - // util/lang.js - set(obj: Object, key: string, value: any): void; - del(obj: Object, key: string): void; - hasOwn(obj: Object, key: string): boolean; - isLiteral(exp: string): boolean; - isReserved(str: string): boolean; - _toString(value: any): string; - toNumber(value: T): T | number; - toBoolean(value: T): T | boolean; - stripQuotes(str: string): string; - camelize(str: string): string; - hyphenate(str: string): string; - classify(str: string): string; - bind(fn: Function, ctx: Object): Function; - toAarray(list: ArrayLike, start?: number): Array; - extend(to: T, from: F): (T & F); - isObject(obj: any): boolean; - isPlainObject(obj: any): boolean; - isArray: typeof Array.isArray; - def(obj: Object, key: string, value: any, enumerable?: boolean): void; - debounce(func: Function, wait: number): Function; - indexOf(arr: Array, obj: T): number; - cancellable(fn: Function): Function; - looseEqual(a: any, b: any): boolean; - // util/env.js - hasProto: boolean; - inBrowser: boolean; - isIE9: boolean; - isAndroid: boolean; - transitionProp: string; - transitionEndEvent: string; - animationProp: string; - animationEndEvent: string; - nextTick(cb: Function, ctx?: Object): void; - // util/dom.js - query(el: string | Element): Element; - inDoc(node: Node): boolean; - getAttr(node: Node, _attr: string): string; - getBindAttr(node: Node, name: string): string; - before(el: Element, target: Element): void; - after(el: Element, target: Element): void; - remove(el: Element): void; - prepend(el: Element, target: Element): void; - replace(target: Element, el: Element): void; - on(el: Element, event: string, cb: Function): void; - off(el: Element, event: string, cb: Function): void; - addClass(el: Element, cls: string): void; - removeClass(el: Element, cls: string): void; - extractContent(el: Element, asFragment: boolean): (HTMLDivElement | DocumentFragment); - trimNode(node: Node): void; - isTemplate(el: Element): boolean; - createAnchor(content: string, persist: boolean): (Comment | Text); - findRef(node: Element): string; - mapNodeRange(node: Node, end: Node, op: Function): void; - removeNodeRange(start: Node, end: Node, vm: any, frag: DocumentFragment, cb: Function): void; - // util/options.js - mergeOptions(parent: P, child: C, vm?: any): (P & C); - resolveAsset(options: Object, type: string, id: string): (Object | Function); - assertAsset(val: any, type: string, id: string): void; - // util/component.js - commonTagRE: RegExp; - checkComponentAttr(el: Element, options?: Object): Object; - initProp(vm: Vue, prop: Object, value: any): void; - assertProp(prop: Object, value: any): boolean; - // util/debug.js - warn(msg: string, e?: Error): void; - // observer/index.js - defineReactive(obj: Object, key: string, val: any): void; - } - - // instance/api/global.js - interface VueStatic { - new (options?: ComponentOption): Vue; - prototype: Vue; - util: VueUtil; - config: VueConfig; - set(object: Object, key: string, value: any): void; - delete(object: Object, key: string): void; - nextTick(callback: Function): any; - - cid: number; - - extend(options?: ComponentOption): VueStatic; - use(callback: Function | { install: Function, [key: string]: any }, option?: Object): VueStatic; - mixin(mixin: Object): void; - - directive(id: string, definition: T): T; - directive(id: string): any; - elementDirective(id: string, definition: T): T; - elementDirective(id: string): any; - filter(id: string, definition: T): T; - filter(id: string): any; - component(id: string, definition: ComponentOption): any; - component(id: string): any; - transition(id: string, hooks: T): T; - transition(id: string): TransitionOption; - partial(id: string, partial: string): string; - partial(id: string): string; - } -} - -declare var Vue: vuejs.VueStatic; - -declare module "vue" { - export = Vue; -} diff --git a/vue/tsconfig.json b/vue/tsconfig.json deleted file mode 100644 index 152a23449d..0000000000 --- a/vue/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "vue-tests.ts" - ] -} \ No newline at end of file diff --git a/vue/vue-tests.ts b/vue/vue-tests.ts deleted file mode 100644 index 429ec3682b..0000000000 --- a/vue/vue-tests.ts +++ /dev/null @@ -1,276 +0,0 @@ - - -namespace TestConfig { - "use strict"; - - Vue.config.debug = true; - Vue.config.delimiters = ["${", "}"]; - Vue.config.unsafeDelimiters = ['{!!', '!!}']; - Vue.config.silent = true; - Vue.config.async = false; - Vue.config.devtools = true; -} - -namespace TestGlobalAPI { - "use strict"; - - var AppConstructor = Vue.extend({}); - var extendedApp = new AppConstructor(); - Vue.nextTick(() => {}); - Vue.set({}, "key", "value"); - Vue.delete({}, "key"); - Vue.directive("directive", { - bind: function() {}, - update: function(val: any, oldVal: any) {}, - unbind: function() {}, - params: ['a'], - paramWatchers: { - a: function(val: any, oldVal: any) {} - }, - twoWay: true, - acceptStatement: true, - priority: 1, - terminal: true, - count: 30 - }); - Vue.directive("my-directive", function() { - const d = this as vuejs.Directive; - d.el; - d.vm; - d.expression; - d.arg; - d.name; - d.modifiers; - d.descriptor; - d.params; - }); - var myDirective = Vue.directive("my-directive"); - var elementDirective = Vue.elementDirective("element-directive"); - Vue.elementDirective("element-directive", elementDirective); - Vue.elementDirective("element-directive", { - bind: function() {}, - unbind: function() {} - }); - var filter = Vue.filter("filter"); - Vue.filter("filter", filter); - Vue.filter("filter", function(val: any) { - return val; - }); - Vue.filter("filter", { - read: function(val: any) {}, - write: function(val: any, oldVal: any) {} - }); - var Component = Vue.component("component"); - Vue.component("component", Component); - Vue.component("component", { - data: function() { - return { d: 0 } - }, - methods: { - action: function() {} - }, - props: ["a", "b"], - computed: { - a: function() { return this.d; }, - b: { - get: function() { return this.a; }, - set: function(val: number) { this.d = val; } - } - } - }); - Vue.component("component", { - props: { - a: [String, Number], - b: { - type: [Number, Function], - required: true - } - }, - init: function() {} - }); - Vue.component("component", { - activate: function(callback: Function) { - callback(); - } - }); - var transition = Vue.transition("transition"); - Vue.transition("transition", transition); - Vue.transition("transition", { - css: false, - stagger: function(index) { - return index; - }, - beforeEnter: function(el) { - el.textContent = 'beforeEnter'; - }, - enter: function(el, done) { - el.textContent = 'enter'; - setTimeout(function() { - done(); - }, 1000); - }, - afterEnter: function(el) { - el.textContent = 'afterEnter'; - }, - enterCancelled: function(el) { - el.textContent = 'enterCancelled'; - }, - beforeLeave: function (el) { - el.textContent = 'beforeLeave'; - }, - leave: function (el, done) { - el.textContent = 'leave'; - done(); - }, - afterLeave: function (el) { - el.textContent = 'afterLeave'; - }, - leaveCancelled: function (el) { - el.textContent = 'leaveCancelled'; - } - }); - var myPartial: string = Vue.partial("my-partial", "
Hello
"); - myPartial = Vue.partial("my-partial"); - Vue.use(() => {}, {}); - Vue.use({install: () => {}, option: () => {}}); - Vue.mixin({ready() {}}); -} - -namespace TestInstanceProperty { - "use strict"; - - var vm = new Vue({el: '#app'}); - var data: any = vm.$data; - var el: HTMLElement = vm.$el; - var options: any = vm.$options; - var parent: any = vm.$parent; - var root: any = vm.$root; - var children: any[] = vm.$children; - var refs: any = vm.$refs; - var els: any = vm.$els; -} - -namespace TestInscanceMethods { - "use strict"; - - var vm = new Vue({el: '#app'}); - vm.$watch('a.b.c', function(newVal: string, oldVal: number) {}); - vm.$watch(function() {return this.a + this.b}, function(newVal: string, oldVal: string) {}); - var unwatch = vm.$watch('a', (value: any) => {}); - unwatch(); - vm.$watch('someObject', (value: any) => {}, {deep: true}); - vm.$watch('a', (value: any) => {}, {immidiate: true}); - vm.$get('a.b'); - vm.$set('a.b', 2); - vm.$delete('a'); - var s: string = vm.$eval('msg | uppercase'); - s = vm.$interpolate('{{msg}} world!'); - vm.$log(); - vm.$log('item'); - - vm - .$on('test', (msg: any) => {}) - .$once('testOnce', (msg: any) => {}) - .$off("event", () => {}) - .$emit("event", 1, 2) - .$dispatch("event", 1, 2, 3) - .$broadcast("event", 1, 2, 3, 4) - - .$appendTo(document.createElement("div"), () => {}) - .$before('#app', () => {}) - .$after(document.getElementById('app')) - .$remove(() => {}) - .$nextTick(() => {}); - - vm - .$mount('#app') - .$destroy(false); -} - -namespace TestVueUtil { - "use strict"; - - var _ = Vue.util; - var target = document.createElement('div'); - var child = document.createElement('div'); - var parent = document.createElement('div'); - var a: any[]; - var b: boolean; - var f: Function; - var n: number; - var s: string; - var o: any; - o = _.checkComponentAttr(target, {}); - _.warn('oops', new Error()); - b = _.inDoc(target); - s = _.getAttr(target, 'v-test'); - _.before(target, child); - _.after(target, child); - _.remove(target); - _.prepend(target, parent); - _.replace(child, target); - _.on(target, 'click', () => {}); - _.off(target, 'click', () => {}); - _.removeClass(target, 'header'); - _.addClass(target, 'header'); - _.nextTick(() => {}, {}); - b = _.isLiteral('123'); - s = _._toString('hi'); - var ns: number | string = _.toNumber('12'); - s = _.stripQuotes('"123"'); - s = _.camelize('abc'); - s = _.hyphenate('whatsUp'); - s = _.classify('abc'); - f = _.bind(() => {}, {}); - a = _.toAarray(document.getElementsByClassName('target')); - o = _.extend({}, {a: 1, b: 2}); - b = _.isObject({}); - b = _.isPlainObject({}); - b = _.isArray([]); - _.def({}, 'test', 123); - _.def({}, 'test2', 123, true); - f = _.debounce(() => {}, 100); - b = _.looseEqual(1, '1'); -} - -namespace TestExplicitExtend { - "use strict"; - - export class Application extends Vue { - text: string; - constructor() { - super(); - this._init({ - // data is necessary to always write in init() - data: { - text: "hello world." - }, - methods: { - action: this.action - }, - props: { - propA: Object, - propB: { - type: Application, - default: () => new Application(), - twoWay: true, - coerce(value: any) {} - } - } - }); - } - action(): void { - console.log("action"); - this.$on("event", (value: any) => {}).anotherAction(); - } - anotherAction(): void { - this.$emit("event"); - } - $els: { - target: HTMLDivElement; - } - } - - var app = new Application(); - app.$mount("#main").$destroy(); -} From 43b47cd512f9755f34bdb0b7db487aa347f4bcb2 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 9 Dec 2016 08:50:18 -0800 Subject: [PATCH 13/19] Revert "Vue provides its own typings (#13230)" (#13235) This reverts commit fd18042829bc98599cb23fd1f52e9f8661ad171d. --- notNeededPackages.json | 6 - vue-resource/package.json | 5 - vue-router/package.json | 5 - vue/index.d.ts | 268 ++++++++++++++++++++++++++++++++++++ vue/tsconfig.json | 19 +++ vue/vue-tests.ts | 276 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 563 insertions(+), 16 deletions(-) delete mode 100644 vue-resource/package.json delete mode 100644 vue-router/package.json create mode 100644 vue/index.d.ts create mode 100644 vue/tsconfig.json create mode 100644 vue/vue-tests.ts diff --git a/notNeededPackages.json b/notNeededPackages.json index eee68b5219..472a3881ca 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -94,12 +94,6 @@ "typingsPackageName": "normalizr", "sourceRepoURL": "https://github.com/paularmstrong/normalizr", "asOfVersion": "2.0.18" - }, - { - "libraryName": "vuejs", - "typingsPackageName": "vue", - "sourceRepoURL": "https://github.com/vuejs/vue", - "asOfVersion": "2.0.0" } ] } diff --git a/vue-resource/package.json b/vue-resource/package.json deleted file mode 100644 index 1fe0305da3..0000000000 --- a/vue-resource/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "@types/vue": "^1.0.31" - } -} diff --git a/vue-router/package.json b/vue-router/package.json deleted file mode 100644 index 1fe0305da3..0000000000 --- a/vue-router/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "@types/vue": "^1.0.31" - } -} diff --git a/vue/index.d.ts b/vue/index.d.ts new file mode 100644 index 0000000000..02e4f70463 --- /dev/null +++ b/vue/index.d.ts @@ -0,0 +1,268 @@ +// Type definitions for vuejs 1.0.21 +// Project: https://github.com/vuejs/vue +// Definitions by: odangosan , kaorun343 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Array { + $remove(item: T): Array; + $set(index: any, val: T): T; +} + +declare namespace vuejs { + + interface PropOption { + type?: { new (...args: any[]): any; } | { new (...args: any[]): any; }[]; + required?: boolean; + default?: any; + twoWay?: boolean; + validator?(value: any): boolean; + coerce?(value: any): any; + } + + interface ComputedOption { + get(): any; + set(value: any): void; + } + + interface WatchOption { + handler(val: any, oldVal: any): void; + deep?: boolean; + immidiate?: boolean; + } + + interface DirectiveOption { + bind?(): any; + update?(newVal?: any, oldVal?: any): any; + unbind?(): any; + params?: string[]; + deep?: boolean; + twoWay?: boolean; + acceptStatement?: boolean; + terminal?: boolean; + priority?: number; + [key: string]: any; + } + + interface Directive { + el: HTMLElement; + vm: Vue; + expression: string; + arg?: string; + name: string; + modifiers: { [key: string]: boolean }; + descriptor: any; + params?: { [key: string]: any }; + } + + interface FilterOption { + read?: Function; + write?: Function; + } + + interface TransitionOption { + css?: boolean; + animation?: string; + enterClass?: string; + leaveClass?: string; + beforeEnter?(el: HTMLElement): void; + enter?(el: HTMLElement, done?: () => void): void; + afterEnter?(el: HTMLElement): void; + enterCancelled?(el: HTMLElement): void; + beforeLeave?(el: HTMLElement): void; + leave?(el: HTMLElement, done?: () => void): void; + afterLeave?(el: HTMLElement): void; + leaveCancelled?(el: HTMLElement): void; + stagger?(index: number): number; + enterStagger?(index: number): number; + leaveStagger?(index: number): number; + [key: string]: any; + } + + interface ComponentOption { + data?: { [key: string]: any } | Function; + props?: string[] | { [key: string]: (PropOption | { new (...args: any[]): any; } | { new (...args: any[]): any; }[]) }; + computed?: { [key: string]: (Function | ComputedOption) }; + methods?: { [key: string]: Function }; + watch?: { [key: string]: ((val: any, oldVal: any) => void) | string | WatchOption }; + el?: string | HTMLElement | (() => HTMLElement); + template?: string; + replace?: boolean; + init?(): void; + created?(): void; + beforeCompile?(): void; + compiled?(): void; + ready?(): void; + attached?(): void; + detached?(): void; + beforeDestroy?(): void; + destroyed?(): void; + activate?: (done: () => void) => void; + directives?: { [key: string]: (DirectiveOption | Function) }; + elementDirectives?: { [key: string]: (DirectiveOption | Function) }; + filters?: { [key: string]: (Function | FilterOption) }; + components?: { [key: string]: any }; + transitions?: { [key: string]: TransitionOption }; + partials?: { [key: string]: string }; + parent?: Vue; + events?: { [key: string]: ((...args: any[]) => (boolean | void)) | string }; + mixins?: Object[]; + name?: string; + [key: string]: any; + } + + interface Vue { + $data: any; + $el: HTMLElement; + $options: Object; + $parent: Vue; + $root: Vue; + $children: Vue[]; + $refs: Object; + $els: Object; + + // instance/api/data.js + $get(exp: string, asStatement?: boolean): any; + $set(key: string | number, value: T): T; + $delete(key: string): void; + $eval(expression: string): string; + $interpolate(expression: string): string; + $log(keypath?: string): void; + $watch(expOrFn: string | Function, callback: ((newVal: any, oldVal?: any) => any) | string, options?: { deep?: boolean, immidiate?: boolean }): Function; + // instance/api/dom.js + $nextTick(callback: Function): void; + $appendTo(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; + $prependTo(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; + $before(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; + $after(target: (HTMLElement | string), callback?: Function, withTransition?: boolean): this; + $remove(callback?: Function): this; + // instance/api/events.js + $on(event: string, callback: Function): this; + $once(event: string, callback: Function): this; + $off(event: string, callback?: Function): this; + $emit(event: string, ...args: any[]): this; + $broadcast(event: string, ...args: any[]): this; + $dispatch(event: string, ...args: any[]): this; + // instance/api/lifecycle.js + $mount(elementOrSelector?: (HTMLElement | string)): this; + $destroy(remove?: boolean): void; + $compile(el: Element | DocumentFragment, host?: Vue): Function; + + _init(options?: ComponentOption): void; + } + + interface VueConfig { + debug: boolean; + delimiters: [string, string]; + unsafeDelimiters: [string, string]; + silent: boolean; + async: boolean; + devtools: boolean; + } + + interface VueUtil { + // util/lang.js + set(obj: Object, key: string, value: any): void; + del(obj: Object, key: string): void; + hasOwn(obj: Object, key: string): boolean; + isLiteral(exp: string): boolean; + isReserved(str: string): boolean; + _toString(value: any): string; + toNumber(value: T): T | number; + toBoolean(value: T): T | boolean; + stripQuotes(str: string): string; + camelize(str: string): string; + hyphenate(str: string): string; + classify(str: string): string; + bind(fn: Function, ctx: Object): Function; + toAarray(list: ArrayLike, start?: number): Array; + extend(to: T, from: F): (T & F); + isObject(obj: any): boolean; + isPlainObject(obj: any): boolean; + isArray: typeof Array.isArray; + def(obj: Object, key: string, value: any, enumerable?: boolean): void; + debounce(func: Function, wait: number): Function; + indexOf(arr: Array, obj: T): number; + cancellable(fn: Function): Function; + looseEqual(a: any, b: any): boolean; + // util/env.js + hasProto: boolean; + inBrowser: boolean; + isIE9: boolean; + isAndroid: boolean; + transitionProp: string; + transitionEndEvent: string; + animationProp: string; + animationEndEvent: string; + nextTick(cb: Function, ctx?: Object): void; + // util/dom.js + query(el: string | Element): Element; + inDoc(node: Node): boolean; + getAttr(node: Node, _attr: string): string; + getBindAttr(node: Node, name: string): string; + before(el: Element, target: Element): void; + after(el: Element, target: Element): void; + remove(el: Element): void; + prepend(el: Element, target: Element): void; + replace(target: Element, el: Element): void; + on(el: Element, event: string, cb: Function): void; + off(el: Element, event: string, cb: Function): void; + addClass(el: Element, cls: string): void; + removeClass(el: Element, cls: string): void; + extractContent(el: Element, asFragment: boolean): (HTMLDivElement | DocumentFragment); + trimNode(node: Node): void; + isTemplate(el: Element): boolean; + createAnchor(content: string, persist: boolean): (Comment | Text); + findRef(node: Element): string; + mapNodeRange(node: Node, end: Node, op: Function): void; + removeNodeRange(start: Node, end: Node, vm: any, frag: DocumentFragment, cb: Function): void; + // util/options.js + mergeOptions(parent: P, child: C, vm?: any): (P & C); + resolveAsset(options: Object, type: string, id: string): (Object | Function); + assertAsset(val: any, type: string, id: string): void; + // util/component.js + commonTagRE: RegExp; + checkComponentAttr(el: Element, options?: Object): Object; + initProp(vm: Vue, prop: Object, value: any): void; + assertProp(prop: Object, value: any): boolean; + // util/debug.js + warn(msg: string, e?: Error): void; + // observer/index.js + defineReactive(obj: Object, key: string, val: any): void; + } + + // instance/api/global.js + interface VueStatic { + new (options?: ComponentOption): Vue; + prototype: Vue; + util: VueUtil; + config: VueConfig; + set(object: Object, key: string, value: any): void; + delete(object: Object, key: string): void; + nextTick(callback: Function): any; + + cid: number; + + extend(options?: ComponentOption): VueStatic; + use(callback: Function | { install: Function, [key: string]: any }, option?: Object): VueStatic; + mixin(mixin: Object): void; + + directive(id: string, definition: T): T; + directive(id: string): any; + elementDirective(id: string, definition: T): T; + elementDirective(id: string): any; + filter(id: string, definition: T): T; + filter(id: string): any; + component(id: string, definition: ComponentOption): any; + component(id: string): any; + transition(id: string, hooks: T): T; + transition(id: string): TransitionOption; + partial(id: string, partial: string): string; + partial(id: string): string; + } +} + +declare var Vue: vuejs.VueStatic; + +declare module "vue" { + export = Vue; +} diff --git a/vue/tsconfig.json b/vue/tsconfig.json new file mode 100644 index 0000000000..152a23449d --- /dev/null +++ b/vue/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vue-tests.ts" + ] +} \ No newline at end of file diff --git a/vue/vue-tests.ts b/vue/vue-tests.ts new file mode 100644 index 0000000000..429ec3682b --- /dev/null +++ b/vue/vue-tests.ts @@ -0,0 +1,276 @@ + + +namespace TestConfig { + "use strict"; + + Vue.config.debug = true; + Vue.config.delimiters = ["${", "}"]; + Vue.config.unsafeDelimiters = ['{!!', '!!}']; + Vue.config.silent = true; + Vue.config.async = false; + Vue.config.devtools = true; +} + +namespace TestGlobalAPI { + "use strict"; + + var AppConstructor = Vue.extend({}); + var extendedApp = new AppConstructor(); + Vue.nextTick(() => {}); + Vue.set({}, "key", "value"); + Vue.delete({}, "key"); + Vue.directive("directive", { + bind: function() {}, + update: function(val: any, oldVal: any) {}, + unbind: function() {}, + params: ['a'], + paramWatchers: { + a: function(val: any, oldVal: any) {} + }, + twoWay: true, + acceptStatement: true, + priority: 1, + terminal: true, + count: 30 + }); + Vue.directive("my-directive", function() { + const d = this as vuejs.Directive; + d.el; + d.vm; + d.expression; + d.arg; + d.name; + d.modifiers; + d.descriptor; + d.params; + }); + var myDirective = Vue.directive("my-directive"); + var elementDirective = Vue.elementDirective("element-directive"); + Vue.elementDirective("element-directive", elementDirective); + Vue.elementDirective("element-directive", { + bind: function() {}, + unbind: function() {} + }); + var filter = Vue.filter("filter"); + Vue.filter("filter", filter); + Vue.filter("filter", function(val: any) { + return val; + }); + Vue.filter("filter", { + read: function(val: any) {}, + write: function(val: any, oldVal: any) {} + }); + var Component = Vue.component("component"); + Vue.component("component", Component); + Vue.component("component", { + data: function() { + return { d: 0 } + }, + methods: { + action: function() {} + }, + props: ["a", "b"], + computed: { + a: function() { return this.d; }, + b: { + get: function() { return this.a; }, + set: function(val: number) { this.d = val; } + } + } + }); + Vue.component("component", { + props: { + a: [String, Number], + b: { + type: [Number, Function], + required: true + } + }, + init: function() {} + }); + Vue.component("component", { + activate: function(callback: Function) { + callback(); + } + }); + var transition = Vue.transition("transition"); + Vue.transition("transition", transition); + Vue.transition("transition", { + css: false, + stagger: function(index) { + return index; + }, + beforeEnter: function(el) { + el.textContent = 'beforeEnter'; + }, + enter: function(el, done) { + el.textContent = 'enter'; + setTimeout(function() { + done(); + }, 1000); + }, + afterEnter: function(el) { + el.textContent = 'afterEnter'; + }, + enterCancelled: function(el) { + el.textContent = 'enterCancelled'; + }, + beforeLeave: function (el) { + el.textContent = 'beforeLeave'; + }, + leave: function (el, done) { + el.textContent = 'leave'; + done(); + }, + afterLeave: function (el) { + el.textContent = 'afterLeave'; + }, + leaveCancelled: function (el) { + el.textContent = 'leaveCancelled'; + } + }); + var myPartial: string = Vue.partial("my-partial", "
Hello
"); + myPartial = Vue.partial("my-partial"); + Vue.use(() => {}, {}); + Vue.use({install: () => {}, option: () => {}}); + Vue.mixin({ready() {}}); +} + +namespace TestInstanceProperty { + "use strict"; + + var vm = new Vue({el: '#app'}); + var data: any = vm.$data; + var el: HTMLElement = vm.$el; + var options: any = vm.$options; + var parent: any = vm.$parent; + var root: any = vm.$root; + var children: any[] = vm.$children; + var refs: any = vm.$refs; + var els: any = vm.$els; +} + +namespace TestInscanceMethods { + "use strict"; + + var vm = new Vue({el: '#app'}); + vm.$watch('a.b.c', function(newVal: string, oldVal: number) {}); + vm.$watch(function() {return this.a + this.b}, function(newVal: string, oldVal: string) {}); + var unwatch = vm.$watch('a', (value: any) => {}); + unwatch(); + vm.$watch('someObject', (value: any) => {}, {deep: true}); + vm.$watch('a', (value: any) => {}, {immidiate: true}); + vm.$get('a.b'); + vm.$set('a.b', 2); + vm.$delete('a'); + var s: string = vm.$eval('msg | uppercase'); + s = vm.$interpolate('{{msg}} world!'); + vm.$log(); + vm.$log('item'); + + vm + .$on('test', (msg: any) => {}) + .$once('testOnce', (msg: any) => {}) + .$off("event", () => {}) + .$emit("event", 1, 2) + .$dispatch("event", 1, 2, 3) + .$broadcast("event", 1, 2, 3, 4) + + .$appendTo(document.createElement("div"), () => {}) + .$before('#app', () => {}) + .$after(document.getElementById('app')) + .$remove(() => {}) + .$nextTick(() => {}); + + vm + .$mount('#app') + .$destroy(false); +} + +namespace TestVueUtil { + "use strict"; + + var _ = Vue.util; + var target = document.createElement('div'); + var child = document.createElement('div'); + var parent = document.createElement('div'); + var a: any[]; + var b: boolean; + var f: Function; + var n: number; + var s: string; + var o: any; + o = _.checkComponentAttr(target, {}); + _.warn('oops', new Error()); + b = _.inDoc(target); + s = _.getAttr(target, 'v-test'); + _.before(target, child); + _.after(target, child); + _.remove(target); + _.prepend(target, parent); + _.replace(child, target); + _.on(target, 'click', () => {}); + _.off(target, 'click', () => {}); + _.removeClass(target, 'header'); + _.addClass(target, 'header'); + _.nextTick(() => {}, {}); + b = _.isLiteral('123'); + s = _._toString('hi'); + var ns: number | string = _.toNumber('12'); + s = _.stripQuotes('"123"'); + s = _.camelize('abc'); + s = _.hyphenate('whatsUp'); + s = _.classify('abc'); + f = _.bind(() => {}, {}); + a = _.toAarray(document.getElementsByClassName('target')); + o = _.extend({}, {a: 1, b: 2}); + b = _.isObject({}); + b = _.isPlainObject({}); + b = _.isArray([]); + _.def({}, 'test', 123); + _.def({}, 'test2', 123, true); + f = _.debounce(() => {}, 100); + b = _.looseEqual(1, '1'); +} + +namespace TestExplicitExtend { + "use strict"; + + export class Application extends Vue { + text: string; + constructor() { + super(); + this._init({ + // data is necessary to always write in init() + data: { + text: "hello world." + }, + methods: { + action: this.action + }, + props: { + propA: Object, + propB: { + type: Application, + default: () => new Application(), + twoWay: true, + coerce(value: any) {} + } + } + }); + } + action(): void { + console.log("action"); + this.$on("event", (value: any) => {}).anotherAction(); + } + anotherAction(): void { + this.$emit("event"); + } + $els: { + target: HTMLDivElement; + } + } + + var app = new Application(); + app.$mount("#main").$destroy(); +} From 9d6ee729f8498cccc8e5b74d4daae14db022a50f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 9 Dec 2016 14:03:28 -0300 Subject: [PATCH 14/19] Add fs-promise declarations (#13223) --- fs-promise/fs-promise-tests.ts | 51 ++++++++++++++++++++++++++++++ fs-promise/index.d.ts | 58 ++++++++++++++++++++++++++++++++++ fs-promise/tsconfig.json | 19 +++++++++++ fs-promise/tslint.json | 1 + 4 files changed, 129 insertions(+) create mode 100644 fs-promise/fs-promise-tests.ts create mode 100644 fs-promise/index.d.ts create mode 100644 fs-promise/tsconfig.json create mode 100644 fs-promise/tslint.json diff --git a/fs-promise/fs-promise-tests.ts b/fs-promise/fs-promise-tests.ts new file mode 100644 index 0000000000..4469ea5c22 --- /dev/null +++ b/fs-promise/fs-promise-tests.ts @@ -0,0 +1,51 @@ +import * as fs from "fs-promise"; + +var src: string; +var dst: string; +var dir: string; +var path: string; +var data: any; +var writeOptions: fs.WriteOptions; +var writeJsonOptions: fs.WriteJsonOptions; +var readJsonOptions: fs.ReadJsonOptions; + +async function test() { + await fs.copy(src, dst); + await fs.emptyDir(dir); + await fs.emptydir(dir); + await fs.ensureFile(path); + await fs.createFile(path); + await fs.ensureDir(dir); + await fs.ensureLink(src, dst); + await fs.createLink(src, dst); + await fs.ensureSymlink(src, dst); + await fs.ensureSymlink(src, dst, "dir"); + await fs.ensureSymlink(src, dst, "file"); + await fs.ensureSymlink(src, dst, "junction"); + await fs.createSymlink(src, dst, "dir"); + await fs.mkdirs(dir); + await fs.mkdirp(dir); + await fs.move(src, dst); + await fs.outputFile(path, "test"); + await fs.outputFile(path, "test", writeOptions); + await fs.outputFile(path, new Buffer([1,2])); + await fs.outputFile(path, new Buffer([1,2]), writeOptions); + await fs.outputJson(path, data); + await fs.outputJson(path, data, writeJsonOptions); + await fs.outputJSON(path, data, writeJsonOptions); + let json = await fs.readJson(path); + json = await fs.readJson(path, readJsonOptions); + json = await fs.readJSON(path, readJsonOptions); + await fs.remove(path); + let dirs: string[] = await fs.walk(dir); + await fs.writeJson(path, data); + await fs.writeJson(path, data, writeJsonOptions); + await fs.writeJSON(path, data, writeJsonOptions); + return dirs; +} + +test().then((dirs: string[]) => { + console.log(dirs); +}).catch((err) => { + console.log(err); +}); diff --git a/fs-promise/index.d.ts b/fs-promise/index.d.ts new file mode 100644 index 0000000000..09b6ec4b9c --- /dev/null +++ b/fs-promise/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for fs-promise 1.0 +// Project: https://github.com/kevinbeaty/fs-promise#readme +// Definitions by: Thiago de Arruda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export * from "mz/fs"; + +export interface WriteOptions { + encoding?: string; + mode?: number; + flag?: string; +} + +type JsonReplacerArray = Array; + +type JsonReplacerFunction = (key: any, value: any) => any; + +type JsonReplacer = JsonReplacerArray | JsonReplacerFunction; + +export interface WriteJsonOptions extends WriteOptions { + spaces?: number; + replacer?: JsonReplacer; +} + +export interface ReadJsonOptions { + encoding: string; + flag?: string; + reviver: (key: any, value: any) => any; +} + +export function copy(src: string, dst: string): Promise; +export function emptyDir(dir: string): Promise; +export function ensureFile(file: string): Promise; +export function ensureDir(dir: string): Promise; +export function ensureLink(srcpath: string, dstpath: string): Promise; +export function ensureSymlink(srcpath: string, dstpath: string, type?: "dir" | "file" | "junction"): Promise; +export function mkdirs(dir: string): Promise; +export function move(src: string, dst: string): Promise; +export function outputFile(file: string, data: string | Buffer, options?: WriteOptions): Promise; +export function outputJson(file: string, data: any, options?: WriteJsonOptions): Promise; +export function readJson(file: string, options?: ReadJsonOptions): Promise; +export function remove(path: string): Promise; +export function walk(dir: string): Promise; +export function writeJson(file: string, data: any, options?: WriteJsonOptions): Promise; + +// aliases +export { + emptyDir as emptydir, + ensureFile as createFile, + ensureLink as createLink, + ensureSymlink as createSymlink, + mkdirs as mkdirp, + outputJson as outputJSON, + readJson as readJSON, + writeJson as writeJSON +}; diff --git a/fs-promise/tsconfig.json b/fs-promise/tsconfig.json new file mode 100644 index 0000000000..dcf9975c0d --- /dev/null +++ b/fs-promise/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fs-promise-tests.ts" + ] +} diff --git a/fs-promise/tslint.json b/fs-promise/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fs-promise/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 4d3b20542671be23c6b3a552c21e7e8bc2c6145e Mon Sep 17 00:00:00 2001 From: Markus Wolf Date: Sat, 10 Dec 2016 16:53:20 +0100 Subject: [PATCH 15/19] Add typings for meow (#13221) * feat: add typings for meow * style: use 4 spaces * chore: add tslint * updates after review --- meow/index.d.ts | 30 ++++++++++++++++++++++++++++++ meow/meow-tests.ts | 19 +++++++++++++++++++ meow/tsconfig.json | 19 +++++++++++++++++++ meow/tslint.json | 3 +++ 4 files changed, 71 insertions(+) create mode 100644 meow/index.d.ts create mode 100644 meow/meow-tests.ts create mode 100644 meow/tsconfig.json create mode 100644 meow/tslint.json diff --git a/meow/index.d.ts b/meow/index.d.ts new file mode 100644 index 0000000000..d687f65611 --- /dev/null +++ b/meow/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for meow 3.6 +// Project: https://github.com/sindresorhus/meow +// Definitions by: KnisterPeter +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as minimist from 'minimist'; + +declare function meow(options: string | string[] | meow.Options, minimistOptions?: minimist.Opts): meow.Result; +declare namespace meow { + + export interface Options { + description?: string | boolean; + help?: string | boolean; + version?: string | boolean; + pkg?: any; + argv?: string[]; + inferType?: boolean; + } + + export interface Result { + input: string[]; + flags: { [name: string]: any }; + pkg: any; + help: string; + showHelp(code: number): void; + } + +} + +export = meow; diff --git a/meow/meow-tests.ts b/meow/meow-tests.ts new file mode 100644 index 0000000000..cb2e1dc90a --- /dev/null +++ b/meow/meow-tests.ts @@ -0,0 +1,19 @@ +import meow = require('meow'); +import Options = meow.Options; + +var options: Options = {}; +options.description = true; +options.description = 'string'; +options.help = true; +options.help = 'string'; +options.version = true; +options.version = 'string'; +options.argv = ['string', 'string']; +options.inferType = true; + +meow(options); +meow('Usage text', { + alias: { + opt: 'opt' + } +}); diff --git a/meow/tsconfig.json b/meow/tsconfig.json new file mode 100644 index 0000000000..3e433b6c02 --- /dev/null +++ b/meow/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "meow-tests.ts" + ] +} diff --git a/meow/tslint.json b/meow/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/meow/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 0b2bdb8321364a68ed48a853712728852eb5563d Mon Sep 17 00:00:00 2001 From: Slavo Vojacek Date: Sat, 10 Dec 2016 17:33:37 +0000 Subject: [PATCH 16/19] =?UTF-8?q?Update=20enzyme/enzyme.d.ts=20=E2=80=93?= =?UTF-8?q?=20forEach=20iterator=20function=20takes=20index=20as=20second?= =?UTF-8?q?=20argument=20(#13243)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update enzyme/enzyme-1.2.0.d.ts – forEach iterator function takes index as second argument * Update enzyme-1.2.0.d.ts Make index optional in forEach --- enzyme/enzyme-1.2.0.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/enzyme/enzyme-1.2.0.d.ts b/enzyme/enzyme-1.2.0.d.ts index c135267e95..865331529b 100644 --- a/enzyme/enzyme-1.2.0.d.ts +++ b/enzyme/enzyme-1.2.0.d.ts @@ -253,9 +253,9 @@ declare module "enzyme" { * * Returns itself. * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first - * argument, and will be run with a context of the original instance. + * argument, index as a second, and will be run with a context of the original instance. */ - forEach(fn: (wrapper: this) => any): this; + forEach(fn: (wrapper: this, index?: number) => any): this; /** * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map @@ -470,4 +470,4 @@ declare module "enzyme" { export function describeWithDOM(description: String, fn: Function): void; export function spyLifecycle(component: typeof Component): void; -} \ No newline at end of file +} From 67a9bd38aead64c54eda117180257592fdb61652 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sat, 10 Dec 2016 09:35:46 -0800 Subject: [PATCH 17/19] Create koa-pug definitions (#13220) * Create koa-pug definitions * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI --- koa-pug/index.d.ts | 37 +++++++++++++++++++++++++++++++++++++ koa-pug/koa-pug-tests.ts | 0 koa-pug/tsconfig.json | 19 +++++++++++++++++++ koa-pug/tslint.json | 1 + 4 files changed, 57 insertions(+) create mode 100644 koa-pug/index.d.ts create mode 100644 koa-pug/koa-pug-tests.ts create mode 100644 koa-pug/tsconfig.json create mode 100644 koa-pug/tslint.json diff --git a/koa-pug/index.d.ts b/koa-pug/index.d.ts new file mode 100644 index 0000000000..e25a5bc6bf --- /dev/null +++ b/koa-pug/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for koa-pug 3.0 +// Project: https://github.com/chrisyip/koa-pug +// Definitions by: Xavier Stouder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as koa from "koa"; + +export namespace Koa { + interface Context { + render(viewPath: string, locals?: Pug.PugLocals, overrideOpts?: Pug.PugCtxOptions, noCache?: boolean): void; + // tslint:disable-next-line:unified-signatures + render(pugStr: string, locals?: Pug.PugLocals, overrideOpts?: Pug.PugCtxOptions): void; + // tslint:disable-next-line:unified-signatures + render(pugStr: string, locals?: Pug.PugLocals, noCache?: boolean): void; + } +} +export class Pug { + constructor(options?: Pug.PugOptions); + use(app: koa): void; +} +export namespace Pug { + export interface PugOptions { + viewPath?: string; + pretty?: boolean; + compileDebug?: boolean; + debug?: boolean; + locals?: PugLocals; + noCache?: boolean; + helperPath?: string | Array; + basedir?: string; + app?: koa; + } + export interface PugCtxOptions extends PugOptions { + fromString: boolean; + } + export interface PugLocals { [str: string]: any; } +} diff --git a/koa-pug/koa-pug-tests.ts b/koa-pug/koa-pug-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/koa-pug/tsconfig.json b/koa-pug/tsconfig.json new file mode 100644 index 0000000000..21d8c4f990 --- /dev/null +++ b/koa-pug/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-pug-tests.ts" + ] +} diff --git a/koa-pug/tslint.json b/koa-pug/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/koa-pug/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From d686ddcd8e2a471e88d190b787184467d0450ad5 Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Sun, 11 Dec 2016 16:57:15 +0100 Subject: [PATCH 18/19] fixed babel-code-frame typings (#13246) * fixed babel-code-frame typings * latest version header --- babel-code-frame/babel-code-frame-tests.ts | 2 +- babel-code-frame/index.d.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/babel-code-frame/babel-code-frame-tests.ts b/babel-code-frame/babel-code-frame-tests.ts index 1177570acd..7047bf88d7 100644 --- a/babel-code-frame/babel-code-frame-tests.ts +++ b/babel-code-frame/babel-code-frame-tests.ts @@ -1,4 +1,4 @@ -import codeFrame from "babel-code-frame"; +import codeFrame = require("babel-code-frame"); const code = ` const number = 1; diff --git a/babel-code-frame/index.d.ts b/babel-code-frame/index.d.ts index 935f39ea4e..ebfde63c4c 100644 --- a/babel-code-frame/index.d.ts +++ b/babel-code-frame/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for babel-code-frame 6.16 +// Type definitions for babel-code-frame 6.20 // Project: https://github.com/babel/babel/tree/master/packages // Definitions by: Mohsen Azimi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -28,9 +28,11 @@ interface BabelCodeFrameOptions { * * @returns Framed code */ -export default function babelCodeFrame( +declare function codeFrame( rawLines: string, lineNumber: number, colNumber: number, options?: BabelCodeFrameOptions ): string; + +export = codeFrame; From d89e3032bd80dffac1e48dc033d35aee5037e6f6 Mon Sep 17 00:00:00 2001 From: Mateusz Lewandowski Date: Sun, 11 Dec 2016 17:09:57 +0100 Subject: [PATCH 19/19] Missing stroke parameters in SVG properties --- react/index.d.ts | 3 ++- react/react-tests.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index c600dfcc39..467af23d9f 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -2179,7 +2179,8 @@ declare namespace React { stopColor?: string; stopOpacity?: number | string; stroke?: string; - strokeDasharray?: string; + strokeDasharray?: string | number; + strokeDashoffset?: string | number; strokeLinecap?: "butt" | "round" | "square" | "inherit"; strokeLinejoin?: "miter" | "round" | "bevel" | "inherit"; strokeMiterlimit?: string; diff --git a/react/react-tests.ts b/react/react-tests.ts index c2d80d0dd0..ab23c65532 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -341,13 +341,17 @@ React.DOM.svg({ x: 22, y: 10, width: 4, - height: 28 + height: 28, + strokeDasharray: '30%', + strokeDashoffset: '20%' }), React.DOM.rect({ x: 10, y: 22, width: 28, - height: 4 + height: 4, + strokeDasharray: 30, + strokeDashoffset: 20 }), React.DOM.path({ d: "M0,0V3H3V0ZM1,1V2H2V1Z",