gpt4 book ai didi

Angular2 AoT - 不支持表达形式

转载 作者:太空狗 更新时间:2023-10-29 18:32:08 27 4
gpt4 key购买 nike

我正在尝试使用 ngc 编译 angular 2.4.4:

Error: Error encountered resolving symbol values statically. Expression form not supported (position 52:9 in the original .ts file), resolving symbol DEFAULT_APP_STATE in...

它看起来像是在提示我如何为@ngrx/store 导出常量。

我尝试将常量更改为导出函数...以及所有属性。

之前:

export const DEFAULT_APP_STATE = {
Offline: DEFAULT_APP_OFFLINE_STATE,
Initialized: DEFAULT_APP_INITIALIZED_STATE,
Console: DEFAULT_CONSOLE_DICTIONARY,
Identity: DEFAULT_IDENTITY,
HamburgerState: DEFAULT_HAMBURGER_STATE,
Customers: DEFAULT_CUSTOMER_STATE,
UserMenuVisibility: DEFAULT_USER_MENU_VISIBILITY,
StreamViewMultiple: DEFAULT_STREAM_VIEW_MULTIPLE_STATE,
StreamViewSingle: DEFAULT_STREAM_VIEW_SINGLE_STATE,
Streams: DEFAULT_STREAM_DICTIONARY,
Destinations: DEFAULT_DESTINATION_DICTIONARY,
DestinationList: DEFAULT_DESTINATION_LIST_STATE,
IDestinationTranscodeModal: DEFAULT_DESTINATION_TRANSCODE_MODAL_STATE
} as IAppState;

目前:

export function DEFAULT_APP_STATE() {
return {
Offline: DEFAULT_APP_OFFLINE_STATE(),
Initialized: DEFAULT_APP_INITIALIZED_STATE(),
Console: DEFAULT_CONSOLE_DICTIONARY(),
Identity: DEFAULT_IDENTITY(),
HamburgerState: DEFAULT_HAMBURGER_STATE(),
Customers: DEFAULT_CUSTOMER_STATE(),
UserMenuVisibility: DEFAULT_USER_MENU_VISIBILITY(),
StreamViewMultiple: DEFAULT_STREAM_VIEW_MULTIPLE_STATE(),
StreamViewSingle: DEFAULT_STREAM_VIEW_SINGLE_STATE(),
Streams: DEFAULT_STREAM_DICTIONARY(),
Destinations: DEFAULT_DESTINATION_DICTIONARY(),
DestinationList: DEFAULT_DESTINATION_LIST_STATE(),
IDestinationTranscodeModal: DEFAULT_DESTINATION_TRANSCODE_MODAL_STATE()
} as IAppState;
};

我在我的 imports[] 中使用它:

...
imports: [
...,
StoreModule.provideStore({
Offline: APP_OFFLINE_REDUCER,
Initialized: APP_INITIALIZED_REDUCER,
Console: CONSOLE_REDUCER,
Identity: IDENTITY_REDUCER,
Customers: CUSTOMER_REDUCER,
Hamburger: HAMBURGER_REDUCER,
UserMenuVisibility: USER_MENU_VISIBILITY_REDUCER,
StreamViewSingle: STREAM_VIEW_SINGLE_REDUCER,
StreamViewMultiple: STREAM_VIEW_MULTIPLE_REDUCER,
Streams: STREAM_REDUCER,
Destinations: DESTINATION_REDUCER,
DestinationList: DESTINATION_LIST_REDUCER,
DestinationTranscodeModal: DESTINATION_TRANSCODE_MODAL_REDUCER
}, DEFAULT_APP_STATE()),
...
],...

每个 reducer 都已经从常量 lambda 声明更改为导出函数

export const reducer = () => { ...} 

export function reducer() { ... }

谁能理解 ngc 编译器在提示什么?

最佳答案

在此特定实例中,一旦我将原始常量声明修改为不使用“...作为 IAppState”子句,ngc compliation 就会停止提示。

没用:

export const DEFAULT_APP_STATE = {
Offline: DEFAULT_APP_OFFLINE_STATE,
Initialized: DEFAULT_APP_INITIALIZED_STATE,
Console: DEFAULT_CONSOLE_DICTIONARY,
Identity: DEFAULT_IDENTITY,
HamburgerState: DEFAULT_HAMBURGER_STATE,
Customers: DEFAULT_CUSTOMER_STATE,
UserMenuVisibility: DEFAULT_USER_MENU_VISIBILITY,
StreamViewMultiple: DEFAULT_STREAM_VIEW_MULTIPLE_STATE,
StreamViewSingle: DEFAULT_STREAM_VIEW_SINGLE_STATE,
Streams: DEFAULT_STREAM_DICTIONARY,
Destinations: DEFAULT_DESTINATION_DICTIONARY,
DestinationList: DEFAULT_DESTINATION_LIST_STATE,
IDestinationTranscodeModal: DEFAULT_DESTINATION_TRANSCODE_MODAL_STATE
} as IAppState;

工作:

export const DEFAULT_APP_STATE: IAppState = {
Offline: DEFAULT_APP_OFFLINE_STATE,
Initialized: DEFAULT_APP_INITIALIZED_STATE,
Console: DEFAULT_CONSOLE_DICTIONARY,
Identity: DEFAULT_IDENTITY,
HamburgerState: DEFAULT_HAMBURGER_STATE,
Customers: DEFAULT_CUSTOMER_STATE,
UserMenuVisibility: DEFAULT_USER_MENU_VISIBILITY,
StreamViewMultiple: DEFAULT_STREAM_VIEW_MULTIPLE_STATE,
StreamViewSingle: DEFAULT_STREAM_VIEW_SINGLE_STATE,
Streams: DEFAULT_STREAM_DICTIONARY,
Destinations: DEFAULT_DESTINATION_DICTIONARY,
DestinationList: DEFAULT_DESTINATION_LIST_STATE,
IDestinationTranscodeModal: DEFAULT_DESTINATION_TRANSCODE_MODAL_STATE
};

关于Angular2 AoT - 不支持表达形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41795494/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com