@@ -5,6 +5,7 @@ import { SignatureFlags } from "#enums/signatureFlags";
55import { SignatureKind } from "#enums/signatureKind" ;
66import { SymbolFlags } from "#enums/symbolFlags" ;
77import { TypeFlags } from "#enums/typeFlags" ;
8+ import { TypePredicateKind } from "#enums/typePredicateKind" ;
89import type {
910 Expression ,
1011 Node ,
@@ -39,11 +40,13 @@ import type {
3940 ConfigResponse ,
4041 DocumentIdentifier ,
4142 DocumentPosition ,
43+ IndexInfoResponse ,
4244 InitializeResponse ,
4345 LSPUpdateSnapshotParams ,
4446 ProjectResponse ,
4547 SignatureResponse ,
4648 SymbolResponse ,
49+ TypePredicateResponse ,
4750 TypeResponse ,
4851 UpdateSnapshotParams ,
4952 UpdateSnapshotResponse ,
@@ -56,8 +59,12 @@ import {
5659 type ClientSpawnOptions ,
5760} from "./client.ts" ;
5861import type {
62+ AssertsIdentifierTypePredicate ,
63+ AssertsThisTypePredicate ,
5964 ConditionalType ,
65+ IdentifierTypePredicate ,
6066 IndexedAccessType ,
67+ IndexInfo ,
6168 IndexType ,
6269 InterfaceType ,
6370 IntersectionType ,
@@ -66,17 +73,20 @@ import type {
6673 StringMappingType ,
6774 SubstitutionType ,
6875 TemplateLiteralType ,
76+ ThisTypePredicate ,
6977 TupleType ,
7078 Type ,
7179 TypeParameter ,
80+ TypePredicate ,
81+ TypePredicateBase ,
7282 TypeReference ,
7383 UnionOrIntersectionType ,
7484 UnionType ,
7585} from "./types.ts" ;
7686
77- export { ElementFlags , ObjectFlags , SignatureFlags , SignatureKind , SymbolFlags , TypeFlags } ;
87+ export { ElementFlags , ObjectFlags , SignatureFlags , SignatureKind , SymbolFlags , TypeFlags , TypePredicateKind } ;
7888export type { APIOptions , ClientSocketOptions , ClientSpawnOptions , DocumentIdentifier , DocumentPosition , LSPConnectionOptions } ;
79- export type { ConditionalType , IndexedAccessType , IndexType , InterfaceType , IntersectionType , LiteralType , ObjectType , StringMappingType , SubstitutionType , TemplateLiteralType , TupleType , TypeParameter , TypeReference , UnionOrIntersectionType , UnionType } ;
89+ export type { AssertsIdentifierTypePredicate , AssertsThisTypePredicate , ConditionalType , IdentifierTypePredicate , IndexedAccessType , IndexInfo , IndexType , InterfaceType , IntersectionType , LiteralType , ObjectType , StringMappingType , SubstitutionType , TemplateLiteralType , ThisTypePredicate , TupleType , TypeParameter , TypePredicate , TypePredicateBase , TypeReference , UnionOrIntersectionType , UnionType } ;
8090export { documentURIToFileName , fileNameToDocumentURI } from "../path.ts" ;
8191
8292/** Type alias for the snapshot-scoped object registry */
@@ -601,6 +611,97 @@ export class Checker {
601611 flags,
602612 } ) ;
603613 }
614+
615+ async isContextSensitive ( node : Node ) : Promise < boolean > {
616+ return this . client . apiRequest < boolean > ( "isContextSensitive" , {
617+ snapshot : this . snapshotId ,
618+ project : this . projectId ,
619+ location : getNodeId ( node ) ,
620+ } ) ;
621+ }
622+
623+ async getReturnTypeOfSignature ( signature : Signature ) : Promise < Type | undefined > {
624+ const data = await this . client . apiRequest < TypeResponse | null > ( "getReturnTypeOfSignature" , {
625+ snapshot : this . snapshotId ,
626+ project : this . projectId ,
627+ signature : signature . id ,
628+ } ) ;
629+ return data ? this . objectRegistry . getOrCreateType ( data ) : undefined ;
630+ }
631+
632+ async getRestTypeOfSignature ( signature : Signature ) : Promise < Type | undefined > {
633+ const data = await this . client . apiRequest < TypeResponse | null > ( "getRestTypeOfSignature" , {
634+ snapshot : this . snapshotId ,
635+ project : this . projectId ,
636+ signature : signature . id ,
637+ } ) ;
638+ return data ? this . objectRegistry . getOrCreateType ( data ) : undefined ;
639+ }
640+
641+ async getTypePredicateOfSignature ( signature : Signature ) : Promise < TypePredicate | undefined > {
642+ const data = await this . client . apiRequest < TypePredicateResponse | null > ( "getTypePredicateOfSignature" , {
643+ snapshot : this . snapshotId ,
644+ project : this . projectId ,
645+ signature : signature . id ,
646+ } ) ;
647+ if ( ! data ) return undefined ;
648+ return {
649+ kind : data . kind ,
650+ parameterIndex : data . parameterIndex ,
651+ parameterName : data . parameterName ,
652+ type : data . type ? this . objectRegistry . getOrCreateType ( data . type ) : undefined ,
653+ } as TypePredicate ;
654+ }
655+
656+ async getBaseTypes ( type : Type ) : Promise < readonly Type [ ] > {
657+ const data = await this . client . apiRequest < TypeResponse [ ] | null > ( "getBaseTypes" , {
658+ snapshot : this . snapshotId ,
659+ project : this . projectId ,
660+ type : type . id ,
661+ } ) ;
662+ return data ? data . map ( d => this . objectRegistry . getOrCreateType ( d ) ) : [ ] ;
663+ }
664+
665+ async getPropertiesOfType ( type : Type ) : Promise < readonly Symbol [ ] > {
666+ const data = await this . client . apiRequest < SymbolResponse [ ] | null > ( "getPropertiesOfType" , {
667+ snapshot : this . snapshotId ,
668+ project : this . projectId ,
669+ type : type . id ,
670+ } ) ;
671+ return data ? data . map ( d => this . objectRegistry . getOrCreateSymbol ( d ) ) : [ ] ;
672+ }
673+
674+ async getIndexInfosOfType ( type : Type ) : Promise < readonly IndexInfo [ ] > {
675+ const data = await this . client . apiRequest < IndexInfoResponse [ ] | null > ( "getIndexInfosOfType" , {
676+ snapshot : this . snapshotId ,
677+ project : this . projectId ,
678+ type : type . id ,
679+ } ) ;
680+ if ( ! data ) return [ ] ;
681+ return data . map ( d => ( {
682+ keyType : this . objectRegistry . getOrCreateType ( d . keyType ) ,
683+ valueType : this . objectRegistry . getOrCreateType ( d . valueType ) ,
684+ isReadonly : d . isReadonly ?? false ,
685+ } ) ) ;
686+ }
687+
688+ async getConstraintOfTypeParameter ( type : Type ) : Promise < Type | undefined > {
689+ const data = await this . client . apiRequest < TypeResponse | null > ( "getConstraintOfTypeParameter" , {
690+ snapshot : this . snapshotId ,
691+ project : this . projectId ,
692+ type : type . id ,
693+ } ) ;
694+ return data ? this . objectRegistry . getOrCreateType ( data ) : undefined ;
695+ }
696+
697+ async getTypeArguments ( type : Type ) : Promise < readonly Type [ ] > {
698+ const data = await this . client . apiRequest < TypeResponse [ ] | null > ( "getTypeArguments" , {
699+ snapshot : this . snapshotId ,
700+ project : this . projectId ,
701+ type : type . id ,
702+ } ) ;
703+ return data ? data . map ( d => this . objectRegistry . getOrCreateType ( d ) ) : [ ] ;
704+ }
604705}
605706
606707export class Emitter {
0 commit comments