angular 2 typescript An implementation cannot be declared in ambient contexts

前端 未结 6 1497
刺人心
刺人心 2021-01-07 23:02

I am new to typescript and I am trying to create a function for an angular 2 directive. Can anyone explain, in language for n00bs, what the error is trying to tell me when I

6条回答
  •  太阳男子
    2021-01-07 23:35

    An implementation cannot be declared in ambient contexts

    You most probably have your file named as foo.d.ts instead of foo.ts. That marks it as a declaration file (more on that https://basarat.gitbooks.io/typescript/content/docs/types/ambient/d.ts.html) and you cannot put logic in these as you are declaring what logic exists elsewhere.

提交回复
热议问题