ncs contained setAttribute setAttributeNS setAttributeNode
  syntax keyword typescriptDOMElemFuncs contained setAttributeNodeNS setCapture supports
  syntax keyword typescriptDOMElemFuncs contained getAttribute
  hi def link typescriptDOMElemFuncs Keyword

  syntax keyword typescriptDOMDocProp contained activeElement body cookie defaultView
  syntax keyword typescriptDOMDocProp contained designMode dir domain embeds forms head
  syntax keyword typescriptDOMDocProp contained images lastModified links location plugins
  syntax keyword typescriptDOMDocProp contained postMessage readyState referrer registerElement
  syntax keyword typescriptDOMDocProp contained scripts styleSheets title vlinkColor
  syntax keyword typescriptDOMDocProp contained xmlEncoding characterSet compatMode
  syntax keyword typescriptDOMDocProp contained contentType currentScript doctype documentElement
  syntax keyword typescriptDOMDocProp contained documentURI documentURIObject firstChild
  syntax keyword typescriptDOMDocProp contained implementation lastStyleSheetSet namespaceURI
  syntax keyword typescriptDOMDocProp contained nodePrincipal ononline pointerLockElement
  syntax keyword typescriptDOMDocProp contained popupNode preferredStyleSheetSet selectedStyleSheetSet
  syntax keyword typescriptDOMDocProp contained styleSheetSets textContent tooltipNode
  syntax cluster props add=typescriptDOMDocProp
  hi def link typescriptDOMDocProp Keyword
  syntax keyword typescriptDOMDocMethod contained caretPositionFromPoint close createNodeIterator nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained createRange createTreeWalker elementFromPoint nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained getElementsByName adoptNode createAttribute nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained createCDATASection createComment createDocumentFragment nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained createElement createElementNS createEvent nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained createExpression createNSResolver nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained createProcessingInstruction createTextNode nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained enableStyleSheetsForSet evaluate execCommand nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained exitPointerLock getBoxObjectFor getElementById nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained getElementsByClassName getElementsByTagName nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained getElementsByTagNameNS getSelection nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained hasFocus importNode loadOverlay open nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained queryCommandSupported querySelector nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMDocMethod contained querySelectorAll write writeln nextgroup=typescriptFuncCallArg
  syntax cluster props add=typescriptDOMDocMethod
  hi def link typescriptDOMDocMethod Keyword

  syntax keyword typescriptDOMEventTargetMethod contained addEventListener removeEventListener nextgroup=typescriptEventFuncCallArg
  syntax keyword typescriptDOMEventTargetMethod contained dispatchEvent waitUntil nextgroup=typescriptEventFuncCallArg
  syntax cluster props add=typescriptDOMEventTargetMethod
  hi def link typescriptDOMEventTargetMethod Keyword
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName AnimationEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName AudioProcessingEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName BeforeInputEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName BeforeUnloadEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName BlobEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName ClipboardEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName CloseEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName CompositionEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName CSSFontFaceLoadEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName CustomEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName DeviceLightEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName DeviceMotionEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName DeviceOrientationEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName DeviceProximityEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName DOMTransactionEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName DragEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName EditingBeforeInputEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName ErrorEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName FocusEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName GamepadEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName HashChangeEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName IDBVersionChangeEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName KeyboardEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName MediaStreamEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName MessageEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName MouseEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName MutationEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName OfflineAudioCompletionEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName PageTransitionEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName PointerEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName PopStateEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName ProgressEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName RelatedEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName RTCPeerConnectionIceEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName SensorEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName StorageEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName SVGEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName SVGZoomEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName TimeEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName TouchEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName TrackEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName TransitionEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName UIEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName UserProximityEvent
  syntax keyword typescriptDOMEventCons containedin=typescriptIdentifierName WheelEvent
  hi def link typescriptDOMEventCons Structure
  syntax keyword typescriptDOMEventProp contained bubbles cancelable currentTarget defaultPrevented
  syntax keyword typescriptDOMEventProp contained eventPhase target timeStamp type isTrusted
  syntax keyword typescriptDOMEventProp contained isReload
  syntax cluster props add=typescriptDOMEventProp
  hi def link typescriptDOMEventProp Keyword
  syntax keyword typescriptDOMEventMethod contained initEvent preventDefault stopImmediatePropagation nextgroup=typescriptEventFuncCallArg
  syntax keyword typescriptDOMEventMethod contained stopPropagation respondWith default nextgroup=typescriptEventFuncCallArg
  syntax cluster props add=typescriptDOMEventMethod
  hi def link typescriptDOMEventMethod Keyword

  syntax keyword typescriptDOMStorage contained sessionStorage localStorage
  hi def link typescriptDOMStorage Keyword
  syntax keyword typescriptDOMStorageProp contained length
  syntax cluster props add=typescriptDOMStorageProp
  hi def link typescriptDOMStorageProp Keyword
  syntax keyword typescriptDOMStorageMethod contained getItem key setItem removeItem nextgroup=typescriptFuncCallArg
  syntax keyword typescriptDOMStorageMethod contained clear nextgroup=typescriptFuncCallArg
  syntax cluster props add=typescriptDOMStorageMethod
  hi def link typescriptDOMStorageMethod Keyword

  syntax keyword typescriptDOMFormProp contained acceptCharset action elements encoding
  syntax keyword typescriptDOMFormProp contained enctype length method name target
  syntax cluster props add=typescriptDOMFormProp
  hi def link typescriptDOMFormProp Keyword
  syntax keyword typescriptDOMFormMethod contained reportValidity reset submit nextgroup=typescriptFuncCallArg
  syntax cluster props add=typescriptDOMFormMethod
  hi def link typescriptDOMFormMethod Keyword

  syntax keyword typescriptDOMStyle contained alignContent alignItems alignSelf animation
  syntax keyword typescriptDOMStyle contained animationDelay animationDirection animationDuration
  syntax keyword typescriptDOMStyle contained animationFillMode animationIterationCount
  syntax keyword typescriptDOMStyle contained animationName animationPlayState animationTimingFunction
  syntax keyword typescriptDOMStyle contained appearance backfaceVisibility background
  syntax keyword typescriptDOMStyle contained backgroundAttachment backgroundBlendMode
  syntax keyword typescriptDOMStyle contained backgroundClip backgroundColor backgroundImage
  syntax keyword typescriptDOMStyle contained backgroundOrigin backgroundPosition backgroundRepeat
  syntax keyword typescriptDOMStyle contained backgroundSize border borderBottom borderBottomColor
  syntax keyword typescriptDOMStyle contained borderBottomLeftRadius borderBottomRightRadius
  syntax keyword typescriptDOMStyle contained borderBottomStyle borderBottomWidth borderCollapse
  syntax keyword typescriptDOMStyle contained borderColor borderImage borderImageOutset
  syntax keyword typescriptDOMStyle contained borderImageRepeat borderImageSlice borderImageSource
  syntax keyword typescriptDOMStyle contained borderImageWidth borderLeft borderLeftColor
  syntax keyword typescriptDOMStyle contained borderLeftStyle borderLeftWidth borderRadius
  syntax keyword typescriptDOMStyle contained borderRight borderRightColor borderRightStyle
  syntax keyword typescriptDOMStyle contained borderRightWidth borderSpacing borderStyle
  syntax keyword typescriptDOMStyle contained borderTop borderTopColor borderTopLeftRadius
  syntax keyword typescriptDOMStyle contained borderTopRightRadius borderTopStyle borderTopWidth
  syntax keyword typescriptDOMStyle contained borderWidth bottom boxDecorationBreak
  syntax keyword typescriptDOMStyle contained boxShadow boxSizing breakAfter breakBefore
  syntax keyword typescriptDOMStyle contained breakInside captionSide caretColor caretShape
  syntax keyword typescriptDOMStyle contained caret clear clip clipPath color columns
  syntax keyword typescriptDOMStyle contained columnCount columnFill columnGap columnRule
  syntax keyword typescriptDOMStyle contained columnRuleColor columnRuleStyle columnRuleWidth
  syntax keyword typescriptDOMStyle contained columnSpan columnWidth content counterIncrement
  syntax keyword typescriptDOMStyle contained counterReset cursor direction display
  syntax keyword typescriptDOMStyle contained emptyCells flex flexBasis flexDirection
  syntax keyword typescriptDOMStyle contained flexFlow flexGrow flexShrink flexWrap
  syntax keyword typescriptDOMStyle contained float font fontFamily fontFeatureSettings
  syntax keyword typescriptDOMStyle contained fontKerning fontLanguageOverride fontSize
  syntax keyword typescriptDOMStyle contained fontSizeAdjust fontStretch fontStyle fontSynthesis
  syntax keyword typescriptDOMStyle contained fontVariant fontVariantAlternates fontVariantCaps
  syntax keyword typescriptDOMStyle contained fontVariantEastAsian fontVariantLigatures
  syntax keyword typescriptDOMStyle contained fontVariantNumeric fontVariantPosition
  syntax keyword typescriptDOMStyle contained fontWeight grad grid gridArea gridAutoColumns
  syntax keyword typescriptDOMStyle contained gridAutoFlow gridAutoPosition gridAutoRows
  syntax keyword typescriptDOMStyle contained gridColumn gridColumnStart gridColumnEnd
  syntax keyword typescriptDOMStyle contained gridRow gridRowStart gridRowEnd gridTemplate
  syntax keyword typescriptDOMStyle contained gridTemplateAreas gridTemplateRows gridTemplateColumns
  syntax keyword typescriptDOMStyle contained height hyphens imageRendering imageResolution
  syntax keyword typescriptDOMStyle contained imageOrientation imeMode inherit justifyContent
  syntax keyword typescriptDOMStyle contained left letterSpacing lineBreak lineHeight
  syntax keyword typescriptDOMStyle contained listStyle listStyleImage listStylePosition
  syntax keyword typescriptDOMStyle contained listStyleType margin marginBottom marginLeft
  syntax keyword typescriptDOMStyle contained marginRight marginTop marks mask maskType
  syntax keyword typescriptDOMStyle contained maxHeight maxWidth minHeight minWidth
  syntax keyword typescriptDOMStyle contained mixBlendMode objectFit objectPosition
  syntax keyword typescriptDOMStyle contained opacity order orphans outline outlineColor
  syntax keyword typescriptDOMStyle contained outlineOffset outlineStyle outlineWidth
  syntax keyword typescriptDOMStyle contained overflow overflowWrap overflowX overflowY
  syntax keyword typescriptDOMStyle contained overflowClipBox padding paddingBottom
  syntax keyword typescriptDOMStyle contained paddingLeft paddingRight paddingTop pageBreakAfter
  syntax keyword typescriptDOMStyle contained pageBreakBefore pageBreakInside perspective
  syntax keyword typescriptDOMStyle contained perspectiveOrigin pointerEvents position
  syntax keyword typescriptDOMStyle contained quotes resize right shapeImageThreshold
  syntax keyword typescriptDOMStyle contained shapeMargin shapeOutside tableLayout tabSize
  syntax keyword typescriptDOMStyle contained textAlign textAlignLast textCombineHorizontal
  syntax keyword typescriptDOMStyle contained textDecoration textDecorationColor textDecorationLine
  syntax keyword typescriptDOMStyle contained textDecorationStyle textIndent textOrientation
  syntax keyword typescriptDOMStyle contained textOverflow textRendering textShadow
  syntax keyword typescriptDOMStyle contained textTransform textUnderlinePosition top
  syntax keyword typescriptDOMStyle contained touchAction transform transformOrigin
  syntax keyword typescriptDOMStyle contained transformStyle transition transitionDelay
  syntax keyword typescriptDOMStyle contained transitionDuration transitionProperty
  syntax keyword typescriptDOMStyle contained transitionTimingFunction unicodeBidi unicodeRange
  syntax keyword typescriptDOMStyle contained userSelect userZoom verticalAlign visibility
  syntax keyword typescriptDOMStyle contained whiteSpace width willChange wordBreak
  syntax keyword typescriptDOMStyle contained wordSpacing wordWrap writingMode zIndex
  hi def link typescriptDOMStyle Keyword



  let typescript_props = 1
  syntax keyword typescriptAnimationEvent contained animationend animationiteration
  syntax keyword typescriptAnimationEvent contained animationstart beginEvent endEvent
  syntax keyword typescriptAnimationEvent contained repeatEvent
  syntax cluster events add=typescriptAnimationEvent
  hi def link typescriptAnimationEvent Title
  syntax keyword typescriptCSSEvent contained CssRuleViewRefreshed CssRuleViewChanged
  syntax keyword typescriptCSSEvent contained CssRuleViewCSSLinkClicked transitionend
  syntax cluster events add=typescriptCSSEvent
  hi def link typescriptCSSEvent Title
  syntax keyword typescriptDatabaseEvent contained blocked complete error success upgradeneeded
  syntax keyword typescriptDatabaseEvent contained versionchange
  syntax cluster events add=typescriptDatabaseEvent
  hi def link typescriptDatabaseEvent Title
  syntax keyword typescriptDocumentEvent contained DOMLinkAdded DOMLinkRemoved DOMMetaAdded
  syntax keyword typescriptDocumentEvent contained DOMMetaRemoved DOMWillOpenModalDialog
  syntax keyword typescriptDocumentEvent contained DOMModalDialogClosed unload
  syntax cluster events add=typescriptDocumentEvent
  hi def link typescriptDocumentEvent Title
  syntax keyword typescriptDOMMutationEvent contained DOMAttributeNameChanged DOMAttrModified
  syntax keyword typescriptDOMMutationEvent contained DOMCharacterDataModified DOMContentLoaded
  syntax keyword typescriptDOMMutationEvent contained DOMElementNameChanged DOMNodeInserted
  syntax keyword typescriptDOMMutationEvent contained DOMNodeInsertedIntoDocument DOMNodeRemoved
  syntax keyword typescriptDOMMutationEvent contained DOMNodeRemovedFromDocument DOMSubtreeModified
  syntax cluster events add=typescriptDOMMutationEvent
  hi def link typescriptDOMMutationEvent Title
  syntax keyword typescriptDragEvent contained drag dragdrop dragend dragenter dragexit
  syntax keyword typescriptDragEvent contained draggesture dragleave dragover dragstart
  syntax keyword typescriptDragEvent contained drop
  syntax cluster events add=typescriptDragEvent
  hi def link typescriptDragEvent Title
  syntax keyword typescriptElementEvent contained invalid overflow underflow DOMAutoComplete
  syntax keyword typescriptElementEvent contained command commandupdate
  syntax cluster events add=typescriptElementEvent
  hi def link typescriptElementEvent Title
  syntax keyword typescriptFocusEvent contained blur change DOMFocusIn DOMFocusOut focus
  syntax keyword typescriptFocusEvent contained focusin focusout
  syntax cluster events add=typescriptFocusEvent
  hi def link typescriptFocusEvent Title
  syntax keyword typescriptFormEvent contained reset submit
  syntax cluster events add=typescriptFormEvent
  hi def link typescriptFormEvent Title
  syntax keyword typescriptFrameEvent contained DOMFrameContentLoaded
  syntax cluster events add=typescriptFrameEvent
  hi def link typescriptFrameEvent Title
  syntax keyword typescriptInputDeviceEvent contained click contextmenu DOMMouseScroll
  syntax keyword typescriptInputDeviceEvent contained dblclick gamepadconnected gamepaddisconnected
  syntax keyword typescriptInputDeviceEvent contained keydown keypress keyup MozGamepadButtonDown
  syntax keyword typescriptInputDeviceEvent contained MozGamepadButtonUp mousedown mouseenter
  syntax keyword typescriptInputDeviceEvent contained mouseleave mousemove mouseout
  syntax keyword typescriptInputDeviceEvent contained mouseover mouseup mousewheel MozMousePixelScroll
  syntax keyword typescriptInputDeviceEvent contained pointerlockchange pointerlockerror
  syntax keyword typescriptInputDeviceEvent contained wheel
  syntax cluster events add=typescriptInputDeviceEvent
  hi def link typescriptInputDeviceEvent Title
  syntax keyword typescriptMediaEvent contained audioprocess canplay canplaythrough
  syntax keyword typescriptMediaEvent contained durationchange emptied ended ended loadeddata
  syntax keyword typescriptMediaEvent contained loadedmetadata MozAudioAvailable pause
  syntax keyword typescriptMediaEvent contained play playing ratechange seeked seeking
  syntax keyword typescriptMediaEvent contained stalled suspend timeupdate volumechange
  syntax keyword typescriptMediaEvent contained waiting complete
  syntax cluster events add=typescriptMediaEvent
  hi def link typescriptMediaEvent Title
  syntax keyword typescriptMenuEvent contained DOMMenuItemActive DOMMenuItemInactive
  syntax cluster events add=typescriptMenuEvent
  hi def link typescriptMenuEvent Title
  syntax keyword typescriptNetworkEvent contained datachange dataerror disabled enabled
  syntax keyword typescriptNetworkEvent contained offline online statuschange connectionInfoUpdate
  syntax cluster events add=typescriptNetworkEvent
  hi def link typescriptNetworkEvent Title
  syntax keyword typescriptProgressEvent contained abort error load loadend loadstart
  syntax keyword typescriptProgressEvent contained progress timeout uploadprogress
  syntax cluster events add=typescriptProgressEvent
  hi def link typescriptProgressEvent Title
  syntax keyword typescriptResourceEvent contained cached error load
  syntax cluster events add=typescriptResourceEvent
  hi def link typescriptResourceEvent Title
  syntax keyword typescriptScriptEvent contained afterscriptexecute beforescriptexecute
  syntax cluster events add=typescriptScriptEvent
  hi def link typescriptScriptEvent Title
  syntax keyword typescriptSensorEvent contained compassneedscalibration devicelight
  syntax keyword typescriptSensorEvent contained devicemotion deviceorientation deviceproximity
  syntax keyword typescriptSensorEvent contained orientationchange userproximity
  syntax cluster events add=typescriptSensorEvent
  hi def link typescriptSensorEvent Title
  syntax keyword typescriptSessionHistoryEvent contained pagehide pageshow popstate
  syntax cluster events add=typescriptSessionHistoryEvent
  hi def link typescriptSessionHistoryEvent Title
  syntax keyword typescriptStorageEvent contained change storage
  syntax cluster events add=typescriptStorageEvent
  hi def link typescriptStorageEvent Title
  syntax keyword typescriptSVGEvent contained SVGAbort SVGError SVGLoad SVGResize SVGScroll
  syntax keyword typescriptSVGEvent contained SVGUnload SVGZoom
  syntax cluster events add=typescriptSVGEvent
  hi def link typescriptSVGEvent Title
  syntax keyword typescriptTabEvent contained visibilitychange
  syntax cluster events add=typescriptTabEvent
  hi def link typescriptTabEvent Title
  syntax keyword typescriptTextEvent contained compositionend compositionstart compositionupdate
  syntax keyword typescriptTextEvent contained copy cut paste select text
  syntax cluster events add=typescriptTextEvent
  hi def link typescriptTextEvent Title
  syntax keyword typescriptTouchEvent contained touchcancel touchend touchenter touchleave
  syntax keyword typescriptTouchEvent contained touchmove touchstart
  syntax cluster events add=typescriptTouchEvent
  hi def link typescriptTouchEvent Title
  syntax keyword typescriptUpdateEvent contained checking downloading error noupdate
  syntax keyword typescriptUpdateEvent contained obsolete updateready
  syntax cluster events add=typescriptUpdateEvent
  hi def link typescriptUpdateEvent Title
  syntax keyword typescriptValueChangeEvent contained hashchange input readystatechange
  syntax cluster events add=typescriptValueChangeEvent
  hi def link typescriptValueChangeEvent Title
  syntax keyword typescriptViewEvent contained fullscreen fullscreenchange fullscreenerror
  syntax keyword typescriptViewEvent contained resize scroll
  syntax cluster events add=typescriptViewEvent
  hi def link typescriptViewEvent Title
  syntax keyword typescriptWebsocketEvent contained close error message open
  syntax cluster events add=typescriptWebsocketEvent
  hi def link typescriptWebsocketEvent Title
  syntax keyword typescriptWindowEvent contained DOMWindowCreated DOMWindowClose DOMTitleChanged
  syntax cluster events add=typescriptWindowEvent
  hi def link typescriptWindowEvent Title
  syntax keyword typescriptUncategorizedEvent contained beforeunload message open show
  syntax cluster events add=typescriptUncategorizedEvent
  hi def link typescriptUncategorizedEvent Title
  syntax keyword typescriptServiceWorkerEvent contained install activate fetch
  syntax cluster events add=typescriptServiceWorkerEvent
  hi def link typescriptServiceWorkerEvent Title


endif

" patch
" patch for generated code
syntax keyword typescriptGlobal Promise
  \ nextgroup=typescriptGlobalPromiseDot,typescriptFuncCallArg,typescriptTypeArguments oneline
syntax keyword typescriptGlobal Map WeakMap
  \ nextgroup=typescriptGlobalPromiseDot,typescriptFuncCallArg,typescriptTypeArguments oneline

syntax keyword typescriptConstructor           contained constructor
  \ nextgroup=@typescriptCallSignature
  \ skipwhite skipempty


syntax cluster memberNextGroup contains=typescriptMemberOptionality,typescriptTypeAnnotation,@typescriptCallSignature

syntax match typescriptMember /#\?\K\k*/
  \ nextgroup=@memberNextGroup
  \ contained skipwhite

syntax match typescriptMethodAccessor contained /\v(get|set)\s\K/me=e-1
  \ nextgroup=@typescriptMembers

syntax cluster typescriptPropertyMemberDeclaration contains=
  \ typescriptClassStatic,
  \ typescriptAccessibilityModifier,
  \ typescriptReadonlyModifier,
  \ typescriptMethodAccessor,
  \ @typescriptMembers
  " \ typescriptMemberVariableDeclaration

syntax match typescriptMemberOptionality /?\|!/ contained
  \ nextgroup=typescriptTypeAnnotation,@typescriptCallSignature
  \ skipwhite skipempty

syntax cluster typescriptMembers contains=typescriptMember,typescriptStringMember,typescriptComputedMember

syntax keyword typescriptClassStatic static
  \ nextgroup=@typescriptMembers,typescriptAsyncFuncKeyword,typescriptReadonlyModifier
  \ skipwhite contained

syntax keyword typescriptAccessibilityModifier public private protected contained

syntax keyword typescriptReadonlyModifier readonly contained

syntax region  typescriptStringMember   contained
  \ start=/\z(["']\)/  skip=/\\\\\|\\\z1\|\\\n/  end=/\z1/
  \ nextgroup=@memberNextGroup
  \ skipwhite skipempty

syntax region  typescriptComputedMember   contained matchgroup=typescriptProperty
  \ start=/\[/rs=s+1 end=/]/
  \ contains=@typescriptValue,typescriptMember,typescriptMappedIn
  \ nextgroup=@memberNextGroup
  \ skipwhite skipempty

"don't add typescriptMembers to nextgroup, let outer scope match it
" so we won't match abstract method outside abstract class
syntax keyword typescriptAbstract              abstract
  \ nextgroup=typescriptClassKeyword
  \ skipwhite skipnl
syntax keyword typescriptClassKeyword          class
  \ nextgroup=typescriptClassName,typescriptClassExtends,typescriptClassBlock
  \ skipwhite

syntax match   typescriptClassName             contained /\K\k*/
  \ nextgroup=typescriptClassBlock,typescriptClassExtends,typescriptClassTypeParameter
  \ skipwhite skipnl

syntax region typescriptClassTypeParameter
  \ start=/</ end=/>/
  \ contains=@typescriptTypeParameterCluster
  \ nextgroup=typescriptClassBlock,typescriptClassExtends
  \ contained skipwhite skipnl

syntax keyword typescriptClassExtends          contained extends implements nextgroup=typescriptClassHeritage skipwhite skipnl

syntax match   typescriptClassHeritage         contained /\v(\k|\.|\(|\))+/
  \ nextgroup=typescriptClassBlock,typescriptClassExtends,typescriptMixinComma,typescriptClassTypeArguments
  \ contains=@typescriptValue
  \ skipwhite skipnl
  \ contained

syntax region typescriptClassTypeArguments matchgroup=typescriptTypeBrackets
  \ start=/</ end=/>/
  \ contains=@typescriptType
  \ nextgroup=typescriptClassExtends,typescriptClassBlock,typescriptMixinComma
  \ contained skipwhite skipnl

syntax match typescriptMixinComma /,/ contained nextgroup=typescriptClassHeritage skipwhite skipnl

" we need add arrowFunc to class block for high order arrow func
" see test case
syntax region  typescriptClassBlock matchgroup=typescriptBraces start=/{/ end=/}/
  \ contains=@typescriptPropertyMemberDeclaration,typescriptAbstract,@typescriptComments,typescriptBlock,typescriptAssign,typescriptDecorator,typescriptAsyncFuncKeyword,typescriptArrowFunc
  \ contained fold

syntax keyword typescriptInterfaceKeyword          interface nextgroup=typescriptInterfaceName skipwhite
syntax match   typescriptInterfaceName             contained /\k\+/
  \ nextgroup=typescriptObjectType,typescriptInterfaceExtends,typescriptInterfaceTypeParameter
  \ skipwhite skipnl
syntax region typescriptInterfaceTypeParameter
  \ start=/</ end=/>/
  \ contains=@typescriptTypeParameterCluster
  \ nextgroup=typescriptObjectType,typescriptInterfaceExtends
  \ contained
  \ skipwhite skipnl

syntax keyword typescriptInterfaceExtends          contained extends nextgroup=typescriptInterfaceHeritage skipwhite skipnl

syntax match typescriptInterfaceHeritage contained /\v(\k|\.)+/
  \ nextgroup=typescriptObjectType,typescriptInterfaceComma,typescriptInterfaceTypeArguments
  \ skipwhite

syntax region typescriptInterfaceTypeArguments matchgroup=typescriptTypeBrackets
  \ start=/</ end=/>/ skip=/\s*,\s*/
  \ contains=@typescriptType
  \ nextgroup=typescriptObjectType,typescriptInterfaceComma
  \ contained skipwhite

syntax match typescriptInterfaceComma /,/ contained nextgroup=typescriptInterfaceHeritage skipwhite skipnl

"Block VariableStatement EmptyStatement ExpressionStatement IfStatement IterationStatement ContinueStatement BreakStatement ReturnStatement WithStatement LabelledStatement SwitchStatement ThrowStatement TryStatement DebuggerStatement
syntax cluster typescriptStatement
  \ contains=typescriptBlock,typescriptVariable,
  \ @typescriptTopExpression,typescriptAssign,
  \ typescriptConditional,typescriptRepeat,typescriptBranch,
  \ typescriptLabel,typescriptStatementKeyword,
  \ typescriptFuncKeyword,
  \ typescriptTry,typescriptExceptions,typescriptDebugger,
  \ typescriptExport,typescriptInterfaceKeyword,typescriptEnum,
  \ typescriptModule,typescriptAliasKeyword,typescriptImport

syntax cluster typescriptPrimitive  contains=typescriptString,typescriptTemplate,typescriptRegexpString,typescriptNumber,typescriptBoolean,typescriptNull,typescriptArray

syntax cluster typescriptEventTypes            contains=typescriptEventString,typescriptTemplate,typescriptNumber,typescriptBoolean,typescriptNull

" top level expression: no arrow func
" also no func keyword. funcKeyword is contained in statement
" funcKeyword allows overloading (func without body)
" funcImpl requires body
syntax cluster typescriptTopExpression
  \ contains=@typescriptPrimitive,
  \ typescriptIdentifier,typescriptIdentifierName,
  \ typescriptOperator,typescriptUnaryOp,
  \ typescriptParenExp,typescriptRegexpString,
  \ typescriptGlobal,typescriptAsyncFuncKeyword,
  \ typescriptClassKeyword,typescriptTypeCast

" no object literal, used in type cast and arrow func
" TODO: change func keyword to funcImpl
syntax cluster typescriptExpression
  \ contains=@typescriptTopExpression,
  \ typescriptArrowFuncDef,
  \ typescriptFuncImpl

syntax cluster typescriptValue
  \ contains=@typescriptExpression,typescriptObjectLiteral

syntax cluster typescriptEventExpression       contains=typescriptArrowFuncDef,typescriptParenExp,@typescriptValue,typescriptRegexpString,@typescriptEventTypes,typescriptOperator,typescriptGlobal,jsxRegion

syntax keyword typescriptAsyncFuncKeyword      async
  \ nextgroup=typescriptFuncKeyword,typescriptArrowFuncDef
  \ skipwhite

syntax keyword typescriptAsyncFuncKeyword      await
  \ nextgroup=@typescriptValue
  \ skipwhite

syntax keyword typescriptFuncKeyword           function
  \ nextgroup=typescriptAsyncFunc,typescriptFuncName,@typescriptCallSignature
  \ skipwhite skipempty

syntax match   typescriptAsyncFunc             contained /*/
  \ nextgroup=typescriptFuncName,@typescriptCallSignature
  \ skipwhite skipempty

syntax match   typescriptFuncName              contained /\K\k*/
  \ nextgroup=@typescriptCallSignature
  \ skipwhite

" destructuring ({ a: ee }) =>
syntax match   typescriptArrowFuncDef          contained /(\(\s*\({\_[^}]*}\|\k\+\)\(:\_[^)]\)\?,\?\)\+)\s*=>/
  \ contains=typescriptArrowFuncArg,typescriptArrowFunc
  \ nextgroup=@typescriptExpression,typescriptBlock
  \ skipwhite skipempty

" matches `(a) =>` or `([a]) =>` or
" `(
"  a) =>`
syntax match   typescriptArrowFuncDef          contained /(\(\_s*[a-zA-Z\$_\[.]\_[^)]*\)*)\s*=>/
  \ contains=typescriptArrowFuncArg,typescriptArrowFunc
  \ nextgroup=@typescriptExpression,typescriptBlock
  \ skipwhite skipempty

syntax match   typescriptArrowFuncDef          contained /\K\k*\s*=>/
  \ contains=typescriptArrowFuncArg,typescriptArrowFunc
  \ nextgroup=@typescriptExpression,typescriptBlock
  \ skipwhite skipempty

" TODO: optimize this pattern
syntax region   typescriptArrowFuncDef          contained start=/(\_[^(^)]*):/ end=/=>/
  \ contains=typescriptArrowFuncArg,typescriptArrowFunc,typescriptTypeAnnotation
  \ nextgroup=@typescriptExpression,typescriptBlock
  \ skipwhite skipempty keepend

syntax match   typescriptArrowFunc             /=>/
syntax match   typescriptArrowFuncArg          contained /\K\k*/
syntax region  typescriptArrowFuncArg          contained start=/<\|(/ end=/\ze=>/ contains=@typescriptCallSignature

syntax region typescriptReturnAnnotation contained start=/:/ end=/{/me=e-1 contains=@typescriptType nextgroup=typescriptBlock


syntax region typescriptFuncImpl contained start=/function\>/ end=/{/me=e-1
  \ contains=typescriptFuncKeyword
  \ nextgroup=typescriptBlock

syntax cluster typescriptCallImpl contains=typescriptGenericImpl,typescriptParamImpl
syntax region typescriptGenericImpl matchgroup=typescriptTypeBrackets
  \ start=/</ end=/>/ skip=/\s*,\s*/
  \ contains=typescriptTypeParameter
  \ nextgroup=typescriptParamImpl
  \ contained skipwhite
syntax region typescriptParamImpl matchgroup=typescriptParens
  \ start=/(/ end=/)/
  \ contains=typescriptDecorator,@typescriptParameterList,@typescriptComments
  \ nextgroup=typescriptReturnAnnotation,typescriptBlock
  \ contained skipwhite skipnl

syntax match typescriptDecorator /@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>/
  \ nextgroup=typescriptFuncCallArg,typescriptTypeArguments
  \ contains=@_semantic,typescriptDotNotation

" Define the default highlighting.
hi def link typescriptReserved             Error

hi def link typescriptEndColons            Exception
hi def link typescriptSymbols              Normal
hi def link typescriptBraces               Function
hi def link typescriptParens               Normal
hi def link typescriptComment              Comment
hi def link typescriptLineComment          Comment
hi def link typescriptDocComment           Comment
hi def link typescriptCommentTodo          Todo
hi def link typescriptMagicComment         SpecialComment
hi def link typescriptRef                  Include
hi def link typescriptDocNotation          SpecialComment
hi def link typescriptDocTags              SpecialComment
hi def link typescriptDocNGParam           typescriptDocParam
hi def link typescriptDocParam             Function
hi def link typescriptDocNumParam          Function
hi def link typescriptDocEventRef          Function
hi def link typescriptDocNamedParamType    Type
hi def link typescriptDocParamName         Type
hi def link typescriptDocParamType         Type
hi def link typescriptString               String
hi def link typescriptSpecial              Special
hi def link typescriptStringLiteralType    String
hi def link typescriptTemplateLiteralType  String
hi def link typescriptStringMember         String
hi def link typescriptTemplate             String
hi def link typescriptEventString          String
hi def link typescriptDestructureString    String
hi def link typescriptASCII                Special
hi def link typescriptTemplateSB           Label
hi def link typescriptRegexpString         String
hi def link typescriptGlobal               Constant
hi def link typescriptTestGlobal           Function
hi def link typescriptPrototype            Type
hi def link typescriptConditional          Conditional
hi def link typescriptConditionalElse      Conditional
hi def link typescriptCase                 Conditional
hi def link typescriptDefault              typescriptCase
hi def link typescriptBranch               Conditional
hi def link typescriptIdentifier           Structure
hi def link typescriptVariable             Identifier
hi def link typescriptDestructureVariable  PreProc
hi def link typescriptEnumKeyword          Identifier
hi def link typescriptRepeat               Repeat
hi def link typescriptForOperator          Repeat
hi def link typescriptStatementKeyword     Statement
hi def link typescriptMessage              Keyword
hi def link typescriptOperator             Identifier
hi def link typescriptKeywordOp            Identifier
hi def link typescriptCastKeyword          Special
hi def link typescriptType                 Type
hi def link typescriptNull                 Boolean
hi def link typescriptNumber               Number
hi def link typescriptBoolean              Boolean
hi def link typescriptObjectLabel          typescriptLabel
hi def link typescriptDestructureLabel     Function
hi def link typescriptLabel                Label
hi def link typescriptTupleLable           Label
hi def link typescriptStringProperty       String
hi def link typescriptImport               Special
hi def link typescriptImportType           Special
hi def link typescriptAmbientDeclaration   Special
hi def link typescriptExport               Special
hi def link typescriptExportType           Special
hi def link typescriptModule               Special
hi def link typescriptTry                  Special
hi def link typescriptExceptions           Special

hi def link typescriptMember              Function
hi def link typescriptMethodAccessor       Operator

hi def link typescriptAsyncFuncKeyword     Keyword
hi def link typescriptObjectAsyncKeyword   Keyword
hi def link typescriptAsyncFor             Keyword
hi def link typescriptFuncKeyword          Keyword
hi def link typescriptAsyncFunc            Keyword
hi def link typescriptArrowFunc            Type
hi def link typescriptFuncName             Function
hi def link typescriptFuncArg              PreProc
hi def link typescriptArrowFuncArg         PreProc
hi def link typescriptFuncComma            Operator

hi def link typescriptClassKeyword         Keyword
hi def link typescriptClassExtends         Keyword
" hi def link typescriptClassName            Function
hi def link typescriptAbstract             Special
" hi def link typescriptClassHeritage        Function
" hi def link typescriptInterfaceHeritage    Function
hi def link typescriptClassStatic          StorageClass
hi def link typescriptReadonlyModifier     Keyword
hi def link typescriptInterfaceKeyword     Keyword
hi def link typescriptInterfaceExtends     Keyword
hi def link typescriptInterfaceName        Function

hi def link shellbang                      Comment

hi def link typescriptTypeParameter         Identifier
hi def link typescriptConstraint            Keyword
hi def link typescriptPredefinedType        Type
hi def link typescriptReadonlyArrayKeyword  Keyword
hi def link typescriptUnion                 Operator
hi def link typescriptFuncTypeArrow         Function
hi def link typescriptConstructorType       Function
hi def link typescriptTypeQuery             Keyword
hi def link typescriptAccessibilityModifier Keyword
hi def link typescriptOptionalMark          PreProc
hi def link typescriptFuncType              Special
hi def link typescriptMappedIn              Special
hi def link typescriptCall                  PreProc
hi def link typescriptParamImpl             PreProc
hi def link typescriptConstructSignature    Identifier
hi def link typescriptAliasDeclaration      Identifier
hi def link typescriptAliasKeyword          Keyword
hi def link typescriptUserDefinedType       Keyword
hi def link typescriptTypeReference         Identifier
hi def link typescriptConstructor           Keyword
hi def link typescriptDecorator             Special
hi def link typescriptAssertType            Keyword

hi link typeScript             NONE

if exists('s:cpo_save')
  let &cpo = s:cpo_save
  unlet s:cpo_save
endif
