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:
Kristiyan Kostadinov 2025-07-15 16:30:56 +02:00
parent acdb8d673d
commit 6dc29b3bf7
4 changed files with 16 additions and 0 deletions

View file

@ -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};
}

View file

@ -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';

View 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 {}

View file

@ -34,6 +34,7 @@ const AOT_ONLY = new Set<string>([
'ɵINPUT_SIGNAL_BRAND_WRITE_TYPE',
'ɵUnwrapDirectiveSignalInputs',
'ɵunwrapWritableSignal',
'ɵassertType',
]);
/**