0
<script>
태그 및 창 범위 내 index.html에 정의 된 외부 변수를 처리해야하는 응용 프로그램을 개발했습니다. 일부 타이핑 작업을하기 위해 타이프 스크립트 (typcript) 파일에 접근해야하지만 컴파일 중에는 아래와 같이 오류가 나타납니다.typescript 2.0에서 외부 정의되지 않은 변수를 처리하는 방법
//index.html
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<script>
window.widgetResources = {
'sessionId': '2f60e0a2-3fa2-46f4-9a5c-4a8afe5007c8',
'staticResourceURL': 'http://localhost:9090/OfferFinder/16101/1/0/',
'offers': {
</script>
</head>
<body>
<app>loadings...</app>
</body>
</html>
//WidgetResourcesList.js
export class WidgetResourcesList {
//noinspection TypeScriptUnresolvedVariable
widgetResources = window.widgetResources;
}
//error getting
C:\quickstart>tsc
app/services/WidgetResourcesList.ts(5,28): error TS2339:
`Property 'widgetResources' does not exist on type 'Window'.`