sveast 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -8
- package/core.d.ts +26 -4
- package/core.js +1 -1
- package/entities.js +1 -1
- package/index.d.ts +153 -5
- package/index.js +1 -1
- package/is-valid-type.js +1 -1
- package/lexer.d.ts +79 -0
- package/lexer.js +2 -0
- package/package.json +11 -1
- package/parse-imports-exports.js +1 -0
- package/parse-module.js +1 -1
- package/parse.js +1 -1
- package/{shared-p7c7qbej.js → shared-1xjsv3h6.js} +2 -2
- package/shared-as9can03.js +10 -0
- package/shared-b37zemjd.js +2 -0
- package/shared-drsxcq8p.js +2 -0
- package/{shared-c2k7d7rg.js → shared-g16dt48m.js} +2 -2
- package/shared-gyydaea2.js +3 -0
- package/shared-mwp38arc.js +2 -0
- package/shared-pmkdz7sc.js +3 -0
- package/shared-pt7hcxxy.js +2 -0
- package/shared-pyjcz2f8.js +12 -0
- package/shared-qnfwr59k.js +2 -0
- package/{shared-xw9zc4rz.js → shared-yr6e6h72.js} +2 -2
- package/typescript.js +1 -1
- package/walk.d.ts +1891 -0
- package/walk.js +1 -1
- package/shared-3ca5cgq8.js +0 -2
- package/shared-7q7hyetp.js +0 -3
- package/shared-cx7c0gk3.js +0 -10
- package/shared-da2hc1fx.js +0 -2
- package/shared-kqcn291j.js +0 -2
- package/shared-t6kshmn4.js +0 -12
- package/shared-xvd609sh.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b}from"./shared-cx7c0gk3.js";var N=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,F=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),q=new Set("public private protected readonly declare abstract override static accessor".split(" ")),O=new Set("public private protected readonly override".split(" ")),K=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),V=new Set("var let const function class interface enum".split(" ")),L=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),C=1,H=32,U=256,j=0,z=1,d=2,G=3,Q=4,T=6,w=7,D=256,g=1024,W=8|g,Y=d|D,I=1,X=2,P=40,J=41,Z=44,_=46,v=58,f=61,R=60,m=123,tt=91,S=42,et=35,A=34,E=39,st=SyntaxError("speculative parse failed"),y=b((x)=>{let{tokTypes:s,keywordTypes:M,isIdentifierChar:B,isIdentifierStart:c}=x.acorn,u=new x.acorn.TokenType("@");class k extends x{inType=!1;$5=!1;$6=!1;$8=null;$o=null;$p=!1;$q=!1;$i=null;$b=[[]];$r=0;$12=0;constructor(t,e,r){super(t,e,r);let i=this.options.onComment;if(typeof i==="function")this.options.onComment=(n,a,h,o,l,p)=>{if(h<this.$12)return;this.$12=o,i.call(this,n,a,h,o,l,p)}}getTokenFromCode(t){if(t===64)return++this.pos,this.finishToken(u);return super.getTokenFromCode(t)}readToken_lt_gt(t){if(this.inType)return this.finishOp(s.relational,1);return super.readToken_lt_gt(t)}$9(t){let e=this.inType;this.inType=!0;let r=t();if(this.inType=e,!e&&this.type===s.relational)this.pos=this.start,this.nextToken();return r}$1(){return this.type===s.relational&&this.value==="<"}$k(){if(this.type===s.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(s.relational,"<");return this.$1()}$c(){return this.type===s.relational&&this.value===">"}$s(){return this.type===s.prefix&&this.value==="!"}hasPrecedingLineBreak(){return this.$13(this.lastTokEnd,this.start)}$13(t,e){for(let r=t;r<e;r++){let i=this.input.charCodeAt(r);if(i===10||i===13||i===8232||i===8233)return!0}return!1}$d(t=this.pos){return N.lastIndex=t,N.exec(this.input),N.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let t=this.$d(),e=t;while(e<this.input.length&&B(this.input.charCodeAt(e)))e++;return this.input.slice(t,e)}$a(){return!this.$13(this.pos,this.$d())}$14(){return this.$a()&&c(this.$2())&&!Object.hasOwn(M,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$5:this.$5,$6:this.$6,$8:this.$8,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(t){this.pos=t.pos,this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,this.startLoc=t.startLoc,this.endLoc=t.endLoc,this.lastTokStart=t.lastTokStart,this.lastTokEnd=t.lastTokEnd,this.lastTokStartLoc=t.lastTokStartLoc,this.lastTokEndLoc=t.lastTokEndLoc,this.curLine=t.curLine,this.lineStart=t.lineStart,this.context=t.context,this.exprAllowed=t.exprAllowed,this.containsEsc=t.containsEsc,this.inType=t.inType,this.$5=t.$5,this.$6=t.$6,this.$8=t.$8,this.scopeStack.length=t.scopes,this.privateNameStack.length=t.privateNames,this.labels=t.labels,this.labels.length=t.labelCount,this.strict=t.strict,this.yieldPos=t.yieldPos,this.awaitPos=t.awaitPos,this.awaitIdentPos=t.awaitIdentPos,this.potentialArrowAt=t.potentialArrowAt,this.potentialArrowInForAwait=t.potentialArrowInForAwait}raise(t,e){if(this.$r>0)throw st;return super.raise(t,e)}$1y(t,e){try{super.raise(t,e)}catch(r){if(r instanceof SyntaxError)r.$1z=!0;throw r}throw Error("unreachable")}$f(t,e=!1){let r=this.$15();this.$r++;try{let i=t();if(e||i===void 0)this.$16(r);return i}catch(i){if(!(i instanceof SyntaxError)||!e&&i.$1z)throw i;this.$16(r);return}finally{this.$r--}}$t(t){return this.$f(t,!0)===!0}$17(t){if(t.end=this.lastTokEnd,this.options.locations)t.loc.end=this.lastTokEndLoc}$l(t,e){if(t.start=e.start,this.options.locations)t.loc.start=e.loc.start}$4(t=!1){let e=this.startNode();return e.typeAnnotation=this.$9(()=>(this.next(),t?this.$20():this.$0())),this.finishNode(e,"TSTypeAnnotation")}$g(t,e){if(e&&this.eat(s.question))t.optional=!0,this.$17(t);if(this.type===s.colon)t.typeAnnotation=this.$4(),this.$17(t);return t}$20(){if(this.type!==s.name&&this.type!==s._this)return this.$0();if(this.isContextual("asserts")&&this.$a()&&c(this.$2())){let t=this.startNode();if(this.next(),t.parameterName=this.type===s._this?this.$u():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$v(t,!0);return t.asserts=!0,t.typeAnnotation=null,this.finishNode(t,"TSTypePredicate")}if(this.$3()==="is"&&this.$a()){let t=this.startNode();return t.parameterName=this.type===s._this?this.$u():this.parseIdent(!0),this.$v(t,!1)}return this.$0()}$v(t,e){this.next();let r=this.startNode();return r.typeAnnotation=this.$0(),t.typeAnnotation=this.finishNode(r,"TSTypeAnnotation"),t.asserts=e,this.finishNode(t,"TSTypePredicate")}$u(){let t=this.startNode();return this.next(),this.finishNode(t,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let t=this.$0();if(this.type!==s.eof)this.unexpected();return t}$0(){let t=this.$18();if(this.$5||this.type!==s._extends||this.hasPrecedingLineBreak())return t;let e=this.startNodeAt(t.start,t.loc?.start);return this.next(),e.checkType=t,e.extendsType=this.$h(!0,()=>this.$18()),this.expect(s.question),e.trueType=this.$h(!1,()=>this.$0()),this.expect(s.colon),e.falseType=this.$h(!1,()=>this.$0()),this.finishNode(e,"TSConditionalType")}$h(t,e){let r=this.$5;this.$5=t;let i=e();return this.$5=r,i}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===s._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",s.bitwiseOR,()=>this.$1a("TSIntersectionType",s.bitwiseAND,()=>this.$1b()))}$19(t){let e=this.startNode();if(t==="TSConstructorType"){if(e.abstract=this.isContextual("abstract"),e.abstract)this.next();this.next()}return this.$h(!1,()=>this.$m(e,s.arrow)),this.finishNode(e,t)}$m(t,e){if(this.$1())t.typeParameters=this.$7();if(this.expect(s.parenL),t.parameters=this.parseBindingList(s.parenR,!1,!0),this.type===e)t.typeAnnotation=this.$4(!0);else if(e===s.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==s.parenL)return!1;return this.$t(()=>{if(this.next(),this.type===s.parenR||this.type===s.ellipsis)return!0;if(this.type===s.name||this.type===s._this)this.next();else if(this.type===s.braceL||this.type===s.bracketL)this.parseBindingAtom();else return!1;let t=this.type;if(t===s.colon||t===s.comma||t===s.question||t===s.eq)return!0;if(t!==s.parenR)return!1;return this.next(),this.type===s.arrow})}$1a(t,e,r){let i=this.startNode(),n=this.eat(e),a=[];do a.push(r());while(this.eat(e));if(a.length===1&&!n)return a[0];return i.types=a,this.finishNode(i,t)}$1b(){if(this.type===s.name&&!this.containsEsc){let t=this.value;if(t==="keyof"||t==="unique"||t==="readonly"){let e=this.startNode();return this.next(),e.operator=t,e.typeAnnotation=this.$1b(),this.finishNode(e,"TSTypeOperator")}if(t==="infer"){let e=this.startNode();this.next();let r=this.startNode();r.name=this.$w();let i=this.$f(()=>this.$22());if(i)r.constraint=i;return e.typeParameter=this.finishNode(r,"TSTypeParameter"),this.finishNode(e,"TSInferType")}}return this.$h(!1,()=>this.$23())}$22(){if(!this.eat(s._extends))return;let t=this.$h(!0,()=>this.$0());if(this.$5||this.type!==s.question)return t;return}$w(){if(this.type!==s.name&&!this.type.keyword)this.unexpected();let t=this.type===s.name?this.value:this.type.keyword;return this.next(),t}$23(){let t=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(s.bracketL)){let e=this.startNodeAt(t.start,t.loc?.start);if(this.eat(s.bracketR))e.elementType=t,t=this.finishNode(e,"TSArrayType");else e.objectType=t,e.indexType=this.$0(),this.expect(s.bracketR),t=this.finishNode(e,"TSIndexedAccessType")}return t}$24(){switch(this.type){case s.name:case s._void:case s._null:{let t=F.get(this.value);if(t&&(this.type!==s.name||!this.containsEsc&&this.$2()!==_)){let e=this.startNode();return this.next(),this.finishNode(e,t)}return this.$1c()}case s.string:case s.num:case s._true:case s._false:{let t=this.startNode();return t.literal=this.parseExprAtom(),this.finishNode(t,"TSLiteralType")}case s.plusMin:{if(this.value!=="-")break;let t=this.startNode(),e=this.startNode();if(this.next(),this.type!==s.num)this.unexpected();return e.operator="-",e.prefix=!0,e.argument=this.parseExprAtom(),t.literal=this.finishNode(e,"UnaryExpression"),this.finishNode(t,"TSLiteralType")}case s.backQuote:return this.$25();case s._this:{let t=this.$u();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let e=this.startNodeAt(t.start,t.loc?.start);return e.parameterName=t,this.$v(e,!1)}return t}case s._typeof:return this.$26();case s._import:return this.$1d();case s.braceL:return this.$27()?this.$28():this.$29();case s.bracketL:return this.$2a();case s.parenL:{let t=this.startNode();return this.next(),t.typeAnnotation=this.$0(),this.expect(s.parenR),this.finishNode(t,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let t=this.startNode();if(t.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())t.typeArguments=this.$e();return this.finishNode(t,"TSTypeReference")}$j(){let t=this.parseIdent(!0);while(this.eat(s.dot)){let e=this.startNodeAt(t.start,t.loc?.start);e.left=t,e.right=this.parseIdent(!0),t=this.finishNode(e,"TSQualifiedName")}return t}$26(){let t=this.startNode();if(this.next(),t.exprName=this.type===s._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())t.typeArguments=this.$e();return this.finishNode(t,"TSTypeQuery")}$1d(){let t=this.startNode();if(this.next(),t.argument=this.$1e(),this.eat(s.dot))t.qualifier=this.$j();if(this.$1())t.typeArguments=this.$e();return this.finishNode(t,"TSImportType")}$x(){if(this.type!==s.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(s.parenL);let t=this.$x();return this.expect(s.parenR),t}$25(){let t=this.startNode(),e=this.startNode();this.next(),e.expressions=[];let r=this.parseTemplateElement({isTagged:!1});e.quasis=[r];while(!r.tail){if(this.type===s.eof)this.raise(this.pos,"Unterminated template literal");this.expect(s.dollarBraceL),e.expressions.push(this.$0()),this.expect(s.braceR),r=this.parseTemplateElement({isTagged:!1}),e.quasis.push(r)}return this.next(),t.literal=this.finishNode(e,"TemplateLiteral"),this.finishNode(t,"TSLiteralType")}$27(){return this.$t(()=>{if(this.next(),this.type===s.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==s.bracketL)return!1;if(this.next(),this.type!==s.name)return!1;return this.next(),this.type===s._in})}$28(){let t=this.startNode();if(this.expect(s.braceL),this.type===s.plusMin)t.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))t.readonly=!0;this.expect(s.bracketL);let e=this.startNode();if(e.name=this.$w(),this.expect(s._in),e.constraint=this.$0(),t.typeParameter=this.finishNode(e,"TSTypeParameter"),t.nameType=this.eatContextual("as")?this.$0():null,this.expect(s.bracketR),this.type===s.plusMin)t.optional=this.value,this.next(),this.expect(s.question);else if(this.eat(s.question))t.optional=!0;if(this.eat(s.colon))t.typeAnnotation=this.$0();return this.semicolon(),this.expect(s.braceR),this.finishNode(t,"TSMappedType")}$29(){let t=this.startNode();return t.members=this.$1f(),this.finishNode(t,"TSTypeLiteral")}$1f(){this.expect(s.braceL);let t=[];while(!this.eat(s.braceR))t.push(this.$2b());return t}$2b(){let t=this.startNode(),e="TSPropertySignature",r=this.type===s._new?this.$2():-1;if(this.type===s.parenL||this.$1())e="TSCallSignatureDeclaration",this.$m(t,s.colon);else if(r===P||r===R)e="TSConstructSignatureDeclaration",this.next(),this.$m(t,s.colon);else{let i=this.type===s._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$n(!0))this.next(),t.readonly=!0;if(this.type===s.bracketL&&this.$1g())return this.$1h(t);let n="method";if(i)t.key=i;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$n(!1))n=this.value,this.next();this.parsePropertyName(t)}if(this.eat(s.question))t.optional=!0;if(this.type===s.parenL||this.$1()){if(e="TSMethodSignature",n!=="method")t.kind=n;this.$m(t,s.colon),t.kind=n}else if(this.type===s.colon)t.typeAnnotation=this.$4()}return this.$1i(),this.finishNode(t,e)}$1i(){if(!this.eat(s.comma))this.semicolon()}$1g(){return this.$t(()=>{if(this.next(),this.type!==s.name)return!1;return this.next(),this.type===s.colon})}$1h(t){if(this.expect(s.bracketL),t.parameters=[this.$g(this.parseIdent(),!1)],this.expect(s.bracketR),this.type===s.colon)t.typeAnnotation=this.$4();return this.$1i(),this.finishNode(t,"TSIndexSignature")}$2a(){let t=this.startNode();this.expect(s.bracketL),t.elementTypes=[];while(!this.eat(s.bracketR))if(t.elementTypes.push(this.$2c()),this.type!==s.bracketR)this.expect(s.comma);return this.finishNode(t,"TSTupleType")}$2c(){let t=this.start,e=this.startLoc,r=this.eat(s.ellipsis),i;if((this.type===s.name||this.type.keyword)&&this.$2d()){let n=this.startNode();n.label=this.parseIdent(!0),n.optional=this.eat(s.question),this.expect(s.colon),n.elementType=this.$0(),i=this.finishNode(n,"TSNamedTupleMember")}else if(i=this.$0(),this.eat(s.question)){let n=this.startNodeAt(i.start,i.loc?.start);n.typeAnnotation=i,i=this.finishNode(n,"TSOptionalType")}if(r){let n=this.startNodeAt(t,e);n.typeAnnotation=i,i=this.finishNode(n,"TSRestType")}return i}$2d(){let t=this.$d();if(this.input.charCodeAt(t)===63)t=this.$d(t+1);return this.input.charCodeAt(t)===v}$7(){return this.$9(()=>{let t=this.startNode();this.next(),t.params=[];while(!this.$c()){let e=this.startNode();while((this.type===s._const||this.type===s._in||this.isContextual("out"))&&c(this.$2()))e[this.value]=!0,this.next();if(e.name=this.$w(),this.eat(s._extends))e.constraint=this.$0();if(this.eat(s.eq))e.default=this.$0();if(t.params.push(this.finishNode(e,"TSTypeParameter")),!this.$c()){if(this.expect(s.comma),this.$c())t.extra={trailingComma:this.lastTokStart}}}if(this.next(),t.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(t,"TSTypeParameterDeclaration")})}$e(){return this.$9(()=>{let t=this.startNode();this.next(),t.params=[];while(!this.$c())if(t.params.push(this.$0()),!this.$c())this.expect(s.comma);if(t.params.length===0)this.unexpected();return this.next(),this.finishNode(t,"TSTypeParameterInstantiation")})}$1j(){let t=[];do{let e=this.startNode();if(e.expression=this.$j(),this.$1())e.typeParameters=this.$e();t.push(this.finishNode(e,"TSExpressionWithTypeArguments"))}while(this.eat(s.comma));return t}$1k(t=!1){if(this.type!==s.name||this.containsEsc){if(this.type===s._const&&this.$3()==="enum")return this.$y(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(t);return this.$1l(this.startNode(),this.value)}$2e(t){switch(t){case"interface":case"type":case"namespace":return this.$14();case"enum":return c(this.$2());case"abstract":return this.$a()&&this.$3()==="class";case"module":{let e=this.$2();return this.$a()&&(e===A||e===E||c(e))}case"declare":return this.$a()&&K.has(this.$3());case"global":return this.$a()&&this.$2()===m}return!1}$1l(t,e){switch(e){case"interface":return this.$1m(t);case"type":return this.$2g(t);case"enum":return this.$y(t);case"abstract":return this.$1n(t,!0);case"global":return t.global=!0,t.id=this.parseIdent(),t.body=this.$z(),this.finishNode(t,"TSModuleDeclaration")}return this.$2h(t)}$2f(t){let e=this.$6;this.$6=!0;let r=this.startNode();this.next();let i=this.value;if(i==="const"&&this.$3()==="enum")r.const=!0;if(!t&&V.has(i))r.declare=!0;let n;if(r.const)n=this.$y(r);else if(i==="var"||i==="let"||i==="const")n=this.parseVarStatement(r,i,!0);else if(i==="function")this.next(),n=this.parseFunction(r,I,!1,!1);else if(i==="class")n=this.parseClass(r,!0);else n=this.$1l(r,i);return n.declare=!0,this.$6=e,n}$1n(t,e){return this.next(),t.abstract=!0,this.parseClass(t,e)}$1m(t){if(this.next(),t.id=this.parseIdent(),this.checkLValSimple(t.id,w),this.$1())t.typeParameters=this.$7();return this.$9(()=>{if(this.eat(s._extends))t.extends=this.$1j();let e=this.startNode();e.body=this.$1f(),t.body=this.finishNode(e,"TSInterfaceBody")}),this.finishNode(t,"TSInterfaceDeclaration")}$2g(t){if(this.next(),t.id=this.parseIdent(),this.checkLValSimple(t.id,T),this.$1())t.typeParameters=this.$7();return t.typeAnnotation=this.$9(()=>(this.expect(s.eq),this.$0())),this.semicolon(),this.finishNode(t,"TSTypeAliasDeclaration")}$y(t){if(this.type===s._const)t.const=!0,this.next();this.next(),t.id=this.parseIdent(),this.checkLValSimple(t.id,Y),this.expect(s.braceL),t.members=[];while(!this.eat(s.braceR)){let e=this.startNode();if(e.id=this.type===s.string?this.parseExprAtom():this.parseIdent(!0),this.eat(s.eq))e.initializer=this.parseMaybeAssign();if(t.members.push(this.finishNode(e,"TSEnumMember")),this.type!==s.braceR)this.expect(s.comma)}return this.finishNode(t,"TSEnumDeclaration")}$2h(t){if(this.next(),this.type===s.string){if(t.id=this.parseExprAtom(),this.type===s.braceL)t.body=this.$z();else this.semicolon();return this.finishNode(t,"TSModuleDeclaration")}return t.id=this.parseIdent(),this.checkLValSimple(t.id,W),this.$1o(t)}$1o(t){if(this.eat(s.dot)){let e=this.startNode();e.id=this.parseIdent(),t.body=this.$1o(e)}else t.body=this.$z();return this.finishNode(t,"TSModuleDeclaration")}$z(){this.enterScope(U);let t=this.startNode();this.enterScope(0),this.expect(s.braceL),t.body=[];while(!this.eat(s.braceR))t.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(t,"TSModuleBlock")}$1p(t,e){if(t.isExport=e,t.id=this.parseIdent(),this.checkLValSimple(t.id,d),this.expect(s.eq),this.isContextual("require")&&this.$2()===P){let r=this.startNode();this.next(),r.expression=this.$1e(),t.moduleReference=this.finishNode(r,"TSExternalModuleReference")}else t.moduleReference=this.$j();return this.semicolon(),this.finishNode(t,"TSImportEqualsDeclaration")}$2i(){let t=this.$d();if(this.input.charCodeAt(t)!==f)return!1;let e=this.input.charCodeAt(t+1);return e!==f&&e!==62}parseStatement(t,e,r){if(this.type===u)this.$1q(!0);let i=this.$1k();if(i)return i;return super.parseStatement(t,e,r)}parseVarStatement(t,e,r){return super.parseVarStatement(t,e,r||this.$6)}parseVarId(t,e){if(super.parseVarId(t,e),t.id.type==="Identifier"&&this.$s()&&!this.hasPrecedingLineBreak())this.next(),t.definite=!0;this.$g(t.id,!1)}parseCatchClauseParam(){let t=this.$g(this.parseBindingAtom(),!1),e=t.type==="Identifier";return this.enterScope(e?H:0),this.checkLValPattern(t,e?Q:d),this.expect(s.parenR),t}parseImport(t){if(this.next(),t.importKind="value",this.type===s.string)t.specifiers=[],t.source=this.parseExprAtom();else{if(this.isContextual("type")){let e=this.$2();if(e===m||e===S||c(e)&&this.$3()!=="from")t.importKind="type",this.next()}if(this.type===s.name&&this.$2i())return this.$1p(t,!1);t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.$x()}return this.$1r(t),this.semicolon(),this.finishNode(t,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=s._with;return this.type===s._with?super.parseWithClause():void 0}$1r(t){let e=this.parseWithClause();if(e)t.attributes=e}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(t){return this.$1s("exportKind",()=>super.parseExportSpecifier(t))}$1s(t,e){let r=this.isContextual("type")?this.$2():-1;if(r===A||r===E||c(r)&&this.$3()!=="as"){let n=this.startNode();this.next();let a=e();return this.$l(a,n),a[t]="type",a}let i=e();return i[t]="value",i}parseExport(t,e){if(this.next(),this.eat(s._import)){if(t.importKind="value",this.isContextual("type")&&c(this.$2())&&this.$3()!=="from")t.importKind="type",this.next();return this.$1p(t,!0)}if(this.eat(s.eq))return t.expression=this.parseExpression(),this.semicolon(),this.finishNode(t,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),t.id=this.parseIdent(),this.semicolon(),this.finishNode(t,"TSNamespaceExportDeclaration");if(t.exportKind="value",this.isContextual("type")){let n=this.$2();if(n===m||n===S)t.exportKind="type",this.next()}if(this.eat(s.star))return this.parseExportAllDeclaration(t,e);if(this.eat(s._default)){if(this.isContextual("interface")&&this.$14())t.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")t.declaration=this.$1n(this.startNode(),"nullableID");else t.declaration=this.parseExportDefaultDeclaration();return this.finishNode(t,"ExportDefaultDeclaration")}let r=this.isContextual("declare"),i=this.$1k(!0);if(i||this.shouldParseExportStatement()){if(t.declaration=i??this.parseStatement(null),r||t.declaration.type==="TSInterfaceDeclaration"||t.declaration.type==="TSTypeAliasDeclaration")t.exportKind="type";return t.specifiers=[],t.source=null,this.finishNode(t,"ExportNamedDeclaration")}if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))t.source=this.$x(),this.$1r(t);else{for(let n of t.specifiers)if(this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal")this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.");t.source=null}return this.semicolon(),this.finishNode(t,"ExportNamedDeclaration")}parseFunction(t,e,r,i,n){let a=e&I;if(a)this.$i=t;super.parseFunction(t,e,r,i,n),this.$i=null;let h=!t.body;if(h)t.type="TSDeclareFunction";if(a&&t.id){if(h){if(this.$6&&this.currentScope().flags&C)this.declareName(t.id.name,g,t.id.start);this.checkLValSimple(t.id,j)}else if(!(e&X)){let o=G;if(this.strict||t.generator||t.async)o=this.treatFunctionsAsVar?z:d;this.checkLValSimple(t.id,o)}}return t}parseFunctionParams(t){if(this.$1())t.typeParameters=this.$7();if(super.parseFunctionParams(t),this.type===s.colon)t.returnType=this.$4(!0)}parseFunctionBody(t,e,r,i){if(r&&this.type===s.colon)t.returnType=this.$4(!0);if(e||this.type===s.braceL){super.parseFunctionBody(t,e,r,i);return}this.semicolon(),this.exitScope()}parseMethod(t,e,r){let i=this.$o;this.$o=null;let n=super.parseMethod(t,e,r);if(!n.body)n.type="TSDeclareMethod";if(i)n.typeParameters=i;return n}parseBindingList(t,e,r,i){let n=i===!0||this.$p;return this.$p=!1,super.parseBindingList(t,e,r,n)}$n(t){if(!t&&!this.$a())return!1;let e=this.$2();return e===tt||e===m||e===S||e===_||e===et||e===A||e===E||e>=48&&e<=57||c(e)}parseAssignableListItem(t){let e=this.$10(),r=this.start,i=this.startLoc,n,a=!1,h=!1;if(t)while(this.type===s.name&&O.has(this.value)&&!this.containsEsc&&this.$n(!1)){if(this.value==="readonly")a=!0;else if(this.value==="override")h=!0;else n=this.value;this.next()}let o;if(this.type===s._this)o=this.startNode(),o.name="this",this.next(),this.finishNode(o,"Identifier");else o=this.parseBindingAtom();let l=this.type===s.eq?this.parseMaybeDefault(r,i,o):this.parseMaybeDefault(o.start,o.loc?.start,this.$g(o,!0));if(e.length>0)l.decorators=e;if(!n&&!a&&!h)return l;let p=this.startNodeAt(r,i);if(n)p.accessibility=n;if(a)p.readonly=!0;if(h)p.override=!0;return p.parameter=l,this.finishNode(p,"TSParameterProperty")}parseBindingListItem(t){if(t.type==="RestElement")this.$g(t,!0);return t}checkLValSimple(t,e,r){if(this.$i&&t===this.$i.id){this.$i=null;return}if(!e&&L.has(t.type)){this.checkLValSimple(t.expression,e,r);return}switch(t.type){case"TSParameterProperty":this.checkLValInnerPattern(t.parameter,e,r);return;case"Identifier":if(t.name==="this")return}super.checkLValSimple(t,e,r)}toAssignable(t,e,r){if(t&&!e&&L.has(t.type))return t;return super.toAssignable(t,e,r)}declareName(t,e,r){let i=this.currentScope();if(e&g){this.$1t(i,t),i.$1u??=[],i.$1u.push(t);return}if(e===T||e===w){if(i.$11??=[],e===T&&i.$11.includes(t))this.raise(r,`type '${t}' has already been declared.`);i.$11.push(t),this.$1t(i,t);return}if(e&D){if(i.$1v??=[],i.$1v.includes(t))return;super.declareName(t,d,r),i.$1v.push(t);return}super.declareName(t,e,r)}$1t(t,e){if(this.inModule&&t.flags&C)delete this.undefinedExports[e]}checkLocalExport(t){for(let e=this.scopeStack.length-1;e>=0;e--){let r=this.scopeStack[e];if(r.$11?.includes(t.name)||r.$1u?.includes(t.name))return}super.checkLocalExport(t)}checkExport(){}raiseRecoverable(t,e){if(e==="Duplicate constructor in the same class")return;super.raiseRecoverable(t,e)}$10(){let t=[];while(this.type===u)t.push(this.$1w());return t}$1q(t){let e=this.$b[this.$b.length-1];while(this.type===u)e.push(this.$1w());if(this.type===s._export){if(!t)this.unexpected()}else if(this.type!==s._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let t=this.startNode();this.next(),this.$b.push([]);let e=this.start,r=this.startLoc,i;if(this.type===s.parenL){if(this.next(),i=this.parseExpression(),this.expect(s.parenR),this.options.preserveParens){let a=this.startNodeAt(e,r);a.expression=i,i=this.finishNode(a,"ParenthesizedExpression")}}else{i=this.parseIdent(!1);while(this.eat(s.dot)){let a=this.startNodeAt(e,r);a.object=i,a.property=this.parseIdent(!0),a.computed=!1,i=this.finishNode(a,"MemberExpression")}}let n=this.$k()?this.$e():void 0;if(this.eat(s.parenL)){let a=this.startNodeAt(i.start,i.loc?.start);if(a.callee=i,a.arguments=this.parseExprList(s.parenR,!1,!1),n)a.typeArguments=n;i=this.finishNode(a,"CallExpression")}else if(n){let a=this.startNodeAt(i.start,i.loc?.start);a.expression=i,a.typeArguments=n,i=this.finishNode(a,"TSInstantiationExpression")}return t.expression=i,this.$b.pop(),this.finishNode(t,"Decorator")}shouldParseExportStatement(){return this.type===u||super.shouldParseExportStatement()}parseExprAtom(t,e,r){if(this.type===u)this.$1q(!1);return super.parseExprAtom(t,e,r)}parseProperty(t,e){if(t||this.type!==u)return super.parseProperty(t,e);let r=this.$10(),i=super.parseProperty(t,e);if(i.type==="SpreadElement")this.raise(i.start,"Decorators can't be used with SpreadElement");return i.decorators=r,i}parseClassId(t,e){let r=this.$b.length-1,i=this.$b[r];if(i.length>0)t.decorators=i,this.$l(t,i[0]),this.$b[r]=[];if(!this.isContextual("implements")||e===!0)super.parseClassId(t,e);if(this.$1())t.typeParameters=this.$7()}parseClassSuper(t){if(super.parseClassSuper(t),t.superClass&&this.$1())t.superTypeParameters=this.$e();if(this.eatContextual("implements"))t.implements=this.$9(()=>this.$1j())}parseClassElement(t){if(this.type===u){let h=this.$10();if(this.type===s.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let o=this.parseClassElement(t);return o.decorators=h,this.$l(o,h[0]),o}if(this.eat(s.semi))return null;let e=this.startNode();while(this.type===s.name&&q.has(this.value)&&!this.containsEsc&&this.$n(this.value==="static")){let h=this.value;if(this.next(),h==="static"&&this.type===s.braceL)return this.next(),this.parseClassStaticBlock(e),e;if(h==="public"||h==="private"||h==="protected")e.accessibility=h;else e[h]=!0}if(this.type===s.bracketL&&this.$1g())return this.$1h(e);e.static??=!1;let r="",i=!1,n=!1,a="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===s.star)&&!this.canInsertSemicolon())n=!0;else r="async";if(!r&&this.eat(s.star))i=!0;if(!r&&!n&&!i){let h=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())a=h;else r=h}if(r)e.computed=!1,e.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),e.key.name=r,this.finishNode(e.key,"Identifier");else this.parseClassElementName(e);if(this.eat(s.question))e.optional=!0;if(this.type===s.parenL||this.$1()||a!=="method"||i||n){let h=e.key,o=!e.static&&!e.computed&&(h.type==="Identifier"&&h.name==="constructor"||h.type==="Literal"&&h.value==="constructor");if(e.kind=o?"constructor":a,this.$1())e.typeParameters=this.$7();this.$p=o,this.parseClassMethod(e,i,n,o&&t)}else{if(!e.optional&&this.$s())this.next(),e.definite=!0;if(this.type===s.colon)e.typeAnnotation=this.$4();this.parseClassField(e)}return e}parseMaybeAssign(t,e,r){if(this.$k()){let i=this.$f(()=>{let n=this.$7(),a=super.parseMaybeAssign(t,e,r);if(a.type!=="ArrowFunctionExpression")return;return a.typeParameters=n,this.$l(a,n),a});if(i)return i}return super.parseMaybeAssign(t,e,r)}parseMaybeUnary(t,e,r,i){if(this.$k()){let n=this.startNode();return n.typeAnnotation=this.$9(()=>{this.next();let a=this.$0();if(!this.$c())this.unexpected();return this.next(),a}),n.expression=this.parseMaybeUnary(null,!1,!1,i),this.finishNode(n,"TSTypeAssertion")}return super.parseMaybeUnary(t,e,r,i)}parseMaybeConditional(t,e){let r=this.start,i=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.type===s.question&&!(n.type==="ArrowFunctionExpression"&&n.start===r)&&!this.$2j()){this.next();let a=this.startNodeAt(r,i);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(s.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return n}$2j(){let t=this.$d(),e=this.input.charCodeAt(t);if(e===v||e===Z||e===J)return!0;return e===f&&this.input.charCodeAt(t+1)!==f}parseParenItem(t){return this.$g(t,!0)}$1x(){if(this.type!==s.colon)return!0;let t=this.$f(()=>{let e=this.$4(!0);return this.type===s.arrow&&!this.canInsertSemicolon()?e:void 0});if(!t)return!1;return this.$8=t,!0}shouldParseArrow(t){return this.$1x()&&super.shouldParseArrow(t)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(t,e,r,i){if(this.$8)t.returnType=this.$8,this.$8=null;return super.parseArrowExpression(t,e,r,i)}parseExprList(t,e,r,i){if(!this.$q)return super.parseExprList(t,e,r,i);this.$q=!1;let n=[],a=!0;while(!this.eat(t)){if(a)a=!1;else if(this.expect(s.comma),e&&this.afterTrailingComma(t))break;if(this.type===s.ellipsis){let h=this.parseSpread(i);if(this.eat(s.question))h.optional=!0;if(this.type===s.colon)h.typeAnnotation=this.$4();n.push(h)}else n.push(this.parseMaybeAssign(!1,i,this.parseParenItem))}return n}parseSubscript(t,e,r,i,n,a,h){if(this.$s()&&!this.hasPrecedingLineBreak()){let l=this.startNodeAt(e,r);return this.exprAllowed=!1,this.next(),l.expression=t,this.finishNode(l,"TSNonNullExpression")}if(n&&this.$1()){let l=this.$f(()=>this.$2k(e,r,h));if(l)return l}let o=this.type===s.questionDot&&this.$2()===R;if(this.$1()||o||this.type===s.bitShift&&this.value==="<<"){let l=this.$f(()=>{if(o)this.next();this.$k();let p=this.$e();if(this.type===s.parenL&&!i)return p;if(this.type===s.backQuote)return o?void 0:p;if(o)return;if(this.$c()||this.type===s.bitShift||this.type.startsExpr&&this.type!==s.parenL&&!this.hasPrecedingLineBreak())return;return p});if(l){let p=this.startNodeAt(e,r);if(this.type===s.parenL&&!i){if(this.next(),p.callee=t,p.arguments=this.parseExprList(s.parenR,!0,!1),p.typeArguments=l,o)t.optional=!0;if(o||a)p.optional=o;return this.finishNode(p,"CallExpression")}if(this.type===s.backQuote)return p.tag=t,p.quasi=this.parseTemplate({isTagged:!0}),p.typeArguments=l,this.finishNode(p,"TaggedTemplateExpression");return p.expression=t,p.typeArguments=l,this.finishNode(p,"TSInstantiationExpression")}}if(n&&this.type===s.parenL)this.$q=!0;return super.parseSubscript(t,e,r,i,n,a,h)}$2k(t,e,r){let i=this.startNodeAt(t,e);if(i.typeParameters=this.$7(),this.expect(s.parenL),i.params=this.parseBindingList(s.parenR,!1,!0),this.type===s.colon)i.returnType=this.$4(!0);if(this.type!==s.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(i,i.params,!0,r)}parseDynamicImport(t){if(this.next(),t.source=this.parseMaybeAssign(),this.eat(s.comma)&&this.type!==s.parenR)t.arguments=[this.parseExpression()];return this.expect(s.parenR),this.finishNode(t,"ImportExpression")}parseNew(){let t=super.parseNew();if(t.callee?.type!=="TSInstantiationExpression")return t;let e=this.startNodeAt(t.start,t.loc?.start);return e.callee=t.callee.expression,e.typeArguments=t.callee.typeArguments,e.arguments=t.arguments,this.finishNodeAt(e,"NewExpression",t.end,t.loc?.end)}parseExprOp(t,e,r,i,n){if(s._in.binop>i&&this.type===s.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let a=this.value==="satisfies",h=this.startNodeAt(e,r);return h.expression=t,h.typeAnnotation=this.$9(()=>{if(this.next(),!a&&this.type===s._const){let o=this.startNode();return o.typeName=this.parseIdent(!0),this.finishNode(o,"TSTypeReference")}return this.$0()}),this.finishNode(h,a?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(h,e,r,i,n)}return super.parseExprOp(t,e,r,i,n)}parseGetterSetter(t){t.kind=t.key.name,super.parseGetterSetter(t)}parsePropertyValue(t,e,r,i,n,a,h,o){if(!e&&this.$1()){if(this.$o=this.$7(),this.type!==s.parenL)this.unexpected();t.kind="init"}return super.parsePropertyValue(t,e,r,i,n,a,h,o)}}return k});
|
|
2
|
-
export{
|
|
1
|
+
import{A}from"./shared-as9can03.js";var x=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,F=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),q=new Set("public private protected readonly declare abstract override static accessor".split(" ")),O=new Set("public private protected readonly override".split(" ")),K=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),V=new Set("var let const function class interface enum".split(" ")),L=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),C=1,H=32,U=256,j=0,z=1,d=2,G=3,Q=4,N=6,w=7,D=256,g=1024,W=8|g,Y=d|D,I=1,X=2,P=40,J=41,Z=44,_=46,v=58,f=61,R=60,y=123,tt=91,S=42,et=35,b=34,E=39,st=SyntaxError("speculative parse failed"),T=A((m)=>{let{tokTypes:s,keywordTypes:M,isIdentifierChar:B,isIdentifierStart:c}=m.acorn,u=new m.acorn.TokenType("@");class k extends m{inType=!1;$5=!1;$6=!1;$8=null;$o=null;$p=!1;$q=!1;$i=null;$b=[[]];$r=0;$12=0;constructor(t,e,r){super(t,e,r);let i=this.options.onComment;if(typeof i==="function")this.options.onComment=(n,a,h,o,l,p)=>{if(h<this.$12)return;this.$12=o,i.call(this,n,a,h,o,l,p)}}getTokenFromCode(t){if(t===64)return++this.pos,this.finishToken(u);return super.getTokenFromCode(t)}readToken_lt_gt(t){if(this.inType)return this.finishOp(s.relational,1);return super.readToken_lt_gt(t)}$9(t){let e=this.inType;this.inType=!0;let r=t();if(this.inType=e,!e&&this.type===s.relational)this.pos=this.start,this.nextToken();return r}$1(){return this.type===s.relational&&this.value==="<"}$k(){if(this.type===s.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(s.relational,"<");return this.$1()}$c(){return this.type===s.relational&&this.value===">"}$s(){return this.type===s.prefix&&this.value==="!"}hasPrecedingLineBreak(){return this.$13(this.lastTokEnd,this.start)}$13(t,e){for(let r=t;r<e;r++){let i=this.input.charCodeAt(r);if(i===10||i===13||i===8232||i===8233)return!0}return!1}$d(t=this.pos){return x.lastIndex=t,x.exec(this.input),x.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let t=this.$d(),e=t;while(e<this.input.length&&B(this.input.charCodeAt(e)))e++;return this.input.slice(t,e)}$a(){return!this.$13(this.pos,this.$d())}$14(){return this.$a()&&c(this.$2())&&!Object.hasOwn(M,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$5:this.$5,$6:this.$6,$8:this.$8,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(t){this.pos=t.pos,this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,this.startLoc=t.startLoc,this.endLoc=t.endLoc,this.lastTokStart=t.lastTokStart,this.lastTokEnd=t.lastTokEnd,this.lastTokStartLoc=t.lastTokStartLoc,this.lastTokEndLoc=t.lastTokEndLoc,this.curLine=t.curLine,this.lineStart=t.lineStart,this.context=t.context,this.exprAllowed=t.exprAllowed,this.containsEsc=t.containsEsc,this.inType=t.inType,this.$5=t.$5,this.$6=t.$6,this.$8=t.$8,this.scopeStack.length=t.scopes,this.privateNameStack.length=t.privateNames,this.labels=t.labels,this.labels.length=t.labelCount,this.strict=t.strict,this.yieldPos=t.yieldPos,this.awaitPos=t.awaitPos,this.awaitIdentPos=t.awaitIdentPos,this.potentialArrowAt=t.potentialArrowAt,this.potentialArrowInForAwait=t.potentialArrowInForAwait}raise(t,e){if(this.$r>0)throw st;return super.raise(t,e)}$1y(t,e){try{super.raise(t,e)}catch(r){if(r instanceof SyntaxError)r.$1z=!0;throw r}throw Error("unreachable")}$f(t,e=!1){let r=this.$15();this.$r++;try{let i=t();if(e||i===void 0)this.$16(r);return i}catch(i){if(!(i instanceof SyntaxError)||!e&&i.$1z)throw i;this.$16(r);return}finally{this.$r--}}$t(t){return this.$f(t,!0)===!0}$17(t){if(t.end=this.lastTokEnd,this.options.locations)t.loc.end=this.lastTokEndLoc}$l(t,e){if(t.start=e.start,this.options.locations)t.loc.start=e.loc.start}$4(t=!1){let e=this.startNode();return e.typeAnnotation=this.$9(()=>(this.next(),t?this.$20():this.$0())),this.finishNode(e,"TSTypeAnnotation")}$g(t,e){if(e&&this.eat(s.question))t.optional=!0,this.$17(t);if(this.type===s.colon)t.typeAnnotation=this.$4(),this.$17(t);return t}$20(){if(this.type!==s.name&&this.type!==s._this)return this.$0();if(this.isContextual("asserts")&&this.$a()&&c(this.$2())){let t=this.startNode();if(this.next(),t.parameterName=this.type===s._this?this.$u():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$v(t,!0);return t.asserts=!0,t.typeAnnotation=null,this.finishNode(t,"TSTypePredicate")}if(this.$3()==="is"&&this.$a()){let t=this.startNode();return t.parameterName=this.type===s._this?this.$u():this.parseIdent(!0),this.$v(t,!1)}return this.$0()}$v(t,e){this.next();let r=this.startNode();return r.typeAnnotation=this.$0(),t.typeAnnotation=this.finishNode(r,"TSTypeAnnotation"),t.asserts=e,this.finishNode(t,"TSTypePredicate")}$u(){let t=this.startNode();return this.next(),this.finishNode(t,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let t=this.$0();if(this.type!==s.eof)this.unexpected();return t}$0(){let t=this.$18();if(this.$5||this.type!==s._extends||this.hasPrecedingLineBreak())return t;let e=this.startNodeAt(t.start,t.loc?.start);return this.next(),e.checkType=t,e.extendsType=this.$h(!0,()=>this.$18()),this.expect(s.question),e.trueType=this.$h(!1,()=>this.$0()),this.expect(s.colon),e.falseType=this.$h(!1,()=>this.$0()),this.finishNode(e,"TSConditionalType")}$h(t,e){let r=this.$5;this.$5=t;let i=e();return this.$5=r,i}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===s._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",s.bitwiseOR,()=>this.$1a("TSIntersectionType",s.bitwiseAND,()=>this.$1b()))}$19(t){let e=this.startNode();if(t==="TSConstructorType"){if(e.abstract=this.isContextual("abstract"),e.abstract)this.next();this.next()}return this.$h(!1,()=>this.$m(e,s.arrow)),this.finishNode(e,t)}$m(t,e){if(this.$1())t.typeParameters=this.$7();if(this.expect(s.parenL),t.parameters=this.parseBindingList(s.parenR,!1,!0),this.type===e)t.typeAnnotation=this.$4(!0);else if(e===s.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==s.parenL)return!1;return this.$t(()=>{if(this.next(),this.type===s.parenR||this.type===s.ellipsis)return!0;if(this.type===s.name||this.type===s._this)this.next();else if(this.type===s.braceL||this.type===s.bracketL)this.parseBindingAtom();else return!1;let t=this.type;if(t===s.colon||t===s.comma||t===s.question||t===s.eq)return!0;if(t!==s.parenR)return!1;return this.next(),this.type===s.arrow})}$1a(t,e,r){let i=this.startNode(),n=this.eat(e),a=[];do a.push(r());while(this.eat(e));if(a.length===1&&!n)return a[0];return i.types=a,this.finishNode(i,t)}$1b(){if(this.type===s.name&&!this.containsEsc){let t=this.value;if(t==="keyof"||t==="unique"||t==="readonly"){let e=this.startNode();return this.next(),e.operator=t,e.typeAnnotation=this.$1b(),this.finishNode(e,"TSTypeOperator")}if(t==="infer"){let e=this.startNode();this.next();let r=this.startNode();r.name=this.$w();let i=this.$f(()=>this.$22());if(i)r.constraint=i;return e.typeParameter=this.finishNode(r,"TSTypeParameter"),this.finishNode(e,"TSInferType")}}return this.$h(!1,()=>this.$23())}$22(){if(!this.eat(s._extends))return;let t=this.$h(!0,()=>this.$0());if(this.$5||this.type!==s.question)return t;return}$w(){if(this.type!==s.name&&!this.type.keyword)this.unexpected();let t=this.type===s.name?this.value:this.type.keyword;return this.next(),t}$23(){let t=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(s.bracketL)){let e=this.startNodeAt(t.start,t.loc?.start);if(this.eat(s.bracketR))e.elementType=t,t=this.finishNode(e,"TSArrayType");else e.objectType=t,e.indexType=this.$0(),this.expect(s.bracketR),t=this.finishNode(e,"TSIndexedAccessType")}return t}$24(){switch(this.type){case s.name:case s._void:case s._null:{let t=F.get(this.value);if(t&&(this.type!==s.name||!this.containsEsc&&this.$2()!==_)){let e=this.startNode();return this.next(),this.finishNode(e,t)}return this.$1c()}case s.string:case s.num:case s._true:case s._false:{let t=this.startNode();return t.literal=this.parseExprAtom(),this.finishNode(t,"TSLiteralType")}case s.plusMin:{if(this.value!=="-")break;let t=this.startNode(),e=this.startNode();if(this.next(),this.type!==s.num)this.unexpected();return e.operator="-",e.prefix=!0,e.argument=this.parseExprAtom(),t.literal=this.finishNode(e,"UnaryExpression"),this.finishNode(t,"TSLiteralType")}case s.backQuote:return this.$25();case s._this:{let t=this.$u();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let e=this.startNodeAt(t.start,t.loc?.start);return e.parameterName=t,this.$v(e,!1)}return t}case s._typeof:return this.$26();case s._import:return this.$1d();case s.braceL:return this.$27()?this.$28():this.$29();case s.bracketL:return this.$2a();case s.parenL:{let t=this.startNode();return this.next(),t.typeAnnotation=this.$0(),this.expect(s.parenR),this.finishNode(t,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let t=this.startNode();if(t.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())t.typeArguments=this.$e();return this.finishNode(t,"TSTypeReference")}$j(){let t=this.parseIdent(!0);while(this.eat(s.dot)){let e=this.startNodeAt(t.start,t.loc?.start);e.left=t,e.right=this.parseIdent(!0),t=this.finishNode(e,"TSQualifiedName")}return t}$26(){let t=this.startNode();if(this.next(),t.exprName=this.type===s._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())t.typeArguments=this.$e();return this.finishNode(t,"TSTypeQuery")}$1d(){let t=this.startNode();if(this.next(),t.argument=this.$1e(),this.eat(s.dot))t.qualifier=this.$j();if(this.$1())t.typeArguments=this.$e();return this.finishNode(t,"TSImportType")}$x(){if(this.type!==s.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(s.parenL);let t=this.$x();return this.expect(s.parenR),t}$25(){let t=this.startNode(),e=this.startNode();this.next(),e.expressions=[];let r=this.parseTemplateElement({isTagged:!1});e.quasis=[r];while(!r.tail){if(this.type===s.eof)this.raise(this.pos,"Unterminated template literal");this.expect(s.dollarBraceL),e.expressions.push(this.$0()),this.expect(s.braceR),r=this.parseTemplateElement({isTagged:!1}),e.quasis.push(r)}return this.next(),t.literal=this.finishNode(e,"TemplateLiteral"),this.finishNode(t,"TSLiteralType")}$27(){return this.$t(()=>{if(this.next(),this.type===s.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==s.bracketL)return!1;if(this.next(),this.type!==s.name)return!1;return this.next(),this.type===s._in})}$28(){let t=this.startNode();if(this.expect(s.braceL),this.type===s.plusMin)t.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))t.readonly=!0;this.expect(s.bracketL);let e=this.startNode();if(e.name=this.$w(),this.expect(s._in),e.constraint=this.$0(),t.typeParameter=this.finishNode(e,"TSTypeParameter"),t.nameType=this.eatContextual("as")?this.$0():null,this.expect(s.bracketR),this.type===s.plusMin)t.optional=this.value,this.next(),this.expect(s.question);else if(this.eat(s.question))t.optional=!0;if(this.eat(s.colon))t.typeAnnotation=this.$0();return this.semicolon(),this.expect(s.braceR),this.finishNode(t,"TSMappedType")}$29(){let t=this.startNode();return t.members=this.$1f(),this.finishNode(t,"TSTypeLiteral")}$1f(){this.expect(s.braceL);let t=[];while(!this.eat(s.braceR))t.push(this.$2b());return t}$2b(){let t=this.startNode(),e="TSPropertySignature",r=this.type===s._new?this.$2():-1;if(this.type===s.parenL||this.$1())e="TSCallSignatureDeclaration",this.$m(t,s.colon);else if(r===P||r===R)e="TSConstructSignatureDeclaration",this.next(),this.$m(t,s.colon);else{let i=this.type===s._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$n(!0))this.next(),t.readonly=!0;if(this.type===s.bracketL&&this.$1g())return this.$1h(t);let n="method";if(i)t.key=i;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$n(!1))n=this.value,this.next();this.parsePropertyName(t)}if(this.eat(s.question))t.optional=!0;if(this.type===s.parenL||this.$1()){if(e="TSMethodSignature",n!=="method")t.kind=n;this.$m(t,s.colon),t.kind=n}else if(this.type===s.colon)t.typeAnnotation=this.$4()}return this.$1i(),this.finishNode(t,e)}$1i(){if(!this.eat(s.comma))this.semicolon()}$1g(){return this.$t(()=>{if(this.next(),this.type!==s.name)return!1;return this.next(),this.type===s.colon})}$1h(t){if(this.expect(s.bracketL),t.parameters=[this.$g(this.parseIdent(),!1)],this.expect(s.bracketR),this.type===s.colon)t.typeAnnotation=this.$4();return this.$1i(),this.finishNode(t,"TSIndexSignature")}$2a(){let t=this.startNode();this.expect(s.bracketL),t.elementTypes=[];while(!this.eat(s.bracketR))if(t.elementTypes.push(this.$2c()),this.type!==s.bracketR)this.expect(s.comma);return this.finishNode(t,"TSTupleType")}$2c(){let t=this.start,e=this.startLoc,r=this.eat(s.ellipsis),i;if((this.type===s.name||this.type.keyword)&&this.$2d()){let n=this.startNode();n.label=this.parseIdent(!0),n.optional=this.eat(s.question),this.expect(s.colon),n.elementType=this.$0(),i=this.finishNode(n,"TSNamedTupleMember")}else if(i=this.$0(),this.eat(s.question)){let n=this.startNodeAt(i.start,i.loc?.start);n.typeAnnotation=i,i=this.finishNode(n,"TSOptionalType")}if(r){let n=this.startNodeAt(t,e);n.typeAnnotation=i,i=this.finishNode(n,"TSRestType")}return i}$2d(){let t=this.$d();if(this.input.charCodeAt(t)===63)t=this.$d(t+1);return this.input.charCodeAt(t)===v}$7(){return this.$9(()=>{let t=this.startNode();this.next(),t.params=[];while(!this.$c()){let e=this.startNode();while((this.type===s._const||this.type===s._in||this.isContextual("out"))&&c(this.$2()))e[this.value]=!0,this.next();if(e.name=this.$w(),this.eat(s._extends))e.constraint=this.$0();if(this.eat(s.eq))e.default=this.$0();if(t.params.push(this.finishNode(e,"TSTypeParameter")),!this.$c()){if(this.expect(s.comma),this.$c())t.extra={trailingComma:this.lastTokStart}}}if(this.next(),t.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(t,"TSTypeParameterDeclaration")})}$e(){return this.$9(()=>{let t=this.startNode();this.next(),t.params=[];while(!this.$c())if(t.params.push(this.$0()),!this.$c())this.expect(s.comma);if(t.params.length===0)this.unexpected();return this.next(),this.finishNode(t,"TSTypeParameterInstantiation")})}$1j(){let t=[];do{let e=this.startNode();if(e.expression=this.$j(),this.$1())e.typeParameters=this.$e();t.push(this.finishNode(e,"TSExpressionWithTypeArguments"))}while(this.eat(s.comma));return t}$1k(t=!1){if(this.type!==s.name||this.containsEsc){if(this.type===s._const&&this.$3()==="enum")return this.$y(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(t);return this.$1l(this.startNode(),this.value)}$2e(t){switch(t){case"interface":case"type":case"namespace":return this.$14();case"enum":return c(this.$2());case"abstract":return this.$a()&&this.$3()==="class";case"module":{let e=this.$2();return this.$a()&&(e===b||e===E||c(e))}case"declare":return this.$a()&&K.has(this.$3());case"global":return this.$a()&&this.$2()===y}return!1}$1l(t,e){switch(e){case"interface":return this.$1m(t);case"type":return this.$2g(t);case"enum":return this.$y(t);case"abstract":return this.$1n(t,!0);case"global":return t.global=!0,t.id=this.parseIdent(),t.body=this.$z(),this.finishNode(t,"TSModuleDeclaration")}return this.$2h(t)}$2f(t){let e=this.$6;this.$6=!0;let r=this.startNode();this.next();let i=this.value;if(i==="const"&&this.$3()==="enum")r.const=!0;if(!t&&V.has(i))r.declare=!0;let n;if(r.const)n=this.$y(r);else if(i==="var"||i==="let"||i==="const")n=this.parseVarStatement(r,i,!0);else if(i==="function")this.next(),n=this.parseFunction(r,I,!1,!1);else if(i==="class")n=this.parseClass(r,!0);else n=this.$1l(r,i);return n.declare=!0,this.$6=e,n}$1n(t,e){return this.next(),t.abstract=!0,this.parseClass(t,e)}$1m(t){if(this.next(),t.id=this.parseIdent(),this.checkLValSimple(t.id,w),this.$1())t.typeParameters=this.$7();return this.$9(()=>{if(this.eat(s._extends))t.extends=this.$1j();let e=this.startNode();e.body=this.$1f(),t.body=this.finishNode(e,"TSInterfaceBody")}),this.finishNode(t,"TSInterfaceDeclaration")}$2g(t){if(this.next(),t.id=this.parseIdent(),this.checkLValSimple(t.id,N),this.$1())t.typeParameters=this.$7();return t.typeAnnotation=this.$9(()=>(this.expect(s.eq),this.$0())),this.semicolon(),this.finishNode(t,"TSTypeAliasDeclaration")}$y(t){if(this.type===s._const)t.const=!0,this.next();this.next(),t.id=this.parseIdent(),this.checkLValSimple(t.id,Y),this.expect(s.braceL),t.members=[];while(!this.eat(s.braceR)){let e=this.startNode();if(e.id=this.type===s.string?this.parseExprAtom():this.parseIdent(!0),this.eat(s.eq))e.initializer=this.parseMaybeAssign();if(t.members.push(this.finishNode(e,"TSEnumMember")),this.type!==s.braceR)this.expect(s.comma)}return this.finishNode(t,"TSEnumDeclaration")}$2h(t){if(this.next(),this.type===s.string){if(t.id=this.parseExprAtom(),this.type===s.braceL)t.body=this.$z();else this.semicolon();return this.finishNode(t,"TSModuleDeclaration")}return t.id=this.parseIdent(),this.checkLValSimple(t.id,W),this.$1o(t)}$1o(t){if(this.eat(s.dot)){let e=this.startNode();e.id=this.parseIdent(),t.body=this.$1o(e)}else t.body=this.$z();return this.finishNode(t,"TSModuleDeclaration")}$z(){this.enterScope(U);let t=this.startNode();this.enterScope(0),this.expect(s.braceL),t.body=[];while(!this.eat(s.braceR))t.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(t,"TSModuleBlock")}$1p(t,e){if(t.isExport=e,t.id=this.parseIdent(),this.checkLValSimple(t.id,d),this.expect(s.eq),this.isContextual("require")&&this.$2()===P){let r=this.startNode();this.next(),r.expression=this.$1e(),t.moduleReference=this.finishNode(r,"TSExternalModuleReference")}else t.moduleReference=this.$j();return this.semicolon(),this.finishNode(t,"TSImportEqualsDeclaration")}$2i(){let t=this.$d();if(this.input.charCodeAt(t)!==f)return!1;let e=this.input.charCodeAt(t+1);return e!==f&&e!==62}parseStatement(t,e,r){if(this.type===u)this.$1q(!0);let i=this.$1k();if(i)return i;return super.parseStatement(t,e,r)}parseVarStatement(t,e,r){return super.parseVarStatement(t,e,r||this.$6)}parseVarId(t,e){if(super.parseVarId(t,e),t.id.type==="Identifier"&&this.$s()&&!this.hasPrecedingLineBreak())this.next(),t.definite=!0;this.$g(t.id,!1)}parseCatchClauseParam(){let t=this.$g(this.parseBindingAtom(),!1),e=t.type==="Identifier";return this.enterScope(e?H:0),this.checkLValPattern(t,e?Q:d),this.expect(s.parenR),t}parseImport(t){if(this.next(),t.importKind="value",this.type===s.string)t.specifiers=[],t.source=this.parseExprAtom();else{if(this.isContextual("type")){let e=this.$2();if(e===y||e===S||c(e)&&this.$3()!=="from")t.importKind="type",this.next()}if(this.type===s.name&&this.$2i())return this.$1p(t,!1);t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.$x()}return this.$1r(t),this.semicolon(),this.finishNode(t,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=s._with;return this.type===s._with?super.parseWithClause():void 0}$1r(t){let e=this.parseWithClause();if(e)t.attributes=e}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(t){return this.$1s("exportKind",()=>super.parseExportSpecifier(t))}$1s(t,e){let r=this.isContextual("type")?this.$2():-1;if(r===b||r===E||c(r)&&this.$3()!=="as"){let n=this.startNode();this.next();let a=e();return this.$l(a,n),a[t]="type",a}let i=e();return i[t]="value",i}parseExport(t,e){if(this.next(),this.eat(s._import)){if(t.importKind="value",this.isContextual("type")&&c(this.$2())&&this.$3()!=="from")t.importKind="type",this.next();return this.$1p(t,!0)}if(this.eat(s.eq))return t.expression=this.parseExpression(),this.semicolon(),this.finishNode(t,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),t.id=this.parseIdent(),this.semicolon(),this.finishNode(t,"TSNamespaceExportDeclaration");if(t.exportKind="value",this.isContextual("type")){let n=this.$2();if(n===y||n===S)t.exportKind="type",this.next()}if(this.eat(s.star))return this.parseExportAllDeclaration(t,e);if(this.eat(s._default)){if(this.isContextual("interface")&&this.$14())t.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")t.declaration=this.$1n(this.startNode(),"nullableID");else t.declaration=this.parseExportDefaultDeclaration();return this.finishNode(t,"ExportDefaultDeclaration")}let r=this.isContextual("declare"),i=this.$1k(!0);if(i||this.shouldParseExportStatement()){if(t.declaration=i??this.parseStatement(null),r||t.declaration.type==="TSInterfaceDeclaration"||t.declaration.type==="TSTypeAliasDeclaration")t.exportKind="type";return t.specifiers=[],t.source=null,this.finishNode(t,"ExportNamedDeclaration")}if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))t.source=this.$x(),this.$1r(t);else{for(let n of t.specifiers)if(this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal")this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.");t.source=null}return this.semicolon(),this.finishNode(t,"ExportNamedDeclaration")}parseFunction(t,e,r,i,n){let a=e&I;if(a)this.$i=t;super.parseFunction(t,e,r,i,n),this.$i=null;let h=!t.body;if(h)t.type="TSDeclareFunction";if(a&&t.id){if(h){if(this.$6&&this.currentScope().flags&C)this.declareName(t.id.name,g,t.id.start);this.checkLValSimple(t.id,j)}else if(!(e&X)){let o=G;if(this.strict||t.generator||t.async)o=this.treatFunctionsAsVar?z:d;this.checkLValSimple(t.id,o)}}return t}parseFunctionParams(t){if(this.$1())t.typeParameters=this.$7();if(super.parseFunctionParams(t),this.type===s.colon)t.returnType=this.$4(!0)}parseFunctionBody(t,e,r,i){if(r&&this.type===s.colon)t.returnType=this.$4(!0);if(e||this.type===s.braceL){super.parseFunctionBody(t,e,r,i);return}this.semicolon(),this.exitScope()}parseMethod(t,e,r){let i=this.$o;this.$o=null;let n=super.parseMethod(t,e,r);if(!n.body)n.type="TSDeclareMethod";if(i)n.typeParameters=i;return n}parseBindingList(t,e,r,i){let n=i===!0||this.$p;return this.$p=!1,super.parseBindingList(t,e,r,n)}$n(t){if(!t&&!this.$a())return!1;let e=this.$2();return e===tt||e===y||e===S||e===_||e===et||e===b||e===E||e>=48&&e<=57||c(e)}parseAssignableListItem(t){let e=this.$10(),r=this.start,i=this.startLoc,n,a=!1,h=!1;if(t)while(this.type===s.name&&O.has(this.value)&&!this.containsEsc&&this.$n(!1)){if(this.value==="readonly")a=!0;else if(this.value==="override")h=!0;else n=this.value;this.next()}let o;if(this.type===s._this)o=this.startNode(),o.name="this",this.next(),this.finishNode(o,"Identifier");else o=this.parseBindingAtom();let l=this.type===s.eq?this.parseMaybeDefault(r,i,o):this.parseMaybeDefault(o.start,o.loc?.start,this.$g(o,!0));if(e.length>0)l.decorators=e;if(!n&&!a&&!h)return l;let p=this.startNodeAt(r,i);if(n)p.accessibility=n;if(a)p.readonly=!0;if(h)p.override=!0;return p.parameter=l,this.finishNode(p,"TSParameterProperty")}parseBindingListItem(t){if(t.type==="RestElement")this.$g(t,!0);return t}checkLValSimple(t,e,r){if(this.$i&&t===this.$i.id){this.$i=null;return}if(!e&&L.has(t.type)){this.checkLValSimple(t.expression,e,r);return}switch(t.type){case"TSParameterProperty":this.checkLValInnerPattern(t.parameter,e,r);return;case"Identifier":if(t.name==="this")return}super.checkLValSimple(t,e,r)}toAssignable(t,e,r){if(t&&!e&&L.has(t.type))return t;return super.toAssignable(t,e,r)}declareName(t,e,r){let i=this.currentScope();if(e&g){this.$1t(i,t),i.$1u??=[],i.$1u.push(t);return}if(e===N||e===w){if(i.$11??=[],e===N&&i.$11.includes(t))this.raise(r,`type '${t}' has already been declared.`);i.$11.push(t),this.$1t(i,t);return}if(e&D){if(i.$1v??=[],i.$1v.includes(t))return;super.declareName(t,d,r),i.$1v.push(t);return}super.declareName(t,e,r)}$1t(t,e){if(this.inModule&&t.flags&C)delete this.undefinedExports[e]}checkLocalExport(t){for(let e=this.scopeStack.length-1;e>=0;e--){let r=this.scopeStack[e];if(r.$11?.includes(t.name)||r.$1u?.includes(t.name))return}super.checkLocalExport(t)}checkExport(){}raiseRecoverable(t,e){if(e==="Duplicate constructor in the same class")return;super.raiseRecoverable(t,e)}$10(){let t=[];while(this.type===u)t.push(this.$1w());return t}$1q(t){let e=this.$b[this.$b.length-1];while(this.type===u)e.push(this.$1w());if(this.type===s._export){if(!t)this.unexpected()}else if(this.type!==s._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let t=this.startNode();this.next(),this.$b.push([]);let e=this.start,r=this.startLoc,i;if(this.type===s.parenL){if(this.next(),i=this.parseExpression(),this.expect(s.parenR),this.options.preserveParens){let a=this.startNodeAt(e,r);a.expression=i,i=this.finishNode(a,"ParenthesizedExpression")}}else{i=this.parseIdent(!1);while(this.eat(s.dot)){let a=this.startNodeAt(e,r);a.object=i,a.property=this.parseIdent(!0),a.computed=!1,i=this.finishNode(a,"MemberExpression")}}let n=this.$k()?this.$e():void 0;if(this.eat(s.parenL)){let a=this.startNodeAt(i.start,i.loc?.start);if(a.callee=i,a.arguments=this.parseExprList(s.parenR,!1,!1),n)a.typeArguments=n;i=this.finishNode(a,"CallExpression")}else if(n){let a=this.startNodeAt(i.start,i.loc?.start);a.expression=i,a.typeArguments=n,i=this.finishNode(a,"TSInstantiationExpression")}return t.expression=i,this.$b.pop(),this.finishNode(t,"Decorator")}shouldParseExportStatement(){return this.type===u||super.shouldParseExportStatement()}parseExprAtom(t,e,r){if(this.type===u)this.$1q(!1);return super.parseExprAtom(t,e,r)}parseProperty(t,e){if(t||this.type!==u)return super.parseProperty(t,e);let r=this.$10(),i=super.parseProperty(t,e);if(i.type==="SpreadElement")this.raise(i.start,"Decorators can't be used with SpreadElement");return i.decorators=r,i}parseClassId(t,e){let r=this.$b.length-1,i=this.$b[r];if(i.length>0)t.decorators=i,this.$l(t,i[0]),this.$b[r]=[];if(!this.isContextual("implements")||e===!0)super.parseClassId(t,e);if(this.$1())t.typeParameters=this.$7()}parseClassSuper(t){if(super.parseClassSuper(t),t.superClass&&this.$1())t.superTypeParameters=this.$e();if(this.eatContextual("implements"))t.implements=this.$9(()=>this.$1j())}parseClassElement(t){if(this.type===u){let h=this.$10();if(this.type===s.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let o=this.parseClassElement(t);return o.decorators=h,this.$l(o,h[0]),o}if(this.eat(s.semi))return null;let e=this.startNode();while(this.type===s.name&&q.has(this.value)&&!this.containsEsc&&this.$n(this.value==="static")){let h=this.value;if(this.next(),h==="static"&&this.type===s.braceL)return this.next(),this.parseClassStaticBlock(e),e;if(h==="public"||h==="private"||h==="protected")e.accessibility=h;else e[h]=!0}if(this.type===s.bracketL&&this.$1g())return this.$1h(e);e.static??=!1;let r="",i=!1,n=!1,a="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===s.star)&&!this.canInsertSemicolon())n=!0;else r="async";if(!r&&this.eat(s.star))i=!0;if(!r&&!n&&!i){let h=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())a=h;else r=h}if(r)e.computed=!1,e.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),e.key.name=r,this.finishNode(e.key,"Identifier");else this.parseClassElementName(e);if(this.eat(s.question))e.optional=!0;if(this.type===s.parenL||this.$1()||a!=="method"||i||n){let h=e.key,o=!e.static&&!e.computed&&(h.type==="Identifier"&&h.name==="constructor"||h.type==="Literal"&&h.value==="constructor");if(e.kind=o?"constructor":a,this.$1())e.typeParameters=this.$7();this.$p=o,this.parseClassMethod(e,i,n,o&&t)}else{if(!e.optional&&this.$s())this.next(),e.definite=!0;if(this.type===s.colon)e.typeAnnotation=this.$4();this.parseClassField(e)}return e}parseMaybeAssign(t,e,r){if(this.$k()){let i=this.$f(()=>{let n=this.$7(),a=super.parseMaybeAssign(t,e,r);if(a.type!=="ArrowFunctionExpression")return;return a.typeParameters=n,this.$l(a,n),a});if(i)return i}return super.parseMaybeAssign(t,e,r)}parseMaybeUnary(t,e,r,i){if(this.$k()){let n=this.startNode();return n.typeAnnotation=this.$9(()=>{this.next();let a=this.$0();if(!this.$c())this.unexpected();return this.next(),a}),n.expression=this.parseMaybeUnary(null,!1,!1,i),this.finishNode(n,"TSTypeAssertion")}return super.parseMaybeUnary(t,e,r,i)}parseMaybeConditional(t,e){let r=this.start,i=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.type===s.question&&!(n.type==="ArrowFunctionExpression"&&n.start===r)&&!this.$2j()){this.next();let a=this.startNodeAt(r,i);return a.test=n,a.consequent=this.parseMaybeAssign(),this.expect(s.colon),a.alternate=this.parseMaybeAssign(t),this.finishNode(a,"ConditionalExpression")}return n}$2j(){let t=this.$d(),e=this.input.charCodeAt(t);if(e===v||e===Z||e===J)return!0;return e===f&&this.input.charCodeAt(t+1)!==f}parseParenItem(t){return this.$g(t,!0)}$1x(){if(this.type!==s.colon)return!0;let t=this.$f(()=>{let e=this.$4(!0);return this.type===s.arrow&&!this.canInsertSemicolon()?e:void 0});if(!t)return!1;return this.$8=t,!0}shouldParseArrow(t){return this.$1x()&&super.shouldParseArrow(t)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(t,e,r,i){if(this.$8)t.returnType=this.$8,this.$8=null;return super.parseArrowExpression(t,e,r,i)}parseExprList(t,e,r,i){if(!this.$q)return super.parseExprList(t,e,r,i);this.$q=!1;let n=[],a=!0;while(!this.eat(t)){if(a)a=!1;else if(this.expect(s.comma),e&&this.afterTrailingComma(t))break;if(this.type===s.ellipsis){let h=this.parseSpread(i);if(this.eat(s.question))h.optional=!0;if(this.type===s.colon)h.typeAnnotation=this.$4();n.push(h)}else n.push(this.parseMaybeAssign(!1,i,this.parseParenItem))}return n}parseSubscript(t,e,r,i,n,a,h){if(this.$s()&&!this.hasPrecedingLineBreak()){let l=this.startNodeAt(e,r);return this.exprAllowed=!1,this.next(),l.expression=t,this.finishNode(l,"TSNonNullExpression")}if(n&&this.$1()){let l=this.$f(()=>this.$2k(e,r,h));if(l)return l}let o=this.type===s.questionDot&&this.$2()===R;if(this.$1()||o||this.type===s.bitShift&&this.value==="<<"){let l=this.$f(()=>{if(o)this.next();this.$k();let p=this.$e();if(this.type===s.parenL&&!i)return p;if(this.type===s.backQuote)return o?void 0:p;if(o)return;if(this.$c()||this.type===s.bitShift||this.type.startsExpr&&this.type!==s.parenL&&!this.hasPrecedingLineBreak())return;return p});if(l){let p=this.startNodeAt(e,r);if(this.type===s.parenL&&!i){if(this.next(),p.callee=t,p.arguments=this.parseExprList(s.parenR,!0,!1),p.typeArguments=l,o)t.optional=!0;if(o||a)p.optional=o;return this.finishNode(p,"CallExpression")}if(this.type===s.backQuote)return p.tag=t,p.quasi=this.parseTemplate({isTagged:!0}),p.typeArguments=l,this.finishNode(p,"TaggedTemplateExpression");return p.expression=t,p.typeArguments=l,this.finishNode(p,"TSInstantiationExpression")}}if(n&&this.type===s.parenL)this.$q=!0;return super.parseSubscript(t,e,r,i,n,a,h)}$2k(t,e,r){let i=this.startNodeAt(t,e);if(i.typeParameters=this.$7(),this.expect(s.parenL),i.params=this.parseBindingList(s.parenR,!1,!0),this.type===s.colon)i.returnType=this.$4(!0);if(this.type!==s.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(i,i.params,!0,r)}parseDynamicImport(t){if(this.next(),t.source=this.parseMaybeAssign(),this.eat(s.comma)&&this.type!==s.parenR)t.arguments=[this.parseExpression()];return this.expect(s.parenR),this.finishNode(t,"ImportExpression")}parseNew(){let t=super.parseNew();if(t.callee?.type!=="TSInstantiationExpression")return t;let e=this.startNodeAt(t.start,t.loc?.start);return e.callee=t.callee.expression,e.typeArguments=t.callee.typeArguments,e.arguments=t.arguments,this.finishNodeAt(e,"NewExpression",t.end,t.loc?.end)}parseExprOp(t,e,r,i,n){if(s._in.binop>i&&this.type===s.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let a=this.value==="satisfies",h=this.startNodeAt(e,r);return h.expression=t,h.typeAnnotation=this.$9(()=>{if(this.next(),!a&&this.type===s._const){let o=this.startNode();return o.typeName=this.parseIdent(!0),this.finishNode(o,"TSTypeReference")}return this.$0()}),this.finishNode(h,a?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(h,e,r,i,n)}return super.parseExprOp(t,e,r,i,n)}parseGetterSetter(t){t.kind=t.key.name,super.parseGetterSetter(t)}parsePropertyValue(t,e,r,i,n,a,h,o){if(!e&&this.$1()){if(this.$o=this.$7(),this.type!==s.parenL)this.unexpected();t.kind="init"}return super.parsePropertyValue(t,e,r,i,n,a,h,o)}}return k});
|
|
2
|
+
export{T};
|
package/typescript.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-as9can03.js";import"./shared-pyjcz2f8.js";import"./shared-yr6e6h72.js";import{s}from"./shared-mwp38arc.js";import{Oe}from"./shared-pt7hcxxy.js";var t=Oe(s);export{t as typescript};
|