카테고리 없음

[모난] Angular2로 gapi 함수를 찾을 수 없습니다.

필살기쓰세요 2021. 1. 15. 00:33

최근에이 문제를 발견했으며 다음은 저에게 도움이되는 몇 가지 구성입니다.

DefinitelyTyped @ types / gapi 패키지를 사용하고 있습니다.

npm install --save-dev @types/gapi

typescript docs 에서 /// <reference types="..." />지시문을 사용 하여 typescript 파일에 유형을로드합니다.

/// <reference types="gapi" />

tsconfig.json내 프로젝트의 루트 파일에있는 추가 구성 :

{
  ...
    "compilerOptions": {
        // I thought this was enough to recognize the types
            // but that was not the case
                "typeRoots": ["node_modules/@types"],
                    ...
                      }
                      }
                      

typescript v2.0 이상을 사용해야합니다.



출처
https://stackoverflow.com/questions/39915890