private screensMap: Map<string, ComponentType<any>>;
public constructor() {
this.screensMap = new Map()
.set(BootstrapLaunch.name, BootstrapLaunch)
.set(BootstrapWelcome.name, BootstrapWelcome);
}
但这是失败的:
private screensMap: Map<string, ComponentType<any>>;
public constructor() {
this.screensMap = new Map([
[BootstrapLaunch.name, BootstrapLaunch],
[BootstrapWelcome.name, BootstrapWelcome],
]);
}
下一个错误是:
error TS2345: Argument of type '([string, typeof BootstrapLaunch] | [string, typeof BootstrapWelcome])[]' is not assignable to parameter of type 'ReadonlyArray<[string, typeof BootstrapLaunch]>'.
Type '[string, typeof BootstrapLaunch] | [string, typeof BootstrapWelcome]' is not assignable to type '[string, typeof BootstrapLaunch]'.
Type '[string, typeof BootstrapWelcome]' is not assignable to type '[string, typeof BootstrapLaunch]'.
Type 'typeof BootstrapWelcome' is not assignable to type 'typeof BootstrapLaunch'.
Type 'BootstrapWelcome' is not assignable to type 'BootstrapLaunch'.
Types of property 'componentDidMount' are incompatible.
Type '(() => void) | undefined' is not assignable to type '() => void'.
Type 'undefined' is not assignable to type '() => void'.