@itwin/presentation-shared
Advanced tools
Comparing version 1.1.0 to 1.2.0
# @itwin/presentation-shared | ||
## 1.2.0 | ||
### Minor Changes | ||
- [#791](https://github.com/iTwin/presentation/pull/791): Added a number of mapped types: | ||
- `Props<TFunc>` obtains the type of the first `TFunc` function argument. | ||
```ts | ||
function func(props: { x: number; y: string }) { | ||
// ... | ||
} | ||
type FunctionProps = Props<typeof func>; // { x: number, y: string } | ||
``` | ||
- `EventListener<TEvent>` obtains the event listener type of given event type. | ||
```ts | ||
type MyEvent = Event<(arg: number) => void>; | ||
type MyEventListener = EventListener<MyEvent>; // (arg: number) => void | ||
``` | ||
- `EventArgs<TEvent>` obtains the type of the first event listener's argument of given event type. | ||
```ts | ||
type MyEvent = Event<(arg: { x: number; y: string }) => void>; | ||
type MyEventArgs = EventArgs<MyEvent>; // { x: number, y: string } | ||
``` | ||
## 1.1.0 | ||
@@ -4,0 +33,0 @@ |
@@ -8,3 +8,3 @@ import * as ECSql from "./shared/ecsql-snippets/index.js"; | ||
export { ILogger, NOOP_LOGGER, LogFunction, LogLevel } from "./shared/Logging.js"; | ||
export { ArrayElement, OmitOverUnion } from "./shared/MappedTypes.js"; | ||
export { ArrayElement, EventArgs, EventListener, OmitOverUnion, Props } from "./shared/MappedTypes.js"; | ||
export { createCachingECClassHierarchyInspector, EC, getClass, ECClassHierarchyInspector, ECSchemaProvider } from "./shared/Metadata.js"; | ||
@@ -11,0 +11,0 @@ export { createMainThreadReleaseOnTimePassedHandler, julianToDateTime, normalizeFullClassName, parseFullClassName, releaseMainThread, trimWhitespace, } from "./shared/Utils.js"; |
@@ -0,1 +1,2 @@ | ||
import { Event } from "./Event.js"; | ||
/** | ||
@@ -11,2 +12,17 @@ * An utility `Omit` type which works with union types. | ||
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; | ||
/** | ||
* Returns type of the first `TFunc` parameter. | ||
* @public | ||
*/ | ||
export type Props<TFunc extends (...args: any[]) => any> = Parameters<TFunc>[0]; | ||
/** | ||
* Returns type of the given `Event` listener. | ||
* @public | ||
*/ | ||
export type EventListener<TEvent extends Event> = TEvent extends Event<infer TListener> ? TListener : never; | ||
/** | ||
* Returns type of the given `Event` arguments. | ||
* @public | ||
*/ | ||
export type EventArgs<TEvent extends Event> = Props<EventListener<TEvent>>; | ||
//# sourceMappingURL=MappedTypes.d.ts.map |
@@ -8,3 +8,3 @@ import * as ECSql from "./shared/ecsql-snippets/index.js"; | ||
export { ILogger, NOOP_LOGGER, LogFunction, LogLevel } from "./shared/Logging.js"; | ||
export { ArrayElement, OmitOverUnion } from "./shared/MappedTypes.js"; | ||
export { ArrayElement, EventArgs, EventListener, OmitOverUnion, Props } from "./shared/MappedTypes.js"; | ||
export { createCachingECClassHierarchyInspector, EC, getClass, ECClassHierarchyInspector, ECSchemaProvider } from "./shared/Metadata.js"; | ||
@@ -11,0 +11,0 @@ export { createMainThreadReleaseOnTimePassedHandler, julianToDateTime, normalizeFullClassName, parseFullClassName, releaseMainThread, trimWhitespace, } from "./shared/Utils.js"; |
@@ -0,1 +1,2 @@ | ||
import { Event } from "./Event.js"; | ||
/** | ||
@@ -11,2 +12,17 @@ * An utility `Omit` type which works with union types. | ||
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; | ||
/** | ||
* Returns type of the first `TFunc` parameter. | ||
* @public | ||
*/ | ||
export type Props<TFunc extends (...args: any[]) => any> = Parameters<TFunc>[0]; | ||
/** | ||
* Returns type of the given `Event` listener. | ||
* @public | ||
*/ | ||
export type EventListener<TEvent extends Event> = TEvent extends Event<infer TListener> ? TListener : never; | ||
/** | ||
* Returns type of the given `Event` arguments. | ||
* @public | ||
*/ | ||
export type EventArgs<TEvent extends Event> = Props<EventListener<TEvent>>; | ||
//# sourceMappingURL=MappedTypes.d.ts.map |
{ | ||
"name": "@itwin/presentation-shared", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "The package contains types and utilities used across different iTwin.js Presentation packages.", | ||
@@ -35,6 +35,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@itwin/core-bentley": "^4.9.0" | ||
"@itwin/core-bentley": "^4.10.1" | ||
}, | ||
"devDependencies": { | ||
"@itwin/build-tools": "^4.10.0-dev.33", | ||
"@itwin/build-tools": "^4.10.1", | ||
"@itwin/eslint-plugin": "5.0.0-dev.1", | ||
@@ -41,0 +41,0 @@ "@types/chai": "^4.3.16", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
294001
4151
Updated@itwin/core-bentley@^4.10.1