ts-morph.d.ts 497 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145
  1. import { errors, StandardizedFilePath, ts } from "@ts-morph/common";
  2. /** Holds the compiler options. */
  3. export declare class CompilerOptionsContainer extends SettingsContainer<ts.CompilerOptions> {
  4. constructor(defaultSettings?: ts.CompilerOptions);
  5. /**
  6. * Sets one or all of the compiler options.
  7. *
  8. * WARNING: Setting the compiler options will cause a complete reparse of all the source files.
  9. * @param settings - Compiler options to set.
  10. */
  11. set(settings: Partial<ts.CompilerOptions>): void;
  12. /** Gets the encoding from the compiler options or returns utf-8. */
  13. getEncoding(): string;
  14. }
  15. /** Represents a file system that can be interacted with. */
  16. export interface FileSystemHost {
  17. /** Gets if this file system is case sensitive. */
  18. isCaseSensitive(): boolean;
  19. /** Asynchronously deletes the specified file or directory. */
  20. delete(path: string): Promise<void>;
  21. /** Synchronously deletes the specified file or directory */
  22. deleteSync(path: string): void;
  23. /**
  24. * Reads all the child directories and files.
  25. * @remarks Implementers should have this return the full file path.
  26. */
  27. readDirSync(dirPath: string): RuntimeDirEntry[];
  28. /** Asynchronously reads a file at the specified path. */
  29. readFile(filePath: string, encoding?: string): Promise<string>;
  30. /** Synchronously reads a file at the specified path. */
  31. readFileSync(filePath: string, encoding?: string): string;
  32. /** Asynchronously writes a file to the file system. */
  33. writeFile(filePath: string, fileText: string): Promise<void>;
  34. /** Synchronously writes a file to the file system. */
  35. writeFileSync(filePath: string, fileText: string): void;
  36. /** Asynchronously creates a directory at the specified path. */
  37. mkdir(dirPath: string): Promise<void>;
  38. /** Synchronously creates a directory at the specified path. */
  39. mkdirSync(dirPath: string): void;
  40. /** Asynchronously moves a file or directory. */
  41. move(srcPath: string, destPath: string): Promise<void>;
  42. /** Synchronously moves a file or directory. */
  43. moveSync(srcPath: string, destPath: string): void;
  44. /** Asynchronously copies a file or directory. */
  45. copy(srcPath: string, destPath: string): Promise<void>;
  46. /** Synchronously copies a file or directory. */
  47. copySync(srcPath: string, destPath: string): void;
  48. /**
  49. * Asynchronously checks if a file exists.
  50. * @remarks Implementers should throw an `errors.FileNotFoundError` when it does not exist.
  51. */
  52. fileExists(filePath: string): Promise<boolean>;
  53. /**
  54. * Synchronously checks if a file exists.
  55. * @remarks Implementers should throw an `errors.FileNotFoundError` when it does not exist.
  56. */
  57. fileExistsSync(filePath: string): boolean;
  58. /** Asynchronously checks if a directory exists. */
  59. directoryExists(dirPath: string): Promise<boolean>;
  60. /** Synchronously checks if a directory exists. */
  61. directoryExistsSync(dirPath: string): boolean;
  62. /** See https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options */
  63. realpathSync(path: string): string;
  64. /** Gets the current directory of the environment. */
  65. getCurrentDirectory(): string;
  66. /** Uses pattern matching to find files or directories. */
  67. glob(patterns: ReadonlyArray<string>): Promise<string[]>;
  68. /** Synchronously uses pattern matching to find files or directories. */
  69. globSync(patterns: ReadonlyArray<string>): string[];
  70. }
  71. /** An implementation of a file system that exists in memory only. */
  72. export declare class InMemoryFileSystemHost implements FileSystemHost {
  73. #private;
  74. /** Constructor. */
  75. constructor();
  76. /** @inheritdoc */
  77. isCaseSensitive(): boolean;
  78. /** @inheritdoc */
  79. delete(path: string): Promise<void>;
  80. /** @inheritdoc */
  81. deleteSync(path: string): void;
  82. /** @inheritdoc */
  83. readDirSync(dirPath: string): RuntimeDirEntry[];
  84. /** @inheritdoc */
  85. readFile(filePath: string, encoding?: string): Promise<string>;
  86. /** @inheritdoc */
  87. readFileSync(filePath: string, encoding?: string): string;
  88. /** @inheritdoc */
  89. writeFile(filePath: string, fileText: string): Promise<void>;
  90. /** @inheritdoc */
  91. writeFileSync(filePath: string, fileText: string): void;
  92. /** @inheritdoc */
  93. mkdir(dirPath: string): Promise<void>;
  94. /** @inheritdoc */
  95. mkdirSync(dirPath: string): void;
  96. /** @inheritdoc */
  97. move(srcPath: string, destPath: string): Promise<void>;
  98. /** @inheritdoc */
  99. moveSync(srcPath: string, destPath: string): void;
  100. /** @inheritdoc */
  101. copy(srcPath: string, destPath: string): Promise<void>;
  102. /** @inheritdoc */
  103. copySync(srcPath: string, destPath: string): void;
  104. /** @inheritdoc */
  105. fileExists(filePath: string): Promise<boolean>;
  106. /** @inheritdoc */
  107. fileExistsSync(filePath: string): boolean;
  108. /** @inheritdoc */
  109. directoryExists(dirPath: string): Promise<boolean>;
  110. /** @inheritdoc */
  111. directoryExistsSync(dirPath: string): boolean;
  112. /** @inheritdoc */
  113. realpathSync(path: string): string;
  114. /** @inheritdoc */
  115. getCurrentDirectory(): string;
  116. /** @inheritdoc */
  117. glob(patterns: ReadonlyArray<string>): Promise<string[]>;
  118. /** @inheritdoc */
  119. globSync(patterns: ReadonlyArray<string>): string[];
  120. }
  121. /** Host for implementing custom module and/or type reference directive resolution. */
  122. export interface ResolutionHost {
  123. resolveModuleNames?: ts.LanguageServiceHost["resolveModuleNames"];
  124. getResolvedModuleWithFailedLookupLocationsFromCache?: ts.LanguageServiceHost["getResolvedModuleWithFailedLookupLocationsFromCache"];
  125. resolveTypeReferenceDirectives?: ts.LanguageServiceHost["resolveTypeReferenceDirectives"];
  126. }
  127. /**
  128. * Factory used to create a resolution host.
  129. * @remarks The compiler options are retrieved via a function in order to get the project's current compiler options.
  130. */
  131. export type ResolutionHostFactory = (moduleResolutionHost: ts.ModuleResolutionHost, getCompilerOptions: () => ts.CompilerOptions) => ResolutionHost;
  132. /** Collection of reusable resolution hosts. */
  133. export declare const ResolutionHosts: {
  134. deno: ResolutionHostFactory;
  135. };
  136. export interface RuntimeDirEntry {
  137. name: string;
  138. isFile: boolean;
  139. isDirectory: boolean;
  140. isSymlink: boolean;
  141. }
  142. export declare abstract class SettingsContainer<T extends object> {
  143. #private;
  144. protected _settings: T;
  145. /**
  146. * Constructor.
  147. * @param defaultSettings - The settings to use by default.
  148. */
  149. constructor(defaultSettings: T);
  150. /** Resets the settings to the default. */
  151. reset(): void;
  152. /** Gets a copy of the settings as an object. */
  153. get(): T;
  154. /**
  155. * Sets one or all of the settings.
  156. * @param settings - Settings to set.
  157. */
  158. set(settings: Partial<T>): void;
  159. /**
  160. * Subscribe to modifications in the settings container.
  161. * @param action - Action to execute when the settings change.
  162. */
  163. onModified(action: () => void): void;
  164. }
  165. declare const ArgumentError: typeof errors.ArgumentError;
  166. declare const ArgumentNullOrWhitespaceError: typeof errors.ArgumentNullOrWhitespaceError;
  167. declare const ArgumentOutOfRangeError: typeof errors.ArgumentOutOfRangeError;
  168. declare const ArgumentTypeError: typeof errors.ArgumentTypeError;
  169. declare const BaseError: typeof errors.BaseError;
  170. declare const DirectoryNotFoundError: typeof errors.DirectoryNotFoundError;
  171. declare const FileNotFoundError: typeof errors.FileNotFoundError;
  172. declare const InvalidOperationError: typeof errors.InvalidOperationError;
  173. declare const NotImplementedError: typeof errors.NotImplementedError;
  174. declare const NotSupportedError: typeof errors.NotSupportedError;
  175. declare const PathNotFoundError: typeof errors.PathNotFoundError;
  176. export declare class Directory {
  177. #private;
  178. private constructor();
  179. /**
  180. * Checks if this directory is an ancestor of the provided directory.
  181. * @param possibleDescendant - Directory or source file that's a possible descendant.
  182. */
  183. isAncestorOf(possibleDescendant: Directory | SourceFile): boolean;
  184. /**
  185. * Checks if this directory is a descendant of the provided directory.
  186. * @param possibleAncestor - Directory or source file that's a possible ancestor.
  187. */
  188. isDescendantOf(possibleAncestor: Directory): boolean;
  189. /** Gets the path to the directory. */
  190. getPath(): StandardizedFilePath;
  191. /** Gets the directory path's base name. */
  192. getBaseName(): string;
  193. /** Gets the parent directory or throws if it doesn't exist or was never added to the project. */
  194. getParentOrThrow(message?: string | (() => string)): Directory;
  195. /** Gets the parent directory if it exists and was added to the project. */
  196. getParent(): Directory | undefined;
  197. /**
  198. * Gets a child directory with the specified path or throws if not found.
  199. * @param path - Relative path from this directory or absolute path.
  200. */
  201. getDirectoryOrThrow(path: string): Directory;
  202. /**
  203. * Gets a child directory by the specified condition or throws if not found.
  204. * @param condition - Condition to check the directory with.
  205. */
  206. getDirectoryOrThrow(condition: (directory: Directory) => boolean): Directory;
  207. /**
  208. * Gets a directory with the specified path or undefined if not found.
  209. * @param path - Relative path from this directory or absolute path.
  210. */
  211. getDirectory(path: string): Directory | undefined;
  212. /**
  213. * Gets a child directory by the specified condition or undefined if not found.
  214. * @param condition - Condition to check the directory with.
  215. */
  216. getDirectory(condition: (directory: Directory) => boolean): Directory | undefined;
  217. /**
  218. * Gets a child source file with the specified path or throws if not found.
  219. * @param path - Relative or absolute path to the file.
  220. */
  221. getSourceFileOrThrow(path: string): SourceFile;
  222. /**
  223. * Gets a child source file by the specified condition or throws if not found.
  224. * @param condition - Condition to check the source file with.
  225. */
  226. getSourceFileOrThrow(condition: (sourceFile: SourceFile) => boolean): SourceFile;
  227. /**
  228. * Gets a child source file with the specified path or undefined if not found.
  229. * @param path - Relative or absolute path to the file.
  230. */
  231. getSourceFile(path: string): SourceFile | undefined;
  232. /**
  233. * Gets a child source file by the specified condition or undefined if not found.
  234. * @param condition - Condition to check the source file with.
  235. */
  236. getSourceFile(condition: (sourceFile: SourceFile) => boolean): SourceFile | undefined;
  237. /** Gets the child directories. */
  238. getDirectories(): Directory[];
  239. /** Gets the source files within this directory. */
  240. getSourceFiles(): SourceFile[];
  241. /**
  242. * Gets all the source files added to the project relative to the directory that match a pattern.
  243. * @param globPattern - Glob pattern for filtering out the source files.
  244. */
  245. getSourceFiles(globPattern: string): SourceFile[];
  246. /**
  247. * Gets all the source files added to the project relative to the directory that match the provided patterns.
  248. * @param globPatterns - Glob patterns for filtering out the source files.
  249. */
  250. getSourceFiles(globPatterns: ReadonlyArray<string>): SourceFile[];
  251. /** Gets the source files in the current directory and all the descendant directories. */
  252. getDescendantSourceFiles(): SourceFile[];
  253. /** Gets the descendant directories. */
  254. getDescendantDirectories(): Directory[];
  255. /**
  256. * Add source files based on file globs.
  257. * @param fileGlobs - File glob or globs to add files based on.
  258. * @returns The matched source files.
  259. */
  260. addSourceFilesAtPaths(fileGlobs: string | ReadonlyArray<string>): SourceFile[];
  261. /**
  262. * Adds an existing directory from the relative path or directory name, or returns undefined if it doesn't exist.
  263. *
  264. * Will return the directory if it was already added.
  265. * @param relativeOrAbsoluteDirPath - Directory name or path to the directory that should be added.
  266. * @param options - Options.
  267. */
  268. addDirectoryAtPathIfExists(relativeOrAbsoluteDirPath: string, options?: DirectoryAddOptions): Directory | undefined;
  269. /**
  270. * Adds an existing directory from the relative path or directory name, or throws if it doesn't exist.
  271. *
  272. * Will return the directory if it was already added.
  273. * @param relativeOrAbsoluteDirPath - Directory name or path to the directory that should be added.
  274. * @throws DirectoryNotFoundError if the directory does not exist.
  275. */
  276. addDirectoryAtPath(relativeOrAbsoluteDirPath: string, options?: DirectoryAddOptions): Directory;
  277. /**
  278. * Creates a directory if it doesn't exist.
  279. * @param relativeOrAbsoluteDirPath - Relative or absolute path to the directory that should be created.
  280. */
  281. createDirectory(relativeOrAbsoluteDirPath: string): Directory;
  282. /**
  283. * Creates a source file, relative to this directory.
  284. *
  285. * Note: The file will not be created and saved to the file system until .save() is called on the source file.
  286. * @param relativeFilePath - Relative file path of the source file to create.
  287. * @param sourceFileText - Text, structure, or writer function to create the source file text with.
  288. * @param options - Options.
  289. * @throws - InvalidOperationError if a source file already exists at the provided file name.
  290. */
  291. createSourceFile(relativeFilePath: string, sourceFileText?: string | OptionalKind<SourceFileStructure> | WriterFunction, options?: SourceFileCreateOptions): SourceFile;
  292. /**
  293. * Adds an existing source file, relative to this directory, or returns undefined.
  294. *
  295. * Will return the source file if it was already added.
  296. * @param relativeFilePath - Relative file path to add.
  297. */
  298. addSourceFileAtPathIfExists(relativeFilePath: string): SourceFile | undefined;
  299. /**
  300. * Adds an existing source file, relative to this directory, or throws if it doesn't exist.
  301. *
  302. * Will return the source file if it was already added.
  303. * @param relativeFilePath - Relative file path to add.
  304. * @throws FileNotFoundError when the file doesn't exist.
  305. */
  306. addSourceFileAtPath(relativeFilePath: string): SourceFile;
  307. /**
  308. * Emits the files in the directory.
  309. * @param options - Options for emitting.
  310. */
  311. emit(options?: {
  312. emitOnlyDtsFiles?: boolean;
  313. outDir?: string;
  314. declarationDir?: string;
  315. }): Promise<DirectoryEmitResult>;
  316. /**
  317. * Emits the files in the directory synchronously.
  318. *
  319. * Remarks: This might be very slow compared to the asynchronous version if there are a lot of files.
  320. * @param options - Options for emitting.
  321. */
  322. emitSync(options?: {
  323. emitOnlyDtsFiles?: boolean;
  324. outDir?: string;
  325. declarationDir?: string;
  326. }): DirectoryEmitResult;
  327. /**
  328. * Copies the directory to a subdirectory of the specified directory.
  329. * @param dirPathOrDirectory Directory path or directory object to copy the directory to.
  330. * @param options Options for copying.
  331. * @returns The new copied directory.
  332. */
  333. copyToDirectory(dirPathOrDirectory: string | Directory, options?: DirectoryCopyOptions): Directory;
  334. /**
  335. * Copies the directory to a new directory.
  336. * @param relativeOrAbsolutePath - The relative or absolute path to the new directory.
  337. * @param options - Options.
  338. * @returns The directory the copy was made to.
  339. */
  340. copy(relativeOrAbsolutePath: string, options?: DirectoryCopyOptions): Directory;
  341. /**
  342. * Immediately copies the directory to the specified path asynchronously.
  343. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path.
  344. * @param options - Options for moving the directory.
  345. * @remarks If includeTrackedFiles is true, then it will execute the pending operations in the current directory.
  346. */
  347. copyImmediately(relativeOrAbsolutePath: string, options?: DirectoryCopyOptions): Promise<Directory>;
  348. /**
  349. * Immediately copies the directory to the specified path synchronously.
  350. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path.
  351. * @param options - Options for moving the directory.
  352. * @remarks If includeTrackedFiles is true, then it will execute the pending operations in the current directory.
  353. */
  354. copyImmediatelySync(relativeOrAbsolutePath: string, options?: DirectoryCopyOptions): Directory;
  355. /**
  356. * Moves the directory to a subdirectory of the specified directory.
  357. * @param dirPathOrDirectory Directory path or directory object to move the directory to.
  358. * @param options Options for moving.
  359. */
  360. moveToDirectory(dirPathOrDirectory: string | Directory, options?: DirectoryMoveOptions): this;
  361. /**
  362. * Moves the directory to a new path.
  363. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path.
  364. * @param options - Options for moving the directory.
  365. */
  366. move(relativeOrAbsolutePath: string, options?: DirectoryMoveOptions): this;
  367. /**
  368. * Immediately moves the directory to a new path asynchronously.
  369. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path.
  370. * @param options - Options for moving the directory.
  371. */
  372. moveImmediately(relativeOrAbsolutePath: string, options?: DirectoryMoveOptions): Promise<this>;
  373. /**
  374. * Immediately moves the directory to a new path synchronously.
  375. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path.
  376. * @param options - Options for moving the directory.
  377. */
  378. moveImmediatelySync(relativeOrAbsolutePath: string, options?: DirectoryMoveOptions): this;
  379. /**
  380. * Recreates the directory.
  381. * @remarks This will delete all the descendant source files and directories in memory and queue a delete & mkdir to the file system.
  382. */
  383. clear(): void;
  384. /**
  385. * Asynchronously recreates the directory.
  386. * @remarks This will delete all the descendant source files and directories in memory and push a delete & mkdir to the file system.
  387. */
  388. clearImmediately(): Promise<void>;
  389. /**
  390. * Synchronously recreates the directory.
  391. * @remarks This will delete all the descendant source files and directories in memory and push a delete & mkdir to the file system.
  392. */
  393. clearImmediatelySync(): void;
  394. /**
  395. * Queues a deletion of the directory to the file system.
  396. *
  397. * The directory will be deleted when calling ast.save(). If you wish to delete the file immediately, then use deleteImmediately().
  398. */
  399. delete(): void;
  400. /** Asyncronously deletes the directory and all its descendants from the file system. */
  401. deleteImmediately(): Promise<void>;
  402. /** Synchronously deletes the directory and all its descendants from the file system. */
  403. deleteImmediatelySync(): void;
  404. /**
  405. * Forgets the directory and all its descendants from the Project.
  406. *
  407. * Note: Does not delete the directory from the file system.
  408. */
  409. forget(): void;
  410. /** Asynchronously saves the directory and all the unsaved source files to the disk. */
  411. save(): Promise<void>;
  412. /** Synchronously saves the directory and all the unsaved source files to the disk. */
  413. saveSync(): void;
  414. /**
  415. * Gets the relative path to the specified path.
  416. * @param fileOrDirPath - The file or directory path.
  417. */
  418. getRelativePathTo(fileOrDirPath: string): string;
  419. /**
  420. * Gets the relative path to another source file.
  421. * @param sourceFile - Source file.
  422. */
  423. getRelativePathTo(sourceFile: SourceFile): string;
  424. /**
  425. * Gets the relative path to another directory.
  426. * @param directory - Directory.
  427. */
  428. getRelativePathTo(directory: Directory): string;
  429. /**
  430. * Gets the relative path to the specified file path as a module specifier.
  431. * @param filePath - File path.
  432. * @remarks To get to a directory, provide `path/to/directory/index.ts`.
  433. */
  434. getRelativePathAsModuleSpecifierTo(filePath: string): string;
  435. /**
  436. * Gets the relative path to the specified source file as a module specifier.
  437. * @param sourceFile - Source file.
  438. */
  439. getRelativePathAsModuleSpecifierTo(sourceFile: SourceFile): string;
  440. /**
  441. * Gets the relative path to the specified directory as a module specifier.
  442. * @param directory - Directory.
  443. */
  444. getRelativePathAsModuleSpecifierTo(directory: Directory): string;
  445. /** Gets the project. */
  446. getProject(): Project;
  447. /** Gets if the directory was forgotten. */
  448. wasForgotten(): boolean;
  449. }
  450. export interface DirectoryAddOptions {
  451. /**
  452. * Whether to also recursively add all the directory's descendant directories.
  453. * @remarks Defaults to false.
  454. */
  455. recursive?: boolean;
  456. }
  457. export interface DirectoryCopyOptions extends SourceFileCopyOptions {
  458. /**
  459. * Includes all the files in the directory and sub-directory when copying.
  460. * @remarks - Defaults to true.
  461. */
  462. includeUntrackedFiles?: boolean;
  463. }
  464. export declare class DirectoryEmitResult {
  465. #private;
  466. private constructor();
  467. /** Gets a collections of skipped file paths. */
  468. getSkippedFilePaths(): StandardizedFilePath[];
  469. /** Gets the output file paths. */
  470. getOutputFilePaths(): StandardizedFilePath[];
  471. }
  472. export interface DirectoryMoveOptions extends SourceFileMoveOptions {
  473. }
  474. /** Occurs when there is a problem doing a manipulation. */
  475. export declare class ManipulationError extends errors.InvalidOperationError {
  476. readonly filePath: string;
  477. readonly oldText: string;
  478. readonly newText: string;
  479. constructor(filePath: string, oldText: string, newText: string, errorMessage: string);
  480. }
  481. /** Project that holds source files. */
  482. export declare class Project {
  483. #private;
  484. /**
  485. * Initializes a new instance.
  486. * @param options - Optional options.
  487. */
  488. constructor(options?: ProjectOptions);
  489. /** Gets the manipulation settings. */
  490. get manipulationSettings(): ManipulationSettingsContainer;
  491. /** Gets the compiler options for modification. */
  492. get compilerOptions(): CompilerOptionsContainer;
  493. /**
  494. * Adds the source files the project's source files depend on to the project.
  495. * @returns The added source files.
  496. * @remarks * This should be done after source files are added to the project, preferably once to
  497. * avoid doing more work than necessary.
  498. * * This is done by default when creating a Project and providing a tsconfig.json and
  499. * not specifying to not add the source files.
  500. */
  501. resolveSourceFileDependencies(): SourceFile[];
  502. /**
  503. * Adds an existing directory from the path or returns undefined if it doesn't exist.
  504. *
  505. * Will return the directory if it was already added.
  506. * @param dirPath - Path to add the directory at.
  507. * @param options - Options.
  508. */
  509. addDirectoryAtPathIfExists(dirPath: string, options?: DirectoryAddOptions): Directory | undefined;
  510. /**
  511. * Adds an existing directory from the path or throws if it doesn't exist.
  512. *
  513. * Will return the directory if it was already added.
  514. * @param dirPath - Path to add the directory at.
  515. * @param options - Options.
  516. * @throws DirectoryNotFoundError when the directory does not exist.
  517. */
  518. addDirectoryAtPath(dirPath: string, options?: DirectoryAddOptions): Directory;
  519. /**
  520. * Creates a directory at the specified path.
  521. * @param dirPath - Path to create the directory at.
  522. */
  523. createDirectory(dirPath: string): Directory;
  524. /**
  525. * Gets a directory by the specified path or throws if it doesn't exist.
  526. * @param dirPath - Path to create the directory at.
  527. */
  528. getDirectoryOrThrow(dirPath: string, message?: string | (() => string)): Directory;
  529. /**
  530. * Gets a directory by the specified path or returns undefined if it doesn't exist.
  531. * @param dirPath - Directory path.
  532. */
  533. getDirectory(dirPath: string): Directory | undefined;
  534. /** Gets all the directories. */
  535. getDirectories(): Directory[];
  536. /** Gets the directories without a parent. */
  537. getRootDirectories(): Directory[];
  538. /**
  539. * Adds source files based on file globs.
  540. * @param fileGlobs - File glob or globs to add files based on.
  541. * @returns The matched source files.
  542. */
  543. addSourceFilesAtPaths(fileGlobs: string | ReadonlyArray<string>): SourceFile[];
  544. /**
  545. * Adds a source file from a file path if it exists or returns undefined.
  546. *
  547. * Will return the source file if it was already added.
  548. * @param filePath - File path to get the file from.
  549. */
  550. addSourceFileAtPathIfExists(filePath: string): SourceFile | undefined;
  551. /**
  552. * Adds an existing source file from a file path or throws if it doesn't exist.
  553. *
  554. * Will return the source file if it was already added.
  555. * @param filePath - File path to get the file from.
  556. * @throws FileNotFoundError when the file is not found.
  557. */
  558. addSourceFileAtPath(filePath: string): SourceFile;
  559. /**
  560. * Adds all the source files from the specified tsconfig.json.
  561. *
  562. * Note that this is done by default when specifying a tsconfig file in the constructor and not explicitly setting the
  563. * `skipAddingFilesFromTsConfig` option to `true`.
  564. * @param tsConfigFilePath - File path to the tsconfig.json file.
  565. */
  566. addSourceFilesFromTsConfig(tsConfigFilePath: string): SourceFile[];
  567. /**
  568. * Creates a source file at the specified file path with the specified text.
  569. *
  570. * Note: The file will not be created and saved to the file system until .save() is called on the source file.
  571. * @param filePath - File path of the source file.
  572. * @param sourceFileText - Text, structure, or writer function for the source file text.
  573. * @param options - Options.
  574. * @throws - InvalidOperationError if a source file already exists at the provided file path.
  575. */
  576. createSourceFile(filePath: string, sourceFileText?: string | OptionalKind<SourceFileStructure> | WriterFunction, options?: SourceFileCreateOptions): SourceFile;
  577. /**
  578. * Removes a source file from the project.
  579. * @param sourceFile - Source file to remove.
  580. * @returns True if removed.
  581. */
  582. removeSourceFile(sourceFile: SourceFile): boolean;
  583. /**
  584. * Gets a source file by a file name or file path. Throws an error if it doesn't exist.
  585. * @param fileNameOrPath - File name or path that the path could end with or equal.
  586. */
  587. getSourceFileOrThrow(fileNameOrPath: string): SourceFile;
  588. /**
  589. * Gets a source file by a search function. Throws an error if it doesn't exist.
  590. * @param searchFunction - Search function.
  591. */
  592. getSourceFileOrThrow(searchFunction: (file: SourceFile) => boolean): SourceFile;
  593. /**
  594. * Gets a source file by a file name or file path. Returns undefined if none exists.
  595. * @param fileNameOrPath - File name or path that the path could end with or equal.
  596. */
  597. getSourceFile(fileNameOrPath: string): SourceFile | undefined;
  598. /**
  599. * Gets a source file by a search function. Returns undefined if none exists.
  600. * @param searchFunction - Search function.
  601. */
  602. getSourceFile(searchFunction: (file: SourceFile) => boolean): SourceFile | undefined;
  603. /** Gets all the source files added to the project. */
  604. getSourceFiles(): SourceFile[];
  605. /**
  606. * Gets all the source files added to the project that match a pattern.
  607. * @param globPattern - Glob pattern for filtering out the source files.
  608. */
  609. getSourceFiles(globPattern: string): SourceFile[];
  610. /**
  611. * Gets all the source files added to the project that match the passed in patterns.
  612. * @param globPatterns - Glob patterns for filtering out the source files.
  613. */
  614. getSourceFiles(globPatterns: ReadonlyArray<string>): SourceFile[];
  615. /**
  616. * Gets the specified ambient module symbol or returns undefined if not found.
  617. * @param moduleName - The ambient module name with or without quotes.
  618. */
  619. getAmbientModule(moduleName: string): Symbol | undefined;
  620. /**
  621. * Gets the specified ambient module symbol or throws if not found.
  622. * @param moduleName - The ambient module name with or without quotes.
  623. */
  624. getAmbientModuleOrThrow(moduleName: string, message?: string | (() => string)): Symbol;
  625. /**
  626. * Gets the ambient module symbols (ex. modules in the
  627. * @types folder or node_modules).
  628. */
  629. getAmbientModules(): Symbol[];
  630. /** Saves all the unsaved source files to the file system and deletes all deleted files. */
  631. save(): Promise<void>;
  632. /**
  633. * Synchronously saves all the unsaved source files to the file system and deletes all deleted files.
  634. *
  635. * Remarks: This might be very slow compared to the asynchronous version if there are a lot of files.
  636. */
  637. saveSync(): void;
  638. /**
  639. * Enables logging to the console.
  640. * @param enabled - Enabled.
  641. */
  642. enableLogging(enabled?: boolean): void;
  643. /** Gets the pre-emit diagnostics. */
  644. getPreEmitDiagnostics(): Diagnostic[];
  645. /** Gets the language service. */
  646. getLanguageService(): LanguageService;
  647. /** Gets the program. */
  648. getProgram(): Program;
  649. /** Gets the type checker. */
  650. getTypeChecker(): TypeChecker;
  651. /** Gets the file system. */
  652. getFileSystem(): FileSystemHost;
  653. /**
  654. * Asynchronously emits all the source files to the file system as JavaScript files.
  655. * @param emitOptions - Optional emit options.
  656. */
  657. emit(emitOptions?: EmitOptions): Promise<EmitResult>;
  658. /**
  659. * Synchronously emits all the source files to the file system as JavaScript files.
  660. * @param emitOptions - Optional emit options.
  661. */
  662. emitSync(emitOptions?: EmitOptions): EmitResult;
  663. /**
  664. * Emits all the source files to memory.
  665. * @param emitOptions - Optional emit options.
  666. */
  667. emitToMemory(emitOptions?: EmitOptions): MemoryEmitResult;
  668. /** Gets the compiler options. */
  669. getCompilerOptions(): CompilerOptions;
  670. /** Gets the diagnostics found when parsing the tsconfig.json file provided in the project's constructor. */
  671. getConfigFileParsingDiagnostics(): Diagnostic[];
  672. /**
  673. * Creates a writer with the current manipulation settings.
  674. * @remarks Generally it's best to use a provided writer, but this may be useful in some scenarios.
  675. */
  676. createWriter(): CodeBlockWriter;
  677. /**
  678. * Forgets the nodes created in the scope of the passed in block.
  679. *
  680. * This is an advanced method that can be used to easily "forget" all the nodes created within the scope of the block.
  681. * @param block - Block of code to run. Use the `remember` callback or return a node to remember it.
  682. */
  683. forgetNodesCreatedInBlock<T = void>(block: (remember: (...node: Node[]) => void) => T): T;
  684. /**
  685. * Forgets the nodes created in the scope of the passed in block asynchronously.
  686. *
  687. * This is an advanced method that can be used to easily "forget" all the nodes created within the scope of the block.
  688. * @param block - Block of code to run. Use the `remember` callback or return a node to remember it.
  689. */
  690. forgetNodesCreatedInBlock<T = void>(block: (remember: (...node: Node[]) => void) => Promise<T>): Promise<T>;
  691. /**
  692. * Formats an array of diagnostics with their color and context into a string.
  693. * @param diagnostics - Diagnostics to get a string of.
  694. * @param options - Collection of options. For example, the new line character to use (defaults to the OS' new line character).
  695. */
  696. formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray<Diagnostic>, opts?: {
  697. newLineChar?: "\n" | "\r\n";
  698. }): string;
  699. /** Gets a ts.ModuleResolutionHost for the project. */
  700. getModuleResolutionHost(): ts.ModuleResolutionHost;
  701. }
  702. /** Options for creating a project. */
  703. export interface ProjectOptions {
  704. /** Compiler options */
  705. compilerOptions?: CompilerOptions;
  706. /** File path to the tsconfig.json file. */
  707. tsConfigFilePath?: string;
  708. /** Can be overriden by `tsConfigFilePath` or `compilerOptions`. */
  709. defaultCompilerOptions?: CompilerOptions;
  710. /**
  711. * Whether to skip adding the source files from the specified tsconfig.json.
  712. * @default false
  713. */
  714. skipAddingFilesFromTsConfig?: boolean;
  715. /**
  716. * Skip resolving file dependencies when providing a ts config file path and adding the files from tsconfig.
  717. * @default false
  718. */
  719. skipFileDependencyResolution?: boolean;
  720. /**
  721. * Skip loading the lib files. Unlike the compiler API, ts-morph does not load these
  722. * from the node_modules folder, but instead loads them from some other JS code
  723. * and uses a fake path for their existence. If you want to use a custom lib files
  724. * folder path, then provide one using the libFolderPath options.
  725. * @default false
  726. */
  727. skipLoadingLibFiles?: boolean;
  728. /** The folder to use for loading lib files. */
  729. libFolderPath?: string;
  730. /** Manipulation settings */
  731. manipulationSettings?: Partial<ManipulationSettings>;
  732. /**
  733. * Whether to use an in-memory file system.
  734. * @default false
  735. */
  736. useInMemoryFileSystem?: boolean;
  737. /**
  738. * Optional file system host. Useful for mocking access to the file system.
  739. * @remarks Consider using `useInMemoryFileSystem` instead.
  740. */
  741. fileSystem?: FileSystemHost;
  742. /** Creates a resolution host for specifying custom module and/or type reference directive resolution. */
  743. resolutionHost?: ResolutionHostFactory;
  744. }
  745. /** Options for creating a source file. */
  746. export interface SourceFileCreateOptions {
  747. /**
  748. * Whether a source file should be overwritten if it exists. Defaults to false.
  749. * @remarks When false, the method will throw when a file exists.
  750. */
  751. overwrite?: boolean;
  752. /** Specifies the script kind of the source file. */
  753. scriptKind?: ScriptKind;
  754. }
  755. export type Constructor<T> = new (...args: any[]) => T;
  756. export type InstanceOf<T> = T extends new (...args: any[]) => infer U ? U : never;
  757. export type WriterFunction = (writer: CodeBlockWriter) => void;
  758. /**
  759. * Creates a wrapped node from a compiler node.
  760. * @param node - Node to create a wrapped node from.
  761. * @param info - Info for creating the wrapped node.
  762. */
  763. export declare function createWrappedNode<T extends ts.Node = ts.Node>(node: T, opts?: CreateWrappedNodeOptions): CompilerNodeToWrappedType<T>;
  764. export interface CreateWrappedNodeOptions {
  765. /** Compiler options. */
  766. compilerOptions?: CompilerOptions;
  767. /** Optional source file of the node. Will make it not bother going up the tree to find the source file. */
  768. sourceFile?: ts.SourceFile;
  769. /** Type checker. */
  770. typeChecker?: ts.TypeChecker;
  771. }
  772. /**
  773. * Prints the provided node using the compiler's printer.
  774. * @param node - Compiler node.
  775. * @param options - Options.
  776. * @remarks If the node was not constructed with the compiler API factory methods and the node
  777. * does not have parents set, then use the other overload that accepts a source file.
  778. */
  779. export declare function printNode(node: ts.Node, options?: PrintNodeOptions): string;
  780. /**
  781. * Prints the provided node using the compiler's printer.
  782. * @param node - Compiler node.
  783. * @param sourceFile - Compiler source file.
  784. * @param options - Options.
  785. */
  786. export declare function printNode(node: ts.Node, sourceFile: ts.SourceFile, options?: PrintNodeOptions): string;
  787. /** Options for printing a node. */
  788. export interface PrintNodeOptions {
  789. /** Whether to remove comments or not. */
  790. removeComments?: boolean;
  791. /**
  792. * New line kind.
  793. *
  794. * Defaults to line feed.
  795. */
  796. newLineKind?: NewLineKind;
  797. /**
  798. * From the compiler api: "A value indicating the purpose of a node. This is primarily used to
  799. * distinguish between an `Identifier` used in an expression position, versus an
  800. * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you
  801. * should just pass `Unspecified`."
  802. *
  803. * Defaults to `Unspecified`.
  804. */
  805. emitHint?: EmitHint;
  806. /**
  807. * The script kind.
  808. *
  809. * @remarks This is only useful when passing in a compiler node that was constructed
  810. * with the compiler API factory methods.
  811. *
  812. * Defaults to TSX.
  813. */
  814. scriptKind?: ScriptKind;
  815. }
  816. export type SourceFileReferencingNodes = ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration | CallExpression;
  817. export interface CompilerOptionsFromTsConfigOptions {
  818. encoding?: string;
  819. fileSystem?: FileSystemHost;
  820. }
  821. export interface CompilerOptionsFromTsConfigResult {
  822. options: CompilerOptions;
  823. errors: Diagnostic[];
  824. }
  825. /**
  826. * Gets the compiler options from a specified tsconfig.json
  827. * @param filePath - File path to the tsconfig.json.
  828. * @param options - Options.
  829. */
  830. export declare function getCompilerOptionsFromTsConfig(filePath: string, options?: CompilerOptionsFromTsConfigOptions): CompilerOptionsFromTsConfigResult;
  831. /** Functions for writing code. */
  832. export declare class Writers {
  833. private constructor();
  834. /**
  835. * Gets a writer function for writing the provided object as an object literal expression.
  836. * @param obj - Object to write.
  837. */
  838. static object(obj: {
  839. [key: string]: WriterFunctionOrValue | undefined;
  840. }): WriterFunction;
  841. /** Gets a writer function for writing an object type. */
  842. static objectType(structure: TypeElementMemberedNodeStructure): WriterFunction;
  843. /** Gets a writer function for writing a union type (ex. `FirstType | SecondType`). */
  844. static unionType(firstType: WriterFunctionOrValue, secondType: WriterFunctionOrValue, ...additionalTypes: WriterFunctionOrValue[]): (writer: CodeBlockWriter) => void;
  845. /** Gets a writer function for writing an intersection type (ex. `FirstType & SecondType`). */
  846. static intersectionType(firstType: WriterFunctionOrValue, secondType: WriterFunctionOrValue, ...additionalTypes: WriterFunctionOrValue[]): (writer: CodeBlockWriter) => void;
  847. /** Gets a writer function for writing a type assertion (ex. `type as assertionType`). */
  848. static assertion(type: WriterFunctionOrValue, assertionType: WriterFunctionOrValue): (writer: CodeBlockWriter) => void;
  849. /**
  850. * Gets a writer function for writing a return statement returning the provided value (ex. `return value;`).
  851. * @param value - Value to be returned.
  852. */
  853. static returnStatement(value: WriterFunctionOrValue): WriterFunction;
  854. }
  855. export type WriterFunctionOrValue = string | number | WriterFunction;
  856. export type AssertionKey = Identifier | StringLiteral;
  857. export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier | NoSubstitutionTemplateLiteral | BigIntLiteral;
  858. export type ModuleName = Identifier | StringLiteral;
  859. export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
  860. export type ArrayBindingElement = BindingElement | OmittedExpression;
  861. export type BindingName = Identifier | BindingPattern;
  862. export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern;
  863. export type BooleanLiteral = TrueLiteral | FalseLiteral;
  864. export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement | InstanceofExpression;
  865. export type EntityNameExpression = Identifier | PropertyAccessExpression;
  866. export type DeclarationName = PropertyName | JsxAttributeName | StringLiteralLike | ElementAccessExpression | BindingPattern | EntityNameExpression;
  867. export type EntityName = Identifier | QualifiedName;
  868. export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment;
  869. export type JsxAttributeName = Identifier | JsxNamespacedName;
  870. export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute;
  871. export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement;
  872. export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess | JsxNamespacedName;
  873. export interface JsxTagNamePropertyAccess extends PropertyAccessExpression {
  874. getExpression(): Identifier | ThisExpression | JsxTagNamePropertyAccess;
  875. }
  876. export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration;
  877. export type CaseOrDefaultClause = CaseClause | DefaultClause;
  878. export type ModuleReference = EntityName | ExternalModuleReference;
  879. export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral;
  880. export type TypeElementTypes = PropertySignature | MethodSignature | ConstructSignatureDeclaration | CallSignatureDeclaration | IndexSignatureDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
  881. export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral;
  882. /**
  883. * Local target declarations.
  884. * @remarks This may be missing some types. Please open an issue if this returns a type not listed here.
  885. */
  886. export type LocalTargetDeclarations = SourceFile | ClassDeclaration | InterfaceDeclaration | EnumDeclaration | FunctionDeclaration | VariableDeclaration | TypeAliasDeclaration | ModuleDeclaration | ExportAssignment;
  887. /**
  888. * Declarations that can be exported from a module.
  889. * @remarks This may be missing some types. Please open an issue if this returns a type not listed here.
  890. */
  891. export type ExportedDeclarations = ClassDeclaration | InterfaceDeclaration | EnumDeclaration | FunctionDeclaration | VariableDeclaration | TypeAliasDeclaration | ModuleDeclaration | Expression | SourceFile;
  892. export declare function AmbientableNode<T extends Constructor<AmbientableNodeExtensionType>>(Base: T): Constructor<AmbientableNode> & T;
  893. export interface AmbientableNode {
  894. /** If the node has the declare keyword. */
  895. hasDeclareKeyword(): boolean;
  896. /** Gets the declare keyword or undefined if none exists. */
  897. getDeclareKeyword(): Node | undefined;
  898. /** Gets the declare keyword or throws if it doesn't exist. */
  899. getDeclareKeywordOrThrow(message?: string | (() => string)): Node;
  900. /** Gets if the node is ambient. */
  901. isAmbient(): boolean;
  902. /**
  903. * Sets if this node has a declare keyword.
  904. * @param value - To add the declare keyword or not.
  905. */
  906. setHasDeclareKeyword(value?: boolean): this;
  907. }
  908. type AmbientableNodeExtensionType = Node & ModifierableNode;
  909. export declare function ArgumentedNode<T extends Constructor<ArgumentedNodeExtensionType>>(Base: T): Constructor<ArgumentedNode> & T;
  910. export interface ArgumentedNode {
  911. /** Gets all the arguments of the node. */
  912. getArguments(): Node[];
  913. /**
  914. * Adds an argument.
  915. * @param argumentText - Argument text to add.
  916. */
  917. addArgument(argumentText: string | WriterFunction): Node;
  918. /**
  919. * Adds arguments.
  920. * @param argumentTexts - Argument texts to add.
  921. */
  922. addArguments(argumentTexts: ReadonlyArray<string | WriterFunction> | WriterFunction): Node[];
  923. /**
  924. * Inserts an argument.
  925. * @param index - Child index to insert at.
  926. * @param argumentText - Argument text to insert.
  927. */
  928. insertArgument(index: number, argumentText: string | WriterFunction): Node;
  929. /**
  930. * Inserts arguments.
  931. * @param index - Child index to insert at.
  932. * @param argumentTexts - Argument texts to insert.
  933. */
  934. insertArguments(index: number, argumentTexts: ReadonlyArray<string | WriterFunction> | WriterFunction): Node[];
  935. /**
  936. * Removes an argument.
  937. * @param arg - Argument to remove.
  938. */
  939. removeArgument(arg: Node): this;
  940. /**
  941. * Removes an argument.
  942. * @param index - Index to remove.
  943. */
  944. removeArgument(index: number): this;
  945. }
  946. type ArgumentedNodeExtensionType = Node<ts.Node & {
  947. arguments?: ts.NodeArray<ts.Node>;
  948. }>;
  949. export declare function AsyncableNode<T extends Constructor<AsyncableNodeExtensionType>>(Base: T): Constructor<AsyncableNode> & T;
  950. export interface AsyncableNode {
  951. /** If it's async. */
  952. isAsync(): boolean;
  953. /** Gets the async keyword or undefined if none exists. */
  954. getAsyncKeyword(): Node<ts.AsyncKeyword> | undefined;
  955. /** Gets the async keyword or throws if none exists. */
  956. getAsyncKeywordOrThrow(message?: string | (() => string)): Node<ts.AsyncKeyword>;
  957. /**
  958. * Sets if the node is async.
  959. * @param value - If it should be async or not.
  960. */
  961. setIsAsync(value: boolean): this;
  962. }
  963. type AsyncableNodeExtensionType = Node & ModifierableNode;
  964. export declare function AwaitableNode<T extends Constructor<AwaitableNodeExtensionType>>(Base: T): Constructor<AwaitableNode> & T;
  965. export interface AwaitableNode {
  966. /** If it's an awaited node. */
  967. isAwaited(): boolean;
  968. /** Gets the await token or undefined if none exists. */
  969. getAwaitKeyword(): Node<ts.AwaitKeyword> | undefined;
  970. /** Gets the await token or throws if none exists. */
  971. getAwaitKeywordOrThrow(message?: string | (() => string)): Node<ts.AwaitKeyword>;
  972. /**
  973. * Sets if the node is awaited.
  974. * @param value - If it should be awaited or not.
  975. */
  976. setIsAwaited(value: boolean): this;
  977. }
  978. type AwaitableNodeExtensionType = Node<ts.Node & {
  979. awaitModifier?: ts.AwaitKeyword;
  980. }>;
  981. export declare function BodiedNode<T extends Constructor<BodiedNodeExtensionType>>(Base: T): Constructor<BodiedNode> & T;
  982. export interface BodiedNode {
  983. /** Gets the body. */
  984. getBody(): Node;
  985. /**
  986. * Sets the body text.
  987. * @param textOrWriterFunction - Text or writer function to set as the body.
  988. */
  989. setBodyText(textOrWriterFunction: string | WriterFunction): this;
  990. /** Gets the body text without leading whitespace, leading indentation, or trailing whitespace. */
  991. getBodyText(): string;
  992. }
  993. type BodiedNodeExtensionType = Node<ts.Node & {
  994. body: ts.Node;
  995. }>;
  996. export declare function BodyableNode<T extends Constructor<BodyableNodeExtensionType>>(Base: T): Constructor<BodyableNode> & T;
  997. export interface BodyableNode {
  998. /** Gets the body or throws an error if it doesn't exist. */
  999. getBodyOrThrow(message?: string | (() => string)): Node;
  1000. /** Gets the body if it exists. */
  1001. getBody(): Node | undefined;
  1002. /** Gets the body text without leading whitespace, leading indentation, or trailing whitespace. Returns undefined if there is no body. */
  1003. getBodyText(): string | undefined;
  1004. /** Gets if the node has a body. */
  1005. hasBody(): boolean;
  1006. /**
  1007. * Sets the body text. A body is required to do this operation.
  1008. * @param textOrWriterFunction - Text or writer function to set as the body.
  1009. */
  1010. setBodyText(textOrWriterFunction: string | WriterFunction): this;
  1011. /** Adds a body if it doesn't exists. */
  1012. addBody(): this;
  1013. /** Removes the body if it exists. */
  1014. removeBody(): this;
  1015. }
  1016. type BodyableNodeExtensionType = Node<ts.Node & {
  1017. body?: ts.Node;
  1018. }>;
  1019. export declare function ChildOrderableNode<T extends Constructor<ChildOrderableNodeExtensionType>>(Base: T): Constructor<ChildOrderableNode> & T;
  1020. export interface ChildOrderableNode {
  1021. /** Sets the child order of the node within the parent. */
  1022. setOrder(order: number): this;
  1023. }
  1024. type ChildOrderableNodeExtensionType = Node;
  1025. export declare function DecoratableNode<T extends Constructor<DecoratableNodeExtensionType>>(Base: T): Constructor<DecoratableNode> & T;
  1026. export interface DecoratableNode {
  1027. /**
  1028. * Gets a decorator or undefined if it doesn't exist.
  1029. * @param name - Name of the parameter.
  1030. */
  1031. getDecorator(name: string): Decorator | undefined;
  1032. /**
  1033. * Gets a decorator or undefined if it doesn't exist.
  1034. * @param findFunction - Function to use to find the parameter.
  1035. */
  1036. getDecorator(findFunction: (declaration: Decorator) => boolean): Decorator | undefined;
  1037. /**
  1038. * Gets a decorator or throws if it doesn't exist.
  1039. * @param name - Name of the parameter.
  1040. */
  1041. getDecoratorOrThrow(name: string): Decorator;
  1042. /**
  1043. * Gets a decorator or throws if it doesn't exist.
  1044. * @param findFunction - Function to use to find the parameter.
  1045. */
  1046. getDecoratorOrThrow(findFunction: (declaration: Decorator) => boolean): Decorator;
  1047. /** Gets all the decorators of the node. */
  1048. getDecorators(): Decorator[];
  1049. /**
  1050. * Adds a decorator.
  1051. * @param structure - Structure of the decorator.
  1052. */
  1053. addDecorator(structure: OptionalKind<DecoratorStructure>): Decorator;
  1054. /**
  1055. * Adds decorators.
  1056. * @param structures - Structures of the decorators.
  1057. */
  1058. addDecorators(structures: ReadonlyArray<OptionalKind<DecoratorStructure>>): Decorator[];
  1059. /**
  1060. * Inserts a decorator.
  1061. * @param index - Child index to insert at. Specify a negative index to insert from the reverse.
  1062. * @param structure - Structure of the decorator.
  1063. */
  1064. insertDecorator(index: number, structure: OptionalKind<DecoratorStructure>): Decorator;
  1065. /**
  1066. * Insert decorators.
  1067. * @param index - Child index to insert at.
  1068. * @param structures - Structures to insert.
  1069. */
  1070. insertDecorators(index: number, structures: ReadonlyArray<OptionalKind<DecoratorStructure>>): Decorator[];
  1071. }
  1072. type DecoratableNodeExtensionType = Node<ts.Node> & ModifierableNode;
  1073. export declare function DotDotDotTokenableNode<T extends Constructor<DotDotDotTokenableNodeExtensionType>>(Base: T): Constructor<DotDotDotTokenableNode> & T;
  1074. export interface DotDotDotTokenableNode {
  1075. /** Gets the dot dot dot token (...) if it exists or returns undefined */
  1076. getDotDotDotToken(): Node<ts.DotDotDotToken> | undefined;
  1077. /** Gets the dot dot dot token (...) if it exists or throws if not. */
  1078. getDotDotDotTokenOrThrow(message?: string | (() => string)): Node<ts.DotDotDotToken>;
  1079. }
  1080. type DotDotDotTokenableNodeExtensionType = Node<ts.Node & {
  1081. dotDotDotToken?: ts.DotDotDotToken;
  1082. }>;
  1083. export declare function ExclamationTokenableNode<T extends Constructor<ExclamationTokenableNodeExtensionType>>(Base: T): Constructor<ExclamationTokenableNode> & T;
  1084. export interface ExclamationTokenableNode {
  1085. /** If it has a exclamation token. */
  1086. hasExclamationToken(): boolean;
  1087. /** Gets the exclamation token node or returns undefined if it doesn't exist. */
  1088. getExclamationTokenNode(): Node<ts.ExclamationToken> | undefined;
  1089. /** Gets the exclamation token node or throws. */
  1090. getExclamationTokenNodeOrThrow(message?: string | (() => string)): Node<ts.ExclamationToken>;
  1091. /**
  1092. * Sets if this node has a exclamation token.
  1093. * @param value - If it should have a exclamation token or not.
  1094. */
  1095. setHasExclamationToken(value: boolean): this;
  1096. }
  1097. type ExclamationTokenableNodeExtensionType = Node<ts.Node & {
  1098. exclamationToken?: ts.ExclamationToken;
  1099. }>;
  1100. export declare function ExportableNode<T extends Constructor<ExportableNodeExtensionType>>(Base: T): Constructor<ExportableNode> & T;
  1101. export interface ExportableNode extends ExportGetableNode {
  1102. /**
  1103. * Sets if this node is a default export of a file.
  1104. * @param value - If it should be a default export or not.
  1105. */
  1106. setIsDefaultExport(value: boolean): this;
  1107. /**
  1108. * Sets if the node is exported.
  1109. *
  1110. * Note: Will remove the default keyword if set.
  1111. * @param value - If it should be exported or not.
  1112. */
  1113. setIsExported(value: boolean): this;
  1114. }
  1115. type ExportableNodeExtensionType = Node & ModifierableNode;
  1116. export declare function ExportGetableNode<T extends Constructor<ExportGetableNodeExtensionType>>(Base: T): Constructor<ExportGetableNode> & T;
  1117. export interface ExportGetableNode {
  1118. /** If the node has the export keyword. */
  1119. hasExportKeyword(): boolean;
  1120. /** Gets the export keyword or undefined if none exists. */
  1121. getExportKeyword(): Node | undefined;
  1122. /** Gets the export keyword or throws if none exists. */
  1123. getExportKeywordOrThrow(message?: string | (() => string)): Node;
  1124. /** If the node has the default keyword. */
  1125. hasDefaultKeyword(): boolean;
  1126. /** Gets the default keyword or undefined if none exists. */
  1127. getDefaultKeyword(): Node | undefined;
  1128. /** Gets the default keyword or throws if none exists. */
  1129. getDefaultKeywordOrThrow(message?: string | (() => string)): Node;
  1130. /** Gets if the node is exported from a namespace, is a default export, or is a named export. */
  1131. isExported(): boolean;
  1132. /** Gets if this node is a default export of a file. */
  1133. isDefaultExport(): boolean;
  1134. /** Gets if this node is a named export of a file. */
  1135. isNamedExport(): boolean;
  1136. }
  1137. type ExportGetableNodeExtensionType = Node;
  1138. export declare function ExtendsClauseableNode<T extends Constructor<ExtendsClauseableNodeExtensionType>>(Base: T): Constructor<ExtendsClauseableNode> & T;
  1139. export interface ExtendsClauseableNode {
  1140. /** Gets the extends clauses. */
  1141. getExtends(): ExpressionWithTypeArguments[];
  1142. /**
  1143. * Adds multiple extends clauses.
  1144. * @param texts - Texts to add for the extends clause.
  1145. */
  1146. addExtends(texts: ReadonlyArray<string | WriterFunction> | WriterFunction): ExpressionWithTypeArguments[];
  1147. /**
  1148. * Adds an extends clause.
  1149. * @param text - Text to add for the extends clause.
  1150. */
  1151. addExtends(text: string): ExpressionWithTypeArguments;
  1152. /**
  1153. * Inserts multiple extends clauses.
  1154. * @param texts - Texts to insert for the extends clause.
  1155. */
  1156. insertExtends(index: number, texts: ReadonlyArray<string | WriterFunction> | WriterFunction): ExpressionWithTypeArguments[];
  1157. /**
  1158. * Inserts an extends clause.
  1159. * @param text - Text to insert for the extends clause.
  1160. */
  1161. insertExtends(index: number, text: string): ExpressionWithTypeArguments;
  1162. /**
  1163. * Removes the extends at the specified index.
  1164. * @param index - Index to remove.
  1165. */
  1166. removeExtends(index: number): this;
  1167. /**
  1168. * Removes the specified extends.
  1169. * @param extendsNode - Node of the extend to remove.
  1170. */
  1171. removeExtends(extendsNode: ExpressionWithTypeArguments): this;
  1172. }
  1173. type ExtendsClauseableNodeExtensionType = Node & HeritageClauseableNode;
  1174. export declare function GeneratorableNode<T extends Constructor<GeneratorableNodeExtensionType>>(Base: T): Constructor<GeneratorableNode> & T;
  1175. export interface GeneratorableNode {
  1176. /** If it's a generator function. */
  1177. isGenerator(): boolean;
  1178. /** Gets the asterisk token or undefined if none exists. */
  1179. getAsteriskToken(): Node<ts.AsteriskToken> | undefined;
  1180. /** Gets the asterisk token or throws if none exists. */
  1181. getAsteriskTokenOrThrow(message?: string | (() => string)): Node<ts.AsteriskToken>;
  1182. /**
  1183. * Sets if the node is a generator.
  1184. * @param value - If it should be a generator or not.
  1185. */
  1186. setIsGenerator(value: boolean): this;
  1187. }
  1188. type GeneratorableNodeExtensionType = Node<ts.Node & {
  1189. asteriskToken?: ts.AsteriskToken;
  1190. }>;
  1191. export declare function HeritageClauseableNode<T extends Constructor<HeritageClauseableNodeExtensionType>>(Base: T): Constructor<HeritageClauseableNode> & T;
  1192. export interface HeritageClauseableNode {
  1193. /** Gets the heritage clauses of the node. */
  1194. getHeritageClauses(): HeritageClause[];
  1195. /**
  1196. * Gets the heritage clause by kind.
  1197. * @kind - Kind of heritage clause.
  1198. */
  1199. getHeritageClauseByKind(kind: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword): HeritageClause | undefined;
  1200. /**
  1201. * Gets the heritage clause by kind or throws if it doesn't exist.
  1202. * @kind - Kind of heritage clause.
  1203. */
  1204. getHeritageClauseByKindOrThrow(kind: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword): HeritageClause;
  1205. }
  1206. type HeritageClauseableNodeExtensionType = Node<ts.Node & {
  1207. heritageClauses?: ts.NodeArray<ts.HeritageClause>;
  1208. }>;
  1209. export declare function ImplementsClauseableNode<T extends Constructor<ImplementsClauseableNodeExtensionType>>(Base: T): Constructor<ImplementsClauseableNode> & T;
  1210. export interface ImplementsClauseableNode {
  1211. /** Gets the implements clauses. */
  1212. getImplements(): ExpressionWithTypeArguments[];
  1213. /**
  1214. * Adds an implements clause.
  1215. * @param text - Text to add for the implements clause.
  1216. */
  1217. addImplements(text: string): ExpressionWithTypeArguments;
  1218. /**
  1219. * Adds multiple implements clauses.
  1220. * @param text - Texts to add for the implements clause.
  1221. */
  1222. addImplements(text: ReadonlyArray<string | WriterFunction> | WriterFunction): ExpressionWithTypeArguments[];
  1223. /**
  1224. * Inserts an implements clause.
  1225. * @param text - Text to insert for the implements clause.
  1226. */
  1227. insertImplements(index: number, texts: ReadonlyArray<string | WriterFunction> | WriterFunction): ExpressionWithTypeArguments[];
  1228. /**
  1229. * Inserts multiple implements clauses.
  1230. * @param text - Texts to insert for the implements clause.
  1231. */
  1232. insertImplements(index: number, text: string): ExpressionWithTypeArguments;
  1233. /**
  1234. * Removes the implements at the specified index.
  1235. * @param index - Index to remove.
  1236. */
  1237. removeImplements(index: number): this;
  1238. /**
  1239. * Removes the specified implements.
  1240. * @param implementsNode - Node of the implements to remove.
  1241. */
  1242. removeImplements(implementsNode: ExpressionWithTypeArguments): this;
  1243. }
  1244. type ImplementsClauseableNodeExtensionType = Node & HeritageClauseableNode;
  1245. export declare function InitializerExpressionableNode<T extends Constructor<InitializerExpressionableNodeExtensionType>>(Base: T): Constructor<InitializerExpressionableNode> & T;
  1246. export interface InitializerExpressionableNode extends InitializerExpressionGetableNode {
  1247. /** Removes the initializer. */
  1248. removeInitializer(): this;
  1249. /**
  1250. * Sets the initializer.
  1251. * @param text - Text or writer function to set for the initializer.
  1252. */
  1253. setInitializer(textOrWriterFunction: string | WriterFunction): this;
  1254. }
  1255. type InitializerExpressionableNodeExtensionType = Node<ts.Node & {
  1256. initializer?: ts.Expression;
  1257. }>;
  1258. export declare function InitializerExpressionGetableNode<T extends Constructor<InitializerExpressionGetableNodeExtensionType>>(Base: T): Constructor<InitializerExpressionGetableNode> & T;
  1259. export interface InitializerExpressionGetableNode {
  1260. /** Gets if node has an initializer. */
  1261. hasInitializer(): boolean;
  1262. /** Gets the initializer. */
  1263. getInitializer(): Expression | undefined;
  1264. /** Gets the initializer if it's a certain kind or throws. */
  1265. getInitializerIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind): KindToExpressionMappings[TKind];
  1266. /** Gets the initializer if it's a certain kind. */
  1267. getInitializerIfKind<TKind extends SyntaxKind>(kind: TKind): KindToExpressionMappings[TKind] | undefined;
  1268. /** Gets the initializer or throw. */
  1269. getInitializerOrThrow(message?: string | (() => string)): Expression;
  1270. }
  1271. type InitializerExpressionGetableNodeExtensionType = Node<ts.Node & {
  1272. initializer?: ts.Expression;
  1273. }>;
  1274. export declare function JSDocableNode<T extends Constructor<JSDocableNodeExtensionType>>(Base: T): Constructor<JSDocableNode> & T;
  1275. export interface JSDocableNode {
  1276. /** Gets the JS doc nodes. */
  1277. getJsDocs(): JSDoc[];
  1278. /**
  1279. * Adds a JS doc.
  1280. * @param structure - Structure to add.
  1281. */
  1282. addJsDoc(structure: OptionalKind<JSDocStructure> | string | WriterFunction): JSDoc;
  1283. /**
  1284. * Adds JS docs.
  1285. * @param structures - Structures to add.
  1286. */
  1287. addJsDocs(structures: ReadonlyArray<OptionalKind<JSDocStructure> | string | WriterFunction>): JSDoc[];
  1288. /**
  1289. * Inserts a JS doc.
  1290. * @param index - Child index to insert at.
  1291. * @param structure - Structure to insert.
  1292. */
  1293. insertJsDoc(index: number, structure: OptionalKind<JSDocStructure> | string | WriterFunction): JSDoc;
  1294. /**
  1295. * Inserts JS docs.
  1296. * @param index - Child index to insert at.
  1297. * @param structures - Structures to insert.
  1298. */
  1299. insertJsDocs(index: number, structures: ReadonlyArray<OptionalKind<JSDocStructure> | string | WriterFunction>): JSDoc[];
  1300. }
  1301. type JSDocableNodeExtensionType = Node<ts.Node & {
  1302. jsDoc?: ts.NodeArray<ts.JSDoc>;
  1303. }>;
  1304. export declare function LiteralLikeNode<T extends Constructor<LiteralLikeNodeExtensionType>>(Base: T): Constructor<LiteralLikeNode> & T;
  1305. export interface LiteralLikeNode {
  1306. /** Get text of the literal. */
  1307. getLiteralText(): string;
  1308. /** Gets if the literal is terminated. */
  1309. isTerminated(): boolean;
  1310. /** Gets if the literal has an extended unicode escape. */
  1311. hasExtendedUnicodeEscape(): boolean;
  1312. }
  1313. type LiteralLikeNodeExtensionType = Node<ts.LiteralLikeNode>;
  1314. export declare function ModifierableNode<T extends Constructor<ModifierableNodeExtensionType>>(Base: T): Constructor<ModifierableNode> & T;
  1315. export interface ModifierableNode {
  1316. /** Gets the node's modifiers. */
  1317. getModifiers(): Node<ts.Modifier>[];
  1318. /**
  1319. * Gets the first modifier of the specified syntax kind or throws if none found.
  1320. * @param kind - Syntax kind.
  1321. */
  1322. getFirstModifierByKindOrThrow<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind];
  1323. /**
  1324. * Gets the first modifier of the specified syntax kind or undefined if none found.
  1325. * @param kind - Syntax kind.
  1326. */
  1327. getFirstModifierByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  1328. /**
  1329. * Gets if it has the specified modifier.
  1330. * @param kind - Syntax kind to check for.
  1331. */
  1332. hasModifier(kind: SyntaxKind): boolean;
  1333. /**
  1334. * Gets if it has the specified modifier.
  1335. * @param text - Text to check for.
  1336. */
  1337. hasModifier(text: ModifierTexts): boolean;
  1338. /**
  1339. * Toggles a modifier.
  1340. * @param text - Text to toggle the modifier for.
  1341. * @param value - Optional toggling value.
  1342. */
  1343. toggleModifier(text: ModifierTexts, value?: boolean): this;
  1344. }
  1345. type ModifierableNodeExtensionType = Node;
  1346. export type ModifierTexts = "export" | "default" | "declare" | "abstract" | "public" | "protected" | "private" | "readonly" | "static" | "async" | "const" | "override" | "in" | "out" | "accessor";
  1347. export declare function ModuledNode<T extends Constructor<ModuledNodeExtensionType>>(Base: T): Constructor<ModuledNode> & T;
  1348. export interface ModuledNode {
  1349. /**
  1350. * Adds an import.
  1351. * @param structure - Structure that represents the import.
  1352. */
  1353. addImportDeclaration(structure: OptionalKind<ImportDeclarationStructure>): ImportDeclaration;
  1354. /**
  1355. * Adds imports.
  1356. * @param structures - Structures that represent the imports.
  1357. */
  1358. addImportDeclarations(structures: ReadonlyArray<OptionalKind<ImportDeclarationStructure>>): ImportDeclaration[];
  1359. /**
  1360. * Insert an import.
  1361. * @param index - Child index to insert at.
  1362. * @param structure - Structure that represents the import.
  1363. */
  1364. insertImportDeclaration(index: number, structure: OptionalKind<ImportDeclarationStructure>): ImportDeclaration;
  1365. /**
  1366. * Inserts imports.
  1367. * @param index - Child index to insert at.
  1368. * @param structures - Structures that represent the imports to insert.
  1369. */
  1370. insertImportDeclarations(index: number, structures: ReadonlyArray<OptionalKind<ImportDeclarationStructure>>): ImportDeclaration[];
  1371. /**
  1372. * Gets the first import declaration that matches a condition, or undefined if it doesn't exist.
  1373. * @param condition - Condition to get the import declaration by.
  1374. */
  1375. getImportDeclaration(condition: (importDeclaration: ImportDeclaration) => boolean): ImportDeclaration | undefined;
  1376. /**
  1377. * Gets the first import declaration that matches a module specifier, or undefined if it doesn't exist.
  1378. * @param module - Module specifier to get the import declaration by.
  1379. */
  1380. getImportDeclaration(moduleSpecifier: string): ImportDeclaration | undefined;
  1381. /**
  1382. * Gets the first import declaration that matches a condition, or throws if it doesn't exist.
  1383. * @param condition - Condition to get the import declaration by.
  1384. */
  1385. getImportDeclarationOrThrow(condition: (importDeclaration: ImportDeclaration) => boolean): ImportDeclaration;
  1386. /**
  1387. * Gets the first import declaration that matches a module specifier, or throws if it doesn't exist.
  1388. * @param module - Module specifier to get the import declaration by.
  1389. */
  1390. getImportDeclarationOrThrow(moduleSpecifier: string): ImportDeclaration;
  1391. /** Get the module's import declarations. */
  1392. getImportDeclarations(): ImportDeclaration[];
  1393. /**
  1394. * Add export declarations.
  1395. * @param structure - Structure that represents the export.
  1396. */
  1397. addExportDeclaration(structure: OptionalKind<ExportDeclarationStructure>): ExportDeclaration;
  1398. /**
  1399. * Add export declarations.
  1400. * @param structures - Structures that represent the exports.
  1401. */
  1402. addExportDeclarations(structures: ReadonlyArray<OptionalKind<ExportDeclarationStructure>>): ExportDeclaration[];
  1403. /**
  1404. * Insert an export declaration.
  1405. * @param index - Child index to insert at.
  1406. * @param structure - Structure that represents the export.
  1407. */
  1408. insertExportDeclaration(index: number, structure: OptionalKind<ExportDeclarationStructure>): ExportDeclaration;
  1409. /**
  1410. * Insert export declarations.
  1411. * @param index - Child index to insert at.
  1412. * @param structures - Structures that represent the exports to insert.
  1413. */
  1414. insertExportDeclarations(index: number, structures: ReadonlyArray<OptionalKind<ExportDeclarationStructure>>): ExportDeclaration[];
  1415. getExportDeclaration(condition: (exportDeclaration: ExportDeclaration) => boolean, message?: string | (() => string)): ExportDeclaration | undefined;
  1416. /**
  1417. * Gets the first export declaration that matches a module specifier, or undefined if it doesn't exist.
  1418. * @param module - Module specifier to get the export declaration by.
  1419. */
  1420. getExportDeclaration(moduleSpecifier: string): ExportDeclaration | undefined;
  1421. /**
  1422. * Gets the first export declaration that matches a condition, or throws if it doesn't exist.
  1423. * @param condition - Condition to get the export declaration by.
  1424. */
  1425. getExportDeclarationOrThrow(condition: (exportDeclaration: ExportDeclaration) => boolean, message?: string | (() => string)): ExportDeclaration;
  1426. /**
  1427. * Gets the first export declaration that matches a module specifier, or throws if it doesn't exist.
  1428. * @param module - Module specifier to get the export declaration by.
  1429. */
  1430. getExportDeclarationOrThrow(moduleSpecifier: string, message?: string | (() => string)): ExportDeclaration;
  1431. /** Get the export declarations. */
  1432. getExportDeclarations(): ExportDeclaration[];
  1433. /**
  1434. * Add export assignments.
  1435. * @param structure - Structure that represents the export.
  1436. */
  1437. addExportAssignment(structure: OptionalKind<ExportAssignmentStructure>): ExportAssignment;
  1438. /**
  1439. * Add export assignments.
  1440. * @param structures - Structures that represent the exports.
  1441. */
  1442. addExportAssignments(structures: ReadonlyArray<OptionalKind<ExportAssignmentStructure>>): ExportAssignment[];
  1443. /**
  1444. * Insert an export assignment.
  1445. * @param index - Child index to insert at.
  1446. * @param structure - Structure that represents the export.
  1447. */
  1448. insertExportAssignment(index: number, structure: OptionalKind<ExportAssignmentStructure>): ExportAssignment;
  1449. /**
  1450. * Insert export assignments into a file.
  1451. * @param index - Child index to insert at.
  1452. * @param structures - Structures that represent the exports to insert.
  1453. */
  1454. insertExportAssignments(index: number, structures: ReadonlyArray<OptionalKind<ExportAssignmentStructure>>): ExportAssignment[];
  1455. /**
  1456. * Gets the first export assignment that matches a condition, or undefined if it doesn't exist.
  1457. * @param condition - Condition to get the export assignment by.
  1458. */
  1459. getExportAssignment(condition: (exportAssignment: ExportAssignment) => boolean): ExportAssignment | undefined;
  1460. /**
  1461. * Gets the first export assignment that matches a condition, or throws if it doesn't exist.
  1462. * @param condition - Condition to get the export assignment by.
  1463. */
  1464. getExportAssignmentOrThrow(condition: (exportAssignment: ExportAssignment) => boolean, message?: string | (() => string)): ExportAssignment;
  1465. /** Get the file's export assignments. */
  1466. getExportAssignments(): ExportAssignment[];
  1467. /** Gets the default export symbol. */
  1468. getDefaultExportSymbol(): Symbol | undefined;
  1469. /** Gets the default export symbol or throws if it doesn't exist. */
  1470. getDefaultExportSymbolOrThrow(message?: string | (() => string)): Symbol;
  1471. /** Gets the export symbols. */
  1472. getExportSymbols(): Symbol[];
  1473. /**
  1474. * Gets all the declarations that are exported from the module.
  1475. *
  1476. * The key is the name it's exported on and the value is the array of declarations for that name.
  1477. *
  1478. * This will include declarations that are transitively exported from other modules. If you mean to get the export
  1479. * declarations then use `.getExportDeclarations()`.
  1480. */
  1481. getExportedDeclarations(): ReadonlyMap<string, ExportedDeclarations[]>;
  1482. /** Removes any "export default". */
  1483. removeDefaultExport(defaultExportSymbol?: Symbol | undefined): this;
  1484. }
  1485. type ModuledNodeExtensionType = Node<ts.SourceFile | ts.ModuleDeclaration> & StatementedNode;
  1486. export declare function BindingNamedNode<T extends Constructor<BindingNamedNodeExtensionType>>(Base: T): Constructor<BindingNamedNode> & T;
  1487. export interface BindingNamedNode extends BindingNamedNodeSpecific, ReferenceFindableNode, RenameableNode {
  1488. }
  1489. type BindingNamedNodeExtensionType = NamedNodeBaseExtensionType<ts.BindingName>;
  1490. export type BindingNamedNodeSpecific = NamedNodeSpecificBase<BindingName>;
  1491. export declare function ImportAttributeNamedNode<T extends Constructor<ImportAttributeNamedNodeExtensionType>>(Base: T): Constructor<ImportAttributeNamedNode> & T;
  1492. export interface ImportAttributeNamedNode extends ImportAttributeNamedNodeSpecific, ReferenceFindableNode, RenameableNode {
  1493. }
  1494. type ImportAttributeNamedNodeExtensionType = NamedNodeBaseExtensionType<ts.ImportAttributeName>;
  1495. export type ImportAttributeNamedNodeSpecific = NamedNodeSpecificBase<AssertionKey>;
  1496. export declare function ModuleNamedNode<T extends Constructor<ModuleNamedNodeExtensionType>>(Base: T): Constructor<ModuleNamedNode> & T;
  1497. export interface ModuleNamedNode extends ModuleNamedNodeSpecific, ReferenceFindableNode, RenameableNode {
  1498. }
  1499. type ModuleNamedNodeExtensionType = NamedNodeBaseExtensionType<ts.ModuleName>;
  1500. export type ModuleNamedNodeSpecific = NamedNodeSpecificBase<ModuleName>;
  1501. export declare function NameableNode<T extends Constructor<NameableNodeExtensionType>>(Base: T): Constructor<NameableNode> & T;
  1502. export interface NameableNode extends NameableNodeSpecific, ReferenceFindableNode, RenameableNode {
  1503. }
  1504. type NameableNodeExtensionType = Node<ts.Node & {
  1505. name?: ts.Identifier;
  1506. }>;
  1507. export interface NameableNodeSpecific {
  1508. /** Gets the name node if it exists. */
  1509. getNameNode(): Identifier | undefined;
  1510. /** Gets the name node if it exists, or throws. */
  1511. getNameNodeOrThrow(message?: string | (() => string)): Identifier;
  1512. /** Gets the name if it exists. */
  1513. getName(): string | undefined;
  1514. /** Gets the name if it exists, or throws. */
  1515. getNameOrThrow(message?: string | (() => string)): string;
  1516. /** Removes the name from the node. */
  1517. removeName(): this;
  1518. }
  1519. export declare function NamedNode<T extends Constructor<NamedNodeExtensionType>>(Base: T): Constructor<NamedNode> & T;
  1520. export interface NamedNode extends NamedNodeSpecific, ReferenceFindableNode, RenameableNode {
  1521. }
  1522. type NamedNodeExtensionType = NamedNodeBaseExtensionType<ts.Identifier>;
  1523. export type NamedNodeSpecific = NamedNodeSpecificBase<Identifier>;
  1524. export declare function NamedNodeBase<TCompilerNode extends ts.Node, U extends Constructor<NamedNodeBaseExtensionType<TCompilerNode>>>(Base: U): Constructor<NamedNodeSpecificBase<CompilerNodeToWrappedType<TCompilerNode>>> & U;
  1525. export interface NamedNodeSpecificBase<TNode extends Node> {
  1526. /** Gets the name node. */
  1527. getNameNode(): TNode;
  1528. /** Gets the name as a string. */
  1529. getName(): string;
  1530. }
  1531. type NamedNodeBaseExtensionType<TCompilerNode extends ts.Node> = Node<ts.Node & {
  1532. name: TCompilerNode;
  1533. }>;
  1534. export declare function PropertyNamedNode<T extends Constructor<PropertyNamedNodeExtensionType>>(Base: T): Constructor<PropertyNamedNode> & T;
  1535. export interface PropertyNamedNode extends PropertyNamedNodeSpecific, ReferenceFindableNode, RenameableNode {
  1536. }
  1537. type PropertyNamedNodeExtensionType = NamedNodeBaseExtensionType<ts.PropertyName>;
  1538. export type PropertyNamedNodeSpecific = NamedNodeSpecificBase<PropertyName>;
  1539. export declare function ReferenceFindableNode<T extends Constructor<ReferenceFindableNodeExtensionType>>(Base: T): Constructor<ReferenceFindableNode> & T;
  1540. export interface ReferenceFindableNode {
  1541. /** Finds the references of the definition of the node. */
  1542. findReferences(): ReferencedSymbol[];
  1543. /** Finds the nodes that reference the definition of the node. */
  1544. findReferencesAsNodes(): Node[];
  1545. }
  1546. type ReferenceFindableNodeExtensionType = Node<ts.Node & {
  1547. name?: ts.PropertyName | ts.BindingName | ts.DeclarationName | ts.StringLiteral;
  1548. }>;
  1549. export declare function RenameableNode<T extends Constructor<RenameableNodeExtensionType>>(Base: T): Constructor<RenameableNode> & T;
  1550. export interface RenameableNode {
  1551. /**
  1552. * Renames the name of the node.
  1553. * @param newName - New name.
  1554. * @param options - Options for renaming.
  1555. */
  1556. rename(newName: string, options?: RenameOptions): this;
  1557. }
  1558. type RenameableNodeExtensionType = Node<ts.Node>;
  1559. export declare function OverrideableNode<T extends Constructor<OverrideableNodeExtensionType>>(Base: T): Constructor<OverrideableNode> & T;
  1560. export interface OverrideableNode {
  1561. /** If it has an override keyword. */
  1562. hasOverrideKeyword(): boolean;
  1563. /** Gets the override keyword or undefined if none exists. */
  1564. getOverrideKeyword(): Node<ts.OverrideKeyword> | undefined;
  1565. /** Gets the override keyword or throws if none exists. */
  1566. getOverrideKeywordOrThrow(message?: string | (() => string)): Node<ts.Modifier>;
  1567. /**
  1568. * Sets if the node has an override keyword.
  1569. * @param value - If it should have an override keyword or not.
  1570. */
  1571. setHasOverrideKeyword(value: boolean): this;
  1572. }
  1573. type OverrideableNodeExtensionType = Node & ModifierableNode;
  1574. export declare function ParameteredNode<T extends Constructor<ParameteredNodeExtensionType>>(Base: T): Constructor<ParameteredNode> & T;
  1575. export interface ParameteredNode {
  1576. /**
  1577. * Gets a parameter or undefined if it doesn't exist.
  1578. * @param name - Name of the parameter.
  1579. */
  1580. getParameter(name: string): ParameterDeclaration | undefined;
  1581. /**
  1582. * Gets a parameter or undefined if it doesn't exist.
  1583. * @param findFunction - Function to use to find the parameter.
  1584. */
  1585. getParameter(findFunction: (declaration: ParameterDeclaration) => boolean): ParameterDeclaration | undefined;
  1586. /**
  1587. * Gets a parameter or throws if it doesn't exist.
  1588. * @param name - Name of the parameter.
  1589. */
  1590. getParameterOrThrow(name: string): ParameterDeclaration;
  1591. /**
  1592. * Gets a parameter or throws if it doesn't exist.
  1593. * @param findFunction - Function to use to find the parameter.
  1594. */
  1595. getParameterOrThrow(findFunction: (declaration: ParameterDeclaration) => boolean): ParameterDeclaration;
  1596. /** Gets all the parameters of the node. */
  1597. getParameters(): ParameterDeclaration[];
  1598. /**
  1599. * Adds a parameter.
  1600. * @param structure - Structure of the parameter.
  1601. */
  1602. addParameter(structure: OptionalKind<ParameterDeclarationStructure>): ParameterDeclaration;
  1603. /**
  1604. * Adds parameters.
  1605. * @param structures - Structures of the parameters.
  1606. */
  1607. addParameters(structures: ReadonlyArray<OptionalKind<ParameterDeclarationStructure>>): ParameterDeclaration[];
  1608. /**
  1609. * Inserts parameters.
  1610. * @param index - Child index to insert at.
  1611. * @param structures - Parameters to insert.
  1612. */
  1613. insertParameters(index: number, structures: ReadonlyArray<OptionalKind<ParameterDeclarationStructure>>): ParameterDeclaration[];
  1614. /**
  1615. * Inserts a parameter.
  1616. * @param index - Child index to insert at.
  1617. * @param structures - Parameter to insert.
  1618. */
  1619. insertParameter(index: number, structure: OptionalKind<ParameterDeclarationStructure>): ParameterDeclaration;
  1620. }
  1621. type ParameteredNodeExtensionType = Node<ts.Node & {
  1622. parameters: ts.NodeArray<ts.ParameterDeclaration>;
  1623. }>;
  1624. export declare function QuestionDotTokenableNode<T extends Constructor<QuestionDotTokenableNodeExtensionType>>(Base: T): Constructor<QuestionDotTokenableNode> & T;
  1625. export interface QuestionDotTokenableNode {
  1626. /** If it has a question dot token. */
  1627. hasQuestionDotToken(): boolean;
  1628. /** Gets the question dot token node or returns undefined if it doesn't exist. */
  1629. getQuestionDotTokenNode(): Node<ts.QuestionDotToken> | undefined;
  1630. /** Gets the question dot token node or throws. */
  1631. getQuestionDotTokenNodeOrThrow(message?: string | (() => string)): Node<ts.QuestionDotToken>;
  1632. /**
  1633. * Sets if this node has a question dot token.
  1634. * @param value - If it should have a question dot token or not.
  1635. */
  1636. setHasQuestionDotToken(value: boolean): this;
  1637. }
  1638. type QuestionDotTokenableNodeExtensionType = Node<ts.Node & {
  1639. questionDotToken?: ts.QuestionDotToken;
  1640. }>;
  1641. export declare function QuestionTokenableNode<T extends Constructor<QuestionTokenableNodeExtensionType>>(Base: T): Constructor<QuestionTokenableNode> & T;
  1642. export interface QuestionTokenableNode {
  1643. /** If it has a question token. */
  1644. hasQuestionToken(): boolean;
  1645. /** Gets the question token node or returns undefined if it doesn't exist. */
  1646. getQuestionTokenNode(): Node<ts.QuestionToken> | undefined;
  1647. /** Gets the question token node or throws. */
  1648. getQuestionTokenNodeOrThrow(message?: string | (() => string)): Node<ts.QuestionToken>;
  1649. /**
  1650. * Sets if this node has a question token.
  1651. * @param value - If it should have a question token or not.
  1652. */
  1653. setHasQuestionToken(value: boolean): this;
  1654. }
  1655. type QuestionTokenableNodeExtensionType = Node<ts.Node & {
  1656. questionToken?: ts.QuestionToken;
  1657. }>;
  1658. export declare function ReadonlyableNode<T extends Constructor<ReadonlyableNodeExtensionType>>(Base: T): Constructor<ReadonlyableNode> & T;
  1659. export interface ReadonlyableNode {
  1660. /** Gets if it's readonly. */
  1661. isReadonly(): boolean;
  1662. /** Gets the readonly keyword, or undefined if none exists. */
  1663. getReadonlyKeyword(): Node | undefined;
  1664. /** Gets the readonly keyword, or throws if none exists. */
  1665. getReadonlyKeywordOrThrow(message?: string | (() => string)): Node;
  1666. /**
  1667. * Sets if this node is readonly.
  1668. * @param value - If readonly or not.
  1669. */
  1670. setIsReadonly(value: boolean): this;
  1671. }
  1672. type ReadonlyableNodeExtensionType = Node & ModifierableNode;
  1673. export declare function ReturnTypedNode<T extends Constructor<ReturnTypedNodeExtensionType>>(Base: T): Constructor<ReturnTypedNode> & T;
  1674. export interface ReturnTypedNode {
  1675. /** Gets the return type. */
  1676. getReturnType(): Type;
  1677. /** Gets the return type node or undefined if none exists. */
  1678. getReturnTypeNode(): TypeNode | undefined;
  1679. /** Gets the return type node or throws if none exists. */
  1680. getReturnTypeNodeOrThrow(message?: string | (() => string)): TypeNode;
  1681. /**
  1682. * Sets the return type of the node.
  1683. * @param textOrWriterFunction - Text or writer function to set the return type with.
  1684. */
  1685. setReturnType(textOrWriterFunction: string | WriterFunction): this;
  1686. /** Removes the return type. */
  1687. removeReturnType(): this;
  1688. /** Gets the signature of the node from the type checker. */
  1689. getSignature(): Signature;
  1690. }
  1691. type ReturnTypedNodeExtensionType = Node<ts.SignatureDeclaration>;
  1692. export declare function ScopeableNode<T extends Constructor<ScopeableNodeExtensionType>>(Base: T): Constructor<ScopeableNode> & T;
  1693. export interface ScopeableNode {
  1694. /**
  1695. * Gets the scope.
  1696. */
  1697. getScope(): Scope | undefined;
  1698. /**
  1699. * Sets the scope.
  1700. * @param scope - Scope to set to.
  1701. */
  1702. setScope(scope: Scope | undefined): this;
  1703. /** Gets if the node has a scope keyword. */
  1704. hasScopeKeyword(): boolean;
  1705. }
  1706. type ScopeableNodeExtensionType = Node & ModifierableNode;
  1707. export declare function ScopedNode<T extends Constructor<ScopedNodeExtensionType>>(Base: T): Constructor<ScopedNode> & T;
  1708. export interface ScopedNode {
  1709. /** Gets the scope. */
  1710. getScope(): Scope;
  1711. /**
  1712. * Sets the scope.
  1713. * @param scope - Scope to set to.
  1714. */
  1715. setScope(scope: Scope | undefined): this;
  1716. /** Gets if the node has a scope keyword. */
  1717. hasScopeKeyword(): boolean;
  1718. }
  1719. type ScopedNodeExtensionType = Node & ModifierableNode;
  1720. export declare function SignaturedDeclaration<T extends Constructor<SignaturedDeclarationExtensionType>>(Base: T): Constructor<SignaturedDeclaration> & T;
  1721. export interface SignaturedDeclaration extends ParameteredNode, ReturnTypedNode {
  1722. }
  1723. type SignaturedDeclarationExtensionType = Node<ts.SignatureDeclaration>;
  1724. export declare function StaticableNode<T extends Constructor<StaticableNodeExtensionType>>(Base: T): Constructor<StaticableNode> & T;
  1725. export interface StaticableNode {
  1726. /** Gets if it's static. */
  1727. isStatic(): boolean;
  1728. /** Gets the static keyword, or undefined if none exists. */
  1729. getStaticKeyword(): Node | undefined;
  1730. /** Gets the static keyword, or throws if none exists. */
  1731. getStaticKeywordOrThrow(message?: string | (() => string)): Node;
  1732. /**
  1733. * Sets if the node is static.
  1734. * @param value - If it should be static or not.
  1735. */
  1736. setIsStatic(value: boolean): this;
  1737. }
  1738. type StaticableNodeExtensionType = Node & ModifierableNode;
  1739. export declare function TextInsertableNode<T extends Constructor<TextInsertableNodeExtensionType>>(Base: T): Constructor<TextInsertableNode> & T;
  1740. export interface TextInsertableNode {
  1741. /**
  1742. * Inserts text within the body of the node.
  1743. *
  1744. * WARNING: This will forget any previously navigated descendant nodes.
  1745. * @param pos - Position to insert at.
  1746. * @param textOrWriterFunction - Text to insert.
  1747. */
  1748. insertText(pos: number, textOrWriterFunction: string | WriterFunction): this;
  1749. /**
  1750. * Replaces text within the body of the node.
  1751. *
  1752. * WARNING: This will forget any previously navigated descendant nodes.
  1753. * @param range - Start and end position of the text to replace.
  1754. * @param textOrWriterFunction - Text to replace the range with.
  1755. */
  1756. replaceText(range: [number, number], textOrWriterFunction: string | WriterFunction): this;
  1757. /** Removes all the text within the node */
  1758. removeText(): this;
  1759. /**
  1760. * Removes text within the body of the node.
  1761. *
  1762. * WARNING: This will forget any previously navigated descendant nodes.
  1763. * @param pos - Start position to remove.
  1764. * @param end - End position to remove.
  1765. */
  1766. removeText(pos: number, end: number): this;
  1767. }
  1768. type TextInsertableNodeExtensionType = Node;
  1769. export declare function TypeArgumentedNode<T extends Constructor<TypeArgumentedNodeExtensionType>>(Base: T): Constructor<TypeArgumentedNode> & T;
  1770. export interface TypeArgumentedNode {
  1771. /** Gets all the type arguments of the node. */
  1772. getTypeArguments(): TypeNode[];
  1773. /**
  1774. * Adds a type argument.
  1775. * @param argumentText - Argument text to add.
  1776. */
  1777. addTypeArgument(argumentText: string): TypeNode;
  1778. /**
  1779. * Adds type arguments.
  1780. * @param argumentTexts - Argument texts to add.
  1781. */
  1782. addTypeArguments(argumentTexts: ReadonlyArray<string>): TypeNode[];
  1783. /**
  1784. * Inserts a type argument.
  1785. * @param index - Child index to insert at.
  1786. * @param argumentText - Argument text to insert.
  1787. */
  1788. insertTypeArgument(index: number, argumentText: string): TypeNode;
  1789. /**
  1790. * Inserts type arguments.
  1791. * @param index - Child index to insert at.
  1792. * @param argumentTexts - Argument texts to insert.
  1793. */
  1794. insertTypeArguments(index: number, argumentTexts: ReadonlyArray<string>): TypeNode[];
  1795. /**
  1796. * Removes a type argument.
  1797. * @param typeArg - Type argument to remove.
  1798. */
  1799. removeTypeArgument(typeArg: Node): this;
  1800. /**
  1801. * Removes a type argument.
  1802. * @param index - Index to remove.
  1803. */
  1804. removeTypeArgument(index: number): this;
  1805. }
  1806. type TypeArgumentedNodeExtensionType = Node<ts.Node & {
  1807. typeArguments?: ts.NodeArray<ts.TypeNode>;
  1808. }>;
  1809. export declare function TypedNode<T extends Constructor<TypedNodeExtensionType>>(Base: T): Constructor<TypedNode> & T;
  1810. export interface TypedNode {
  1811. /** Gets the type node or undefined if none exists. */
  1812. getTypeNode(): TypeNode | undefined;
  1813. /** Gets the type node or throws if none exists. */
  1814. getTypeNodeOrThrow(message?: string | (() => string)): TypeNode;
  1815. /**
  1816. * Sets the type.
  1817. * @param textOrWriterFunction - Text or writer function to set the type with.
  1818. */
  1819. setType(textOrWriterFunction: string | WriterFunction): this;
  1820. /** Removes the type. */
  1821. removeType(): this;
  1822. }
  1823. type TypedNodeExtensionType = Node<ts.Node & {
  1824. type?: ts.TypeNode;
  1825. }>;
  1826. export declare function TypeElementMemberedNode<T extends Constructor<TypeElementMemberedNodeExtensionType>>(Base: T): Constructor<TypeElementMemberedNode> & T;
  1827. export interface TypeElementMemberedNode {
  1828. /**
  1829. * Adds a member.
  1830. * @param member - Member to add.
  1831. */
  1832. addMember(member: string | WriterFunction | TypeElementMemberStructures): TypeElementTypes | CommentTypeElement;
  1833. /**
  1834. * Adds members.
  1835. * @param members - Collection of members to add.
  1836. */
  1837. addMembers(members: string | WriterFunction | ReadonlyArray<string | WriterFunction | TypeElementMemberStructures>): (TypeElementTypes | CommentTypeElement)[];
  1838. /**
  1839. * Inserts a member.
  1840. * @param index - Child index to insert at.
  1841. * @param member - Member to insert.
  1842. */
  1843. insertMember(index: number, member: string | WriterFunction | TypeElementMemberStructures): TypeElementTypes | CommentTypeElement;
  1844. /**
  1845. * Inserts members.
  1846. * @param index - Child index to insert at.
  1847. * @param members - Collection of members to insert.
  1848. */
  1849. insertMembers(index: number, members: string | WriterFunction | ReadonlyArray<string | WriterFunction | TypeElementMemberStructures>): (TypeElementTypes | CommentTypeElement)[];
  1850. /**
  1851. * Add construct signature.
  1852. * @param structure - Structure representing the construct signature.
  1853. */
  1854. addConstructSignature(structure: OptionalKind<ConstructSignatureDeclarationStructure>): ConstructSignatureDeclaration;
  1855. /**
  1856. * Add construct signatures.
  1857. * @param structures - Structures representing the construct signatures.
  1858. */
  1859. addConstructSignatures(structures: ReadonlyArray<OptionalKind<ConstructSignatureDeclarationStructure>>): ConstructSignatureDeclaration[];
  1860. /**
  1861. * Insert construct signature.
  1862. * @param index - Child index to insert at.
  1863. * @param structure - Structure representing the construct signature.
  1864. */
  1865. insertConstructSignature(index: number, structure: OptionalKind<ConstructSignatureDeclarationStructure>): ConstructSignatureDeclaration;
  1866. /**
  1867. * Insert construct signatures.
  1868. * @param index - Child index to insert at.
  1869. * @param structures - Structures representing the construct signatures.
  1870. */
  1871. insertConstructSignatures(index: number, structures: ReadonlyArray<OptionalKind<ConstructSignatureDeclarationStructure>>): ConstructSignatureDeclaration[];
  1872. /**
  1873. * Gets the first construct signature by a find function.
  1874. * @param findFunction - Function to find the construct signature by.
  1875. */
  1876. getConstructSignature(findFunction: (member: ConstructSignatureDeclaration) => boolean): ConstructSignatureDeclaration | undefined;
  1877. /**
  1878. * Gets the first construct signature by a find function or throws if not found.
  1879. * @param findFunction - Function to find the construct signature by.
  1880. */
  1881. getConstructSignatureOrThrow(findFunction: (member: ConstructSignatureDeclaration) => boolean): ConstructSignatureDeclaration;
  1882. /** Gets the interface construct signatures. */
  1883. getConstructSignatures(): ConstructSignatureDeclaration[];
  1884. /**
  1885. * Add call signature.
  1886. * @param structure - Structure representing the call signature.
  1887. */
  1888. addCallSignature(structure: OptionalKind<CallSignatureDeclarationStructure>): CallSignatureDeclaration;
  1889. /**
  1890. * Add call signatures.
  1891. * @param structures - Structures representing the call signatures.
  1892. */
  1893. addCallSignatures(structures: ReadonlyArray<OptionalKind<CallSignatureDeclarationStructure>>): CallSignatureDeclaration[];
  1894. /**
  1895. * Insert call signature.
  1896. * @param index - Child index to insert at.
  1897. * @param structure - Structure representing the call signature.
  1898. */
  1899. insertCallSignature(index: number, structure: OptionalKind<CallSignatureDeclarationStructure>): CallSignatureDeclaration;
  1900. /**
  1901. * Insert call signatures.
  1902. * @param index - Child index to insert at.
  1903. * @param structures - Structures representing the call signatures.
  1904. */
  1905. insertCallSignatures(index: number, structures: ReadonlyArray<OptionalKind<CallSignatureDeclarationStructure>>): CallSignatureDeclaration[];
  1906. /**
  1907. * Gets the first call signature by a find function.
  1908. * @param findFunction - Function to find the call signature by.
  1909. */
  1910. getCallSignature(findFunction: (member: CallSignatureDeclaration) => boolean): CallSignatureDeclaration | undefined;
  1911. /**
  1912. * Gets the first call signature by a find function or throws if not found.
  1913. * @param findFunction - Function to find the call signature by.
  1914. */
  1915. getCallSignatureOrThrow(findFunction: (member: CallSignatureDeclaration) => boolean): CallSignatureDeclaration;
  1916. /** Gets the interface call signatures. */
  1917. getCallSignatures(): CallSignatureDeclaration[];
  1918. /**
  1919. * Add index signature.
  1920. * @param structure - Structure representing the index signature.
  1921. */
  1922. addIndexSignature(structure: OptionalKind<IndexSignatureDeclarationStructure>): IndexSignatureDeclaration;
  1923. /**
  1924. * Add index signatures.
  1925. * @param structures - Structures representing the index signatures.
  1926. */
  1927. addIndexSignatures(structures: ReadonlyArray<OptionalKind<IndexSignatureDeclarationStructure>>): IndexSignatureDeclaration[];
  1928. /**
  1929. * Insert index signature.
  1930. * @param index - Child index to insert at.
  1931. * @param structure - Structure representing the index signature.
  1932. */
  1933. insertIndexSignature(index: number, structure: OptionalKind<IndexSignatureDeclarationStructure>): IndexSignatureDeclaration;
  1934. /**
  1935. * Insert index signatures.
  1936. * @param index - Child index to insert at.
  1937. * @param structures - Structures representing the index signatures.
  1938. */
  1939. insertIndexSignatures(index: number, structures: ReadonlyArray<OptionalKind<IndexSignatureDeclarationStructure>>): IndexSignatureDeclaration[];
  1940. /**
  1941. * Gets the first index signature by a find function.
  1942. * @param findFunction - Function to find the index signature by.
  1943. */
  1944. getIndexSignature(findFunction: (member: IndexSignatureDeclaration) => boolean): IndexSignatureDeclaration | undefined;
  1945. /**
  1946. * Gets the first index signature by a find function or throws if not found.
  1947. * @param findFunction - Function to find the index signature by.
  1948. */
  1949. getIndexSignatureOrThrow(findFunction: (member: IndexSignatureDeclaration) => boolean): IndexSignatureDeclaration;
  1950. /** Gets the interface index signatures. */
  1951. getIndexSignatures(): IndexSignatureDeclaration[];
  1952. /**
  1953. * Add method.
  1954. * @param structure - Structure representing the method.
  1955. */
  1956. addMethod(structure: OptionalKind<MethodSignatureStructure>): MethodSignature;
  1957. /**
  1958. * Add methods.
  1959. * @param structures - Structures representing the methods.
  1960. */
  1961. addMethods(structures: ReadonlyArray<OptionalKind<MethodSignatureStructure>>): MethodSignature[];
  1962. /**
  1963. * Insert method.
  1964. * @param index - Child index to insert at.
  1965. * @param structure - Structure representing the method.
  1966. */
  1967. insertMethod(index: number, structure: OptionalKind<MethodSignatureStructure>): MethodSignature;
  1968. /**
  1969. * Insert methods.
  1970. * @param index - Child index to insert at.
  1971. * @param structures - Structures representing the methods.
  1972. */
  1973. insertMethods(index: number, structures: ReadonlyArray<OptionalKind<MethodSignatureStructure>>): MethodSignature[];
  1974. /**
  1975. * Gets the first method by name.
  1976. * @param name - Name.
  1977. */
  1978. getMethod(name: string): MethodSignature | undefined;
  1979. /**
  1980. * Gets the first method by a find function.
  1981. * @param findFunction - Function to find the method by.
  1982. */
  1983. getMethod(findFunction: (member: MethodSignature) => boolean): MethodSignature | undefined;
  1984. /**
  1985. * Gets the first method by name or throws if not found.
  1986. * @param name - Name.
  1987. */
  1988. getMethodOrThrow(name: string): MethodSignature;
  1989. /**
  1990. * Gets the first method by a find function or throws if not found.
  1991. * @param findFunction - Function to find the method by.
  1992. */
  1993. getMethodOrThrow(findFunction: (member: MethodSignature) => boolean): MethodSignature;
  1994. /** Gets the interface method signatures. */
  1995. getMethods(): MethodSignature[];
  1996. /**
  1997. * Add property.
  1998. * @param structure - Structure representing the property.
  1999. */
  2000. addProperty(structure: OptionalKind<PropertySignatureStructure>): PropertySignature;
  2001. /**
  2002. * Add properties.
  2003. * @param structures - Structures representing the properties.
  2004. */
  2005. addProperties(structures: ReadonlyArray<OptionalKind<PropertySignatureStructure>>): PropertySignature[];
  2006. /**
  2007. * Insert property.
  2008. * @param index - Child index to insert at.
  2009. * @param structure - Structure representing the property.
  2010. */
  2011. insertProperty(index: number, structure: OptionalKind<PropertySignatureStructure>): PropertySignature;
  2012. /**
  2013. * Insert properties.
  2014. * @param index - Child index to insert at.
  2015. * @param structures - Structures representing the properties.
  2016. */
  2017. insertProperties(index: number, structures: ReadonlyArray<OptionalKind<PropertySignatureStructure>>): PropertySignature[];
  2018. /**
  2019. * Gets the first property by name.
  2020. * @param name - Name.
  2021. */
  2022. getProperty(name: string): PropertySignature | undefined;
  2023. /**
  2024. * Gets the first property by a find function.
  2025. * @param findFunction - Function to find the property by.
  2026. */
  2027. getProperty(findFunction: (member: PropertySignature) => boolean): PropertySignature | undefined;
  2028. /**
  2029. * Gets the first property by name or throws if not found.
  2030. * @param name - Name.
  2031. */
  2032. getPropertyOrThrow(name: string): PropertySignature;
  2033. /**
  2034. * Gets the first property by a find function or throws if not found.
  2035. * @param findFunction - Function to find the property by.
  2036. */
  2037. getPropertyOrThrow(findFunction: (member: PropertySignature) => boolean): PropertySignature;
  2038. /** Gets the interface property signatures. */
  2039. getProperties(): PropertySignature[];
  2040. /**
  2041. * Add get accessor.
  2042. * @param structure - Structure representing the get accessor.
  2043. */
  2044. addGetAccessor(structure: OptionalKind<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
  2045. /**
  2046. * Add get accessors.
  2047. * @param structures - Structures representing the get accessors.
  2048. */
  2049. addGetAccessors(structures: ReadonlyArray<OptionalKind<GetAccessorDeclarationStructure>>): GetAccessorDeclaration[];
  2050. /**
  2051. * Insert get accessor.
  2052. * @param index - Child index to insert at.
  2053. * @param structure - Structure representing the get accessor.
  2054. */
  2055. insertGetAccessor(index: number, structure: OptionalKind<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
  2056. /**
  2057. * Insert get accessors.
  2058. * @param index - Child index to insert at.
  2059. * @param structures - Structures representing the get accessors.
  2060. */
  2061. insertGetAccessors(index: number, structures: ReadonlyArray<OptionalKind<GetAccessorDeclarationStructure>>): GetAccessorDeclaration[];
  2062. /**
  2063. * Gets the first get accessor by name.
  2064. * @param name - Name.
  2065. */
  2066. getGetAccessor(name: string): GetAccessorDeclaration | undefined;
  2067. /**
  2068. * Gets the first get accessor by a find function.
  2069. * @param findFunction - Function to find the get accessor by.
  2070. */
  2071. getGetAccessor(findFunction: (member: GetAccessorDeclaration) => boolean): GetAccessorDeclaration | undefined;
  2072. /**
  2073. * Gets the first get accessor by name or throws if not found.
  2074. * @param name - Name.
  2075. */
  2076. getGetAccessorOrThrow(name: string): GetAccessorDeclaration;
  2077. /**
  2078. * Gets the first get accessor by a find function or throws if not found.
  2079. * @param findFunction - Function to find the get accessor by.
  2080. */
  2081. getGetAccessorOrThrow(findFunction: (member: GetAccessorDeclaration) => boolean): GetAccessorDeclaration;
  2082. /** Gets the interface get accessor declarations. */
  2083. getGetAccessors(): GetAccessorDeclaration[];
  2084. /**
  2085. * Add set accessor.
  2086. * @param structure - Structure representing the set accessor.
  2087. */
  2088. addSetAccessor(structure: OptionalKind<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
  2089. /**
  2090. * Add set accessors.
  2091. * @param structures - Structures representing the set accessors.
  2092. */
  2093. addSetAccessors(structures: ReadonlyArray<OptionalKind<SetAccessorDeclarationStructure>>): SetAccessorDeclaration[];
  2094. /**
  2095. * Insert set accessor.
  2096. * @param index - Child index to insert at.
  2097. * @param structure - Structure representing the set accessor.
  2098. */
  2099. insertSetAccessor(index: number, structure: OptionalKind<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
  2100. /**
  2101. * Insert set accessors.
  2102. * @param index - Child index to insert at.
  2103. * @param structures - Structures representing the set accessors.
  2104. */
  2105. insertSetAccessors(index: number, structures: ReadonlyArray<OptionalKind<SetAccessorDeclarationStructure>>): SetAccessorDeclaration[];
  2106. /**
  2107. * Gets the first set accessor by name.
  2108. * @param name - Name.
  2109. */
  2110. getSetAccessor(name: string): SetAccessorDeclaration | undefined;
  2111. /**
  2112. * Gets the first set accessor by a find function.
  2113. * @param findFunction - Function to find the set accessor by.
  2114. */
  2115. getSetAccessor(findFunction: (member: SetAccessorDeclaration) => boolean): SetAccessorDeclaration | undefined;
  2116. /**
  2117. * Gets the first set accessor by name or throws if not found.
  2118. * @param name - Name.
  2119. */
  2120. getSetAccessorOrThrow(name: string): SetAccessorDeclaration;
  2121. /**
  2122. * Gets the first set accessor by a find function or throws if not found.
  2123. * @param findFunction - Function to find the set accessor by.
  2124. */
  2125. getSetAccessorOrThrow(findFunction: (member: SetAccessorDeclaration) => boolean): SetAccessorDeclaration;
  2126. /** Gets the interface set accessor declarations. */
  2127. getSetAccessors(): SetAccessorDeclaration[];
  2128. /** Gets all the members. */
  2129. getMembers(): TypeElementTypes[];
  2130. /** Gets all the members with comment type elements. */
  2131. getMembersWithComments(): (TypeElementTypes | CommentTypeElement)[];
  2132. }
  2133. type TypeElementMemberedNodeExtensionType = Node<ts.Node & {
  2134. members: ts.NodeArray<ts.TypeElement>;
  2135. }>;
  2136. export declare function TypeParameteredNode<T extends Constructor<TypeParameteredNodeExtensionType>>(Base: T): Constructor<TypeParameteredNode> & T;
  2137. export interface TypeParameteredNode {
  2138. /**
  2139. * Gets a type parameter or undefined if it doesn't exist.
  2140. * @param name - Name of the parameter.
  2141. */
  2142. getTypeParameter(name: string): TypeParameterDeclaration | undefined;
  2143. /**
  2144. * Gets a type parameter or undefined if it doesn't exist.
  2145. * @param findFunction - Function to use to find the type parameter.
  2146. */
  2147. getTypeParameter(findFunction: (declaration: TypeParameterDeclaration) => boolean): TypeParameterDeclaration | undefined;
  2148. /**
  2149. * Gets a type parameter or throws if it doesn't exist.
  2150. * @param name - Name of the parameter.
  2151. */
  2152. getTypeParameterOrThrow(name: string): TypeParameterDeclaration;
  2153. /**
  2154. * Gets a type parameter or throws if it doesn't exist.
  2155. * @param findFunction - Function to use to find the type parameter.
  2156. */
  2157. getTypeParameterOrThrow(findFunction: (declaration: TypeParameterDeclaration) => boolean): TypeParameterDeclaration;
  2158. /** Gets the type parameters. */
  2159. getTypeParameters(): TypeParameterDeclaration[];
  2160. /**
  2161. * Adds a type parameter.
  2162. * @param structure - Structure of the type parameter.
  2163. */
  2164. addTypeParameter(structure: OptionalKind<TypeParameterDeclarationStructure> | string): TypeParameterDeclaration;
  2165. /**
  2166. * Adds type parameters.
  2167. * @param structures - Structures of the type parameters.
  2168. */
  2169. addTypeParameters(structures: ReadonlyArray<OptionalKind<TypeParameterDeclarationStructure> | string>): TypeParameterDeclaration[];
  2170. /**
  2171. * Inserts a type parameter.
  2172. * @param index - Child index to insert at. Specify a negative index to insert from the reverse.
  2173. * @param structure - Structure of the type parameter.
  2174. */
  2175. insertTypeParameter(index: number, structure: OptionalKind<TypeParameterDeclarationStructure> | string): TypeParameterDeclaration;
  2176. /**
  2177. * Inserts type parameters.
  2178. * @param index - Child index to insert at. Specify a negative index to insert from the reverse.
  2179. * @param structures - Structures of the type parameters.
  2180. */
  2181. insertTypeParameters(index: number, structures: ReadonlyArray<OptionalKind<TypeParameterDeclarationStructure> | string>): TypeParameterDeclaration[];
  2182. }
  2183. type TypeParameteredNodeExtensionType = Node<ts.Node & {
  2184. typeParameters?: ts.NodeArray<ts.TypeParameterDeclaration>;
  2185. }>;
  2186. export declare function UnwrappableNode<T extends Constructor<UnwrappableNodeExtensionType>>(Base: T): Constructor<UnwrappableNode> & T;
  2187. export interface UnwrappableNode {
  2188. /** Replaces the node's text with its body's statements. */
  2189. unwrap(): void;
  2190. }
  2191. type UnwrappableNodeExtensionType = Node;
  2192. export declare class ArrayBindingPattern extends Node<ts.ArrayBindingPattern> {
  2193. /** Gets the array binding pattern's elements. */
  2194. getElements(): (BindingElement | OmittedExpression)[];
  2195. /** @inheritdoc **/
  2196. getParent(): NodeParentType<ts.ArrayBindingPattern>;
  2197. /** @inheritdoc **/
  2198. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ArrayBindingPattern>>;
  2199. }
  2200. declare const BindingElementBase: Constructor<DotDotDotTokenableNode> & Constructor<InitializerExpressionableNode> & Constructor<BindingNamedNode> & typeof Node;
  2201. export declare class BindingElement extends BindingElementBase<ts.BindingElement> {
  2202. /**
  2203. * Gets binding element's property name node or throws if not found.
  2204. *
  2205. * For example in `const { a: b } = { a: 5 }`, `a` would be the property name.
  2206. */
  2207. getPropertyNameNodeOrThrow(message?: string | (() => string)): PropertyName;
  2208. /**
  2209. * Gets binding element's property name node or returns undefined if not found.
  2210. *
  2211. * For example in `const { a: b } = { a: 5 }`, `a` would be the property name.
  2212. */
  2213. getPropertyNameNode(): PropertyName | undefined;
  2214. /** @inheritdoc **/
  2215. getParent(): NodeParentType<ts.BindingElement>;
  2216. /** @inheritdoc **/
  2217. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.BindingElement>>;
  2218. }
  2219. export declare class ObjectBindingPattern extends Node<ts.ObjectBindingPattern> {
  2220. /** Gets the object binding pattern's elements. */
  2221. getElements(): BindingElement[];
  2222. /** @inheritdoc **/
  2223. getParent(): NodeParentType<ts.ObjectBindingPattern>;
  2224. /** @inheritdoc **/
  2225. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ObjectBindingPattern>>;
  2226. }
  2227. export declare function AbstractableNode<T extends Constructor<AbstractableNodeExtensionType>>(Base: T): Constructor<AbstractableNode> & T;
  2228. export interface AbstractableNode {
  2229. /** Gets if the node is abstract. */
  2230. isAbstract(): boolean;
  2231. /** Gets the abstract keyword or undefined if it doesn't exist. */
  2232. getAbstractKeyword(): Node | undefined;
  2233. /** Gets the abstract keyword or throws if it doesn't exist. */
  2234. getAbstractKeywordOrThrow(message?: string | (() => string)): Node;
  2235. /**
  2236. * Sets if the node is abstract.
  2237. * @param isAbstract - If it should be abstract or not.
  2238. */
  2239. setIsAbstract(isAbstract: boolean): this;
  2240. }
  2241. type AbstractableNodeExtensionType = Node & ModifierableNode;
  2242. export declare function ClassLikeDeclarationBase<T extends Constructor<ClassLikeDeclarationBaseExtensionType>>(Base: T): Constructor<ClassLikeDeclarationBase> & T;
  2243. export interface ClassLikeDeclarationBase extends NameableNode, TextInsertableNode, ImplementsClauseableNode, HeritageClauseableNode, AbstractableNode, JSDocableNode, TypeParameteredNode, DecoratableNode, ModifierableNode, ClassLikeDeclarationBaseSpecific {
  2244. }
  2245. declare function ClassLikeDeclarationBaseSpecific<T extends Constructor<ClassLikeDeclarationBaseSpecificExtensionType>>(Base: T): Constructor<ClassLikeDeclarationBaseSpecific> & T;
  2246. interface ClassLikeDeclarationBaseSpecific {
  2247. /**
  2248. * Sets the extends expression.
  2249. * @param text - Text to set as the extends expression.
  2250. */
  2251. setExtends(text: string | WriterFunction): this;
  2252. /** Removes the extends expression, if it exists. */
  2253. removeExtends(): this;
  2254. /** Gets the extends expression or throws if it doesn't exist. */
  2255. getExtendsOrThrow(message?: string | (() => string)): ExpressionWithTypeArguments;
  2256. /** Gets the extends expression or returns undefined if it doesn't exist. */
  2257. getExtends(): ExpressionWithTypeArguments | undefined;
  2258. /**
  2259. * Inserts a class member.
  2260. * @param member - Class member to insert.
  2261. */
  2262. addMember(member: string | WriterFunction | ClassMemberStructures): ClassMemberTypes | CommentClassElement;
  2263. /**
  2264. * Inserts class members.
  2265. * @param members - Collection of class members to insert.
  2266. */
  2267. addMembers(members: string | WriterFunction | ReadonlyArray<string | WriterFunction | ClassMemberStructures>): (ClassMemberTypes | CommentClassElement)[];
  2268. /**
  2269. * Inserts a class member.
  2270. * @param index - Child index to insert at.
  2271. * @param member - Class member to insert.
  2272. */
  2273. insertMember(index: number, member: string | WriterFunction | ClassMemberStructures): ClassMemberTypes | CommentClassElement;
  2274. /**
  2275. * Inserts class members.
  2276. * @param index - Child index to insert at.
  2277. * @param members - Collection of class members to insert.
  2278. */
  2279. insertMembers(index: number, members: string | WriterFunction | ReadonlyArray<string | WriterFunction | ClassMemberStructures>): (ClassMemberTypes | CommentClassElement)[];
  2280. /**
  2281. * Adds a constructor.
  2282. * @param structure - Structure of the constructor.
  2283. */
  2284. addConstructor(structure?: OptionalKind<ConstructorDeclarationStructure>): ConstructorDeclaration;
  2285. /**
  2286. * Adds constructors.
  2287. * @param structures - Structures of the constructor.
  2288. */
  2289. addConstructors(structures: ReadonlyArray<OptionalKind<ConstructorDeclarationStructure>>): ConstructorDeclaration[];
  2290. /**
  2291. * Inserts a constructor.
  2292. * @param index - Child index to insert at.
  2293. * @param structure - Structure of the constructor.
  2294. */
  2295. insertConstructor(index: number, structure?: OptionalKind<ConstructorDeclarationStructure>): ConstructorDeclaration;
  2296. /**
  2297. * Inserts constructors.
  2298. * @param index - Child index to insert at.
  2299. * @param structures - Structures of the constructor.
  2300. */
  2301. insertConstructors(index: number, structures: ReadonlyArray<OptionalKind<ConstructorDeclarationStructure>>): ConstructorDeclaration[];
  2302. /** Gets the constructor declarations. */
  2303. getConstructors(): ConstructorDeclaration[];
  2304. /**
  2305. * Adds a static block.
  2306. * @param structure - Structure of the static block.
  2307. */
  2308. addStaticBlock(structure?: OptionalKind<ClassStaticBlockDeclarationStructure>): ClassStaticBlockDeclaration;
  2309. /**
  2310. * Adds static block.
  2311. * @param structures - Structures of the static block.
  2312. */
  2313. addStaticBlocks(structures: ReadonlyArray<OptionalKind<ClassStaticBlockDeclarationStructure>>): ClassStaticBlockDeclaration[];
  2314. /**
  2315. * Inserts a static block.
  2316. * @param index - Child index to insert at.
  2317. * @param structure - Structure of the static block.
  2318. */
  2319. insertStaticBlock(index: number, structure?: OptionalKind<ClassStaticBlockDeclarationStructure>): ClassStaticBlockDeclaration;
  2320. /**
  2321. * Inserts static blocks.
  2322. * @param index - Child index to insert at.
  2323. * @param structures - Structures of the static blocks.
  2324. */
  2325. insertStaticBlocks(index: number, structures: ReadonlyArray<OptionalKind<ClassStaticBlockDeclarationStructure>>): ClassStaticBlockDeclaration[];
  2326. /** Gets the static blocks. */
  2327. getStaticBlocks(): ClassStaticBlockDeclaration[];
  2328. /**
  2329. * Add get accessor.
  2330. * @param structure - Structure representing the get accessor.
  2331. */
  2332. addGetAccessor(structure: OptionalKind<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
  2333. /**
  2334. * Add properties.
  2335. * @param structures - Structures representing the properties.
  2336. */
  2337. addGetAccessors(structures: ReadonlyArray<OptionalKind<GetAccessorDeclarationStructure>>): GetAccessorDeclaration[];
  2338. /**
  2339. * Insert get accessor.
  2340. * @param index - Child index to insert at.
  2341. * @param structure - Structure representing the get accessor.
  2342. */
  2343. insertGetAccessor(index: number, structure: OptionalKind<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
  2344. /**
  2345. * Insert properties.
  2346. * @param index - Child index to insert at.
  2347. * @param structures - Structures representing the properties.
  2348. */
  2349. insertGetAccessors(index: number, structures: ReadonlyArray<OptionalKind<GetAccessorDeclarationStructure>>): GetAccessorDeclaration[];
  2350. /**
  2351. * Add set accessor.
  2352. * @param structure - Structure representing the set accessor.
  2353. */
  2354. addSetAccessor(structure: OptionalKind<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
  2355. /**
  2356. * Add properties.
  2357. * @param structures - Structures representing the properties.
  2358. */
  2359. addSetAccessors(structures: ReadonlyArray<OptionalKind<SetAccessorDeclarationStructure>>): SetAccessorDeclaration[];
  2360. /**
  2361. * Insert set accessor.
  2362. * @param index - Child index to insert at.
  2363. * @param structure - Structure representing the set accessor.
  2364. */
  2365. insertSetAccessor(index: number, structure: OptionalKind<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
  2366. /**
  2367. * Insert properties.
  2368. * @param index - Child index to insert at.
  2369. * @param structures - Structures representing the properties.
  2370. */
  2371. insertSetAccessors(index: number, structures: ReadonlyArray<OptionalKind<SetAccessorDeclarationStructure>>): SetAccessorDeclaration[];
  2372. /**
  2373. * Add property.
  2374. * @param structure - Structure representing the property.
  2375. */
  2376. addProperty(structure: OptionalKind<PropertyDeclarationStructure>): PropertyDeclaration;
  2377. /**
  2378. * Add properties.
  2379. * @param structures - Structures representing the properties.
  2380. */
  2381. addProperties(structures: ReadonlyArray<OptionalKind<PropertyDeclarationStructure>>): PropertyDeclaration[];
  2382. /**
  2383. * Insert property.
  2384. * @param index - Child index to insert at.
  2385. * @param structure - Structure representing the property.
  2386. */
  2387. insertProperty(index: number, structure: OptionalKind<PropertyDeclarationStructure>): PropertyDeclaration;
  2388. /**
  2389. * Insert properties.
  2390. * @param index - Child index to insert at.
  2391. * @param structures - Structures representing the properties.
  2392. */
  2393. insertProperties(index: number, structures: ReadonlyArray<OptionalKind<PropertyDeclarationStructure>>): PropertyDeclaration[];
  2394. /**
  2395. * Add method.
  2396. * @param structure - Structure representing the method.
  2397. */
  2398. addMethod(structure: OptionalKind<MethodDeclarationStructure>): MethodDeclaration;
  2399. /**
  2400. * Add methods.
  2401. * @param structures - Structures representing the methods.
  2402. */
  2403. addMethods(structures: ReadonlyArray<OptionalKind<MethodDeclarationStructure>>): MethodDeclaration[];
  2404. /**
  2405. * Insert method.
  2406. * @param index - Child index to insert at.
  2407. * @param structure - Structure representing the method.
  2408. */
  2409. insertMethod(index: number, structure: OptionalKind<MethodDeclarationStructure>): MethodDeclaration;
  2410. /**
  2411. * Insert methods.
  2412. * @param index - Child index to insert at.
  2413. * @param structures - Structures representing the methods.
  2414. */
  2415. insertMethods(index: number, structures: ReadonlyArray<OptionalKind<MethodDeclarationStructure>>): MethodDeclaration[];
  2416. /**
  2417. * Gets the first instance property by name.
  2418. * @param name - Name.
  2419. */
  2420. getInstanceProperty(name: string): ClassInstancePropertyTypes | undefined;
  2421. /**
  2422. * Gets the first instance property by a find function.
  2423. * @param findFunction - Function to find an instance property by.
  2424. */
  2425. getInstanceProperty(findFunction: (prop: ClassInstancePropertyTypes) => boolean): ClassInstancePropertyTypes | undefined;
  2426. /**
  2427. * Gets the first instance property by name or throws if not found.
  2428. * @param name - Name.
  2429. */
  2430. getInstancePropertyOrThrow(name: string): ClassInstancePropertyTypes;
  2431. /**
  2432. * Gets the first instance property by a find function or throws if not found.
  2433. * @param findFunction - Function to find an instance property by.
  2434. */
  2435. getInstancePropertyOrThrow(findFunction: (prop: ClassInstancePropertyTypes) => boolean): ClassInstancePropertyTypes;
  2436. /** Gets the class instance property declarations. */
  2437. getInstanceProperties(): ClassInstancePropertyTypes[];
  2438. /**
  2439. * Gets the first static property by name.
  2440. * @param name - Name.
  2441. */
  2442. getStaticProperty(name: string): ClassStaticPropertyTypes | undefined;
  2443. /**
  2444. * Gets the first static property by a find function.
  2445. * @param findFunction - Function to find a static property by.
  2446. */
  2447. getStaticProperty(findFunction: (prop: ClassStaticPropertyTypes) => boolean): ClassStaticPropertyTypes | undefined;
  2448. /**
  2449. * Gets the first static property by name or throws if not found.
  2450. * @param name - Name.
  2451. */
  2452. getStaticPropertyOrThrow(name: string): ClassStaticPropertyTypes;
  2453. /**
  2454. * Gets the first static property by a find function. or throws if not found.
  2455. * @param findFunction - Function to find a static property by.
  2456. */
  2457. getStaticPropertyOrThrow(findFunction: (prop: ClassStaticPropertyTypes) => boolean): ClassStaticPropertyTypes;
  2458. /** Gets the class instance property declarations. */
  2459. getStaticProperties(): ClassStaticPropertyTypes[];
  2460. /**
  2461. * Gets the first property declaration by name.
  2462. * @param name - Name.
  2463. */
  2464. getProperty(name: string): PropertyDeclaration | undefined;
  2465. /**
  2466. * Gets the first property declaration by a find function.
  2467. * @param findFunction - Function to find a property declaration by.
  2468. */
  2469. getProperty(findFunction: (property: PropertyDeclaration) => boolean): PropertyDeclaration | undefined;
  2470. /**
  2471. * Gets the first property declaration by name or throws if it doesn't exist.
  2472. * @param name - Name.
  2473. */
  2474. getPropertyOrThrow(name: string): PropertyDeclaration;
  2475. /**
  2476. * Gets the first property declaration by a find function or throws if it doesn't exist.
  2477. * @param findFunction - Function to find a property declaration by.
  2478. */
  2479. getPropertyOrThrow(findFunction: (property: PropertyDeclaration) => boolean): PropertyDeclaration;
  2480. /** Gets the class property declarations regardless of whether it's an instance of static property. */
  2481. getProperties(): PropertyDeclaration[];
  2482. /**
  2483. * Gets the first get accessor declaration by name.
  2484. * @param name - Name.
  2485. */
  2486. getGetAccessor(name: string): GetAccessorDeclaration | undefined;
  2487. /**
  2488. * Gets the first get accessor declaration by a find function.
  2489. * @param findFunction - Function to find a get accessor declaration by.
  2490. */
  2491. getGetAccessor(findFunction: (getAccessor: GetAccessorDeclaration) => boolean): GetAccessorDeclaration | undefined;
  2492. /**
  2493. * Gets the first get accessor declaration by name or throws if it doesn't exist.
  2494. * @param name - Name.
  2495. */
  2496. getGetAccessorOrThrow(name: string): GetAccessorDeclaration;
  2497. /**
  2498. * Gets the first get accessor declaration by a find function or throws if it doesn't exist.
  2499. * @param findFunction - Function to find a get accessor declaration by.
  2500. */
  2501. getGetAccessorOrThrow(findFunction: (getAccessor: GetAccessorDeclaration) => boolean): GetAccessorDeclaration;
  2502. /** Gets the class get accessor declarations regardless of whether it's an instance of static getAccessor. */
  2503. getGetAccessors(): GetAccessorDeclaration[];
  2504. /**
  2505. * Sets the first set accessor declaration by name.
  2506. * @param name - Name.
  2507. */
  2508. getSetAccessor(name: string): SetAccessorDeclaration | undefined;
  2509. /**
  2510. * Sets the first set accessor declaration by a find function.
  2511. * @param findFunction - Function to find a set accessor declaration by.
  2512. */
  2513. getSetAccessor(findFunction: (setAccessor: SetAccessorDeclaration) => boolean): SetAccessorDeclaration | undefined;
  2514. /**
  2515. * Sets the first set accessor declaration by name or throws if it doesn't exist.
  2516. * @param name - Name.
  2517. */
  2518. getSetAccessorOrThrow(name: string): SetAccessorDeclaration;
  2519. /**
  2520. * Sets the first set accessor declaration by a find function or throws if it doesn't exist.
  2521. * @param findFunction - Function to find a set accessor declaration by.
  2522. */
  2523. getSetAccessorOrThrow(findFunction: (setAccessor: SetAccessorDeclaration) => boolean): SetAccessorDeclaration;
  2524. /** Sets the class set accessor declarations regardless of whether it's an instance of static setAccessor. */
  2525. getSetAccessors(): SetAccessorDeclaration[];
  2526. /**
  2527. * Gets the first method declaration by name.
  2528. * @param name - Name.
  2529. */
  2530. getMethod(name: string): MethodDeclaration | undefined;
  2531. /**
  2532. * Gets the first method declaration by a find function.
  2533. * @param findFunction - Function to find a method declaration by.
  2534. */
  2535. getMethod(findFunction: (method: MethodDeclaration) => boolean): MethodDeclaration | undefined;
  2536. /**
  2537. * Gets the first method declaration by name or throws if it doesn't exist.
  2538. * @param name - Name.
  2539. */
  2540. getMethodOrThrow(name: string): MethodDeclaration;
  2541. /**
  2542. * Gets the first method declaration by a find function or throws if it doesn't exist.
  2543. * @param findFunction - Function to find a method declaration by.
  2544. */
  2545. getMethodOrThrow(findFunction: (method: MethodDeclaration) => boolean): MethodDeclaration;
  2546. /** Gets the class method declarations regardless of whether it's an instance of static method. */
  2547. getMethods(): MethodDeclaration[];
  2548. /**
  2549. * Gets the first instance method by name.
  2550. * @param name - Name.
  2551. */
  2552. getInstanceMethod(name: string): MethodDeclaration | undefined;
  2553. /**
  2554. * Gets the first instance method by a find function.
  2555. * @param findFunction - Function to find an instance method by.
  2556. */
  2557. getInstanceMethod(findFunction: (method: MethodDeclaration) => boolean): MethodDeclaration | undefined;
  2558. /**
  2559. * Gets the first instance method by name or throws if not found.
  2560. * @param name - Name.
  2561. */
  2562. getInstanceMethodOrThrow(name: string): MethodDeclaration;
  2563. /**
  2564. * Gets the first instance method by a find function. or throws if not found.
  2565. * @param findFunction - Function to find an instance method by.
  2566. */
  2567. getInstanceMethodOrThrow(findFunction: (method: MethodDeclaration) => boolean): MethodDeclaration;
  2568. /** Gets the class instance method declarations. */
  2569. getInstanceMethods(): MethodDeclaration[];
  2570. /**
  2571. * Gets the first static method by name.
  2572. * @param name - Name.
  2573. */
  2574. getStaticMethod(name: string): MethodDeclaration | undefined;
  2575. /**
  2576. * Gets the first static method by a find function.
  2577. * @param findFunction - Function to find a static method by.
  2578. */
  2579. getStaticMethod(findFunction: (method: MethodDeclaration) => boolean): MethodDeclaration | undefined;
  2580. /**
  2581. * Gets the first static method by name or throws if not found.
  2582. * @param name - Name.
  2583. */
  2584. getStaticMethodOrThrow(name: string): MethodDeclaration;
  2585. /**
  2586. * Gets the first static method by a find function. or throws if not found.
  2587. * @param findFunction - Function to find a static method by.
  2588. */
  2589. getStaticMethodOrThrow(findFunction: (method: MethodDeclaration) => boolean): MethodDeclaration;
  2590. /** Gets the class instance method declarations. */
  2591. getStaticMethods(): MethodDeclaration[];
  2592. /**
  2593. * Gets the first instance member by name.
  2594. * @param name - Name.
  2595. */
  2596. getInstanceMember(name: string): ClassInstanceMemberTypes | undefined;
  2597. /**
  2598. * Gets the first instance member by a find function.
  2599. * @param findFunction - Function to find the instance member by.
  2600. */
  2601. getInstanceMember(findFunction: (member: ClassInstanceMemberTypes) => boolean): ClassInstanceMemberTypes | undefined;
  2602. /**
  2603. * Gets the first instance member by name or throws if not found.
  2604. * @param name - Name.
  2605. */
  2606. getInstanceMemberOrThrow(name: string): ClassInstanceMemberTypes;
  2607. /**
  2608. * Gets the first instance member by a find function. or throws if not found.
  2609. * @param findFunction - Function to find the instance member by.
  2610. */
  2611. getInstanceMemberOrThrow(findFunction: (member: ClassInstanceMemberTypes) => boolean): ClassInstanceMemberTypes;
  2612. /** Gets the instance members. */
  2613. getInstanceMembers(): ClassInstanceMemberTypes[];
  2614. /**
  2615. * Gets the first static member by name.
  2616. * @param name - Name.
  2617. */
  2618. getStaticMember(name: string): ClassStaticMemberTypes | undefined;
  2619. /**
  2620. * Gets the first static member by a find function.
  2621. * @param findFunction - Function to find an static method by.
  2622. */
  2623. getStaticMember(findFunction: (member: ClassStaticMemberTypes) => boolean): ClassStaticMemberTypes | undefined;
  2624. /**
  2625. * Gets the first static member by name or throws if not found.
  2626. * @param name - Name.
  2627. */
  2628. getStaticMemberOrThrow(name: string): ClassStaticMemberTypes;
  2629. /**
  2630. * Gets the first static member by a find function. or throws if not found.
  2631. * @param findFunction - Function to find an static method by.
  2632. */
  2633. getStaticMemberOrThrow(findFunction: (member: ClassStaticMemberTypes) => boolean): ClassStaticMemberTypes;
  2634. /** Gets the static members. */
  2635. getStaticMembers(): ClassStaticMemberTypes[];
  2636. /** Gets the class' members regardless of whether it's an instance of static member. */
  2637. getMembers(): ClassMemberTypes[];
  2638. /** Gets the class' members with comment class elements. */
  2639. getMembersWithComments(): (ClassMemberTypes | CommentClassElement)[];
  2640. /**
  2641. * Gets the first member by name.
  2642. * @param name - Name.
  2643. */
  2644. getMember(name: string): ClassMemberTypes | undefined;
  2645. /**
  2646. * Gets the first member by a find function.
  2647. * @param findFunction - Function to find an method by.
  2648. */
  2649. getMember(findFunction: (member: ClassMemberTypes) => boolean): ClassMemberTypes | undefined;
  2650. /**
  2651. * Gets the first member by name or throws if not found.
  2652. * @param name - Name.
  2653. */
  2654. getMemberOrThrow(name: string): ClassMemberTypes;
  2655. /**
  2656. * Gets the first member by a find function. or throws if not found.
  2657. * @param findFunction - Function to find an method by.
  2658. */
  2659. getMemberOrThrow(findFunction: (member: ClassMemberTypes) => boolean): ClassMemberTypes;
  2660. /**
  2661. * Gets the base types.
  2662. *
  2663. * This is useful to use if the base could possibly be a mixin.
  2664. */
  2665. getBaseTypes(): Type[];
  2666. /**
  2667. * Gets the base class or throws.
  2668. *
  2669. * Note: Use getBaseTypes if you need to get the mixins.
  2670. */
  2671. getBaseClassOrThrow(message?: string | (() => string)): ClassDeclaration;
  2672. /**
  2673. * Gets the base class.
  2674. *
  2675. * Note: Use getBaseTypes if you need to get the mixins.
  2676. */
  2677. getBaseClass(): ClassDeclaration | undefined;
  2678. /** Gets all the derived classes. */
  2679. getDerivedClasses(): ClassDeclaration[];
  2680. }
  2681. export type ClassPropertyTypes = PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
  2682. export type ClassInstancePropertyTypes = ClassPropertyTypes | ParameterDeclaration;
  2683. export type ClassInstanceMemberTypes = MethodDeclaration | ClassInstancePropertyTypes;
  2684. export type ClassStaticPropertyTypes = PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
  2685. export type ClassStaticMemberTypes = MethodDeclaration | ClassStaticBlockDeclaration | ClassStaticPropertyTypes;
  2686. export type ClassMemberTypes = MethodDeclaration | PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | ClassStaticBlockDeclaration;
  2687. type ClassLikeDeclarationBaseExtensionType = Node<ts.ClassLikeDeclarationBase>;
  2688. type ClassLikeDeclarationBaseSpecificExtensionType = Node<ts.ClassLikeDeclarationBase> & HeritageClauseableNode & ModifierableNode & NameableNode;
  2689. declare const ClassDeclarationBase: Constructor<ModuleChildableNode> & Constructor<AmbientableNode> & Constructor<ExportableNode> & Constructor<ClassLikeDeclarationBase> & typeof Statement;
  2690. export declare class ClassDeclaration extends ClassDeclarationBase<ts.ClassDeclaration> {
  2691. /**
  2692. * Sets the node from a structure.
  2693. * @param structure - Structure to set the node with.
  2694. */
  2695. set(structure: Partial<ClassDeclarationStructure>): this;
  2696. /** Gets the structure equivalent to this node. */
  2697. getStructure(): ClassDeclarationStructure;
  2698. /**
  2699. * Extracts an interface declaration structure from the class.
  2700. * @param name - Name of the interface. Falls back to the same name as the class and then the filepath's base name.
  2701. */
  2702. extractInterface(name?: string): InterfaceDeclarationStructure;
  2703. /**
  2704. * Extracts an interface declaration structure from the static part of the class.
  2705. * @param name - Name of the interface.
  2706. */
  2707. extractStaticInterface(name: string): InterfaceDeclarationStructure;
  2708. /** @inheritdoc **/
  2709. getParent(): NodeParentType<ts.ClassDeclaration>;
  2710. /** @inheritdoc **/
  2711. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ClassDeclaration>>;
  2712. }
  2713. export declare class ClassElement<T extends ts.ClassElement = ts.ClassElement> extends Node<T> {
  2714. /** Removes the class member. */
  2715. remove(): void;
  2716. }
  2717. declare const ClassExpressionBase: Constructor<ClassLikeDeclarationBase> & typeof PrimaryExpression;
  2718. export declare class ClassExpression extends ClassExpressionBase<ts.ClassExpression> {
  2719. /** @inheritdoc **/
  2720. getParent(): NodeParentType<ts.ClassExpression>;
  2721. /** @inheritdoc **/
  2722. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ClassExpression>>;
  2723. }
  2724. declare const ClassStaticBlockDeclarationBase: Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<StatementedNode> & Constructor<JSDocableNode> & Constructor<BodiedNode> & typeof ClassElement;
  2725. export declare class ClassStaticBlockDeclaration extends ClassStaticBlockDeclarationBase<ts.ClassStaticBlockDeclaration> {
  2726. /**
  2727. * Method that exists for the sake of making code compile that looks for the name of static members.
  2728. * This always returns "static".
  2729. */
  2730. getName(): "static";
  2731. /**
  2732. * Method that exists for the sake of making code compile that looks for this method on class members.
  2733. * This always returns true.
  2734. */
  2735. isStatic(): true;
  2736. /**
  2737. * Sets the node from a structure.
  2738. * @param structure - Structure to set the node with.
  2739. */
  2740. set(structure: Partial<ClassStaticBlockDeclarationStructure>): this;
  2741. /** Gets the structure equivalent to this node. */
  2742. getStructure(): ClassStaticBlockDeclarationStructure;
  2743. /** @inheritdoc **/
  2744. getParent(): NodeParentType<ts.ClassStaticBlockDeclaration>;
  2745. /** @inheritdoc **/
  2746. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ClassStaticBlockDeclaration>>;
  2747. }
  2748. export declare class CommentClassElement extends ClassElement<CompilerCommentClassElement> {
  2749. }
  2750. declare const ConstructorDeclarationBase: Constructor<ReferenceFindableNode> & Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<OverloadableNode> & Constructor<ScopedNode> & Constructor<FunctionLikeDeclaration> & Constructor<BodyableNode> & typeof ClassElement;
  2751. declare const ConstructorDeclarationOverloadBase: Constructor<TypeParameteredNode> & Constructor<JSDocableNode> & Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<ScopedNode> & Constructor<ModifierableNode> & Constructor<SignaturedDeclaration> & typeof ClassElement;
  2752. export declare class ConstructorDeclaration extends ConstructorDeclarationBase<ts.ConstructorDeclaration> {
  2753. /**
  2754. * Sets the node from a structure.
  2755. * @param structure - Structure to set the node with.
  2756. */
  2757. set(structure: Partial<ConstructorDeclarationStructure>): this;
  2758. /**
  2759. * Add a constructor overload.
  2760. * @param structure - Structure to add.
  2761. */
  2762. addOverload(structure: OptionalKind<ConstructorDeclarationOverloadStructure>): ConstructorDeclaration;
  2763. /**
  2764. * Add constructor overloads.
  2765. * @param structures - Structures to add.
  2766. */
  2767. addOverloads(structures: ReadonlyArray<OptionalKind<ConstructorDeclarationOverloadStructure>>): ConstructorDeclaration[];
  2768. /**
  2769. * Inserts a constructor overload.
  2770. * @param index - Child index to insert at.
  2771. * @param structure - Structures to insert.
  2772. */
  2773. insertOverload(index: number, structure: OptionalKind<ConstructorDeclarationOverloadStructure>): ConstructorDeclaration;
  2774. /**
  2775. * Inserts constructor overloads.
  2776. * @param index - Child index to insert at.
  2777. * @param structures - Structures to insert.
  2778. */
  2779. insertOverloads(index: number, structures: ReadonlyArray<OptionalKind<ConstructorDeclarationOverloadStructure>>): ConstructorDeclaration[];
  2780. /** Gets the structure equivalent to this node. */
  2781. getStructure(): ConstructorDeclarationStructure | ConstructorDeclarationOverloadStructure;
  2782. /** @inheritdoc **/
  2783. getParent(): NodeParentType<ts.ConstructorDeclaration>;
  2784. /** @inheritdoc **/
  2785. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ConstructorDeclaration>>;
  2786. }
  2787. declare const GetAccessorDeclarationBase: Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<DecoratableNode> & Constructor<AbstractableNode> & Constructor<ScopedNode> & Constructor<StaticableNode> & Constructor<FunctionLikeDeclaration> & Constructor<BodyableNode> & Constructor<PropertyNamedNode> & typeof ClassElement;
  2788. export declare class GetAccessorDeclaration extends GetAccessorDeclarationBase<ts.GetAccessorDeclaration> {
  2789. /**
  2790. * Sets the node from a structure.
  2791. * @param structure - Structure to set the node with.
  2792. */
  2793. set(structure: Partial<GetAccessorDeclarationStructure>): this;
  2794. /** Gets the corresponding set accessor if one exists. */
  2795. getSetAccessor(): SetAccessorDeclaration | undefined;
  2796. /** Gets the corresponding set accessor or throws if not exists. */
  2797. getSetAccessorOrThrow(message?: string | (() => string)): SetAccessorDeclaration;
  2798. /** Gets the structure equivalent to this node. */
  2799. getStructure(): GetAccessorDeclarationStructure;
  2800. /** @inheritdoc **/
  2801. getParent(): NodeParentType<ts.GetAccessorDeclaration>;
  2802. /** @inheritdoc **/
  2803. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.GetAccessorDeclaration>>;
  2804. }
  2805. declare const MethodDeclarationBase: Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<OverrideableNode> & Constructor<OverloadableNode> & Constructor<BodyableNode> & Constructor<DecoratableNode> & Constructor<AbstractableNode> & Constructor<ScopedNode> & Constructor<QuestionTokenableNode> & Constructor<StaticableNode> & Constructor<AsyncableNode> & Constructor<GeneratorableNode> & Constructor<FunctionLikeDeclaration> & Constructor<PropertyNamedNode> & typeof ClassElement;
  2806. declare const MethodDeclarationOverloadBase: Constructor<JSDocableNode> & Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<OverrideableNode> & Constructor<ScopedNode> & Constructor<TypeParameteredNode> & Constructor<AbstractableNode> & Constructor<QuestionTokenableNode> & Constructor<StaticableNode> & Constructor<AsyncableNode> & Constructor<ModifierableNode> & Constructor<GeneratorableNode> & Constructor<SignaturedDeclaration> & typeof ClassElement;
  2807. export declare class MethodDeclaration extends MethodDeclarationBase<ts.MethodDeclaration> {
  2808. /**
  2809. * Sets the node from a structure.
  2810. * @param structure - Structure to set the node with.
  2811. */
  2812. set(structure: Partial<MethodDeclarationStructure>): this;
  2813. /**
  2814. * Add a method overload.
  2815. * @param structure - Structure to add.
  2816. */
  2817. addOverload(structure: OptionalKind<MethodDeclarationOverloadStructure>): MethodDeclaration;
  2818. /**
  2819. * Add method overloads.
  2820. * @param structures - Structures to add.
  2821. */
  2822. addOverloads(structures: ReadonlyArray<OptionalKind<MethodDeclarationOverloadStructure>>): MethodDeclaration[];
  2823. /**
  2824. * Inserts a method overload.
  2825. * @param index - Child index to insert at.
  2826. * @param structure - Structures to insert.
  2827. */
  2828. insertOverload(index: number, structure: OptionalKind<MethodDeclarationOverloadStructure>): MethodDeclaration;
  2829. /**
  2830. * Inserts method overloads.
  2831. * @param index - Child index to insert at.
  2832. * @param structures - Structures to insert.
  2833. */
  2834. insertOverloads(index: number, structures: ReadonlyArray<OptionalKind<MethodDeclarationOverloadStructure>>): MethodDeclaration[];
  2835. /** Gets the structure equivalent to this node. */
  2836. getStructure(): MethodDeclarationStructure | MethodDeclarationOverloadStructure;
  2837. /** @inheritdoc **/
  2838. getParent(): NodeParentType<ts.MethodDeclaration>;
  2839. /** @inheritdoc **/
  2840. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.MethodDeclaration>>;
  2841. }
  2842. declare const PropertyDeclarationBase: Constructor<ChildOrderableNode> & Constructor<OverrideableNode> & Constructor<AmbientableNode> & Constructor<DecoratableNode> & Constructor<AbstractableNode> & Constructor<ScopedNode> & Constructor<StaticableNode> & Constructor<JSDocableNode> & Constructor<ReadonlyableNode> & Constructor<ExclamationTokenableNode> & Constructor<QuestionTokenableNode> & Constructor<InitializerExpressionableNode> & Constructor<TypedNode> & Constructor<PropertyNamedNode> & Constructor<ModifierableNode> & typeof ClassElement;
  2843. export declare class PropertyDeclaration extends PropertyDeclarationBase<ts.PropertyDeclaration> {
  2844. /** Gets if this property declaration has an accessor keyword. */
  2845. hasAccessorKeyword(): boolean;
  2846. /** Sets if this property declaration should have an accessor keyword. */
  2847. setHasAccessorKeyword(value: boolean): this;
  2848. /**
  2849. * Sets the node from a structure.
  2850. * @param structure - Structure to set the node with.
  2851. */
  2852. set(structure: Partial<PropertyDeclarationStructure>): this;
  2853. /** Removes the property. */
  2854. remove(): void;
  2855. /** Gets the structure equivalent to this node. */
  2856. getStructure(): PropertyDeclarationStructure;
  2857. /** @inheritdoc **/
  2858. getParent(): NodeParentType<ts.PropertyDeclaration>;
  2859. /** @inheritdoc **/
  2860. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PropertyDeclaration>>;
  2861. }
  2862. declare const SetAccessorDeclarationBase: Constructor<ChildOrderableNode> & Constructor<TextInsertableNode> & Constructor<DecoratableNode> & Constructor<AbstractableNode> & Constructor<ScopedNode> & Constructor<StaticableNode> & Constructor<FunctionLikeDeclaration> & Constructor<BodyableNode> & Constructor<PropertyNamedNode> & typeof ClassElement;
  2863. export declare class SetAccessorDeclaration extends SetAccessorDeclarationBase<ts.SetAccessorDeclaration> {
  2864. /**
  2865. * Sets the node from a structure.
  2866. * @param structure - Structure to set the node with.
  2867. */
  2868. set(structure: Partial<SetAccessorDeclarationStructure>): this;
  2869. /** Gets the corresponding get accessor if one exists. */
  2870. getGetAccessor(): GetAccessorDeclaration | undefined;
  2871. /** Gets the corresponding get accessor or throws if not exists. */
  2872. getGetAccessorOrThrow(message?: string | (() => string)): GetAccessorDeclaration;
  2873. /** Gets the structure equivalent to this node. */
  2874. getStructure(): SetAccessorDeclarationStructure;
  2875. /** @inheritdoc **/
  2876. getParent(): NodeParentType<ts.SetAccessorDeclaration>;
  2877. /** @inheritdoc **/
  2878. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SetAccessorDeclaration>>;
  2879. }
  2880. export declare class CommentRange extends TextRange<ts.CommentRange> {
  2881. private constructor();
  2882. /** Gets the comment syntax kind. */
  2883. getKind(): ts.CommentKind;
  2884. }
  2885. export declare abstract class CompilerCommentNode implements ts.Node {
  2886. #private;
  2887. pos: number;
  2888. end: number;
  2889. kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia;
  2890. flags: ts.NodeFlags;
  2891. modifiers?: ts.NodeArray<ts.Modifier> | undefined;
  2892. parent: ts.Node;
  2893. protected constructor();
  2894. getSourceFile(): ts.SourceFile;
  2895. getChildCount(sourceFile?: ts.SourceFile | undefined): number;
  2896. getChildAt(index: number, sourceFile?: ts.SourceFile | undefined): ts.Node;
  2897. getChildren(sourceFile?: ts.SourceFile | undefined): ts.Node[];
  2898. getStart(sourceFile?: ts.SourceFile | undefined, includeJsDocComment?: boolean | undefined): number;
  2899. getFullStart(): number;
  2900. getEnd(): number;
  2901. getWidth(sourceFile?: ts.SourceFileLike | undefined): number;
  2902. getFullWidth(): number;
  2903. getLeadingTriviaWidth(sourceFile?: ts.SourceFile | undefined): number;
  2904. getFullText(sourceFile?: ts.SourceFile | undefined): string;
  2905. getText(sourceFile?: ts.SourceFile | undefined): string;
  2906. getFirstToken(sourceFile?: ts.SourceFile | undefined): ts.Node | undefined;
  2907. getLastToken(sourceFile?: ts.SourceFile | undefined): ts.Node | undefined;
  2908. forEachChild<T>(cbNode: (node: ts.Node) => T | undefined, cbNodeArray?: ((nodes: ts.NodeArray<ts.Node>) => T | undefined) | undefined): T | undefined;
  2909. }
  2910. export declare class CompilerCommentStatement extends CompilerCommentNode implements ts.Statement {
  2911. _jsdocContainerBrand: any;
  2912. _statementBrand: any;
  2913. }
  2914. export declare class CompilerCommentClassElement extends CompilerCommentNode implements ts.ClassElement {
  2915. _classElementBrand: any;
  2916. _declarationBrand: any;
  2917. }
  2918. export declare class CompilerCommentTypeElement extends CompilerCommentNode implements ts.TypeElement {
  2919. _typeElementBrand: any;
  2920. _declarationBrand: any;
  2921. }
  2922. export declare class CompilerCommentObjectLiteralElement extends CompilerCommentNode implements ts.ObjectLiteralElement {
  2923. _declarationBrand: any;
  2924. _objectLiteralBrand: any;
  2925. declarationBrand: any;
  2926. }
  2927. export declare class CompilerCommentEnumMember extends CompilerCommentNode implements ts.Node {
  2928. }
  2929. export type NodePropertyToWrappedType<NodeType extends ts.Node, KeyName extends keyof NodeType, NonNullableNodeType = NonNullable<NodeType[KeyName]>> = NodeType[KeyName] extends ts.NodeArray<infer ArrayNodeTypeForNullable> | undefined ? CompilerNodeToWrappedType<ArrayNodeTypeForNullable>[] | undefined : NodeType[KeyName] extends ts.NodeArray<infer ArrayNodeType> ? CompilerNodeToWrappedType<ArrayNodeType>[] : NodeType[KeyName] extends ts.Node ? CompilerNodeToWrappedType<NodeType[KeyName]> : NonNullableNodeType extends ts.Node ? CompilerNodeToWrappedType<NonNullableNodeType> | undefined : NodeType[KeyName];
  2930. export type NodeParentType<NodeType extends ts.Node> = NodeType extends ts.SourceFile ? undefined : ts.Node extends NodeType ? CompilerNodeToWrappedType<NodeType["parent"]> | undefined : CompilerNodeToWrappedType<NodeType["parent"]>;
  2931. export declare class Node<NodeType extends ts.Node = ts.Node> {
  2932. #private;
  2933. /** Gets if the node is an AnyKeyword. */
  2934. static readonly isAnyKeyword: (node: Node | undefined) => node is Expression;
  2935. /** Gets if the node is an ArrayBindingPattern. */
  2936. static readonly isArrayBindingPattern: (node: Node | undefined) => node is ArrayBindingPattern;
  2937. /** Gets if the node is an ArrayLiteralExpression. */
  2938. static readonly isArrayLiteralExpression: (node: Node | undefined) => node is ArrayLiteralExpression;
  2939. /** Gets if the node is an ArrowFunction. */
  2940. static readonly isArrowFunction: (node: Node | undefined) => node is ArrowFunction;
  2941. /** Gets if the node is an AsExpression. */
  2942. static readonly isAsExpression: (node: Node | undefined) => node is AsExpression;
  2943. /** Gets if the node is an AwaitExpression. */
  2944. static readonly isAwaitExpression: (node: Node | undefined) => node is AwaitExpression;
  2945. /** Gets if the node is a BigIntLiteral. */
  2946. static readonly isBigIntLiteral: (node: Node | undefined) => node is BigIntLiteral;
  2947. /** Gets if the node is a BinaryExpression. */
  2948. static readonly isBinaryExpression: (node: Node | undefined) => node is BinaryExpression;
  2949. /** Gets if the node is a BindingElement. */
  2950. static readonly isBindingElement: (node: Node | undefined) => node is BindingElement;
  2951. /** Gets if the node is a Block. */
  2952. static readonly isBlock: (node: Node | undefined) => node is Block;
  2953. /** Gets if the node is a BooleanKeyword. */
  2954. static readonly isBooleanKeyword: (node: Node | undefined) => node is Expression;
  2955. /** Gets if the node is a BreakStatement. */
  2956. static readonly isBreakStatement: (node: Node | undefined) => node is BreakStatement;
  2957. /** Gets if the node is a CallExpression. */
  2958. static readonly isCallExpression: (node: Node | undefined) => node is CallExpression;
  2959. /** Gets if the node is a CaseBlock. */
  2960. static readonly isCaseBlock: (node: Node | undefined) => node is CaseBlock;
  2961. /** Gets if the node is a CaseClause. */
  2962. static readonly isCaseClause: (node: Node | undefined) => node is CaseClause;
  2963. /** Gets if the node is a CatchClause. */
  2964. static readonly isCatchClause: (node: Node | undefined) => node is CatchClause;
  2965. /** Gets if the node is a ClassDeclaration. */
  2966. static readonly isClassDeclaration: (node: Node | undefined) => node is ClassDeclaration;
  2967. /** Gets if the node is a ClassExpression. */
  2968. static readonly isClassExpression: (node: Node | undefined) => node is ClassExpression;
  2969. /** Gets if the node is a ClassStaticBlockDeclaration. */
  2970. static readonly isClassStaticBlockDeclaration: (node: Node | undefined) => node is ClassStaticBlockDeclaration;
  2971. /** Gets if the node is a CommaListExpression. */
  2972. static readonly isCommaListExpression: (node: Node | undefined) => node is CommaListExpression;
  2973. /** Gets if the node is a ComputedPropertyName. */
  2974. static readonly isComputedPropertyName: (node: Node | undefined) => node is ComputedPropertyName;
  2975. /** Gets if the node is a ConditionalExpression. */
  2976. static readonly isConditionalExpression: (node: Node | undefined) => node is ConditionalExpression;
  2977. /** Gets if the node is a ContinueStatement. */
  2978. static readonly isContinueStatement: (node: Node | undefined) => node is ContinueStatement;
  2979. /** Gets if the node is a DebuggerStatement. */
  2980. static readonly isDebuggerStatement: (node: Node | undefined) => node is DebuggerStatement;
  2981. /** Gets if the node is a Decorator. */
  2982. static readonly isDecorator: (node: Node | undefined) => node is Decorator;
  2983. /** Gets if the node is a DefaultClause. */
  2984. static readonly isDefaultClause: (node: Node | undefined) => node is DefaultClause;
  2985. /** Gets if the node is a DeleteExpression. */
  2986. static readonly isDeleteExpression: (node: Node | undefined) => node is DeleteExpression;
  2987. /** Gets if the node is a DoStatement. */
  2988. static readonly isDoStatement: (node: Node | undefined) => node is DoStatement;
  2989. /** Gets if the node is an ElementAccessExpression. */
  2990. static readonly isElementAccessExpression: (node: Node | undefined) => node is ElementAccessExpression;
  2991. /** Gets if the node is an EmptyStatement. */
  2992. static readonly isEmptyStatement: (node: Node | undefined) => node is EmptyStatement;
  2993. /** Gets if the node is an EnumDeclaration. */
  2994. static readonly isEnumDeclaration: (node: Node | undefined) => node is EnumDeclaration;
  2995. /** Gets if the node is an EnumMember. */
  2996. static readonly isEnumMember: (node: Node | undefined) => node is EnumMember;
  2997. /** Gets if the node is an ExportAssignment. */
  2998. static readonly isExportAssignment: (node: Node | undefined) => node is ExportAssignment;
  2999. /** Gets if the node is an ExportDeclaration. */
  3000. static readonly isExportDeclaration: (node: Node | undefined) => node is ExportDeclaration;
  3001. /** Gets if the node is an ExportSpecifier. */
  3002. static readonly isExportSpecifier: (node: Node | undefined) => node is ExportSpecifier;
  3003. /** Gets if the node is an ExpressionStatement. */
  3004. static readonly isExpressionStatement: (node: Node | undefined) => node is ExpressionStatement;
  3005. /** Gets if the node is an ExpressionWithTypeArguments. */
  3006. static readonly isExpressionWithTypeArguments: (node: Node | undefined) => node is ExpressionWithTypeArguments;
  3007. /** Gets if the node is an ExternalModuleReference. */
  3008. static readonly isExternalModuleReference: (node: Node | undefined) => node is ExternalModuleReference;
  3009. /** Gets if the node is a ForInStatement. */
  3010. static readonly isForInStatement: (node: Node | undefined) => node is ForInStatement;
  3011. /** Gets if the node is a ForOfStatement. */
  3012. static readonly isForOfStatement: (node: Node | undefined) => node is ForOfStatement;
  3013. /** Gets if the node is a ForStatement. */
  3014. static readonly isForStatement: (node: Node | undefined) => node is ForStatement;
  3015. /** Gets if the node is a FunctionDeclaration. */
  3016. static readonly isFunctionDeclaration: (node: Node | undefined) => node is FunctionDeclaration;
  3017. /** Gets if the node is a FunctionExpression. */
  3018. static readonly isFunctionExpression: (node: Node | undefined) => node is FunctionExpression;
  3019. /** Gets if the node is a HeritageClause. */
  3020. static readonly isHeritageClause: (node: Node | undefined) => node is HeritageClause;
  3021. /** Gets if the node is a Identifier. */
  3022. static readonly isIdentifier: (node: Node | undefined) => node is Identifier;
  3023. /** Gets if the node is a IfStatement. */
  3024. static readonly isIfStatement: (node: Node | undefined) => node is IfStatement;
  3025. /** Gets if the node is a ImportAttribute. */
  3026. static readonly isImportAttribute: (node: Node | undefined) => node is ImportAttribute;
  3027. /** Gets if the node is a ImportAttributes. */
  3028. static readonly isImportAttributes: (node: Node | undefined) => node is ImportAttributes;
  3029. /** Gets if the node is a ImportClause. */
  3030. static readonly isImportClause: (node: Node | undefined) => node is ImportClause;
  3031. /** Gets if the node is a ImportDeclaration. */
  3032. static readonly isImportDeclaration: (node: Node | undefined) => node is ImportDeclaration;
  3033. /** Gets if the node is a ImportEqualsDeclaration. */
  3034. static readonly isImportEqualsDeclaration: (node: Node | undefined) => node is ImportEqualsDeclaration;
  3035. /** Gets if the node is a ImportSpecifier. */
  3036. static readonly isImportSpecifier: (node: Node | undefined) => node is ImportSpecifier;
  3037. /** Gets if the node is a InferKeyword. */
  3038. static readonly isInferKeyword: (node: Node | undefined) => node is Node<ts.Token<SyntaxKind.InferKeyword>>;
  3039. /** Gets if the node is a InterfaceDeclaration. */
  3040. static readonly isInterfaceDeclaration: (node: Node | undefined) => node is InterfaceDeclaration;
  3041. /** Gets if the node is a JSDoc. */
  3042. static readonly isJSDoc: (node: Node | undefined) => node is JSDoc;
  3043. /** Gets if the node is a JSDocAllType. */
  3044. static readonly isJSDocAllType: (node: Node | undefined) => node is JSDocAllType;
  3045. /** Gets if the node is a JSDocAugmentsTag. */
  3046. static readonly isJSDocAugmentsTag: (node: Node | undefined) => node is JSDocAugmentsTag;
  3047. /** Gets if the node is a JSDocAuthorTag. */
  3048. static readonly isJSDocAuthorTag: (node: Node | undefined) => node is JSDocAuthorTag;
  3049. /** Gets if the node is a JSDocCallbackTag. */
  3050. static readonly isJSDocCallbackTag: (node: Node | undefined) => node is JSDocCallbackTag;
  3051. /** Gets if the node is a JSDocClassTag. */
  3052. static readonly isJSDocClassTag: (node: Node | undefined) => node is JSDocClassTag;
  3053. /** Gets if the node is a JSDocDeprecatedTag. */
  3054. static readonly isJSDocDeprecatedTag: (node: Node | undefined) => node is JSDocDeprecatedTag;
  3055. /** Gets if the node is a JSDocEnumTag. */
  3056. static readonly isJSDocEnumTag: (node: Node | undefined) => node is JSDocEnumTag;
  3057. /** Gets if the node is a JSDocFunctionType. */
  3058. static readonly isJSDocFunctionType: (node: Node | undefined) => node is JSDocFunctionType;
  3059. /** Gets if the node is a JSDocImplementsTag. */
  3060. static readonly isJSDocImplementsTag: (node: Node | undefined) => node is JSDocImplementsTag;
  3061. /** Gets if the node is a JSDocLink. */
  3062. static readonly isJSDocLink: (node: Node | undefined) => node is JSDocLink;
  3063. /** Gets if the node is a JSDocLinkCode. */
  3064. static readonly isJSDocLinkCode: (node: Node | undefined) => node is JSDocLinkCode;
  3065. /** Gets if the node is a JSDocLinkPlain. */
  3066. static readonly isJSDocLinkPlain: (node: Node | undefined) => node is JSDocLinkPlain;
  3067. /** Gets if the node is a JSDocMemberName. */
  3068. static readonly isJSDocMemberName: (node: Node | undefined) => node is JSDocMemberName;
  3069. /** Gets if the node is a JSDocNamepathType. */
  3070. static readonly isJSDocNamepathType: (node: Node | undefined) => node is JSDocNamepathType;
  3071. /** Gets if the node is a JSDocNameReference. */
  3072. static readonly isJSDocNameReference: (node: Node | undefined) => node is JSDocNameReference;
  3073. /** Gets if the node is a JSDocNonNullableType. */
  3074. static readonly isJSDocNonNullableType: (node: Node | undefined) => node is JSDocNonNullableType;
  3075. /** Gets if the node is a JSDocNullableType. */
  3076. static readonly isJSDocNullableType: (node: Node | undefined) => node is JSDocNullableType;
  3077. /** Gets if the node is a JSDocOptionalType. */
  3078. static readonly isJSDocOptionalType: (node: Node | undefined) => node is JSDocOptionalType;
  3079. /** Gets if the node is a JSDocOverloadTag. */
  3080. static readonly isJSDocOverloadTag: (node: Node | undefined) => node is JSDocOverloadTag;
  3081. /** Gets if the node is a JSDocOverrideTag. */
  3082. static readonly isJSDocOverrideTag: (node: Node | undefined) => node is JSDocOverrideTag;
  3083. /** Gets if the node is a JSDocParameterTag. */
  3084. static readonly isJSDocParameterTag: (node: Node | undefined) => node is JSDocParameterTag;
  3085. /** Gets if the node is a JSDocPrivateTag. */
  3086. static readonly isJSDocPrivateTag: (node: Node | undefined) => node is JSDocPrivateTag;
  3087. /** Gets if the node is a JSDocPropertyTag. */
  3088. static readonly isJSDocPropertyTag: (node: Node | undefined) => node is JSDocPropertyTag;
  3089. /** Gets if the node is a JSDocProtectedTag. */
  3090. static readonly isJSDocProtectedTag: (node: Node | undefined) => node is JSDocProtectedTag;
  3091. /** Gets if the node is a JSDocPublicTag. */
  3092. static readonly isJSDocPublicTag: (node: Node | undefined) => node is JSDocPublicTag;
  3093. /** Gets if the node is a JSDocReadonlyTag. */
  3094. static readonly isJSDocReadonlyTag: (node: Node | undefined) => node is JSDocReadonlyTag;
  3095. /** Gets if the node is a JSDocReturnTag. */
  3096. static readonly isJSDocReturnTag: (node: Node | undefined) => node is JSDocReturnTag;
  3097. /** Gets if the node is a JSDocSatisfiesTag. */
  3098. static readonly isJSDocSatisfiesTag: (node: Node | undefined) => node is JSDocSatisfiesTag;
  3099. /** Gets if the node is a JSDocSeeTag. */
  3100. static readonly isJSDocSeeTag: (node: Node | undefined) => node is JSDocSeeTag;
  3101. /** Gets if the node is a JSDocSignature. */
  3102. static readonly isJSDocSignature: (node: Node | undefined) => node is JSDocSignature;
  3103. /** Gets if the node is a JSDocTemplateTag. */
  3104. static readonly isJSDocTemplateTag: (node: Node | undefined) => node is JSDocTemplateTag;
  3105. /** Gets if the node is a JSDocText. */
  3106. static readonly isJSDocText: (node: Node | undefined) => node is JSDocText;
  3107. /** Gets if the node is a JSDocThisTag. */
  3108. static readonly isJSDocThisTag: (node: Node | undefined) => node is JSDocThisTag;
  3109. /** Gets if the node is a JSDocThrowsTag. */
  3110. static readonly isJSDocThrowsTag: (node: Node | undefined) => node is JSDocThrowsTag;
  3111. /** Gets if the node is a JSDocTypedefTag. */
  3112. static readonly isJSDocTypedefTag: (node: Node | undefined) => node is JSDocTypedefTag;
  3113. /** Gets if the node is a JSDocTypeExpression. */
  3114. static readonly isJSDocTypeExpression: (node: Node | undefined) => node is JSDocTypeExpression;
  3115. /** Gets if the node is a JSDocTypeLiteral. */
  3116. static readonly isJSDocTypeLiteral: (node: Node | undefined) => node is JSDocTypeLiteral;
  3117. /** Gets if the node is a JSDocTypeTag. */
  3118. static readonly isJSDocTypeTag: (node: Node | undefined) => node is JSDocTypeTag;
  3119. /** Gets if the node is a JSDocUnknownType. */
  3120. static readonly isJSDocUnknownType: (node: Node | undefined) => node is JSDocUnknownType;
  3121. /** Gets if the node is a JSDocVariadicType. */
  3122. static readonly isJSDocVariadicType: (node: Node | undefined) => node is JSDocVariadicType;
  3123. /** Gets if the node is a JsxAttribute. */
  3124. static readonly isJsxAttribute: (node: Node | undefined) => node is JsxAttribute;
  3125. /** Gets if the node is a JsxClosingElement. */
  3126. static readonly isJsxClosingElement: (node: Node | undefined) => node is JsxClosingElement;
  3127. /** Gets if the node is a JsxClosingFragment. */
  3128. static readonly isJsxClosingFragment: (node: Node | undefined) => node is JsxClosingFragment;
  3129. /** Gets if the node is a JsxElement. */
  3130. static readonly isJsxElement: (node: Node | undefined) => node is JsxElement;
  3131. /** Gets if the node is a JsxExpression. */
  3132. static readonly isJsxExpression: (node: Node | undefined) => node is JsxExpression;
  3133. /** Gets if the node is a JsxFragment. */
  3134. static readonly isJsxFragment: (node: Node | undefined) => node is JsxFragment;
  3135. /** Gets if the node is a JsxNamespacedName. */
  3136. static readonly isJsxNamespacedName: (node: Node | undefined) => node is JsxNamespacedName;
  3137. /** Gets if the node is a JsxOpeningElement. */
  3138. static readonly isJsxOpeningElement: (node: Node | undefined) => node is JsxOpeningElement;
  3139. /** Gets if the node is a JsxOpeningFragment. */
  3140. static readonly isJsxOpeningFragment: (node: Node | undefined) => node is JsxOpeningFragment;
  3141. /** Gets if the node is a JsxSelfClosingElement. */
  3142. static readonly isJsxSelfClosingElement: (node: Node | undefined) => node is JsxSelfClosingElement;
  3143. /** Gets if the node is a JsxSpreadAttribute. */
  3144. static readonly isJsxSpreadAttribute: (node: Node | undefined) => node is JsxSpreadAttribute;
  3145. /** Gets if the node is a JsxText. */
  3146. static readonly isJsxText: (node: Node | undefined) => node is JsxText;
  3147. /** Gets if the node is a LabeledStatement. */
  3148. static readonly isLabeledStatement: (node: Node | undefined) => node is LabeledStatement;
  3149. /** Gets if the node is a MetaProperty. */
  3150. static readonly isMetaProperty: (node: Node | undefined) => node is MetaProperty;
  3151. /** Gets if the node is a MethodDeclaration. */
  3152. static readonly isMethodDeclaration: (node: Node | undefined) => node is MethodDeclaration;
  3153. /** Gets if the node is a MethodSignature. */
  3154. static readonly isMethodSignature: (node: Node | undefined) => node is MethodSignature;
  3155. /** Gets if the node is a ModuleBlock. */
  3156. static readonly isModuleBlock: (node: Node | undefined) => node is ModuleBlock;
  3157. /** Gets if the node is a ModuleDeclaration. */
  3158. static readonly isModuleDeclaration: (node: Node | undefined) => node is ModuleDeclaration;
  3159. /** Gets if the node is a NamedExports. */
  3160. static readonly isNamedExports: (node: Node | undefined) => node is NamedExports;
  3161. /** Gets if the node is a NamedImports. */
  3162. static readonly isNamedImports: (node: Node | undefined) => node is NamedImports;
  3163. /** Gets if the node is a NamedTupleMember. */
  3164. static readonly isNamedTupleMember: (node: Node | undefined) => node is NamedTupleMember;
  3165. /** Gets if the node is a NamespaceExport. */
  3166. static readonly isNamespaceExport: (node: Node | undefined) => node is NamespaceExport;
  3167. /** Gets if the node is a NamespaceImport. */
  3168. static readonly isNamespaceImport: (node: Node | undefined) => node is NamespaceImport;
  3169. /** Gets if the node is a NeverKeyword. */
  3170. static readonly isNeverKeyword: (node: Node | undefined) => node is Node<ts.Token<SyntaxKind.NeverKeyword>>;
  3171. /** Gets if the node is a NewExpression. */
  3172. static readonly isNewExpression: (node: Node | undefined) => node is NewExpression;
  3173. /** Gets if the node is a NonNullExpression. */
  3174. static readonly isNonNullExpression: (node: Node | undefined) => node is NonNullExpression;
  3175. /** Gets if the node is a NoSubstitutionTemplateLiteral. */
  3176. static readonly isNoSubstitutionTemplateLiteral: (node: Node | undefined) => node is NoSubstitutionTemplateLiteral;
  3177. /** Gets if the node is a NotEmittedStatement. */
  3178. static readonly isNotEmittedStatement: (node: Node | undefined) => node is NotEmittedStatement;
  3179. /** Gets if the node is a NumberKeyword. */
  3180. static readonly isNumberKeyword: (node: Node | undefined) => node is Expression;
  3181. /** Gets if the node is a NumericLiteral. */
  3182. static readonly isNumericLiteral: (node: Node | undefined) => node is NumericLiteral;
  3183. /** Gets if the node is a ObjectBindingPattern. */
  3184. static readonly isObjectBindingPattern: (node: Node | undefined) => node is ObjectBindingPattern;
  3185. /** Gets if the node is a ObjectKeyword. */
  3186. static readonly isObjectKeyword: (node: Node | undefined) => node is Expression;
  3187. /** Gets if the node is a ObjectLiteralExpression. */
  3188. static readonly isObjectLiteralExpression: (node: Node | undefined) => node is ObjectLiteralExpression;
  3189. /** Gets if the node is a OmittedExpression. */
  3190. static readonly isOmittedExpression: (node: Node | undefined) => node is OmittedExpression;
  3191. /** Gets if the node is a ParenthesizedExpression. */
  3192. static readonly isParenthesizedExpression: (node: Node | undefined) => node is ParenthesizedExpression;
  3193. /** Gets if the node is a PartiallyEmittedExpression. */
  3194. static readonly isPartiallyEmittedExpression: (node: Node | undefined) => node is PartiallyEmittedExpression;
  3195. /** Gets if the node is a PostfixUnaryExpression. */
  3196. static readonly isPostfixUnaryExpression: (node: Node | undefined) => node is PostfixUnaryExpression;
  3197. /** Gets if the node is a PrefixUnaryExpression. */
  3198. static readonly isPrefixUnaryExpression: (node: Node | undefined) => node is PrefixUnaryExpression;
  3199. /** Gets if the node is a PrivateIdentifier. */
  3200. static readonly isPrivateIdentifier: (node: Node | undefined) => node is PrivateIdentifier;
  3201. /** Gets if the node is a PropertyAccessExpression. */
  3202. static readonly isPropertyAccessExpression: (node: Node | undefined) => node is PropertyAccessExpression;
  3203. /** Gets if the node is a PropertyAssignment. */
  3204. static readonly isPropertyAssignment: (node: Node | undefined) => node is PropertyAssignment;
  3205. /** Gets if the node is a PropertyDeclaration. */
  3206. static readonly isPropertyDeclaration: (node: Node | undefined) => node is PropertyDeclaration;
  3207. /** Gets if the node is a PropertySignature. */
  3208. static readonly isPropertySignature: (node: Node | undefined) => node is PropertySignature;
  3209. /** Gets if the node is a QualifiedName. */
  3210. static readonly isQualifiedName: (node: Node | undefined) => node is QualifiedName;
  3211. /** Gets if the node is a RegularExpressionLiteral. */
  3212. static readonly isRegularExpressionLiteral: (node: Node | undefined) => node is RegularExpressionLiteral;
  3213. /** Gets if the node is a ReturnStatement. */
  3214. static readonly isReturnStatement: (node: Node | undefined) => node is ReturnStatement;
  3215. /** Gets if the node is a SatisfiesExpression. */
  3216. static readonly isSatisfiesExpression: (node: Node | undefined) => node is SatisfiesExpression;
  3217. /** Gets if the node is a SemicolonToken. */
  3218. static readonly isSemicolonToken: (node: Node | undefined) => node is Node<ts.Token<SyntaxKind.SemicolonToken>>;
  3219. /** Gets if the node is a ShorthandPropertyAssignment. */
  3220. static readonly isShorthandPropertyAssignment: (node: Node | undefined) => node is ShorthandPropertyAssignment;
  3221. /** Gets if the node is a SourceFile. */
  3222. static readonly isSourceFile: (node: Node | undefined) => node is SourceFile;
  3223. /** Gets if the node is a SpreadAssignment. */
  3224. static readonly isSpreadAssignment: (node: Node | undefined) => node is SpreadAssignment;
  3225. /** Gets if the node is a SpreadElement. */
  3226. static readonly isSpreadElement: (node: Node | undefined) => node is SpreadElement;
  3227. /** Gets if the node is a StringKeyword. */
  3228. static readonly isStringKeyword: (node: Node | undefined) => node is Expression;
  3229. /** Gets if the node is a StringLiteral. */
  3230. static readonly isStringLiteral: (node: Node | undefined) => node is StringLiteral;
  3231. /** Gets if the node is a SwitchStatement. */
  3232. static readonly isSwitchStatement: (node: Node | undefined) => node is SwitchStatement;
  3233. /** Gets if the node is a SymbolKeyword. */
  3234. static readonly isSymbolKeyword: (node: Node | undefined) => node is Expression;
  3235. /** Gets if the node is a SyntaxList. */
  3236. static readonly isSyntaxList: (node: Node | undefined) => node is SyntaxList;
  3237. /** Gets if the node is a TaggedTemplateExpression. */
  3238. static readonly isTaggedTemplateExpression: (node: Node | undefined) => node is TaggedTemplateExpression;
  3239. /** Gets if the node is a TemplateExpression. */
  3240. static readonly isTemplateExpression: (node: Node | undefined) => node is TemplateExpression;
  3241. /** Gets if the node is a TemplateHead. */
  3242. static readonly isTemplateHead: (node: Node | undefined) => node is TemplateHead;
  3243. /** Gets if the node is a TemplateMiddle. */
  3244. static readonly isTemplateMiddle: (node: Node | undefined) => node is TemplateMiddle;
  3245. /** Gets if the node is a TemplateSpan. */
  3246. static readonly isTemplateSpan: (node: Node | undefined) => node is TemplateSpan;
  3247. /** Gets if the node is a TemplateTail. */
  3248. static readonly isTemplateTail: (node: Node | undefined) => node is TemplateTail;
  3249. /** Gets if the node is a ThrowStatement. */
  3250. static readonly isThrowStatement: (node: Node | undefined) => node is ThrowStatement;
  3251. /** Gets if the node is a TryStatement. */
  3252. static readonly isTryStatement: (node: Node | undefined) => node is TryStatement;
  3253. /** Gets if the node is a TypeAliasDeclaration. */
  3254. static readonly isTypeAliasDeclaration: (node: Node | undefined) => node is TypeAliasDeclaration;
  3255. /** Gets if the node is a TypeOfExpression. */
  3256. static readonly isTypeOfExpression: (node: Node | undefined) => node is TypeOfExpression;
  3257. /** Gets if the node is a UndefinedKeyword. */
  3258. static readonly isUndefinedKeyword: (node: Node | undefined) => node is Expression;
  3259. /** Gets if the node is a VariableDeclaration. */
  3260. static readonly isVariableDeclaration: (node: Node | undefined) => node is VariableDeclaration;
  3261. /** Gets if the node is a VariableDeclarationList. */
  3262. static readonly isVariableDeclarationList: (node: Node | undefined) => node is VariableDeclarationList;
  3263. /** Gets if the node is a VariableStatement. */
  3264. static readonly isVariableStatement: (node: Node | undefined) => node is VariableStatement;
  3265. /** Gets if the node is a VoidExpression. */
  3266. static readonly isVoidExpression: (node: Node | undefined) => node is VoidExpression;
  3267. /** Gets if the node is a WhileStatement. */
  3268. static readonly isWhileStatement: (node: Node | undefined) => node is WhileStatement;
  3269. /** Gets if the node is a WithStatement. */
  3270. static readonly isWithStatement: (node: Node | undefined) => node is WithStatement;
  3271. /** Gets if the node is a YieldExpression. */
  3272. static readonly isYieldExpression: (node: Node | undefined) => node is YieldExpression;
  3273. protected constructor();
  3274. /** Gets the underlying compiler node. */
  3275. get compilerNode(): NodeType;
  3276. /**
  3277. * Releases the node and all its descendants from the underlying node cache and ast.
  3278. *
  3279. * This is useful if you want to improve the performance of manipulation by not tracking this node anymore.
  3280. */
  3281. forget(): void;
  3282. /** Forgets the descendants of this node. */
  3283. forgetDescendants(): void;
  3284. /**
  3285. * Gets if the compiler node was forgotten.
  3286. *
  3287. * This will be true when the compiler node was forgotten or removed.
  3288. */
  3289. wasForgotten(): boolean;
  3290. /** Gets the syntax kind. */
  3291. getKind(): SyntaxKind;
  3292. /** Gets the syntax kind name. */
  3293. getKindName(): string;
  3294. /** Gets the node's flags. */
  3295. getFlags(): ts.NodeFlags;
  3296. /**
  3297. * Prints the node using the compiler's printer.
  3298. * @param options - Options.
  3299. */
  3300. print(options?: PrintNodeOptions): string;
  3301. /** Gets the symbol or throws an error if it doesn't exist. */
  3302. getSymbolOrThrow(message?: string | (() => string)): Symbol;
  3303. /** Gets the compiler symbol or undefined if it doesn't exist. */
  3304. getSymbol(): Symbol | undefined;
  3305. /**
  3306. * Gets the symbols in the scope of the node.
  3307. *
  3308. * Note: This will always return the local symbols. If you want the export symbol from a local symbol, then
  3309. * use the `#getExportSymbol()` method on the symbol.
  3310. * @param meaning - Meaning of symbol to filter by.
  3311. */
  3312. getSymbolsInScope(meaning: SymbolFlags): Symbol[];
  3313. /**
  3314. * Gets the specified local symbol by name or throws if it doesn't exist.
  3315. *
  3316. * WARNING: The symbol table of locals is not exposed publicly by the compiler. Use this at your own risk knowing it may break.
  3317. * @param name - Name of the local symbol.
  3318. */
  3319. getLocalOrThrow(name: string, message?: string | (() => string)): Symbol;
  3320. /**
  3321. * Gets the specified local symbol by name or returns undefined if it doesn't exist.
  3322. *
  3323. * WARNING: The symbol table of locals is not exposed publicly by the compiler. Use this at your own risk knowing it may break.
  3324. * @param name - Name of the local symbol.
  3325. */
  3326. getLocal(name: string): Symbol | undefined;
  3327. /**
  3328. * Gets the symbols within the current scope.
  3329. *
  3330. * WARNING: The symbol table of locals is not exposed publicly by the compiler. Use this at your own risk knowing it may break.
  3331. */
  3332. getLocals(): Symbol[];
  3333. /** Gets the type of the node. */
  3334. getType(): Type;
  3335. /**
  3336. * If the node contains the provided range (inclusive).
  3337. * @param pos - Start position.
  3338. * @param end - End position.
  3339. */
  3340. containsRange(pos: number, end: number): boolean;
  3341. /**
  3342. * Gets if the specified position is within a string.
  3343. * @param pos - Position.
  3344. */
  3345. isInStringAtPos(pos: number): boolean;
  3346. /**
  3347. * Gets the node as the specified kind if it is equal to that kind, otherwise throws.
  3348. * @param kind - Syntax kind.
  3349. */
  3350. asKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3351. /**
  3352. * Returns if the node is the specified kind.
  3353. *
  3354. * This is a type guard.
  3355. * @param kind - Syntax kind.
  3356. */
  3357. isKind<TKind extends SyntaxKind>(kind: TKind): this is KindToNodeMappings[TKind];
  3358. /**
  3359. * Gets the node as the specified kind if it is equal to that kind, otherwise returns undefined.
  3360. * @param kind - Syntax kind.
  3361. */
  3362. asKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3363. /**
  3364. * Gets the first child by a condition or throws.
  3365. * @param condition - Condition.
  3366. */
  3367. getFirstChildOrThrow<T extends Node>(condition?: (node: Node) => node is T, message?: string | (() => string)): T;
  3368. /**
  3369. * Gets the first child by a condition or throws.
  3370. * @param condition - Condition.
  3371. */
  3372. getFirstChildOrThrow(condition?: (node: Node) => boolean, message?: string | (() => string)): Node;
  3373. /**
  3374. * Gets the first child by a condition.
  3375. * @param condition - Condition.
  3376. */
  3377. getFirstChild<T extends Node>(condition?: (node: Node) => node is T): T | undefined;
  3378. /**
  3379. * Gets the first child by a condition.
  3380. * @param condition - Condition.
  3381. */
  3382. getFirstChild(condition?: (node: Node) => boolean): Node | undefined;
  3383. /**
  3384. * Gets the last child by a condition or throws.
  3385. * @param condition - Condition.
  3386. */
  3387. getLastChildOrThrow<T extends Node>(condition?: (node: Node) => node is T, message?: string | (() => string)): T;
  3388. /**
  3389. * Gets the last child by a condition or throws.
  3390. * @param condition - Condition.
  3391. */
  3392. getLastChildOrThrow(condition?: (node: Node) => boolean, message?: string | (() => string)): Node;
  3393. /**
  3394. * Gets the last child by a condition.
  3395. * @param condition - Condition.
  3396. */
  3397. getLastChild<T extends Node>(condition?: (node: Node) => node is T): T | undefined;
  3398. /**
  3399. * Gets the last child by a condition.
  3400. * @param condition - Condition.
  3401. */
  3402. getLastChild(condition?: (node: Node) => boolean): Node | undefined;
  3403. /**
  3404. * Gets the first descendant by a condition or throws.
  3405. * @param condition - Condition.
  3406. */
  3407. getFirstDescendantOrThrow<T extends Node>(condition?: (node: Node) => node is T, message?: string | (() => string)): T;
  3408. /**
  3409. * Gets the first descendant by a condition or throws.
  3410. * @param condition - Condition.
  3411. */
  3412. getFirstDescendantOrThrow(condition?: (node: Node) => boolean, message?: string | (() => string)): Node;
  3413. /**
  3414. * Gets the first descendant by a condition.
  3415. * @param condition - Condition.
  3416. */
  3417. getFirstDescendant<T extends Node>(condition?: (node: Node) => node is T): T | undefined;
  3418. /**
  3419. * Gets the first descendant by a condition.
  3420. * @param condition - Condition.
  3421. */
  3422. getFirstDescendant(condition?: (node: Node) => boolean): Node | undefined;
  3423. /**
  3424. * Gets the previous sibling or throws.
  3425. * @param condition - Optional condition for getting the previous sibling.
  3426. */
  3427. getPreviousSiblingOrThrow<T extends Node>(condition?: (node: Node) => node is T, message?: string | (() => string)): T;
  3428. /**
  3429. * Gets the previous sibling or throws.
  3430. * @param condition - Optional condition for getting the previous sibling.
  3431. */
  3432. getPreviousSiblingOrThrow(condition?: (node: Node) => boolean, message?: string | (() => string)): Node;
  3433. /**
  3434. * Gets the previous sibling.
  3435. * @param condition - Optional condition for getting the previous sibling.
  3436. */
  3437. getPreviousSibling<T extends Node>(condition?: (node: Node) => node is T): T | undefined;
  3438. /**
  3439. * Gets the previous sibling.
  3440. * @param condition - Optional condition for getting the previous sibling.
  3441. */
  3442. getPreviousSibling(condition?: (node: Node) => boolean): Node | undefined;
  3443. /**
  3444. * Gets the next sibling or throws.
  3445. * @param condition - Optional condition for getting the next sibling.
  3446. */
  3447. getNextSiblingOrThrow<T extends Node>(condition?: (node: Node) => node is T, message?: string | (() => string)): T;
  3448. /**
  3449. * Gets the next sibling or throws.
  3450. * @param condition - Optional condition for getting the next sibling.
  3451. */
  3452. getNextSiblingOrThrow(condition?: (node: Node) => boolean, message?: string | (() => string)): Node;
  3453. /**
  3454. * Gets the next sibling.
  3455. * @param condition - Optional condition for getting the next sibling.
  3456. */
  3457. getNextSibling<T extends Node>(condition?: (node: Node) => node is T): T | undefined;
  3458. /**
  3459. * Gets the next sibling.
  3460. * @param condition - Optional condition for getting the next sibling.
  3461. */
  3462. getNextSibling(condition?: (node: Node) => boolean): Node | undefined;
  3463. /**
  3464. * Gets the previous siblings.
  3465. *
  3466. * Note: Closest sibling is the zero index.
  3467. */
  3468. getPreviousSiblings(): Node[];
  3469. /**
  3470. * Gets the next siblings.
  3471. *
  3472. * Note: Closest sibling is the zero index.
  3473. */
  3474. getNextSiblings(): Node[];
  3475. /** Gets all the children of the node. */
  3476. getChildren(): Node[];
  3477. /**
  3478. * Gets the child at the specified index.
  3479. * @param index - Index of the child.
  3480. */
  3481. getChildAtIndex(index: number): Node;
  3482. /** Gets the child syntax list or throws if it doesn't exist. */
  3483. getChildSyntaxListOrThrow(message?: string | (() => string)): SyntaxList;
  3484. /** Gets the child syntax list if it exists. */
  3485. getChildSyntaxList(): SyntaxList | undefined;
  3486. /**
  3487. * Invokes the `cbNode` callback for each child and the `cbNodeArray` for every array of nodes stored in properties of the node.
  3488. * If `cbNodeArray` is not defined, then it will pass every element of the array to `cbNode`.
  3489. * @returns The first truthy value returned by a callback.
  3490. * @param cbNode - Callback invoked for each child.
  3491. * @param cbNodeArray - Callback invoked for each array of nodes.
  3492. */
  3493. forEachChild<T>(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: Node[]) => T | undefined): T | undefined;
  3494. /**
  3495. * Invokes the `cbNode` callback for each descendant and the `cbNodeArray` for every array of nodes stored in properties of the node and descendant nodes.
  3496. * If `cbNodeArray` is not defined, then it will pass every element of the array to `cbNode`.
  3497. *
  3498. * @returns The first truthy value returned by a callback.
  3499. * @remarks There exists a `traversal` object on the second parameter that allows various control of iteration.
  3500. * @param cbNode - Callback invoked for each descendant.
  3501. * @param cbNodeArray - Callback invoked for each array of nodes.
  3502. */
  3503. forEachDescendant<T>(cbNode: (node: Node, traversal: ForEachDescendantTraversalControl) => T | undefined, cbNodeArray?: (nodes: Node[], traversal: ForEachDescendantTraversalControl) => T | undefined): T | undefined;
  3504. /** Gets the child nodes passed to the delegate of `node.forEachChild(child => {})` as an array. */
  3505. forEachChildAsArray(): Node<ts.Node>[];
  3506. /** Gets the descendant nodes passed to the delegate of `node.forEachDescendant(descendant => {})` as an array. */
  3507. forEachDescendantAsArray(): Node<ts.Node>[];
  3508. /** Gets the node's descendants. */
  3509. getDescendants(): Node[];
  3510. /** Gets the node's descendant statements and any arrow function statement-like expressions (ex. returns the expression `5` in `() => 5`). */
  3511. getDescendantStatements(): (Statement | Expression)[];
  3512. /** Gets the number of children the node has. */
  3513. getChildCount(): number;
  3514. /**
  3515. * Gets the child at the provided text position, or undefined if not found.
  3516. * @param pos - Text position to search for.
  3517. */
  3518. getChildAtPos(pos: number): Node | undefined;
  3519. /**
  3520. * Gets the most specific descendant at the provided text position, or undefined if not found.
  3521. * @param pos - Text position to search for.
  3522. */
  3523. getDescendantAtPos(pos: number): Node | undefined;
  3524. /**
  3525. * Gets the most specific descendant at the provided start text position with the specified width, or undefined if not found.
  3526. * @param start - Start text position to search for.
  3527. * @param width - Text length of the node to search for.
  3528. */
  3529. getDescendantAtStartWithWidth(start: number, width: number): Node | undefined;
  3530. /** Gets the source file text position where the node starts that includes the leading trivia (comments and whitespace). */
  3531. getPos(): number;
  3532. /**
  3533. * Gets the source file text position where the node ends.
  3534. *
  3535. * @remarks This does not include the following trivia (comments and whitespace).
  3536. */
  3537. getEnd(): number;
  3538. /**
  3539. * Gets the source file text position where the node starts that does not include the leading trivia (comments and whitespace).
  3540. * @param includeJsDocComments - Whether to include the JS doc comments.
  3541. */
  3542. getStart(includeJsDocComments?: boolean): number;
  3543. /** Gets the source file text position of the end of the last significant token or the start of the source file. */
  3544. getFullStart(): number;
  3545. /** Gets the first source file text position that is not whitespace taking into account comment nodes and a previous node's trailing trivia. */
  3546. getNonWhitespaceStart(): number;
  3547. /**
  3548. * Gets the text length of the node without trivia.
  3549. * @param includeJsDocComments - Whether to include the JS doc comments in the width or not.
  3550. */
  3551. getWidth(includeJsDocComments?: boolean): number;
  3552. /** Gets the text length of the node with trivia. */
  3553. getFullWidth(): number;
  3554. /** Gets the node's leading trivia's text length. */
  3555. getLeadingTriviaWidth(): number;
  3556. /** Gets the text length from the end of the current node to the next significant token or new line. */
  3557. getTrailingTriviaWidth(): number;
  3558. /** Gets the text position of the next significant token or new line. */
  3559. getTrailingTriviaEnd(): number;
  3560. /**
  3561. * Gets the text without leading trivia (comments and whitespace).
  3562. * @param includeJsDocComments - Whether to include the js doc comments when getting the text.
  3563. */
  3564. getText(includeJsDocComments?: boolean): string;
  3565. /**
  3566. * Gets the text without leading trivia (comments and whitespace).
  3567. * @param options - Options for getting the text.
  3568. */
  3569. getText(options: {
  3570. trimLeadingIndentation?: boolean;
  3571. includeJsDocComments?: boolean;
  3572. }): string;
  3573. /** Gets the full text with leading trivia (comments and whitespace). */
  3574. getFullText(): string;
  3575. /** Gets the combined modifier flags. */
  3576. getCombinedModifierFlags(): ts.ModifierFlags;
  3577. /** Gets the source file. */
  3578. getSourceFile(): SourceFile;
  3579. /** Gets the project. */
  3580. getProject(): Project;
  3581. /**
  3582. * Gets a compiler node property wrapped in a Node.
  3583. * @param propertyName - Property name.
  3584. */
  3585. getNodeProperty<KeyType extends keyof LocalNodeType, LocalNodeType extends ts.Node = NodeType>(propertyName: KeyType): NodePropertyToWrappedType<LocalNodeType, KeyType>;
  3586. /** Goes up the tree getting all the parents in ascending order. */
  3587. getAncestors(): Node[];
  3588. /** Get the node's parent. */
  3589. getParent(): Node<ts.Node> | undefined;
  3590. /** Gets the parent or throws an error if it doesn't exist. */
  3591. getParentOrThrow(message?: string | (() => string)): Node<ts.Node>;
  3592. /**
  3593. * Goes up the parents (ancestors) of the node while a condition is true.
  3594. * Throws if the initial parent doesn't match the condition.
  3595. * @param condition - Condition that tests the parent to see if the expression is true.
  3596. */
  3597. getParentWhileOrThrow<T extends Node>(condition: (parent: Node, node: Node) => parent is T, message?: string | (() => string)): T;
  3598. /**
  3599. * Goes up the parents (ancestors) of the node while a condition is true.
  3600. * Throws if the initial parent doesn't match the condition.
  3601. * @param condition - Condition that tests the parent to see if the expression is true.
  3602. */
  3603. getParentWhileOrThrow(condition: (parent: Node, node: Node) => boolean, message?: string | (() => string)): Node;
  3604. /**
  3605. * Goes up the parents (ancestors) of the node while a condition is true.
  3606. * Returns undefined if the initial parent doesn't match the condition.
  3607. * @param condition - Condition that tests the parent to see if the expression is true.
  3608. */
  3609. getParentWhile<T extends Node>(condition: (parent: Node, child: Node) => parent is T): T | undefined;
  3610. /**
  3611. * Goes up the parents (ancestors) of the node while a condition is true.
  3612. * Returns undefined if the initial parent doesn't match the condition.
  3613. * @param condition - Condition that tests the parent to see if the expression is true.
  3614. */
  3615. getParentWhile(condition: (parent: Node, child: Node) => boolean): Node | undefined;
  3616. /**
  3617. * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind.
  3618. * Throws if the initial parent is not the specified syntax kind.
  3619. * @param kind - Syntax kind to check for.
  3620. */
  3621. getParentWhileKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3622. /**
  3623. * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind.
  3624. * Returns undefined if the initial parent is not the specified syntax kind.
  3625. * @param kind - Syntax kind to check for.
  3626. */
  3627. getParentWhileKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3628. /** Gets the last token of this node. Usually this is a close brace. */
  3629. getLastToken(): Node;
  3630. /** Gets if this node is in a syntax list. */
  3631. isInSyntaxList(): boolean;
  3632. /** Gets the parent if it's a syntax list or throws an error otherwise. */
  3633. getParentSyntaxListOrThrow(message?: string | (() => string)): SyntaxList;
  3634. /** Gets the parent if it's a syntax list. */
  3635. getParentSyntaxList(): SyntaxList | undefined;
  3636. /** Gets the child index of this node relative to the parent. */
  3637. getChildIndex(): number;
  3638. /** Gets the indentation level of the current node. */
  3639. getIndentationLevel(): number;
  3640. /** Gets the child indentation level of the current node. */
  3641. getChildIndentationLevel(): number;
  3642. /**
  3643. * Gets the indentation text.
  3644. * @param offset - Optional number of levels of indentation to add or remove.
  3645. */
  3646. getIndentationText(offset?: number): string;
  3647. /**
  3648. * Gets the next indentation level text.
  3649. * @param offset - Optional number of levels of indentation to add or remove.
  3650. */
  3651. getChildIndentationText(offset?: number): string;
  3652. /**
  3653. * Gets the position of the start of the line that this node starts on.
  3654. * @param includeJsDocComments - Whether to include the JS doc comments or not.
  3655. */
  3656. getStartLinePos(includeJsDocComments?: boolean): number;
  3657. /**
  3658. * Gets the line number at the start of the node.
  3659. * @param includeJsDocComments - Whether to include the JS doc comments or not.
  3660. */
  3661. getStartLineNumber(includeJsDocComments?: boolean): number;
  3662. /** Gets the line number of the end of the node. */
  3663. getEndLineNumber(): number;
  3664. /** Gets if this is the first node on the current line. */
  3665. isFirstNodeOnLine(): boolean;
  3666. /**
  3667. * Replaces the text of the current node with new text.
  3668. *
  3669. * This will forget the current node and return a new node that can be asserted or type guarded to the correct type.
  3670. * @param textOrWriterFunction - Text or writer function to replace with.
  3671. * @returns The new node.
  3672. * @remarks This will replace the text from the `Node#getStart(true)` position (start position with js docs) to `Node#getEnd()`.
  3673. * Use `Node#getText(true)` to get all the text that will be replaced.
  3674. */
  3675. replaceWithText(textOrWriterFunction: string | WriterFunction): Node;
  3676. /**
  3677. * Prepends the specified whitespace to current node.
  3678. * @param textOrWriterFunction - Text or writer function.
  3679. */
  3680. prependWhitespace(textOrWriterFunction: string | WriterFunction): void;
  3681. /**
  3682. * Appends the specified whitespace to current node.
  3683. * @param textOrWriterFunction - Text or writer function.
  3684. */
  3685. appendWhitespace(textOrWriterFunction: string | WriterFunction): void;
  3686. /**
  3687. * Formats the node's text using the internal TypeScript formatting API.
  3688. * @param settings - Format code settings.
  3689. */
  3690. formatText(settings?: FormatCodeSettings): void;
  3691. /**
  3692. * Transforms the node using the compiler api nodes and functions and returns
  3693. * the node that was transformed (experimental).
  3694. *
  3695. * WARNING: This will forget descendants of transformed nodes and potentially this node.
  3696. * @example Increments all the numeric literals in a source file.
  3697. * ```ts
  3698. * sourceFile.transform(traversal => {
  3699. * const node = traversal.visitChildren(); // recommend always visiting the children first (post order)
  3700. * if (ts.isNumericLiteral(node))
  3701. * return ts.createNumericLiteral((parseInt(node.text, 10) + 1).toString());
  3702. * return node;
  3703. * });
  3704. * ```
  3705. * @example Updates the class declaration node without visiting the children.
  3706. * ```ts
  3707. * const classDec = sourceFile.getClassOrThrow("MyClass");
  3708. * classDec.transform(traversal => {
  3709. * const node = traversal.currentNode;
  3710. * return ts.updateClassDeclaration(node, undefined, undefined, ts.createIdentifier("MyUpdatedClass"), undefined, undefined, []);
  3711. * });
  3712. * ```
  3713. */
  3714. transform(visitNode: (traversal: TransformTraversalControl) => ts.Node): Node;
  3715. /** Gets the leading comment ranges of the current node. */
  3716. getLeadingCommentRanges(): CommentRange[];
  3717. /** Gets the trailing comment ranges of the current node. */
  3718. getTrailingCommentRanges(): CommentRange[];
  3719. /**
  3720. * Gets the children based on a kind.
  3721. * @param kind - Syntax kind.
  3722. */
  3723. getChildrenOfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind][];
  3724. /**
  3725. * Gets the first child by syntax kind or throws an error if not found.
  3726. * @param kind - Syntax kind.
  3727. */
  3728. getFirstChildByKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3729. /**
  3730. * Gets the first child by syntax kind.
  3731. * @param kind - Syntax kind.
  3732. */
  3733. getFirstChildByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3734. /**
  3735. * Gets the first child if it matches the specified syntax kind or throws an error if not found.
  3736. * @param kind - Syntax kind.
  3737. */
  3738. getFirstChildIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3739. /**
  3740. * Gets the first child if it matches the specified syntax kind.
  3741. * @param kind - Syntax kind.
  3742. */
  3743. getFirstChildIfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3744. /**
  3745. * Gets the last child by syntax kind or throws an error if not found.
  3746. * @param kind - Syntax kind.
  3747. */
  3748. getLastChildByKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3749. /**
  3750. * Gets the last child by syntax kind.
  3751. * @param kind - Syntax kind.
  3752. */
  3753. getLastChildByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3754. /**
  3755. * Gets the last child if it matches the specified syntax kind or throws an error if not found.
  3756. * @param kind - Syntax kind.
  3757. */
  3758. getLastChildIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3759. /**
  3760. * Gets the last child if it matches the specified syntax kind.
  3761. * @param kind - Syntax kind.
  3762. */
  3763. getLastChildIfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3764. /**
  3765. * Gets the child at the specified index if it's the specified kind or throws an exception.
  3766. * @param index - Child index to get.
  3767. * @param kind - Expected kind.
  3768. */
  3769. getChildAtIndexIfKindOrThrow<TKind extends SyntaxKind>(index: number, kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3770. /**
  3771. * Gets the child at the specified index if it's the specified kind or returns undefined.
  3772. * @param index - Child index to get.
  3773. * @param kind - Expected kind.
  3774. */
  3775. getChildAtIndexIfKind<TKind extends SyntaxKind>(index: number, kind: TKind): KindToNodeMappings[TKind] | undefined;
  3776. /**
  3777. * Gets the previous sibiling if it matches the specified kind, or throws.
  3778. * @param kind - Kind to check.
  3779. */
  3780. getPreviousSiblingIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3781. /**
  3782. * Gets the next sibiling if it matches the specified kind, or throws.
  3783. * @param kind - Kind to check.
  3784. */
  3785. getNextSiblingIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3786. /**
  3787. * Gets the previous sibling if it matches the specified kind.
  3788. * @param kind - Kind to check.
  3789. */
  3790. getPreviousSiblingIfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3791. /**
  3792. * Gets the next sibling if it matches the specified kind.
  3793. * @param kind - Kind to check.
  3794. */
  3795. getNextSiblingIfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3796. /** Gets the parent if it matches a certain condition or throws. */
  3797. getParentIfOrThrow<T extends Node>(condition: (parent: Node | undefined, node: Node) => parent is T, message?: string | (() => string)): T;
  3798. /** Gets the parent if it matches a certain condition or throws. */
  3799. getParentIfOrThrow(condition: (parent: Node | undefined, node: Node) => boolean, message?: string | (() => string)): Node;
  3800. /** Gets the parent if it matches a certain condition. */
  3801. getParentIf<T extends Node>(condition: (parent: Node | undefined, node: Node) => parent is T): T | undefined;
  3802. /** Gets the parent if it matches a certain condition. */
  3803. getParentIf(condition: (parent: Node | undefined, node: Node) => boolean): Node | undefined;
  3804. /** Gets the parent if it's a certain syntax kind or throws. */
  3805. getParentIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3806. /** Gets the parent if it's a certain syntax kind. */
  3807. getParentIfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3808. /**
  3809. * Gets the first ancestor by syntax kind or throws if not found.
  3810. * @param kind - Syntax kind.
  3811. */
  3812. getFirstAncestorByKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3813. /**
  3814. * Get the first ancestor by syntax kind.
  3815. * @param kind - Syntax kind.
  3816. */
  3817. getFirstAncestorByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3818. /**
  3819. * Gets the first ancestor that matches the provided condition or throws if not found.
  3820. * @param condition - Condition to match.
  3821. */
  3822. getFirstAncestorOrThrow<T extends Node>(condition?: (node: Node) => node is T): T;
  3823. /**
  3824. * Gets the first ancestor that matches the provided condition or throws if not found.
  3825. * @param condition - Condition to match.
  3826. */
  3827. getFirstAncestorOrThrow(condition?: (node: Node) => boolean): Node;
  3828. /**
  3829. * Gets the first ancestor that matches the provided condition or returns undefined if not found.
  3830. * @param condition - Condition to match.
  3831. */
  3832. getFirstAncestor<T extends Node>(condition?: (node: Node) => node is T): T | undefined;
  3833. /**
  3834. * Gets the first ancestor that matches the provided condition or returns undefined if not found.
  3835. * @param condition - Condition to match.
  3836. */
  3837. getFirstAncestor(condition?: (node: Node) => boolean): Node | undefined;
  3838. /**
  3839. * Gets the descendants that match a specified syntax kind.
  3840. * @param kind - Kind to check.
  3841. */
  3842. getDescendantsOfKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind][];
  3843. /**
  3844. * Gets the first descendant by syntax kind or throws.
  3845. * @param kind - Syntax kind.
  3846. */
  3847. getFirstDescendantByKindOrThrow<TKind extends SyntaxKind>(kind: TKind, message?: string | (() => string)): KindToNodeMappings[TKind];
  3848. /**
  3849. * Gets the first descendant by syntax kind.
  3850. * @param kind - Syntax kind.
  3851. */
  3852. getFirstDescendantByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappings[TKind] | undefined;
  3853. /**
  3854. * Gets if the node has an expression.
  3855. * @param node - Node to check.
  3856. */
  3857. static hasExpression<T extends Node>(node: T): node is T & {
  3858. getExpression(): Expression;
  3859. };
  3860. /**
  3861. * Gets if the node has a name.
  3862. * @param node - Node to check.
  3863. */
  3864. static hasName<T extends Node>(node: T): node is T & {
  3865. getName(): string;
  3866. getNameNode(): Node;
  3867. };
  3868. /**
  3869. * Gets if the node has a body.
  3870. * @param node - Node to check.
  3871. */
  3872. static hasBody<T extends Node>(node: T): node is T & {
  3873. getBody(): Node;
  3874. };
  3875. /**
  3876. * Gets if the node has a structure.
  3877. * @param node - Node to check.
  3878. */
  3879. static hasStructure<T extends Node>(node: T): node is T & {
  3880. getStructure(): Structures;
  3881. };
  3882. /** Creates a type guard for syntax kinds. */
  3883. static is<TKind extends keyof KindToNodeMappings>(kind: TKind): (node: Node | undefined) => node is KindToNodeMappings[TKind];
  3884. /** Gets if the provided value is a Node. */
  3885. static isNode(value: unknown): value is Node;
  3886. /** Gets if the provided node is a comment node. */
  3887. static isCommentNode(node: Node | undefined): node is CommentStatement | CommentClassElement | CommentTypeElement | CommentObjectLiteralElement | CommentEnumMember;
  3888. /** Gets if the provided node is a CommentStatement. */
  3889. static isCommentStatement(node: Node | undefined): node is CommentStatement;
  3890. /** Gets if the provided node is a CommentClassElement. */
  3891. static isCommentClassElement(node: Node | undefined): node is CommentClassElement;
  3892. /** Gets if the provided value is a CommentTypeElement. */
  3893. static isCommentTypeElement(node: Node | undefined): node is CommentTypeElement;
  3894. /** Gets if the provided node is a CommentObjectLiteralElement. */
  3895. static isCommentObjectLiteralElement(node: Node | undefined): node is CommentObjectLiteralElement;
  3896. /** Gets if the provided node is a CommentEnumMember. */
  3897. static isCommentEnumMember(node: Node | undefined): node is CommentEnumMember;
  3898. /** Gets if the node is an AbstractableNode. */
  3899. static isAbstractable<T extends Node>(node: T | undefined): node is AbstractableNode & AbstractableNodeExtensionType & T;
  3900. /** Gets if the node is an AmbientableNode. */
  3901. static isAmbientable<T extends Node>(node: T | undefined): node is AmbientableNode & AmbientableNodeExtensionType & T;
  3902. /** Gets if the node is an ArgumentedNode. */
  3903. static isArgumented<T extends Node>(node: T | undefined): node is ArgumentedNode & ArgumentedNodeExtensionType & T;
  3904. /** Gets if the node is an ArrayTypeNode. */
  3905. static isArrayTypeNode(node: Node | undefined): node is ArrayTypeNode;
  3906. /** Gets if the node is an AsyncableNode. */
  3907. static isAsyncable<T extends Node>(node: T | undefined): node is AsyncableNode & AsyncableNodeExtensionType & T;
  3908. /** Gets if the node is an AwaitableNode. */
  3909. static isAwaitable<T extends Node>(node: T | undefined): node is AwaitableNode & AwaitableNodeExtensionType & T;
  3910. /** Gets if the node is a BindingNamedNode. */
  3911. static isBindingNamed<T extends Node>(node: T | undefined): node is BindingNamedNode & BindingNamedNodeExtensionType & T;
  3912. /** Gets if the node is a BodiedNode. */
  3913. static isBodied<T extends Node>(node: T | undefined): node is BodiedNode & BodiedNodeExtensionType & T;
  3914. /** Gets if the node is a BodyableNode. */
  3915. static isBodyable<T extends Node>(node: T | undefined): node is BodyableNode & BodyableNodeExtensionType & T;
  3916. /** Gets if the node is a CallSignatureDeclaration. */
  3917. static isCallSignatureDeclaration(node: Node | undefined): node is CallSignatureDeclaration;
  3918. /** Gets if the node is a ChildOrderableNode. */
  3919. static isChildOrderable<T extends Node>(node: T | undefined): node is ChildOrderableNode & ChildOrderableNodeExtensionType & T;
  3920. /** Gets if the node is a ClassLikeDeclarationBase. */
  3921. static isClassLikeDeclarationBase<T extends Node>(node: T | undefined): node is ClassLikeDeclarationBase & ClassLikeDeclarationBaseExtensionType & T;
  3922. /** Gets if the node is a ConditionalTypeNode. */
  3923. static isConditionalTypeNode(node: Node | undefined): node is ConditionalTypeNode;
  3924. /** Gets if the node is a ConstructorDeclaration. */
  3925. static isConstructorDeclaration(node: Node | undefined): node is ConstructorDeclaration;
  3926. /** Gets if the node is a ConstructorTypeNode. */
  3927. static isConstructorTypeNode(node: Node | undefined): node is ConstructorTypeNode;
  3928. /** Gets if the node is a ConstructSignatureDeclaration. */
  3929. static isConstructSignatureDeclaration(node: Node | undefined): node is ConstructSignatureDeclaration;
  3930. /** Gets if the node is a DecoratableNode. */
  3931. static isDecoratable<T extends Node>(node: T | undefined): node is DecoratableNode & DecoratableNodeExtensionType & T;
  3932. /** Gets if the node is a DotDotDotTokenableNode. */
  3933. static isDotDotDotTokenable<T extends Node>(node: T | undefined): node is DotDotDotTokenableNode & DotDotDotTokenableNodeExtensionType & T;
  3934. /** Gets if the node is an ExclamationTokenableNode. */
  3935. static isExclamationTokenable<T extends Node>(node: T | undefined): node is ExclamationTokenableNode & ExclamationTokenableNodeExtensionType & T;
  3936. /** Gets if the node is an ExportableNode. */
  3937. static isExportable<T extends Node>(node: T | undefined): node is ExportableNode & ExportableNodeExtensionType & T;
  3938. /** Gets if the node is an ExportGetableNode. */
  3939. static isExportGetable<T extends Node>(node: T | undefined): node is ExportGetableNode & ExportGetableNodeExtensionType & T;
  3940. /** Gets if the node is an Expression. */
  3941. static isExpression(node: Node | undefined): node is Expression;
  3942. /** Gets if the node is an ExpressionableNode. */
  3943. static isExpressionable<T extends Node>(node: T | undefined): node is ExpressionableNode & ExpressionableNodeExtensionType & T;
  3944. /** Gets if the node is an ExpressionedNode. */
  3945. static isExpressioned<T extends Node>(node: T | undefined): node is ExpressionedNode & ExpressionedNodeExtensionType & T;
  3946. /** Gets if the node is an ExtendsClauseableNode. */
  3947. static isExtendsClauseable<T extends Node>(node: T | undefined): node is ExtendsClauseableNode & ExtendsClauseableNodeExtensionType & T;
  3948. /** Gets if the node is a FalseLiteral. */
  3949. static isFalseLiteral(node: Node | undefined): node is FalseLiteral;
  3950. /** Gets if the node is a FunctionLikeDeclaration. */
  3951. static isFunctionLikeDeclaration<T extends Node>(node: T | undefined): node is FunctionLikeDeclaration & FunctionLikeDeclarationExtensionType & T;
  3952. /** Gets if the node is a FunctionTypeNode. */
  3953. static isFunctionTypeNode(node: Node | undefined): node is FunctionTypeNode;
  3954. /** Gets if the node is a GeneratorableNode. */
  3955. static isGeneratorable<T extends Node>(node: T | undefined): node is GeneratorableNode & GeneratorableNodeExtensionType & T;
  3956. /** Gets if the node is a GetAccessorDeclaration. */
  3957. static isGetAccessorDeclaration(node: Node | undefined): node is GetAccessorDeclaration;
  3958. /** Gets if the node is a HeritageClauseableNode. */
  3959. static isHeritageClauseable<T extends Node>(node: T | undefined): node is HeritageClauseableNode & HeritageClauseableNodeExtensionType & T;
  3960. /** Gets if the node is a ImplementsClauseableNode. */
  3961. static isImplementsClauseable<T extends Node>(node: T | undefined): node is ImplementsClauseableNode & ImplementsClauseableNodeExtensionType & T;
  3962. /** Gets if the node is a ImportAttributeNamedNode. */
  3963. static isImportAttributeNamed<T extends Node>(node: T | undefined): node is ImportAttributeNamedNode & ImportAttributeNamedNodeExtensionType & T;
  3964. /** Gets if the node is a ImportExpression. */
  3965. static isImportExpression(node: Node | undefined): node is ImportExpression;
  3966. /** Gets if the node is a ImportTypeNode. */
  3967. static isImportTypeNode(node: Node | undefined): node is ImportTypeNode;
  3968. /** Gets if the node is a IndexedAccessTypeNode. */
  3969. static isIndexedAccessTypeNode(node: Node | undefined): node is IndexedAccessTypeNode;
  3970. /** Gets if the node is a IndexSignatureDeclaration. */
  3971. static isIndexSignatureDeclaration(node: Node | undefined): node is IndexSignatureDeclaration;
  3972. /** Gets if the node is a InferTypeNode. */
  3973. static isInferTypeNode(node: Node | undefined): node is InferTypeNode;
  3974. /** Gets if the node is a InitializerExpressionableNode. */
  3975. static isInitializerExpressionable<T extends Node>(node: T | undefined): node is InitializerExpressionableNode & InitializerExpressionableNodeExtensionType & T;
  3976. /** Gets if the node is a InitializerExpressionGetableNode. */
  3977. static isInitializerExpressionGetable<T extends Node>(node: T | undefined): node is InitializerExpressionGetableNode & InitializerExpressionGetableNodeExtensionType & T;
  3978. /** Gets if the node is a IntersectionTypeNode. */
  3979. static isIntersectionTypeNode(node: Node | undefined): node is IntersectionTypeNode;
  3980. /** Gets if the node is a IterationStatement. */
  3981. static isIterationStatement(node: Node | undefined): node is IterationStatement;
  3982. /** Gets if the node is a JSDocableNode. */
  3983. static isJSDocable<T extends Node>(node: T | undefined): node is JSDocableNode & JSDocableNodeExtensionType & T;
  3984. /** Gets if the node is a JSDocPropertyLikeTag. */
  3985. static isJSDocPropertyLikeTag<T extends Node>(node: T | undefined): node is JSDocPropertyLikeTag & JSDocPropertyLikeTagExtensionType & T;
  3986. /** Gets if the node is a JSDocTag. */
  3987. static isJSDocTag(node: Node | undefined): node is JSDocTag;
  3988. /** Gets if the node is a JSDocType. */
  3989. static isJSDocType(node: Node | undefined): node is JSDocType;
  3990. /** Gets if the node is a JSDocTypeExpressionableTag. */
  3991. static isJSDocTypeExpressionableTag<T extends Node>(node: T | undefined): node is JSDocTypeExpressionableTag & JSDocTypeExpressionableTagExtensionType & T;
  3992. /** Gets if the node is a JSDocTypeParameteredTag. */
  3993. static isJSDocTypeParameteredTag<T extends Node>(node: T | undefined): node is JSDocTypeParameteredTag & JSDocTypeParameteredTagExtensionType & T;
  3994. /** Gets if the node is a JSDocUnknownTag. */
  3995. static isJSDocUnknownTag(node: Node | undefined): node is JSDocUnknownTag;
  3996. /** Gets if the node is a JsxAttributedNode. */
  3997. static isJsxAttributed<T extends Node>(node: T | undefined): node is JsxAttributedNode & JsxAttributedNodeExtensionType & T;
  3998. /** Gets if the node is a JsxTagNamedNode. */
  3999. static isJsxTagNamed<T extends Node>(node: T | undefined): node is JsxTagNamedNode & JsxTagNamedNodeExtensionType & T;
  4000. /** Gets if the node is a LeftHandSideExpression. */
  4001. static isLeftHandSideExpression(node: Node | undefined): node is LeftHandSideExpression;
  4002. /** Gets if the node is a LeftHandSideExpressionedNode. */
  4003. static isLeftHandSideExpressioned<T extends Node>(node: T | undefined): node is LeftHandSideExpressionedNode & LeftHandSideExpressionedNodeExtensionType & T;
  4004. /** Gets if the node is a LiteralExpression. */
  4005. static isLiteralExpression(node: Node | undefined): node is LiteralExpression;
  4006. /** Gets if the node is a LiteralLikeNode. */
  4007. static isLiteralLike<T extends Node>(node: T | undefined): node is LiteralLikeNode & LiteralLikeNodeExtensionType & T;
  4008. /** Gets if the node is a LiteralTypeNode. */
  4009. static isLiteralTypeNode(node: Node | undefined): node is LiteralTypeNode;
  4010. /** Gets if the node is a MappedTypeNode. */
  4011. static isMappedTypeNode(node: Node | undefined): node is MappedTypeNode;
  4012. /** Gets if the node is a MemberExpression. */
  4013. static isMemberExpression(node: Node | undefined): node is MemberExpression;
  4014. /** Gets if the node is a ModifierableNode. */
  4015. static isModifierable<T extends Node>(node: T | undefined): node is ModifierableNode & ModifierableNodeExtensionType & T;
  4016. /** Gets if the node is a ModuleChildableNode. */
  4017. static isModuleChildable<T extends Node>(node: T | undefined): node is ModuleChildableNode & ModuleChildableNodeExtensionType & T;
  4018. /** Gets if the node is a ModuledNode. */
  4019. static isModuled<T extends Node>(node: T | undefined): node is ModuledNode & ModuledNodeExtensionType & T;
  4020. /** Gets if the node is a ModuleNamedNode. */
  4021. static isModuleNamed<T extends Node>(node: T | undefined): node is ModuleNamedNode & ModuleNamedNodeExtensionType & T;
  4022. /** Gets if the node is a NameableNode. */
  4023. static isNameable<T extends Node>(node: T | undefined): node is NameableNode & NameableNodeExtensionType & T;
  4024. /** Gets if the node is a NamedNode. */
  4025. static isNamed<T extends Node>(node: T | undefined): node is NamedNode & NamedNodeExtensionType & T;
  4026. /** Gets if the node is a NodeWithTypeArguments. */
  4027. static isNodeWithTypeArguments(node: Node | undefined): node is NodeWithTypeArguments;
  4028. /** Gets if the node is a NullLiteral. */
  4029. static isNullLiteral(node: Node | undefined): node is NullLiteral;
  4030. /** Gets if the node is a OverloadableNode. */
  4031. static isOverloadable<T extends Node>(node: T | undefined): node is OverloadableNode & OverloadableNodeExtensionType & T;
  4032. /** Gets if the node is a OverrideableNode. */
  4033. static isOverrideable<T extends Node>(node: T | undefined): node is OverrideableNode & OverrideableNodeExtensionType & T;
  4034. /** Gets if the node is a ParameterDeclaration. */
  4035. static isParameterDeclaration(node: Node | undefined): node is ParameterDeclaration;
  4036. /** Gets if the node is a ParameteredNode. */
  4037. static isParametered<T extends Node>(node: T | undefined): node is ParameteredNode & ParameteredNodeExtensionType & T;
  4038. /** Gets if the node is a ParenthesizedTypeNode. */
  4039. static isParenthesizedTypeNode(node: Node | undefined): node is ParenthesizedTypeNode;
  4040. /** Gets if the node is a PrimaryExpression. */
  4041. static isPrimaryExpression(node: Node | undefined): node is PrimaryExpression;
  4042. /** Gets if the node is a PropertyNamedNode. */
  4043. static isPropertyNamed<T extends Node>(node: T | undefined): node is PropertyNamedNode & PropertyNamedNodeExtensionType & T;
  4044. /** Gets if the node is a QuestionDotTokenableNode. */
  4045. static isQuestionDotTokenable<T extends Node>(node: T | undefined): node is QuestionDotTokenableNode & QuestionDotTokenableNodeExtensionType & T;
  4046. /** Gets if the node is a QuestionTokenableNode. */
  4047. static isQuestionTokenable<T extends Node>(node: T | undefined): node is QuestionTokenableNode & QuestionTokenableNodeExtensionType & T;
  4048. /** Gets if the node is a ReadonlyableNode. */
  4049. static isReadonlyable<T extends Node>(node: T | undefined): node is ReadonlyableNode & ReadonlyableNodeExtensionType & T;
  4050. /** Gets if the node is a ReferenceFindableNode. */
  4051. static isReferenceFindable<T extends Node>(node: T | undefined): node is ReferenceFindableNode & ReferenceFindableNodeExtensionType & T;
  4052. /** Gets if the node is a RenameableNode. */
  4053. static isRenameable<T extends Node>(node: T | undefined): node is RenameableNode & RenameableNodeExtensionType & T;
  4054. /** Gets if the node is a RestTypeNode. */
  4055. static isRestTypeNode(node: Node | undefined): node is RestTypeNode;
  4056. /** Gets if the node is a ReturnTypedNode. */
  4057. static isReturnTyped<T extends Node>(node: T | undefined): node is ReturnTypedNode & ReturnTypedNodeExtensionType & T;
  4058. /** Gets if the node is a ScopeableNode. */
  4059. static isScopeable<T extends Node>(node: T | undefined): node is ScopeableNode & ScopeableNodeExtensionType & T;
  4060. /** Gets if the node is a ScopedNode. */
  4061. static isScoped<T extends Node>(node: T | undefined): node is ScopedNode & ScopedNodeExtensionType & T;
  4062. /** Gets if the node is a SetAccessorDeclaration. */
  4063. static isSetAccessorDeclaration(node: Node | undefined): node is SetAccessorDeclaration;
  4064. /** Gets if the node is a SignaturedDeclaration. */
  4065. static isSignaturedDeclaration<T extends Node>(node: T | undefined): node is SignaturedDeclaration & SignaturedDeclarationExtensionType & T;
  4066. /** Gets if the node is a Statement. */
  4067. static isStatement(node: Node | undefined): node is Statement;
  4068. /** Gets if the node is a StatementedNode. */
  4069. static isStatemented<T extends Node>(node: T | undefined): node is StatementedNode & StatementedNodeExtensionType & T;
  4070. /** Gets if the node is a StaticableNode. */
  4071. static isStaticable<T extends Node>(node: T | undefined): node is StaticableNode & StaticableNodeExtensionType & T;
  4072. /** Gets if the node is a SuperExpression. */
  4073. static isSuperExpression(node: Node | undefined): node is SuperExpression;
  4074. /** Gets if the node is a TemplateLiteralTypeNode. */
  4075. static isTemplateLiteralTypeNode(node: Node | undefined): node is TemplateLiteralTypeNode;
  4076. /** Gets if the node is a TextInsertableNode. */
  4077. static isTextInsertable<T extends Node>(node: T | undefined): node is TextInsertableNode & TextInsertableNodeExtensionType & T;
  4078. /** Gets if the node is a ThisExpression. */
  4079. static isThisExpression(node: Node | undefined): node is ThisExpression;
  4080. /** Gets if the node is a ThisTypeNode. */
  4081. static isThisTypeNode(node: Node | undefined): node is ThisTypeNode;
  4082. /** Gets if the node is a TrueLiteral. */
  4083. static isTrueLiteral(node: Node | undefined): node is TrueLiteral;
  4084. /** Gets if the node is a TupleTypeNode. */
  4085. static isTupleTypeNode(node: Node | undefined): node is TupleTypeNode;
  4086. /** Gets if the node is a TypeArgumentedNode. */
  4087. static isTypeArgumented<T extends Node>(node: T | undefined): node is TypeArgumentedNode & TypeArgumentedNodeExtensionType & T;
  4088. /** Gets if the node is a TypeAssertion. */
  4089. static isTypeAssertion(node: Node | undefined): node is TypeAssertion;
  4090. /** Gets if the node is a TypedNode. */
  4091. static isTyped<T extends Node>(node: T | undefined): node is TypedNode & TypedNodeExtensionType & T;
  4092. /** Gets if the node is a TypeElement. */
  4093. static isTypeElement(node: Node | undefined): node is TypeElement;
  4094. /** Gets if the node is a TypeElementMemberedNode. */
  4095. static isTypeElementMembered<T extends Node>(node: T | undefined): node is TypeElementMemberedNode & TypeElementMemberedNodeExtensionType & T;
  4096. /** Gets if the node is a TypeLiteralNode. */
  4097. static isTypeLiteral(node: Node | undefined): node is TypeLiteralNode;
  4098. /** Gets if the node is a TypeNode. */
  4099. static isTypeNode(node: Node | undefined): node is TypeNode;
  4100. /** Gets if the node is a TypeOperatorTypeNode. */
  4101. static isTypeOperatorTypeNode(node: Node | undefined): node is TypeOperatorTypeNode;
  4102. /** Gets if the node is a TypeParameterDeclaration. */
  4103. static isTypeParameterDeclaration(node: Node | undefined): node is TypeParameterDeclaration;
  4104. /** Gets if the node is a TypeParameteredNode. */
  4105. static isTypeParametered<T extends Node>(node: T | undefined): node is TypeParameteredNode & TypeParameteredNodeExtensionType & T;
  4106. /** Gets if the node is a TypePredicateNode. */
  4107. static isTypePredicate(node: Node | undefined): node is TypePredicateNode;
  4108. /** Gets if the node is a TypeQueryNode. */
  4109. static isTypeQuery(node: Node | undefined): node is TypeQueryNode;
  4110. /** Gets if the node is a TypeReferenceNode. */
  4111. static isTypeReference(node: Node | undefined): node is TypeReferenceNode;
  4112. /** Gets if the node is a UnaryExpression. */
  4113. static isUnaryExpression(node: Node | undefined): node is UnaryExpression;
  4114. /** Gets if the node is a UnaryExpressionedNode. */
  4115. static isUnaryExpressioned<T extends Node>(node: T | undefined): node is UnaryExpressionedNode & UnaryExpressionedNodeExtensionType & T;
  4116. /** Gets if the node is a UnionTypeNode. */
  4117. static isUnionTypeNode(node: Node | undefined): node is UnionTypeNode;
  4118. /** Gets if the node is a UnwrappableNode. */
  4119. static isUnwrappable<T extends Node>(node: T | undefined): node is UnwrappableNode & UnwrappableNodeExtensionType & T;
  4120. /** Gets if the node is a UpdateExpression. */
  4121. static isUpdateExpression(node: Node | undefined): node is UpdateExpression;
  4122. }
  4123. export declare enum Scope {
  4124. Public = "public",
  4125. Protected = "protected",
  4126. Private = "private"
  4127. }
  4128. export declare class SyntaxList extends Node<ts.SyntaxList> {
  4129. /**
  4130. * Adds text at the end of the current children.
  4131. * @param textOrWriterFunction - Text to add or function that provides a writer to write with.
  4132. * @returns The children that were added.
  4133. */
  4134. addChildText(textOrWriterFunction: string | WriterFunction | ReadonlyArray<string | WriterFunction>): Node<ts.Node>[];
  4135. /**
  4136. * Inserts text at the specified child index.
  4137. * @param index - Child index to insert at.
  4138. * @param textOrWriterFunction - Text to insert or function that provides a writer to write with.
  4139. * @returns The children that were inserted.
  4140. */
  4141. insertChildText(index: number, textOrWriterFunction: string | WriterFunction | ReadonlyArray<string | WriterFunction>): Node<ts.Node>[];
  4142. /** @inheritdoc **/
  4143. getParent(): NodeParentType<ts.SyntaxList>;
  4144. /** @inheritdoc **/
  4145. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SyntaxList>>;
  4146. }
  4147. export declare class TextRange<TRange extends ts.TextRange = ts.TextRange> {
  4148. #private;
  4149. protected constructor();
  4150. /** Gets the underlying compiler object. */
  4151. get compilerObject(): TRange;
  4152. /** Gets the source file of the text range. */
  4153. getSourceFile(): SourceFile;
  4154. /** Gets the position. */
  4155. getPos(): number;
  4156. /** Gets the end. */
  4157. getEnd(): number;
  4158. /** Gets the width of the text range. */
  4159. getWidth(): number;
  4160. /** Gets the text of the text range. */
  4161. getText(): string;
  4162. /**
  4163. * Gets if the text range was forgotten.
  4164. *
  4165. * This will be true after any manipulations have occured to the source file this text range was generated from.
  4166. */
  4167. wasForgotten(): boolean;
  4168. }
  4169. export interface ForEachDescendantTraversalControl {
  4170. /** Stops traversal. */
  4171. stop(): void;
  4172. /** Skips traversal of the current node's descendants. */
  4173. skip(): void;
  4174. /** Skips traversal of the current node, siblings, and all their descendants. */
  4175. up(): void;
  4176. }
  4177. export interface TransformTraversalControl {
  4178. /** Factory to create nodes with. */
  4179. factory: ts.NodeFactory;
  4180. /**
  4181. * The node currently being transformed.
  4182. * @remarks Use the result of `.visitChildren()` instead before transforming if visiting the children.
  4183. */
  4184. currentNode: ts.Node;
  4185. /** Visits the children of the current node and returns a new node for the current node. */
  4186. visitChildren(): ts.Node;
  4187. }
  4188. export type CompilerNodeToWrappedType<T extends ts.Node> = T extends ts.ObjectDestructuringAssignment ? ObjectDestructuringAssignment : T extends ts.ArrayDestructuringAssignment ? ArrayDestructuringAssignment : T extends ts.SuperElementAccessExpression ? SuperElementAccessExpression : T extends ts.SuperPropertyAccessExpression ? SuperPropertyAccessExpression : T extends ts.AssignmentExpression<infer U> ? AssignmentExpression<ts.AssignmentExpression<U>> : T["kind"] extends keyof ImplementedKindToNodeMappings ? ImplementedKindToNodeMappings[T["kind"]] : T extends ts.SyntaxList ? SyntaxList : T extends ts.JSDocTypeExpression ? JSDocTypeExpression : T extends ts.JSDocType ? JSDocType : T extends ts.NodeWithTypeArguments ? NodeWithTypeArguments : T extends ts.TypeNode ? TypeNode : T extends ts.JSDocTag ? JSDocTag : T extends ts.LiteralExpression ? LiteralExpression : T extends ts.PrimaryExpression ? PrimaryExpression : T extends ts.MemberExpression ? MemberExpression : T extends ts.LeftHandSideExpression ? LeftHandSideExpression : T extends ts.UpdateExpression ? UpdateExpression : T extends ts.UnaryExpression ? UnaryExpression : T extends ts.Expression ? Expression : T extends ts.IterationStatement ? IterationStatement : T extends CompilerCommentStatement ? CommentStatement : T extends CompilerCommentClassElement ? CommentClassElement : T extends CompilerCommentTypeElement ? CommentTypeElement : T extends CompilerCommentObjectLiteralElement ? CommentObjectLiteralElement : T extends CompilerCommentEnumMember ? CommentEnumMember : T extends ts.TypeElement ? TypeElement : T extends ts.Statement ? Statement : T extends ts.ClassElement ? ClassElement : T extends ts.ObjectLiteralElement ? ObjectLiteralElement : Node<T>;
  4189. declare const DecoratorBase: Constructor<LeftHandSideExpressionedNode> & typeof Node;
  4190. export declare class Decorator extends DecoratorBase<ts.Decorator> {
  4191. private _getInnerExpression;
  4192. /** Gets the decorator name. */
  4193. getName(): string;
  4194. /** Gets the name node of the decorator. */
  4195. getNameNode(): Identifier;
  4196. /** Gets the full decorator name. */
  4197. getFullName(): string;
  4198. /** Gets if the decorator is a decorator factory. */
  4199. isDecoratorFactory(): boolean;
  4200. /**
  4201. * Set if this decorator is a decorator factory.
  4202. * @param isDecoratorFactory - If it should be a decorator factory or not.
  4203. */
  4204. setIsDecoratorFactory(isDecoratorFactory: boolean): this;
  4205. /** Gets the call expression if a decorator factory, or throws. */
  4206. getCallExpressionOrThrow(message?: string | (() => string)): CallExpression;
  4207. /** Gets the call expression if a decorator factory. */
  4208. getCallExpression(): CallExpression | undefined;
  4209. /** Gets the decorator's arguments from its call expression. */
  4210. getArguments(): Node[];
  4211. /** Gets the decorator's type arguments from its call expression. */
  4212. getTypeArguments(): TypeNode[];
  4213. /**
  4214. * Adds a type argument.
  4215. * @param argumentTexts - Argument text.
  4216. */
  4217. addTypeArgument(argumentText: string): TypeNode<ts.TypeNode>;
  4218. /**
  4219. * Adds type arguments.
  4220. * @param argumentTexts - Argument texts.
  4221. */
  4222. addTypeArguments(argumentTexts: ReadonlyArray<string>): TypeNode<ts.TypeNode>[];
  4223. /**
  4224. * Inserts a type argument.
  4225. * @param index - Child index to insert at.
  4226. * @param argumentTexts - Argument text.
  4227. */
  4228. insertTypeArgument(index: number, argumentText: string): TypeNode<ts.TypeNode>;
  4229. /**
  4230. * Inserts type arguments.
  4231. * @param index - Child index to insert at.
  4232. * @param argumentTexts - Argument texts.
  4233. */
  4234. insertTypeArguments(index: number, argumentTexts: ReadonlyArray<string>): TypeNode<ts.TypeNode>[];
  4235. /**
  4236. * Removes a type argument.
  4237. * @param typeArg - Type argument to remove.
  4238. */
  4239. removeTypeArgument(typeArg: Node): this;
  4240. /**
  4241. * Removes a type argument.
  4242. * @param index - Index to remove.
  4243. */
  4244. removeTypeArgument(index: number): this;
  4245. /**
  4246. * Adds an argument.
  4247. * @param argumentTexts - Argument text.
  4248. */
  4249. addArgument(argumentText: string | WriterFunction): Node<ts.Node>;
  4250. /**
  4251. * Adds arguments.
  4252. * @param argumentTexts - Argument texts.
  4253. */
  4254. addArguments(argumentTexts: ReadonlyArray<string | WriterFunction> | WriterFunction): Node<ts.Node>[];
  4255. /**
  4256. * Inserts an argument.
  4257. * @param index - Child index to insert at.
  4258. * @param argumentTexts - Argument text.
  4259. */
  4260. insertArgument(index: number, argumentText: string | WriterFunction): Node<ts.Node>;
  4261. /**
  4262. * Inserts arguments.
  4263. * @param index - Child index to insert at.
  4264. * @param argumentTexts - Argument texts.
  4265. */
  4266. insertArguments(index: number, argumentTexts: ReadonlyArray<string | WriterFunction> | WriterFunction): Node<ts.Node>[];
  4267. /**
  4268. * Removes an argument based on the node.
  4269. * @param node - Argument's node to remove.
  4270. */
  4271. removeArgument(node: Node): this;
  4272. /**
  4273. * Removes an argument based on the specified index.
  4274. * @param index - Index to remove.
  4275. */
  4276. removeArgument(index: number): this;
  4277. /** Removes this decorator. */
  4278. remove(): void;
  4279. /**
  4280. * Sets the node from a structure.
  4281. * @param structure - Structure to set the node with.
  4282. */
  4283. set(structure: Partial<DecoratorStructure>): this;
  4284. /** Gets the structure equivalent to this node. */
  4285. getStructure(): DecoratorStructure;
  4286. /** @inheritdoc **/
  4287. getParent(): NodeParentType<ts.Decorator>;
  4288. /** @inheritdoc **/
  4289. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.Decorator>>;
  4290. }
  4291. export declare function JSDocPropertyLikeTag<T extends Constructor<JSDocPropertyLikeTagExtensionType>>(Base: T): Constructor<JSDocPropertyLikeTag> & T;
  4292. export interface JSDocPropertyLikeTag {
  4293. /** Gets the type expression node of the JS doc tag if it exists. */
  4294. getTypeExpression(): JSDocTypeExpression | undefined;
  4295. /** Gets the type expression node of the JS doc tag or throws if it doesn't exist. */
  4296. getTypeExpressionOrThrow(message?: string | (() => string)): JSDocTypeExpression;
  4297. /** Gets the name of the JS doc property like tag. */
  4298. getName(): string;
  4299. /** Gets the name node of the JS doc property like tag. */
  4300. getNameNode(): EntityName;
  4301. /** Checks if the JS doc property like tag is bracketed. */
  4302. isBracketed(): boolean;
  4303. }
  4304. type JSDocPropertyLikeTagExtensionType = Node<ts.JSDocPropertyLikeTag> & JSDocTag;
  4305. export declare function JSDocTypeExpressionableTag<T extends Constructor<JSDocTypeExpressionableTagExtensionType>>(Base: T): Constructor<JSDocTypeExpressionableTag> & T;
  4306. export interface JSDocTypeExpressionableTag {
  4307. /** Gets the type expression node of the JS doc tag if it exists. */
  4308. getTypeExpression(): JSDocTypeExpression | undefined;
  4309. /** Gets the type expression node of the JS doc tag or throws if it doesn't exist. */
  4310. getTypeExpressionOrThrow(message?: string | (() => string)): JSDocTypeExpression;
  4311. }
  4312. type JSDocTypeExpressionableTagExtensionType = Node<ts.Node & {
  4313. typeExpression: ts.JSDocTypeExpression | undefined;
  4314. }> & JSDocTag;
  4315. export declare function JSDocTypeParameteredTag<T extends Constructor<JSDocTypeParameteredTagExtensionType>>(Base: T): Constructor<JSDocTypeParameteredTag> & T;
  4316. export interface JSDocTypeParameteredTag {
  4317. /** Gets the type parameters. */
  4318. getTypeParameters(): TypeParameterDeclaration[];
  4319. }
  4320. type JSDocTypeParameteredTagExtensionType = Node<ts.Node & {
  4321. typeParameters: ts.NodeArray<ts.TypeParameterDeclaration>;
  4322. }> & JSDocTag;
  4323. declare const JSDocBase: typeof Node;
  4324. /** JS doc node. */
  4325. export declare class JSDoc extends JSDocBase<ts.JSDoc> {
  4326. /** Gets if this JS doc spans multiple lines. */
  4327. isMultiLine(): boolean;
  4328. /** Gets the tags of the JSDoc. */
  4329. getTags(): JSDocTag[];
  4330. /** Gets the JSDoc's text without the surrounding slashes and stars. */
  4331. getInnerText(): string;
  4332. /** Gets the comment property. Use `#getCommentText()` to get the text of the JS doc comment if necessary. */
  4333. getComment(): string | (JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain | undefined)[] | undefined;
  4334. /** Gets the text of the JS doc comment. */
  4335. getCommentText(): string | undefined;
  4336. /**
  4337. * Gets the description from the JS doc comment.
  4338. * @remarks This will contain a leading newline if the jsdoc is multi-line.
  4339. */
  4340. getDescription(): string;
  4341. /**
  4342. * Sets the description.
  4343. * @param textOrWriterFunction - Text or writer function to set.
  4344. */
  4345. setDescription(textOrWriterFunction: string | WriterFunction): this;
  4346. /**
  4347. * Adds a JS doc tag.
  4348. * @param structure - Tag structure to add.
  4349. */
  4350. addTag(structure: OptionalKind<JSDocTagStructure>): JSDocTag<ts.JSDocTag>;
  4351. /**
  4352. * Adds JS doc tags.
  4353. * @param structures - Tag structures to add.
  4354. */
  4355. addTags(structures: ReadonlyArray<OptionalKind<JSDocTagStructure>>): JSDocTag<ts.JSDocTag>[];
  4356. /**
  4357. * Inserts a JS doc tag at the specified index.
  4358. * @param index - Index to insert at.
  4359. * @param structure - Tag structure to insert.
  4360. */
  4361. insertTag(index: number, structure: OptionalKind<JSDocTagStructure>): JSDocTag<ts.JSDocTag>;
  4362. /**
  4363. * Inserts JS doc tags at the specified index.
  4364. * @param index - Index to insert at.
  4365. * @param structures - Tag structures to insert.
  4366. */
  4367. insertTags(index: number, structures: ReadonlyArray<OptionalKind<JSDocTagStructure>>): JSDocTag<ts.JSDocTag>[];
  4368. /** Removes this JSDoc. */
  4369. remove(): void;
  4370. /**
  4371. * Sets the node from a structure.
  4372. * @param structure - Structure to set the node with.
  4373. */
  4374. set(structure: Partial<JSDocStructure>): Node<ts.Node>;
  4375. /** Gets the structure equivalent to this node. */
  4376. getStructure(): JSDocStructure;
  4377. /** @inheritdoc **/
  4378. getParent(): NodeParentType<ts.JSDoc>;
  4379. /** @inheritdoc **/
  4380. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDoc>>;
  4381. }
  4382. /** JS doc all type. */
  4383. export declare class JSDocAllType extends JSDocType<ts.JSDocAllType> {
  4384. /** @inheritdoc **/
  4385. getParent(): NodeParentType<ts.JSDocAllType>;
  4386. /** @inheritdoc **/
  4387. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocAllType>>;
  4388. }
  4389. /** JS doc augments tag node. */
  4390. export declare class JSDocAugmentsTag extends JSDocTag<ts.JSDocAugmentsTag> {
  4391. /** @inheritdoc **/
  4392. getParent(): NodeParentType<ts.JSDocAugmentsTag>;
  4393. /** @inheritdoc **/
  4394. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocAugmentsTag>>;
  4395. }
  4396. /** JS doc author tag node. */
  4397. export declare class JSDocAuthorTag extends JSDocTag<ts.JSDocAuthorTag> {
  4398. /** @inheritdoc **/
  4399. getParent(): NodeParentType<ts.JSDocAuthorTag>;
  4400. /** @inheritdoc **/
  4401. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocAuthorTag>>;
  4402. }
  4403. /** JS doc callback tag node. */
  4404. export declare class JSDocCallbackTag extends JSDocTag<ts.JSDocCallbackTag> {
  4405. /** @inheritdoc **/
  4406. getParent(): NodeParentType<ts.JSDocCallbackTag>;
  4407. /** @inheritdoc **/
  4408. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocCallbackTag>>;
  4409. }
  4410. /** JS doc class tag node. */
  4411. export declare class JSDocClassTag extends JSDocTag<ts.JSDocClassTag> {
  4412. /** @inheritdoc **/
  4413. getParent(): NodeParentType<ts.JSDocClassTag>;
  4414. /** @inheritdoc **/
  4415. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocClassTag>>;
  4416. }
  4417. /** JS doc deprecated tag node. */
  4418. export declare class JSDocDeprecatedTag extends JSDocTag<ts.JSDocDeprecatedTag> {
  4419. /** @inheritdoc **/
  4420. getParent(): NodeParentType<ts.JSDocDeprecatedTag>;
  4421. /** @inheritdoc **/
  4422. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocDeprecatedTag>>;
  4423. }
  4424. /** JS doc enum tag node. */
  4425. export declare class JSDocEnumTag extends JSDocTag<ts.JSDocEnumTag> {
  4426. /** @inheritdoc **/
  4427. getParent(): NodeParentType<ts.JSDocEnumTag>;
  4428. /** @inheritdoc **/
  4429. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocEnumTag>>;
  4430. }
  4431. declare const JSDocFunctionTypeBase: Constructor<SignaturedDeclaration> & typeof JSDocType;
  4432. /** JS doc function type. */
  4433. export declare class JSDocFunctionType extends JSDocFunctionTypeBase<ts.JSDocFunctionType> {
  4434. /** @inheritdoc **/
  4435. getParent(): NodeParentType<ts.JSDocFunctionType>;
  4436. /** @inheritdoc **/
  4437. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocFunctionType>>;
  4438. }
  4439. /** JS doc implements tag node. */
  4440. export declare class JSDocImplementsTag extends JSDocTag<ts.JSDocImplementsTag> {
  4441. /** @inheritdoc **/
  4442. getParent(): NodeParentType<ts.JSDocImplementsTag>;
  4443. /** @inheritdoc **/
  4444. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocImplementsTag>>;
  4445. }
  4446. /** JS doc link node. */
  4447. export declare class JSDocLink extends Node<ts.JSDocLink> {
  4448. /** @inheritdoc **/
  4449. getParent(): NodeParentType<ts.JSDocLink>;
  4450. /** @inheritdoc **/
  4451. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocLink>>;
  4452. }
  4453. /** JS doc link code node. */
  4454. export declare class JSDocLinkCode extends Node<ts.JSDocLinkCode> {
  4455. /** @inheritdoc **/
  4456. getParent(): NodeParentType<ts.JSDocLinkCode>;
  4457. /** @inheritdoc **/
  4458. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocLinkCode>>;
  4459. }
  4460. /** JS doc link plain node. */
  4461. export declare class JSDocLinkPlain extends Node<ts.JSDocLinkPlain> {
  4462. /** @inheritdoc **/
  4463. getParent(): NodeParentType<ts.JSDocLinkPlain>;
  4464. /** @inheritdoc **/
  4465. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocLinkPlain>>;
  4466. }
  4467. /** JS doc member name node. */
  4468. export declare class JSDocMemberName extends Node<ts.JSDocMemberName> {
  4469. /** @inheritdoc **/
  4470. getParent(): NodeParentType<ts.JSDocMemberName>;
  4471. /** @inheritdoc **/
  4472. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocMemberName>>;
  4473. }
  4474. /** JS doc namepath type. */
  4475. export declare class JSDocNamepathType extends JSDocType<ts.JSDocNamepathType> {
  4476. /** Gets the type node of the JS doc namepath node. */
  4477. getTypeNode(): TypeNode<ts.TypeNode>;
  4478. /** @inheritdoc **/
  4479. getParent(): NodeParentType<ts.JSDocNamepathType>;
  4480. /** @inheritdoc **/
  4481. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocNamepathType>>;
  4482. }
  4483. /** JS doc name reference. */
  4484. export declare class JSDocNameReference extends Node<ts.JSDocNameReference> {
  4485. /** Gets the name of the JS doc name reference. */
  4486. getName(): Identifier | QualifiedName | JSDocMemberName;
  4487. /** @inheritdoc **/
  4488. getParent(): NodeParentType<ts.JSDocNameReference>;
  4489. /** @inheritdoc **/
  4490. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocNameReference>>;
  4491. }
  4492. /** JS doc non-nullable type. */
  4493. export declare class JSDocNonNullableType extends JSDocType<ts.JSDocNonNullableType> {
  4494. /** Gets the type node of the JS doc non-nullable type node. */
  4495. getTypeNode(): TypeNode<ts.TypeNode>;
  4496. isPostfix(): boolean;
  4497. /** @inheritdoc **/
  4498. getParent(): NodeParentType<ts.JSDocNonNullableType>;
  4499. /** @inheritdoc **/
  4500. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocNonNullableType>>;
  4501. }
  4502. /** JS doc nullable type. */
  4503. export declare class JSDocNullableType extends JSDocType<ts.JSDocNullableType> {
  4504. /** Gets the type node of the JS doc nullable type node. */
  4505. getTypeNode(): TypeNode<ts.TypeNode>;
  4506. isPostfix(): boolean;
  4507. /** @inheritdoc **/
  4508. getParent(): NodeParentType<ts.JSDocNullableType>;
  4509. /** @inheritdoc **/
  4510. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocNullableType>>;
  4511. }
  4512. /** JS doc optional type. */
  4513. export declare class JSDocOptionalType extends JSDocType<ts.JSDocOptionalType> {
  4514. /** Gets the type node of the JS doc optional type node. */
  4515. getTypeNode(): TypeNode<ts.TypeNode>;
  4516. /** @inheritdoc **/
  4517. getParent(): NodeParentType<ts.JSDocOptionalType>;
  4518. /** @inheritdoc **/
  4519. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocOptionalType>>;
  4520. }
  4521. declare const JSDocOverloadTagBase: Constructor<JSDocTypeExpressionableTag> & typeof JSDocTag;
  4522. /** JS doc overload tag. */
  4523. export declare class JSDocOverloadTag extends JSDocOverloadTagBase<ts.JSDocOverloadTag> {
  4524. /** @inheritdoc **/
  4525. getParent(): NodeParentType<ts.JSDocOverloadTag>;
  4526. /** @inheritdoc **/
  4527. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocOverloadTag>>;
  4528. }
  4529. /** JS doc override tag node. */
  4530. export declare class JSDocOverrideTag extends JSDocTag<ts.JSDocOverrideTag> {
  4531. /** @inheritdoc **/
  4532. getParent(): NodeParentType<ts.JSDocOverrideTag>;
  4533. /** @inheritdoc **/
  4534. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocOverrideTag>>;
  4535. }
  4536. declare const JSDocParameterTagBase: Constructor<JSDocPropertyLikeTag> & typeof JSDocTag;
  4537. /** JS doc parameter tag node. */
  4538. export declare class JSDocParameterTag extends JSDocParameterTagBase<ts.JSDocParameterTag> {
  4539. /** @inheritdoc **/
  4540. getParent(): NodeParentType<ts.JSDocParameterTag>;
  4541. /** @inheritdoc **/
  4542. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocParameterTag>>;
  4543. }
  4544. /** JS doc private tag node. */
  4545. export declare class JSDocPrivateTag extends JSDocTag<ts.JSDocPrivateTag> {
  4546. /** @inheritdoc **/
  4547. getParent(): NodeParentType<ts.JSDocPrivateTag>;
  4548. /** @inheritdoc **/
  4549. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocPrivateTag>>;
  4550. }
  4551. declare const JSDocPropertyTagBase: Constructor<JSDocPropertyLikeTag> & typeof JSDocTag;
  4552. /** JS doc property tag node. */
  4553. export declare class JSDocPropertyTag extends JSDocPropertyTagBase<ts.JSDocPropertyTag> {
  4554. /** @inheritdoc **/
  4555. getParent(): NodeParentType<ts.JSDocPropertyTag>;
  4556. /** @inheritdoc **/
  4557. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocPropertyTag>>;
  4558. }
  4559. /** JS doc protected tag node. */
  4560. export declare class JSDocProtectedTag extends JSDocTag<ts.JSDocProtectedTag> {
  4561. /** @inheritdoc **/
  4562. getParent(): NodeParentType<ts.JSDocProtectedTag>;
  4563. /** @inheritdoc **/
  4564. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocProtectedTag>>;
  4565. }
  4566. /** JS doc public tag node. */
  4567. export declare class JSDocPublicTag extends JSDocTag<ts.JSDocPublicTag> {
  4568. /** @inheritdoc **/
  4569. getParent(): NodeParentType<ts.JSDocPublicTag>;
  4570. /** @inheritdoc **/
  4571. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocPublicTag>>;
  4572. }
  4573. /** JS doc readonly tag node. */
  4574. export declare class JSDocReadonlyTag extends JSDocTag<ts.JSDocReadonlyTag> {
  4575. /** @inheritdoc **/
  4576. getParent(): NodeParentType<ts.JSDocReadonlyTag>;
  4577. /** @inheritdoc **/
  4578. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocReadonlyTag>>;
  4579. }
  4580. declare const JSDocReturnTagBase: Constructor<JSDocTypeExpressionableTag> & typeof JSDocTag;
  4581. /** JS doc return tag node. */
  4582. export declare class JSDocReturnTag extends JSDocReturnTagBase<ts.JSDocReturnTag> {
  4583. /** @inheritdoc **/
  4584. getParent(): NodeParentType<ts.JSDocReturnTag>;
  4585. /** @inheritdoc **/
  4586. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocReturnTag>>;
  4587. }
  4588. declare const JSDocSatisfiesTagBase: Constructor<JSDocTypeExpressionableTag> & typeof JSDocTag;
  4589. /** JS doc satifiest tag. */
  4590. export declare class JSDocSatisfiesTag extends JSDocSatisfiesTagBase<ts.JSDocSatisfiesTag> {
  4591. /** @inheritdoc **/
  4592. getParent(): NodeParentType<ts.JSDocSatisfiesTag>;
  4593. /** @inheritdoc **/
  4594. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocSatisfiesTag>>;
  4595. }
  4596. declare const JSDocSeeTagBase: Constructor<JSDocTypeExpressionableTag> & typeof JSDocTag;
  4597. /** JS doc "see" tag node. */
  4598. export declare class JSDocSeeTag extends JSDocSeeTagBase<ts.JSDocSeeTag> {
  4599. /** @inheritdoc **/
  4600. getParent(): NodeParentType<ts.JSDocSeeTag>;
  4601. /** @inheritdoc **/
  4602. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocSeeTag>>;
  4603. }
  4604. /** JS doc signature node. */
  4605. export declare class JSDocSignature extends JSDocType<ts.JSDocSignature> {
  4606. /** Gets the type node of the JS doc signature. */
  4607. getTypeNode(): JSDocReturnTag | undefined;
  4608. /** @inheritdoc **/
  4609. getParent(): NodeParentType<ts.JSDocSignature>;
  4610. /** @inheritdoc **/
  4611. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocSignature>>;
  4612. }
  4613. declare const JSDocTagBase: typeof Node;
  4614. /** JS doc tag node. */
  4615. export declare class JSDocTag<NodeType extends ts.JSDocTag = ts.JSDocTag> extends JSDocTagBase<NodeType> {
  4616. /** Gets the tag's name as a string (ex. returns `"param"` for `&#64;param`). */
  4617. getTagName(): string;
  4618. /** Gets the tag name node (ex. Returns the `param` identifier for `&#64;param`). */
  4619. getTagNameNode(): Identifier;
  4620. /**
  4621. * Sets the tag name.
  4622. * @param tagName - The new name to use.
  4623. * @returns The current node or new node if the node kind changed.
  4624. * @remarks This will forget the current node if the JSDocTag kind changes. Use the return value if you're changing the kind.
  4625. */
  4626. setTagName(tagName: string): Node<ts.Node>;
  4627. /** Gets the tag's comment property. Use `#getCommentText()` to get the text of the JS doc tag comment if necessary. */
  4628. getComment(): string | (JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain | undefined)[] | undefined;
  4629. /** Gets the text of the JS doc tag comment (ex. `"Some description."` for `&#64;param value Some description.`). */
  4630. getCommentText(): string | undefined;
  4631. /** Removes the JS doc comment. */
  4632. remove(): void;
  4633. /**
  4634. * Sets the node from a structure.
  4635. * @param structure - Structure to set the node with.
  4636. * @returns The node or the node that replaced the existing node (ex. when changing from a JSDocParameterTag to something else).
  4637. */
  4638. set(structure: Partial<JSDocTagStructure>): Node<ts.Node>;
  4639. /** @inheritdoc */
  4640. replaceWithText(textOrWriterFunction: string | WriterFunction): Node;
  4641. /** Gets a structure that represents this JS doc tag node. */
  4642. getStructure(): JSDocTagStructure;
  4643. }
  4644. /** JS doc tag info. */
  4645. export declare class JSDocTagInfo {
  4646. #private;
  4647. private constructor();
  4648. /** Gets the compiler JS doc tag info. */
  4649. get compilerObject(): ts.JSDocTagInfo;
  4650. /** Gets the name. */
  4651. getName(): string;
  4652. /** Gets the text. */
  4653. getText(): ts.SymbolDisplayPart[];
  4654. }
  4655. declare const JSDocTemplateTagBase: Constructor<JSDocTypeParameteredTag> & typeof JSDocTag;
  4656. /** JS doc template tag node. */
  4657. export declare class JSDocTemplateTag extends JSDocTemplateTagBase<ts.JSDocTemplateTag> {
  4658. /** Gets the template tag's constraint if it exists or returns undefined. */
  4659. getConstraint(): JSDocTypeExpression | undefined;
  4660. /** Gets the template tag's constraint if it exists or throws otherwise. */
  4661. getConstraintOrThrow(message?: string | (() => string)): JSDocTypeExpression;
  4662. /** @inheritdoc **/
  4663. getParent(): NodeParentType<ts.JSDocTemplateTag>;
  4664. /** @inheritdoc **/
  4665. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocTemplateTag>>;
  4666. }
  4667. /** JS doc text node. */
  4668. export declare class JSDocText extends Node<ts.JSDocText> {
  4669. /** @inheritdoc **/
  4670. getParent(): NodeParentType<ts.JSDocText>;
  4671. /** @inheritdoc **/
  4672. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocText>>;
  4673. }
  4674. declare const JSDocThisTagBase: Constructor<JSDocTypeExpressionableTag> & typeof JSDocTag;
  4675. /** JS doc "this" tag node. */
  4676. export declare class JSDocThisTag extends JSDocThisTagBase<ts.JSDocThisTag> {
  4677. /** @inheritdoc **/
  4678. getParent(): NodeParentType<ts.JSDocThisTag>;
  4679. /** @inheritdoc **/
  4680. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocThisTag>>;
  4681. }
  4682. declare const JSDocThrowsTagBase: Constructor<JSDocTypeExpressionableTag> & typeof JSDocTag;
  4683. /** JS doc return tag node. */
  4684. export declare class JSDocThrowsTag extends JSDocThrowsTagBase<ts.JSDocThrowsTag> {
  4685. /** @inheritdoc **/
  4686. getParent(): NodeParentType<ts.JSDocThrowsTag>;
  4687. /** @inheritdoc **/
  4688. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocThrowsTag>>;
  4689. }
  4690. /** JS doc type node. */
  4691. export declare class JSDocType<T extends ts.JSDocType = ts.JSDocType> extends TypeNode<T> {
  4692. }
  4693. /** JS doc type def tag node. */
  4694. export declare class JSDocTypedefTag extends JSDocTag<ts.JSDocTypedefTag> {
  4695. /** @inheritdoc **/
  4696. getParent(): NodeParentType<ts.JSDocTypedefTag>;
  4697. /** @inheritdoc **/
  4698. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocTypedefTag>>;
  4699. }
  4700. /** JS doc type expression node. */
  4701. export declare class JSDocTypeExpression extends TypeNode<ts.JSDocTypeExpression> {
  4702. /** Gets the type node of the JS doc type expression. */
  4703. getTypeNode(): TypeNode<ts.TypeNode>;
  4704. /** @inheritdoc **/
  4705. getParent(): NodeParentType<ts.JSDocTypeExpression>;
  4706. /** @inheritdoc **/
  4707. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocTypeExpression>>;
  4708. }
  4709. /** JS doc type literal. */
  4710. export declare class JSDocTypeLiteral extends JSDocType<ts.JSDocTypeLiteral> {
  4711. /** Gets if it's an array type. */
  4712. isArrayType(): boolean;
  4713. /** Gets the JS doc property tags if they exist. */
  4714. getPropertyTags(): JSDocTag<ts.JSDocTag>[] | undefined;
  4715. /** @inheritdoc **/
  4716. getParent(): NodeParentType<ts.JSDocTypeLiteral>;
  4717. /** @inheritdoc **/
  4718. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocTypeLiteral>>;
  4719. }
  4720. /** JS doc type tag node. */
  4721. export declare class JSDocTypeTag extends JSDocTag<ts.JSDocTypeTag> {
  4722. /** Gets the type expression node of the JS doc property type tag. */
  4723. getTypeExpression(): JSDocTypeExpression | undefined;
  4724. /** @inheritdoc **/
  4725. getParent(): NodeParentType<ts.JSDocTypeTag>;
  4726. /** @inheritdoc **/
  4727. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocTypeTag>>;
  4728. }
  4729. /** JS doc unknown tag node. */
  4730. export declare class JSDocUnknownTag extends JSDocTag<ts.JSDocUnknownTag> {
  4731. /** @inheritdoc **/
  4732. getParent(): NodeParentType<ts.JSDocUnknownTag>;
  4733. /** @inheritdoc **/
  4734. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocUnknownTag>>;
  4735. }
  4736. /** JS doc unknown type. */
  4737. export declare class JSDocUnknownType extends JSDocType<ts.JSDocUnknownType> {
  4738. /** @inheritdoc **/
  4739. getParent(): NodeParentType<ts.JSDocUnknownType>;
  4740. /** @inheritdoc **/
  4741. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocUnknownType>>;
  4742. }
  4743. /** JS doc variadic type. */
  4744. export declare class JSDocVariadicType extends JSDocType<ts.JSDocVariadicType> {
  4745. /** Gets the type node of the JS doc variadic type node. */
  4746. getTypeNode(): TypeNode<ts.TypeNode>;
  4747. /** @inheritdoc **/
  4748. getParent(): NodeParentType<ts.JSDocVariadicType>;
  4749. /** @inheritdoc **/
  4750. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JSDocVariadicType>>;
  4751. }
  4752. export declare class CommentEnumMember extends Node<CompilerCommentEnumMember> {
  4753. /** Removes this enum member comment. */
  4754. remove(): void;
  4755. }
  4756. declare const EnumDeclarationBase: Constructor<TextInsertableNode> & Constructor<ModuleChildableNode> & Constructor<JSDocableNode> & Constructor<AmbientableNode> & Constructor<ExportableNode> & Constructor<ModifierableNode> & Constructor<NamedNode> & typeof Statement;
  4757. export declare class EnumDeclaration extends EnumDeclarationBase<ts.EnumDeclaration> {
  4758. /**
  4759. * Sets the node from a structure.
  4760. * @param structure - Structure to set the node with.
  4761. */
  4762. set(structure: Partial<EnumDeclarationStructure>): this;
  4763. /**
  4764. * Adds a member to the enum.
  4765. * @param structure - Structure of the enum.
  4766. */
  4767. addMember(structure: OptionalKind<EnumMemberStructure>): EnumMember;
  4768. /**
  4769. * Adds a member to the enum.
  4770. * @param structure - Structure of the enum.
  4771. */
  4772. addMember(structure: OptionalKind<EnumMemberStructure> | WriterFunction | string): EnumMember | CommentEnumMember;
  4773. /**
  4774. * Adds members to the enum.
  4775. * @param structures - Structures of the enums.
  4776. */
  4777. addMembers(structures: ReadonlyArray<OptionalKind<EnumMemberStructure>>): EnumMember[];
  4778. /**
  4779. * Adds members to the enum.
  4780. * @param structures - Structures of the enums.
  4781. */
  4782. addMembers(structures: ReadonlyArray<OptionalKind<EnumMemberStructure> | WriterFunction | string> | string | WriterFunction): (EnumMember | CommentEnumMember)[];
  4783. /**
  4784. * Inserts a member to the enum.
  4785. * @param index - Child index to insert at.
  4786. * @param structure - Structure of the enum.
  4787. */
  4788. insertMember(index: number, structure: OptionalKind<EnumMemberStructure>): EnumMember;
  4789. /**
  4790. * Inserts a member to the enum.
  4791. * @param index - Child index to insert at.
  4792. * @param structure - Structure of the enum.
  4793. */
  4794. insertMember(index: number, structure: OptionalKind<EnumMemberStructure> | WriterFunction | string): EnumMember | CommentEnumMember;
  4795. /**
  4796. * Inserts members to an enum.
  4797. * @param index - Child index to insert at.
  4798. * @param structures - Structures of the enums.
  4799. */
  4800. insertMembers(index: number, structures: ReadonlyArray<OptionalKind<EnumMemberStructure>>): EnumMember[];
  4801. /**
  4802. * Inserts members to an enum.
  4803. * @param index - Child index to insert at.
  4804. * @param structures - Structures of the enums.
  4805. */
  4806. insertMembers(index: number, structures: ReadonlyArray<OptionalKind<EnumMemberStructure> | WriterFunction | string> | WriterFunction | string): (EnumMember | CommentEnumMember)[];
  4807. /**
  4808. * Gets an enum member.
  4809. * @param name - Name of the member.
  4810. */
  4811. getMember(name: string): EnumMember | undefined;
  4812. /**
  4813. * Gets an enum member.
  4814. * @param findFunction - Function to use to find the member.
  4815. */
  4816. getMember(findFunction: (declaration: EnumMember) => boolean): EnumMember | undefined;
  4817. /**
  4818. * Gets an enum member or throws if not found.
  4819. * @param name - Name of the member.
  4820. */
  4821. getMemberOrThrow(name: string): EnumMember;
  4822. /**
  4823. * Gets an enum member or throws if not found.
  4824. * @param findFunction - Function to use to find the member.
  4825. */
  4826. getMemberOrThrow(findFunction: (declaration: EnumMember) => boolean): EnumMember;
  4827. /** Gets the enum's members. */
  4828. getMembers(): EnumMember[];
  4829. /** Gets the enum's members with comment enum members. */
  4830. getMembersWithComments(): (EnumMember | CommentEnumMember)[];
  4831. /** Toggle if it's a const enum. */
  4832. setIsConstEnum(value: boolean): this;
  4833. /** Gets if it's a const enum. */
  4834. isConstEnum(): boolean;
  4835. /** Gets the const enum keyword or undefined if not exists. */
  4836. getConstKeyword(): Node<ts.Node> | undefined;
  4837. /** Gets the structure equivalent to this node. */
  4838. getStructure(): EnumDeclarationStructure;
  4839. /** @inheritdoc **/
  4840. getParent(): NodeParentType<ts.EnumDeclaration>;
  4841. /** @inheritdoc **/
  4842. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.EnumDeclaration>>;
  4843. }
  4844. declare const EnumMemberBase: Constructor<JSDocableNode> & Constructor<InitializerExpressionableNode> & Constructor<PropertyNamedNode> & typeof Node;
  4845. export declare class EnumMember extends EnumMemberBase<ts.EnumMember> {
  4846. /** Gets the constant value of the enum. */
  4847. getValue(): string | number | undefined;
  4848. /**
  4849. * Sets the enum value.
  4850. *
  4851. * This is a helper method. Use `#setInitializer` if you want to set the initializer
  4852. * to something other than a string or number.
  4853. * @param value - Enum value.
  4854. */
  4855. setValue(value: string | number): this;
  4856. /** Removes this enum member. */
  4857. remove(): void;
  4858. /**
  4859. * Sets the node from a structure.
  4860. * @param structure - Structure to set the node with.
  4861. */
  4862. set(structure: Partial<EnumMemberStructure>): this;
  4863. /** Gets the structure equivalent to this node. */
  4864. getStructure(): EnumMemberStructure;
  4865. /** @inheritdoc **/
  4866. getParent(): NodeParentType<ts.EnumMember>;
  4867. /** @inheritdoc **/
  4868. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.EnumMember>>;
  4869. }
  4870. declare const ArrayDestructuringAssignmentBase: typeof AssignmentExpression;
  4871. export declare class ArrayDestructuringAssignment extends ArrayDestructuringAssignmentBase<ts.ArrayDestructuringAssignment> {
  4872. /** Gets the left array literal expression of the array destructuring assignment. */
  4873. getLeft(): ArrayLiteralExpression;
  4874. /** @inheritdoc **/
  4875. getParent(): NodeParentType<ts.ArrayDestructuringAssignment>;
  4876. /** @inheritdoc **/
  4877. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ArrayDestructuringAssignment>>;
  4878. }
  4879. export declare class ArrayLiteralExpression extends PrimaryExpression<ts.ArrayLiteralExpression> {
  4880. /** Gets the array's elements. */
  4881. getElements(): Expression[];
  4882. /**
  4883. * Adds an element to the array.
  4884. * @param textOrWriterFunction - Text to add as an element.
  4885. * @param options - Options.
  4886. */
  4887. addElement(textOrWriterFunction: string | WriterFunction, options?: {
  4888. useNewLines?: boolean;
  4889. }): Expression<ts.Expression>;
  4890. /**
  4891. * Adds elements to the array.
  4892. * @param textsOrWriterFunction - Texts to add as elements.
  4893. * @param options - Options.
  4894. */
  4895. addElements(textsOrWriterFunction: ReadonlyArray<string | WriterFunction> | WriterFunction, options?: {
  4896. useNewLines?: boolean;
  4897. }): Expression<ts.Expression>[];
  4898. /**
  4899. * Insert an element into the array.
  4900. * @param index - Child index to insert at.
  4901. * @param text - Text to insert as an element.
  4902. * @param options - Options.
  4903. */
  4904. insertElement(index: number, textOrWriterFunction: string | WriterFunction, options?: {
  4905. useNewLines?: boolean;
  4906. }): Expression<ts.Expression>;
  4907. /**
  4908. * Insert elements into the array.
  4909. * @param index - Child index to insert at.
  4910. * @param textsOrWriterFunction - Texts to insert as elements.
  4911. * @param options - Options.
  4912. */
  4913. insertElements(index: number, textsOrWriterFunction: ReadonlyArray<string | WriterFunction> | WriterFunction, options?: {
  4914. useNewLines?: boolean;
  4915. }): Expression<ts.Expression>[];
  4916. /**
  4917. * Removes an element from the array.
  4918. * @param index - Index to remove from.
  4919. */
  4920. removeElement(index: number): void;
  4921. /**
  4922. * Removes an element from the array.
  4923. * @param element - Element to remove.
  4924. */
  4925. removeElement(element: Expression): void;
  4926. /** @inheritdoc **/
  4927. getParent(): NodeParentType<ts.ArrayLiteralExpression>;
  4928. /** @inheritdoc **/
  4929. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ArrayLiteralExpression>>;
  4930. }
  4931. declare const AsExpressionBase: Constructor<TypedNode> & Constructor<ExpressionedNode> & typeof Expression;
  4932. export declare class AsExpression extends AsExpressionBase<ts.AsExpression> {
  4933. /** @inheritdoc **/
  4934. getParent(): NodeParentType<ts.AsExpression>;
  4935. /** @inheritdoc **/
  4936. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.AsExpression>>;
  4937. }
  4938. declare const AssignmentExpressionBase: typeof BinaryExpression;
  4939. export declare class AssignmentExpression<T extends ts.AssignmentExpression<ts.AssignmentOperatorToken> = ts.AssignmentExpression<ts.AssignmentOperatorToken>> extends AssignmentExpressionBase<T> {
  4940. /** Gets the operator token of the assignment expression. */
  4941. getOperatorToken(): Node<ts.AssignmentOperatorToken>;
  4942. }
  4943. declare const AwaitExpressionBase: Constructor<UnaryExpressionedNode> & typeof UnaryExpression;
  4944. export declare class AwaitExpression extends AwaitExpressionBase<ts.AwaitExpression> {
  4945. /** @inheritdoc **/
  4946. getParent(): NodeParentType<ts.AwaitExpression>;
  4947. /** @inheritdoc **/
  4948. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.AwaitExpression>>;
  4949. }
  4950. export interface InstanceofExpression extends BinaryExpression {
  4951. compilerNode: ts.InstanceofExpression;
  4952. getOperatorToken(): Node<ts.Token<SyntaxKind.InstanceOfKeyword>>;
  4953. }
  4954. declare const BinaryExpressionBase: typeof Expression;
  4955. export declare class BinaryExpression<T extends ts.BinaryExpression = ts.BinaryExpression> extends BinaryExpressionBase<T> {
  4956. /** Gets the left side of the binary expression. */
  4957. getLeft(): Expression;
  4958. /** Gets the operator token of the binary expression. */
  4959. getOperatorToken(): Node<ts.BinaryOperatorToken>;
  4960. /** Gets the right side of the binary expression. */
  4961. getRight(): Expression;
  4962. }
  4963. declare const CallExpressionBase: Constructor<TypeArgumentedNode> & Constructor<ArgumentedNode> & Constructor<QuestionDotTokenableNode> & Constructor<LeftHandSideExpressionedNode> & typeof LeftHandSideExpression;
  4964. export declare class CallExpression<T extends ts.CallExpression = ts.CallExpression> extends CallExpressionBase<T> {
  4965. /** Gets the return type of the call expression. */
  4966. getReturnType(): Type;
  4967. }
  4968. declare const CommaListExpressionBase: typeof Expression;
  4969. export declare class CommaListExpression extends CommaListExpressionBase<ts.CommaListExpression> {
  4970. /** Gets the elements. */
  4971. getElements(): Expression[];
  4972. /** @inheritdoc **/
  4973. getParent(): NodeParentType<ts.CommaListExpression>;
  4974. /** @inheritdoc **/
  4975. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.CommaListExpression>>;
  4976. }
  4977. declare const ConditionalExpressionBase: typeof Expression;
  4978. export declare class ConditionalExpression extends ConditionalExpressionBase<ts.ConditionalExpression> {
  4979. /** Gets the condition of the conditional expression. */
  4980. getCondition(): Expression;
  4981. /** Gets the question token of the conditional expression. */
  4982. getQuestionToken(): Node<ts.QuestionToken>;
  4983. /** Gets the when true expression of the conditional expression. */
  4984. getWhenTrue(): Expression;
  4985. /** Gets the colon token of the conditional expression. */
  4986. getColonToken(): Node<ts.ColonToken>;
  4987. /** Gets the when false expression of the conditional expression. */
  4988. getWhenFalse(): Expression;
  4989. /** @inheritdoc **/
  4990. getParent(): NodeParentType<ts.ConditionalExpression>;
  4991. /** @inheritdoc **/
  4992. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ConditionalExpression>>;
  4993. }
  4994. declare const DeleteExpressionBase: Constructor<UnaryExpressionedNode> & typeof UnaryExpression;
  4995. export declare class DeleteExpression extends DeleteExpressionBase<ts.DeleteExpression> {
  4996. /** @inheritdoc **/
  4997. getParent(): NodeParentType<ts.DeleteExpression>;
  4998. /** @inheritdoc **/
  4999. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.DeleteExpression>>;
  5000. }
  5001. declare const ElementAccessExpressionBase: Constructor<QuestionDotTokenableNode> & Constructor<LeftHandSideExpressionedNode> & typeof MemberExpression;
  5002. export declare class ElementAccessExpression<T extends ts.ElementAccessExpression = ts.ElementAccessExpression> extends ElementAccessExpressionBase<T> {
  5003. /** Gets this element access expression's argument expression or undefined if none exists. */
  5004. getArgumentExpression(): Expression | undefined;
  5005. /** Gets this element access expression's argument expression or throws if none exists. */
  5006. getArgumentExpressionOrThrow(message?: string | (() => string)): Expression<ts.Expression>;
  5007. }
  5008. export declare class Expression<T extends ts.Expression = ts.Expression> extends Node<T> {
  5009. /** Gets the contextual type of the expression. */
  5010. getContextualType(): Type | undefined;
  5011. }
  5012. export declare function ExpressionableNode<T extends Constructor<ExpressionableNodeExtensionType>>(Base: T): Constructor<ExpressionableNode> & T;
  5013. export interface ExpressionableNode {
  5014. /** Gets the expression if it exists or returns undefined. */
  5015. getExpression(): Expression | undefined;
  5016. /** Gets the expression if it exists or throws. */
  5017. getExpressionOrThrow(message?: string | (() => string)): Expression;
  5018. /** Gets the expression if it is of the specified syntax kind or returns undefined. */
  5019. getExpressionIfKind<TKind extends SyntaxKind>(kind: TKind): KindToExpressionMappings[TKind] | undefined;
  5020. /** Gets the expression if it is of the specified syntax kind or throws. */
  5021. getExpressionIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind): KindToExpressionMappings[TKind];
  5022. }
  5023. type ExpressionableNodeExtensionType = Node<ts.Node & {
  5024. expression?: ts.Expression;
  5025. }>;
  5026. export declare function BaseExpressionedNode<T extends Constructor<ExpressionedNodeExtensionType>, TExpression extends Node = CompilerNodeToWrappedType<InstanceOf<T>["compilerNode"]>>(Base: T): Constructor<BaseExpressionedNode<TExpression>> & T;
  5027. export interface BaseExpressionedNode<TExpression extends Node> {
  5028. /** Gets the expression. */
  5029. getExpression(): TExpression;
  5030. /**
  5031. * Gets the expression if its of a certain kind or returns undefined.
  5032. * @param kind - Syntax kind of the expression.
  5033. */
  5034. getExpressionIfKind<TKind extends SyntaxKind>(kind: TKind): KindToExpressionMappings[TKind] | undefined;
  5035. /**
  5036. * Gets the expression if its of a certain kind or throws.
  5037. * @param kind - Syntax kind of the expression.
  5038. */
  5039. getExpressionIfKindOrThrow<TKind extends SyntaxKind>(kind: TKind): KindToExpressionMappings[TKind];
  5040. /**
  5041. * Sets the expression.
  5042. * @param textOrWriterFunction - Text to set the expression with.
  5043. */
  5044. setExpression(textOrWriterFunction: string | WriterFunction): this;
  5045. }
  5046. export declare function ExpressionedNode<T extends Constructor<ExpressionedNodeExtensionType>>(Base: T): Constructor<ExpressionedNode> & T;
  5047. export interface ExpressionedNode extends BaseExpressionedNode<Expression> {
  5048. }
  5049. type ExpressionedNodeExtensionType = Node<ts.Node & {
  5050. expression: ts.Expression;
  5051. }>;
  5052. export declare function ImportExpressionedNode<T extends Constructor<ImportExpressionedNodeExtensionType>>(Base: T): Constructor<ImportExpressionedNode> & T;
  5053. export interface ImportExpressionedNode extends BaseExpressionedNode<ImportExpression> {
  5054. }
  5055. type ImportExpressionedNodeExtensionType = Node<ts.Node & {
  5056. expression: ts.ImportExpression;
  5057. }>;
  5058. export declare function LeftHandSideExpressionedNode<T extends Constructor<LeftHandSideExpressionedNodeExtensionType>>(Base: T): Constructor<LeftHandSideExpressionedNode> & T;
  5059. export interface LeftHandSideExpressionedNode extends BaseExpressionedNode<LeftHandSideExpression> {
  5060. }
  5061. type LeftHandSideExpressionedNodeExtensionType = Node<ts.Node & {
  5062. expression: ts.LeftHandSideExpression;
  5063. }>;
  5064. export declare function SuperExpressionedNode<T extends Constructor<SuperExpressionedNodeExtensionType>>(Base: T): Constructor<SuperExpressionedNode> & T;
  5065. export interface SuperExpressionedNode extends BaseExpressionedNode<SuperExpression> {
  5066. }
  5067. type SuperExpressionedNodeExtensionType = Node<ts.Node & {
  5068. expression: ts.SuperExpression;
  5069. }>;
  5070. export declare function UnaryExpressionedNode<T extends Constructor<UnaryExpressionedNodeExtensionType>>(Base: T): Constructor<UnaryExpressionedNode> & T;
  5071. export interface UnaryExpressionedNode extends BaseExpressionedNode<UnaryExpression> {
  5072. }
  5073. type UnaryExpressionedNodeExtensionType = Node<ts.Node & {
  5074. expression: ts.UnaryExpression;
  5075. }>;
  5076. declare const ImportExpressionBase: typeof PrimaryExpression;
  5077. export declare class ImportExpression extends ImportExpressionBase<ts.ImportExpression> {
  5078. /** @inheritdoc **/
  5079. getParent(): NodeParentType<ts.ImportExpression>;
  5080. /** @inheritdoc **/
  5081. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportExpression>>;
  5082. }
  5083. export declare class LeftHandSideExpression<T extends ts.LeftHandSideExpression = ts.LeftHandSideExpression> extends UpdateExpression<T> {
  5084. }
  5085. declare const LiteralExpressionBase: Constructor<LiteralLikeNode> & typeof PrimaryExpression;
  5086. export declare class LiteralExpression<T extends ts.LiteralExpression = ts.LiteralExpression> extends LiteralExpressionBase<T> {
  5087. }
  5088. export declare class MemberExpression<T extends ts.MemberExpression = ts.MemberExpression> extends LeftHandSideExpression<T> {
  5089. }
  5090. declare const MetaPropertyBase: Constructor<NamedNode> & typeof PrimaryExpression;
  5091. export declare class MetaProperty extends MetaPropertyBase<ts.MetaProperty> {
  5092. /** Gets the keyword token. */
  5093. getKeywordToken(): SyntaxKind.ImportKeyword | SyntaxKind.NewKeyword;
  5094. /** @inheritdoc **/
  5095. getParent(): NodeParentType<ts.MetaProperty>;
  5096. /** @inheritdoc **/
  5097. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.MetaProperty>>;
  5098. }
  5099. declare const NewExpressionBase: Constructor<TypeArgumentedNode> & Constructor<ArgumentedNode> & Constructor<LeftHandSideExpressionedNode> & typeof PrimaryExpression;
  5100. export declare class NewExpression extends NewExpressionBase<ts.NewExpression> {
  5101. /** @inheritdoc **/
  5102. getParent(): NodeParentType<ts.NewExpression>;
  5103. /** @inheritdoc **/
  5104. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NewExpression>>;
  5105. }
  5106. declare const NonNullExpressionBase: Constructor<ExpressionedNode> & typeof LeftHandSideExpression;
  5107. export declare class NonNullExpression extends NonNullExpressionBase<ts.NonNullExpression> {
  5108. /** @inheritdoc **/
  5109. getParent(): NodeParentType<ts.NonNullExpression>;
  5110. /** @inheritdoc **/
  5111. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NonNullExpression>>;
  5112. }
  5113. export declare class CommentObjectLiteralElement extends ObjectLiteralElement<CompilerCommentObjectLiteralElement> {
  5114. }
  5115. declare const ObjectDestructuringAssignmentBase: typeof AssignmentExpression;
  5116. export declare class ObjectDestructuringAssignment extends ObjectDestructuringAssignmentBase<ts.ObjectDestructuringAssignment> {
  5117. /** Gets the left object literal expression of the object destructuring assignment. */
  5118. getLeft(): ObjectLiteralExpression;
  5119. /** @inheritdoc **/
  5120. getParent(): NodeParentType<ts.ObjectDestructuringAssignment>;
  5121. /** @inheritdoc **/
  5122. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ObjectDestructuringAssignment>>;
  5123. }
  5124. export declare class ObjectLiteralElement<T extends ts.ObjectLiteralElement = ts.ObjectLiteralElement> extends Node<T> {
  5125. /** Removes the object literal element from the object literal expression. */
  5126. remove(): void;
  5127. }
  5128. declare const ObjectLiteralExpressionBase: typeof PrimaryExpression;
  5129. export declare class ObjectLiteralExpression extends ObjectLiteralExpressionBase<ts.ObjectLiteralExpression> {
  5130. #private;
  5131. /**
  5132. * Gets the first property by the provided name or throws.
  5133. * @param name - Name of the property.
  5134. */
  5135. getPropertyOrThrow(name: string): ObjectLiteralElementLike;
  5136. /**
  5137. * Gets the first property that matches the provided find function or throws.
  5138. * @param findFunction - Find function.
  5139. */
  5140. getPropertyOrThrow(findFunction: (property: ObjectLiteralElementLike) => boolean): ObjectLiteralElementLike;
  5141. /**
  5142. * Gets the first property by the provided name or returns undefined.
  5143. * @param name - Name of the property.
  5144. */
  5145. getProperty(name: string): ObjectLiteralElementLike | undefined;
  5146. /**
  5147. * Gets the first property that matches the provided find function or returns undefined.
  5148. * @param findFunction - Find function.
  5149. */
  5150. getProperty(findFunction: (property: ObjectLiteralElementLike) => boolean): ObjectLiteralElementLike | undefined;
  5151. /** Gets the properties. */
  5152. getProperties(): ObjectLiteralElementLike[];
  5153. /** Gets the properties with comment object literal elements. */
  5154. getPropertiesWithComments(): (ObjectLiteralElementLike | CommentObjectLiteralElement)[];
  5155. /**
  5156. * Adds the specified property to the object literal expression.
  5157. *
  5158. * Note: If you only want to add a property assignment, then it might be more convenient to use #addPropertyAssignment.
  5159. * @structure - The structure to add.
  5160. */
  5161. addProperty(structure: string | WriterFunction | ObjectLiteralExpressionPropertyStructures): CommentObjectLiteralElement | ObjectLiteralElementLike;
  5162. /**
  5163. * Adds the specified properties to the object literal expression.
  5164. *
  5165. * Note: If you only want to add property assignments, then it might be more convenient to use #addPropertyAssignments.
  5166. * @structures - The structures to add.
  5167. */
  5168. addProperties(structures: string | WriterFunction | ReadonlyArray<string | WriterFunction | ObjectLiteralExpressionPropertyStructures>): (CommentObjectLiteralElement | ObjectLiteralElementLike)[];
  5169. /**
  5170. * Inserts the specified property to the object literal expression.
  5171. *
  5172. * Note: If you only want to insert a property assignment, then it might be more convenient to use #insertPropertyAssignment.
  5173. * @index - The index to insert at.
  5174. * @structure - The structure to insert.
  5175. */
  5176. insertProperty(index: number, structure: string | WriterFunction | ObjectLiteralExpressionPropertyStructures): CommentObjectLiteralElement | ObjectLiteralElementLike;
  5177. /**
  5178. * Inserts the specified properties to the object literal expression.
  5179. *
  5180. * Note: If you only want to insert property assignments, then it might be more convenient to use #insertPropertyAssignments.
  5181. * @index - The index to insert at.
  5182. * @structures - The structures to insert.
  5183. */
  5184. insertProperties(index: number, structures: string | WriterFunction | ReadonlyArray<string | WriterFunction | ObjectLiteralExpressionPropertyStructures>): (CommentObjectLiteralElement | ObjectLiteralElementLike)[];
  5185. /**
  5186. * Adds a property assignment.
  5187. * @param structure - Structure that represents the property assignment to add.
  5188. */
  5189. addPropertyAssignment(structure: OptionalKind<PropertyAssignmentStructure>): PropertyAssignment;
  5190. /**
  5191. * Adds property assignments.
  5192. * @param structures - Structure that represents the property assignments to add.
  5193. */
  5194. addPropertyAssignments(structures: ReadonlyArray<OptionalKind<PropertyAssignmentStructure>>): PropertyAssignment[];
  5195. /**
  5196. * Inserts a property assignment at the specified index.
  5197. * @param index - Child index to insert at.
  5198. * @param structure - Structure that represents the property assignment to insert.
  5199. */
  5200. insertPropertyAssignment(index: number, structure: OptionalKind<PropertyAssignmentStructure>): PropertyAssignment;
  5201. /**
  5202. * Inserts property assignments at the specified index.
  5203. * @param index - Child index to insert at.
  5204. * @param structures - Structures that represent the property assignments to insert.
  5205. */
  5206. insertPropertyAssignments(index: number, structures: ReadonlyArray<OptionalKind<PropertyAssignmentStructure>>): PropertyAssignment[];
  5207. /**
  5208. * Adds a shorthand property assignment.
  5209. * @param structure - Structure that represents the shorthand property assignment to add.
  5210. */
  5211. addShorthandPropertyAssignment(structure: OptionalKind<ShorthandPropertyAssignmentStructure>): ShorthandPropertyAssignment;
  5212. /**
  5213. * Adds shorthand property assignments.
  5214. * @param structures - Structure that represents the shorthand property assignments to add.
  5215. */
  5216. addShorthandPropertyAssignments(structures: ReadonlyArray<OptionalKind<ShorthandPropertyAssignmentStructure>>): ShorthandPropertyAssignment[];
  5217. /**
  5218. * Inserts a shorthand property assignment at the specified index.
  5219. * @param index - Child index to insert at.
  5220. * @param structure - Structure that represents the shorthand property assignment to insert.
  5221. */
  5222. insertShorthandPropertyAssignment(index: number, structure: OptionalKind<ShorthandPropertyAssignmentStructure>): ShorthandPropertyAssignment;
  5223. /**
  5224. * Inserts shorthand property assignments at the specified index.
  5225. * @param index - Child index to insert at.
  5226. * @param structures - Structures that represent the shorthand property assignments to insert.
  5227. */
  5228. insertShorthandPropertyAssignments(index: number, structures: ReadonlyArray<OptionalKind<ShorthandPropertyAssignmentStructure>>): ShorthandPropertyAssignment[];
  5229. /**
  5230. * Adds a spread assignment.
  5231. * @param structure - Structure that represents the spread assignment to add.
  5232. */
  5233. addSpreadAssignment(structure: OptionalKind<SpreadAssignmentStructure>): SpreadAssignment;
  5234. /**
  5235. * Adds spread assignments.
  5236. * @param structures - Structure that represents the spread assignments to add.
  5237. */
  5238. addSpreadAssignments(structures: ReadonlyArray<OptionalKind<SpreadAssignmentStructure>>): SpreadAssignment[];
  5239. /**
  5240. * Inserts a spread assignment at the specified index.
  5241. * @param index - Child index to insert at.
  5242. * @param structure - Structure that represents the spread assignment to insert.
  5243. */
  5244. insertSpreadAssignment(index: number, structure: OptionalKind<SpreadAssignmentStructure>): SpreadAssignment;
  5245. /**
  5246. * Inserts spread assignments at the specified index.
  5247. * @param index - Child index to insert at.
  5248. * @param structures - Structures that represent the spread assignments to insert.
  5249. */
  5250. insertSpreadAssignments(index: number, structures: ReadonlyArray<OptionalKind<SpreadAssignmentStructure>>): SpreadAssignment[];
  5251. /**
  5252. * Adds a method.
  5253. * @param structure - Structure that represents the method to add.
  5254. */
  5255. addMethod(structure: OptionalKind<MethodDeclarationStructure>): MethodDeclaration;
  5256. /**
  5257. * Adds methods.
  5258. * @param structures - Structure that represents the methods to add.
  5259. */
  5260. addMethods(structures: ReadonlyArray<OptionalKind<MethodDeclarationStructure>>): MethodDeclaration[];
  5261. /**
  5262. * Inserts a method at the specified index.
  5263. * @param index - Child index to insert at.
  5264. * @param structure - Structure that represents the method to insert.
  5265. */
  5266. insertMethod(index: number, structure: OptionalKind<MethodDeclarationStructure>): MethodDeclaration;
  5267. /**
  5268. * Inserts methods at the specified index.
  5269. * @param index - Child index to insert at.
  5270. * @param structures - Structures that represent the methods to insert.
  5271. */
  5272. insertMethods(index: number, structures: ReadonlyArray<OptionalKind<MethodDeclarationStructure>>): MethodDeclaration[];
  5273. /**
  5274. * Adds a get accessor.
  5275. * @param structure - Structure that represents the property assignment to add.
  5276. */
  5277. addGetAccessor(structure: OptionalKind<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
  5278. /**
  5279. * Adds get accessors.
  5280. * @param structures - Structure that represents the get accessors to add.
  5281. */
  5282. addGetAccessors(structures: ReadonlyArray<OptionalKind<GetAccessorDeclarationStructure>>): GetAccessorDeclaration[];
  5283. /**
  5284. * Inserts a get accessor at the specified index.
  5285. * @param index - Child index to insert at.
  5286. * @param structure - Structure that represents the get accessor to insert.
  5287. */
  5288. insertGetAccessor(index: number, structure: OptionalKind<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
  5289. /**
  5290. * Inserts get accessors at the specified index.
  5291. * @param index - Child index to insert at.
  5292. * @param structures - Structures that represent the get accessors to insert.
  5293. */
  5294. insertGetAccessors(index: number, structures: ReadonlyArray<OptionalKind<GetAccessorDeclarationStructure>>): GetAccessorDeclaration[];
  5295. /**
  5296. * Adds a set accessor.
  5297. * @param structure - Structure that represents the property assignment to add.
  5298. */
  5299. addSetAccessor(structure: OptionalKind<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
  5300. /**
  5301. * Adds set accessors.
  5302. * @param structures - Structure that represents the set accessors to add.
  5303. */
  5304. addSetAccessors(structures: ReadonlyArray<OptionalKind<SetAccessorDeclarationStructure>>): SetAccessorDeclaration[];
  5305. /**
  5306. * Inserts a set accessor at the specified index.
  5307. * @param index - Child index to insert at.
  5308. * @param structure - Structure that represents the set accessor to insert.
  5309. */
  5310. insertSetAccessor(index: number, structure: OptionalKind<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
  5311. /**
  5312. * Inserts set accessors at the specified index.
  5313. * @param index - Child index to insert at.
  5314. * @param structures - Structures that represent the set accessors to insert.
  5315. */
  5316. insertSetAccessors(index: number, structures: ReadonlyArray<OptionalKind<SetAccessorDeclarationStructure>>): SetAccessorDeclaration[];
  5317. /** @inheritdoc **/
  5318. getParent(): NodeParentType<ts.ObjectLiteralExpression>;
  5319. /** @inheritdoc **/
  5320. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ObjectLiteralExpression>>;
  5321. }
  5322. declare const PropertyAssignmentBase: Constructor<InitializerExpressionGetableNode> & Constructor<QuestionTokenableNode> & Constructor<PropertyNamedNode> & typeof ObjectLiteralElement;
  5323. export declare class PropertyAssignment extends PropertyAssignmentBase<ts.PropertyAssignment> {
  5324. /**
  5325. * Removes the initializer and returns the new shorthand property assignment.
  5326. *
  5327. * Note: The current node will no longer be valid because it's no longer a property assignment.
  5328. */
  5329. removeInitializer(): ShorthandPropertyAssignment;
  5330. /**
  5331. * Sets the initializer.
  5332. * @param textOrWriterFunction - New text ot set for the initializer.
  5333. */
  5334. setInitializer(textOrWriterFunction: string | WriterFunction): this;
  5335. /**
  5336. * Sets the node from a structure.
  5337. * @param structure - Structure to set the node with.
  5338. */
  5339. set(structure: Partial<PropertyAssignmentStructure>): this | ShorthandPropertyAssignment;
  5340. /** Gets the structure equivalent to this node. */
  5341. getStructure(): PropertyAssignmentStructure;
  5342. /** @inheritdoc **/
  5343. getParent(): NodeParentType<ts.PropertyAssignment>;
  5344. /** @inheritdoc **/
  5345. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PropertyAssignment>>;
  5346. }
  5347. declare const ShorthandPropertyAssignmentBase: Constructor<InitializerExpressionGetableNode> & Constructor<QuestionTokenableNode> & Constructor<NamedNode> & typeof ObjectLiteralElement;
  5348. export declare class ShorthandPropertyAssignment extends ShorthandPropertyAssignmentBase<ts.ShorthandPropertyAssignment> {
  5349. /** Gets if the shorthand property assignment has an object assignment initializer. */
  5350. hasObjectAssignmentInitializer(): boolean;
  5351. /** Gets the object assignment initializer or throws if it doesn't exist. */
  5352. getObjectAssignmentInitializerOrThrow(message?: string | (() => string)): Expression<ts.Expression>;
  5353. /** Gets the object assignment initializer if it exists. */
  5354. getObjectAssignmentInitializer(): Expression | undefined;
  5355. /** Gets the equals token or throws if it doesn't exist. */
  5356. getEqualsTokenOrThrow(message?: string | (() => string)): Node<ts.EqualsToken>;
  5357. /** Gets the equals token if it exists. */
  5358. getEqualsToken(): Node<ts.EqualsToken> | undefined;
  5359. /**
  5360. * Remove the object assignment initializer.
  5361. *
  5362. * This is only useful to remove bad code.
  5363. */
  5364. removeObjectAssignmentInitializer(): this;
  5365. /**
  5366. * Sets the initializer.
  5367. *
  5368. * Note: The current node will no longer be valid because it's no longer a shorthand property assignment.
  5369. * @param text - New text to set for the initializer.
  5370. */
  5371. setInitializer(text: string): PropertyAssignment;
  5372. /**
  5373. * Sets the node from a structure.
  5374. * @param structure - Structure to set the node with.
  5375. */
  5376. set(structure: Partial<ShorthandPropertyAssignmentStructure>): this;
  5377. /** Gets the structure equivalent to this node. */
  5378. getStructure(): ShorthandPropertyAssignmentStructure;
  5379. /**
  5380. * Gets the shorthand assignment value symbol of this node if it exists. Convenience API
  5381. * for TypeChecker#getShorthandAssignmentValueSymbol(node)
  5382. */
  5383. getValueSymbol(): Symbol | undefined;
  5384. /** Gets the value symbol or throws if it doesn't exist. */
  5385. getValueSymbolOrThrow(message?: string | (() => string)): Symbol;
  5386. /** @inheritdoc **/
  5387. getParent(): NodeParentType<ts.ShorthandPropertyAssignment>;
  5388. /** @inheritdoc **/
  5389. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ShorthandPropertyAssignment>>;
  5390. }
  5391. declare const SpreadAssignmentBase: Constructor<ExpressionedNode> & typeof ObjectLiteralElement;
  5392. export declare class SpreadAssignment extends SpreadAssignmentBase<ts.SpreadAssignment> {
  5393. /**
  5394. * Sets the node from a structure.
  5395. * @param structure - Structure to set the node with.
  5396. */
  5397. set(structure: Partial<SpreadAssignmentStructure>): this;
  5398. /** Gets the structure equivalent to this node. */
  5399. getStructure(): SpreadAssignmentStructure;
  5400. /** @inheritdoc **/
  5401. getParent(): NodeParentType<ts.SpreadAssignment>;
  5402. /** @inheritdoc **/
  5403. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SpreadAssignment>>;
  5404. }
  5405. declare const OmittedExpressionBase: typeof Expression;
  5406. export declare class OmittedExpression extends OmittedExpressionBase<ts.OmittedExpression> {
  5407. /** @inheritdoc **/
  5408. getParent(): NodeParentType<ts.OmittedExpression>;
  5409. /** @inheritdoc **/
  5410. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.OmittedExpression>>;
  5411. }
  5412. declare const ParenthesizedExpressionBase: Constructor<ExpressionedNode> & typeof Expression;
  5413. export declare class ParenthesizedExpression extends ParenthesizedExpressionBase<ts.ParenthesizedExpression> {
  5414. /** @inheritdoc **/
  5415. getParent(): NodeParentType<ts.ParenthesizedExpression>;
  5416. /** @inheritdoc **/
  5417. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ParenthesizedExpression>>;
  5418. }
  5419. declare const PartiallyEmittedExpressionBase: Constructor<ExpressionedNode> & typeof Expression;
  5420. export declare class PartiallyEmittedExpression extends PartiallyEmittedExpressionBase<ts.PartiallyEmittedExpression> {
  5421. /** @inheritdoc **/
  5422. getParent(): NodeParentType<ts.PartiallyEmittedExpression>;
  5423. /** @inheritdoc **/
  5424. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PartiallyEmittedExpression>>;
  5425. }
  5426. declare const PostfixUnaryExpressionBase: typeof UnaryExpression;
  5427. export declare class PostfixUnaryExpression extends PostfixUnaryExpressionBase<ts.PostfixUnaryExpression> {
  5428. /** Gets the operator token of the postfix unary expression. */
  5429. getOperatorToken(): ts.PostfixUnaryOperator;
  5430. /** Gets the operand of the postfix unary expression. */
  5431. getOperand(): LeftHandSideExpression;
  5432. /** @inheritdoc **/
  5433. getParent(): NodeParentType<ts.PostfixUnaryExpression>;
  5434. /** @inheritdoc **/
  5435. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PostfixUnaryExpression>>;
  5436. }
  5437. declare const PrefixUnaryExpressionBase: typeof UnaryExpression;
  5438. export declare class PrefixUnaryExpression extends PrefixUnaryExpressionBase<ts.PrefixUnaryExpression> {
  5439. /** Gets the operator token of the prefix unary expression. */
  5440. getOperatorToken(): ts.PrefixUnaryOperator;
  5441. /** Gets the operand of the prefix unary expression. */
  5442. getOperand(): UnaryExpression;
  5443. /** @inheritdoc **/
  5444. getParent(): NodeParentType<ts.PrefixUnaryExpression>;
  5445. /** @inheritdoc **/
  5446. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PrefixUnaryExpression>>;
  5447. }
  5448. export declare class PrimaryExpression<T extends ts.PrimaryExpression = ts.PrimaryExpression> extends MemberExpression<T> {
  5449. }
  5450. declare const PropertyAccessExpressionBase: Constructor<NamedNode> & Constructor<QuestionDotTokenableNode> & Constructor<LeftHandSideExpressionedNode> & typeof MemberExpression;
  5451. export declare class PropertyAccessExpression<T extends ts.PropertyAccessExpression = ts.PropertyAccessExpression> extends PropertyAccessExpressionBase<T> {
  5452. }
  5453. declare const SatisfiesExpressionBase: Constructor<TypedNode> & Constructor<ExpressionedNode> & typeof Expression;
  5454. export declare class SatisfiesExpression extends SatisfiesExpressionBase<ts.SatisfiesExpression> {
  5455. /** @inheritdoc **/
  5456. getParent(): NodeParentType<ts.SatisfiesExpression>;
  5457. /** @inheritdoc **/
  5458. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SatisfiesExpression>>;
  5459. }
  5460. declare const SpreadElementBase: Constructor<ExpressionedNode> & typeof Expression;
  5461. export declare class SpreadElement extends SpreadElementBase<ts.SpreadElement> {
  5462. /** @inheritdoc **/
  5463. getParent(): NodeParentType<ts.SpreadElement>;
  5464. /** @inheritdoc **/
  5465. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SpreadElement>>;
  5466. }
  5467. declare const SuperElementAccessExpressionBase: Constructor<SuperExpressionedNode> & typeof ElementAccessExpression;
  5468. export declare class SuperElementAccessExpression extends SuperElementAccessExpressionBase<ts.SuperElementAccessExpression> {
  5469. /** @inheritdoc **/
  5470. getParent(): NodeParentType<ts.SuperElementAccessExpression>;
  5471. /** @inheritdoc **/
  5472. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SuperElementAccessExpression>>;
  5473. }
  5474. declare const SuperExpressionBase: typeof PrimaryExpression;
  5475. export declare class SuperExpression extends SuperExpressionBase<ts.SuperExpression> {
  5476. /** @inheritdoc **/
  5477. getParent(): NodeParentType<ts.SuperExpression>;
  5478. /** @inheritdoc **/
  5479. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SuperExpression>>;
  5480. }
  5481. declare const SuperPropertyAccessExpressionBase: Constructor<SuperExpressionedNode> & typeof PropertyAccessExpression;
  5482. export declare class SuperPropertyAccessExpression extends SuperPropertyAccessExpressionBase<ts.SuperPropertyAccessExpression> {
  5483. /** @inheritdoc **/
  5484. getParent(): NodeParentType<ts.SuperPropertyAccessExpression>;
  5485. /** @inheritdoc **/
  5486. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SuperPropertyAccessExpression>>;
  5487. }
  5488. declare const ThisExpressionBase: typeof PrimaryExpression;
  5489. export declare class ThisExpression extends ThisExpressionBase<ts.ThisExpression> {
  5490. /** @inheritdoc **/
  5491. getParent(): NodeParentType<ts.ThisExpression>;
  5492. /** @inheritdoc **/
  5493. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ThisExpression>>;
  5494. }
  5495. declare const TypeAssertionBase: Constructor<TypedNode> & Constructor<UnaryExpressionedNode> & typeof UnaryExpression;
  5496. export declare class TypeAssertion extends TypeAssertionBase<ts.TypeAssertion> {
  5497. /** @inheritdoc **/
  5498. getParent(): NodeParentType<ts.TypeAssertion>;
  5499. /** @inheritdoc **/
  5500. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeAssertion>>;
  5501. }
  5502. declare const TypeOfExpressionBase: Constructor<UnaryExpressionedNode> & typeof UnaryExpression;
  5503. export declare class TypeOfExpression extends TypeOfExpressionBase<ts.TypeOfExpression> {
  5504. /** @inheritdoc **/
  5505. getParent(): NodeParentType<ts.TypeOfExpression>;
  5506. /** @inheritdoc **/
  5507. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeOfExpression>>;
  5508. }
  5509. export declare class UnaryExpression<T extends ts.UnaryExpression = ts.UnaryExpression> extends Expression<T> {
  5510. }
  5511. export declare class UpdateExpression<T extends ts.UpdateExpression = ts.UpdateExpression> extends UnaryExpression<T> {
  5512. }
  5513. declare const VoidExpressionBase: Constructor<UnaryExpressionedNode> & typeof UnaryExpression;
  5514. export declare class VoidExpression extends VoidExpressionBase<ts.VoidExpression> {
  5515. /** @inheritdoc **/
  5516. getParent(): NodeParentType<ts.VoidExpression>;
  5517. /** @inheritdoc **/
  5518. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.VoidExpression>>;
  5519. }
  5520. declare const YieldExpressionBase: Constructor<ExpressionableNode> & Constructor<GeneratorableNode> & typeof Expression;
  5521. export declare class YieldExpression extends YieldExpressionBase<ts.YieldExpression> {
  5522. /** @inheritdoc **/
  5523. getParent(): NodeParentType<ts.YieldExpression>;
  5524. /** @inheritdoc **/
  5525. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.YieldExpression>>;
  5526. }
  5527. declare const ArrowFunctionBase: Constructor<TextInsertableNode> & Constructor<BodiedNode> & Constructor<AsyncableNode> & Constructor<FunctionLikeDeclaration> & typeof Expression;
  5528. export declare class ArrowFunction extends ArrowFunctionBase<ts.ArrowFunction> {
  5529. /** Gets the equals greater than token of the arrow function. */
  5530. getEqualsGreaterThan(): Node<ts.Token<SyntaxKind.EqualsGreaterThanToken>>;
  5531. /** @inheritdoc **/
  5532. getParent(): NodeParentType<ts.ArrowFunction>;
  5533. /** @inheritdoc **/
  5534. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ArrowFunction>>;
  5535. }
  5536. declare const FunctionDeclarationBase: Constructor<UnwrappableNode> & Constructor<TextInsertableNode> & Constructor<OverloadableNode> & Constructor<BodyableNode> & Constructor<AsyncableNode> & Constructor<GeneratorableNode> & Constructor<AmbientableNode> & Constructor<ExportableNode> & Constructor<FunctionLikeDeclaration> & Constructor<ModuleChildableNode> & Constructor<NameableNode> & typeof Statement;
  5537. declare const FunctionDeclarationOverloadBase: Constructor<UnwrappableNode> & Constructor<TextInsertableNode> & Constructor<AsyncableNode> & Constructor<GeneratorableNode> & Constructor<SignaturedDeclaration> & Constructor<AmbientableNode> & Constructor<ModuleChildableNode> & Constructor<JSDocableNode> & Constructor<TypeParameteredNode> & Constructor<ExportableNode> & Constructor<ModifierableNode> & typeof Statement;
  5538. export declare class FunctionDeclaration extends FunctionDeclarationBase<ts.FunctionDeclaration> {
  5539. /**
  5540. * Adds a function overload.
  5541. * @param structure - Structure of the overload.
  5542. */
  5543. addOverload(structure: OptionalKind<FunctionDeclarationOverloadStructure>): FunctionDeclaration;
  5544. /**
  5545. * Adds function overloads.
  5546. * @param structures - Structures of the overloads.
  5547. */
  5548. addOverloads(structures: ReadonlyArray<OptionalKind<FunctionDeclarationOverloadStructure>>): FunctionDeclaration[];
  5549. /**
  5550. * Inserts a function overload.
  5551. * @param index - Child index to insert at.
  5552. * @param structure - Structure of the overload.
  5553. */
  5554. insertOverload(index: number, structure: OptionalKind<FunctionDeclarationOverloadStructure>): FunctionDeclaration;
  5555. /**
  5556. * Inserts function overloads.
  5557. * @param index - Child index to insert at.
  5558. * @param structure - Structures of the overloads.
  5559. */
  5560. insertOverloads(index: number, structures: ReadonlyArray<OptionalKind<FunctionDeclarationOverloadStructure>>): FunctionDeclaration[];
  5561. /** Removes this function declaration. */
  5562. remove(): void;
  5563. /**
  5564. * Sets the node from a structure.
  5565. * @param structure - Structure to set the node with.
  5566. */
  5567. set(structure: Partial<FunctionDeclarationStructure>): this;
  5568. /** Gets the structure equivalent to this node. */
  5569. getStructure(): FunctionDeclarationStructure | FunctionDeclarationOverloadStructure;
  5570. /** @inheritdoc **/
  5571. getParent(): NodeParentType<ts.FunctionDeclaration>;
  5572. /** @inheritdoc **/
  5573. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.FunctionDeclaration>>;
  5574. }
  5575. declare const FunctionExpressionBase: Constructor<JSDocableNode> & Constructor<TextInsertableNode> & Constructor<BodiedNode> & Constructor<AsyncableNode> & Constructor<GeneratorableNode> & Constructor<StatementedNode> & Constructor<TypeParameteredNode> & Constructor<SignaturedDeclaration> & Constructor<ModifierableNode> & Constructor<NameableNode> & typeof PrimaryExpression;
  5576. export declare class FunctionExpression extends FunctionExpressionBase<ts.FunctionExpression> {
  5577. /** @inheritdoc **/
  5578. getParent(): NodeParentType<ts.FunctionExpression>;
  5579. /** @inheritdoc **/
  5580. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.FunctionExpression>>;
  5581. }
  5582. export declare function FunctionLikeDeclaration<T extends Constructor<FunctionLikeDeclarationExtensionType>>(Base: T): Constructor<FunctionLikeDeclaration> & T;
  5583. export interface FunctionLikeDeclaration extends JSDocableNode, TypeParameteredNode, SignaturedDeclaration, StatementedNode, ModifierableNode {
  5584. }
  5585. type FunctionLikeDeclarationExtensionType = Node<ts.FunctionLikeDeclaration>;
  5586. export declare function OverloadableNode<T extends Constructor<OverloadableNodeExtensionType>>(Base: T): Constructor<OverloadableNode> & T;
  5587. /** Node that supports overloads. */
  5588. export interface OverloadableNode {
  5589. /** Gets all the overloads associated with this node. */
  5590. getOverloads(): this[];
  5591. /** Gets the implementation or undefined if it doesn't exist. */
  5592. getImplementation(): this | undefined;
  5593. /** Gets the implementation or throws if it doesn't exist. */
  5594. getImplementationOrThrow(message?: string | (() => string)): this;
  5595. /** Gets if this is not the implementation. */
  5596. isOverload(): boolean;
  5597. /** Gets if this is the implementation. */
  5598. isImplementation(): boolean;
  5599. }
  5600. type OverloadableNodeExtensionType = Node & BodyableNode;
  5601. declare const ParameterDeclarationBase: Constructor<OverrideableNode> & Constructor<QuestionTokenableNode> & Constructor<DecoratableNode> & Constructor<ScopeableNode> & Constructor<ReadonlyableNode> & Constructor<ModifierableNode> & Constructor<DotDotDotTokenableNode> & Constructor<TypedNode> & Constructor<InitializerExpressionableNode> & Constructor<BindingNamedNode> & typeof Node;
  5602. export declare class ParameterDeclaration extends ParameterDeclarationBase<ts.ParameterDeclaration> {
  5603. /** Gets if it's a rest parameter. */
  5604. isRestParameter(): boolean;
  5605. /** Gets if this is a property with a scope, readonly, or override keyword (found in class constructors). */
  5606. isParameterProperty(): boolean;
  5607. /**
  5608. * Sets if it's a rest parameter.
  5609. * @param value - Sets if it's a rest parameter or not.
  5610. */
  5611. setIsRestParameter(value: boolean): this;
  5612. /** Gets if it's optional. */
  5613. isOptional(): boolean;
  5614. /** Remove this parameter. */
  5615. remove(): void;
  5616. /**
  5617. * Sets the node from a structure.
  5618. * @param structure - Structure to set the node with.
  5619. */
  5620. set(structure: Partial<ParameterDeclarationStructure>): this;
  5621. /** Gets the structure equivalent to this node. */
  5622. getStructure(): ParameterDeclarationStructure;
  5623. /**
  5624. * Sets if this node has a question token.
  5625. * @param value - If it should have a question token or not.
  5626. */
  5627. setHasQuestionToken(value: boolean): this;
  5628. /**
  5629. * Sets the initializer.
  5630. * @param text - Text or writer function to set for the initializer.
  5631. */
  5632. setInitializer(textOrWriterFunction: string | WriterFunction): this;
  5633. /**
  5634. * Sets the type.
  5635. * @param textOrWriterFunction - Text or writer function to set the type with.
  5636. */
  5637. setType(textOrWriterFunction: string | WriterFunction): this;
  5638. /** @inheritdoc **/
  5639. getParent(): NodeParentType<ts.ParameterDeclaration>;
  5640. /** @inheritdoc **/
  5641. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ParameterDeclaration>>;
  5642. }
  5643. export declare class HeritageClause extends Node<ts.HeritageClause> {
  5644. /** Gets all the type nodes for the heritage clause. */
  5645. getTypeNodes(): ExpressionWithTypeArguments[];
  5646. /** Gets the heritage clause token. */
  5647. getToken(): SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
  5648. /**
  5649. * Remove the expression from the heritage clause.
  5650. * @param index - Index of the expression to remove.
  5651. */
  5652. removeExpression(index: number): this;
  5653. /**
  5654. * Removes the expression from the heritage clause.
  5655. * @param expressionNode - Expression to remove.
  5656. */
  5657. removeExpression(expressionNode: ExpressionWithTypeArguments): this;
  5658. /** @inheritdoc **/
  5659. getParent(): NodeParentType<ts.HeritageClause>;
  5660. /** @inheritdoc **/
  5661. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.HeritageClause>>;
  5662. }
  5663. declare const CallSignatureDeclarationBase: Constructor<TypeParameteredNode> & Constructor<ChildOrderableNode> & Constructor<JSDocableNode> & Constructor<SignaturedDeclaration> & typeof TypeElement;
  5664. export declare class CallSignatureDeclaration extends CallSignatureDeclarationBase<ts.CallSignatureDeclaration> {
  5665. /**
  5666. * Sets the node from a structure.
  5667. * @param structure - Structure to set the node with.
  5668. */
  5669. set(structure: Partial<CallSignatureDeclarationStructure>): this;
  5670. /** Gets the structure equivalent to this node. */
  5671. getStructure(): CallSignatureDeclarationStructure;
  5672. /** @inheritdoc **/
  5673. getParent(): NodeParentType<ts.CallSignatureDeclaration>;
  5674. /** @inheritdoc **/
  5675. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.CallSignatureDeclaration>>;
  5676. }
  5677. export declare class CommentTypeElement extends TypeElement<CompilerCommentTypeElement> {
  5678. }
  5679. declare const ConstructSignatureDeclarationBase: Constructor<TypeParameteredNode> & Constructor<ChildOrderableNode> & Constructor<JSDocableNode> & Constructor<SignaturedDeclaration> & typeof TypeElement;
  5680. export declare class ConstructSignatureDeclaration extends ConstructSignatureDeclarationBase<ts.ConstructSignatureDeclaration> {
  5681. /**
  5682. * Sets the node from a structure.
  5683. * @param structure - Structure to set the node with.
  5684. */
  5685. set(structure: Partial<ConstructSignatureDeclarationStructure>): this;
  5686. /** Gets the structure equivalent to this node. */
  5687. getStructure(): ConstructSignatureDeclarationStructure;
  5688. /** @inheritdoc **/
  5689. getParent(): NodeParentType<ts.ConstructSignatureDeclaration>;
  5690. /** @inheritdoc **/
  5691. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ConstructSignatureDeclaration>>;
  5692. }
  5693. declare const IndexSignatureDeclarationBase: Constructor<ReturnTypedNode> & Constructor<ChildOrderableNode> & Constructor<JSDocableNode> & Constructor<ReadonlyableNode> & Constructor<ModifierableNode> & typeof TypeElement;
  5694. export declare class IndexSignatureDeclaration extends IndexSignatureDeclarationBase<ts.IndexSignatureDeclaration> {
  5695. /** Gets the key name. */
  5696. getKeyName(): string;
  5697. /**
  5698. * Sets the key name.
  5699. * @param name - New name.
  5700. */
  5701. setKeyName(name: string): void;
  5702. /** Gets the key name node. */
  5703. getKeyNameNode(): BindingName;
  5704. /** Gets the key type. */
  5705. getKeyType(): Type;
  5706. /**
  5707. * Sets the key type.
  5708. * @param type - Type.
  5709. */
  5710. setKeyType(type: string): this;
  5711. /** Gets the key type node. */
  5712. getKeyTypeNode(): TypeNode;
  5713. /**
  5714. * Sets the node from a structure.
  5715. * @param structure - Structure to set the node with.
  5716. */
  5717. set(structure: Partial<IndexSignatureDeclarationStructure>): this;
  5718. /** Gets the structure equivalent to this node. */
  5719. getStructure(): IndexSignatureDeclarationStructure;
  5720. /** @inheritdoc **/
  5721. getParent(): NodeParentType<ts.IndexSignatureDeclaration>;
  5722. /** @inheritdoc **/
  5723. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.IndexSignatureDeclaration>>;
  5724. }
  5725. declare const InterfaceDeclarationBase: Constructor<TypeElementMemberedNode> & Constructor<TextInsertableNode> & Constructor<ExtendsClauseableNode> & Constructor<HeritageClauseableNode> & Constructor<TypeParameteredNode> & Constructor<JSDocableNode> & Constructor<AmbientableNode> & Constructor<ModuleChildableNode> & Constructor<ExportableNode> & Constructor<ModifierableNode> & Constructor<NamedNode> & typeof Statement;
  5726. export declare class InterfaceDeclaration extends InterfaceDeclarationBase<ts.InterfaceDeclaration> {
  5727. /** Gets the base types. */
  5728. getBaseTypes(): Type[];
  5729. /** Gets the base declarations. */
  5730. getBaseDeclarations(): (TypeAliasDeclaration | InterfaceDeclaration | ClassDeclaration)[];
  5731. /**
  5732. * Gets all the implementations of the interface.
  5733. *
  5734. * This is similar to "go to implementation."
  5735. */
  5736. getImplementations(): ImplementationLocation[];
  5737. /**
  5738. * Sets the node from a structure.
  5739. * @param structure - Structure to set the node with.
  5740. */
  5741. set(structure: Partial<InterfaceDeclarationStructure>): this;
  5742. /** Gets the structure equivalent to this node. */
  5743. getStructure(): InterfaceDeclarationStructure;
  5744. /** @inheritdoc **/
  5745. getParent(): NodeParentType<ts.InterfaceDeclaration>;
  5746. /** @inheritdoc **/
  5747. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.InterfaceDeclaration>>;
  5748. }
  5749. declare const MethodSignatureBase: Constructor<ChildOrderableNode> & Constructor<JSDocableNode> & Constructor<QuestionTokenableNode> & Constructor<TypeParameteredNode> & Constructor<SignaturedDeclaration> & Constructor<PropertyNamedNode> & typeof TypeElement;
  5750. export declare class MethodSignature extends MethodSignatureBase<ts.MethodSignature> {
  5751. /**
  5752. * Sets the node from a structure.
  5753. * @param structure - Structure to set the node with.
  5754. */
  5755. set(structure: Partial<MethodSignatureStructure>): this;
  5756. /** Gets the structure equivalent to this node. */
  5757. getStructure(): MethodSignatureStructure;
  5758. /** @inheritdoc **/
  5759. getParent(): NodeParentType<ts.MethodSignature>;
  5760. /** @inheritdoc **/
  5761. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.MethodSignature>>;
  5762. }
  5763. declare const PropertySignatureBase: Constructor<ChildOrderableNode> & Constructor<JSDocableNode> & Constructor<ReadonlyableNode> & Constructor<QuestionTokenableNode> & Constructor<InitializerExpressionableNode> & Constructor<TypedNode> & Constructor<PropertyNamedNode> & Constructor<ModifierableNode> & typeof TypeElement;
  5764. export declare class PropertySignature extends PropertySignatureBase<ts.PropertySignature> {
  5765. /**
  5766. * Sets the node from a structure.
  5767. * @param structure - Structure to set the node with.
  5768. */
  5769. set(structure: Partial<PropertySignatureStructure>): this;
  5770. /** Gets the structure equivalent to this node. */
  5771. getStructure(): PropertySignatureStructure;
  5772. /** @inheritdoc **/
  5773. getParent(): NodeParentType<ts.PropertySignature>;
  5774. /** @inheritdoc **/
  5775. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PropertySignature>>;
  5776. }
  5777. export declare class TypeElement<TNode extends ts.TypeElement = ts.TypeElement> extends Node<TNode> {
  5778. /** Removes the member. */
  5779. remove(): void;
  5780. }
  5781. export declare function JsxAttributedNode<T extends Constructor<JsxAttributedNodeExtensionType>>(Base: T): Constructor<JsxAttributedNode> & T;
  5782. export interface JsxAttributedNode {
  5783. /** Gets the JSX element's attributes. */
  5784. getAttributes(): JsxAttributeLike[];
  5785. /**
  5786. * Gets an attribute by name or returns undefined when it can't be found.
  5787. * @param name - Name to search for.
  5788. */
  5789. getAttribute(name: string): JsxAttributeLike | undefined;
  5790. /**
  5791. * Gets an attribute by a find function or returns undefined when it can't be found.
  5792. * @param findFunction - Find function.
  5793. */
  5794. getAttribute(findFunction: (attribute: JsxAttributeLike) => boolean): JsxAttributeLike | undefined;
  5795. /**
  5796. * Gets an attribute by name or throws when it can't be found.
  5797. * @param name - Name to search for.
  5798. */
  5799. getAttributeOrThrow(name: string): JsxAttributeLike;
  5800. /**
  5801. * Gets an attribute by a find function or throws when it can't be found.
  5802. * @param findFunction - Find function.
  5803. */
  5804. getAttributeOrThrow(findFunction: (attribute: JsxAttributeLike) => boolean): JsxAttributeLike;
  5805. /** Adds an attribute into the element. */
  5806. addAttribute(attribute: OptionalKind<JsxAttributeStructure> | OptionalKind<JsxSpreadAttributeStructure>): JsxAttributeLike;
  5807. /** Adds attributes into the element. */
  5808. addAttributes(attributes: ReadonlyArray<OptionalKind<JsxAttributeStructure> | OptionalKind<JsxSpreadAttributeStructure>>): JsxAttributeLike[];
  5809. /** Inserts an attribute into the element. */
  5810. insertAttribute(index: number, attribute: OptionalKind<JsxAttributeStructure> | OptionalKind<JsxSpreadAttributeStructure>): JsxAttributeLike;
  5811. /** Inserts attributes into the element. */
  5812. insertAttributes(index: number, attributes: ReadonlyArray<OptionalKind<JsxAttributeStructure> | OptionalKind<JsxSpreadAttributeStructure>>): JsxAttributeLike[];
  5813. }
  5814. type JsxAttributedNodeExtensionType = Node<ts.Node & {
  5815. attributes: ts.JsxAttributes;
  5816. }> & JsxTagNamedNode;
  5817. export declare function JsxTagNamedNode<T extends Constructor<JsxTagNamedNodeExtensionType>>(Base: T): Constructor<JsxTagNamedNode> & T;
  5818. export interface JsxTagNamedNode {
  5819. /** Gets the tag name of the JSX closing element. */
  5820. getTagNameNode(): JsxTagNameExpression;
  5821. }
  5822. type JsxTagNamedNodeExtensionType = Node<ts.Node & {
  5823. tagName: ts.JsxTagNameExpression;
  5824. }>;
  5825. declare const JsxAttributeBase: typeof Node;
  5826. export declare class JsxAttribute extends JsxAttributeBase<ts.JsxAttribute> {
  5827. /** Gets the name node of the JSX attribute. */
  5828. getNameNode(): JsxAttributeName;
  5829. /** Sets the name of the JSX attribute. */
  5830. setName(name: string | JsxNamespacedNameStructure): this;
  5831. /** Gets the JSX attribute's initializer or throws if it doesn't exist. */
  5832. getInitializerOrThrow(message?: string | (() => string)): StringLiteral | JsxElement | JsxSelfClosingElement | JsxFragment | JsxExpression;
  5833. /** Gets the JSX attribute's initializer or returns undefined if it doesn't exist. */
  5834. getInitializer(): JsxElement | JsxExpression | JsxFragment | JsxSelfClosingElement | StringLiteral | undefined;
  5835. /**
  5836. * Sets the initializer.
  5837. * @param textOrWriterFunction - Text or writer function to set the initializer with.
  5838. * @remarks You need to provide the quotes or braces.
  5839. */
  5840. setInitializer(textOrWriterFunction: string | WriterFunction): this;
  5841. /** Removes the initializer. */
  5842. removeInitializer(): this;
  5843. /** Removes the JSX attribute. */
  5844. remove(): void;
  5845. /**
  5846. * Sets the node from a structure.
  5847. * @param structure - Structure to set the node with.
  5848. */
  5849. set(structure: Partial<JsxAttributeStructure>): this;
  5850. /** Gets the structure equivalent to this node. */
  5851. getStructure(): JsxAttributeStructure;
  5852. /** @inheritdoc **/
  5853. getParent(): NodeParentType<ts.JsxAttribute>;
  5854. /** @inheritdoc **/
  5855. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxAttribute>>;
  5856. }
  5857. declare const JsxClosingElementBase: Constructor<JsxTagNamedNode> & typeof Node;
  5858. export declare class JsxClosingElement extends JsxClosingElementBase<ts.JsxClosingElement> {
  5859. /** @inheritdoc **/
  5860. getParent(): NodeParentType<ts.JsxClosingElement>;
  5861. /** @inheritdoc **/
  5862. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxClosingElement>>;
  5863. }
  5864. export declare class JsxClosingFragment extends Expression<ts.JsxClosingFragment> {
  5865. /** @inheritdoc **/
  5866. getParent(): NodeParentType<ts.JsxClosingFragment>;
  5867. /** @inheritdoc **/
  5868. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxClosingFragment>>;
  5869. }
  5870. declare const JsxElementBase: typeof PrimaryExpression;
  5871. export declare class JsxElement extends JsxElementBase<ts.JsxElement> {
  5872. /** Gets the children of the JSX element. */
  5873. getJsxChildren(): JsxChild[];
  5874. /** Gets the opening element. */
  5875. getOpeningElement(): JsxOpeningElement;
  5876. /** Gets the closing element. */
  5877. getClosingElement(): JsxClosingElement;
  5878. /**
  5879. * Sets the body text.
  5880. * @param textOrWriterFunction - Text or writer function to set as the body.
  5881. */
  5882. setBodyText(textOrWriterFunction: string | WriterFunction): this;
  5883. /**
  5884. * Sets the body text without surrounding new lines.
  5885. * @param textOrWriterFunction - Text to set as the body.
  5886. */
  5887. setBodyTextInline(textOrWriterFunction: string | WriterFunction): this;
  5888. /**
  5889. * Sets the node from a structure.
  5890. * @param structure - Structure to set the node with.
  5891. */
  5892. set(structure: Partial<JsxElementStructure>): this;
  5893. /** Gets the structure equivalent to this node. */
  5894. getStructure(): JsxElementStructure;
  5895. /** @inheritdoc **/
  5896. getParent(): NodeParentType<ts.JsxElement>;
  5897. /** @inheritdoc **/
  5898. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxElement>>;
  5899. }
  5900. declare const JsxExpressionBase: Constructor<ExpressionableNode> & Constructor<DotDotDotTokenableNode> & typeof Expression;
  5901. export declare class JsxExpression extends JsxExpressionBase<ts.JsxExpression> {
  5902. /** @inheritdoc **/
  5903. getParent(): NodeParentType<ts.JsxExpression>;
  5904. /** @inheritdoc **/
  5905. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxExpression>>;
  5906. }
  5907. export declare class JsxFragment extends PrimaryExpression<ts.JsxFragment> {
  5908. /** Gets the children of the JSX fragment. */
  5909. getJsxChildren(): JsxChild[];
  5910. /** Gets the opening fragment. */
  5911. getOpeningFragment(): JsxOpeningFragment;
  5912. /** Gets the closing fragment. */
  5913. getClosingFragment(): JsxClosingFragment;
  5914. /** @inheritdoc **/
  5915. getParent(): NodeParentType<ts.JsxFragment>;
  5916. /** @inheritdoc **/
  5917. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxFragment>>;
  5918. }
  5919. declare const JsxNamespacedNameBase: typeof Node;
  5920. export declare class JsxNamespacedName extends JsxNamespacedNameBase<ts.JsxNamespacedName> {
  5921. /** Gets the namespace name node. */
  5922. getNamespaceNode(): Identifier;
  5923. /** Gets the name node. */
  5924. getNameNode(): Identifier;
  5925. set(structure: JsxNamespacedNameStructure): this;
  5926. getStructure(): JsxNamespacedNameStructure;
  5927. /** @inheritdoc **/
  5928. getParent(): NodeParentType<ts.JsxNamespacedName>;
  5929. /** @inheritdoc **/
  5930. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxNamespacedName>>;
  5931. }
  5932. declare const JsxOpeningElementBase: Constructor<JsxAttributedNode> & Constructor<JsxTagNamedNode> & typeof Expression;
  5933. export declare class JsxOpeningElement extends JsxOpeningElementBase<ts.JsxOpeningElement> {
  5934. /** @inheritdoc **/
  5935. getParent(): NodeParentType<ts.JsxOpeningElement>;
  5936. /** @inheritdoc **/
  5937. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxOpeningElement>>;
  5938. }
  5939. export declare class JsxOpeningFragment extends Expression<ts.JsxOpeningFragment> {
  5940. /** @inheritdoc **/
  5941. getParent(): NodeParentType<ts.JsxOpeningFragment>;
  5942. /** @inheritdoc **/
  5943. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxOpeningFragment>>;
  5944. }
  5945. declare const JsxSelfClosingElementBase: Constructor<JsxAttributedNode> & Constructor<JsxTagNamedNode> & typeof PrimaryExpression;
  5946. export declare class JsxSelfClosingElement extends JsxSelfClosingElementBase<ts.JsxSelfClosingElement> {
  5947. /**
  5948. * Sets the node from a structure.
  5949. * @param structure - Structure to set the node with.
  5950. */
  5951. set(structure: Partial<JsxSelfClosingElementStructure>): this;
  5952. /** Gets the structure equivalent to this node. */
  5953. getStructure(): JsxSelfClosingElementStructure;
  5954. /** @inheritdoc **/
  5955. getParent(): NodeParentType<ts.JsxSelfClosingElement>;
  5956. /** @inheritdoc **/
  5957. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxSelfClosingElement>>;
  5958. }
  5959. declare const JsxSpreadAttributeBase: Constructor<ExpressionedNode> & typeof Node;
  5960. export declare class JsxSpreadAttribute extends JsxSpreadAttributeBase<ts.JsxSpreadAttribute> {
  5961. /** Removes the JSX spread attribute. */
  5962. remove(): void;
  5963. /**
  5964. * Sets the node from a structure.
  5965. * @param structure - Structure to set the node with.
  5966. */
  5967. set(structure: Partial<JsxSpreadAttributeStructure>): this;
  5968. /** Gets the structure equivalent to this node. */
  5969. getStructure(): JsxSpreadAttributeStructure;
  5970. /** @inheritdoc **/
  5971. getParent(): NodeParentType<ts.JsxSpreadAttribute>;
  5972. /** @inheritdoc **/
  5973. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxSpreadAttribute>>;
  5974. }
  5975. declare const JsxTextBase: Constructor<LiteralLikeNode> & typeof Node;
  5976. export declare class JsxText extends JsxTextBase<ts.JsxText> {
  5977. /** Gets if the JSX text contains only white spaces. */
  5978. containsOnlyTriviaWhiteSpaces(): boolean;
  5979. /** @inheritdoc **/
  5980. getParent(): NodeParentType<ts.JsxText>;
  5981. /** @inheritdoc **/
  5982. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.JsxText>>;
  5983. }
  5984. export interface ImplementedKindToNodeMappings {
  5985. [SyntaxKind.SourceFile]: SourceFile;
  5986. [SyntaxKind.ArrayBindingPattern]: ArrayBindingPattern;
  5987. [SyntaxKind.ArrayLiteralExpression]: ArrayLiteralExpression;
  5988. [SyntaxKind.ArrayType]: ArrayTypeNode;
  5989. [SyntaxKind.ArrowFunction]: ArrowFunction;
  5990. [SyntaxKind.AsExpression]: AsExpression;
  5991. [SyntaxKind.AwaitExpression]: AwaitExpression;
  5992. [SyntaxKind.BigIntLiteral]: BigIntLiteral;
  5993. [SyntaxKind.BindingElement]: BindingElement;
  5994. [SyntaxKind.BinaryExpression]: BinaryExpression;
  5995. [SyntaxKind.Block]: Block;
  5996. [SyntaxKind.BreakStatement]: BreakStatement;
  5997. [SyntaxKind.CallExpression]: CallExpression;
  5998. [SyntaxKind.CallSignature]: CallSignatureDeclaration;
  5999. [SyntaxKind.CaseBlock]: CaseBlock;
  6000. [SyntaxKind.CaseClause]: CaseClause;
  6001. [SyntaxKind.CatchClause]: CatchClause;
  6002. [SyntaxKind.ClassDeclaration]: ClassDeclaration;
  6003. [SyntaxKind.ClassExpression]: ClassExpression;
  6004. [SyntaxKind.ClassStaticBlockDeclaration]: ClassStaticBlockDeclaration;
  6005. [SyntaxKind.ConditionalType]: ConditionalTypeNode;
  6006. [SyntaxKind.Constructor]: ConstructorDeclaration;
  6007. [SyntaxKind.ConstructorType]: ConstructorTypeNode;
  6008. [SyntaxKind.ConstructSignature]: ConstructSignatureDeclaration;
  6009. [SyntaxKind.ContinueStatement]: ContinueStatement;
  6010. [SyntaxKind.CommaListExpression]: CommaListExpression;
  6011. [SyntaxKind.ComputedPropertyName]: ComputedPropertyName;
  6012. [SyntaxKind.ConditionalExpression]: ConditionalExpression;
  6013. [SyntaxKind.DebuggerStatement]: DebuggerStatement;
  6014. [SyntaxKind.Decorator]: Decorator;
  6015. [SyntaxKind.DefaultClause]: DefaultClause;
  6016. [SyntaxKind.DeleteExpression]: DeleteExpression;
  6017. [SyntaxKind.DoStatement]: DoStatement;
  6018. [SyntaxKind.ElementAccessExpression]: ElementAccessExpression;
  6019. [SyntaxKind.EmptyStatement]: EmptyStatement;
  6020. [SyntaxKind.EnumDeclaration]: EnumDeclaration;
  6021. [SyntaxKind.EnumMember]: EnumMember;
  6022. [SyntaxKind.ExportAssignment]: ExportAssignment;
  6023. [SyntaxKind.ExportDeclaration]: ExportDeclaration;
  6024. [SyntaxKind.ExportSpecifier]: ExportSpecifier;
  6025. [SyntaxKind.ExpressionWithTypeArguments]: ExpressionWithTypeArguments;
  6026. [SyntaxKind.ExpressionStatement]: ExpressionStatement;
  6027. [SyntaxKind.ExternalModuleReference]: ExternalModuleReference;
  6028. [SyntaxKind.QualifiedName]: QualifiedName;
  6029. [SyntaxKind.ForInStatement]: ForInStatement;
  6030. [SyntaxKind.ForOfStatement]: ForOfStatement;
  6031. [SyntaxKind.ForStatement]: ForStatement;
  6032. [SyntaxKind.FunctionDeclaration]: FunctionDeclaration;
  6033. [SyntaxKind.FunctionExpression]: FunctionExpression;
  6034. [SyntaxKind.FunctionType]: FunctionTypeNode;
  6035. [SyntaxKind.GetAccessor]: GetAccessorDeclaration;
  6036. [SyntaxKind.HeritageClause]: HeritageClause;
  6037. [SyntaxKind.Identifier]: Identifier;
  6038. [SyntaxKind.IfStatement]: IfStatement;
  6039. [SyntaxKind.ImportClause]: ImportClause;
  6040. [SyntaxKind.ImportDeclaration]: ImportDeclaration;
  6041. [SyntaxKind.ImportEqualsDeclaration]: ImportEqualsDeclaration;
  6042. [SyntaxKind.ImportSpecifier]: ImportSpecifier;
  6043. [SyntaxKind.ImportType]: ImportTypeNode;
  6044. [SyntaxKind.ImportAttribute]: ImportAttribute;
  6045. [SyntaxKind.ImportAttributes]: ImportAttributes;
  6046. [SyntaxKind.IndexedAccessType]: IndexedAccessTypeNode;
  6047. [SyntaxKind.IndexSignature]: IndexSignatureDeclaration;
  6048. [SyntaxKind.InferType]: InferTypeNode;
  6049. [SyntaxKind.InterfaceDeclaration]: InterfaceDeclaration;
  6050. [SyntaxKind.IntersectionType]: IntersectionTypeNode;
  6051. [SyntaxKind.JSDocAllType]: JSDocAllType;
  6052. [SyntaxKind.JSDocAugmentsTag]: JSDocAugmentsTag;
  6053. [SyntaxKind.JSDocAuthorTag]: JSDocAuthorTag;
  6054. [SyntaxKind.JSDocCallbackTag]: JSDocCallbackTag;
  6055. [SyntaxKind.JSDocClassTag]: JSDocClassTag;
  6056. [SyntaxKind.JSDocDeprecatedTag]: JSDocDeprecatedTag;
  6057. [SyntaxKind.JSDocEnumTag]: JSDocEnumTag;
  6058. [SyntaxKind.JSDocFunctionType]: JSDocFunctionType;
  6059. [SyntaxKind.JSDocImplementsTag]: JSDocImplementsTag;
  6060. [SyntaxKind.JSDocLink]: JSDocLink;
  6061. [SyntaxKind.JSDocLinkCode]: JSDocLinkCode;
  6062. [SyntaxKind.JSDocLinkPlain]: JSDocLinkPlain;
  6063. [SyntaxKind.JSDocMemberName]: JSDocMemberName;
  6064. [SyntaxKind.JSDocNamepathType]: JSDocNamepathType;
  6065. [SyntaxKind.JSDocNameReference]: JSDocNameReference;
  6066. [SyntaxKind.JSDocNonNullableType]: JSDocNonNullableType;
  6067. [SyntaxKind.JSDocNullableType]: JSDocNullableType;
  6068. [SyntaxKind.JSDocOptionalType]: JSDocOptionalType;
  6069. [SyntaxKind.JSDocOverrideTag]: JSDocOverrideTag;
  6070. [SyntaxKind.JSDocParameterTag]: JSDocParameterTag;
  6071. [SyntaxKind.JSDocPrivateTag]: JSDocPrivateTag;
  6072. [SyntaxKind.JSDocPropertyTag]: JSDocPropertyTag;
  6073. [SyntaxKind.JSDocProtectedTag]: JSDocProtectedTag;
  6074. [SyntaxKind.JSDocPublicTag]: JSDocPublicTag;
  6075. [SyntaxKind.JSDocReturnTag]: JSDocReturnTag;
  6076. [SyntaxKind.JSDocReadonlyTag]: JSDocReadonlyTag;
  6077. [SyntaxKind.JSDocThrowsTag]: JSDocThrowsTag;
  6078. [SyntaxKind.JSDocOverloadTag]: JSDocOverloadTag;
  6079. [SyntaxKind.JSDocSatisfiesTag]: JSDocSatisfiesTag;
  6080. [SyntaxKind.JSDocSeeTag]: JSDocSeeTag;
  6081. [SyntaxKind.JSDocSignature]: JSDocSignature;
  6082. [SyntaxKind.JSDocTag]: JSDocUnknownTag;
  6083. [SyntaxKind.JSDocTemplateTag]: JSDocTemplateTag;
  6084. [SyntaxKind.JSDocText]: JSDocText;
  6085. [SyntaxKind.JSDocThisTag]: JSDocThisTag;
  6086. [SyntaxKind.JSDocTypeExpression]: JSDocTypeExpression;
  6087. [SyntaxKind.JSDocTypeLiteral]: JSDocTypeLiteral;
  6088. [SyntaxKind.JSDocTypeTag]: JSDocTypeTag;
  6089. [SyntaxKind.JSDocTypedefTag]: JSDocTypedefTag;
  6090. [SyntaxKind.JSDocUnknownType]: JSDocUnknownType;
  6091. [SyntaxKind.JSDocVariadicType]: JSDocVariadicType;
  6092. [SyntaxKind.JsxAttribute]: JsxAttribute;
  6093. [SyntaxKind.JsxClosingElement]: JsxClosingElement;
  6094. [SyntaxKind.JsxClosingFragment]: JsxClosingFragment;
  6095. [SyntaxKind.JsxElement]: JsxElement;
  6096. [SyntaxKind.JsxExpression]: JsxExpression;
  6097. [SyntaxKind.JsxFragment]: JsxFragment;
  6098. [SyntaxKind.JsxNamespacedName]: JsxNamespacedName;
  6099. [SyntaxKind.JsxOpeningElement]: JsxOpeningElement;
  6100. [SyntaxKind.JsxOpeningFragment]: JsxOpeningFragment;
  6101. [SyntaxKind.JsxSelfClosingElement]: JsxSelfClosingElement;
  6102. [SyntaxKind.JsxSpreadAttribute]: JsxSpreadAttribute;
  6103. [SyntaxKind.JsxText]: JsxText;
  6104. [SyntaxKind.LabeledStatement]: LabeledStatement;
  6105. [SyntaxKind.LiteralType]: LiteralTypeNode;
  6106. [SyntaxKind.MappedType]: MappedTypeNode;
  6107. [SyntaxKind.MetaProperty]: MetaProperty;
  6108. [SyntaxKind.MethodDeclaration]: MethodDeclaration;
  6109. [SyntaxKind.MethodSignature]: MethodSignature;
  6110. [SyntaxKind.ModuleBlock]: ModuleBlock;
  6111. [SyntaxKind.ModuleDeclaration]: ModuleDeclaration;
  6112. [SyntaxKind.NamedExports]: NamedExports;
  6113. [SyntaxKind.NamedImports]: NamedImports;
  6114. [SyntaxKind.NamedTupleMember]: NamedTupleMember;
  6115. [SyntaxKind.NamespaceExport]: NamespaceExport;
  6116. [SyntaxKind.NamespaceImport]: NamespaceImport;
  6117. [SyntaxKind.NewExpression]: NewExpression;
  6118. [SyntaxKind.NonNullExpression]: NonNullExpression;
  6119. [SyntaxKind.NotEmittedStatement]: NotEmittedStatement;
  6120. [SyntaxKind.NoSubstitutionTemplateLiteral]: NoSubstitutionTemplateLiteral;
  6121. [SyntaxKind.NumericLiteral]: NumericLiteral;
  6122. [SyntaxKind.ObjectBindingPattern]: ObjectBindingPattern;
  6123. [SyntaxKind.ObjectLiteralExpression]: ObjectLiteralExpression;
  6124. [SyntaxKind.OmittedExpression]: OmittedExpression;
  6125. [SyntaxKind.Parameter]: ParameterDeclaration;
  6126. [SyntaxKind.ParenthesizedExpression]: ParenthesizedExpression;
  6127. [SyntaxKind.ParenthesizedType]: ParenthesizedTypeNode;
  6128. [SyntaxKind.PartiallyEmittedExpression]: PartiallyEmittedExpression;
  6129. [SyntaxKind.PostfixUnaryExpression]: PostfixUnaryExpression;
  6130. [SyntaxKind.PrefixUnaryExpression]: PrefixUnaryExpression;
  6131. [SyntaxKind.PrivateIdentifier]: PrivateIdentifier;
  6132. [SyntaxKind.PropertyAccessExpression]: PropertyAccessExpression;
  6133. [SyntaxKind.PropertyAssignment]: PropertyAssignment;
  6134. [SyntaxKind.PropertyDeclaration]: PropertyDeclaration;
  6135. [SyntaxKind.PropertySignature]: PropertySignature;
  6136. [SyntaxKind.RegularExpressionLiteral]: RegularExpressionLiteral;
  6137. [SyntaxKind.RestType]: RestTypeNode;
  6138. [SyntaxKind.ReturnStatement]: ReturnStatement;
  6139. [SyntaxKind.SatisfiesExpression]: SatisfiesExpression;
  6140. [SyntaxKind.SetAccessor]: SetAccessorDeclaration;
  6141. [SyntaxKind.ShorthandPropertyAssignment]: ShorthandPropertyAssignment;
  6142. [SyntaxKind.SpreadAssignment]: SpreadAssignment;
  6143. [SyntaxKind.SpreadElement]: SpreadElement;
  6144. [SyntaxKind.StringLiteral]: StringLiteral;
  6145. [SyntaxKind.SwitchStatement]: SwitchStatement;
  6146. [SyntaxKind.SyntaxList]: SyntaxList;
  6147. [SyntaxKind.TaggedTemplateExpression]: TaggedTemplateExpression;
  6148. [SyntaxKind.TemplateExpression]: TemplateExpression;
  6149. [SyntaxKind.TemplateHead]: TemplateHead;
  6150. [SyntaxKind.TemplateLiteralType]: TemplateLiteralTypeNode;
  6151. [SyntaxKind.TemplateMiddle]: TemplateMiddle;
  6152. [SyntaxKind.TemplateSpan]: TemplateSpan;
  6153. [SyntaxKind.TemplateTail]: TemplateTail;
  6154. [SyntaxKind.ThisType]: ThisTypeNode;
  6155. [SyntaxKind.ThrowStatement]: ThrowStatement;
  6156. [SyntaxKind.TryStatement]: TryStatement;
  6157. [SyntaxKind.TupleType]: TupleTypeNode;
  6158. [SyntaxKind.TypeAliasDeclaration]: TypeAliasDeclaration;
  6159. [SyntaxKind.TypeAssertionExpression]: TypeAssertion;
  6160. [SyntaxKind.TypeLiteral]: TypeLiteralNode;
  6161. [SyntaxKind.TypeOperator]: TypeOperatorTypeNode;
  6162. [SyntaxKind.TypeParameter]: TypeParameterDeclaration;
  6163. [SyntaxKind.TypePredicate]: TypePredicateNode;
  6164. [SyntaxKind.TypeQuery]: TypeQueryNode;
  6165. [SyntaxKind.TypeReference]: TypeReferenceNode;
  6166. [SyntaxKind.UnionType]: UnionTypeNode;
  6167. [SyntaxKind.VariableDeclaration]: VariableDeclaration;
  6168. [SyntaxKind.VariableDeclarationList]: VariableDeclarationList;
  6169. [SyntaxKind.VariableStatement]: VariableStatement;
  6170. [SyntaxKind.JSDoc]: JSDoc;
  6171. [SyntaxKind.TypeOfExpression]: TypeOfExpression;
  6172. [SyntaxKind.WhileStatement]: WhileStatement;
  6173. [SyntaxKind.WithStatement]: WithStatement;
  6174. [SyntaxKind.YieldExpression]: YieldExpression;
  6175. [SyntaxKind.SemicolonToken]: Node<ts.Token<SyntaxKind.SemicolonToken>>;
  6176. [SyntaxKind.InferKeyword]: Node<ts.Token<SyntaxKind.InferKeyword>>;
  6177. [SyntaxKind.NeverKeyword]: Node<ts.Token<SyntaxKind.NeverKeyword>>;
  6178. [SyntaxKind.AnyKeyword]: Expression;
  6179. [SyntaxKind.BooleanKeyword]: Expression;
  6180. [SyntaxKind.NumberKeyword]: Expression;
  6181. [SyntaxKind.ObjectKeyword]: Expression;
  6182. [SyntaxKind.StringKeyword]: Expression;
  6183. [SyntaxKind.SymbolKeyword]: Expression;
  6184. [SyntaxKind.UndefinedKeyword]: Expression;
  6185. [SyntaxKind.FalseKeyword]: FalseLiteral;
  6186. [SyntaxKind.ImportKeyword]: ImportExpression;
  6187. [SyntaxKind.NullKeyword]: NullLiteral;
  6188. [SyntaxKind.SuperKeyword]: SuperExpression;
  6189. [SyntaxKind.ThisKeyword]: ThisExpression;
  6190. [SyntaxKind.TrueKeyword]: TrueLiteral;
  6191. [SyntaxKind.VoidExpression]: VoidExpression;
  6192. }
  6193. export interface KindToNodeMappings extends ImplementedKindToNodeMappings {
  6194. [kind: number]: Node;
  6195. }
  6196. export interface KindToExpressionMappings {
  6197. [kind: number]: Node;
  6198. [SyntaxKind.ArrayLiteralExpression]: ArrayLiteralExpression;
  6199. [SyntaxKind.ArrowFunction]: ArrowFunction;
  6200. [SyntaxKind.AsExpression]: AsExpression;
  6201. [SyntaxKind.AwaitExpression]: AwaitExpression;
  6202. [SyntaxKind.BigIntLiteral]: BigIntLiteral;
  6203. [SyntaxKind.BinaryExpression]: BinaryExpression;
  6204. [SyntaxKind.CallExpression]: CallExpression;
  6205. [SyntaxKind.ClassExpression]: ClassExpression;
  6206. [SyntaxKind.CommaListExpression]: CommaListExpression;
  6207. [SyntaxKind.ConditionalExpression]: ConditionalExpression;
  6208. [SyntaxKind.DeleteExpression]: DeleteExpression;
  6209. [SyntaxKind.ElementAccessExpression]: ElementAccessExpression;
  6210. [SyntaxKind.FunctionExpression]: FunctionExpression;
  6211. [SyntaxKind.Identifier]: Identifier;
  6212. [SyntaxKind.JsxClosingFragment]: JsxClosingFragment;
  6213. [SyntaxKind.JsxElement]: JsxElement;
  6214. [SyntaxKind.JsxExpression]: JsxExpression;
  6215. [SyntaxKind.JsxFragment]: JsxFragment;
  6216. [SyntaxKind.JsxOpeningElement]: JsxOpeningElement;
  6217. [SyntaxKind.JsxOpeningFragment]: JsxOpeningFragment;
  6218. [SyntaxKind.JsxSelfClosingElement]: JsxSelfClosingElement;
  6219. [SyntaxKind.MetaProperty]: MetaProperty;
  6220. [SyntaxKind.NewExpression]: NewExpression;
  6221. [SyntaxKind.NonNullExpression]: NonNullExpression;
  6222. [SyntaxKind.NoSubstitutionTemplateLiteral]: NoSubstitutionTemplateLiteral;
  6223. [SyntaxKind.NumericLiteral]: NumericLiteral;
  6224. [SyntaxKind.ObjectLiteralExpression]: ObjectLiteralExpression;
  6225. [SyntaxKind.OmittedExpression]: OmittedExpression;
  6226. [SyntaxKind.ParenthesizedExpression]: ParenthesizedExpression;
  6227. [SyntaxKind.PartiallyEmittedExpression]: PartiallyEmittedExpression;
  6228. [SyntaxKind.PostfixUnaryExpression]: PostfixUnaryExpression;
  6229. [SyntaxKind.PrefixUnaryExpression]: PrefixUnaryExpression;
  6230. [SyntaxKind.PropertyAccessExpression]: PropertyAccessExpression;
  6231. [SyntaxKind.RegularExpressionLiteral]: RegularExpressionLiteral;
  6232. [SyntaxKind.SatisfiesExpression]: SatisfiesExpression;
  6233. [SyntaxKind.SpreadElement]: SpreadElement;
  6234. [SyntaxKind.StringLiteral]: StringLiteral;
  6235. [SyntaxKind.TaggedTemplateExpression]: TaggedTemplateExpression;
  6236. [SyntaxKind.TemplateExpression]: TemplateExpression;
  6237. [SyntaxKind.TypeAssertionExpression]: TypeAssertion;
  6238. [SyntaxKind.TypeOfExpression]: TypeOfExpression;
  6239. [SyntaxKind.YieldExpression]: YieldExpression;
  6240. [SyntaxKind.AnyKeyword]: Expression;
  6241. [SyntaxKind.BooleanKeyword]: Expression;
  6242. [SyntaxKind.NumberKeyword]: Expression;
  6243. [SyntaxKind.ObjectKeyword]: Expression;
  6244. [SyntaxKind.StringKeyword]: Expression;
  6245. [SyntaxKind.SymbolKeyword]: Expression;
  6246. [SyntaxKind.UndefinedKeyword]: Expression;
  6247. [SyntaxKind.FalseKeyword]: FalseLiteral;
  6248. [SyntaxKind.ImportKeyword]: ImportExpression;
  6249. [SyntaxKind.NullKeyword]: NullLiteral;
  6250. [SyntaxKind.SuperKeyword]: SuperExpression;
  6251. [SyntaxKind.ThisKeyword]: ThisExpression;
  6252. [SyntaxKind.TrueKeyword]: TrueLiteral;
  6253. [SyntaxKind.VoidExpression]: VoidExpression;
  6254. }
  6255. declare const BigIntLiteralBase: typeof LiteralExpression;
  6256. export declare class BigIntLiteral extends BigIntLiteralBase<ts.BigIntLiteral> {
  6257. /**
  6258. * Gets the BigInt literal value.
  6259. *
  6260. * Assert this as a `bigint` in environments that support it.
  6261. */
  6262. getLiteralValue(): unknown;
  6263. /**
  6264. * Sets the bigint literal value.
  6265. * @param value - Value to set (must provide a bigint here at runtime).
  6266. */
  6267. setLiteralValue(value: unknown): this;
  6268. /** @inheritdoc **/
  6269. getParent(): NodeParentType<ts.BigIntLiteral>;
  6270. /** @inheritdoc **/
  6271. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.BigIntLiteral>>;
  6272. }
  6273. declare const TrueLiteralBase: typeof PrimaryExpression;
  6274. export declare class TrueLiteral extends TrueLiteralBase<ts.TrueLiteral> {
  6275. /** Gets the literal value. */
  6276. getLiteralValue(): boolean;
  6277. /**
  6278. * Sets the literal value.
  6279. *
  6280. * Note: This forgets the current node and returns the new node if the value changes.
  6281. * @param value - Value to set.
  6282. */
  6283. setLiteralValue(value: boolean): this | FalseLiteral;
  6284. /** @inheritdoc **/
  6285. getParent(): NodeParentType<ts.TrueLiteral>;
  6286. /** @inheritdoc **/
  6287. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TrueLiteral>>;
  6288. }
  6289. declare const FalseLiteralBase: typeof PrimaryExpression;
  6290. export declare class FalseLiteral extends FalseLiteralBase<ts.FalseLiteral> {
  6291. /** Gets the literal value. */
  6292. getLiteralValue(): boolean;
  6293. /**
  6294. * Sets the literal value.
  6295. *
  6296. * Note: This forgets the current node and returns the new node if the value changes.
  6297. * @param value - Value to set.
  6298. */
  6299. setLiteralValue(value: boolean): this | TrueLiteral;
  6300. /** @inheritdoc **/
  6301. getParent(): NodeParentType<ts.FalseLiteral>;
  6302. /** @inheritdoc **/
  6303. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.FalseLiteral>>;
  6304. }
  6305. declare const NullLiteralBase: typeof PrimaryExpression;
  6306. export declare class NullLiteral extends NullLiteralBase<ts.NullLiteral> {
  6307. /** @inheritdoc **/
  6308. getParent(): NodeParentType<ts.NullLiteral>;
  6309. /** @inheritdoc **/
  6310. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NullLiteral>>;
  6311. }
  6312. declare const NumericLiteralBase: typeof LiteralExpression;
  6313. export declare class NumericLiteral extends NumericLiteralBase<ts.NumericLiteral> {
  6314. /** Gets the literal value. */
  6315. getLiteralValue(): number;
  6316. /**
  6317. * Sets the literal value.
  6318. * @param value - Value to set.
  6319. */
  6320. setLiteralValue(value: number): this;
  6321. /** @inheritdoc **/
  6322. getParent(): NodeParentType<ts.NumericLiteral>;
  6323. /** @inheritdoc **/
  6324. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NumericLiteral>>;
  6325. }
  6326. /** Quote type for a string literal. */
  6327. export declare enum QuoteKind {
  6328. /** Single quote */
  6329. Single = "'",
  6330. /** Double quote */
  6331. Double = "\""
  6332. }
  6333. declare const RegularExpressionLiteralBase: typeof LiteralExpression;
  6334. export declare class RegularExpressionLiteral extends RegularExpressionLiteralBase<ts.RegularExpressionLiteral> {
  6335. /** Gets the literal value. */
  6336. getLiteralValue(): RegExp;
  6337. /**
  6338. * Sets the literal value according to a pattern and some flags.
  6339. * @param pattern - Pattern.
  6340. * @param flags - Flags.
  6341. */
  6342. setLiteralValue(pattern: string, flags?: string): this;
  6343. /**
  6344. * Sets the literal value according to a regular expression object.
  6345. * @param regExp - Regular expression.
  6346. */
  6347. setLiteralValue(regExp: RegExp): this;
  6348. /** @inheritdoc **/
  6349. getParent(): NodeParentType<ts.RegularExpressionLiteral>;
  6350. /** @inheritdoc **/
  6351. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.RegularExpressionLiteral>>;
  6352. }
  6353. declare const StringLiteralBase: typeof LiteralExpression;
  6354. export declare class StringLiteral extends StringLiteralBase<ts.StringLiteral> {
  6355. /**
  6356. * Gets the literal value.
  6357. *
  6358. * This is equivalent to .getLiteralText() for string literals and only exists for consistency with other literals.
  6359. */
  6360. getLiteralValue(): string;
  6361. /**
  6362. * Sets the literal value.
  6363. * @param value - Value to set.
  6364. */
  6365. setLiteralValue(value: string): this;
  6366. /** Gets the quote kind. */
  6367. getQuoteKind(): QuoteKind;
  6368. /** @inheritdoc **/
  6369. getParent(): NodeParentType<ts.StringLiteral>;
  6370. /** @inheritdoc **/
  6371. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.StringLiteral>>;
  6372. }
  6373. declare const NoSubstitutionTemplateLiteralBase: typeof LiteralExpression;
  6374. export declare class NoSubstitutionTemplateLiteral extends NoSubstitutionTemplateLiteralBase<ts.NoSubstitutionTemplateLiteral> {
  6375. /** Gets the literal value. */
  6376. getLiteralValue(): string;
  6377. /**
  6378. * Sets the literal value.
  6379. *
  6380. * Note: This could possibly replace the node if you add a tagged template.
  6381. * @param value - Value to set.
  6382. * @returns The new node if the kind changed; the current node otherwise.
  6383. */
  6384. setLiteralValue(value: string): TemplateLiteral;
  6385. /** @inheritdoc **/
  6386. getParent(): NodeParentType<ts.NoSubstitutionTemplateLiteral>;
  6387. /** @inheritdoc **/
  6388. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NoSubstitutionTemplateLiteral>>;
  6389. }
  6390. export declare class TaggedTemplateExpression extends MemberExpression<ts.TaggedTemplateExpression> {
  6391. /** Gets the tag. */
  6392. getTag(): LeftHandSideExpression;
  6393. /** Gets the template literal. */
  6394. getTemplate(): TemplateLiteral;
  6395. /**
  6396. * Removes the tag from the tagged template.
  6397. * @returns The new template expression.
  6398. */
  6399. removeTag(): TemplateLiteral;
  6400. /** @inheritdoc **/
  6401. getParent(): NodeParentType<ts.TaggedTemplateExpression>;
  6402. /** @inheritdoc **/
  6403. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TaggedTemplateExpression>>;
  6404. }
  6405. declare const TemplateExpressionBase: typeof PrimaryExpression;
  6406. export declare class TemplateExpression extends TemplateExpressionBase<ts.TemplateExpression> {
  6407. /** Gets the template head. */
  6408. getHead(): TemplateHead;
  6409. /** Gets the template spans. */
  6410. getTemplateSpans(): TemplateSpan[];
  6411. /**
  6412. * Sets the literal value.
  6413. *
  6414. * Note: This could possibly replace the node if you remove all the tagged templates.
  6415. * @param value - Value to set.
  6416. * @returns The new node if the kind changed; the current node otherwise.
  6417. */
  6418. setLiteralValue(value: string): Node<ts.Node>;
  6419. /** @inheritdoc **/
  6420. getParent(): NodeParentType<ts.TemplateExpression>;
  6421. /** @inheritdoc **/
  6422. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TemplateExpression>>;
  6423. }
  6424. declare const TemplateHeadBase: Constructor<LiteralLikeNode> & typeof Node;
  6425. export declare class TemplateHead extends TemplateHeadBase<ts.TemplateHead> {
  6426. /** @inheritdoc **/
  6427. getParent(): NodeParentType<ts.TemplateHead>;
  6428. /** @inheritdoc **/
  6429. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TemplateHead>>;
  6430. }
  6431. declare const TemplateMiddleBase: Constructor<LiteralLikeNode> & typeof Node;
  6432. export declare class TemplateMiddle extends TemplateMiddleBase<ts.TemplateMiddle> {
  6433. /** @inheritdoc **/
  6434. getParent(): NodeParentType<ts.TemplateMiddle>;
  6435. /** @inheritdoc **/
  6436. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TemplateMiddle>>;
  6437. }
  6438. declare const TemplateSpanBase: Constructor<ExpressionedNode> & typeof Node;
  6439. export declare class TemplateSpan extends TemplateSpanBase<ts.TemplateSpan> {
  6440. /** Gets the template literal. */
  6441. getLiteral(): TemplateMiddle | TemplateTail;
  6442. /** @inheritdoc **/
  6443. getParent(): NodeParentType<ts.TemplateSpan>;
  6444. /** @inheritdoc **/
  6445. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TemplateSpan>>;
  6446. }
  6447. declare const TemplateTailBase: Constructor<LiteralLikeNode> & typeof Node;
  6448. export declare class TemplateTail extends TemplateTailBase<ts.TemplateTail> {
  6449. /** @inheritdoc **/
  6450. getParent(): NodeParentType<ts.TemplateTail>;
  6451. /** @inheritdoc **/
  6452. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TemplateTail>>;
  6453. }
  6454. declare const ExportAssignmentBase: Constructor<ExpressionedNode> & Constructor<JSDocableNode> & typeof Statement;
  6455. export declare class ExportAssignment extends ExportAssignmentBase<ts.ExportAssignment> {
  6456. /**
  6457. * Gets if this is an export equals assignment.
  6458. *
  6459. * If this is false, then it's `export default`.
  6460. */
  6461. isExportEquals(): boolean;
  6462. /**
  6463. * Sets if this is an export equals assignment or export default.
  6464. * @param value - Whether it should be an export equals assignment.
  6465. */
  6466. setIsExportEquals(value: boolean): this;
  6467. /**
  6468. * Sets the node from a structure.
  6469. * @param structure - Structure to set the node with.
  6470. */
  6471. set(structure: Partial<ExportAssignmentStructure>): this;
  6472. /** Gets the structure equivalent to this node. */
  6473. getStructure(): ExportAssignmentStructure;
  6474. /** @inheritdoc **/
  6475. getParent(): NodeParentType<ts.ExportAssignment>;
  6476. /** @inheritdoc **/
  6477. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ExportAssignment>>;
  6478. }
  6479. declare const ExportDeclarationBase: typeof Statement;
  6480. export declare class ExportDeclaration extends ExportDeclarationBase<ts.ExportDeclaration> {
  6481. /** Gets if this export declaration is type only. */
  6482. isTypeOnly(): boolean;
  6483. /** Sets if this export declaration is type only. */
  6484. setIsTypeOnly(value: boolean): this;
  6485. /** Gets the namespace export or returns undefined if it doesn't exist. (ex. `* as ns`, but not `*`). */
  6486. getNamespaceExport(): NamespaceExport | undefined;
  6487. /** Gets the namespace export or throws if it doesn't exist. (ex. `* as ns`, but not `*`) */
  6488. getNamespaceExportOrThrow(message?: string | (() => string)): NamespaceExport;
  6489. /** Sets the namespace export name. */
  6490. setNamespaceExport(name: string): this;
  6491. /**
  6492. * Sets the import specifier.
  6493. * @param text - Text to set as the module specifier.
  6494. */
  6495. setModuleSpecifier(text: string): this;
  6496. /**
  6497. * Sets the import specifier.
  6498. * @param sourceFile - Source file to set the module specifier from.
  6499. */
  6500. setModuleSpecifier(sourceFile: SourceFile): this;
  6501. /** Gets the module specifier or undefined if it doesn't exist. */
  6502. getModuleSpecifier(): StringLiteral | undefined;
  6503. /** Gets the module specifier value or undefined if it doesn't exist. */
  6504. getModuleSpecifierValue(): string | undefined;
  6505. /** Gets the source file referenced in the module specifier or throws if it can't find it or it doesn't exist. */
  6506. getModuleSpecifierSourceFileOrThrow(message?: string | (() => string)): SourceFile;
  6507. /** Gets the source file referenced in the module specifier. */
  6508. getModuleSpecifierSourceFile(): SourceFile | undefined;
  6509. /** Gets if the module specifier starts with `./` or `../`. */
  6510. isModuleSpecifierRelative(): boolean;
  6511. /** Removes the module specifier. */
  6512. removeModuleSpecifier(): this;
  6513. /** Gets if the module specifier exists */
  6514. hasModuleSpecifier(): boolean;
  6515. /** Gets if this export declaration is a namespace export. */
  6516. isNamespaceExport(): boolean;
  6517. /** Gets if the export declaration has named exports. */
  6518. hasNamedExports(): boolean;
  6519. /**
  6520. * Adds a named export.
  6521. * @param namedExport - Structure, name, or writer function to write the named export.
  6522. */
  6523. addNamedExport(namedExport: OptionalKind<ExportSpecifierStructure> | string | WriterFunction): ExportSpecifier;
  6524. /**
  6525. * Adds named exports.
  6526. * @param namedExports - Structures, names, or writer function to write the named exports.
  6527. */
  6528. addNamedExports(namedExports: ReadonlyArray<OptionalKind<ExportSpecifierStructure> | string | WriterFunction> | WriterFunction): ExportSpecifier[];
  6529. /**
  6530. * Inserts a named export.
  6531. * @param index - Child index to insert at.
  6532. * @param namedExport - Structure, name, or writer function to write the named export.
  6533. */
  6534. insertNamedExport(index: number, namedExport: OptionalKind<ExportSpecifierStructure> | string | WriterFunction): ExportSpecifier;
  6535. /**
  6536. * Inserts named exports into the export declaration.
  6537. * @param index - Child index to insert at.
  6538. * @param namedExports - Structures, names, or writer funciton to write the named exports.
  6539. */
  6540. insertNamedExports(index: number, namedExports: ReadonlyArray<OptionalKind<ExportSpecifierStructure> | string | WriterFunction> | WriterFunction): ExportSpecifier[];
  6541. /** Gets the named exports. */
  6542. getNamedExports(): ExportSpecifier[];
  6543. /** Changes the export declaration to namespace export. Removes all the named exports. */
  6544. toNamespaceExport(): this;
  6545. /** Sets the import attributes. */
  6546. setAttributes(elements: ReadonlyArray<OptionalKind<ImportAttributeStructure>> | undefined): this;
  6547. /** Gets the import attributes or returns undefined if it doesn't exist. */
  6548. getAttributes(): ImportAttributes | undefined;
  6549. /**
  6550. * Sets the node from a structure.
  6551. * @param structure - Structure to set the node with.
  6552. */
  6553. set(structure: Partial<ExportDeclarationStructure>): this;
  6554. /** Gets the structure equivalent to this node. */
  6555. getStructure(): ExportDeclarationStructure;
  6556. /** @inheritdoc **/
  6557. getParent(): NodeParentType<ts.ExportDeclaration>;
  6558. /** @inheritdoc **/
  6559. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ExportDeclaration>>;
  6560. }
  6561. declare const ExportSpecifierBase: typeof Node;
  6562. export declare class ExportSpecifier extends ExportSpecifierBase<ts.ExportSpecifier> {
  6563. /** Sets the name of what's being exported. */
  6564. setName(name: string): this;
  6565. /** Gets the name of the export specifier. */
  6566. getName(): string;
  6567. /** Gets the name node of what's being exported. */
  6568. getNameNode(): StringLiteral | Identifier;
  6569. /**
  6570. * Sets the alias for the name being exported and renames all the usages.
  6571. * @param alias - Alias to set.
  6572. */
  6573. renameAlias(alias: string): this;
  6574. /**
  6575. * Sets the alias without renaming all the usages.
  6576. * @param alias - Alias to set.
  6577. */
  6578. setAlias(alias: string): this;
  6579. /**
  6580. * Removes the alias without renaming.
  6581. * @remarks Use removeAliasWithRename() if you want it to rename any usages to the name of the export specifier.
  6582. */
  6583. removeAlias(): this;
  6584. /** Removes the alias and renames any usages to the name of the export specifier. */
  6585. removeAliasWithRename(): this;
  6586. /** Gets the alias identifier, if it exists. */
  6587. getAliasNode(): StringLiteral | Identifier | undefined;
  6588. /** Gets if this is a type only import specifier. */
  6589. isTypeOnly(): boolean;
  6590. /** Sets if this is a type only import specifier. */
  6591. setIsTypeOnly(value: boolean): this;
  6592. /** Gets the export declaration associated with this export specifier. */
  6593. getExportDeclaration(): ExportDeclaration;
  6594. /** Gets the local target symbol of the export specifier or throws if it doesn't exist. */
  6595. getLocalTargetSymbolOrThrow(message?: string | (() => string)): Symbol;
  6596. /** Gets the local target symbol of the export specifier or undefined if it doesn't exist. */
  6597. getLocalTargetSymbol(): Symbol | undefined;
  6598. /** Gets all the declarations referenced by the export specifier. */
  6599. getLocalTargetDeclarations(): LocalTargetDeclarations[];
  6600. /** Removes the export specifier. */
  6601. remove(): void;
  6602. /**
  6603. * Sets the node from a structure.
  6604. * @param structure - Structure to set the node with.
  6605. */
  6606. set(structure: Partial<ExportSpecifierStructure>): this;
  6607. /** Gets the structure equivalent to this node. */
  6608. getStructure(): ExportSpecifierStructure;
  6609. /** @inheritdoc **/
  6610. getParent(): NodeParentType<ts.ExportSpecifier>;
  6611. /** @inheritdoc **/
  6612. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ExportSpecifier>>;
  6613. }
  6614. declare const ExternalModuleReferenceBase: Constructor<ExpressionableNode> & typeof Node;
  6615. export declare class ExternalModuleReference extends ExternalModuleReferenceBase<ts.ExternalModuleReference> {
  6616. /** Gets the source file referenced or throws if it can't find it. */
  6617. getReferencedSourceFileOrThrow(message?: string | (() => string)): SourceFile;
  6618. /** Gets if the external module reference is relative. */
  6619. isRelative(): boolean;
  6620. /** Gets the source file referenced or returns undefined if it can't find it. */
  6621. getReferencedSourceFile(): SourceFile | undefined;
  6622. /** @inheritdoc **/
  6623. getParent(): NodeParentType<ts.ExternalModuleReference>;
  6624. /** @inheritdoc **/
  6625. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ExternalModuleReference>>;
  6626. }
  6627. declare const ImportAttributeBase: Constructor<ImportAttributeNamedNode> & typeof Node;
  6628. export declare class ImportAttribute extends ImportAttributeBase<ts.ImportAttribute> {
  6629. /** Gets the value of the assert entry. */
  6630. getValue(): Expression;
  6631. /** Sets the name and value. */
  6632. set(structure: Partial<ImportAttributeStructure>): this;
  6633. /** Gets the structure equivalent to this node. */
  6634. getStructure(): ImportAttributeStructure;
  6635. /** @inheritdoc **/
  6636. getParent(): NodeParentType<ts.ImportAttribute>;
  6637. /** @inheritdoc **/
  6638. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportAttribute>>;
  6639. }
  6640. declare const ImportAttributesBase: typeof Node;
  6641. export declare class ImportAttributes extends ImportAttributesBase<ts.ImportAttributes> {
  6642. /** Sets the elements in the import attributes */
  6643. setElements(elements: ReadonlyArray<OptionalKind<ImportAttributeStructure>>): this;
  6644. /** Gets the elements of the import attributes. */
  6645. getElements(): ImportAttribute[];
  6646. /** Removes the assert clause. */
  6647. remove(): void;
  6648. /** @inheritdoc **/
  6649. getParent(): NodeParentType<ts.ImportAttributes>;
  6650. /** @inheritdoc **/
  6651. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportAttributes>>;
  6652. }
  6653. declare const ImportClauseBase: typeof Node;
  6654. export declare class ImportClause extends ImportClauseBase<ts.ImportClause> {
  6655. /** Gets if this import clause is type only. */
  6656. isTypeOnly(): boolean;
  6657. /** Sets if this import declaration is type only. */
  6658. setIsTypeOnly(value: boolean): this;
  6659. /** Gets the default import or throws if it doesn't exit. */
  6660. getDefaultImportOrThrow(message?: string | (() => string)): Identifier;
  6661. /** Gets the default import or returns undefined if it doesn't exist. */
  6662. getDefaultImport(): Identifier | undefined;
  6663. /** Gets the named bindings of the import clause or throws if it doesn't exist. */
  6664. getNamedBindingsOrThrow(message?: string | (() => string)): NamespaceImport | NamedImports;
  6665. /** Gets the named bindings of the import clause or returns undefined if it doesn't exist. */
  6666. getNamedBindings(): NamespaceImport | NamedImports | undefined;
  6667. /** Gets the namespace import if it exists or throws. */
  6668. getNamespaceImportOrThrow(message?: string | (() => string)): Identifier;
  6669. /** Gets the namespace import identifier, if it exists. */
  6670. getNamespaceImport(): Identifier | undefined;
  6671. /** Gets the namespace import identifier, if it exists. */
  6672. getNamedImports(): ImportSpecifier[];
  6673. /** @inheritdoc **/
  6674. getParent(): NodeParentType<ts.ImportClause>;
  6675. /** @inheritdoc **/
  6676. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportClause>>;
  6677. }
  6678. declare const ImportDeclarationBase: typeof Statement;
  6679. export declare class ImportDeclaration extends ImportDeclarationBase<ts.ImportDeclaration> {
  6680. /** Gets if this import declaration is type only. */
  6681. isTypeOnly(): boolean;
  6682. /** Sets if this import declaration is type only. */
  6683. setIsTypeOnly(value: boolean): this;
  6684. /**
  6685. * Sets the import specifier.
  6686. * @param text - Text to set as the module specifier.
  6687. */
  6688. setModuleSpecifier(text: string): this;
  6689. /**
  6690. * Sets the import specifier.
  6691. * @param sourceFile - Source file to set the module specifier from.
  6692. */
  6693. setModuleSpecifier(sourceFile: SourceFile): this;
  6694. /** Gets the module specifier. */
  6695. getModuleSpecifier(): StringLiteral;
  6696. /** Gets the module specifier string literal value. */
  6697. getModuleSpecifierValue(): string;
  6698. /** Gets the source file referenced in the module specifier or throws if it can't find it. */
  6699. getModuleSpecifierSourceFileOrThrow(message?: string | (() => string)): SourceFile;
  6700. /** Gets the source file referenced in the module specifier or returns undefined if it can't find it. */
  6701. getModuleSpecifierSourceFile(): SourceFile | undefined;
  6702. /** Gets if the module specifier starts with `./` or `../`. */
  6703. isModuleSpecifierRelative(): boolean;
  6704. /**
  6705. * Sets the default import.
  6706. * @param text - Text to set as the default import.
  6707. * @remarks Use renameDefaultImport to rename.
  6708. */
  6709. setDefaultImport(text: string): this;
  6710. /**
  6711. * Renames or sets the provided default import.
  6712. * @param text - Text to set or rename the default import with.
  6713. */
  6714. renameDefaultImport(text: string): this;
  6715. /** Gets the default import or throws if it doesn't exit. */
  6716. getDefaultImportOrThrow(message?: string | (() => string)): Identifier;
  6717. /** Gets the default import or returns undefined if it doesn't exist. */
  6718. getDefaultImport(): Identifier | undefined;
  6719. /**
  6720. * Sets the namespace import.
  6721. * @param text - Text to set as the namespace import.
  6722. * @throws - InvalidOperationError if a named import exists.
  6723. */
  6724. setNamespaceImport(text: string): this;
  6725. /** Removes the namespace import. */
  6726. removeNamespaceImport(): this;
  6727. /** Removes the default import. */
  6728. removeDefaultImport(): this;
  6729. /** Gets the namespace import if it exists or throws. */
  6730. getNamespaceImportOrThrow(message?: string | (() => string)): Identifier;
  6731. /** Gets the namespace import identifier, if it exists. */
  6732. getNamespaceImport(): Identifier | undefined;
  6733. /**
  6734. * Adds a named import.
  6735. * @param namedImport - Name, structure, or writer to write the named import with.
  6736. */
  6737. addNamedImport(namedImport: OptionalKind<ImportSpecifierStructure> | string | WriterFunction): ImportSpecifier;
  6738. /**
  6739. * Adds named imports.
  6740. * @param namedImport - Structures, names, or writer function to write the named import with.
  6741. */
  6742. addNamedImports(namedImports: ReadonlyArray<OptionalKind<ImportSpecifierStructure> | string | WriterFunction> | WriterFunction): ImportSpecifier[];
  6743. /**
  6744. * Inserts a named import.
  6745. * @param index - Child index to insert at.
  6746. * @param namedImport - Structure, name, or writer function to write the named import with.
  6747. */
  6748. insertNamedImport(index: number, namedImport: OptionalKind<ImportSpecifierStructure> | string | WriterFunction): ImportSpecifier;
  6749. /**
  6750. * Inserts named imports into the import declaration.
  6751. * @param index - Child index to insert at.
  6752. * @param namedImports - Structures, names, or writer function to write the named import with.
  6753. */
  6754. insertNamedImports(index: number, namedImports: ReadonlyArray<OptionalKind<ImportSpecifierStructure> | string | WriterFunction> | WriterFunction): ImportSpecifier[];
  6755. /** Gets the named imports. */
  6756. getNamedImports(): ImportSpecifier[];
  6757. /**
  6758. * Removes all the named imports.
  6759. * @remarks To remove a single named import, get the named import and call `#remove()` on it.
  6760. */
  6761. removeNamedImports(): this;
  6762. /** Gets the import clause or throws if it doesn't exist. */
  6763. getImportClauseOrThrow(message?: string | (() => string)): ImportClause;
  6764. /** Gets the import clause or returns undefined if it doesn't exist. */
  6765. getImportClause(): ImportClause | undefined;
  6766. /** Sets the import attributes. */
  6767. setAttributes(elements: ReadonlyArray<OptionalKind<ImportAttributeStructure>> | undefined): this;
  6768. /** Gets the import attributes or returns undefined if it doesn't exist. */
  6769. getAttributes(): ImportAttributes | undefined;
  6770. /**
  6771. * Sets the node from a structure.
  6772. * @param structure - Structure to set the node with.
  6773. */
  6774. set(structure: Partial<ImportDeclarationStructure>): this;
  6775. /** Gets the structure equivalent to this node. */
  6776. getStructure(): ImportDeclarationStructure;
  6777. /** @inheritdoc **/
  6778. getParent(): NodeParentType<ts.ImportDeclaration>;
  6779. /** @inheritdoc **/
  6780. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportDeclaration>>;
  6781. }
  6782. declare const ImportEqualsDeclarationBase: Constructor<ExportableNode> & Constructor<ModifierableNode> & Constructor<JSDocableNode> & Constructor<NamedNode> & typeof Statement;
  6783. export declare class ImportEqualsDeclaration extends ImportEqualsDeclarationBase<ts.ImportEqualsDeclaration> {
  6784. /** Gets if this import equals declaration is type only. */
  6785. isTypeOnly(): boolean;
  6786. /** Sets if this import equals declaration is type only. */
  6787. setIsTypeOnly(value: boolean): this;
  6788. /** Gets the module reference of the import equals declaration. */
  6789. getModuleReference(): ModuleReference;
  6790. /** Gets if the external module reference is relative. */
  6791. isExternalModuleReferenceRelative(): boolean;
  6792. /**
  6793. * Sets the external module reference.
  6794. * @param externalModuleReference - External module reference as a string.
  6795. */
  6796. setExternalModuleReference(externalModuleReference: string): this;
  6797. /**
  6798. * Sets the external module reference.
  6799. * @param sourceFile - Source file to set the external module reference to.
  6800. */
  6801. setExternalModuleReference(sourceFile: SourceFile): this;
  6802. /** Gets the source file referenced in the external module reference or throws if it doesn't exist. */
  6803. getExternalModuleReferenceSourceFileOrThrow(message?: string | (() => string)): SourceFile;
  6804. /** Gets the source file referenced in the external module reference or returns undefined if it doesn't exist. */
  6805. getExternalModuleReferenceSourceFile(): SourceFile | undefined;
  6806. /** @inheritdoc **/
  6807. getParent(): NodeParentType<ts.ImportEqualsDeclaration>;
  6808. /** @inheritdoc **/
  6809. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportEqualsDeclaration>>;
  6810. }
  6811. declare const ImportSpecifierBase: typeof Node;
  6812. export declare class ImportSpecifier extends ImportSpecifierBase<ts.ImportSpecifier> {
  6813. /**
  6814. * Sets the identifier being imported.
  6815. * @param name - Name being imported.
  6816. */
  6817. setName(name: string): this;
  6818. /** Gets the name of the import specifier. */
  6819. getName(): string;
  6820. /** Gets the name node of what's being imported. */
  6821. getNameNode(): StringLiteral | Identifier;
  6822. /**
  6823. * Sets the alias for the name being imported and renames all the usages.
  6824. * @param alias - Alias to set.
  6825. */
  6826. renameAlias(alias: string): this;
  6827. /**
  6828. * Sets the alias without renaming all the usages.
  6829. * @param alias - Alias to set.
  6830. */
  6831. setAlias(alias: string): this;
  6832. /**
  6833. * Removes the alias without renaming.
  6834. * @remarks Use removeAliasWithRename() if you want it to rename any usages to the name of the import specifier.
  6835. */
  6836. removeAlias(): this;
  6837. /** Removes the alias and renames any usages to the name of the import specifier. */
  6838. removeAliasWithRename(): this;
  6839. /** Gets the alias identifier, if it exists. */
  6840. getAliasNode(): Identifier | undefined;
  6841. /** Gets if this is a type only import specifier. */
  6842. isTypeOnly(): boolean;
  6843. /** Sets if this is a type only import specifier. */
  6844. setIsTypeOnly(value: boolean): this;
  6845. /** Gets the import declaration associated with this import specifier. */
  6846. getImportDeclaration(): ImportDeclaration;
  6847. /** Remove the import specifier. */
  6848. remove(): void;
  6849. /**
  6850. * Sets the node from a structure.
  6851. * @param structure - Structure to set the node with.
  6852. */
  6853. set(structure: Partial<ImportSpecifierStructure>): this;
  6854. /** Gets the structure equivalent to this node. */
  6855. getStructure(): ImportSpecifierStructure;
  6856. /** @inheritdoc **/
  6857. getParent(): NodeParentType<ts.ImportSpecifier>;
  6858. /** @inheritdoc **/
  6859. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportSpecifier>>;
  6860. }
  6861. declare const ModuleBlockBase: Constructor<StatementedNode> & typeof Statement;
  6862. export declare class ModuleBlock extends ModuleBlockBase<ts.ModuleBlock> {
  6863. /** @inheritdoc **/
  6864. getParent(): NodeParentType<ts.ModuleBlock>;
  6865. /** @inheritdoc **/
  6866. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ModuleBlock>>;
  6867. }
  6868. export declare function ModuleChildableNode<T extends Constructor<ModuleChildableNodeExtensionType>>(Base: T): Constructor<ModuleChildableNode> & T;
  6869. export interface ModuleChildableNode {
  6870. /** Gets the parent module declaration or undefined if it doesn't exist. */
  6871. getParentModule(): ModuleDeclaration | undefined;
  6872. /** Gets the parent module declaration or throws if it doesn't exist. */
  6873. getParentModuleOrThrow(message?: string | (() => string)): ModuleDeclaration;
  6874. }
  6875. type ModuleChildableNodeExtensionType = Node;
  6876. declare const ModuleDeclarationBase: Constructor<ModuledNode> & Constructor<UnwrappableNode> & Constructor<TextInsertableNode> & Constructor<BodyableNode> & Constructor<ModuleChildableNode> & Constructor<StatementedNode> & Constructor<JSDocableNode> & Constructor<AmbientableNode> & Constructor<ExportableNode> & Constructor<ModifierableNode> & Constructor<ModuleNamedNode> & typeof Statement;
  6877. export declare class ModuleDeclaration extends ModuleDeclarationBase<ts.ModuleDeclaration> {
  6878. /** Gets the full name of the namespace. */
  6879. getName(): string;
  6880. /**
  6881. * Sets the name without renaming references.
  6882. * @param newName - New full namespace name.
  6883. */
  6884. setName(newName: string): this;
  6885. /**
  6886. * Renames the module name.
  6887. *
  6888. * Note: The TS compiler does not update module declarations for string literal module names unfortunately.
  6889. * @param newName - New name.
  6890. * @param options - Options for renaming.
  6891. */
  6892. rename(newName: string, options?: RenameOptions): this;
  6893. /** Gets the name nodes or the string literal. */
  6894. getNameNodes(): Identifier[] | StringLiteral;
  6895. /** Gets if this namespace has a namespace keyword. */
  6896. hasNamespaceKeyword(): boolean;
  6897. /** Gets if this namespace has a namespace keyword. */
  6898. hasModuleKeyword(): boolean;
  6899. /**
  6900. * Sets the namespace declaration kind.
  6901. * @param kind - Kind to set.
  6902. */
  6903. setDeclarationKind(kind: ModuleDeclarationKind): this;
  6904. /** Gets the namesapce declaration kind. */
  6905. getDeclarationKind(): ModuleDeclarationKind;
  6906. /** Gets the namespace or module keyword or returns undefined if it's global. */
  6907. getDeclarationKindKeyword(): Node<ts.Node> | undefined;
  6908. /**
  6909. * Sets the node from a structure.
  6910. * @param structure - Structure to set the node with.
  6911. */
  6912. set(structure: Partial<ModuleDeclarationStructure>): this;
  6913. /** Gets the structure equivalent to this node. */
  6914. getStructure(): ModuleDeclarationStructure;
  6915. /** @inheritdoc **/
  6916. getParent(): NodeParentType<ts.ModuleDeclaration>;
  6917. /** @inheritdoc **/
  6918. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ModuleDeclaration>>;
  6919. }
  6920. export declare enum ModuleDeclarationKind {
  6921. Namespace = "namespace",
  6922. Module = "module",
  6923. Global = "global"
  6924. }
  6925. declare const NamedExportsBase: typeof Node;
  6926. export declare class NamedExports extends NamedExportsBase<ts.NamedExports> {
  6927. /** Gets the export specifiers. */
  6928. getElements(): ExportSpecifier[];
  6929. /** @inheritdoc **/
  6930. getParent(): NodeParentType<ts.NamedExports>;
  6931. /** @inheritdoc **/
  6932. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NamedExports>>;
  6933. }
  6934. declare const NamedImportsBase: typeof Node;
  6935. export declare class NamedImports extends NamedImportsBase<ts.NamedImports> {
  6936. /** Gets the import specifiers. */
  6937. getElements(): ImportSpecifier[];
  6938. /** @inheritdoc **/
  6939. getParent(): NodeParentType<ts.NamedImports>;
  6940. /** @inheritdoc **/
  6941. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NamedImports>>;
  6942. }
  6943. declare const NamespaceExportBase: Constructor<RenameableNode> & typeof Node;
  6944. export declare class NamespaceExport extends NamespaceExportBase<ts.NamespaceExport> {
  6945. /** Sets the name of the namespace export. */
  6946. setName(name: string): this;
  6947. /** Gets the name of the namespace export. */
  6948. getName(): string;
  6949. /** Gets the namespace export's name node. */
  6950. getNameNode(): StringLiteral | Identifier;
  6951. /** @inheritdoc **/
  6952. getParent(): NodeParentType<ts.NamespaceExport>;
  6953. /** @inheritdoc **/
  6954. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NamespaceExport>>;
  6955. }
  6956. declare const NamespaceImportBase: Constructor<RenameableNode> & typeof Node;
  6957. export declare class NamespaceImport extends NamespaceImportBase<ts.NamespaceImport> {
  6958. /** Sets the name of the namespace import. */
  6959. setName(name: string): this;
  6960. /** Gets the name of the namespace import. */
  6961. getName(): string;
  6962. /** Gets the namespace import's name node. */
  6963. getNameNode(): Identifier;
  6964. /** @inheritdoc **/
  6965. getParent(): NodeParentType<ts.NamespaceImport>;
  6966. /** @inheritdoc **/
  6967. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NamespaceImport>>;
  6968. }
  6969. export declare class FileReference extends TextRange<ts.FileReference> {
  6970. constructor(compilerObject: ts.FileReference, sourceFile: SourceFile);
  6971. /** Gets the referenced file name. */
  6972. getFileName(): string;
  6973. }
  6974. /** Result of refreshing a source file from the file system. */
  6975. export declare enum FileSystemRefreshResult {
  6976. /** The source file did not change. */
  6977. NoChange = 0,
  6978. /** The source file was updated from the file system. */
  6979. Updated = 1,
  6980. /** The source file was deleted. */
  6981. Deleted = 2
  6982. }
  6983. export interface SourceFileCopyOptions {
  6984. overwrite?: boolean;
  6985. }
  6986. export interface SourceFileMoveOptions {
  6987. overwrite?: boolean;
  6988. }
  6989. /** Options for emitting a source file. */
  6990. export interface SourceFileEmitOptions extends EmitOptionsBase {
  6991. }
  6992. declare const SourceFileBase: Constructor<ModuledNode> & Constructor<StatementedNode> & Constructor<TextInsertableNode> & typeof Node;
  6993. export declare class SourceFile extends SourceFileBase<ts.SourceFile> {
  6994. #private;
  6995. private constructor();
  6996. /** Gets the file path. */
  6997. getFilePath(): StandardizedFilePath;
  6998. /** Gets the file path's base name. */
  6999. getBaseName(): string;
  7000. /** Gets the file path's base name without the extension. */
  7001. getBaseNameWithoutExtension(): string;
  7002. /** Gets the file path's extension. */
  7003. getExtension(): string;
  7004. /** Gets the directory that the source file is contained in. */
  7005. getDirectory(): Directory;
  7006. /** Gets the directory path that the source file is contained in. */
  7007. getDirectoryPath(): StandardizedFilePath;
  7008. /** Gets the full text with leading trivia. */
  7009. getFullText(): string;
  7010. /**
  7011. * Gets the line and column number at the provided position (1-indexed).
  7012. * @param pos - Position in the source file.
  7013. */
  7014. getLineAndColumnAtPos(pos: number): {
  7015. line: number;
  7016. column: number;
  7017. };
  7018. /**
  7019. * Gets the character count from the start of the line to the provided position.
  7020. * @param pos - Position.
  7021. */
  7022. getLengthFromLineStartAtPos(pos: number): number;
  7023. /**
  7024. * Copies this source file to the specified directory.
  7025. *
  7026. * This will modify the module specifiers in the new file, if necessary.
  7027. * @param dirPathOrDirectory Directory path or directory object to copy the file to.
  7028. * @param options Options for copying.
  7029. * @returns The source file the copy was made to.
  7030. */
  7031. copyToDirectory(dirPathOrDirectory: string | Directory, options?: SourceFileCopyOptions): SourceFile;
  7032. /**
  7033. * Copy this source file to a new file.
  7034. *
  7035. * This will modify the module specifiers in the new file, if necessary.
  7036. * @param filePath - New file path. Can be relative to the original file or an absolute path.
  7037. * @param options - Options for copying.
  7038. */
  7039. copy(filePath: string, options?: SourceFileCopyOptions): SourceFile;
  7040. /**
  7041. * Copy this source file to a new file and immediately saves it to the file system asynchronously.
  7042. *
  7043. * This will modify the module specifiers in the new file, if necessary.
  7044. * @param filePath - New file path. Can be relative to the original file or an absolute path.
  7045. * @param options - Options for copying.
  7046. */
  7047. copyImmediately(filePath: string, options?: SourceFileCopyOptions): Promise<SourceFile>;
  7048. /**
  7049. * Copy this source file to a new file and immediately saves it to the file system synchronously.
  7050. *
  7051. * This will modify the module specifiers in the new file, if necessary.
  7052. * @param filePath - New file path. Can be relative to the original file or an absolute path.
  7053. * @param options - Options for copying.
  7054. */
  7055. copyImmediatelySync(filePath: string, options?: SourceFileCopyOptions): SourceFile;
  7056. /**
  7057. * Moves this source file to the specified directory.
  7058. *
  7059. * This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
  7060. * @param dirPathOrDirectory Directory path or directory object to move the file to.
  7061. * @param options Options for moving.
  7062. */
  7063. moveToDirectory(dirPathOrDirectory: string | Directory, options?: SourceFileMoveOptions): SourceFile;
  7064. /**
  7065. * Moves this source file to a new file.
  7066. *
  7067. * This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
  7068. * @param filePath - New file path. Can be relative to the original file or an absolute path.
  7069. * @param options - Options for moving.
  7070. */
  7071. move(filePath: string, options?: SourceFileMoveOptions): SourceFile;
  7072. /**
  7073. * Moves this source file to a new file and asynchronously updates the file system immediately.
  7074. *
  7075. * This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
  7076. * @param filePath - New file path. Can be relative to the original file or an absolute path.
  7077. * @param options - Options for moving.
  7078. */
  7079. moveImmediately(filePath: string, options?: SourceFileMoveOptions): Promise<SourceFile>;
  7080. /**
  7081. * Moves this source file to a new file and synchronously updates the file system immediately.
  7082. *
  7083. * This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
  7084. * @param filePath - New file path. Can be relative to the original file or an absolute path.
  7085. * @param options - Options for moving.
  7086. */
  7087. moveImmediatelySync(filePath: string, options?: SourceFileMoveOptions): SourceFile;
  7088. /**
  7089. * Queues a deletion of the file to the file system.
  7090. *
  7091. * The file will be deleted when you call ast.save(). If you wish to immediately delete the file, then use deleteImmediately().
  7092. */
  7093. delete(): void;
  7094. /** Asynchronously deletes the file from the file system. */
  7095. deleteImmediately(): Promise<void>;
  7096. /** Synchronously deletes the file from the file system. */
  7097. deleteImmediatelySync(): void;
  7098. /** Asynchronously saves this file with any changes. */
  7099. save(): Promise<void>;
  7100. /** Synchronously saves this file with any changes. */
  7101. saveSync(): void;
  7102. /** Gets any `/// <reference path="..." />` comments. */
  7103. getPathReferenceDirectives(): FileReference[];
  7104. /** Gets any `/// <reference types="..." />` comments. */
  7105. getTypeReferenceDirectives(): FileReference[];
  7106. /** Gets any `/// <reference lib="..." />` comments. */
  7107. getLibReferenceDirectives(): FileReference[];
  7108. /** Gets any source files that reference this source file. */
  7109. getReferencingSourceFiles(): SourceFile[];
  7110. /** Gets the import and exports in other source files that reference this source file. */
  7111. getReferencingNodesInOtherSourceFiles(): SourceFileReferencingNodes[];
  7112. /** Gets the string literals in other source files that reference this source file. */
  7113. getReferencingLiteralsInOtherSourceFiles(): StringLiteral[];
  7114. /** Gets the source files this source file references in string literals. */
  7115. getReferencedSourceFiles(): SourceFile[];
  7116. /** Gets the nodes that reference other source files in string literals. */
  7117. getNodesReferencingOtherSourceFiles(): SourceFileReferencingNodes[];
  7118. /**
  7119. * Gets the string literals in this source file that references other source files.
  7120. * @remarks This is similar to `getImportStringLiterals()`, but `getImportStringLiterals()`
  7121. * will return import string literals that may not be referencing another source file
  7122. * or have not been able to be resolved.
  7123. */
  7124. getLiteralsReferencingOtherSourceFiles(): StringLiteral[];
  7125. /** Gets all the descendant string literals that reference a module. */
  7126. getImportStringLiterals(): StringLiteral[];
  7127. /** Gets the script target of the source file. */
  7128. getLanguageVersion(): ScriptTarget;
  7129. /** Gets the language variant of the source file. */
  7130. getLanguageVariant(): LanguageVariant;
  7131. /** Gets the script kind of the source file. */
  7132. getScriptKind(): ScriptKind;
  7133. /** Gets if this is a declaration file. */
  7134. isDeclarationFile(): boolean;
  7135. /** Gets if the source file was discovered while loading an external library. */
  7136. isFromExternalLibrary(): boolean;
  7137. /** Gets if the source file is a descendant of a node_modules directory. */
  7138. isInNodeModules(): boolean;
  7139. /** Gets if this source file has been saved or if the latest changes have been saved. */
  7140. isSaved(): boolean;
  7141. /** Gets the pre-emit diagnostics of the specified source file. */
  7142. getPreEmitDiagnostics(): Diagnostic[];
  7143. /**
  7144. * Deindents the line at the specified position.
  7145. * @param pos - Position.
  7146. * @param times - Times to unindent. Specify a negative value to indent.
  7147. */
  7148. unindent(pos: number, times?: number): this;
  7149. /**
  7150. * Deindents the lines within the specified range.
  7151. * @param positionRange - Position range.
  7152. * @param times - Times to unindent. Specify a negative value to indent.
  7153. */
  7154. unindent(positionRange: [number, number], times?: number): this;
  7155. /**
  7156. * Indents the line at the specified position.
  7157. * @param pos - Position.
  7158. * @param times - Times to indent. Specify a negative value to unindent.
  7159. */
  7160. indent(pos: number, times?: number): this;
  7161. /**
  7162. * Indents the lines within the specified range.
  7163. * @param positionRange - Position range.
  7164. * @param times - Times to indent. Specify a negative value to unindent.
  7165. */
  7166. indent(positionRange: [number, number], times?: number): this;
  7167. /** Asynchronously emits the source file as a JavaScript file. */
  7168. emit(options?: SourceFileEmitOptions): Promise<EmitResult>;
  7169. /** Synchronously emits the source file as a JavaScript file. */
  7170. emitSync(options?: SourceFileEmitOptions): EmitResult;
  7171. /**
  7172. * Gets the emit output of this source file.
  7173. * @param options - Emit options.
  7174. */
  7175. getEmitOutput(options?: {
  7176. emitOnlyDtsFiles?: boolean;
  7177. }): EmitOutput;
  7178. /**
  7179. * Formats the source file text using the internal TypeScript formatting API.
  7180. * @param settings - Format code settings.
  7181. */
  7182. formatText(settings?: FormatCodeSettings): void;
  7183. /**
  7184. * Refresh the source file from the file system.
  7185. *
  7186. * WARNING: When updating from the file system, this will "forget" any previously navigated nodes.
  7187. * @returns What action ended up taking place.
  7188. */
  7189. refreshFromFileSystem(): Promise<FileSystemRefreshResult>;
  7190. /**
  7191. * Synchronously refreshes the source file from the file system.
  7192. *
  7193. * WARNING: When updating from the file system, this will "forget" any previously navigated nodes.
  7194. * @returns What action ended up taking place.
  7195. */
  7196. refreshFromFileSystemSync(): FileSystemRefreshResult;
  7197. /**
  7198. * Gets the relative path to the specified path.
  7199. * @param fileOrDirPath - The file or directory path.
  7200. */
  7201. getRelativePathTo(fileOrDirPath: string): string;
  7202. /**
  7203. * Gets the relative path to another source file.
  7204. * @param sourceFile - Source file.
  7205. */
  7206. getRelativePathTo(sourceFile: SourceFile): string;
  7207. /**
  7208. * Gets the relative path to another directory.
  7209. * @param directory - Directory.
  7210. */
  7211. getRelativePathTo(directory: Directory): string;
  7212. /**
  7213. * Gets the relative path to the specified file path as a module specifier.
  7214. * @param filePath - File path.
  7215. * @remarks To get to a directory, provide `path/to/directory/index.ts`.
  7216. */
  7217. getRelativePathAsModuleSpecifierTo(filePath: string): string;
  7218. /**
  7219. * Gets the relative path to the specified source file as a module specifier.
  7220. * @param sourceFile - Source file.
  7221. */
  7222. getRelativePathAsModuleSpecifierTo(sourceFile: SourceFile): string;
  7223. /**
  7224. * Gets the relative path to the specified directory as a module specifier.
  7225. * @param directory - Directory.
  7226. */
  7227. getRelativePathAsModuleSpecifierTo(directory: Directory): string;
  7228. /**
  7229. * Subscribe to when the source file is modified.
  7230. * @param subscription - Subscription.
  7231. * @param subscribe - Optional and defaults to true. Use an explicit false to unsubscribe.
  7232. */
  7233. onModified(subscription: (sender: SourceFile) => void, subscribe?: boolean): this;
  7234. /**
  7235. * Organizes the imports in the file.
  7236. *
  7237. * WARNING! This will forget all the nodes in the file! It's best to do this after you're all done with the file.
  7238. * @param formatSettings - Format code settings.
  7239. * @param userPreferences - User preferences for refactoring.
  7240. */
  7241. organizeImports(formatSettings?: FormatCodeSettings, userPreferences?: UserPreferences): this;
  7242. /**
  7243. * Removes all unused declarations like interfaces, classes, enums, functions, variables, parameters,
  7244. * methods, properties, imports, etc. from this file.
  7245. *
  7246. * Tip: For optimal results, sometimes this method needs to be called more than once. There could be nodes
  7247. * that are only referenced in unused declarations and in this case, another call will also remove them.
  7248. *
  7249. * WARNING! This will forget all the nodes in the file! It's best to do this after you're all done with the file.
  7250. * @param formatSettings - Format code settings.
  7251. * @param userPreferences - User preferences for refactoring.
  7252. */
  7253. fixUnusedIdentifiers(formatSettings?: FormatCodeSettings, userPreferences?: UserPreferences): this;
  7254. /**
  7255. * Code fix to add import declarations for identifiers that are referenced, but not imported in the source file.
  7256. * @param formatSettings - Format code settings.
  7257. * @param userPreferences - User preferences for refactoring.
  7258. */
  7259. fixMissingImports(formatSettings?: FormatCodeSettings, userPreferences?: UserPreferences): this;
  7260. /**
  7261. * Applies the text changes to the source file.
  7262. *
  7263. * WARNING! This will forget all the nodes in the file! It's best to do this after you're all done with the file.
  7264. * @param textChanges - Text changes.
  7265. */
  7266. applyTextChanges(textChanges: ReadonlyArray<ts.TextChange | TextChange>): this;
  7267. /**
  7268. * Sets the node from a structure.
  7269. * @param structure - Structure to set the node with.
  7270. */
  7271. set(structure: Partial<SourceFileStructure>): this;
  7272. /** Gets the structure equivalent to this node. */
  7273. getStructure(): SourceFileStructure;
  7274. /** @inheritdoc **/
  7275. getParent(): NodeParentType<ts.SourceFile>;
  7276. /** @inheritdoc **/
  7277. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SourceFile>>;
  7278. }
  7279. declare function CommonIdentifierBase<T extends Constructor<CommonIdentifierBaseExtensionType>>(Base: T): Constructor<CommonIdentifierBase> & T;
  7280. interface CommonIdentifierBase {
  7281. /** Gets the text for the identifier. */
  7282. getText(): string;
  7283. /**
  7284. * Gets the definition nodes of the identifier.
  7285. * @remarks This is similar to "go to definition" and `.getDefinitions()`, but only returns the nodes.
  7286. */
  7287. getDefinitionNodes(): Node[];
  7288. /**
  7289. * Gets the definitions of the identifier.
  7290. * @remarks This is similar to "go to definition." Use `.getDefinitionNodes()` if you only care about the nodes.
  7291. */
  7292. getDefinitions(): DefinitionInfo[];
  7293. }
  7294. type CommonIdentifierBaseExtensionType = Node<ts.Node & {
  7295. text: string;
  7296. }>;
  7297. declare const ComputedPropertyNameBase: Constructor<ExpressionedNode> & typeof Node;
  7298. export declare class ComputedPropertyName extends ComputedPropertyNameBase<ts.ComputedPropertyName> {
  7299. /** @inheritdoc **/
  7300. getParent(): NodeParentType<ts.ComputedPropertyName>;
  7301. /** @inheritdoc **/
  7302. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ComputedPropertyName>>;
  7303. }
  7304. declare const IdentifierBase: Constructor<CommonIdentifierBase> & Constructor<ReferenceFindableNode> & Constructor<RenameableNode> & typeof PrimaryExpression;
  7305. export declare class Identifier extends IdentifierBase<ts.Identifier> {
  7306. /**
  7307. * Gets the implementations of the identifier.
  7308. *
  7309. * This is similar to "go to implementation."
  7310. */
  7311. getImplementations(): ImplementationLocation[];
  7312. /** @inheritdoc **/
  7313. getParent(): NodeParentType<ts.Identifier>;
  7314. /** @inheritdoc **/
  7315. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.Identifier>>;
  7316. }
  7317. declare const PrivateIdentifierBase: Constructor<CommonIdentifierBase> & Constructor<ReferenceFindableNode> & Constructor<RenameableNode> & typeof Node;
  7318. export declare class PrivateIdentifier extends PrivateIdentifierBase<ts.PrivateIdentifier> {
  7319. /** @inheritdoc **/
  7320. getParent(): NodeParentType<ts.PrivateIdentifier>;
  7321. /** @inheritdoc **/
  7322. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.PrivateIdentifier>>;
  7323. }
  7324. export declare class QualifiedName extends Node<ts.QualifiedName> {
  7325. /** Gets the left side of the qualified name. */
  7326. getLeft(): EntityName;
  7327. /** Gets the right identifier of the qualified name. */
  7328. getRight(): Identifier;
  7329. /** @inheritdoc **/
  7330. getParent(): NodeParentType<ts.QualifiedName>;
  7331. /** @inheritdoc **/
  7332. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.QualifiedName>>;
  7333. }
  7334. declare const BlockBase: Constructor<TextInsertableNode> & Constructor<StatementedNode> & typeof Statement;
  7335. export declare class Block extends BlockBase<ts.Block> {
  7336. /** @inheritdoc **/
  7337. getParent(): NodeParentType<ts.Block>;
  7338. /** @inheritdoc **/
  7339. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.Block>>;
  7340. }
  7341. export declare class BreakStatement extends Statement<ts.BreakStatement> {
  7342. /** Gets this break statement's label or undefined if it does not exist. */
  7343. getLabel(): Identifier | undefined;
  7344. /** Gets this break statement's label or throw if it does not exist. */
  7345. getLabelOrThrow(message?: string | (() => string)): Identifier;
  7346. /** @inheritdoc **/
  7347. getParent(): NodeParentType<ts.BreakStatement>;
  7348. /** @inheritdoc **/
  7349. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.BreakStatement>>;
  7350. }
  7351. declare const CaseBlockBase: Constructor<TextInsertableNode> & typeof Node;
  7352. export declare class CaseBlock extends CaseBlockBase<ts.CaseBlock> {
  7353. /** Gets the clauses. */
  7354. getClauses(): CaseOrDefaultClause[];
  7355. /**
  7356. * Removes the clause at the specified index.
  7357. * @param index - Index.
  7358. */
  7359. removeClause(index: number): this;
  7360. /**
  7361. * Removes the clauses in the specified range.
  7362. * @param indexRange - Index range.
  7363. */
  7364. removeClauses(indexRange: [number, number]): this;
  7365. /** @inheritdoc **/
  7366. getParent(): NodeParentType<ts.CaseBlock>;
  7367. /** @inheritdoc **/
  7368. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.CaseBlock>>;
  7369. }
  7370. declare const CaseClauseBase: Constructor<JSDocableNode> & Constructor<ExpressionedNode> & Constructor<TextInsertableNode> & Constructor<StatementedNode> & typeof Node;
  7371. export declare class CaseClause extends CaseClauseBase<ts.CaseClause> {
  7372. /** Removes this case clause. */
  7373. remove(): void;
  7374. /** @inheritdoc **/
  7375. getParent(): NodeParentType<ts.CaseClause>;
  7376. /** @inheritdoc **/
  7377. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.CaseClause>>;
  7378. }
  7379. declare const CatchClauseBase: typeof Node;
  7380. export declare class CatchClause extends CatchClauseBase<ts.CatchClause> {
  7381. /** Gets this catch clause's block. */
  7382. getBlock(): Block;
  7383. /** Gets this catch clause's variable declaration or undefined if none exists. */
  7384. getVariableDeclaration(): VariableDeclaration | undefined;
  7385. /** Gets this catch clause's variable declaration or throws if none exists. */
  7386. getVariableDeclarationOrThrow(message?: string | (() => string)): VariableDeclaration;
  7387. /** @inheritdoc **/
  7388. getParent(): NodeParentType<ts.CatchClause>;
  7389. /** @inheritdoc **/
  7390. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.CatchClause>>;
  7391. }
  7392. export declare class CommentStatement extends Statement<CompilerCommentStatement> {
  7393. }
  7394. export declare class ContinueStatement extends Statement<ts.ContinueStatement> {
  7395. /** Gets this continue statement's label or undefined if it does not exist. */
  7396. getLabel(): Identifier | undefined;
  7397. /** Gets this continue statement's label or throw if it does not exist. */
  7398. getLabelOrThrow(message?: string | (() => string)): Identifier;
  7399. /** @inheritdoc **/
  7400. getParent(): NodeParentType<ts.ContinueStatement>;
  7401. /** @inheritdoc **/
  7402. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ContinueStatement>>;
  7403. }
  7404. declare const DebuggerStatementBase: typeof Statement;
  7405. export declare class DebuggerStatement extends DebuggerStatementBase<ts.DebuggerStatement> {
  7406. /** @inheritdoc **/
  7407. getParent(): NodeParentType<ts.DebuggerStatement>;
  7408. /** @inheritdoc **/
  7409. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.DebuggerStatement>>;
  7410. }
  7411. declare const DefaultClauseBase: Constructor<TextInsertableNode> & Constructor<StatementedNode> & typeof Node;
  7412. export declare class DefaultClause extends DefaultClauseBase<ts.DefaultClause> {
  7413. /** Removes the default clause. */
  7414. remove(): void;
  7415. /** @inheritdoc **/
  7416. getParent(): NodeParentType<ts.DefaultClause>;
  7417. /** @inheritdoc **/
  7418. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.DefaultClause>>;
  7419. }
  7420. declare const DoStatementBase: Constructor<ExpressionedNode> & typeof IterationStatement;
  7421. export declare class DoStatement extends DoStatementBase<ts.DoStatement> {
  7422. /** @inheritdoc **/
  7423. getParent(): NodeParentType<ts.DoStatement>;
  7424. /** @inheritdoc **/
  7425. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.DoStatement>>;
  7426. }
  7427. declare const EmptyStatementBase: typeof Statement;
  7428. export declare class EmptyStatement extends EmptyStatementBase<ts.EmptyStatement> {
  7429. /** @inheritdoc **/
  7430. getParent(): NodeParentType<ts.EmptyStatement>;
  7431. /** @inheritdoc **/
  7432. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.EmptyStatement>>;
  7433. }
  7434. declare const ExpressionStatementBase: Constructor<ExpressionedNode> & Constructor<JSDocableNode> & typeof Statement;
  7435. export declare class ExpressionStatement extends ExpressionStatementBase<ts.ExpressionStatement> {
  7436. /** @inheritdoc **/
  7437. getParent(): NodeParentType<ts.ExpressionStatement>;
  7438. /** @inheritdoc **/
  7439. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ExpressionStatement>>;
  7440. }
  7441. declare const ForInStatementBase: Constructor<ExpressionedNode> & typeof IterationStatement;
  7442. export declare class ForInStatement extends ForInStatementBase<ts.ForInStatement> {
  7443. /** Gets this for in statement's initializer. */
  7444. getInitializer(): VariableDeclarationList | Expression;
  7445. /** @inheritdoc **/
  7446. getParent(): NodeParentType<ts.ForInStatement>;
  7447. /** @inheritdoc **/
  7448. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ForInStatement>>;
  7449. }
  7450. declare const ForOfStatementBase: Constructor<ExpressionedNode> & Constructor<AwaitableNode> & typeof IterationStatement;
  7451. export declare class ForOfStatement extends ForOfStatementBase<ts.ForOfStatement> {
  7452. /** Gets this for of statement's initializer. */
  7453. getInitializer(): VariableDeclarationList | Expression;
  7454. /** @inheritdoc **/
  7455. getParent(): NodeParentType<ts.ForOfStatement>;
  7456. /** @inheritdoc **/
  7457. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ForOfStatement>>;
  7458. }
  7459. declare const ForStatementBase: typeof IterationStatement;
  7460. export declare class ForStatement extends ForStatementBase<ts.ForStatement> {
  7461. /** Gets this for statement's initializer or undefined if none exists. */
  7462. getInitializer(): VariableDeclarationList | Expression | undefined;
  7463. /** Gets this for statement's initializer or throws if none exists. */
  7464. getInitializerOrThrow(message?: string | (() => string)): Expression<ts.Expression> | VariableDeclarationList;
  7465. /** Gets this for statement's condition or undefined if none exists. */
  7466. getCondition(): Expression | undefined;
  7467. /** Gets this for statement's condition or throws if none exists. */
  7468. getConditionOrThrow(message?: string | (() => string)): Expression<ts.Expression>;
  7469. /** Gets this for statement's incrementor. */
  7470. getIncrementor(): Expression | undefined;
  7471. /** Gets this for statement's incrementor or throws if none exists. */
  7472. getIncrementorOrThrow(message?: string | (() => string)): Expression<ts.Expression>;
  7473. /** @inheritdoc **/
  7474. getParent(): NodeParentType<ts.ForStatement>;
  7475. /** @inheritdoc **/
  7476. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ForStatement>>;
  7477. }
  7478. declare const IfStatementBase: Constructor<ExpressionedNode> & typeof Statement;
  7479. export declare class IfStatement extends IfStatementBase<ts.IfStatement> {
  7480. /** Gets this if statement's then statement. */
  7481. getThenStatement(): Statement;
  7482. /** Gets this if statement's else statement. */
  7483. getElseStatement(): Statement | undefined;
  7484. /** @inheritdoc */
  7485. remove(): void;
  7486. /** @inheritdoc **/
  7487. getParent(): NodeParentType<ts.IfStatement>;
  7488. /** @inheritdoc **/
  7489. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.IfStatement>>;
  7490. }
  7491. export declare class IterationStatement<T extends ts.IterationStatement = ts.IterationStatement> extends Statement<T> {
  7492. /** Gets this iteration statement's statement. */
  7493. getStatement(): Statement;
  7494. }
  7495. declare const LabeledStatementBase: Constructor<JSDocableNode> & typeof Statement;
  7496. export declare class LabeledStatement extends LabeledStatementBase<ts.LabeledStatement> {
  7497. /** Gets this labeled statement's label */
  7498. getLabel(): Identifier;
  7499. /** Gets this labeled statement's statement */
  7500. getStatement(): Statement;
  7501. /** @inheritdoc **/
  7502. getParent(): NodeParentType<ts.LabeledStatement>;
  7503. /** @inheritdoc **/
  7504. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.LabeledStatement>>;
  7505. }
  7506. declare const NotEmittedStatementBase: typeof Statement;
  7507. export declare class NotEmittedStatement extends NotEmittedStatementBase<ts.NotEmittedStatement> {
  7508. /** @inheritdoc **/
  7509. getParent(): NodeParentType<ts.NotEmittedStatement>;
  7510. /** @inheritdoc **/
  7511. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NotEmittedStatement>>;
  7512. }
  7513. declare const ReturnStatementBase: Constructor<ExpressionableNode> & typeof Statement;
  7514. export declare class ReturnStatement extends ReturnStatementBase<ts.ReturnStatement> {
  7515. /** @inheritdoc **/
  7516. getParent(): NodeParentType<ts.ReturnStatement>;
  7517. /** @inheritdoc **/
  7518. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ReturnStatement>>;
  7519. }
  7520. declare const StatementBase: Constructor<ChildOrderableNode> & typeof Node;
  7521. export declare class Statement<T extends ts.Statement = ts.Statement> extends StatementBase<T> {
  7522. /** Removes the statement. */
  7523. remove(): void;
  7524. }
  7525. export declare function StatementedNode<T extends Constructor<StatementedNodeExtensionType>>(Base: T): Constructor<StatementedNode> & T;
  7526. export interface StatementedNode {
  7527. /** Gets the node's statements. */
  7528. getStatements(): Statement[];
  7529. /** Gets the node's statements with comment statements. */
  7530. getStatementsWithComments(): Statement[];
  7531. /**
  7532. * Gets the first statement that matches the provided condition or returns undefined if it doesn't exist.
  7533. * @param findFunction - Function to find the statement by.
  7534. */
  7535. getStatement<T extends Statement>(findFunction: (statement: Statement) => statement is T): T | undefined;
  7536. /**
  7537. * Gets the first statement that matches the provided condition or returns undefined if it doesn't exist.
  7538. * @param findFunction - Function to find the statement by.
  7539. */
  7540. getStatement(findFunction: (statement: Statement) => boolean): Statement | undefined;
  7541. /**
  7542. * Gets the first statement that matches the provided condition or throws if it doesn't exist.
  7543. * @param findFunction - Function to find the statement by.
  7544. */
  7545. getStatementOrThrow<T extends Statement>(findFunction: (statement: Statement) => statement is T): T;
  7546. /**
  7547. * Gets the first statement that matches the provided condition or throws if it doesn't exist.
  7548. * @param findFunction - Function to find the statement by.
  7549. */
  7550. getStatementOrThrow(findFunction: (statement: Statement) => boolean): Statement;
  7551. /**
  7552. * Gets the first statement that matches the provided syntax kind or returns undefined if it doesn't exist.
  7553. * @param kind - Syntax kind to find the node by.
  7554. */
  7555. getStatementByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappingsWithCommentStatements[TKind] | undefined;
  7556. /**
  7557. * Gets the first statement that matches the provided syntax kind or throws if it doesn't exist.
  7558. * @param kind - Syntax kind to find the node by.
  7559. */
  7560. getStatementByKindOrThrow<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappingsWithCommentStatements[TKind];
  7561. /**
  7562. * Add statements.
  7563. * @param statements - statements to add.
  7564. * @returns The statements that were added.
  7565. */
  7566. addStatements(statements: string | WriterFunction | ReadonlyArray<string | WriterFunction | StatementStructures>): Statement[];
  7567. /**
  7568. * Inserts statements at the specified index.
  7569. * @param index - Child index to insert at.
  7570. * @param statements - Statements to insert.
  7571. * @returns The statements that were inserted.
  7572. */
  7573. insertStatements(index: number, statements: string | WriterFunction | ReadonlyArray<string | WriterFunction | StatementStructures>): Statement[];
  7574. /**
  7575. * Removes the statement at the specified index.
  7576. * @param index - Child index to remove the statement at.
  7577. */
  7578. removeStatement(index: number): this;
  7579. /**
  7580. * Removes the statements at the specified index range.
  7581. * @param indexRange - The start and end inclusive index range to remove.
  7582. */
  7583. removeStatements(indexRange: [number, number]): this;
  7584. /**
  7585. * Adds an class declaration as a child.
  7586. * @param structure - Structure of the class declaration to add.
  7587. */
  7588. addClass(structure: OptionalKind<ClassDeclarationStructure>): ClassDeclaration;
  7589. /**
  7590. * Adds class declarations as a child.
  7591. * @param structures - Structures of the class declarations to add.
  7592. */
  7593. addClasses(structures: ReadonlyArray<OptionalKind<ClassDeclarationStructure>>): ClassDeclaration[];
  7594. /**
  7595. * Inserts an class declaration as a child.
  7596. * @param index - Child index to insert at.
  7597. * @param structure - Structure of the class declaration to insert.
  7598. */
  7599. insertClass(index: number, structure: OptionalKind<ClassDeclarationStructure>): ClassDeclaration;
  7600. /**
  7601. * Inserts class declarations as a child.
  7602. * @param index - Child index to insert at.
  7603. * @param structures - Structures of the class declarations to insert.
  7604. */
  7605. insertClasses(index: number, structures: ReadonlyArray<OptionalKind<ClassDeclarationStructure>>): ClassDeclaration[];
  7606. /** Gets the direct class declaration children. */
  7607. getClasses(): ClassDeclaration[];
  7608. /**
  7609. * Gets a class.
  7610. * @param name - Name of the class.
  7611. */
  7612. getClass(name: string): ClassDeclaration | undefined;
  7613. /**
  7614. * Gets a class.
  7615. * @param findFunction - Function to use to find the class.
  7616. */
  7617. getClass(findFunction: (declaration: ClassDeclaration) => boolean): ClassDeclaration | undefined;
  7618. /**
  7619. * Gets a class or throws if it doesn't exist.
  7620. * @param name - Name of the class.
  7621. */
  7622. getClassOrThrow(name: string): ClassDeclaration;
  7623. /**
  7624. * Gets a class or throws if it doesn't exist.
  7625. * @param findFunction - Function to use to find the class.
  7626. */
  7627. getClassOrThrow(findFunction: (declaration: ClassDeclaration) => boolean): ClassDeclaration;
  7628. /**
  7629. * Adds an enum declaration as a child.
  7630. * @param structure - Structure of the enum declaration to add.
  7631. */
  7632. addEnum(structure: OptionalKind<EnumDeclarationStructure>): EnumDeclaration;
  7633. /**
  7634. * Adds enum declarations as a child.
  7635. * @param structures - Structures of the enum declarations to add.
  7636. */
  7637. addEnums(structures: ReadonlyArray<OptionalKind<EnumDeclarationStructure>>): EnumDeclaration[];
  7638. /**
  7639. * Inserts an enum declaration as a child.
  7640. * @param index - Child index to insert at.
  7641. * @param structure - Structure of the enum declaration to insert.
  7642. */
  7643. insertEnum(index: number, structure: OptionalKind<EnumDeclarationStructure>): EnumDeclaration;
  7644. /**
  7645. * Inserts enum declarations as a child.
  7646. * @param index - Child index to insert at.
  7647. * @param structures - Structures of the enum declarations to insert.
  7648. */
  7649. insertEnums(index: number, structures: ReadonlyArray<OptionalKind<EnumDeclarationStructure>>): EnumDeclaration[];
  7650. /** Gets the direct enum declaration children. */
  7651. getEnums(): EnumDeclaration[];
  7652. /**
  7653. * Gets an enum.
  7654. * @param name - Name of the enum.
  7655. */
  7656. getEnum(name: string): EnumDeclaration | undefined;
  7657. /**
  7658. * Gets an enum.
  7659. * @param findFunction - Function to use to find the enum.
  7660. */
  7661. getEnum(findFunction: (declaration: EnumDeclaration) => boolean): EnumDeclaration | undefined;
  7662. /**
  7663. * Gets an enum or throws if it doesn't exist.
  7664. * @param name - Name of the enum.
  7665. */
  7666. getEnumOrThrow(name: string): EnumDeclaration;
  7667. /**
  7668. * Gets an enum or throws if it doesn't exist.
  7669. * @param findFunction - Function to use to find the enum.
  7670. */
  7671. getEnumOrThrow(findFunction: (declaration: EnumDeclaration) => boolean): EnumDeclaration;
  7672. /**
  7673. * Adds a function declaration as a child.
  7674. * @param structure - Structure of the function declaration to add.
  7675. */
  7676. addFunction(structure: OptionalKind<FunctionDeclarationStructure>): FunctionDeclaration;
  7677. /**
  7678. * Adds function declarations as a child.
  7679. * @param structures - Structures of the function declarations to add.
  7680. */
  7681. addFunctions(structures: ReadonlyArray<OptionalKind<FunctionDeclarationStructure>>): FunctionDeclaration[];
  7682. /**
  7683. * Inserts an function declaration as a child.
  7684. * @param index - Child index to insert at.
  7685. * @param structure - Structure of the function declaration to insert.
  7686. */
  7687. insertFunction(index: number, structure: OptionalKind<FunctionDeclarationStructure>): FunctionDeclaration;
  7688. /**
  7689. * Inserts function declarations as a child.
  7690. * @param index - Child index to insert at.
  7691. * @param structures - Structures of the function declarations to insert.
  7692. */
  7693. insertFunctions(index: number, structures: ReadonlyArray<OptionalKind<FunctionDeclarationStructure>>): FunctionDeclaration[];
  7694. /** Gets the direct function declaration children. */
  7695. getFunctions(): FunctionDeclaration[];
  7696. /**
  7697. * Gets a function.
  7698. * @param name - Name of the function.
  7699. */
  7700. getFunction(name: string): FunctionDeclaration | undefined;
  7701. /**
  7702. * Gets a function.
  7703. * @param findFunction - Function to use to find the function.
  7704. */
  7705. getFunction(findFunction: (declaration: FunctionDeclaration) => boolean): FunctionDeclaration | undefined;
  7706. /**
  7707. * Gets a function or throws if it doesn't exist.
  7708. * @param name - Name of the function.
  7709. */
  7710. getFunctionOrThrow(name: string): FunctionDeclaration;
  7711. /**
  7712. * Gets a function or throws if it doesn't exist.
  7713. * @param findFunction - Function to use to find the function.
  7714. */
  7715. getFunctionOrThrow(findFunction: (declaration: FunctionDeclaration) => boolean): FunctionDeclaration;
  7716. /**
  7717. * Adds a interface declaration as a child.
  7718. * @param structure - Structure of the interface declaration to add.
  7719. */
  7720. addInterface(structure: OptionalKind<InterfaceDeclarationStructure>): InterfaceDeclaration;
  7721. /**
  7722. * Adds interface declarations as a child.
  7723. * @param structures - Structures of the interface declarations to add.
  7724. */
  7725. addInterfaces(structures: ReadonlyArray<OptionalKind<InterfaceDeclarationStructure>>): InterfaceDeclaration[];
  7726. /**
  7727. * Inserts an interface declaration as a child.
  7728. * @param index - Child index to insert at.
  7729. * @param structure - Structure of the interface declaration to insert.
  7730. */
  7731. insertInterface(index: number, structure: OptionalKind<InterfaceDeclarationStructure>): InterfaceDeclaration;
  7732. /**
  7733. * Inserts interface declarations as a child.
  7734. * @param index - Child index to insert at.
  7735. * @param structures - Structures of the interface declarations to insert.
  7736. */
  7737. insertInterfaces(index: number, structures: ReadonlyArray<OptionalKind<InterfaceDeclarationStructure>>): InterfaceDeclaration[];
  7738. /** Gets the direct interface declaration children. */
  7739. getInterfaces(): InterfaceDeclaration[];
  7740. /**
  7741. * Gets an interface.
  7742. * @param name - Name of the interface.
  7743. */
  7744. getInterface(name: string): InterfaceDeclaration | undefined;
  7745. /**
  7746. * Gets an interface.
  7747. * @param findFunction - Function to use to find the interface.
  7748. */
  7749. getInterface(findFunction: (declaration: InterfaceDeclaration) => boolean): InterfaceDeclaration | undefined;
  7750. /**
  7751. * Gets an interface or throws if it doesn't exist.
  7752. * @param name - Name of the interface.
  7753. */
  7754. getInterfaceOrThrow(name: string): InterfaceDeclaration;
  7755. /**
  7756. * Gets an interface or throws if it doesn't exist.
  7757. * @param findFunction - Function to use to find the interface.
  7758. */
  7759. getInterfaceOrThrow(findFunction: (declaration: InterfaceDeclaration) => boolean): InterfaceDeclaration;
  7760. /**
  7761. * Adds a module declaration as a child.
  7762. * @param structure - Structure of the namespace declaration to add.
  7763. */
  7764. addModule(structure: OptionalKind<ModuleDeclarationStructure>): ModuleDeclaration;
  7765. /**
  7766. * Adds module declarations as a child.
  7767. * @param structures - Structures of the namespace declarations to add.
  7768. */
  7769. addModules(structures: ReadonlyArray<OptionalKind<ModuleDeclarationStructure>>): ModuleDeclaration[];
  7770. /**
  7771. * Inserts a module declaration as a child.
  7772. * @param index - Child index to insert at.
  7773. * @param structure - Structure of the namespace declaration to insert.
  7774. */
  7775. insertModule(index: number, structure: OptionalKind<ModuleDeclarationStructure>): ModuleDeclaration;
  7776. /**
  7777. * Inserts module declarations as children.
  7778. * @param index - Child index to insert at.
  7779. * @param structures - Structures of the namespace declarations to insert.
  7780. */
  7781. insertModules(index: number, structures: ReadonlyArray<OptionalKind<ModuleDeclarationStructure>>): ModuleDeclaration[];
  7782. /** Gets the module declaration children. */
  7783. getModules(): ModuleDeclaration[];
  7784. /**
  7785. * Gets a module declaration child by name.
  7786. * @param name - Name of the namespace.
  7787. */
  7788. getModule(name: string): ModuleDeclaration | undefined;
  7789. /**
  7790. * Gets a module declaration child by condition.
  7791. * @param findFunction - Function to use to find the namespace.
  7792. */
  7793. getModule(findFunction: (declaration: ModuleDeclaration) => boolean): ModuleDeclaration | undefined;
  7794. /**
  7795. * Gets a module declaration child by name or throws if it doesn't exist.
  7796. * @param name - Name of the namespace.
  7797. */
  7798. getModuleOrThrow(name: string): ModuleDeclaration;
  7799. /**
  7800. * Gets a module declaration child by condition or throws if it doesn't exist.
  7801. * @param findFunction - Function to use to find the namespace.
  7802. */
  7803. getModuleOrThrow(findFunction: (declaration: ModuleDeclaration) => boolean): ModuleDeclaration;
  7804. /**
  7805. * Adds a type alias declaration as a child.
  7806. * @param structure - Structure of the type alias declaration to add.
  7807. */
  7808. addTypeAlias(structure: OptionalKind<TypeAliasDeclarationStructure>): TypeAliasDeclaration;
  7809. /**
  7810. * Adds type alias declarations as a child.
  7811. * @param structures - Structures of the type alias declarations to add.
  7812. */
  7813. addTypeAliases(structures: ReadonlyArray<OptionalKind<TypeAliasDeclarationStructure>>): TypeAliasDeclaration[];
  7814. /**
  7815. * Inserts an type alias declaration as a child.
  7816. * @param index - Child index to insert at.
  7817. * @param structure - Structure of the type alias declaration to insert.
  7818. */
  7819. insertTypeAlias(index: number, structure: OptionalKind<TypeAliasDeclarationStructure>): TypeAliasDeclaration;
  7820. /**
  7821. * Inserts type alias declarations as a child.
  7822. * @param index - Child index to insert at.
  7823. * @param structures - Structures of the type alias declarations to insert.
  7824. */
  7825. insertTypeAliases(index: number, structures: ReadonlyArray<OptionalKind<TypeAliasDeclarationStructure>>): TypeAliasDeclaration[];
  7826. /** Gets the direct type alias declaration children. */
  7827. getTypeAliases(): TypeAliasDeclaration[];
  7828. /**
  7829. * Gets a type alias.
  7830. * @param name - Name of the type alias.
  7831. */
  7832. getTypeAlias(name: string): TypeAliasDeclaration | undefined;
  7833. /**
  7834. * Gets a type alias.
  7835. * @param findFunction - Function to use to find the type alias.
  7836. */
  7837. getTypeAlias(findFunction: (declaration: TypeAliasDeclaration) => boolean): TypeAliasDeclaration | undefined;
  7838. /**
  7839. * Gets a type alias or throws if it doesn't exist.
  7840. * @param name - Name of the type alias.
  7841. */
  7842. getTypeAliasOrThrow(name: string): TypeAliasDeclaration;
  7843. /**
  7844. * Gets a type alias or throws if it doesn't exist.
  7845. * @param findFunction - Function to use to find the type alias.
  7846. */
  7847. getTypeAliasOrThrow(findFunction: (declaration: TypeAliasDeclaration) => boolean): TypeAliasDeclaration;
  7848. /**
  7849. * Adds a variable statement.
  7850. * @param structure - Structure of the variable statement.
  7851. */
  7852. addVariableStatement(structure: OptionalKind<VariableStatementStructure>): VariableStatement;
  7853. /**
  7854. * Adds variable statements.
  7855. * @param structures - Structures of the variable statements.
  7856. */
  7857. addVariableStatements(structures: ReadonlyArray<OptionalKind<VariableStatementStructure>>): VariableStatement[];
  7858. /**
  7859. * Inserts a variable statement.
  7860. * @param structure - Structure of the variable statement.
  7861. */
  7862. insertVariableStatement(index: number, structure: OptionalKind<VariableStatementStructure>): VariableStatement;
  7863. /**
  7864. * Inserts variable statements.
  7865. * @param structures - Structures of the variable statements.
  7866. */
  7867. insertVariableStatements(index: number, structures: ReadonlyArray<OptionalKind<VariableStatementStructure>>): VariableStatement[];
  7868. /** Gets the direct variable statement children. */
  7869. getVariableStatements(): VariableStatement[];
  7870. /**
  7871. * Gets a variable statement.
  7872. * @param name - Name of one of the variable statement's declarations.
  7873. */
  7874. getVariableStatement(name: string): VariableStatement | undefined;
  7875. /**
  7876. * Gets a variable statement.
  7877. * @param findFunction - Function to use to find the variable statement.
  7878. */
  7879. getVariableStatement(findFunction: (declaration: VariableStatement) => boolean): VariableStatement | undefined;
  7880. /**
  7881. * Gets a variable statement or throws if it doesn't exist.
  7882. * @param name - Name of one of the variable statement's declarations.
  7883. */
  7884. getVariableStatementOrThrow(name: string): VariableStatement;
  7885. /**
  7886. * Gets a variable statement or throws if it doesn't exist.
  7887. * @param findFunction - Function to use to find the variable statement.
  7888. */
  7889. getVariableStatementOrThrow(findFunction: (declaration: VariableStatement) => boolean): VariableStatement;
  7890. /**
  7891. * Gets all the variable declarations within the variable statement children.
  7892. * @remarks This does not return the variable declarations within for statements or for of statements.
  7893. */
  7894. getVariableDeclarations(): VariableDeclaration[];
  7895. /**
  7896. * Gets a variable declaration.
  7897. * @param name - Name of the variable declaration.
  7898. */
  7899. getVariableDeclaration(name: string): VariableDeclaration | undefined;
  7900. /**
  7901. * Gets a variable declaration.
  7902. * @param findFunction - Function to use to find the variable declaration.
  7903. */
  7904. getVariableDeclaration(findFunction: (declaration: VariableDeclaration) => boolean): VariableDeclaration | undefined;
  7905. /**
  7906. * Gets a variable declaration or throws if it doesn't exist.
  7907. * @param name - Name of the variable declaration.
  7908. */
  7909. getVariableDeclarationOrThrow(name: string): VariableDeclaration;
  7910. /**
  7911. * Gets a variable declaration or throws if it doesn't exist.
  7912. * @param findFunction - Function to use to find the variable declaration.
  7913. */
  7914. getVariableDeclarationOrThrow(findFunction: (declaration: VariableDeclaration) => boolean): VariableDeclaration;
  7915. }
  7916. type StatementedNodeExtensionType = Node<ts.SourceFile | ts.FunctionDeclaration | ts.ModuleDeclaration | ts.FunctionLikeDeclaration | ts.CaseClause | ts.DefaultClause | ts.ModuleBlock>;
  7917. export interface KindToNodeMappingsWithCommentStatements extends ImplementedKindToNodeMappings {
  7918. [kind: number]: Node;
  7919. [SyntaxKind.SingleLineCommentTrivia]: CommentStatement;
  7920. [SyntaxKind.MultiLineCommentTrivia]: CommentStatement;
  7921. }
  7922. declare const SwitchStatementBase: Constructor<ExpressionedNode> & typeof Statement;
  7923. export declare class SwitchStatement extends SwitchStatementBase<ts.SwitchStatement> {
  7924. /** Gets this switch statement's case block. */
  7925. getCaseBlock(): CaseBlock;
  7926. /** Gets the switch statement's case block's clauses. */
  7927. getClauses(): CaseOrDefaultClause[];
  7928. /**
  7929. * Removes the specified clause based on the provided index.
  7930. * @param index - Index.
  7931. */
  7932. removeClause(index: number): CaseBlock;
  7933. /**
  7934. * Removes the specified clauses based on the provided index range.
  7935. * @param indexRange - Index range.
  7936. */
  7937. removeClauses(indexRange: [number, number]): CaseBlock;
  7938. /** @inheritdoc **/
  7939. getParent(): NodeParentType<ts.SwitchStatement>;
  7940. /** @inheritdoc **/
  7941. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.SwitchStatement>>;
  7942. }
  7943. declare const ThrowStatementBase: Constructor<ExpressionedNode> & typeof Statement;
  7944. export declare class ThrowStatement extends ThrowStatementBase<ts.ThrowStatement> {
  7945. /** @inheritdoc **/
  7946. getParent(): NodeParentType<ts.ThrowStatement>;
  7947. /** @inheritdoc **/
  7948. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ThrowStatement>>;
  7949. }
  7950. declare const TryStatementBase: typeof Statement;
  7951. export declare class TryStatement extends TryStatementBase<ts.TryStatement> {
  7952. /** Gets this try statement's try block. */
  7953. getTryBlock(): Block;
  7954. /** Gets this try statement's catch clause or undefined if none exists. */
  7955. getCatchClause(): CatchClause | undefined;
  7956. /** Gets this try statement's catch clause or throws if none exists. */
  7957. getCatchClauseOrThrow(message?: string | (() => string)): CatchClause;
  7958. /** Gets this try statement's finally block or undefined if none exists. */
  7959. getFinallyBlock(): Block | undefined;
  7960. /** Gets this try statement's finally block or throws if none exists. */
  7961. getFinallyBlockOrThrow(message?: string | (() => string)): Block;
  7962. /** @inheritdoc **/
  7963. getParent(): NodeParentType<ts.TryStatement>;
  7964. /** @inheritdoc **/
  7965. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TryStatement>>;
  7966. }
  7967. declare const VariableStatementBase: Constructor<ModuleChildableNode> & Constructor<JSDocableNode> & Constructor<AmbientableNode> & Constructor<ExportableNode> & Constructor<ModifierableNode> & typeof Statement;
  7968. export declare class VariableStatement extends VariableStatementBase<ts.VariableStatement> {
  7969. /** Get variable declaration list. */
  7970. getDeclarationList(): VariableDeclarationList;
  7971. /** Get the variable declarations. */
  7972. getDeclarations(): VariableDeclaration[];
  7973. /** Gets the variable declaration kind. */
  7974. getDeclarationKind(): VariableDeclarationKind;
  7975. /** Gets the variable declaration kind keywords. */
  7976. getDeclarationKindKeywords(): Node<ts.Node>[];
  7977. /**
  7978. * Sets the variable declaration kind.
  7979. * @param type - Type to set.
  7980. */
  7981. setDeclarationKind(type: VariableDeclarationKind): VariableDeclarationList;
  7982. /**
  7983. * Add a variable declaration to the statement.
  7984. * @param structure - Structure representing the variable declaration to add.
  7985. */
  7986. addDeclaration(structure: OptionalKind<VariableDeclarationStructure>): VariableDeclaration;
  7987. /**
  7988. * Adds variable declarations to the statement.
  7989. * @param structures - Structures representing the variable declarations to add.
  7990. */
  7991. addDeclarations(structures: ReadonlyArray<OptionalKind<VariableDeclarationStructure>>): VariableDeclaration[];
  7992. /**
  7993. * Inserts a variable declaration at the specified index within the statement.
  7994. * @param index - Child index to insert at.
  7995. * @param structure - Structure representing the variable declaration to insert.
  7996. */
  7997. insertDeclaration(index: number, structure: OptionalKind<VariableDeclarationStructure>): VariableDeclaration;
  7998. /**
  7999. * Inserts variable declarations at the specified index within the statement.
  8000. * @param index - Child index to insert at.
  8001. * @param structures - Structures representing the variable declarations to insert.
  8002. */
  8003. insertDeclarations(index: number, structures: ReadonlyArray<OptionalKind<VariableDeclarationStructure>>): VariableDeclaration[];
  8004. /**
  8005. * Sets the node from a structure.
  8006. * @param structure - Structure to set the node with.
  8007. */
  8008. set(structure: Partial<VariableStatementStructure>): this;
  8009. /** Gets the structure equivalent to this node. */
  8010. getStructure(): VariableStatementStructure;
  8011. /** @inheritdoc **/
  8012. getParent(): NodeParentType<ts.VariableStatement>;
  8013. /** @inheritdoc **/
  8014. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.VariableStatement>>;
  8015. }
  8016. declare const WhileStatementBase: Constructor<ExpressionedNode> & typeof IterationStatement;
  8017. export declare class WhileStatement extends WhileStatementBase<ts.WhileStatement> {
  8018. /** @inheritdoc **/
  8019. getParent(): NodeParentType<ts.WhileStatement>;
  8020. /** @inheritdoc **/
  8021. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.WhileStatement>>;
  8022. }
  8023. declare const WithStatementBase: Constructor<ExpressionedNode> & typeof Statement;
  8024. export declare class WithStatement extends WithStatementBase<ts.WithStatement> {
  8025. /** Gets this with statement's statement. */
  8026. getStatement(): Statement;
  8027. /** @inheritdoc **/
  8028. getParent(): NodeParentType<ts.WithStatement>;
  8029. /** @inheritdoc **/
  8030. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.WithStatement>>;
  8031. }
  8032. export declare class ArrayTypeNode extends TypeNode<ts.ArrayTypeNode> {
  8033. /** Gets the array type node's element type node. */
  8034. getElementTypeNode(): TypeNode;
  8035. /** @inheritdoc **/
  8036. getParent(): NodeParentType<ts.ArrayTypeNode>;
  8037. /** @inheritdoc **/
  8038. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ArrayTypeNode>>;
  8039. }
  8040. export declare class ConditionalTypeNode extends TypeNode<ts.ConditionalTypeNode> {
  8041. /**
  8042. * Gets the conditional type node's check type.
  8043. *
  8044. * Ex. In `CheckType extends ExtendsType ? TrueType : FalseType` returns `CheckType`.
  8045. */
  8046. getCheckType(): TypeNode<ts.TypeNode>;
  8047. /**
  8048. * Gets the conditional type node's extends type.
  8049. *
  8050. * Ex. In `CheckType extends ExtendsType ? TrueType : FalseType` returns `ExtendsType`.
  8051. */
  8052. getExtendsType(): TypeNode<ts.TypeNode>;
  8053. /**
  8054. * Gets the conditional type node's true type.
  8055. *
  8056. * Ex. In `CheckType extends ExtendsType ? TrueType : FalseType` returns `TrueType`.
  8057. */
  8058. getTrueType(): TypeNode<ts.TypeNode>;
  8059. /**
  8060. * Gets the conditional type node's false type.
  8061. *
  8062. * Ex. In `CheckType extends ExtendsType ? TrueType : FalseType` returns `FalseType`.
  8063. */
  8064. getFalseType(): TypeNode<ts.TypeNode>;
  8065. /** @inheritdoc **/
  8066. getParent(): NodeParentType<ts.ConditionalTypeNode>;
  8067. /** @inheritdoc **/
  8068. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ConditionalTypeNode>>;
  8069. }
  8070. declare const ConstructorTypeNodeBase: Constructor<AbstractableNode> & Constructor<ModifierableNode> & typeof FunctionOrConstructorTypeNodeBase;
  8071. export declare class ConstructorTypeNode extends ConstructorTypeNodeBase<ts.ConstructorTypeNode> {
  8072. /** @inheritdoc **/
  8073. getParent(): NodeParentType<ts.ConstructorTypeNode>;
  8074. /** @inheritdoc **/
  8075. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ConstructorTypeNode>>;
  8076. }
  8077. declare const ExpressionWithTypeArgumentsBase: Constructor<LeftHandSideExpressionedNode> & typeof NodeWithTypeArguments;
  8078. export declare class ExpressionWithTypeArguments extends ExpressionWithTypeArgumentsBase<ts.ExpressionWithTypeArguments> {
  8079. /** @inheritdoc **/
  8080. getParent(): NodeParentType<ts.ExpressionWithTypeArguments>;
  8081. /** @inheritdoc **/
  8082. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ExpressionWithTypeArguments>>;
  8083. }
  8084. declare const FunctionOrConstructorTypeNodeBaseBase: Constructor<SignaturedDeclaration> & typeof TypeNode;
  8085. export declare class FunctionOrConstructorTypeNodeBase<T extends ts.FunctionOrConstructorTypeNode = ts.FunctionOrConstructorTypeNode> extends FunctionOrConstructorTypeNodeBaseBase<T> {
  8086. }
  8087. declare const FunctionTypeNodeBase: Constructor<TypeParameteredNode> & typeof FunctionOrConstructorTypeNodeBase;
  8088. export declare class FunctionTypeNode extends FunctionTypeNodeBase<ts.FunctionTypeNode> {
  8089. /** @inheritdoc **/
  8090. getParent(): NodeParentType<ts.FunctionTypeNode>;
  8091. /** @inheritdoc **/
  8092. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.FunctionTypeNode>>;
  8093. }
  8094. export declare class ImportTypeNode extends NodeWithTypeArguments<ts.ImportTypeNode> {
  8095. /**
  8096. * Sets the argument text.
  8097. * @param text - Text of the argument.
  8098. */
  8099. setArgument(text: string): this;
  8100. /** Gets the argument passed into the import type. */
  8101. getArgument(): TypeNode;
  8102. /**
  8103. * Sets the qualifier text.
  8104. * @param text - Text.
  8105. */
  8106. setQualifier(text: string): this;
  8107. /** Gets the qualifier of the import type if it exists or throws */
  8108. getQualifierOrThrow(message?: string | (() => string)): EntityName;
  8109. /** Gets the qualifier of the import type if it exists or returns undefined. */
  8110. getQualifier(): EntityName | undefined;
  8111. /** Gets the import attributes container if it exists. */
  8112. getAttributes(): ImportAttributes | undefined;
  8113. /** Gets the import attributes container if it exists or throws. */
  8114. getAttributesOrThrow(message?: string | (() => string)): ImportAttributes;
  8115. /** @inheritdoc **/
  8116. getParent(): NodeParentType<ts.ImportTypeNode>;
  8117. /** @inheritdoc **/
  8118. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ImportTypeNode>>;
  8119. }
  8120. export declare class IndexedAccessTypeNode extends TypeNode<ts.IndexedAccessTypeNode> {
  8121. /**
  8122. * Gets the indexed access type node's object type node.
  8123. *
  8124. * This is `MyObjectType` in `MyObjectType["myIndex"]`.
  8125. */
  8126. getObjectTypeNode(): TypeNode;
  8127. /**
  8128. * Gets the indexed access type node's index type node.
  8129. *
  8130. * This is `"myIndex"` in `MyObjectType["myIndex"]`.
  8131. */
  8132. getIndexTypeNode(): TypeNode;
  8133. /** @inheritdoc **/
  8134. getParent(): NodeParentType<ts.IndexedAccessTypeNode>;
  8135. /** @inheritdoc **/
  8136. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.IndexedAccessTypeNode>>;
  8137. }
  8138. export declare class InferTypeNode extends TypeNode<ts.InferTypeNode> {
  8139. /**
  8140. * Gets the infer type node's type parameter.
  8141. *
  8142. * Ex. In `infer R` returns `R`.
  8143. */
  8144. getTypeParameter(): TypeParameterDeclaration;
  8145. /** @inheritdoc **/
  8146. getParent(): NodeParentType<ts.InferTypeNode>;
  8147. /** @inheritdoc **/
  8148. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.InferTypeNode>>;
  8149. }
  8150. export declare class IntersectionTypeNode extends TypeNode<ts.IntersectionTypeNode> {
  8151. /** Gets the intersection type nodes. */
  8152. getTypeNodes(): TypeNode[];
  8153. /** @inheritdoc **/
  8154. getParent(): NodeParentType<ts.IntersectionTypeNode>;
  8155. /** @inheritdoc **/
  8156. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.IntersectionTypeNode>>;
  8157. }
  8158. export declare class LiteralTypeNode extends TypeNode<ts.LiteralTypeNode> {
  8159. /** Gets the literal type node's literal. */
  8160. getLiteral(): NullLiteral | BooleanLiteral | LiteralExpression | PrefixUnaryExpression;
  8161. /** @inheritdoc **/
  8162. getParent(): NodeParentType<ts.LiteralTypeNode>;
  8163. /** @inheritdoc **/
  8164. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.LiteralTypeNode>>;
  8165. }
  8166. export declare class MappedTypeNode extends TypeNode<ts.MappedTypeNode> {
  8167. /** Gets the mapped type node's name type node if any. */
  8168. getNameTypeNode(): TypeNode | undefined;
  8169. /** Gets the mapped type node's name type node or throws if it doesn't exist. */
  8170. getNameTypeNodeOrThrow(message?: string | (() => string)): TypeNode;
  8171. /** Gets the mapped type's readonly token. */
  8172. getReadonlyToken(): Node<ts.ReadonlyKeyword> | Node<ts.PlusToken> | Node<ts.MinusToken> | undefined;
  8173. /** Gets the mapped type's readonly token or throws if not exist. */
  8174. getReadonlyTokenOrThrow(message?: string | (() => string)): Node<ts.ReadonlyKeyword> | Node<ts.PlusToken> | Node<ts.MinusToken>;
  8175. /** Gets the mapped type's question token. */
  8176. getQuestionToken(): Node<ts.QuestionToken> | Node<ts.PlusToken> | Node<ts.MinusToken> | undefined;
  8177. /** Gets the mapped type's question token or throws if not exist. */
  8178. getQuestionTokenOrThrow(message?: string | (() => string)): Node<ts.QuestionToken> | Node<ts.PlusToken> | Node<ts.MinusToken>;
  8179. /** Gets the mapped type node's type parameter. */
  8180. getTypeParameter(): TypeParameterDeclaration;
  8181. /** Gets the mapped type node's type node if it exists or returns undefined when not. */
  8182. getTypeNode(): TypeNode | undefined;
  8183. /** Gets the mapped type node's type node if it exists or throws when undefined. */
  8184. getTypeNodeOrThrow(message?: string | (() => string)): TypeNode;
  8185. /** @inheritdoc **/
  8186. getParent(): NodeParentType<ts.MappedTypeNode>;
  8187. /** @inheritdoc **/
  8188. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.MappedTypeNode>>;
  8189. }
  8190. declare const NamedTupleMemberBase: Constructor<TypedNode> & Constructor<QuestionTokenableNode> & Constructor<DotDotDotTokenableNode> & Constructor<JSDocableNode> & Constructor<NamedNode> & typeof TypeNode;
  8191. /**
  8192. * A named/labeled tuple element.
  8193. *
  8194. * Ex. `start: number` in `type Range = [start: number, end: number]`
  8195. */
  8196. export declare class NamedTupleMember extends NamedTupleMemberBase<ts.NamedTupleMember> {
  8197. /** Gets the named tuple type's type. */
  8198. getTypeNode(): TypeNode<ts.TypeNode>;
  8199. /** Throws. This is not supported for NamedTupleMember. */
  8200. removeType(): never;
  8201. /** @inheritdoc **/
  8202. getParent(): NodeParentType<ts.NamedTupleMember>;
  8203. /** @inheritdoc **/
  8204. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.NamedTupleMember>>;
  8205. }
  8206. export declare class ParenthesizedTypeNode extends TypeNode<ts.ParenthesizedTypeNode> {
  8207. /** Gets the node within the parentheses. */
  8208. getTypeNode(): TypeNode;
  8209. /**
  8210. * Sets the type within the parentheses.
  8211. * @param textOrWriterFunction - Text or writer function to set the type with.
  8212. */
  8213. setType(textOrWriterFunction: string | WriterFunction): this;
  8214. /** @inheritdoc **/
  8215. getParent(): NodeParentType<ts.ParenthesizedTypeNode>;
  8216. /** @inheritdoc **/
  8217. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ParenthesizedTypeNode>>;
  8218. }
  8219. export declare class RestTypeNode extends TypeNode<ts.RestTypeNode> {
  8220. /** Gets the rest type node's inner type. */
  8221. getTypeNode(): TypeNode<ts.TypeNode>;
  8222. /** @inheritdoc **/
  8223. getParent(): NodeParentType<ts.RestTypeNode>;
  8224. /** @inheritdoc **/
  8225. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.RestTypeNode>>;
  8226. }
  8227. export declare class TemplateLiteralTypeNode extends TypeNode<ts.TemplateLiteralTypeNode> {
  8228. /** Gets the template head. */
  8229. getHead(): TemplateHead;
  8230. /** Gets the template spans. */
  8231. getTemplateSpans(): TypeNode<ts.TypeNode>[];
  8232. /**
  8233. * Sets the literal value.
  8234. *
  8235. * Note: This could possibly replace the node if you remove all the tagged templates.
  8236. * @param value - Value to set.
  8237. * @returns The new node if the kind changed; the current node otherwise.
  8238. */
  8239. setLiteralValue(value: string): Node<ts.Node>;
  8240. /** @inheritdoc **/
  8241. getParent(): NodeParentType<ts.TemplateLiteralTypeNode>;
  8242. /** @inheritdoc **/
  8243. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TemplateLiteralTypeNode>>;
  8244. }
  8245. export declare class ThisTypeNode extends TypeNode<ts.ThisTypeNode> {
  8246. /** @inheritdoc **/
  8247. getParent(): NodeParentType<ts.ThisTypeNode>;
  8248. /** @inheritdoc **/
  8249. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.ThisTypeNode>>;
  8250. }
  8251. export declare class TupleTypeNode extends TypeNode<ts.TupleTypeNode> {
  8252. /** Gets the tuple element type nodes. */
  8253. getElements(): (TypeNode<ts.TypeNode> | NamedTupleMember)[];
  8254. /** @inheritdoc **/
  8255. getParent(): NodeParentType<ts.TupleTypeNode>;
  8256. /** @inheritdoc **/
  8257. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TupleTypeNode>>;
  8258. }
  8259. declare const TypeAliasDeclarationBase: Constructor<TypeParameteredNode> & Constructor<TypedNode> & Constructor<JSDocableNode> & Constructor<AmbientableNode> & Constructor<ExportableNode> & Constructor<ModifierableNode> & Constructor<NamedNode> & typeof Statement;
  8260. export declare class TypeAliasDeclaration extends TypeAliasDeclarationBase<ts.TypeAliasDeclaration> {
  8261. /**
  8262. * Sets the node from a structure.
  8263. * @param structure - Structure to set the node with.
  8264. */
  8265. set(structure: Partial<TypeAliasDeclarationStructure>): this;
  8266. /** Gets the structure equivalent to this node. */
  8267. getStructure(): TypeAliasDeclarationStructure;
  8268. /** @inheritdoc **/
  8269. getParent(): NodeParentType<ts.TypeAliasDeclaration>;
  8270. /** @inheritdoc **/
  8271. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeAliasDeclaration>>;
  8272. }
  8273. declare const TypeLiteralNodeBase: Constructor<TypeElementMemberedNode> & typeof TypeNode;
  8274. export declare class TypeLiteralNode extends TypeLiteralNodeBase<ts.TypeLiteralNode> {
  8275. /** @inheritdoc **/
  8276. getParent(): NodeParentType<ts.TypeLiteralNode>;
  8277. /** @inheritdoc **/
  8278. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeLiteralNode>>;
  8279. }
  8280. export declare class TypeNode<T extends ts.TypeNode = ts.TypeNode> extends Node<T> {
  8281. }
  8282. declare const NodeWithTypeArgumentsBase: Constructor<TypeArgumentedNode> & typeof TypeNode;
  8283. export declare class NodeWithTypeArguments<T extends ts.NodeWithTypeArguments = ts.NodeWithTypeArguments> extends NodeWithTypeArgumentsBase<T> {
  8284. }
  8285. export declare class TypeOperatorTypeNode extends TypeNode<ts.TypeOperatorNode> {
  8286. /** Gets the operator of the type node. */
  8287. getOperator(): SyntaxKind.KeyOfKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.UniqueKeyword;
  8288. /** Gets the node within the type operator. */
  8289. getTypeNode(): TypeNode;
  8290. /** @inheritdoc **/
  8291. getParent(): NodeParentType<ts.TypeOperatorNode>;
  8292. /** @inheritdoc **/
  8293. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeOperatorNode>>;
  8294. }
  8295. /** Variance of the type parameter. */
  8296. export declare enum TypeParameterVariance {
  8297. /** Variance is not specified. */
  8298. None = 0,
  8299. /** Contravariant. */
  8300. In = 1,
  8301. /** Covariant. */
  8302. Out = 2,
  8303. /** Invariant. */
  8304. InOut = 3
  8305. }
  8306. declare const TypeParameterDeclarationBase: Constructor<ModifierableNode> & Constructor<NamedNode> & typeof Node;
  8307. export declare class TypeParameterDeclaration extends TypeParameterDeclarationBase<ts.TypeParameterDeclaration> {
  8308. /** Gets if this is a const type parameter. */
  8309. isConst(): boolean;
  8310. /** Sets if this is a const type parameter or not. */
  8311. setIsConst(value: boolean): this;
  8312. /** Gets the constraint of the type parameter. */
  8313. getConstraint(): TypeNode | undefined;
  8314. /** Gets the constraint of the type parameter or throws if it doesn't exist. */
  8315. getConstraintOrThrow(message?: string | (() => string)): TypeNode<ts.TypeNode>;
  8316. /**
  8317. * Sets the type parameter constraint.
  8318. * @param text - Text to set as the constraint.
  8319. */
  8320. setConstraint(text: string | WriterFunction): this;
  8321. /** Removes the constraint type node. */
  8322. removeConstraint(): this;
  8323. /** Gets the default node of the type parameter. */
  8324. getDefault(): TypeNode | undefined;
  8325. /** Gets the default node of the type parameter or throws if it doesn't exist. */
  8326. getDefaultOrThrow(message?: string | (() => string)): TypeNode<ts.TypeNode>;
  8327. /**
  8328. * Sets the type parameter default type node.
  8329. * @param text - Text to set as the default type node.
  8330. */
  8331. setDefault(text: string | WriterFunction): this;
  8332. /** Removes the default type node. */
  8333. removeDefault(): this;
  8334. /** Set the variance of the type parameter. */
  8335. setVariance(variance: TypeParameterVariance): this;
  8336. /** Gets the variance of the type parameter. */
  8337. getVariance(): TypeParameterVariance;
  8338. /** Removes this type parameter. */
  8339. remove(): void;
  8340. /**
  8341. * Sets the node from a structure.
  8342. * @param structure - Structure to set the node with.
  8343. */
  8344. set(structure: Partial<TypeParameterDeclarationStructure>): this;
  8345. /** Gets the structure equivalent to this node. */
  8346. getStructure(): TypeParameterDeclarationStructure;
  8347. /** @inheritdoc **/
  8348. getParent(): NodeParentType<ts.TypeParameterDeclaration>;
  8349. /** @inheritdoc **/
  8350. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeParameterDeclaration>>;
  8351. }
  8352. /**
  8353. * A type predicate node which says the specified parameter name is a specific type if the function returns true.
  8354. *
  8355. * Examples:
  8356. * * `param is string` in `declare function isString(param: unknown): param is string;`.
  8357. * * `asserts condition` in `declare function assert(condition: any): asserts condition;`.
  8358. */
  8359. export declare class TypePredicateNode extends TypeNode<ts.TypePredicateNode> {
  8360. /** Gets the parameter name node */
  8361. getParameterNameNode(): Identifier | ThisTypeNode;
  8362. /** Gets if the type predicate has an `asserts` modifier (ex. `asserts condition`). */
  8363. hasAssertsModifier(): boolean;
  8364. /** Gets the asserts modifier if it exists. */
  8365. getAssertsModifier(): Node<ts.AssertsKeyword> | undefined;
  8366. /** Gets the asserts modifier if it exists or throws otherwise. */
  8367. getAssertsModifierOrThrow(message?: string | (() => string)): Node<ts.AssertsKeyword>;
  8368. /** Gets the type name if it exists or returns undefined when it asserts a condition. */
  8369. getTypeNode(): TypeNode | undefined;
  8370. /** Gets the type name if it exists or throws when it asserts a condition. */
  8371. getTypeNodeOrThrow(message?: string | (() => string)): TypeNode;
  8372. /** @inheritdoc **/
  8373. getParent(): NodeParentType<ts.TypePredicateNode>;
  8374. /** @inheritdoc **/
  8375. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypePredicateNode>>;
  8376. }
  8377. export declare class TypeQueryNode extends NodeWithTypeArguments<ts.TypeQueryNode> {
  8378. /** Gets the expression name. */
  8379. getExprName(): EntityName;
  8380. /** @inheritdoc **/
  8381. getParent(): NodeParentType<ts.TypeQueryNode>;
  8382. /** @inheritdoc **/
  8383. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeQueryNode>>;
  8384. }
  8385. export declare class TypeReferenceNode extends NodeWithTypeArguments<ts.TypeReferenceNode> {
  8386. /** Gets the type name. */
  8387. getTypeName(): EntityName;
  8388. /** @inheritdoc **/
  8389. getParent(): NodeParentType<ts.TypeReferenceNode>;
  8390. /** @inheritdoc **/
  8391. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.TypeReferenceNode>>;
  8392. }
  8393. export declare class UnionTypeNode extends TypeNode<ts.UnionTypeNode> {
  8394. /** Gets the union type nodes. */
  8395. getTypeNodes(): TypeNode[];
  8396. /** @inheritdoc **/
  8397. getParent(): NodeParentType<ts.UnionTypeNode>;
  8398. /** @inheritdoc **/
  8399. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.UnionTypeNode>>;
  8400. }
  8401. declare const VariableDeclarationBase: Constructor<ExportGetableNode> & Constructor<ExclamationTokenableNode> & Constructor<TypedNode> & Constructor<InitializerExpressionableNode> & Constructor<BindingNamedNode> & typeof Node;
  8402. export declare class VariableDeclaration extends VariableDeclarationBase<ts.VariableDeclaration> {
  8403. /** Removes this variable declaration. */
  8404. remove(): void;
  8405. /** Gets the corresponding variable statement if it exists. Throws for variable declarations in for statements. */
  8406. getVariableStatementOrThrow(message?: string | (() => string)): VariableStatement;
  8407. /** Gets the corresponding variable statement if it exists. Returns undefined for variable declarations in for statements. */
  8408. getVariableStatement(): VariableStatement | undefined;
  8409. /**
  8410. * Sets the node from a structure.
  8411. * @param structure - Structure to set the node with.
  8412. */
  8413. set(structure: Partial<VariableDeclarationStructure>): this;
  8414. /** Gets the structure equivalent to this node. */
  8415. getStructure(): VariableDeclarationStructure;
  8416. /** @inheritdoc **/
  8417. getParent(): NodeParentType<ts.VariableDeclaration>;
  8418. /** @inheritdoc **/
  8419. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.VariableDeclaration>>;
  8420. }
  8421. export declare enum VariableDeclarationKind {
  8422. Var = "var",
  8423. Let = "let",
  8424. Const = "const",
  8425. AwaitUsing = "await using",
  8426. Using = "using"
  8427. }
  8428. declare const VariableDeclarationListBase: Constructor<ModifierableNode> & typeof Node;
  8429. export declare class VariableDeclarationList extends VariableDeclarationListBase<ts.VariableDeclarationList> {
  8430. /** Get the variable declarations. */
  8431. getDeclarations(): VariableDeclaration[];
  8432. /** Gets the variable declaration kind. */
  8433. getDeclarationKind(): VariableDeclarationKind;
  8434. /** Gets the variable declaration kind keywords. */
  8435. getDeclarationKindKeywords(): Node[];
  8436. /**
  8437. * Sets the variable declaration kind.
  8438. * @param type - Type to set.
  8439. */
  8440. setDeclarationKind(type: VariableDeclarationKind): this;
  8441. /**
  8442. * Add a variable declaration to the statement.
  8443. * @param structure - Structure representing the variable declaration to add.
  8444. */
  8445. addDeclaration(structure: OptionalKind<VariableDeclarationStructure>): VariableDeclaration;
  8446. /**
  8447. * Adds variable declarations to the statement.
  8448. * @param structures - Structures representing the variable declarations to add.
  8449. */
  8450. addDeclarations(structures: ReadonlyArray<OptionalKind<VariableDeclarationStructure>>): VariableDeclaration[];
  8451. /**
  8452. * Inserts a variable declaration at the specified index within the statement.
  8453. * @param index - Child index to insert at.
  8454. * @param structure - Structure representing the variable declaration to insert.
  8455. */
  8456. insertDeclaration(index: number, structure: OptionalKind<VariableDeclarationStructure>): VariableDeclaration;
  8457. /**
  8458. * Inserts variable declarations at the specified index within the statement.
  8459. * @param index - Child index to insert at.
  8460. * @param structures - Structures representing the variable declarations to insert.
  8461. */
  8462. insertDeclarations(index: number, structures: ReadonlyArray<OptionalKind<VariableDeclarationStructure>>): VariableDeclaration[];
  8463. /** @inheritdoc **/
  8464. getParent(): NodeParentType<ts.VariableDeclarationList>;
  8465. /** @inheritdoc **/
  8466. getParentOrThrow(message?: string | (() => string)): NonNullable<NodeParentType<ts.VariableDeclarationList>>;
  8467. }
  8468. export declare class Signature {
  8469. #private;
  8470. private constructor();
  8471. /** Gets the underlying compiler signature. */
  8472. get compilerSignature(): ts.Signature;
  8473. /** Gets the type parameters. */
  8474. getTypeParameters(): TypeParameter[];
  8475. /** Gets the parameters. */
  8476. getParameters(): Symbol[];
  8477. /** Gets the signature return type. */
  8478. getReturnType(): Type;
  8479. /** Get the documentation comments. */
  8480. getDocumentationComments(): SymbolDisplayPart[];
  8481. /** Gets the JS doc tags. */
  8482. getJsDocTags(): JSDocTagInfo[];
  8483. /** Gets the signature's declaration. */
  8484. getDeclaration(): MethodSignature | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | FunctionExpression | ArrowFunction | FunctionDeclaration | JSDocFunctionType;
  8485. }
  8486. export declare class Symbol {
  8487. #private;
  8488. private constructor();
  8489. /** Gets the underlying compiler symbol. */
  8490. get compilerSymbol(): ts.Symbol;
  8491. /** Gets the symbol name. */
  8492. getName(): string;
  8493. /** Gets the escaped name. */
  8494. getEscapedName(): string;
  8495. /** Gets the aliased symbol or throws if it doesn't exist. */
  8496. getAliasedSymbolOrThrow(message?: string | (() => string)): Symbol;
  8497. /** Follows a single alias to get the immediately aliased symbol or returns undefined if it doesn't exist. */
  8498. getImmediatelyAliasedSymbol(): Symbol | undefined;
  8499. /** Follows a single alias to get the immediately aliased symbol or throws if it doesn't exist. */
  8500. getImmediatelyAliasedSymbolOrThrow(message?: string | (() => string)): Symbol;
  8501. /** Gets the aliased symbol or returns undefined if it doesn't exist. */
  8502. getAliasedSymbol(): Symbol | undefined;
  8503. /**
  8504. * Gets the export symbol of the symbol if its a local symbol with a corresponding export symbol. Otherwise returns the current symbol.
  8505. *
  8506. * The following is from the compiler API documentation:
  8507. *
  8508. * For example, at `export type T = number;`:
  8509. * - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`.
  8510. * - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol.
  8511. * - Calling `getExportSymbol` on that local symbol will return the exported symbol.
  8512. */
  8513. getExportSymbol(): Symbol;
  8514. /** Gets if the symbol is an alias. */
  8515. isAlias(): boolean;
  8516. /** Gets if the symbol is optional. */
  8517. isOptional(): boolean;
  8518. /** Gets the symbol flags. */
  8519. getFlags(): SymbolFlags;
  8520. /**
  8521. * Gets if the symbol has the specified flags.
  8522. * @param flags - Flags to check if the symbol has.
  8523. */
  8524. hasFlags(flags: SymbolFlags): boolean;
  8525. /** Gets the value declaration of a symbol or throws if it doesn't exist. */
  8526. getValueDeclarationOrThrow(message?: string | (() => string)): Node;
  8527. /** Gets the value declaration of the symbol or returns undefined if it doesn't exist. */
  8528. getValueDeclaration(): Node | undefined;
  8529. /** Gets the symbol declarations. */
  8530. getDeclarations(): Node[];
  8531. /**
  8532. * Gets the export of the symbol by the specified name or throws if not exists.
  8533. * @param name - Name of the export.
  8534. */
  8535. getExportOrThrow(name: string, message?: string | (() => string)): Symbol;
  8536. /**
  8537. * Gets the export of the symbol by the specified name or returns undefined if not exists.
  8538. * @param name - Name of the export.
  8539. */
  8540. getExport(name: string): Symbol | undefined;
  8541. /** Gets the exports from the symbol. */
  8542. getExports(): Symbol[];
  8543. /**
  8544. * Gets the global export of the symbol by the specified name or throws if not exists.
  8545. * @param name - Name of the global export.
  8546. */
  8547. getGlobalExportOrThrow(name: string, message?: string | (() => string)): Symbol;
  8548. /**
  8549. * Gets the global export of the symbol by the specified name or returns undefined if not exists.
  8550. * @param name - Name of the global export.
  8551. */
  8552. getGlobalExport(name: string): Symbol | undefined;
  8553. /** Gets the global exports from the symbol. */
  8554. getGlobalExports(): Symbol[];
  8555. /**
  8556. * Gets the member of the symbol by the specified name or throws if not exists.
  8557. * @param name - Name of the export.
  8558. */
  8559. getMemberOrThrow(name: string, message?: string | (() => string)): Symbol;
  8560. /**
  8561. * Gets the member of the symbol by the specified name or returns undefined if not exists.
  8562. * @param name - Name of the member.
  8563. */
  8564. getMember(name: string): Symbol | undefined;
  8565. /** Gets the members of the symbol */
  8566. getMembers(): Symbol[];
  8567. /** Gets the declared type of the symbol. */
  8568. getDeclaredType(): Type;
  8569. /**
  8570. * Gets the type of the symbol at a location.
  8571. * @param node - Location to get the type at for this symbol.
  8572. */
  8573. getTypeAtLocation(node: Node): Type<ts.Type>;
  8574. /** Gets the fully qualified name. */
  8575. getFullyQualifiedName(): string;
  8576. /** Gets the JS doc tag infos of the symbol. */
  8577. getJsDocTags(): JSDocTagInfo[];
  8578. }
  8579. export interface FormatCodeSettings extends ts.FormatCodeSettings {
  8580. ensureNewLineAtEndOfFile?: boolean;
  8581. }
  8582. /** Options for renaming a node. */
  8583. export interface RenameOptions {
  8584. /**
  8585. * Whether comments referencing this node should be renamed.
  8586. * @remarks False by default.
  8587. */
  8588. renameInComments?: boolean;
  8589. /**
  8590. * Whether strings referencing this node should be renamed.
  8591. * @remarks False by default.
  8592. */
  8593. renameInStrings?: boolean;
  8594. /**
  8595. * Whether to enable renaming shorthand property assignments, binding elements, and import & export specifiers without changing behaviour.
  8596. * @remarks Defaults to the `usePrefixAndSuffixTextForRename` manipulation setting.
  8597. * This setting is only available when using TypeScript 3.4+.
  8598. */
  8599. usePrefixAndSuffixText?: boolean;
  8600. }
  8601. /** User preferences for refactoring. */
  8602. export interface UserPreferences extends ts.UserPreferences {
  8603. }
  8604. export declare class LanguageService {
  8605. #private;
  8606. private constructor();
  8607. /** Gets the compiler language service. */
  8608. get compilerObject(): ts.LanguageService;
  8609. /** Gets the language service's program. */
  8610. getProgram(): Program;
  8611. /**
  8612. * Gets the definitions for the specified node.
  8613. * @param node - Node.
  8614. */
  8615. getDefinitions(node: Node): DefinitionInfo[];
  8616. /**
  8617. * Gets the definitions at the specified position.
  8618. * @param sourceFile - Source file.
  8619. * @param pos - Position.
  8620. */
  8621. getDefinitionsAtPosition(sourceFile: SourceFile, pos: number): DefinitionInfo[];
  8622. /**
  8623. * Gets the implementations for the specified node.
  8624. * @param node - Node.
  8625. */
  8626. getImplementations(node: Node): ImplementationLocation[];
  8627. /**
  8628. * Gets the implementations at the specified position.
  8629. * @param sourceFile - Source file.
  8630. * @param pos - Position.
  8631. */
  8632. getImplementationsAtPosition(sourceFile: SourceFile, pos: number): ImplementationLocation[];
  8633. /**
  8634. * Finds references based on the specified node.
  8635. * @param node - Node to find references for.
  8636. */
  8637. findReferences(node: Node): ReferencedSymbol[];
  8638. /**
  8639. * Finds the nodes that reference the definition(s) of the specified node.
  8640. * @param node - Node.
  8641. */
  8642. findReferencesAsNodes(node: Node): Node<ts.Node>[];
  8643. /**
  8644. * Finds references based on the specified position.
  8645. * @param sourceFile - Source file.
  8646. * @param pos - Position to find the reference at.
  8647. */
  8648. findReferencesAtPosition(sourceFile: SourceFile, pos: number): ReferencedSymbol[];
  8649. /**
  8650. * Find the rename locations for the specified node.
  8651. * @param node - Node to get the rename locations for.
  8652. * @param options - Options for renaming.
  8653. */
  8654. findRenameLocations(node: Node, options?: RenameOptions): RenameLocation[];
  8655. /**
  8656. * Gets the suggestion diagnostics.
  8657. * @param filePathOrSourceFile - The source file or file path to get suggestions for.
  8658. */
  8659. getSuggestionDiagnostics(filePathOrSourceFile: SourceFile | string): DiagnosticWithLocation[];
  8660. /**
  8661. * Gets the formatting edits for a range.
  8662. * @param filePath - File path.
  8663. * @param range - Position range.
  8664. * @param formatSettings - Format code settings.
  8665. */
  8666. getFormattingEditsForRange(filePath: string, range: [number, number], formatSettings: FormatCodeSettings): TextChange[];
  8667. /**
  8668. * Gets the formatting edits for a document.
  8669. * @param filePath - File path of the source file.
  8670. * @param formatSettings - Format code settings.
  8671. */
  8672. getFormattingEditsForDocument(filePath: string, formatSettings: FormatCodeSettings): TextChange[];
  8673. /**
  8674. * Gets the formatted text for a document.
  8675. * @param filePath - File path of the source file.
  8676. * @param formatSettings - Format code settings.
  8677. */
  8678. getFormattedDocumentText(filePath: string, formatSettings: FormatCodeSettings): string;
  8679. /**
  8680. * Gets the emit output of a source file.
  8681. * @param sourceFile - Source file.
  8682. * @param emitOnlyDtsFiles - Whether to only emit the d.ts files.
  8683. */
  8684. getEmitOutput(sourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitOutput;
  8685. /**
  8686. * Gets the emit output of a source file.
  8687. * @param filePath - File path.
  8688. * @param emitOnlyDtsFiles - Whether to only emit the d.ts files.
  8689. */
  8690. getEmitOutput(filePath: string, emitOnlyDtsFiles?: boolean): EmitOutput;
  8691. /**
  8692. * Gets the indentation at the specified position.
  8693. * @param sourceFile - Source file.
  8694. * @param position - Position.
  8695. * @param settings - Editor settings.
  8696. */
  8697. getIdentationAtPosition(sourceFile: SourceFile, position: number, settings?: EditorSettings): number;
  8698. /**
  8699. * Gets the indentation at the specified position.
  8700. * @param filePath - File path.
  8701. * @param position - Position.
  8702. * @param settings - Editor settings.
  8703. */
  8704. getIdentationAtPosition(filePath: string, position: number, settings?: EditorSettings): number;
  8705. /**
  8706. * Gets the file text changes for organizing the imports in a source file.
  8707. *
  8708. * @param sourceFile - Source file.
  8709. * @param formatSettings - Format code settings.
  8710. * @param userPreferences - User preferences for refactoring.
  8711. */
  8712. organizeImports(sourceFile: SourceFile, formatSettings?: FormatCodeSettings, userPreferences?: UserPreferences): FileTextChanges[];
  8713. /**
  8714. * Gets the file text changes for organizing the imports in a source file.
  8715. *
  8716. * @param filePath - File path of the source file.
  8717. * @param formatSettings - Format code settings.
  8718. * @param userPreferences - User preferences for refactoring.
  8719. */
  8720. organizeImports(filePath: string, formatSettings?: FormatCodeSettings, userPreferences?: UserPreferences): FileTextChanges[];
  8721. /**
  8722. * Gets the edit information for applying a refactor at a the provided position in a source file.
  8723. * @param filePathOrSourceFile - File path or source file to get the edits for.
  8724. * @param formatSettings - Fomat code settings.
  8725. * @param positionOrRange - Position in the source file where to apply given refactor.
  8726. * @param refactorName - Refactor name.
  8727. * @param actionName - Refactor action name.
  8728. * @param preferences - User preferences for refactoring.
  8729. */
  8730. getEditsForRefactor(filePathOrSourceFile: string | SourceFile, formatSettings: FormatCodeSettings, positionOrRange: number | {
  8731. getPos(): number;
  8732. getEnd(): number;
  8733. }, refactorName: string, actionName: string, preferences?: UserPreferences): RefactorEditInfo | undefined;
  8734. /**
  8735. * Gets file changes and actions to perform for the provided fixId.
  8736. * @param filePathOrSourceFile - File path or source file to get the combined code fixes for.
  8737. * @param fixId - Identifier for the code fix (ex. "fixMissingImport"). These ids are found in the `ts.codefix` namespace in the compiler api source.
  8738. * @param formatSettings - Format code settings.
  8739. * @param preferences - User preferences for refactoring.
  8740. */
  8741. getCombinedCodeFix(filePathOrSourceFile: string | SourceFile, fixId: {}, formatSettings?: FormatCodeSettings, preferences?: UserPreferences): CombinedCodeActions;
  8742. /**
  8743. * Gets the edit information for applying a code fix at the provided text range in a source file.
  8744. * @param filePathOrSourceFile - File path or source file to get the code fixes for.
  8745. * @param start - Start position of the text range to be fixed.
  8746. * @param end - End position of the text range to be fixed.
  8747. * @param errorCodes - One or more error codes associated with the code fixes to retrieve.
  8748. * @param formatOptions - Format code settings.
  8749. * @param preferences - User preferences for refactoring.
  8750. */
  8751. getCodeFixesAtPosition(filePathOrSourceFile: string | SourceFile, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions?: FormatCodeSettings, preferences?: UserPreferences): CodeFixAction[];
  8752. }
  8753. /** Options for emitting from a Program. */
  8754. export interface ProgramEmitOptions extends EmitOptions {
  8755. writeFile?: ts.WriteFileCallback;
  8756. }
  8757. /** Options for emitting. */
  8758. export interface EmitOptions extends EmitOptionsBase {
  8759. /** Optional source file to only emit. */
  8760. targetSourceFile?: SourceFile;
  8761. }
  8762. export interface EmitOptionsBase {
  8763. /** Whether only .d.ts files should be emitted. */
  8764. emitOnlyDtsFiles?: boolean;
  8765. /** Transformers to act on the files when emitting. */
  8766. customTransformers?: ts.CustomTransformers;
  8767. }
  8768. /** Wrapper around Program. */
  8769. export declare class Program {
  8770. #private;
  8771. private constructor();
  8772. /** Gets the underlying compiler program. */
  8773. get compilerObject(): ts.Program;
  8774. /** Get the program's type checker. */
  8775. getTypeChecker(): TypeChecker;
  8776. /**
  8777. * Asynchronously emits the TypeScript files as JavaScript files.
  8778. * @param options - Options for emitting.
  8779. */
  8780. emit(options?: ProgramEmitOptions): Promise<EmitResult>;
  8781. /**
  8782. * Synchronously emits the TypeScript files as JavaScript files.
  8783. * @param options - Options for emitting.
  8784. * @remarks Use `emit()` as the asynchronous version will be much faster.
  8785. */
  8786. emitSync(options?: ProgramEmitOptions): EmitResult;
  8787. /**
  8788. * Emits the TypeScript files to JavaScript files to memory.
  8789. * @param options - Options for emitting.
  8790. */
  8791. emitToMemory(options?: EmitOptions): MemoryEmitResult;
  8792. /**
  8793. * Gets the syntactic diagnostics.
  8794. * @param sourceFile - Optional source file to filter by.
  8795. */
  8796. getSyntacticDiagnostics(sourceFile?: SourceFile): DiagnosticWithLocation[];
  8797. /**
  8798. * Gets the semantic diagnostics.
  8799. * @param sourceFile - Optional source file to filter by.
  8800. */
  8801. getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
  8802. /**
  8803. * Gets the declaration diagnostics.
  8804. * @param sourceFile - Optional source file to filter by.
  8805. */
  8806. getDeclarationDiagnostics(sourceFile?: SourceFile): DiagnosticWithLocation[];
  8807. /** Gets the global diagnostics. */
  8808. getGlobalDiagnostics(): Diagnostic[];
  8809. /** Gets the diagnostics found when parsing the tsconfig.json file. */
  8810. getConfigFileParsingDiagnostics(): Diagnostic[];
  8811. /** Gets the emit module resolution kind. */
  8812. getEmitModuleResolutionKind(): ModuleResolutionKind;
  8813. /**
  8814. * Gets if the provided source file was discovered while loading an external library.
  8815. * @param sourceFile - Source file.
  8816. */
  8817. isSourceFileFromExternalLibrary(sourceFile: SourceFile): boolean;
  8818. }
  8819. /** Represents a code action. */
  8820. export declare class CodeAction<TCompilerObject extends ts.CodeAction = ts.CodeAction> {
  8821. #private;
  8822. protected constructor();
  8823. /** Gets the compiler object. */
  8824. get compilerObject(): TCompilerObject;
  8825. /** Description of the code action. */
  8826. getDescription(): string;
  8827. /** Text changes to apply to each file as part of the code action. */
  8828. getChanges(): FileTextChanges[];
  8829. }
  8830. /** Represents a code fix action. */
  8831. export declare class CodeFixAction extends CodeAction<ts.CodeFixAction> {
  8832. /** Short name to identify the fix, for use by telemetry. */
  8833. getFixName(): string;
  8834. /**
  8835. * If present, one may call 'getCombinedCodeFix' with this fixId.
  8836. * This may be omitted to indicate that the code fix can't be applied in a group.
  8837. */
  8838. getFixId(): {} | undefined;
  8839. /** Gets the description of the code fix when fixing everything. */
  8840. getFixAllDescription(): string | undefined;
  8841. }
  8842. /**
  8843. * Represents file changes.
  8844. *
  8845. * @remarks Commands are currently not implemented.
  8846. */
  8847. export declare class CombinedCodeActions {
  8848. #private;
  8849. private constructor();
  8850. /** Gets the compiler object. */
  8851. get compilerObject(): ts.CombinedCodeActions;
  8852. /** Text changes to apply to each file. */
  8853. getChanges(): FileTextChanges[];
  8854. /**
  8855. * Executes the combined code actions.
  8856. *
  8857. * WARNING: This will cause all nodes to be forgotten in the changed files.
  8858. * @options - Options used when applying the changes.
  8859. */
  8860. applyChanges(options?: ApplyFileTextChangesOptions): this;
  8861. }
  8862. /** Definition info. */
  8863. export declare class DefinitionInfo<TCompilerObject extends ts.DefinitionInfo = ts.DefinitionInfo> extends DocumentSpan<TCompilerObject> {
  8864. protected constructor();
  8865. /** Gets the kind. */
  8866. getKind(): ts.ScriptElementKind;
  8867. /** Gets the name. */
  8868. getName(): string;
  8869. /** Gets the container kind. */
  8870. getContainerKind(): ts.ScriptElementKind;
  8871. /** Gets the container name. */
  8872. getContainerName(): string;
  8873. /** Gets the declaration node. */
  8874. getDeclarationNode(): Node | undefined;
  8875. }
  8876. /** Diagnostic. */
  8877. export declare class Diagnostic<TCompilerObject extends ts.Diagnostic = ts.Diagnostic> {
  8878. protected constructor();
  8879. /** Gets the underlying compiler diagnostic. */
  8880. get compilerObject(): TCompilerObject;
  8881. /** Gets the source file. */
  8882. getSourceFile(): SourceFile | undefined;
  8883. /** Gets the message text. */
  8884. getMessageText(): string | DiagnosticMessageChain;
  8885. /** Gets the line number. */
  8886. getLineNumber(): number | undefined;
  8887. /** Gets the start. */
  8888. getStart(): number | undefined;
  8889. /** Gets the length. */
  8890. getLength(): number | undefined;
  8891. /** Gets the diagnostic category. */
  8892. getCategory(): DiagnosticCategory;
  8893. /** Gets the code of the diagnostic. */
  8894. getCode(): number;
  8895. /** Gets the source. */
  8896. getSource(): string | undefined;
  8897. }
  8898. /** Diagnostic message chain. */
  8899. export declare class DiagnosticMessageChain {
  8900. private constructor();
  8901. /** Gets the underlying compiler object. */
  8902. get compilerObject(): ts.DiagnosticMessageChain;
  8903. /** Gets the message text. */
  8904. getMessageText(): string;
  8905. /** Gets the next diagnostic message chains in the chain. */
  8906. getNext(): DiagnosticMessageChain[] | undefined;
  8907. /** Gets the code of the diagnostic message chain. */
  8908. getCode(): number;
  8909. /** Gets the category of the diagnostic message chain. */
  8910. getCategory(): DiagnosticCategory;
  8911. }
  8912. export declare class DiagnosticWithLocation extends Diagnostic<ts.DiagnosticWithLocation> {
  8913. private constructor();
  8914. /** Gets the line number. */
  8915. getLineNumber(): number;
  8916. /** Gets the start. */
  8917. getStart(): number;
  8918. /** Gets the length */
  8919. getLength(): number;
  8920. /** Gets the source file. */
  8921. getSourceFile(): SourceFile;
  8922. }
  8923. /** Document span. */
  8924. export declare class DocumentSpan<TCompilerObject extends ts.DocumentSpan = ts.DocumentSpan> {
  8925. protected constructor();
  8926. /** Gets the compiler object. */
  8927. get compilerObject(): TCompilerObject;
  8928. /** Gets the source file this reference is in. */
  8929. getSourceFile(): SourceFile;
  8930. /** Gets the text span. */
  8931. getTextSpan(): TextSpan;
  8932. /** Gets the node at the start of the text span. */
  8933. getNode(): Node<ts.Node>;
  8934. /** Gets the original text span if the span represents a location that was remapped. */
  8935. getOriginalTextSpan(): TextSpan | undefined;
  8936. /** Gets the original file name if the span represents a location that was remapped. */
  8937. getOriginalFileName(): string | undefined;
  8938. }
  8939. /** Output of an emit on a single file. */
  8940. export declare class EmitOutput {
  8941. #private;
  8942. private constructor();
  8943. /** TypeScript compiler emit result. */
  8944. get compilerObject(): ts.EmitOutput;
  8945. /** Gets the diagnostics. */
  8946. getDiagnostics(): Diagnostic<ts.Diagnostic>[];
  8947. /** Gets if the emit was skipped. */
  8948. getEmitSkipped(): boolean;
  8949. /** Gets the output files. */
  8950. getOutputFiles(): OutputFile[];
  8951. }
  8952. /** Result of an emit. */
  8953. export declare class EmitResult {
  8954. protected constructor();
  8955. /** TypeScript compiler emit result. */
  8956. get compilerObject(): ts.EmitResult;
  8957. /** If the emit was skipped. */
  8958. getEmitSkipped(): boolean;
  8959. /**
  8960. * Contains declaration emit diagnostics.
  8961. *
  8962. * If the `noEmitOnError` compiler option is true, this will also include the program's semantic, syntactic, global, options, and if enabled declaration diagnostics.
  8963. * @remarks If you are looking for non-declaration emit diagnostics, then call `Project#getPreEmitDiagnostics()` or get specific diagnostics available from the program.
  8964. */
  8965. getDiagnostics(): Diagnostic<ts.Diagnostic>[];
  8966. }
  8967. export interface ApplyFileTextChangesOptions {
  8968. /** If a file should be overwritten when the file text change is for a new file, but the file currently exists. */
  8969. overwrite?: boolean;
  8970. }
  8971. export declare class FileTextChanges {
  8972. #private;
  8973. private constructor();
  8974. /** Gets the file path. */
  8975. getFilePath(): string;
  8976. /** Gets the source file if it was in the cache at the time of this class' creation. */
  8977. getSourceFile(): SourceFile | undefined;
  8978. /** Gets the text changes */
  8979. getTextChanges(): TextChange[];
  8980. /**
  8981. * Applies the text changes to the file. This modifies and possibly creates a new source file.
  8982. *
  8983. * WARNING: This will forget any previously navigated descendant nodes in the source file.
  8984. * @param options - Options for applying the text changes to the file.
  8985. */
  8986. applyChanges(options?: ApplyFileTextChangesOptions): this | undefined;
  8987. /** Gets if this change is for creating a new file. */
  8988. isNewFile(): boolean;
  8989. }
  8990. export declare class ImplementationLocation extends DocumentSpan<ts.ImplementationLocation> {
  8991. private constructor();
  8992. /** Gets the kind. */
  8993. getKind(): ts.ScriptElementKind;
  8994. /** Gets the display parts. */
  8995. getDisplayParts(): SymbolDisplayPart[];
  8996. }
  8997. /** The emitted file in memory. */
  8998. export interface MemoryEmitResultFile {
  8999. /** File path that was emitted to. */
  9000. filePath: StandardizedFilePath;
  9001. /** The text that was emitted. */
  9002. text: string;
  9003. /** Whether the byte order mark should be written. */
  9004. writeByteOrderMark: boolean;
  9005. }
  9006. /** Result of an emit to memory. */
  9007. export declare class MemoryEmitResult extends EmitResult {
  9008. #private;
  9009. private constructor();
  9010. /** Gets the files that were emitted to memory. */
  9011. getFiles(): MemoryEmitResultFile[];
  9012. /** Asynchronously writes the files to the file system. */
  9013. saveFiles(): Promise<void[]>;
  9014. /**
  9015. * Synchronously writes the files to the file system.
  9016. * @remarks Use `saveFiles()` as the asynchronous version will be much faster.
  9017. */
  9018. saveFilesSync(): void;
  9019. }
  9020. /** Output file of an emit. */
  9021. export declare class OutputFile {
  9022. #private;
  9023. private constructor();
  9024. /** TypeScript compiler output file. */
  9025. get compilerObject(): ts.OutputFile;
  9026. /** Gets the file path. */
  9027. getFilePath(): StandardizedFilePath;
  9028. /** Gets whether the byte order mark should be written. */
  9029. getWriteByteOrderMark(): boolean;
  9030. /** Gets the file text. */
  9031. getText(): string;
  9032. }
  9033. /** Set of edits to make in response to a refactor action, plus an optional location where renaming should be invoked from. */
  9034. export declare class RefactorEditInfo {
  9035. #private;
  9036. private constructor();
  9037. /** Gets the compiler refactor edit info. */
  9038. get compilerObject(): ts.RefactorEditInfo;
  9039. /** Gets refactor file text changes */
  9040. getEdits(): FileTextChanges[];
  9041. /** Gets the file path for a rename refactor. */
  9042. getRenameFilePath(): string | undefined;
  9043. /** Location where renaming should be invoked from. */
  9044. getRenameLocation(): number | undefined;
  9045. /**
  9046. * Executes the combined code actions.
  9047. *
  9048. * WARNING: This will cause all nodes to be forgotten in the changed files.
  9049. * @options - Options used when applying the changes.
  9050. */
  9051. applyChanges(options?: ApplyFileTextChangesOptions): this;
  9052. }
  9053. /** Referenced symbol. */
  9054. export declare class ReferencedSymbol {
  9055. #private;
  9056. private constructor();
  9057. /** Gets the compiler referenced symbol. */
  9058. get compilerObject(): ts.ReferencedSymbol;
  9059. /** Gets the definition. */
  9060. getDefinition(): ReferencedSymbolDefinitionInfo;
  9061. /** Gets the references. */
  9062. getReferences(): ReferencedSymbolEntry[];
  9063. }
  9064. export declare class ReferencedSymbolDefinitionInfo extends DefinitionInfo<ts.ReferencedSymbolDefinitionInfo> {
  9065. private constructor();
  9066. /** Gets the display parts. */
  9067. getDisplayParts(): SymbolDisplayPart[];
  9068. }
  9069. export declare class ReferenceEntry<T extends ts.ReferenceEntry = ts.ReferenceEntry> extends DocumentSpan<T> {
  9070. protected constructor();
  9071. isWriteAccess(): boolean;
  9072. isInString(): true | undefined;
  9073. }
  9074. export declare class ReferencedSymbolEntry extends ReferenceEntry<ts.ReferencedSymbolEntry> {
  9075. private constructor();
  9076. /** If this is the definition reference. */
  9077. isDefinition(): boolean | undefined;
  9078. }
  9079. /** Rename location. */
  9080. export declare class RenameLocation extends DocumentSpan<ts.RenameLocation> {
  9081. /** Gets the text to insert before the rename. */
  9082. getPrefixText(): string | undefined;
  9083. /** Gets the text to insert after the rename. */
  9084. getSuffixText(): string | undefined;
  9085. }
  9086. /** Symbol display part. */
  9087. export declare class SymbolDisplayPart {
  9088. #private;
  9089. private constructor();
  9090. /** Gets the compiler symbol display part. */
  9091. get compilerObject(): ts.SymbolDisplayPart;
  9092. /** Gets the text. */
  9093. getText(): string;
  9094. /**
  9095. * Gets the kind.
  9096. *
  9097. * Examples: "text", "lineBreak"
  9098. */
  9099. getKind(): string;
  9100. }
  9101. /** Represents a text change. */
  9102. export declare class TextChange {
  9103. #private;
  9104. private constructor();
  9105. /** Gets the compiler text change. */
  9106. get compilerObject(): ts.TextChange;
  9107. /** Gets the text span. */
  9108. getSpan(): TextSpan;
  9109. /** Gets the new text. */
  9110. getNewText(): string;
  9111. }
  9112. /** Represents a span of text. */
  9113. export declare class TextSpan {
  9114. #private;
  9115. private constructor();
  9116. /** Gets the compiler text span. */
  9117. get compilerObject(): ts.TextSpan;
  9118. /** Gets the start. */
  9119. getStart(): number;
  9120. /** Gets the start + length. */
  9121. getEnd(): number;
  9122. /** Gets the length. */
  9123. getLength(): number;
  9124. }
  9125. /** Wrapper around the TypeChecker. */
  9126. export declare class TypeChecker {
  9127. #private;
  9128. private constructor();
  9129. /** Gets the compiler's TypeChecker. */
  9130. get compilerObject(): ts.TypeChecker;
  9131. /**
  9132. * Gets the ambient module symbols (ex. modules in the
  9133. * @types folder or node_modules).
  9134. */
  9135. getAmbientModules(): Symbol[];
  9136. /**
  9137. * Gets the apparent type of a type.
  9138. * @param type - Type to get the apparent type of.
  9139. */
  9140. getApparentType(type: Type): Type<ts.Type>;
  9141. /**
  9142. * Gets the constant value of a declaration.
  9143. * @param node - Node to get the constant value from.
  9144. */
  9145. getConstantValue(node: EnumMember): string | number | undefined;
  9146. /**
  9147. * Gets the fully qualified name of a symbol.
  9148. * @param symbol - Symbol to get the fully qualified name of.
  9149. */
  9150. getFullyQualifiedName(symbol: Symbol): string;
  9151. /**
  9152. * Gets the type at the specified location.
  9153. * @param node - Node to get the type for.
  9154. */
  9155. getTypeAtLocation(node: Node): Type;
  9156. /**
  9157. * Gets the contextual type of an expression.
  9158. * @param expression - Expression.
  9159. */
  9160. getContextualType(expression: Expression): Type | undefined;
  9161. /**
  9162. * Gets the type of a symbol at the specified location.
  9163. * @param symbol - Symbol to get the type for.
  9164. * @param node - Location to get the type for.
  9165. */
  9166. getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
  9167. /**
  9168. * Gets the declared type of a symbol.
  9169. * @param symbol - Symbol to get the type for.
  9170. */
  9171. getDeclaredTypeOfSymbol(symbol: Symbol): Type;
  9172. /**
  9173. * Gets the symbol at the specified location or undefined if none exists.
  9174. * @param node - Node to get the symbol for.
  9175. */
  9176. getSymbolAtLocation(node: Node): Symbol | undefined;
  9177. /**
  9178. * Gets the aliased symbol of a symbol.
  9179. * @param symbol - Symbol to get the alias symbol of.
  9180. */
  9181. getAliasedSymbol(symbol: Symbol): Symbol | undefined;
  9182. /**
  9183. * Follow a single alias to get the immediately aliased symbol.
  9184. * @param symbol - Symbol to get the immediate alias symbol of.
  9185. */
  9186. getImmediatelyAliasedSymbol(symbol: Symbol): Symbol | undefined;
  9187. /**
  9188. * Gets the export symbol of a local symbol with a corresponding export symbol. Otherwise returns the input symbol.
  9189. *
  9190. * The following is from the compiler API documentation:
  9191. *
  9192. * For example, at `export type T = number;`:
  9193. * - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`.
  9194. * - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol.
  9195. * - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol.
  9196. */
  9197. getExportSymbolOfSymbol(symbol: Symbol): Symbol;
  9198. /**
  9199. * Gets the properties of a type.
  9200. * @param type - Type.
  9201. */
  9202. getPropertiesOfType(type: Type): Symbol[];
  9203. /**
  9204. * Gets the type text
  9205. * @param type - Type to get the text of.
  9206. * @param enclosingNode - Enclosing node.
  9207. * @param typeFormatFlags - Type format flags.
  9208. */
  9209. getTypeText(type: Type, enclosingNode?: Node, typeFormatFlags?: TypeFormatFlags): string;
  9210. /**
  9211. * Gets the return type of a signature.
  9212. * @param signature - Signature to get the return type of.
  9213. */
  9214. getReturnTypeOfSignature(signature: Signature): Type;
  9215. /**
  9216. * Gets a signature from a node.
  9217. * @param node - Node to get the signature from.
  9218. */
  9219. getSignatureFromNode(node: Node<ts.SignatureDeclaration>): Signature | undefined;
  9220. /**
  9221. * Gets the exports of a module.
  9222. * @param moduleSymbol - Module symbol.
  9223. */
  9224. getExportsOfModule(moduleSymbol: Symbol): Symbol[];
  9225. /**
  9226. * Gets the local target symbol of the provided export specifier.
  9227. * @param exportSpecifier - Export specifier.
  9228. */
  9229. getExportSpecifierLocalTargetSymbol(exportSpecifier: ExportSpecifier): Symbol | undefined;
  9230. /**
  9231. * Gets the resolved signature from a node or returns undefined if the signature can't be resolved.
  9232. * @param node - Node to get the signature from.
  9233. */
  9234. getResolvedSignature(node: CallLikeExpression): Signature | undefined;
  9235. /**
  9236. * Gets the resolved signature from a node or throws if the signature cannot be resolved.
  9237. * @param node - Node to get the signature from.
  9238. */
  9239. getResolvedSignatureOrThrow(node: CallLikeExpression, message?: string | (() => string)): Signature;
  9240. /**
  9241. * Gets the base type of a literal type.
  9242. *
  9243. * For example, for a number literal type it will return the number type.
  9244. * @param type - Literal type to get the base type of.
  9245. */
  9246. getBaseTypeOfLiteralType(type: Type): Type<ts.Type>;
  9247. /**
  9248. * Gets the symbols in the scope of the provided node.
  9249. *
  9250. * Note: This will always return the local symbols. If you want the export symbol from a local symbol, then
  9251. * use the `#getExportSymbolOfSymbol(symbol)` method.
  9252. * @param node - Node to check the scope for.
  9253. * @param meaning - Meaning of symbol to filter by.
  9254. */
  9255. getSymbolsInScope(node: Node, meaning: SymbolFlags): Symbol[];
  9256. /**
  9257. * Gets the type arguments from a type reference.
  9258. * @param typeReference - Type reference.
  9259. */
  9260. getTypeArguments(typeReference: Type): Type<ts.Type>[];
  9261. /** Checks if a type is assignable to another type. */
  9262. isTypeAssignableTo(sourceType: Type, targetType: Type): boolean;
  9263. /** Gets the shorthand assignment value symbol of the provided node. */
  9264. getShorthandAssignmentValueSymbol(node: Node): Symbol | undefined;
  9265. resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
  9266. }
  9267. export declare class Type<TType extends ts.Type = ts.Type> {
  9268. #private;
  9269. protected constructor();
  9270. /** Gets the underlying compiler type. */
  9271. get compilerType(): TType;
  9272. /**
  9273. * Gets the type text.
  9274. * @param enclosingNode - The enclosing node.
  9275. * @param typeFormatFlags - Format flags for the type text.
  9276. */
  9277. getText(enclosingNode?: Node, typeFormatFlags?: TypeFormatFlags): string;
  9278. /** Gets the alias symbol if it exists. */
  9279. getAliasSymbol(): Symbol | undefined;
  9280. /** Gets the alias symbol if it exists, or throws. */
  9281. getAliasSymbolOrThrow(message?: string | (() => string)): Symbol;
  9282. /** Gets the alias type arguments. */
  9283. getAliasTypeArguments(): Type[];
  9284. /** Gets the apparent type. */
  9285. getApparentType(): Type;
  9286. /** Gets the array element type or throws if it doesn't exist (ex. for `T[]` it would be `T`). */
  9287. getArrayElementTypeOrThrow(message?: string | (() => string)): Type<ts.Type>;
  9288. /** Gets the array element type or returns undefined if it doesn't exist (ex. for `T[]` it would be `T`). */
  9289. getArrayElementType(): Type<ts.Type> | undefined;
  9290. /** Gets the base types. */
  9291. getBaseTypes(): Type<ts.BaseType>[];
  9292. /**
  9293. * Gets the base type of a literal type.
  9294. *
  9295. * For example, for a number literal type it will return the number type.
  9296. */
  9297. getBaseTypeOfLiteralType(): Type<ts.Type>;
  9298. /** Gets the call signatures. */
  9299. getCallSignatures(): Signature[];
  9300. /** Gets the construct signatures. */
  9301. getConstructSignatures(): Signature[];
  9302. /** Gets the constraint or throws if it doesn't exist. */
  9303. getConstraintOrThrow(message?: string | (() => string)): Type<ts.Type>;
  9304. /** Gets the constraint or returns undefined if it doesn't exist. */
  9305. getConstraint(): Type<ts.Type> | undefined;
  9306. /** Gets the default type or throws if it doesn't exist. */
  9307. getDefaultOrThrow(message?: string | (() => string)): Type<ts.Type>;
  9308. /** Gets the default type or returns undefined if it doesn't exist. */
  9309. getDefault(): Type<ts.Type> | undefined;
  9310. /** Gets the properties of the type. */
  9311. getProperties(): Symbol[];
  9312. /**
  9313. * Gets a property or throws if it doesn't exist.
  9314. * @param name - By a name.
  9315. */
  9316. getPropertyOrThrow(name: string): Symbol;
  9317. /**
  9318. * Gets a property or throws if it doesn't exist.
  9319. * @param findFunction - Function for searching for a property.
  9320. */
  9321. getPropertyOrThrow(findFunction: (declaration: Symbol) => boolean): Symbol;
  9322. /**
  9323. * Gets a property or returns undefined if it does not exist.
  9324. * @param name - By a name.
  9325. */
  9326. getProperty(name: string): Symbol | undefined;
  9327. /**
  9328. * Gets a property or returns undefined if it does not exist.
  9329. * @param findFunction - Function for searching for a property.
  9330. */
  9331. getProperty(findFunction: (declaration: Symbol) => boolean): Symbol | undefined;
  9332. /** Gets the apparent properties of the type. */
  9333. getApparentProperties(): Symbol[];
  9334. /**
  9335. * Gets an apparent property.
  9336. * @param name - By a name.
  9337. * @param findFunction - Function for searching for an apparent property.
  9338. */
  9339. getApparentProperty(name: string): Symbol | undefined;
  9340. getApparentProperty(findFunction: (declaration: Symbol) => boolean): Symbol | undefined;
  9341. /** Gets if the type is possibly null or undefined. */
  9342. isNullable(): boolean;
  9343. /** Gets the non-nullable type. */
  9344. getNonNullableType(): Type;
  9345. /** Gets the number index type. */
  9346. getNumberIndexType(): Type | undefined;
  9347. /** Gets the string index type. */
  9348. getStringIndexType(): Type | undefined;
  9349. /**
  9350. * Returns the generic type when the type is a type reference, returns itself when it's
  9351. * already a generic type, or otherwise returns undefined.
  9352. *
  9353. * For example:
  9354. *
  9355. * - Given type reference `Promise<string>` returns `Promise<T>`.
  9356. * - Given generic type `Promise<T>` returns the same `Promise<T>`.
  9357. * - Given `string` returns `undefined`.
  9358. */
  9359. getTargetType(): Type<ts.GenericType> | undefined;
  9360. /**
  9361. * Returns the generic type when the type is a type reference, returns itself when it's
  9362. * already a generic type, or otherwise throws an error.
  9363. *
  9364. * For example:
  9365. *
  9366. * - Given type reference `Promise<string>` returns `Promise<T>`.
  9367. * - Given generic type `Promise<T>` returns the same `Promise<T>`.
  9368. * - Given `string` throws an error.
  9369. */
  9370. getTargetTypeOrThrow(message?: string | (() => string)): Type<ts.GenericType>;
  9371. /** Gets type arguments. */
  9372. getTypeArguments(): Type[];
  9373. /** Gets the individual element types of the tuple. */
  9374. getTupleElements(): Type[];
  9375. /** Gets the union types (ex. for `T | U` it returns the array `[T, U]`). */
  9376. getUnionTypes(): Type[];
  9377. /** Gets the intersection types (ex. for `T & U` it returns the array `[T, U]`). */
  9378. getIntersectionTypes(): Type[];
  9379. /** Gets the value of a literal or returns undefined if this is not a literal type. */
  9380. getLiteralValue(): string | number | ts.PseudoBigInt | undefined;
  9381. /** Gets the value of the literal or throws if this is not a literal type. */
  9382. getLiteralValueOrThrow(message?: string | (() => string)): string | number | ts.PseudoBigInt;
  9383. /**
  9384. * Gets the fresh type of the literal or returns undefined if this is not a literal type.
  9385. *
  9386. * Note: I have no idea what this means. Please help contribute to these js docs if you know.
  9387. */
  9388. getLiteralFreshType(): Type<ts.FreshableType> | undefined;
  9389. /**
  9390. * Gets the fresh type of the literal or throws if this is not a literal type.
  9391. *
  9392. * Note: I have no idea what this means. Please help contribute to these js docs if you know.
  9393. */
  9394. getLiteralFreshTypeOrThrow(message?: string | (() => string)): Type<ts.FreshableType>;
  9395. /**
  9396. * Gets the regular type of the literal or returns undefined if this is not a literal type.
  9397. *
  9398. * Note: I have no idea what this means. Please help contribute to these js docs if you know.
  9399. */
  9400. getLiteralRegularType(): Type<ts.FreshableType> | undefined;
  9401. /**
  9402. * Gets the regular type of the literal or throws if this is not a literal type.
  9403. *
  9404. * Note: I have no idea what this means. Please help contribute to these js docs if you know.
  9405. */
  9406. getLiteralRegularTypeOrThrow(message?: string | (() => string)): Type<ts.FreshableType>;
  9407. /** Gets the symbol of the type. */
  9408. getSymbol(): Symbol | undefined;
  9409. /** Gets the symbol of the type or throws. */
  9410. getSymbolOrThrow(message?: string | (() => string)): Symbol;
  9411. /** Gets if the type is assignable to another type. */
  9412. isAssignableTo(target: Type): boolean;
  9413. /** Gets if this is an anonymous type. */
  9414. isAnonymous(): boolean;
  9415. /** Gets if this is an any type. */
  9416. isAny(): boolean;
  9417. /** Gets if this is a never type. */
  9418. isNever(): boolean;
  9419. /** Gets if this is an array type. */
  9420. isArray(): boolean;
  9421. /** Gets if this is a readonly array type. */
  9422. isReadonlyArray(): boolean;
  9423. /** Gets if this is a template literal type. */
  9424. isTemplateLiteral(): this is Type<ts.TemplateLiteralType>;
  9425. /** Gets if this is a boolean type. */
  9426. isBoolean(): boolean;
  9427. /** Gets if this is a string type. */
  9428. isString(): boolean;
  9429. /** Gets if this is a number type. */
  9430. isNumber(): boolean;
  9431. /** Gets if this is a BigInt. */
  9432. isBigInt(): boolean;
  9433. /** Gets if this is a literal type. */
  9434. isLiteral(): boolean;
  9435. /** Gets if this is a boolean literal type. */
  9436. isBooleanLiteral(): boolean;
  9437. /** Gets if this is a BigInt literal type. */
  9438. isBigIntLiteral(): boolean;
  9439. /** Gets if this is an enum literal type. */
  9440. isEnumLiteral(): boolean;
  9441. /** Gets if this is a number literal type. */
  9442. isNumberLiteral(): this is Type<ts.NumberLiteralType>;
  9443. /** Gets if this is a string literal type. */
  9444. isStringLiteral(): this is Type<ts.StringLiteralType>;
  9445. /** Gets if this is a class type. */
  9446. isClass(): this is Type<ts.InterfaceType>;
  9447. /** Gets if this is a class or interface type. */
  9448. isClassOrInterface(): this is Type<ts.InterfaceType>;
  9449. /** Gets if this is an enum type. */
  9450. isEnum(): boolean;
  9451. /** Gets if this is an interface type. */
  9452. isInterface(): this is Type<ts.InterfaceType>;
  9453. /** Gets if this is an object type. */
  9454. isObject(): this is Type<ts.ObjectType>;
  9455. /** Gets if this is a type parameter. */
  9456. isTypeParameter(): this is TypeParameter;
  9457. /** Gets if this is a tuple type. */
  9458. isTuple(): this is Type<ts.TupleType>;
  9459. /** Gets if this is a union type. */
  9460. isUnion(): this is Type<ts.UnionType>;
  9461. /** Gets if this is an intersection type. */
  9462. isIntersection(): this is Type<ts.IntersectionType>;
  9463. /** Gets if this is a union or intersection type. */
  9464. isUnionOrIntersection(): this is Type<ts.UnionOrIntersectionType>;
  9465. /** Gets if this is the unknown type. */
  9466. isUnknown(): boolean;
  9467. /** Gets if this is the null type. */
  9468. isNull(): boolean;
  9469. /** Gets if this is the undefined type. */
  9470. isUndefined(): boolean;
  9471. /** Gets if this is the void type. */
  9472. isVoid(): boolean;
  9473. /** Gets the type flags. */
  9474. getFlags(): TypeFlags;
  9475. /**
  9476. * Gets the object flags.
  9477. * @remarks Returns 0 for a non-object type.
  9478. */
  9479. getObjectFlags(): 0 | ObjectFlags.Class | ObjectFlags.Interface | ObjectFlags.Reference | ObjectFlags.Tuple | ObjectFlags.Anonymous | ObjectFlags.Mapped | ObjectFlags.Instantiated | ObjectFlags.ObjectLiteral | ObjectFlags.EvolvingArray | ObjectFlags.ObjectLiteralPatternWithComputedProperties | ObjectFlags.ReverseMapped | ObjectFlags.JsxAttributes | ObjectFlags.JSLiteral | ObjectFlags.FreshLiteral | ObjectFlags.ArrayLiteral | ObjectFlags.ClassOrInterface | ObjectFlags.ContainsSpread | ObjectFlags.ObjectRestType | ObjectFlags.InstantiationExpressionType | ObjectFlags.SingleSignatureType;
  9480. }
  9481. export declare class TypeParameter extends Type<ts.TypeParameter> {
  9482. #private;
  9483. /** Gets the constraint or throws if it doesn't exist. */
  9484. getConstraintOrThrow(message?: string | (() => string)): Type;
  9485. /** Gets the constraint type. */
  9486. getConstraint(): Type | undefined;
  9487. /** Gets the default type or throws if it doesn't exist. */
  9488. getDefaultOrThrow(message?: string | (() => string)): Type;
  9489. /** Gets the default type or undefined if it doesn't exist. */
  9490. getDefault(): Type | undefined;
  9491. }
  9492. /** Kinds of indentation */
  9493. export declare enum IndentationText {
  9494. /** Two spaces */
  9495. TwoSpaces = " ",
  9496. /** Four spaces */
  9497. FourSpaces = " ",
  9498. /** Eight spaces */
  9499. EightSpaces = " ",
  9500. /** Tab */
  9501. Tab = "\t"
  9502. }
  9503. /** Manipulation settings. */
  9504. export interface ManipulationSettings extends SupportedFormatCodeSettingsOnly {
  9505. /** Indentation text */
  9506. indentationText: IndentationText;
  9507. /** New line kind */
  9508. newLineKind: NewLineKind;
  9509. /** Quote type used for string literals. */
  9510. quoteKind: QuoteKind;
  9511. /**
  9512. * Whether to enable renaming shorthand property assignments, binding elements,
  9513. * and import & export specifiers without changing behaviour.
  9514. * @remarks Defaults to true.
  9515. * This setting is only available when using TypeScript 3.4+.
  9516. */
  9517. usePrefixAndSuffixTextForRename: boolean;
  9518. /** Whether to use trailing commas when inserting or removing nodes. */
  9519. useTrailingCommas: boolean;
  9520. }
  9521. /** FormatCodeSettings that are currently supported in the library. */
  9522. export interface SupportedFormatCodeSettings extends SupportedFormatCodeSettingsOnly, EditorSettings {
  9523. }
  9524. /** FormatCodeSettings that are currently supported in the library. */
  9525. export interface SupportedFormatCodeSettingsOnly {
  9526. /**
  9527. * Whether to insert a space after opening and before closing non-empty braces.
  9528. *
  9529. * ex. `import { Item } from "./Item";` or `import {Item} from "./Item";`
  9530. * @remarks Defaults to true.
  9531. */
  9532. insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: boolean;
  9533. }
  9534. /** Holds the manipulation settings. */
  9535. export declare class ManipulationSettingsContainer extends SettingsContainer<ManipulationSettings> {
  9536. #private;
  9537. constructor();
  9538. /** Gets the editor settings based on the current manipulation settings. */
  9539. getEditorSettings(): Readonly<EditorSettings>;
  9540. /** Gets the format code settings. */
  9541. getFormatCodeSettings(): Readonly<SupportedFormatCodeSettings>;
  9542. /** Gets the user preferences. */
  9543. getUserPreferences(): Readonly<UserPreferences>;
  9544. /** Gets the quote kind used for string literals. */
  9545. getQuoteKind(): QuoteKind;
  9546. /** Gets the new line kind. */
  9547. getNewLineKind(): NewLineKind;
  9548. /** Gets the new line kind as a string. */
  9549. getNewLineKindAsString(): "\r\n" | "\n";
  9550. /** Gets the indentation text. */
  9551. getIndentationText(): IndentationText;
  9552. /** Gets whether to use prefix and suffix text when renaming. */
  9553. getUsePrefixAndSuffixTextForRename(): boolean;
  9554. /** Gets whether trailing commas should be used. */
  9555. getUseTrailingCommas(): boolean;
  9556. /**
  9557. * Sets one or all of the settings.
  9558. * @param settings - Settings to set.
  9559. */
  9560. set(settings: Partial<ManipulationSettings>): void;
  9561. }
  9562. export type StatementStructures = ClassDeclarationStructure | EnumDeclarationStructure | FunctionDeclarationStructure | InterfaceDeclarationStructure | ModuleDeclarationStructure | TypeAliasDeclarationStructure | ImportDeclarationStructure | ExportDeclarationStructure | ExportAssignmentStructure | VariableStatementStructure;
  9563. export type ClassMemberStructures = ConstructorDeclarationStructure | GetAccessorDeclarationStructure | SetAccessorDeclarationStructure | MethodDeclarationStructure | PropertyDeclarationStructure | ClassStaticBlockDeclarationStructure;
  9564. export type TypeElementMemberStructures = CallSignatureDeclarationStructure | ConstructSignatureDeclarationStructure | IndexSignatureDeclarationStructure | MethodSignatureStructure | PropertySignatureStructure;
  9565. export type InterfaceMemberStructures = TypeElementMemberStructures;
  9566. export type ObjectLiteralExpressionPropertyStructures = PropertyAssignmentStructure | ShorthandPropertyAssignmentStructure | SpreadAssignmentStructure | GetAccessorDeclarationStructure | SetAccessorDeclarationStructure | MethodDeclarationStructure;
  9567. export type JsxStructures = JsxAttributeStructure | JsxSpreadAttributeStructure | JsxElementStructure | JsxSelfClosingElementStructure;
  9568. export type Structures = ImportAttributeStructure | StatementStructures | ClassMemberStructures | EnumMemberStructure | InterfaceMemberStructures | ObjectLiteralExpressionPropertyStructures | JsxStructures | FunctionDeclarationOverloadStructure | MethodDeclarationOverloadStructure | ConstructorDeclarationOverloadStructure | ParameterDeclarationStructure | TypeParameterDeclarationStructure | SourceFileStructure | ExportSpecifierStructure | ImportSpecifierStructure | VariableDeclarationStructure | JSDocStructure | JSDocTagStructure | DecoratorStructure;
  9569. export interface AbstractableNodeStructure {
  9570. isAbstract?: boolean;
  9571. }
  9572. export interface AmbientableNodeStructure {
  9573. hasDeclareKeyword?: boolean;
  9574. }
  9575. export interface AsyncableNodeStructure {
  9576. isAsync?: boolean;
  9577. }
  9578. export interface AwaitableNodeStructure {
  9579. isAwaited?: boolean;
  9580. }
  9581. export interface DecoratableNodeStructure {
  9582. decorators?: OptionalKind<DecoratorStructure>[];
  9583. }
  9584. export interface ExclamationTokenableNodeStructure {
  9585. hasExclamationToken?: boolean;
  9586. }
  9587. export interface ExportableNodeStructure {
  9588. isExported?: boolean;
  9589. isDefaultExport?: boolean;
  9590. }
  9591. export interface ExtendsClauseableNodeStructure {
  9592. extends?: (string | WriterFunction)[] | WriterFunction;
  9593. }
  9594. export interface GeneratorableNodeStructure {
  9595. isGenerator?: boolean;
  9596. }
  9597. export interface ImplementsClauseableNodeStructure {
  9598. implements?: (string | WriterFunction)[] | WriterFunction;
  9599. }
  9600. export interface InitializerExpressionableNodeStructure {
  9601. initializer?: string | WriterFunction;
  9602. }
  9603. export interface JSDocableNodeStructure {
  9604. docs?: (OptionalKind<JSDocStructure> | string)[];
  9605. }
  9606. export interface BindingNamedNodeStructure {
  9607. name: string;
  9608. }
  9609. export interface ImportAttributeNamedNodeStructure {
  9610. name: string;
  9611. }
  9612. export interface ModuleNamedNodeStructure {
  9613. name: string;
  9614. }
  9615. export interface NameableNodeStructure {
  9616. name?: string;
  9617. }
  9618. export interface NamedNodeStructure {
  9619. name: string;
  9620. }
  9621. export interface PropertyNameableNodeStructure {
  9622. name?: string;
  9623. }
  9624. export interface PropertyNamedNodeStructure {
  9625. name: string;
  9626. }
  9627. export interface OverrideableNodeStructure {
  9628. hasOverrideKeyword?: boolean;
  9629. }
  9630. export interface ParameteredNodeStructure {
  9631. parameters?: OptionalKind<ParameterDeclarationStructure>[];
  9632. }
  9633. export interface QuestionDotTokenableNodeStructure {
  9634. hasQuestionDotToken?: boolean;
  9635. }
  9636. export interface QuestionTokenableNodeStructure {
  9637. hasQuestionToken?: boolean;
  9638. }
  9639. export interface ReadonlyableNodeStructure {
  9640. isReadonly?: boolean;
  9641. }
  9642. export interface ReturnTypedNodeStructure {
  9643. returnType?: string | WriterFunction;
  9644. }
  9645. export interface ScopeableNodeStructure {
  9646. scope?: Scope;
  9647. }
  9648. export interface ScopedNodeStructure {
  9649. scope?: Scope;
  9650. }
  9651. export interface SignaturedDeclarationStructure extends ParameteredNodeStructure, ReturnTypedNodeStructure {
  9652. }
  9653. export interface StaticableNodeStructure {
  9654. isStatic?: boolean;
  9655. }
  9656. export interface TypedNodeStructure {
  9657. type?: string | WriterFunction;
  9658. }
  9659. export interface TypeElementMemberedNodeStructure {
  9660. callSignatures?: OptionalKind<CallSignatureDeclarationStructure>[];
  9661. constructSignatures?: OptionalKind<ConstructSignatureDeclarationStructure>[];
  9662. getAccessors?: OptionalKind<GetAccessorDeclarationStructure>[];
  9663. indexSignatures?: OptionalKind<IndexSignatureDeclarationStructure>[];
  9664. methods?: OptionalKind<MethodSignatureStructure>[];
  9665. properties?: OptionalKind<PropertySignatureStructure>[];
  9666. setAccessors?: OptionalKind<SetAccessorDeclarationStructure>[];
  9667. }
  9668. export interface TypeParameteredNodeStructure {
  9669. typeParameters?: (OptionalKind<TypeParameterDeclarationStructure> | string)[];
  9670. }
  9671. export interface ClassLikeDeclarationBaseStructure extends NameableNodeStructure, ClassLikeDeclarationBaseSpecificStructure, ImplementsClauseableNodeStructure, DecoratableNodeStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, AbstractableNodeStructure {
  9672. }
  9673. interface ClassLikeDeclarationBaseSpecificStructure {
  9674. extends?: string | WriterFunction;
  9675. ctors?: OptionalKind<ConstructorDeclarationStructure>[];
  9676. staticBlocks?: OptionalKind<ClassStaticBlockDeclarationStructure>[];
  9677. properties?: OptionalKind<PropertyDeclarationStructure>[];
  9678. getAccessors?: OptionalKind<GetAccessorDeclarationStructure>[];
  9679. setAccessors?: OptionalKind<SetAccessorDeclarationStructure>[];
  9680. methods?: OptionalKind<MethodDeclarationStructure>[];
  9681. }
  9682. export interface ClassDeclarationStructure extends Structure, ClassLikeDeclarationBaseStructure, ClassDeclarationSpecificStructure, AmbientableNodeStructure, ExportableNodeStructure {
  9683. /**
  9684. * The class name.
  9685. * @remarks Can be undefined. For example: `export default class { ... }`
  9686. */
  9687. name?: string;
  9688. }
  9689. interface ClassDeclarationSpecificStructure extends KindedStructure<StructureKind.Class> {
  9690. }
  9691. export interface ClassStaticBlockDeclarationStructure extends Structure, ClassStaticBlockDeclarationSpecificStructure, JSDocableNodeStructure, StatementedNodeStructure {
  9692. }
  9693. interface ClassStaticBlockDeclarationSpecificStructure extends KindedStructure<StructureKind.ClassStaticBlock> {
  9694. }
  9695. export interface ConstructorDeclarationStructure extends Structure, ConstructorDeclarationSpecificStructure, ScopedNodeStructure, FunctionLikeDeclarationStructure {
  9696. }
  9697. interface ConstructorDeclarationSpecificStructure extends KindedStructure<StructureKind.Constructor> {
  9698. overloads?: OptionalKind<ConstructorDeclarationOverloadStructure>[];
  9699. }
  9700. export interface ConstructorDeclarationOverloadStructure extends Structure, ConstructorDeclarationOverloadSpecificStructure, ScopedNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure, JSDocableNodeStructure {
  9701. }
  9702. interface ConstructorDeclarationOverloadSpecificStructure extends KindedStructure<StructureKind.ConstructorOverload> {
  9703. }
  9704. export interface GetAccessorDeclarationStructure extends Structure, GetAccessorDeclarationSpecificStructure, PropertyNamedNodeStructure, StaticableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, FunctionLikeDeclarationStructure {
  9705. }
  9706. interface GetAccessorDeclarationSpecificStructure extends KindedStructure<StructureKind.GetAccessor> {
  9707. }
  9708. export interface MethodDeclarationStructure extends Structure, MethodDeclarationSpecificStructure, PropertyNamedNodeStructure, StaticableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, AsyncableNodeStructure, GeneratorableNodeStructure, FunctionLikeDeclarationStructure, QuestionTokenableNodeStructure, OverrideableNodeStructure {
  9709. }
  9710. interface MethodDeclarationSpecificStructure extends KindedStructure<StructureKind.Method> {
  9711. overloads?: OptionalKind<MethodDeclarationOverloadStructure>[];
  9712. }
  9713. export interface MethodDeclarationOverloadStructure extends Structure, MethodDeclarationOverloadSpecificStructure, StaticableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, AsyncableNodeStructure, GeneratorableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, QuestionTokenableNodeStructure, OverrideableNodeStructure {
  9714. }
  9715. interface MethodDeclarationOverloadSpecificStructure extends KindedStructure<StructureKind.MethodOverload> {
  9716. }
  9717. export interface PropertyDeclarationStructure extends Structure, PropertyDeclarationSpecificStructure, PropertyNamedNodeStructure, TypedNodeStructure, QuestionTokenableNodeStructure, ExclamationTokenableNodeStructure, StaticableNodeStructure, ScopedNodeStructure, JSDocableNodeStructure, ReadonlyableNodeStructure, InitializerExpressionableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, AmbientableNodeStructure, OverrideableNodeStructure {
  9718. }
  9719. interface PropertyDeclarationSpecificStructure extends KindedStructure<StructureKind.Property> {
  9720. hasAccessorKeyword?: boolean;
  9721. }
  9722. export interface SetAccessorDeclarationStructure extends Structure, SetAccessorDeclarationSpecificStructure, PropertyNamedNodeStructure, StaticableNodeStructure, DecoratableNodeStructure, AbstractableNodeStructure, ScopedNodeStructure, FunctionLikeDeclarationStructure {
  9723. }
  9724. interface SetAccessorDeclarationSpecificStructure extends KindedStructure<StructureKind.SetAccessor> {
  9725. }
  9726. export interface DecoratorStructure extends Structure, DecoratorSpecificStructure {
  9727. }
  9728. interface DecoratorSpecificStructure extends KindedStructure<StructureKind.Decorator> {
  9729. name: string;
  9730. /**
  9731. * Arguments for a decorator factory.
  9732. * @remarks Provide an empty array to make the structure a decorator factory.
  9733. */
  9734. arguments?: (string | WriterFunction)[] | WriterFunction;
  9735. typeArguments?: string[];
  9736. }
  9737. export interface JSDocStructure extends Structure, JSDocSpecificStructure {
  9738. }
  9739. interface JSDocSpecificStructure extends KindedStructure<StructureKind.JSDoc> {
  9740. /**
  9741. * The description of the JS doc.
  9742. * @remarks To force this to be multi-line, add a newline to the front of the string.
  9743. */
  9744. description?: string | WriterFunction;
  9745. /** JS doc tags (ex. `&#64;param value - Some description.`). */
  9746. tags?: OptionalKind<JSDocTagStructure>[];
  9747. }
  9748. export interface JSDocTagStructure extends Structure, JSDocTagSpecificStructure {
  9749. }
  9750. interface JSDocTagSpecificStructure extends KindedStructure<StructureKind.JSDocTag> {
  9751. /** The name for the JS doc tag that comes after the "at" symbol. */
  9752. tagName: string;
  9753. /** The text that follows the tag name. */
  9754. text?: string | WriterFunction;
  9755. }
  9756. export interface EnumDeclarationStructure extends Structure, NamedNodeStructure, EnumDeclarationSpecificStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
  9757. }
  9758. interface EnumDeclarationSpecificStructure extends KindedStructure<StructureKind.Enum> {
  9759. isConst?: boolean;
  9760. members?: OptionalKind<EnumMemberStructure>[];
  9761. }
  9762. export interface EnumMemberStructure extends Structure, EnumMemberSpecificStructure, PropertyNamedNodeStructure, JSDocableNodeStructure, InitializerExpressionableNodeStructure {
  9763. }
  9764. interface EnumMemberSpecificStructure extends KindedStructure<StructureKind.EnumMember> {
  9765. /** Convenience property for setting the initializer. */
  9766. value?: number | string;
  9767. }
  9768. export interface ExpressionedNodeStructure {
  9769. expression: string | WriterFunction;
  9770. }
  9771. export interface PropertyAssignmentStructure extends Structure, PropertyAssignmentSpecificStructure, PropertyNamedNodeStructure {
  9772. }
  9773. interface PropertyAssignmentSpecificStructure extends KindedStructure<StructureKind.PropertyAssignment> {
  9774. initializer: string | WriterFunction;
  9775. }
  9776. export interface ShorthandPropertyAssignmentStructure extends Structure, ShorthandPropertyAssignmentSpecificStructure, NamedNodeStructure {
  9777. }
  9778. interface ShorthandPropertyAssignmentSpecificStructure extends KindedStructure<StructureKind.ShorthandPropertyAssignment> {
  9779. }
  9780. export interface SpreadAssignmentStructure extends Structure, SpreadAssignmentSpecificStructure, ExpressionedNodeStructure {
  9781. }
  9782. interface SpreadAssignmentSpecificStructure extends KindedStructure<StructureKind.SpreadAssignment> {
  9783. }
  9784. export interface FunctionDeclarationStructure extends Structure, FunctionDeclarationSpecificStructure, NameableNodeStructure, FunctionLikeDeclarationStructure, AsyncableNodeStructure, GeneratorableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
  9785. }
  9786. interface FunctionDeclarationSpecificStructure extends KindedStructure<StructureKind.Function> {
  9787. overloads?: OptionalKind<FunctionDeclarationOverloadStructure>[];
  9788. }
  9789. export interface FunctionDeclarationOverloadStructure extends Structure, FunctionDeclarationOverloadSpecificStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, AsyncableNodeStructure, GeneratorableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
  9790. }
  9791. interface FunctionDeclarationOverloadSpecificStructure extends KindedStructure<StructureKind.FunctionOverload> {
  9792. }
  9793. export interface FunctionLikeDeclarationStructure extends SignaturedDeclarationStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, StatementedNodeStructure {
  9794. }
  9795. export interface ParameterDeclarationStructure extends Structure, BindingNamedNodeStructure, TypedNodeStructure, ReadonlyableNodeStructure, DecoratableNodeStructure, QuestionTokenableNodeStructure, ScopeableNodeStructure, InitializerExpressionableNodeStructure, ParameterDeclarationSpecificStructure, OverrideableNodeStructure {
  9796. }
  9797. interface ParameterDeclarationSpecificStructure extends KindedStructure<StructureKind.Parameter> {
  9798. isRestParameter?: boolean;
  9799. }
  9800. export interface CallSignatureDeclarationStructure extends Structure, CallSignatureDeclarationSpecificStructure, JSDocableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure {
  9801. }
  9802. interface CallSignatureDeclarationSpecificStructure extends KindedStructure<StructureKind.CallSignature> {
  9803. }
  9804. export interface ConstructSignatureDeclarationStructure extends Structure, ConstructSignatureDeclarationSpecificStructure, JSDocableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure {
  9805. }
  9806. interface ConstructSignatureDeclarationSpecificStructure extends KindedStructure<StructureKind.ConstructSignature> {
  9807. }
  9808. export interface IndexSignatureDeclarationStructure extends Structure, IndexSignatureDeclarationSpecificStructure, JSDocableNodeStructure, ReadonlyableNodeStructure, ReturnTypedNodeStructure {
  9809. }
  9810. interface IndexSignatureDeclarationSpecificStructure extends KindedStructure<StructureKind.IndexSignature> {
  9811. keyName?: string;
  9812. keyType?: string;
  9813. }
  9814. export interface InterfaceDeclarationStructure extends Structure, NamedNodeStructure, InterfaceDeclarationSpecificStructure, ExtendsClauseableNodeStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure, TypeElementMemberedNodeStructure {
  9815. }
  9816. interface InterfaceDeclarationSpecificStructure extends KindedStructure<StructureKind.Interface> {
  9817. }
  9818. export interface MethodSignatureStructure extends Structure, PropertyNamedNodeStructure, MethodSignatureSpecificStructure, QuestionTokenableNodeStructure, JSDocableNodeStructure, SignaturedDeclarationStructure, TypeParameteredNodeStructure {
  9819. }
  9820. interface MethodSignatureSpecificStructure extends KindedStructure<StructureKind.MethodSignature> {
  9821. }
  9822. export interface PropertySignatureStructure extends Structure, PropertySignatureSpecificStructure, PropertyNamedNodeStructure, TypedNodeStructure, QuestionTokenableNodeStructure, JSDocableNodeStructure, ReadonlyableNodeStructure, InitializerExpressionableNodeStructure {
  9823. }
  9824. interface PropertySignatureSpecificStructure extends KindedStructure<StructureKind.PropertySignature> {
  9825. }
  9826. export interface JsxAttributedNodeStructure {
  9827. attributes?: (OptionalKind<JsxAttributeStructure> | JsxSpreadAttributeStructure)[];
  9828. }
  9829. export interface JsxTagNamedNodeStructure {
  9830. name: string;
  9831. }
  9832. export interface JsxAttributeStructure extends Structure, JsxAttributeSpecificStructure {
  9833. }
  9834. interface JsxAttributeSpecificStructure extends KindedStructure<StructureKind.JsxAttribute> {
  9835. name: string | JsxNamespacedNameStructure;
  9836. initializer?: string;
  9837. }
  9838. export interface JsxElementStructure extends Structure, JsxElementSpecificStructure {
  9839. }
  9840. interface JsxElementSpecificStructure extends KindedStructure<StructureKind.JsxElement> {
  9841. name: string;
  9842. attributes?: (OptionalKind<JsxAttributeStructure> | JsxSpreadAttributeStructure)[];
  9843. children?: (OptionalKind<JsxElementStructure> | JsxSelfClosingElementStructure)[];
  9844. bodyText?: string;
  9845. }
  9846. export interface JsxNamespacedNameStructure {
  9847. namespace: string;
  9848. name: string;
  9849. }
  9850. export interface JsxSelfClosingElementStructure extends Structure, JsxTagNamedNodeStructure, JsxSelfClosingElementSpecificStructure, JsxAttributedNodeStructure {
  9851. }
  9852. interface JsxSelfClosingElementSpecificStructure extends KindedStructure<StructureKind.JsxSelfClosingElement> {
  9853. }
  9854. export interface JsxSpreadAttributeStructure extends Structure, JsxSpreadAttributeSpecificStructure {
  9855. }
  9856. interface JsxSpreadAttributeSpecificStructure extends KindedStructure<StructureKind.JsxSpreadAttribute> {
  9857. expression: string;
  9858. }
  9859. export interface ExportAssignmentStructure extends Structure, ExportAssignmentSpecificStructure, JSDocableNodeStructure {
  9860. }
  9861. interface ExportAssignmentSpecificStructure extends KindedStructure<StructureKind.ExportAssignment> {
  9862. isExportEquals?: boolean;
  9863. expression: string | WriterFunction;
  9864. }
  9865. export interface ExportDeclarationStructure extends Structure, ExportDeclarationSpecificStructure {
  9866. }
  9867. interface ExportDeclarationSpecificStructure extends KindedStructure<StructureKind.ExportDeclaration> {
  9868. isTypeOnly?: boolean;
  9869. namespaceExport?: string;
  9870. namedExports?: (string | OptionalKind<ExportSpecifierStructure> | WriterFunction)[] | WriterFunction;
  9871. moduleSpecifier?: string;
  9872. attributes?: OptionalKind<ImportAttributeStructure>[] | undefined;
  9873. }
  9874. export interface ExportSpecifierStructure extends Structure, ExportSpecifierSpecificStructure {
  9875. }
  9876. interface ExportSpecifierSpecificStructure extends KindedStructure<StructureKind.ExportSpecifier> {
  9877. name: string;
  9878. alias?: string;
  9879. isTypeOnly?: boolean;
  9880. }
  9881. export interface ImportAttributeStructure extends Structure, ImportAttributeStructureSpecificStructure, ImportAttributeNamedNodeStructure {
  9882. }
  9883. interface ImportAttributeStructureSpecificStructure extends KindedStructure<StructureKind.ImportAttribute> {
  9884. /** Expression value. Quote this when providing a string. */
  9885. value: string;
  9886. }
  9887. export interface ImportDeclarationStructure extends Structure, ImportDeclarationSpecificStructure {
  9888. }
  9889. interface ImportDeclarationSpecificStructure extends KindedStructure<StructureKind.ImportDeclaration> {
  9890. isTypeOnly?: boolean;
  9891. defaultImport?: string;
  9892. namespaceImport?: string;
  9893. namedImports?: (OptionalKind<ImportSpecifierStructure> | string | WriterFunction)[] | WriterFunction;
  9894. moduleSpecifier: string;
  9895. attributes?: OptionalKind<ImportAttributeStructure>[] | undefined;
  9896. }
  9897. export interface ImportSpecifierStructure extends Structure, ImportSpecifierSpecificStructure {
  9898. }
  9899. interface ImportSpecifierSpecificStructure extends KindedStructure<StructureKind.ImportSpecifier> {
  9900. name: string;
  9901. isTypeOnly?: boolean;
  9902. alias?: string;
  9903. }
  9904. export interface ModuleDeclarationStructure extends Structure, ModuleNamedNodeStructure, ModuleDeclarationSpecificStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure, StatementedNodeStructure {
  9905. }
  9906. interface ModuleDeclarationSpecificStructure extends KindedStructure<StructureKind.Module> {
  9907. /**
  9908. * The module declaration kind.
  9909. *
  9910. * @remarks Defaults to "namespace".
  9911. */
  9912. declarationKind?: ModuleDeclarationKind;
  9913. }
  9914. export interface SourceFileStructure extends Structure, SourceFileSpecificStructure, StatementedNodeStructure {
  9915. }
  9916. interface SourceFileSpecificStructure {
  9917. kind: StructureKind.SourceFile;
  9918. }
  9919. export interface StatementedNodeStructure {
  9920. statements?: (string | WriterFunction | StatementStructures)[] | string | WriterFunction;
  9921. }
  9922. export interface VariableDeclarationStructure extends Structure, VariableDeclarationSpecificStructure, BindingNamedNodeStructure, InitializerExpressionableNodeStructure, TypedNodeStructure, ExclamationTokenableNodeStructure {
  9923. }
  9924. interface VariableDeclarationSpecificStructure extends KindedStructure<StructureKind.VariableDeclaration> {
  9925. }
  9926. export interface VariableStatementStructure extends Structure, VariableStatementSpecificStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
  9927. }
  9928. interface VariableStatementSpecificStructure extends KindedStructure<StructureKind.VariableStatement> {
  9929. declarationKind?: VariableDeclarationKind;
  9930. declarations: OptionalKind<VariableDeclarationStructure>[];
  9931. }
  9932. export interface Structure {
  9933. /** Leading comments or whitespace. */
  9934. leadingTrivia?: string | WriterFunction | (string | WriterFunction)[];
  9935. /** Trailing comments or whitespace. */
  9936. trailingTrivia?: string | WriterFunction | (string | WriterFunction)[];
  9937. }
  9938. /** Type guards for use on structures. */
  9939. export declare const Structure: {
  9940. /**
  9941. * Gets if the provided structure has a name.
  9942. */
  9943. readonly hasName: <T extends Structure>(structure: T) => structure is T & {
  9944. name: string;
  9945. };
  9946. /** Gets if the provided structure is a CallSignatureDeclarationStructure. */
  9947. readonly isCallSignature: (structure: unknown) => structure is CallSignatureDeclarationStructure;
  9948. /** Gets if the provided structure is a JSDocableNodeStructure. */
  9949. readonly isJSDocable: <T_1>(structure: T_1) => structure is T_1 & JSDocableNodeStructure;
  9950. /** Gets if the provided structure is a SignaturedDeclarationStructure. */
  9951. readonly isSignatured: <T_2>(structure: T_2) => structure is T_2 & SignaturedDeclarationStructure;
  9952. /** Gets if the provided structure is a ParameteredNodeStructure. */
  9953. readonly isParametered: <T_3>(structure: T_3) => structure is T_3 & ParameteredNodeStructure;
  9954. /** Gets if the provided structure is a ReturnTypedNodeStructure. */
  9955. readonly isReturnTyped: <T_4>(structure: T_4) => structure is T_4 & ReturnTypedNodeStructure;
  9956. /** Gets if the provided structure is a TypeParameteredNodeStructure. */
  9957. readonly isTypeParametered: <T_5>(structure: T_5) => structure is T_5 & TypeParameteredNodeStructure;
  9958. /** Gets if the provided structure is a ClassDeclarationStructure. */
  9959. readonly isClass: (structure: unknown) => structure is ClassDeclarationStructure;
  9960. /** Gets if the provided structure is a ClassLikeDeclarationBaseStructure. */
  9961. readonly isClassLikeDeclarationBase: <T_6>(structure: T_6) => structure is T_6 & ClassLikeDeclarationBaseStructure;
  9962. /** Gets if the provided structure is a NameableNodeStructure. */
  9963. readonly isNameable: <T_7>(structure: T_7) => structure is T_7 & NameableNodeStructure;
  9964. /** Gets if the provided structure is a ImplementsClauseableNodeStructure. */
  9965. readonly isImplementsClauseable: <T_8>(structure: T_8) => structure is T_8 & ImplementsClauseableNodeStructure;
  9966. /** Gets if the provided structure is a DecoratableNodeStructure. */
  9967. readonly isDecoratable: <T_9>(structure: T_9) => structure is T_9 & DecoratableNodeStructure;
  9968. /** Gets if the provided structure is a AbstractableNodeStructure. */
  9969. readonly isAbstractable: <T_10>(structure: T_10) => structure is T_10 & AbstractableNodeStructure;
  9970. /** Gets if the provided structure is a AmbientableNodeStructure. */
  9971. readonly isAmbientable: <T_11>(structure: T_11) => structure is T_11 & AmbientableNodeStructure;
  9972. /** Gets if the provided structure is a ExportableNodeStructure. */
  9973. readonly isExportable: <T_12>(structure: T_12) => structure is T_12 & ExportableNodeStructure;
  9974. /** Gets if the provided structure is a ClassStaticBlockDeclarationStructure. */
  9975. readonly isClassStaticBlock: (structure: unknown) => structure is ClassStaticBlockDeclarationStructure;
  9976. /** Gets if the provided structure is a StatementedNodeStructure. */
  9977. readonly isStatemented: <T_13>(structure: T_13) => structure is T_13 & StatementedNodeStructure;
  9978. /** Gets if the provided structure is a ConstructorDeclarationOverloadStructure. */
  9979. readonly isConstructorDeclarationOverload: (structure: unknown) => structure is ConstructorDeclarationOverloadStructure;
  9980. /** Gets if the provided structure is a ScopedNodeStructure. */
  9981. readonly isScoped: <T_14>(structure: T_14) => structure is T_14 & ScopedNodeStructure;
  9982. /** Gets if the provided structure is a ConstructorDeclarationStructure. */
  9983. readonly isConstructor: (structure: unknown) => structure is ConstructorDeclarationStructure;
  9984. /** Gets if the provided structure is a FunctionLikeDeclarationStructure. */
  9985. readonly isFunctionLike: <T_15>(structure: T_15) => structure is T_15 & FunctionLikeDeclarationStructure;
  9986. /** Gets if the provided structure is a ConstructSignatureDeclarationStructure. */
  9987. readonly isConstructSignature: (structure: unknown) => structure is ConstructSignatureDeclarationStructure;
  9988. /** Gets if the provided structure is a DecoratorStructure. */
  9989. readonly isDecorator: (structure: unknown) => structure is DecoratorStructure;
  9990. /** Gets if the provided structure is a EnumDeclarationStructure. */
  9991. readonly isEnum: (structure: unknown) => structure is EnumDeclarationStructure;
  9992. /** Gets if the provided structure is a NamedNodeStructure. */
  9993. readonly isNamed: <T_16>(structure: T_16) => structure is T_16 & NamedNodeStructure;
  9994. /** Gets if the provided structure is a EnumMemberStructure. */
  9995. readonly isEnumMember: (structure: unknown) => structure is EnumMemberStructure;
  9996. /** Gets if the provided structure is a PropertyNamedNodeStructure. */
  9997. readonly isPropertyNamed: <T_17>(structure: T_17) => structure is T_17 & PropertyNamedNodeStructure;
  9998. /** Gets if the provided structure is a InitializerExpressionableNodeStructure. */
  9999. readonly isInitializerExpressionable: <T_18>(structure: T_18) => structure is T_18 & InitializerExpressionableNodeStructure;
  10000. /** Gets if the provided structure is a ExportAssignmentStructure. */
  10001. readonly isExportAssignment: (structure: unknown) => structure is ExportAssignmentStructure;
  10002. /** Gets if the provided structure is a ExportDeclarationStructure. */
  10003. readonly isExportDeclaration: (structure: unknown) => structure is ExportDeclarationStructure;
  10004. /** Gets if the provided structure is a ExportSpecifierStructure. */
  10005. readonly isExportSpecifier: (structure: unknown) => structure is ExportSpecifierStructure;
  10006. /** Gets if the provided structure is a FunctionDeclarationOverloadStructure. */
  10007. readonly isFunctionDeclarationOverload: (structure: unknown) => structure is FunctionDeclarationOverloadStructure;
  10008. /** Gets if the provided structure is a AsyncableNodeStructure. */
  10009. readonly isAsyncable: <T_19>(structure: T_19) => structure is T_19 & AsyncableNodeStructure;
  10010. /** Gets if the provided structure is a GeneratorableNodeStructure. */
  10011. readonly isGeneratorable: <T_20>(structure: T_20) => structure is T_20 & GeneratorableNodeStructure;
  10012. /** Gets if the provided structure is a FunctionDeclarationStructure. */
  10013. readonly isFunction: (structure: unknown) => structure is FunctionDeclarationStructure;
  10014. /** Gets if the provided structure is a GetAccessorDeclarationStructure. */
  10015. readonly isGetAccessor: (structure: unknown) => structure is GetAccessorDeclarationStructure;
  10016. /** Gets if the provided structure is a StaticableNodeStructure. */
  10017. readonly isStaticable: <T_21>(structure: T_21) => structure is T_21 & StaticableNodeStructure;
  10018. /** Gets if the provided structure is a ImportAttributeStructure. */
  10019. readonly isImportAttribute: (structure: unknown) => structure is ImportAttributeStructure;
  10020. /** Gets if the provided structure is a ImportAttributeNamedNodeStructure. */
  10021. readonly isImportAttributeNamed: <T_22>(structure: T_22) => structure is T_22 & ImportAttributeNamedNodeStructure;
  10022. /** Gets if the provided structure is a ImportDeclarationStructure. */
  10023. readonly isImportDeclaration: (structure: unknown) => structure is ImportDeclarationStructure;
  10024. /** Gets if the provided structure is a ImportSpecifierStructure. */
  10025. readonly isImportSpecifier: (structure: unknown) => structure is ImportSpecifierStructure;
  10026. /** Gets if the provided structure is a IndexSignatureDeclarationStructure. */
  10027. readonly isIndexSignature: (structure: unknown) => structure is IndexSignatureDeclarationStructure;
  10028. /** Gets if the provided structure is a ReadonlyableNodeStructure. */
  10029. readonly isReadonlyable: <T_23>(structure: T_23) => structure is T_23 & ReadonlyableNodeStructure;
  10030. /** Gets if the provided structure is a InterfaceDeclarationStructure. */
  10031. readonly isInterface: (structure: unknown) => structure is InterfaceDeclarationStructure;
  10032. /** Gets if the provided structure is a ExtendsClauseableNodeStructure. */
  10033. readonly isExtendsClauseable: <T_24>(structure: T_24) => structure is T_24 & ExtendsClauseableNodeStructure;
  10034. /** Gets if the provided structure is a TypeElementMemberedNodeStructure. */
  10035. readonly isTypeElementMembered: <T_25>(structure: T_25) => structure is T_25 & TypeElementMemberedNodeStructure;
  10036. /** Gets if the provided structure is a JSDocStructure. */
  10037. readonly isJSDoc: (structure: unknown) => structure is JSDocStructure;
  10038. /** Gets if the provided structure is a JSDocTagStructure. */
  10039. readonly isJSDocTag: (structure: unknown) => structure is JSDocTagStructure;
  10040. /** Gets if the provided structure is a JsxAttributeStructure. */
  10041. readonly isJsxAttribute: (structure: unknown) => structure is JsxAttributeStructure;
  10042. /** Gets if the provided structure is a JsxElementStructure. */
  10043. readonly isJsxElement: (structure: unknown) => structure is JsxElementStructure;
  10044. /** Gets if the provided structure is a JsxSelfClosingElementStructure. */
  10045. readonly isJsxSelfClosingElement: (structure: unknown) => structure is JsxSelfClosingElementStructure;
  10046. /** Gets if the provided structure is a JsxTagNamedNodeStructure. */
  10047. readonly isJsxTagNamed: <T_26>(structure: T_26) => structure is T_26 & JsxTagNamedNodeStructure;
  10048. /** Gets if the provided structure is a JsxAttributedNodeStructure. */
  10049. readonly isJsxAttributed: <T_27>(structure: T_27) => structure is T_27 & JsxAttributedNodeStructure;
  10050. /** Gets if the provided structure is a JsxSpreadAttributeStructure. */
  10051. readonly isJsxSpreadAttribute: (structure: unknown) => structure is JsxSpreadAttributeStructure;
  10052. /** Gets if the provided structure is a MethodDeclarationOverloadStructure. */
  10053. readonly isMethodDeclarationOverload: (structure: unknown) => structure is MethodDeclarationOverloadStructure;
  10054. /** Gets if the provided structure is a QuestionTokenableNodeStructure. */
  10055. readonly isQuestionTokenable: <T_28>(structure: T_28) => structure is T_28 & QuestionTokenableNodeStructure;
  10056. /** Gets if the provided structure is a OverrideableNodeStructure. */
  10057. readonly isOverrideable: <T_29>(structure: T_29) => structure is T_29 & OverrideableNodeStructure;
  10058. /** Gets if the provided structure is a MethodDeclarationStructure. */
  10059. readonly isMethod: (structure: unknown) => structure is MethodDeclarationStructure;
  10060. /** Gets if the provided structure is a MethodSignatureStructure. */
  10061. readonly isMethodSignature: (structure: unknown) => structure is MethodSignatureStructure;
  10062. /** Gets if the provided structure is a ModuleDeclarationStructure. */
  10063. readonly isModule: (structure: unknown) => structure is ModuleDeclarationStructure;
  10064. /** Gets if the provided structure is a ModuleNamedNodeStructure. */
  10065. readonly isModuleNamed: <T_30>(structure: T_30) => structure is T_30 & ModuleNamedNodeStructure;
  10066. /** Gets if the provided structure is a ParameterDeclarationStructure. */
  10067. readonly isParameter: (structure: unknown) => structure is ParameterDeclarationStructure;
  10068. /** Gets if the provided structure is a BindingNamedNodeStructure. */
  10069. readonly isBindingNamed: <T_31>(structure: T_31) => structure is T_31 & BindingNamedNodeStructure;
  10070. /** Gets if the provided structure is a TypedNodeStructure. */
  10071. readonly isTyped: <T_32>(structure: T_32) => structure is T_32 & TypedNodeStructure;
  10072. /** Gets if the provided structure is a ScopeableNodeStructure. */
  10073. readonly isScopeable: <T_33>(structure: T_33) => structure is T_33 & ScopeableNodeStructure;
  10074. /** Gets if the provided structure is a PropertyAssignmentStructure. */
  10075. readonly isPropertyAssignment: (structure: unknown) => structure is PropertyAssignmentStructure;
  10076. /** Gets if the provided structure is a PropertyDeclarationStructure. */
  10077. readonly isProperty: (structure: unknown) => structure is PropertyDeclarationStructure;
  10078. /** Gets if the provided structure is a ExclamationTokenableNodeStructure. */
  10079. readonly isExclamationTokenable: <T_34>(structure: T_34) => structure is T_34 & ExclamationTokenableNodeStructure;
  10080. /** Gets if the provided structure is a PropertySignatureStructure. */
  10081. readonly isPropertySignature: (structure: unknown) => structure is PropertySignatureStructure;
  10082. /** Gets if the provided structure is a SetAccessorDeclarationStructure. */
  10083. readonly isSetAccessor: (structure: unknown) => structure is SetAccessorDeclarationStructure;
  10084. /** Gets if the provided structure is a ShorthandPropertyAssignmentStructure. */
  10085. readonly isShorthandPropertyAssignment: (structure: unknown) => structure is ShorthandPropertyAssignmentStructure;
  10086. /** Gets if the provided structure is a SourceFileStructure. */
  10087. readonly isSourceFile: (structure: unknown) => structure is SourceFileStructure;
  10088. /** Gets if the provided structure is a SpreadAssignmentStructure. */
  10089. readonly isSpreadAssignment: (structure: unknown) => structure is SpreadAssignmentStructure;
  10090. /** Gets if the provided structure is a ExpressionedNodeStructure. */
  10091. readonly isExpressioned: <T_35>(structure: T_35) => structure is T_35 & ExpressionedNodeStructure;
  10092. /** Gets if the provided structure is a TypeAliasDeclarationStructure. */
  10093. readonly isTypeAlias: (structure: unknown) => structure is TypeAliasDeclarationStructure;
  10094. /** Gets if the provided structure is a TypeParameterDeclarationStructure. */
  10095. readonly isTypeParameter: (structure: unknown) => structure is TypeParameterDeclarationStructure;
  10096. /** Gets if the provided structure is a VariableDeclarationStructure. */
  10097. readonly isVariableDeclaration: (structure: unknown) => structure is VariableDeclarationStructure;
  10098. /** Gets if the provided structure is a VariableStatementStructure. */
  10099. readonly isVariableStatement: (structure: unknown) => structure is VariableStatementStructure;
  10100. };
  10101. export interface KindedStructure<TKind extends StructureKind> {
  10102. kind: TKind;
  10103. }
  10104. export declare enum StructureKind {
  10105. ImportAttribute = 0,
  10106. CallSignature = 1,
  10107. Class = 2,
  10108. ClassStaticBlock = 3,
  10109. ConstructSignature = 4,
  10110. Constructor = 5,
  10111. ConstructorOverload = 6,
  10112. Decorator = 7,
  10113. Enum = 8,
  10114. EnumMember = 9,
  10115. ExportAssignment = 10,
  10116. ExportDeclaration = 11,
  10117. ExportSpecifier = 12,
  10118. Function = 13,
  10119. FunctionOverload = 14,
  10120. GetAccessor = 15,
  10121. ImportDeclaration = 16,
  10122. ImportSpecifier = 17,
  10123. IndexSignature = 18,
  10124. Interface = 19,
  10125. JsxAttribute = 20,
  10126. JsxSpreadAttribute = 21,
  10127. JsxElement = 22,
  10128. JsxSelfClosingElement = 23,
  10129. JSDoc = 24,
  10130. JSDocTag = 25,
  10131. Method = 26,
  10132. MethodOverload = 27,
  10133. MethodSignature = 28,
  10134. Module = 29,
  10135. Parameter = 30,
  10136. Property = 31,
  10137. PropertyAssignment = 32,
  10138. PropertySignature = 33,
  10139. SetAccessor = 34,
  10140. ShorthandPropertyAssignment = 35,
  10141. SourceFile = 36,
  10142. SpreadAssignment = 37,
  10143. TypeAlias = 38,
  10144. TypeParameter = 39,
  10145. VariableDeclaration = 40,
  10146. VariableStatement = 41
  10147. }
  10148. export interface TypeAliasDeclarationStructure extends Structure, TypeAliasDeclarationSpecificStructure, NamedNodeStructure, TypedNodeStructure, TypeParameteredNodeStructure, JSDocableNodeStructure, AmbientableNodeStructure, ExportableNodeStructure {
  10149. type: string | WriterFunction;
  10150. }
  10151. interface TypeAliasDeclarationSpecificStructure extends KindedStructure<StructureKind.TypeAlias> {
  10152. type: string | WriterFunction;
  10153. }
  10154. export interface TypeParameterDeclarationStructure extends Structure, TypeParameterDeclarationSpecificStructure, NamedNodeStructure {
  10155. }
  10156. interface TypeParameterDeclarationSpecificStructure extends KindedStructure<StructureKind.TypeParameter> {
  10157. isConst?: boolean;
  10158. constraint?: string | WriterFunction;
  10159. default?: string | WriterFunction;
  10160. variance?: TypeParameterVariance;
  10161. }
  10162. export type OptionalKind<TStructure extends {
  10163. kind?: StructureKind;
  10164. }> = Pick<TStructure, Exclude<keyof TStructure, "kind">> & Partial<Pick<TStructure, "kind">>;
  10165. /**
  10166. * Iterates over the elements in the provided array.
  10167. * @param structures - Array of structures to iterate over.
  10168. * @param callback - Callback to do on each element in the array. Returning a truthy value will return that value in the main function call.
  10169. */
  10170. export declare function forEachStructureChild<TStructure>(structures: ReadonlyArray<Structures>, callback: (child: Structures) => TStructure | void): TStructure | undefined;
  10171. /**
  10172. * Iterates over the children of the provided array.
  10173. * @remarks If the children do not have a `kind` property, it will be automatically added.
  10174. * @param structure - Structure to iterate over.
  10175. * @param callback - Callback to do on each child of the provided structure. Returning a truthy value will return that value in the main function call.
  10176. */
  10177. export declare function forEachStructureChild<TStructure>(structure: Structures, callback: (child: Structures) => TStructure | void): TStructure | undefined;
  10178. import { CompilerOptions, DiagnosticCategory, EditorSettings, EmitHint, LanguageVariant, ModuleKind, ModuleResolutionKind, NewLineKind, NodeFlags, ObjectFlags, ScriptKind, ScriptTarget, SymbolFlags, SyntaxKind, TypeFlags, TypeFormatFlags } from "@ts-morph/common";
  10179. export { ts, CompilerOptions, DiagnosticCategory, EditorSettings, EmitHint, LanguageVariant, ModuleKind, ModuleResolutionKind, NewLineKind, NodeFlags, ObjectFlags, ScriptKind, ScriptTarget, SymbolFlags, SyntaxKind, TypeFlags, TypeFormatFlags };
  10180. /** Code writer that assists with formatting and visualizing blocks of JavaScript or TypeScript code. */
  10181. export declare class CodeBlockWriter {
  10182. /**
  10183. * Constructor.
  10184. * @param opts - Options for the writer.
  10185. */
  10186. constructor(opts?: Partial<CodeBlockWriterOptions>);
  10187. /** Gets the options. */
  10188. getOptions(): CodeBlockWriterOptions;
  10189. /**
  10190. * Queues the indentation level for the next lines written.
  10191. * @param indentationLevel - Indentation level to queue.
  10192. */
  10193. queueIndentationLevel(indentationLevel: number): this;
  10194. /**
  10195. * Queues the indentation level for the next lines written using the provided indentation text.
  10196. * @param whitespaceText - Gets the indentation level from the indentation text.
  10197. */
  10198. queueIndentationLevel(whitespaceText: string): this;
  10199. /**
  10200. * Writes the text within the provided action with hanging indentation.
  10201. * @param action - Action to perform with hanging indentation.
  10202. */
  10203. hangingIndent(action: () => void): this;
  10204. /**
  10205. * Writes the text within the provided action with hanging indentation unless writing a block.
  10206. * @param action - Action to perform with hanging indentation unless a block is written.
  10207. */
  10208. hangingIndentUnlessBlock(action: () => void): this;
  10209. /**
  10210. * Sets the current indentation level.
  10211. * @param indentationLevel - Indentation level to be at.
  10212. */
  10213. setIndentationLevel(indentationLevel: number): this;
  10214. /**
  10215. * Sets the current indentation using the provided indentation text.
  10216. * @param whitespaceText - Gets the indentation level from the indentation text.
  10217. */
  10218. setIndentationLevel(whitespaceText: string): this;
  10219. /**
  10220. * Sets the indentation level within the provided action and restores the writer's indentation
  10221. * state afterwards.
  10222. * @remarks Restores the writer's state after the action.
  10223. * @param indentationLevel - Indentation level to set.
  10224. * @param action - Action to perform with the indentation.
  10225. */
  10226. withIndentationLevel(indentationLevel: number, action: () => void): this;
  10227. /**
  10228. * Sets the indentation level with the provided indentation text within the provided action
  10229. * and restores the writer's indentation state afterwards.
  10230. * @param whitespaceText - Gets the indentation level from the indentation text.
  10231. * @param action - Action to perform with the indentation.
  10232. */
  10233. withIndentationLevel(whitespaceText: string, action: () => void): this;
  10234. /** Gets the current indentation level. */
  10235. getIndentationLevel(): number;
  10236. /**
  10237. * Writes a block using braces.
  10238. * @param block - Write using the writer within this block.
  10239. */
  10240. block(block?: () => void): this;
  10241. /**
  10242. * Writes an inline block with braces.
  10243. * @param block - Write using the writer within this block.
  10244. */
  10245. inlineBlock(block?: () => void): this;
  10246. /** Indents the code one level for the current line. */
  10247. indent(times?: number): this;
  10248. /**
  10249. * Indents a block of code.
  10250. * @param block - Block to indent.
  10251. */
  10252. indent(block: () => void): this;
  10253. /**
  10254. * Conditionally writes a line of text.
  10255. * @param condition - Condition to evaluate.
  10256. * @param textFunc - A function that returns a string to write if the condition is true.
  10257. */
  10258. conditionalWriteLine(condition: boolean | undefined, textFunc: () => string): this;
  10259. /**
  10260. * Conditionally writes a line of text.
  10261. * @param condition - Condition to evaluate.
  10262. * @param text - Text to write if the condition is true.
  10263. */
  10264. conditionalWriteLine(condition: boolean | undefined, text: string): this;
  10265. /**
  10266. * Writes a line of text.
  10267. * @param text - String to write.
  10268. */
  10269. writeLine(text: string): this;
  10270. /** Writes a newline if the last line was not a newline. */
  10271. newLineIfLastNot(): this;
  10272. /** Writes a blank line if the last written text was not a blank line. */
  10273. blankLineIfLastNot(): this;
  10274. /**
  10275. * Writes a blank line if the condition is true.
  10276. * @param condition - Condition to evaluate.
  10277. */
  10278. conditionalBlankLine(condition: boolean | undefined): this;
  10279. /** Writes a blank line. */
  10280. blankLine(): this;
  10281. /**
  10282. * Writes a newline if the condition is true.
  10283. * @param condition - Condition to evaluate.
  10284. */
  10285. conditionalNewLine(condition: boolean | undefined): this;
  10286. /** Writes a newline. */
  10287. newLine(): this;
  10288. /** Writes a quote character. */
  10289. quote(): this;
  10290. /**
  10291. * Writes text surrounded in quotes.
  10292. * @param text - Text to write.
  10293. */
  10294. quote(text: string): this;
  10295. /** Writes a space if the last character was not a space. */
  10296. spaceIfLastNot(): this;
  10297. /**
  10298. * Writes a space.
  10299. * @param times - Number of times to write a space.
  10300. */
  10301. space(times?: number): this;
  10302. /** Writes a tab if the last character was not a tab. */
  10303. tabIfLastNot(): this;
  10304. /**
  10305. * Writes a tab.
  10306. * @param times - Number of times to write a tab.
  10307. */
  10308. tab(times?: number): this;
  10309. /**
  10310. * Conditionally writes text.
  10311. * @param condition - Condition to evaluate.
  10312. * @param textFunc - A function that returns a string to write if the condition is true.
  10313. */
  10314. conditionalWrite(condition: boolean | undefined, textFunc: () => string): this;
  10315. /**
  10316. * Conditionally writes text.
  10317. * @param condition - Condition to evaluate.
  10318. * @param text - Text to write if the condition is true.
  10319. */
  10320. conditionalWrite(condition: boolean | undefined, text: string): this;
  10321. /**
  10322. * Writes the provided text.
  10323. * @param text - Text to write.
  10324. */
  10325. write(text: string): this;
  10326. /** Writes text to exit a comment if in a comment. */
  10327. closeComment(): this;
  10328. /**
  10329. * Inserts text at the provided position.
  10330. *
  10331. * This method is "unsafe" because it won't update the state of the writer unless
  10332. * inserting at the end position. It is biased towards being fast at inserting closer
  10333. * to the start or end, but slower to insert in the middle. Only use this if
  10334. * absolutely necessary.
  10335. * @param pos - Position to insert at.
  10336. * @param text - Text to insert.
  10337. */
  10338. unsafeInsert(pos: number, text: string): this;
  10339. /** Gets the length of the string in the writer. */
  10340. getLength(): number;
  10341. /** Gets if the writer is currently in a comment. */
  10342. isInComment(): boolean;
  10343. /** Gets if the writer is currently at the start of the first line of the text, block, or indentation block. */
  10344. isAtStartOfFirstLineOfBlock(): boolean;
  10345. /** Gets if the writer is currently on the first line of the text, block, or indentation block. */
  10346. isOnFirstLineOfBlock(): boolean;
  10347. /** Gets if the writer is currently in a string. */
  10348. isInString(): boolean;
  10349. /** Gets if the last chars written were for a newline. */
  10350. isLastNewLine(): boolean;
  10351. /** Gets if the last chars written were for a blank line. */
  10352. isLastBlankLine(): boolean;
  10353. /** Gets if the last char written was a space. */
  10354. isLastSpace(): boolean;
  10355. /** Gets if the last char written was a tab. */
  10356. isLastTab(): boolean;
  10357. /** Gets the last char written. */
  10358. getLastChar(): string | undefined;
  10359. /**
  10360. * Gets if the writer ends with the provided text.
  10361. * @param text - Text to check if the writer ends with the provided text.
  10362. */
  10363. endsWith(text: string): boolean;
  10364. /**
  10365. * Iterates over the writer characters in reverse order. The iteration stops when a non-null or
  10366. * undefined value is returned from the action. The returned value is then returned by the method.
  10367. *
  10368. * @remarks It is much more efficient to use this method rather than `#toString()` since `#toString()`
  10369. * will combine the internal array into a string.
  10370. */
  10371. iterateLastChars<T>(action: (char: string, index: number) => T | undefined): T | undefined;
  10372. /**
  10373. * Iterates over the writer character char codes in reverse order. The iteration stops when a non-null or
  10374. * undefined value is returned from the action. The returned value is then returned by the method.
  10375. *
  10376. * @remarks It is much more efficient to use this method rather than `#toString()` since `#toString()`
  10377. * will combine the internal array into a string. Additionally, this is slightly more efficient that
  10378. * `iterateLastChars` as this won't allocate a string per character.
  10379. */
  10380. iterateLastCharCodes<T>(action: (charCode: number, index: number) => T | undefined): T | undefined;
  10381. /** Gets the writer's text. */
  10382. toString(): string;
  10383. }
  10384. /** Options for the writer. */
  10385. export interface CodeBlockWriterOptions {
  10386. /**
  10387. * Newline character.
  10388. * @remarks Defaults to \n.
  10389. */
  10390. newLine: "\n" | "\r\n";
  10391. /**
  10392. * Number of spaces to indent when `useTabs` is false.
  10393. * @remarks Defaults to 4.
  10394. */
  10395. indentNumberOfSpaces: number;
  10396. /**
  10397. * Whether to use tabs (true) or spaces (false).
  10398. * @remarks Defaults to false.
  10399. */
  10400. useTabs: boolean;
  10401. /**
  10402. * Whether to use a single quote (true) or double quote (false).
  10403. * @remarks Defaults to false.
  10404. */
  10405. useSingleQuote: boolean;
  10406. }