我从哪里导入特征类型到ngrx?

问题描述 投票:0回答:1

我已经将ngrx更新到版本15。组装过程中出现错误,无法导出此类型。请告诉我。 这是我的依赖

  "@angular/animations": "^15.2.10",
    "@angular/cdk": "^15.2.9",
    "@angular/common": "^15.2.10",
    "@angular/compiler": "^15.2.10",
    "@angular/core": "^15.2.10",
    "@angular/forms": "^15.2.10",
    "@angular/material": "^15.2.9",
    "@angular/platform-browser": "^15.2.10",
    "@angular/platform-browser-dynamic": "^15.2.10",
    "@angular/router": "^15.2.10",
    "@ngrx/effects": "^15.4.0",
    "@ngrx/entity": "^15.4.0",
    "@ngrx/schematics": "^15.4.0",
    "@ngrx/store": "^15.4.0",
    "@ngrx/store-devtools": "^15.4.0",
    "@types/yandex-maps": "^2.1.20",
    "angularx-qrcode": "^15.0.1",
    "core-js": "^3.20.3",
    "moment": "^2.29.1",
    "rxjs": "^7.5.2",
    "tslib": "^2.3.1",
    "zone.js": "~0.11.4"

编译应用程序后,错误会以粗体第一个字符串突出显示

**import { Feature } from '@ngrx/store/src/feature_creator';**
import { ActionCreator, TypedAction } from '@ngrx/store/src/models';

export type Action = ActionCreator<string, () => TypedAction<string>>;
export type ActionSuccess<T> = ActionCreator<string, (props: T) => T & TypedAction<string>>;
export type ActionError = ActionCreator<string, (props: { error: unknown }) => { error: unknown } & TypedAction<string>>;
export type ActionWithProps<T> = ActionCreator<string, (props: T) => T & TypedAction<string>>;

export type KioskStoreFeature<TFeatureState, TKioskFeatureName extends keyof Record<string, TFeatureState> & string> = Feature<
  Record<string, TFeatureState>,
  TKioskFeatureName,
  TFeatureState
>;

控制台出错

Error: src/main/client/kiosk/core/store/types/index.ts:1:10 - error TS2459: Module '"@ngrx/store/src/feature_creator"' declares 'Feature' locally, but it is not exported.

1 import { Feature } from '@ngrx/store/src/feature_creator';
           ~~~~~~~

  node_modules/@ngrx/store/src/feature_creator.d.ts:7:14
    7 declare type Feature<AppState extends Record<string, any>, FeatureName extends keyof AppState & string, FeatureState extends AppState[FeatureName]> = FeatureConfig<FeatureName, FeatureState> & BaseSelectors<AppState, FeatureName, FeatureState>;
                   ~~~~~~~
    'Feature' is declared here.

我什么都没尝试过。我没找到答案

javascript angular typescript ngrx
1个回答
0
投票

您的导入路径引用非公共代码 -

Feature
不是导出类型,因此您无法引用它。

您不需要显式声明所有这些类型,而是使用

createFeature
和隐式类型。

// kioskFeature has the type you are trying to define
export const kioskFeature = createFeature(...); 
© www.soinside.com 2019 - 2024. All rights reserved.