Fixing confusion with the new and constructor keywords. (#38997)

* remove non-existing constructor method from Array in Ember

* removed method named "new" and added a constructor to the Collaborator class in google-drive-realtime

* made LocalizedObservable into the class that it actually is in Knockout

* removed a method named "constructor" and replaced it with a constructor in microsoft-ajax

* removed a method called "new" and replaced it with a constructor in microsoft-ajax

* autoformat

* made QueryCursor into the class it actually is in mongoose

* made Connection into a class

* made QueryStream and QueryCursor into a classes

* removed two methods called "new" and replaced them with constructors

* change EventSubscriptionVendor into a class

* removed class only used internally Route (it had a wrongly declared method named "constructor")

* removed non-existing method named "constructor" in rx-angular

* made StackFrame into a class

* made StreamMeter into a class

* removed a method named "new" and replaced it with a constructor
This commit is contained in:
Erik Krogh Kristensen 2019-10-15 19:07:05 +02:00 committed by Andrew Branch
parent 225c60cb41
commit 5d1074409c
14 changed files with 53 additions and 56 deletions

View File

@ -192,7 +192,6 @@ interface String {
}
interface Array<T> {
constructor(arr: any[]): void;
activate(): void;
addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[];
addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[];

View File

@ -12,7 +12,7 @@ declare class Forge {
* Creates a new instance
* @returns {Forge} a new instance.
*/
new(): Forge;
constructor();
/**
* The bindings mapped to this forge instance.

View File

@ -52,8 +52,8 @@ declare namespace gapi.drive.realtime {
// use the permissionId property.
userId : string;
new (sessionId:string, userId:string, displayName:string, color:string, isMe:boolean, isAnonymous:boolean,
photoUrl:string, permissionId:string) : Collaborator;
constructor (sessionId:string, userId:string, displayName:string, color:string, isMe:boolean, isAnonymous:boolean,
photoUrl:string, permissionId:string);
}
// Complete

View File

@ -76,8 +76,8 @@ declare namespace Knockback {
constructor (format: KnockoutObservable<any>, args: any[]);
}
interface LocalizedObservable {
constructor (value: any, options: any, vm: any);
class LocalizedObservable {
constructor(value: any, options: any, vm: any);
destroy();
resetToCurrent();
observedValue(value: any);

View File

@ -627,7 +627,7 @@ declare namespace Sys {
//#region Constructors
constructor(): void;
new(): void;
//#endregion
@ -2505,8 +2505,7 @@ declare namespace Sys {
* @see {@link http://msdn.microsoft.com/en-us/library/bb383800(v=vs.100).aspx}
*/
class ProfileService {
new(): ProfileService;
constructor();
//#region Fields
@ -2525,24 +2524,29 @@ declare namespace Sys {
//#region Methods
/**
* Loads the specified profile properties.
*
* If propertyNames is not supplied, all profile properties enabled for read access are loaded from the server.
* The loaded profile can then be accessed directly from the properties field.
* This enables your application to access the profile properties by using simple field syntax, as shown in the following example:
* @example
* Sys.Services.ProfileService.load(null, LoadCompletedCallback, ProfileFailedCallback, null);
*
* @param propertyName
* A string array that contains the profile properties to load.
* @param loadCompletedCallback
* The function that is called when loading has completed. The default is null.
* @param failedCallback
* The function that is called when loading has failed. The default is null.
* @param userContext
* User context information passed to the callback functions.
*/
static load(propertyNames: string[], loadCompletedCallback: Function, failedCallback: Function, userContext: any): void;
* Loads the specified profile properties.
*
* If propertyNames is not supplied, all profile properties enabled for read access are loaded from the server.
* The loaded profile can then be accessed directly from the properties field.
* This enables your application to access the profile properties by using simple field syntax, as shown in the following example:
* @example
* Sys.Services.ProfileService.load(null, LoadCompletedCallback, ProfileFailedCallback, null);
*
* @param propertyName
* A string array that contains the profile properties to load.
* @param loadCompletedCallback
* The function that is called when loading has completed. The default is null.
* @param failedCallback
* The function that is called when loading has failed. The default is null.
* @param userContext
* User context information passed to the callback functions.
*/
static load(
propertyNames: string[],
loadCompletedCallback: Function,
failedCallback: Function,
userContext: any,
): void;
/**
* @param propertyNames
* A string array that contains the profile properties to save.
@ -2553,7 +2557,12 @@ declare namespace Sys {
* @param userContext
* User context information passed to the callback functions.
*/
static save(propertyNames: string[], saveCompletedCallback: Function, failedCallback: Function, userContext: any): void;
static save(
propertyNames: string[],
saveCompletedCallback: Function,
failedCallback: Function,
userContext: any,
): void;
//#endregion

View File

@ -620,7 +620,7 @@ declare module "mongoose" {
* QueryCursor can only be accessed by query#cursor(), we only
* expose its interface to enable type-checking.
*/
interface QueryCursor<T extends Document> extends stream.Readable {
class QueryCursor<T extends Document> extends stream.Readable {
/**
* A QueryCursor is a concurrency primitive for processing query results
* one document at a time. A QueryCursor fulfills the Node.js streams3 API,
@ -634,7 +634,7 @@ declare module "mongoose" {
* @event data Emitted when the stream is flowing and the next doc is ready
* @event end Emitted when the stream is exhausted
*/
constructor(query: Query<T>, options: any): QueryCursor<T>;
constructor(query: Query<T>, options: any);
/** Marks this cursor as closed. Will stop streaming and subsequent calls to next() will error. */
close(callback?: (error: any, result: any) => void): Promise<any>;

View File

@ -45,8 +45,8 @@ declare module "mongoose" {
Promise: any;
}
export interface Connection extends NodeJS.EventEmitter {
constructor(base: Mongoose): Connection;
export class Connection extends NodeJS.EventEmitter {
constructor(base: Mongoose);
close(callback?: (err: any) => void): Connection;
collection(name: string, options?: Object): Collection;

View File

@ -215,7 +215,7 @@ declare module "mongoose" {
* QueryStream can only be accessed using query#stream(), we only
* expose its interface here.
*/
interface QueryStream extends stream.Stream {
class QueryStream extends stream.Stream {
/**
* Provides a Node.js 0.8 style ReadStream interface for Queries.
* @event data emits a single Mongoose document
@ -230,7 +230,7 @@ declare module "mongoose" {
*/
transform?: Function;
[other: string]: any;
}): QueryStream;
});
/**
* Destroys the stream, closing the underlying cursor, which emits the close event.
@ -550,7 +550,7 @@ declare module "mongoose" {
* QueryCursor can only be accessed by query#cursor(), we only
* expose its interface to enable type-checking.
*/
interface QueryCursor<T extends Document> extends stream.Readable {
class QueryCursor<T extends Document> extends stream.Readable {
/**
* A QueryCursor is a concurrency primitive for processing query results
* one document at a time. A QueryCursor fulfills the Node.js streams3 API,
@ -564,7 +564,7 @@ declare module "mongoose" {
* @event data Emitted when the stream is flowing and the next doc is ready
* @event end Emitted when the stream is exhausted
*/
constructor(query: Query<T>, options: any): QueryCursor<T>;
constructor(query: Query<T>, options: any);
/** Marks this cursor as closed. Will stop streaming and subsequent calls to next() will error. */
close(callback?: (error: any, result: any) => void): Promise<any>;

View File

@ -29,7 +29,7 @@ export type AddableFunction = (runtime: Flow) => void;
export type AddableToAction = Action | AddableFunction;
export class EventContext {
new(context: EventContext | object): this;
constructor(context: EventContext | object);
stageContext(topics: string | ReadonlyArray<string>): StageContext;
state(): State;
repub(type: string, handler: (event: any) => void): void;
@ -44,7 +44,7 @@ export class StageContext extends EventContext {
}
export class ReadableStream extends Readable {
new(topic: string, emitter: EventEmitter): this;
constructor(topic: string, emitter: EventEmitter);
push(data: any): boolean;
}

View File

@ -89,8 +89,8 @@ interface EventSubscription {
* EventSubscriptionVendor stores a set of EventSubscriptions that are
* subscribed to a particular event type.
*/
interface EventSubscriptionVendor {
constructor(): EventSubscriptionVendor;
declare class EventSubscriptionVendor {
constructor();
/**
* Adds a subscription keyed by an event type.

View File

@ -4,15 +4,6 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace routie {
interface Route {
constructor(path: string, name: string): Route;
addHandler(fn: Function): void;
removeHandler(fn: Function): void;
run(params: any): void;
match(path: string, params: any): boolean;
toURL(params: any): string;
}
interface Routie extends RoutieStatic {
(path: string): void;
(path: string, fn: Function): void;

View File

@ -13,9 +13,7 @@ declare namespace Rx {
safeApply($scope: ng.IScope, callback: (data: T) => void): Rx.Observable<T>;
}
export interface ScopeScheduler extends IScheduler {
constructor(scope: ng.IScope) : ScopeScheduler;
}
export interface ScopeScheduler extends IScheduler {}
export interface ScopeSchedulerStatic extends SchedulerStatic {
new ($scope: angular.IScope): ScopeScheduler;

View File

@ -22,8 +22,8 @@ declare namespace StackTrace {
offline?: boolean;
}
export interface StackFrame {
constructor(functionName: string, args: any, fileName: string, lineNumber: number, columnNumber: number): StackFrame;
export class StackFrame {
constructor(functionName: string, args: any, fileName: string, lineNumber: number, columnNumber: number);
functionName: string;
args: any;

View File

@ -10,8 +10,8 @@ import { Transform } from 'stream';
declare function m(maxBytes?: number): m.StreamMeter;
declare namespace m {
export interface StreamMeter extends Transform {
constructor(maxBytes?: number): StreamMeter;
export class StreamMeter extends Transform {
constructor(maxBytes?: number);
bytes: number;
maxBytes: number;
}