mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): expose function to assert type of variables (#62648)
Adds the `ɵassertType` function that will be used during type checking to assert the type of a value. PR Close #62648
This commit is contained in:
parent
acdb8d673d
commit
6dc29b3bf7
4 changed files with 16 additions and 0 deletions
|
|
@ -469,4 +469,5 @@ export class Identifiers {
|
|||
static InputSignalBrandWriteType = {name: 'ɵINPUT_SIGNAL_BRAND_WRITE_TYPE', moduleName: CORE};
|
||||
static UnwrapDirectiveSignalInputs = {name: 'ɵUnwrapDirectiveSignalInputs', moduleName: CORE};
|
||||
static unwrapWritableSignal = {name: 'ɵunwrapWritableSignal', moduleName: CORE};
|
||||
static assertType = {name: 'ɵassertType', moduleName: CORE};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,3 +171,4 @@ export {getClosestComponentName as ɵgetClosestComponentName} from './internal/g
|
|||
export {getComponentDef as ɵgetComponentDef} from './render3/def_getters';
|
||||
export {DEHYDRATED_BLOCK_REGISTRY as ɵDEHYDRATED_BLOCK_REGISTRY} from './defer/registry';
|
||||
export {TimerScheduler as ɵTimerScheduler} from './defer/timer_scheduler';
|
||||
export {ɵassertType} from './type_checking';
|
||||
|
|
|
|||
13
packages/core/src/type_checking.ts
Normal file
13
packages/core/src/type_checking.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility function used during template type checking to assert that a value is of a certain type.
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵassertType<T>(value: unknown): asserts value is T {}
|
||||
|
|
@ -34,6 +34,7 @@ const AOT_ONLY = new Set<string>([
|
|||
'ɵINPUT_SIGNAL_BRAND_WRITE_TYPE',
|
||||
'ɵUnwrapDirectiveSignalInputs',
|
||||
'ɵunwrapWritableSignal',
|
||||
'ɵassertType',
|
||||
]);
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue