source

이 클래스는 SomeModule -> SomeComponent를 통해 소비자에게 표시되지만 최상위 라이브러리 진입점에서 내보내지 않습니다.

ittop 2023. 8. 30. 22:06
반응형

이 클래스는 SomeModule -> SomeComponent를 통해 소비자에게 표시되지만 최상위 라이브러리 진입점에서 내보내지 않습니다.

나는 나의 모든 각진 라이브러리를 업그레이드했습니다.angular 9.0.0사용.ng update그리고 제가 그것들을 만들려고 할 때 아래의 오류가 발생했습니다.

오류:

지원되지 않는 개인 클래스 SomeComponent입니다.이 클래스는 SomeModule -> SomeComponent를 통해 소비자에게 표시되지만 최상위 라이브러리 진입점에서 내보내지 않습니다.

이 오류를 해결한 사람이 있습니까?

이 오류는 구성 요소를 내보낼 때 발생합니다.NgModule그리고 당신의 것에 포함되지 않습니다.public_api.ts,Angular 9이제 오류가 발생합니다.

이 오류는 발생하지 않았습니다.Angular 8하지만 로 업그레이드한 후.Angular 9보이기 시작했습니다.

내보낸 항목이 있는 경우service,module또는component의 등.NgModule반드시 포함시켜야 합니다.public_api.ts그렇지 않으면angular 9이제 오류를 던집니다.

수정: 구성 요소를 에 추가합니다.public_api.ts

export * from './lib/components/some-me/some-me.component';

저는 오늘 같은 문제로 어려움을 겪고 있었습니다.

나의 전제 조건:

  • Angular 11 라이브러리 유형 프로젝트에서 일하고 있습니다.
  • 새로운 지침을 추가했습니다.
  • 모듈 내보내기에 내 지시를 추가하려고 할 때 위와 같은 오류가 발생했습니다.

수정:

  • index.ts 파일에 파일 내보내기를 추가했습니다.

export * from './just/a/relative/path/to/the/directive/{{myDirectiveFile}}';

저도 같은 문제에 부딪혔습니다.스토리북에서 기본 키워드를 삭제해야 했기 때문에 기본 키워드를 삭제할 수 없었습니다.저는 결국 이것을 변경함으로써 그것을 고쳤습니다.

export * from './lib/components/some-me/some-me.component';

대상:

export { default as SomeComponent } from './lib/components/some-me/some-me.component';

public_api.ts 파일에 있습니다.

이 오류는 제가 사용했기 때문에 발생했습니다.default구성 요소를 내보낼 키워드:

@Component({
  selector: 'lib-form',
  templateUrl: './form.component.html',
  styleUrls: ['./form.component.scss'],
})
export default class FormComponent implements OnInit {
    // ...
}

이 키워드의 사용은 나의 린터에 의해 제안되었고, 가져오기를 다음과 같이 쓸 수 있습니다.import FormComponent from './form.component';대신에import { FormComponent } from './form.component';

그러나 이것은 잘 작동하지 않는 것 같습니다.public-api.ts저를 위한 해결책은 그것을 제거하는 것이었습니다.default키워드를 지정하고 모든 가져오기를 변경합니다.

언급URL : https://stackoverflow.com/questions/60121962/this-class-is-visible-to-consumers-via-somemodule-somecomponent-but-is-not-e

반응형