From 72e896c5583fdbc9a7f3d5f7f51eaacbf833c45e Mon Sep 17 00:00:00 2001 From: Alexander T Date: Tue, 29 Oct 2019 06:13:30 +0200 Subject: [PATCH] forge-di: Provides its own types (#39608) --- notNeededPackages.json | 6 + types/forge-di/forge-di-tests.ts | 51 -------- types/forge-di/index.d.ts | 205 ------------------------------- types/forge-di/tsconfig.json | 23 ---- types/forge-di/tslint.json | 80 ------------ 5 files changed, 6 insertions(+), 359 deletions(-) delete mode 100644 types/forge-di/forge-di-tests.ts delete mode 100644 types/forge-di/index.d.ts delete mode 100644 types/forge-di/tsconfig.json delete mode 100644 types/forge-di/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 02eb629da9..37dc0ae75d 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1230,6 +1230,12 @@ "sourceRepoURL": "https://github.com/acdlite/flux-standard-action", "asOfVersion": "1.1.0" }, + { + "libraryName": "forge-di", + "typingsPackageName": "forge-di", + "sourceRepoURL": "https://github.com/nkohari/forge", + "asOfVersion": "12.0.2" + }, { "libraryName": "fork-ts-checker-webpack-plugin", "typingsPackageName": "fork-ts-checker-webpack-plugin", diff --git a/types/forge-di/forge-di-tests.ts b/types/forge-di/forge-di-tests.ts deleted file mode 100644 index 1880c62dc3..0000000000 --- a/types/forge-di/forge-di-tests.ts +++ /dev/null @@ -1,51 +0,0 @@ - -import Forge = require('forge-di'); - -var forge = new Forge(); - -class Bar {} - -class Foo { - constructor(public bar: Bar) { - } -} - -forge.bind('foo').to.type(Foo); -forge.bind('bar').to.type(Bar); - -var foo: Foo = forge.get('foo'); -var barInst = foo.bar; - -// register functions -var createFoo = (bar: Bar) => new Foo(bar); -forge.bind('foo').to.function(createFoo); - -// Conditional bindings and resolution hints -class RedFoo {} -class BlueFoo {} - -forge.bind('foo').to.type(RedFoo).when('red'); -forge.bind('foo').to.type(BlueFoo).when((hint) => hint === 'blue'); - -// Lifecycles -forge.bind('foo').to.type(Foo).as.singleton(); -forge.bind('bar').to.type(Bar).as.transient(); - -// explicit arguments -var manuallyCreatedBar = new Bar(); -forge.bind('foo').to.type(Foo).with({bar: manuallyCreatedBar}); - -var bindingArgs: Forge.IBindingArguments = { - bar: manuallyCreatedBar -}; -forge.bind('foo').to.type(Foo).with(bindingArgs); - -// Ephemeral Bindings TODO -class DependsOnFoo { - constructor(public foo: Foo){} -} -var dependsOnFoo = forge.create(DependsOnFoo); - -// Unbinding and rebinding -forge.unbind('foo'); -forge.rebind('foo').to.type(Foo); \ No newline at end of file diff --git a/types/forge-di/index.d.ts b/types/forge-di/index.d.ts deleted file mode 100644 index d7b3dd8965..0000000000 --- a/types/forge-di/index.d.ts +++ /dev/null @@ -1,205 +0,0 @@ -// Type definitions for forge-di v0.9.5 -// Project: https://github.com/nkohari/forge -// Definitions by: Adam Carr -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -/** - * Implementation of the forge dependency injection manager. - */ -declare class Forge { - /** - * Creates a new instance - * @returns {Forge} a new instance. - */ - constructor(); - - /** - * The bindings mapped to this forge instance. - */ - bindings: Forge.IBindingMap; - - /** - * Creates a new binding. - * @param {string} name The binding name. - */ - bind(name: string): Forge.IBinding; - /** - * Unbinds then recreates a binding for this name. - * @param {string} name The binding name. - */ - rebind(name: string): Forge.IBinding; - /** - * Unbinds all bindings for this name. Returns the number of bindings removed. - * @param {string} name The binding name. - */ - unbind(name: string): number; - /** - * Get instance or instances of type registered under the provided name and optional hint. - * @param {string} name The binding name. - * @param {string} hint The binding hint. - * @param {...args} args Additional args. - */ - get(name: string, hint?: string, ...args: any[]): T; - /** - * Get a single instance of type registered under the provided name and optional hint. - * @param {string} name The binding name. - * @param {string} hint The binding hint. - * @param {...args} args Additional args. - */ - getOne(name: string, hint?: string, ...args: any[]): T; - /** - * Gets all instances of the type registered under the provided name. - * @param {string} name The binding name. - * @param {...args} args Additional args. - */ - getAll(name: string, ...args: any[]): T | T[]; - /** - * Creates an instance of the target type attempting to resolve any dependencies. - * @param {T} target The target type. - * @param {...args} args Additional args. - */ - create(target: T, ...args: any[]): T; - /** - * Get all bindings registered under a binding name and optional hint. - * @param {string} name The binding name. - * @param {string} hint The binding hint. - */ - getMatchingBindings(name: string, hint?: string): Forge.IBinding[]; - /** - * Returns a string that represents all bindings within this forge instance. - */ - inspect(): string; - - resolve(name: string, context?: Forge.IContext, hint?: string, all?: boolean, ...args: any[]): T | T[]; - resolveBindings(context: Forge.IContext, bindings: Forge.IBinding[], hint: string, args: any[], unwrap: boolean): Forge.IBinding[]; -} - -declare namespace Forge { - interface IContext { - new (): IContext; - bindings: IBinding[]; - has(binding: IBinding): boolean; - push(binding: IBinding): void; - pop(): IBinding; - toString(indent: number): string; - } - - interface IType { - new (...args: any[]): any; - } - - /** - * Represents arguments to help with resolving a binding. - */ - interface IBindingArguments { - [name: string]: any; - } - - /** - * Represents a binding between a name, type/instance/function and optional hint. - */ - interface IBinding { - /** The forge that contains this binding. */ - forge: Forge; - /** The binding name. */ - name: string; - /** Alias mapping to this binding. */ - to: IBinding; - /** Alias mapping to this binding. */ - as: IBinding; - /** Whether or not this binding is currently resolving. */ - isResolving: boolean; - /** The resolver for this binding. */ - resolver: IResolver; - /** The lifecycle associated with this binding. Defaults to singleton. */ - lifecycle: ILifecycle; - /** The predicate associated with this binding. Used to support hints. */ - predicate: IPredicate; - /** The additional binding arguments to help resolve dependencies. */ - arguments: IBindingArguments; - - /** - * Checks whether or not this binding matches the hint by executing the predicate. - * @param {string} hint The hint to check against. - */ - matches(hint: string): boolean; - /** - * Registers a type to a binding. This type must have a constructor. - * @param {T} target The target type. - */ - type(target: T): IBinding; - /** - * Registers a type to a binding. This must be a callable function. - * @param {T} target The target function. - */ - function(target: T): IBinding; - /** - * Registeres an instance to a binding. This instance will always be returned. - * @param {T} target The target instance. - */ - instance(target: T): IBinding; - /** - * Configures this binding lifecycle as a singleton. This is the default lifecycle. - */ - singleton(): IBinding; - /** - * Configures this binding lifecycle as transient. - * New instances will be created, if this is a type based binding, on each get. - */ - transient(): IBinding; - /** - * Registers a predicate for this binding. - * @param {IPredicate} predicate The predicate. - */ - when(predicate: IPredicate): IBinding; - /** - * Registers a hint for this binding. - * @param {string} hint The hint. - */ - when(hint: string): IBinding; - /** - * Registers additional binding arguments to help with resolving. - * @param {IBindingArguments} args The additional binding arguments. - */ - with(args: IBindingArguments): IBinding; - /** - * Returns a string representing this binding. - */ - toString(): string; - } - - /** Represents a binding map. */ - interface IBindingMap { - /** Gets a binding by name. */ - [name: string]: IBinding[]; - } - - /** Represents a predicate. */ - interface IPredicate { - /** - * Returns whether or not the hit satisfies this predicate. - * @param {string} hint The hint to check against. - */ - (hint: string): boolean; - } - - /** Represents a resolver. */ - interface IResolver { - /** - * Resolves a specific type. - */ - resolve(): T; - } - - /** Represents a binding lifecycle. */ - interface ILifecycle { - /** - * Returns the instance from a resolver based on the configured lifecycle. - * @param {IResolver} resolver The type resolver. - */ - getInstance(resolver: IResolver): T; - } -} - -export = Forge; diff --git a/types/forge-di/tsconfig.json b/types/forge-di/tsconfig.json deleted file mode 100644 index 14aa632323..0000000000 --- a/types/forge-di/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "forge-di-tests.ts" - ] -} \ No newline at end of file diff --git a/types/forge-di/tslint.json b/types/forge-di/tslint.json deleted file mode 100644 index 3d59f55fda..0000000000 --- a/types/forge-di/tslint.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "npm-naming": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -}