Skip to content

Commit

Permalink
build: 3.0.0
Browse files Browse the repository at this point in the history
17.0.4 版本提取
  • Loading branch information
wszgrcy committed Nov 21, 2023
1 parent f84b464 commit 5eca989
Show file tree
Hide file tree
Showing 23 changed files with 555 additions and 55 deletions.
284 changes: 274 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prettier": "^2.3.2",
"pretty-quick": "^3.1.3",
"rimraf": "^5.0.1",
"rollup": "^3.29.4",
"rollup": "~4.5.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
- 这是 Angualr 依赖注入的独立版本,初始版本逻辑为从 Angular 源码中提取出来,并修复了一些已知 bug
- 使用方法与 Angular 的依赖注入完全一致
# 来源
- Angular 16.2.2
- Angular 17.0.4
# 兼容
- ts 5.1.6
- ts 5.2.2
# 使用方法

-`Injector.create`创建第一级依赖注入器
Expand Down
6 changes: 3 additions & 3 deletions src/import/di/initializer_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ import { InjectionToken } from './injection_token';
*
* @publicApi
*/
export const ENVIRONMENT_INITIALIZER = new InjectionToken<() => void>(
'ENVIRONMENT_INITIALIZER'
);
export const ENVIRONMENT_INITIALIZER = new InjectionToken<
ReadonlyArray<() => void>
>('ENVIRONMENT_INITIALIZER');
17 changes: 11 additions & 6 deletions src/import/di/injection_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ import { ɵɵdefineInjectable } from './interface/defs';
* `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
* the `Injector`. This provides an additional level of type safety.
*
* ```
* interface MyInterface {...}
* const myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
* // myInterface is inferred to be MyInterface.
* ```
* <div class="alert is-helpful">
*
* **Important Note**: Ensure that you use the same instance of the `InjectionToken` in both the
* provider and the injection call. Creating a new instance of `InjectionToken` in different places,
* even with the same description, will be treated as different tokens by Angular's DI system,
* leading to a `NullInjectorError`.
*
* </div>
*
* <code-example format="typescript" language="typescript" path="injection-token/src/main.ts"
* region="InjectionToken"></code-example>
*
* When creating an `InjectionToken`, you can optionally specify a factory function which returns
* (possibly by creating) a default value of the parameterized type `T`. This sets up the
Expand All @@ -51,7 +57,6 @@ import { ɵɵdefineInjectable } from './interface/defs';
*
* {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
*
*
* @publicApi
*/
export class InjectionToken<T> {
Expand Down
6 changes: 3 additions & 3 deletions src/import/di/internal_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import { Type } from '../interface/type';

import { InjectionToken } from './injection_token';

export const INJECTOR_DEF_TYPES = new InjectionToken<Type<unknown>>(
'INJECTOR_DEF_TYPES'
);
export const INJECTOR_DEF_TYPES = new InjectionToken<
ReadonlyArray<Type<unknown>>
>('INJECTOR_DEF_TYPES');
Loading

0 comments on commit 5eca989

Please sign in to comment.