문제

I found the following in a TypeScript declaration file for Angular:

interface IDirective{
    compile?:
        (templateElement: IAugmentedJQuery,

What does the ?: after compile do?

도움이 되었습니까?

해결책

See: Walkthrough: Interfaces | TypeScript :: Describing Simple Types.

Basically, ? marks the member as being optional in the interface.

(EDIT: As noted in comments, this is not restricted to interfaces.)

다른 팁

In this case, the ?: is not a single operator, but rather two operators:

  • ? (optional),

  • : (specify type).

In other languages/cases, ?: would be the Elvis Operator.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top