mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): add utility type for extracting the value of a custom control
Adds the `ɵExtractFormControlValue` type that we can use during template type checking to extract the type of a custom control.
(cherry picked from commit 4b68bddd62)
This commit is contained in:
parent
96cb0cffda
commit
6df098f76c
5 changed files with 16 additions and 0 deletions
|
|
@ -494,6 +494,7 @@ export class Identifiers {
|
|||
// type-checking
|
||||
static InputSignalBrandWriteType = {name: 'ɵINPUT_SIGNAL_BRAND_WRITE_TYPE', moduleName: CORE};
|
||||
static UnwrapDirectiveSignalInputs = {name: 'ɵUnwrapDirectiveSignalInputs', moduleName: CORE};
|
||||
static ExtractFormControlValue = {name: 'ɵExtractFormControlValue', moduleName: CORE};
|
||||
static unwrapWritableSignal = {name: 'ɵunwrapWritableSignal', moduleName: CORE};
|
||||
static assertType = {name: 'ɵassertType', moduleName: CORE};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ export {
|
|||
ɵɵcontentQuerySignal,
|
||||
ɵɵcontrol,
|
||||
ɵɵcontrolCreate,
|
||||
ɵExtractFormControlValue,
|
||||
ɵɵcomponentInstance,
|
||||
ɵɵCopyDefinitionFeature,
|
||||
ɵɵdefineComponent,
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ export {
|
|||
ɵɵproperty,
|
||||
ɵɵcontrol,
|
||||
ɵɵcontrolCreate,
|
||||
ɵExtractFormControlValue,
|
||||
ɵɵcontentQuery,
|
||||
ɵɵcontentQuerySignal,
|
||||
ɵɵloadQuery,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,18 @@ import {listenToOutput} from '../view/directive_outputs';
|
|||
import {listenToDomEvent, wrapListener} from '../view/listeners';
|
||||
import {setPropertyAndInputs, storePropertyBindingMetadata} from './shared';
|
||||
import {writeToDirectiveInput} from './write_to_directive_input';
|
||||
import {ModelSignal} from '../../authoring/model/model_signal';
|
||||
|
||||
/**
|
||||
* Used during template type checking to extract the type of a custom form control.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export type ɵExtractFormControlValue<T> = T extends {value: ModelSignal<infer V>}
|
||||
? V
|
||||
: T extends {checked: ModelSignal<boolean>}
|
||||
? boolean
|
||||
: unknown;
|
||||
|
||||
/**
|
||||
* Possibly sets up a {@link ɵControl} to manage a native or custom form control.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ const AOT_ONLY = new Set<string>([
|
|||
|
||||
// used in type-checking.
|
||||
'ɵINPUT_SIGNAL_BRAND_WRITE_TYPE',
|
||||
'ɵExtractFormControlValue',
|
||||
'ɵUnwrapDirectiveSignalInputs',
|
||||
'ɵunwrapWritableSignal',
|
||||
'ɵassertType',
|
||||
|
|
|
|||
Loading…
Reference in a new issue