mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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
This commit is contained in:
@@ -235,6 +235,9 @@ export class Title {
|
||||
}
|
||||
|
||||
// @public @deprecated
|
||||
export type TransferState = TransferState_2;
|
||||
|
||||
// @public (undocumented)
|
||||
export const TransferState: {
|
||||
new (): TransferState_2;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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: `<span>Original {{childBinding}}</span>`})
|
||||
@@ -46,18 +48,6 @@ class MyIfComp {
|
||||
class ChildChildComp {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'child-comp',
|
||||
template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`,
|
||||
})
|
||||
@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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user