Skip to content

Commit 74c925c

Browse files
alan-agius4dylhunn
authored andcommitted
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
1 parent a152940 commit 74c925c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

goldens/public-api/platform-browser/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ export class Title {
235235
}
236236

237237
// @public @deprecated
238+
export type TransferState = TransferState_2;
239+
240+
// @public (undocumented)
238241
export const TransferState: {
239242
new (): TransferState_2;
240243
};

packages/platform-browser/src/platform-browser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export const makeStateKey = makeStateKeyFromCore;
4747
* instead.
4848
*/
4949
// The below is a workaround to add a deprecated message.
50+
export type TransferState = TransferStateFromCore;
51+
// The below type is needed for G3 due to JSC_CONFORMANCE_VIOLATION.
5052
export const TransferState: {new (): TransferStateFromCore} = TransferStateFromCore;
5153

5254
/**

packages/platform-browser/test/testing_public_spec.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {Compiler, Component, ComponentFactoryResolver, CUSTOM_ELEMENTS_SCHEMA, D
1111
import {fakeAsync, getTestBed, inject, TestBed, tick, waitForAsync, withModule} from '@angular/core/testing';
1212
import {expect} from '@angular/platform-browser/testing/src/matchers';
1313

14+
import {TransferState} from '../public_api';
15+
1416
// Services, and components for the tests.
1517

1618
@Component({selector: 'child-comp', template: `<span>Original {{childBinding}}</span>`})
@@ -46,18 +48,6 @@ class MyIfComp {
4648
class ChildChildComp {
4749
}
4850

49-
@Component({
50-
selector: 'child-comp',
51-
template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`,
52-
})
53-
@Injectable()
54-
class ChildWithChildComp {
55-
childBinding: string;
56-
constructor() {
57-
this.childBinding = 'Child';
58-
}
59-
}
60-
6151
class FancyService {
6252
value: string = 'real value';
6353
getAsyncValue() {
@@ -1057,5 +1047,10 @@ Did you run and wait for 'resolveComponentResources()'?`);
10571047
/Cannot override template when the test module has already been instantiated/);
10581048
});
10591049
});
1050+
1051+
it('TransferState re-export can be used as a type and contructor', () => {
1052+
const transferState: TransferState = new TransferState();
1053+
expect(transferState).toBeDefined();
1054+
});
10601055
});
10611056
}

0 commit comments

Comments
 (0)