inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

앵귤러 파이어베이스 완전정복 - PetStore 쇼핑몰 프로젝트

Petlist 프로젝트 활용하기

9:12

299

Jun Ho Yoon

작성한 질문수 4

0

Error: src/app/classes/item.ts:2:5 - error TS2564: Property 'id' has no initializer and is not definitely assigned in the constructor. 2     id: string;

src/app/classes/item.ts:3:5 - error TS2564: Property 'name' has no initializer and is not definitely assigned in the constructor. 3     name: string;

src/app/classes/item.ts:4:5 - error TS2564: Property 'available' has no initializer and is not definitely assigned in the constructor. 4     available: boolean;

src/app/services/item.service.ts:15:31 - error TS2345: Argument of type 'string | null' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'. 15       this.items = JSON.parse(localStorage.getItem('items'));

src/app/item/item.component.ts:33:9 - error TS2322: Type 'Item | undefined' is not assignable to type 'Item'. Type 'undefined' is not assignable to type 'Item'. 33         this.item = this.itemService.getItem(id);

오류가 생깁니다..

firebase Angular pwa

답변 2

0

서인석

설명대로 다운로드받은 폴더에서 복사하고

새로 생성한 프로젝트에 붙여넣기했는데 저도 저 위와 같은 오류문구가 나오네요

./src/app/services/item.service.ts:2:0-41 - Error: Module not found: Error: Can't resolve 'firebase/app' in 'C:\Users\jun\Documents\angular-08liter\angular-petlist\src\app\services'

./src/app/services/item.service.ts:3:0-27 - Error: Module not found: Error: Can't resolve 'firebase/database' in 'C:\Users\jun\Documents\angular-08liter\angular-petlist\src\app\services'

Error: src/app/classes/item.ts:2:5 - error TS2564: Property 'key' has no initializer and is not definitely assigned in the constructor.

2     key: string;

      ~~~

Error: src/app/classes/item.ts:3:5 - error TS2564: Property 'id' has no initializer and is not definitely assigned in the constructor.

3     id: string;

      ~~

Error: src/app/classes/item.ts:4:5 - error TS2564: Property 'name' has no initializer and is not definitely assigned in the constructor.

4     name: string;

      ~~~~

Error: src/app/classes/item.ts:5:5 - error TS2564: Property 'available' has no initializer and is not definitely assigned in the constructor.

5     available: boolean;

      ~~~~~~~~~

Error: src/app/item/item.component.html:4:27 - error TS2341: Property 'item' is private and only accessible within class 'ItemComponent'.

4       <input [(ngModel)]="item.id" placeholder="ID"/>

                            ~~~~

  src/app/item/item.component.ts:8:16

    8   templateUrl: './item.component.html',

      m               ~~~~~~~~~~~~~~~~~~~~~~~

    Error occurs in the template of component ItemComponent.

Error: src/app/item/item.component.html:4:27 - error TS2341: Property 'item' is private and only accessible within class 'ItemComponent'.

4       <input [(ngModel)]="item.id" placeholder="ID"/>

                            ~~~~

  src/app/item/item.component.ts:8:16

    8   templateUrl: './item.component.html',

                     ~~~~~~~~~~~~~~~~~~~~~~~

    Error occurs in the template of component ItemComponent.

Error: src/app/item/item.component.html:9:27 - error TS2341: Property 'item' is private and only accessible within class 'ItemComponent'.

9       <input [(ngModel)]="item.name" placeholder="Name"/>

                            ~~~~

  src/app/item/item.component.ts:8:16

    8   templateUrl: './item.component.html',

                     ~~~~~~~~~~~~~~~~~~~~~~~

    Error occurs in the template of component ItemComponent.

Error: src/app/item/item.component.html:9:27 - error TS2341: Property 'item' is private and only accessible within class 'ItemComponent'.

9       <input [(ngModel)]="item.name" placeholder="Name"/>

                            ~~~~

  src/app/item/item.component.ts:8:16

    8   templateUrl: './item.component.html',

                     ~~~~~~~~~~~~~~~~~~~~~~~

    Error occurs in the template of component ItemComponent.

Error: src/app/item/item.component.html:14:27 - error TS2341: Property 'item' is private and only accessible within class 'ItemComponent'.

14       <input [(ngModel)]="item.available" type="checkbox"/>

                             ~~~~

  src/app/item/item.component.ts:8:16

    8   templateUrl: './item.component.html',

                     ~~~~~~~~~~~~~~~~~~~~~~~

    Error occurs in the template of component ItemComponent.

Error: src/app/item/item.component.html:14:27 - error TS2341: Property 'item' is private and only accessible within class 'ItemComponent'.

14       <input [(ngModel)]="item.available" type="checkbox"/>

                             ~~~~

  src/app/item/item.component.ts:8:16

    8   templateUrl: './item.component.html',

                     ~~~~~~~~~~~~~~~~~~~~~~~

    Error occurs in the template of component ItemComponent.

Error: src/app/item/item.component.ts:34:9 - error TS2322: Type 'Item | undefined' is not assignable to type 'Item'.

  Type 'undefined' is not assignable to type 'Item'.

34         this.item = this.itemService.getItem(id);

           ~~~~~~~~~

Error: src/app/services/item.service.ts:4:27 - error TS2307: Cannot find module 'firebase/app' or its corresponding type declarations.

4 import * as firebase from 'firebase/app';

                            ~~~~~~~~~~~~~~

Error: src/app/services/item.service.ts:36:33 - error TS7006: Parameter 'snapshot' implicitly has an 'any' type.

36       this.itemList.on('value', snapshot => {

                                   ~~~~~~~~

Error: src/app/services/item.service.ts:37:27 - error TS7006: Parameter 'snap' implicitly has an 'any' type.

37         snapshot.forEach( snap => {

0

노마드크리에이터

안녕하세요?

이 에러만으로 모든 원인을 찾기는 어렵지만 에러 내용을 보시면 Item 이 정의되어 있는지 그리고 import 되어 있는지 부터 확인해 보세요. Petlist는 간단한 구조이니 제공해드린 소스코드와 꼼꼼하게 비교해 보시면 잘못된 부분을 찾으실 수 있을겁니다.

감사합니다.

더백님 감사합니다

1

30

1

39. Main화면 추가 UI 에서 자료는 어디서 받나요??

0

29

1

미션 마감일시를 좀 늘려주세요

0

41

1

개인브랜딩 사이트 만들기가 마감일시가 있었네요.

0

34

1

최종 과제 제출

0

79

3

주사위앱 소개 및 레이아웃 설정 문제

0

53

2

파이어베이스 문의

0

37

2

searchable이 화면 하단에 위치해요

0

60

2

Recoil 에러

0

66

1

cleric.fbx 파일을 열 수 없다는 에러가 뜹니다

0

58

2

강의 15분에 질문드립니다

0

62

2

교육자료 마젠타색

0

59

1

BigQuery 활용편 18강 질문있습니다!

0

80

1

initializeApp 부분에 오류가 납니다.

0

263

1

오류가 납니다

0

216

0

섹션2 FireBase의 petList활용하기에서 에러나네요

0

327

1

6:45

0

220

1

2:16 질문

1

471

3

2:15 어디서 카피할 수 있나요?

1

240

1

구문 문의

0

192

2

소스코드를 찾지 못했습니다. 도움 부탁드립니다.

0

214

1

Angualr-Petstore 소스 위치를 알고싶습니다

0

166

1

Database에 petlist가 추가되지 않습니다

0

252

3

enviorenment.ts 파일에 강사님의 api 정보가 포함되어있는거 같습니다.

0

169

1