From 74c925c19c5a8f4823fa929700f6599970cd61d3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 26 Apr 2023 14:59:11 +0000 Subject: [PATCH] fix(platform-browser): export deprecated `TransferState` as type (#50015) Prior to this commit `TransferState` re-export could not be used as a type. Closes #50014 PR Close #50015 --- goldens/public-api/platform-browser/index.md | 3 +++ .../platform-browser/src/platform-browser.ts | 2 ++ .../test/testing_public_spec.ts | 19 +++++++------------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/goldens/public-api/platform-browser/index.md b/goldens/public-api/platform-browser/index.md index df3ccad791a..afebeb18013 100644 --- a/goldens/public-api/platform-browser/index.md +++ b/goldens/public-api/platform-browser/index.md @@ -235,6 +235,9 @@ export class Title { } // @public @deprecated +export type TransferState = TransferState_2; + +// @public (undocumented) export const TransferState: { new (): TransferState_2; }; diff --git a/packages/platform-browser/src/platform-browser.ts b/packages/platform-browser/src/platform-browser.ts index 2efc7402599..29691fe244d 100644 --- a/packages/platform-browser/src/platform-browser.ts +++ b/packages/platform-browser/src/platform-browser.ts @@ -47,6 +47,8 @@ export const makeStateKey = makeStateKeyFromCore; * instead. */ // The below is a workaround to add a deprecated message. +export type TransferState = TransferStateFromCore; +// The below type is needed for G3 due to JSC_CONFORMANCE_VIOLATION. export const TransferState: {new (): TransferStateFromCore} = TransferStateFromCore; /** diff --git a/packages/platform-browser/test/testing_public_spec.ts b/packages/platform-browser/test/testing_public_spec.ts index 71636f07d25..1746c057a79 100644 --- a/packages/platform-browser/test/testing_public_spec.ts +++ b/packages/platform-browser/test/testing_public_spec.ts @@ -11,6 +11,8 @@ import {Compiler, Component, ComponentFactoryResolver, CUSTOM_ELEMENTS_SCHEMA, D import {fakeAsync, getTestBed, inject, TestBed, tick, waitForAsync, withModule} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/src/matchers'; +import {TransferState} from '../public_api'; + // Services, and components for the tests. @Component({selector: 'child-comp', template: `Original {{childBinding}}`}) @@ -46,18 +48,6 @@ class MyIfComp { class ChildChildComp { } -@Component({ - selector: 'child-comp', - template: `Original {{childBinding}}()`, -}) -@Injectable() -class ChildWithChildComp { - childBinding: string; - constructor() { - this.childBinding = 'Child'; - } -} - class FancyService { value: string = 'real value'; getAsyncValue() { @@ -1057,5 +1047,10 @@ Did you run and wait for 'resolveComponentResources()'?`); /Cannot override template when the test module has already been instantiated/); }); }); + + it('TransferState re-export can be used as a type and contructor', () => { + const transferState: TransferState = new TransferState(); + expect(transferState).toBeDefined(); + }); }); }