mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
14035 lines
679 KiB
TypeScript
14035 lines
679 KiB
TypeScript
/* eslint-disable @typescript-eslint/adjacent-overload-signatures */
|
|
import {
|
|
AstArrayBindingPatternData,
|
|
AstArrayLiteralExpressionData,
|
|
AstArrayTypeNodeData,
|
|
AstArrowFunctionData,
|
|
AstAsExpressionData,
|
|
AstAwaitExpressionData,
|
|
AstBigIntLiteralData,
|
|
AstBinaryExpressionData,
|
|
AstBindingElementData,
|
|
AstBlockData,
|
|
AstBreakStatementData,
|
|
AstBundleData,
|
|
AstCallExpressionData,
|
|
AstCallSignatureDeclarationData,
|
|
AstCaseBlockData,
|
|
AstCaseClauseData,
|
|
AstCatchClauseData,
|
|
AstClassDeclarationData,
|
|
AstClassExpressionData,
|
|
AstClassStaticBlockDeclarationData,
|
|
AstCommaListExpressionData,
|
|
AstComputedPropertyNameData,
|
|
AstConditionalExpressionData,
|
|
AstConditionalTypeNodeData,
|
|
AstConstructorDeclarationData,
|
|
AstConstructorTypeNodeData,
|
|
AstConstructSignatureDeclarationData,
|
|
AstContinueStatementData,
|
|
AstData,
|
|
AstDebuggerStatementData,
|
|
AstDeclarationData,
|
|
AstDecoratorData,
|
|
AstDefaultClauseData,
|
|
AstDeleteExpressionData,
|
|
AstDoStatementData,
|
|
AstElementAccessExpressionData,
|
|
AstEmptyStatementData,
|
|
AstEndOfFileTokenData,
|
|
AstEnumDeclarationData,
|
|
AstEnumMemberData,
|
|
AstExportAssignmentData,
|
|
AstExportDeclarationData,
|
|
AstExportSpecifierData,
|
|
AstExpressionStatementData,
|
|
AstExpressionWithTypeArgumentsData,
|
|
AstExternalModuleReferenceData,
|
|
AstForInStatementData,
|
|
AstForOfStatementData,
|
|
AstForStatementData,
|
|
AstFunctionDeclarationData,
|
|
AstFunctionExpressionData,
|
|
AstFunctionTypeNodeData,
|
|
AstGetAccessorDeclarationData,
|
|
AstHeritageClauseData,
|
|
AstIdentifier,
|
|
AstIdentifierData,
|
|
AstIfStatementData,
|
|
AstImportAttributeData,
|
|
AstImportAttributesData,
|
|
AstImportClauseData,
|
|
AstImportDeclarationData,
|
|
AstImportEqualsDeclarationData,
|
|
AstImportSpecifierData,
|
|
AstImportTypeAssertionContainerData,
|
|
AstImportTypeNodeData,
|
|
AstIndexedAccessTypeNodeData,
|
|
AstIndexSignatureDeclarationData,
|
|
AstInferTypeNodeData,
|
|
AstInterfaceDeclarationData,
|
|
AstIntersectionTypeNodeData,
|
|
AstJSDocAllTypeData,
|
|
AstJSDocAugmentsTagData,
|
|
AstJSDocAuthorTagData,
|
|
AstJSDocCallbackTagData,
|
|
AstJSDocClassReferenceData,
|
|
AstJSDocClassTagData,
|
|
AstJSDocData,
|
|
AstJSDocDeprecatedTagData,
|
|
AstJSDocEnumTagData,
|
|
AstJSDocFunctionTypeData,
|
|
AstJSDocImplementsTagData,
|
|
AstJSDocImportTagData,
|
|
AstJSDocLinkCodeData,
|
|
AstJSDocLinkData,
|
|
AstJSDocLinkPlainData,
|
|
AstJSDocMemberNameData,
|
|
AstJSDocNamepathTypeData,
|
|
AstJSDocNameReferenceData,
|
|
AstJSDocNamespaceDeclarationData,
|
|
AstJSDocNonNullableTypeData,
|
|
AstJSDocNullableTypeData,
|
|
AstJSDocOptionalTypeData,
|
|
AstJSDocOverloadTagData,
|
|
AstJSDocOverrideTagData,
|
|
AstJSDocParameterTagData,
|
|
AstJSDocPrivateTagData,
|
|
AstJSDocPropertyTagData,
|
|
AstJSDocProtectedTagData,
|
|
AstJSDocPublicTagData,
|
|
AstJSDocReadonlyTagData,
|
|
AstJSDocReturnTagData,
|
|
AstJSDocSatisfiesTagData,
|
|
AstJSDocSeeTagData,
|
|
AstJSDocSignatureData,
|
|
AstJSDocTagData,
|
|
AstJSDocTemplateTagData,
|
|
AstJSDocTextData,
|
|
AstJSDocThisTagData,
|
|
AstJSDocThrowsTagData,
|
|
AstJSDocTypedefTagData,
|
|
AstJSDocTypeExpressionData,
|
|
AstJSDocTypeLiteralData,
|
|
AstJSDocTypeTagData,
|
|
AstJSDocUnknownTagData,
|
|
AstJSDocUnknownTypeData,
|
|
AstJSDocVariadicTypeData,
|
|
AstJsonMinusNumericLiteralData,
|
|
AstJsonObjectExpressionStatementData,
|
|
AstJsonSourceFileData,
|
|
AstJsxAttributeData,
|
|
AstJsxAttributesData,
|
|
AstJsxClosingElementData,
|
|
AstJsxClosingFragmentData,
|
|
AstJsxElementData,
|
|
AstJsxExpressionData,
|
|
AstJsxFragmentData,
|
|
AstJsxNamespacedNameData,
|
|
AstJsxOpeningElementData,
|
|
AstJsxOpeningFragmentData,
|
|
AstJsxSelfClosingElementData,
|
|
AstJsxSpreadAttributeData,
|
|
AstJsxTagNamePropertyAccessData,
|
|
AstJsxTextData,
|
|
AstLabeledStatementData,
|
|
AstLiteralExpressionData,
|
|
AstLiteralLikeNodeData,
|
|
AstLiteralTypeNodeData,
|
|
AstMappedTypeNodeData,
|
|
AstMetaPropertyData,
|
|
AstMethodDeclarationData,
|
|
AstMethodSignatureData,
|
|
AstMissingDeclarationData,
|
|
AstModuleBlockData,
|
|
AstModuleDeclarationData,
|
|
AstNamedExportsData,
|
|
AstNamedImportsData,
|
|
AstNamedTupleMemberData,
|
|
AstNamespaceDeclarationData,
|
|
AstNamespaceExportData,
|
|
AstNamespaceExportDeclarationData,
|
|
AstNamespaceImportData,
|
|
AstNewExpressionData,
|
|
AstNode,
|
|
AstNodeArray,
|
|
AstNonNullExpressionData,
|
|
AstNoSubstitutionTemplateLiteralData,
|
|
AstNotEmittedStatementData,
|
|
AstNotEmittedTypeElementData,
|
|
AstNumericLiteralData,
|
|
AstObjectBindingPatternData,
|
|
AstObjectLiteralExpressionData,
|
|
AstOmittedExpressionData,
|
|
AstOptionalTypeNodeData,
|
|
AstParameterDeclarationData,
|
|
AstParenthesizedExpressionData,
|
|
AstParenthesizedTypeNodeData,
|
|
AstPartiallyEmittedExpressionData,
|
|
AstPostfixUnaryExpressionData,
|
|
AstPrefixUnaryExpressionData,
|
|
AstPrivateIdentifierData,
|
|
AstPropertyAccessExpressionData,
|
|
AstPropertyAssignmentData,
|
|
AstPropertyDeclarationData,
|
|
AstPropertySignatureData,
|
|
AstQualifiedNameData,
|
|
AstRegularExpressionLiteralData,
|
|
AstRestTypeNodeData,
|
|
AstReturnStatementData,
|
|
AstSatisfiesExpressionData,
|
|
AstSemicolonClassElementData,
|
|
AstSetAccessorDeclarationData,
|
|
AstShorthandPropertyAssignmentData,
|
|
AstSourceFileData,
|
|
AstSpreadAssignmentData,
|
|
AstSpreadElementData,
|
|
AstStringLiteralData,
|
|
AstStringLiteralLikeNodeData,
|
|
AstSuperExpression,
|
|
AstSuperExpressionData,
|
|
AstSwitchStatementData,
|
|
AstSyntaxListData,
|
|
AstSyntheticExpressionData,
|
|
AstSyntheticReferenceExpressionData,
|
|
AstTaggedTemplateExpressionData,
|
|
AstTemplateExpressionData,
|
|
AstTemplateHeadData,
|
|
AstTemplateLiteralLikeNodeData,
|
|
AstTemplateLiteralTypeNodeData,
|
|
AstTemplateLiteralTypeSpanData,
|
|
AstTemplateMiddleData,
|
|
AstTemplateSpanData,
|
|
AstTemplateTailData,
|
|
AstThisExpressionData,
|
|
AstThisTypeNodeData,
|
|
AstThrowStatementData,
|
|
AstTokenData,
|
|
AstTryStatementData,
|
|
AstTupleTypeNodeData,
|
|
AstTypeAliasDeclarationData,
|
|
AstTypeAssertionData,
|
|
AstTypeLiteralNodeData,
|
|
AstTypeOfExpressionData,
|
|
AstTypeOperatorNodeData,
|
|
AstTypeParameterDeclarationData,
|
|
AstTypePredicateNodeData,
|
|
AstTypeQueryNodeData,
|
|
AstTypeReferenceNodeData,
|
|
AstUnionTypeNodeData,
|
|
AstVariableDeclarationData,
|
|
AstVariableDeclarationListData,
|
|
AstVariableStatementData,
|
|
AstVoidExpressionData,
|
|
AstWhileStatementData,
|
|
AstWithStatementData,
|
|
AstYieldExpressionData,
|
|
AstNodeFactory,
|
|
computePositionOfLineAndCharacter,
|
|
createChildren,
|
|
createMultiMap,
|
|
CreateSourceFileOptions,
|
|
Debug,
|
|
EmitHelperFactory,
|
|
emptyArray,
|
|
find,
|
|
forEach,
|
|
forEachChild,
|
|
getAssignmentDeclarationKind,
|
|
GetCanonicalFileName,
|
|
getEffectiveModifierFlagsNoCache,
|
|
getEmitFlags,
|
|
getLineAndCharacterOfPosition,
|
|
getLineStarts,
|
|
getNodeChildren,
|
|
getNonAssignedNameOfDeclaration,
|
|
getParseTreeNode,
|
|
getSourceFileOfNode,
|
|
getSourceTextOfNodeFromSourceFile,
|
|
getTextOfIdentifierOrLiteral,
|
|
getTokenPosOfNode,
|
|
hasProperty,
|
|
hasSyntacticModifier,
|
|
idText,
|
|
isArrayTypeNode,
|
|
isBigIntLiteral,
|
|
isBindingPattern,
|
|
isCallSignatureDeclaration,
|
|
isComputedPropertyName,
|
|
isConditionalTypeNode,
|
|
isConstructorDeclaration,
|
|
isConstructorTypeNode,
|
|
isConstructSignatureDeclaration,
|
|
isFunctionTypeNode,
|
|
isGeneratedIdentifier,
|
|
isGetAccessorDeclaration,
|
|
isIdentifier,
|
|
isImportTypeNode,
|
|
isIndexedAccessTypeNode,
|
|
isIndexSignatureDeclaration,
|
|
isInferTypeNode,
|
|
isIntersectionTypeNode,
|
|
isLiteralTypeNode,
|
|
isMappedTypeNode,
|
|
isNamedExports,
|
|
isNamedTupleMember,
|
|
isNumericLiteral,
|
|
isOptionalTypeNode,
|
|
isParameter,
|
|
isParenthesizedTypeNode,
|
|
isParseTreeNode,
|
|
isPrivateIdentifier,
|
|
isPropertyAccessExpression,
|
|
isPropertyName,
|
|
isRestTypeNode,
|
|
isSetAccessorDeclaration,
|
|
isStringLiteral,
|
|
isStringOrNumericLiteralLike,
|
|
isThisTypeNode,
|
|
isTupleTypeNode,
|
|
isTypeLiteralNode,
|
|
isTypeOperatorNode,
|
|
isTypeParameterDeclaration,
|
|
isTypePredicateNode,
|
|
isTypeQueryNode,
|
|
isTypeReferenceNode,
|
|
isUnionTypeNode,
|
|
lastOrUndefined,
|
|
MapLike,
|
|
ModeAwareCache,
|
|
ModeAwareCacheKey,
|
|
ModuleResolutionCache,
|
|
MultiMap,
|
|
NodeFactoryFlags,
|
|
nodeIsSynthesized,
|
|
OptionsNameMap,
|
|
PackageJsonInfo,
|
|
PackageJsonInfoCache,
|
|
Pattern,
|
|
positionIsSynthesized,
|
|
setNodeChildren,
|
|
SymlinkCache,
|
|
ThisContainer,
|
|
updateSourceFile,
|
|
AstEntityNameExpression,
|
|
AstQuestionDotToken,
|
|
AstMemberName,
|
|
} from "./_namespaces/ts.js";
|
|
|
|
// branded string type used to store absolute, normalized and canonicalized paths
|
|
// arbitrary file name can be converted to Path via toPath function
|
|
export type Path = string & { __pathBrand: any; };
|
|
|
|
/** @internal */
|
|
export type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
|
|
|
|
export interface TextRange {
|
|
pos: number;
|
|
end: number;
|
|
}
|
|
|
|
export interface ReadonlyTextRange {
|
|
readonly pos: number;
|
|
readonly end: number;
|
|
}
|
|
|
|
// token > SyntaxKind.Identifier => token is a keyword
|
|
// Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync
|
|
export const enum SyntaxKind {
|
|
Unknown,
|
|
EndOfFileToken,
|
|
SingleLineCommentTrivia,
|
|
MultiLineCommentTrivia,
|
|
NewLineTrivia,
|
|
WhitespaceTrivia,
|
|
// We detect and preserve #! on the first line
|
|
ShebangTrivia,
|
|
// We detect and provide better error recovery when we encounter a git merge marker. This
|
|
// allows us to edit files with git-conflict markers in them in a much more pleasant manner.
|
|
ConflictMarkerTrivia,
|
|
// If a file is actually binary, with any luck, we'll get U+FFFD REPLACEMENT CHARACTER
|
|
// in position zero and can just skip what is surely a doomed parse.
|
|
NonTextFileMarkerTrivia,
|
|
// Literals
|
|
NumericLiteral,
|
|
BigIntLiteral,
|
|
StringLiteral,
|
|
JsxText,
|
|
JsxTextAllWhiteSpaces,
|
|
RegularExpressionLiteral,
|
|
NoSubstitutionTemplateLiteral,
|
|
// Pseudo-literals
|
|
TemplateHead,
|
|
TemplateMiddle,
|
|
TemplateTail,
|
|
// Punctuation
|
|
OpenBraceToken,
|
|
CloseBraceToken,
|
|
OpenParenToken,
|
|
CloseParenToken,
|
|
OpenBracketToken,
|
|
CloseBracketToken,
|
|
DotToken,
|
|
DotDotDotToken,
|
|
SemicolonToken,
|
|
CommaToken,
|
|
QuestionDotToken,
|
|
LessThanToken,
|
|
LessThanSlashToken,
|
|
GreaterThanToken,
|
|
LessThanEqualsToken,
|
|
GreaterThanEqualsToken,
|
|
EqualsEqualsToken,
|
|
ExclamationEqualsToken,
|
|
EqualsEqualsEqualsToken,
|
|
ExclamationEqualsEqualsToken,
|
|
EqualsGreaterThanToken,
|
|
PlusToken,
|
|
MinusToken,
|
|
AsteriskToken,
|
|
AsteriskAsteriskToken,
|
|
SlashToken,
|
|
PercentToken,
|
|
PlusPlusToken,
|
|
MinusMinusToken,
|
|
LessThanLessThanToken,
|
|
GreaterThanGreaterThanToken,
|
|
GreaterThanGreaterThanGreaterThanToken,
|
|
AmpersandToken,
|
|
BarToken,
|
|
CaretToken,
|
|
ExclamationToken,
|
|
TildeToken,
|
|
AmpersandAmpersandToken,
|
|
BarBarToken,
|
|
QuestionToken,
|
|
ColonToken,
|
|
AtToken,
|
|
QuestionQuestionToken,
|
|
/** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */
|
|
BacktickToken,
|
|
/** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */
|
|
HashToken,
|
|
// Assignments
|
|
EqualsToken,
|
|
PlusEqualsToken,
|
|
MinusEqualsToken,
|
|
AsteriskEqualsToken,
|
|
AsteriskAsteriskEqualsToken,
|
|
SlashEqualsToken,
|
|
PercentEqualsToken,
|
|
LessThanLessThanEqualsToken,
|
|
GreaterThanGreaterThanEqualsToken,
|
|
GreaterThanGreaterThanGreaterThanEqualsToken,
|
|
AmpersandEqualsToken,
|
|
BarEqualsToken,
|
|
BarBarEqualsToken,
|
|
AmpersandAmpersandEqualsToken,
|
|
QuestionQuestionEqualsToken,
|
|
CaretEqualsToken,
|
|
// Identifiers and PrivateIdentifiers
|
|
Identifier,
|
|
PrivateIdentifier,
|
|
/**
|
|
* Only the special JSDoc comment text scanner produces JSDocCommentTextTokes. One of these tokens spans all text after a tag comment's start and before the next @
|
|
* @internal
|
|
*/
|
|
JSDocCommentTextToken,
|
|
// Reserved words
|
|
BreakKeyword,
|
|
CaseKeyword,
|
|
CatchKeyword,
|
|
ClassKeyword,
|
|
ConstKeyword,
|
|
ContinueKeyword,
|
|
DebuggerKeyword,
|
|
DefaultKeyword,
|
|
DeleteKeyword,
|
|
DoKeyword,
|
|
ElseKeyword,
|
|
EnumKeyword,
|
|
ExportKeyword,
|
|
ExtendsKeyword,
|
|
FalseKeyword,
|
|
FinallyKeyword,
|
|
ForKeyword,
|
|
FunctionKeyword,
|
|
IfKeyword,
|
|
ImportKeyword,
|
|
InKeyword,
|
|
InstanceOfKeyword,
|
|
NewKeyword,
|
|
NullKeyword,
|
|
ReturnKeyword,
|
|
SuperKeyword,
|
|
SwitchKeyword,
|
|
ThisKeyword,
|
|
ThrowKeyword,
|
|
TrueKeyword,
|
|
TryKeyword,
|
|
TypeOfKeyword,
|
|
VarKeyword,
|
|
VoidKeyword,
|
|
WhileKeyword,
|
|
WithKeyword,
|
|
// Strict mode reserved words
|
|
ImplementsKeyword,
|
|
InterfaceKeyword,
|
|
LetKeyword,
|
|
PackageKeyword,
|
|
PrivateKeyword,
|
|
ProtectedKeyword,
|
|
PublicKeyword,
|
|
StaticKeyword,
|
|
YieldKeyword,
|
|
// Contextual keywords
|
|
AbstractKeyword,
|
|
AccessorKeyword,
|
|
AsKeyword,
|
|
AssertsKeyword,
|
|
AssertKeyword,
|
|
AnyKeyword,
|
|
AsyncKeyword,
|
|
AwaitKeyword,
|
|
BooleanKeyword,
|
|
ConstructorKeyword,
|
|
DeclareKeyword,
|
|
GetKeyword,
|
|
InferKeyword,
|
|
IntrinsicKeyword,
|
|
IsKeyword,
|
|
KeyOfKeyword,
|
|
ModuleKeyword,
|
|
NamespaceKeyword,
|
|
NeverKeyword,
|
|
OutKeyword,
|
|
ReadonlyKeyword,
|
|
RequireKeyword,
|
|
NumberKeyword,
|
|
ObjectKeyword,
|
|
SatisfiesKeyword,
|
|
SetKeyword,
|
|
StringKeyword,
|
|
SymbolKeyword,
|
|
TypeKeyword,
|
|
UndefinedKeyword,
|
|
UniqueKeyword,
|
|
UnknownKeyword,
|
|
UsingKeyword,
|
|
FromKeyword,
|
|
GlobalKeyword,
|
|
BigIntKeyword,
|
|
OverrideKeyword,
|
|
OfKeyword, // LastKeyword and LastToken and LastContextualKeyword
|
|
|
|
// Parse tree nodes
|
|
|
|
// Names
|
|
QualifiedName,
|
|
ComputedPropertyName,
|
|
// Signature elements
|
|
TypeParameter,
|
|
Parameter,
|
|
Decorator,
|
|
// TypeMember
|
|
PropertySignature,
|
|
PropertyDeclaration,
|
|
MethodSignature,
|
|
MethodDeclaration,
|
|
ClassStaticBlockDeclaration,
|
|
Constructor,
|
|
GetAccessor,
|
|
SetAccessor,
|
|
CallSignature,
|
|
ConstructSignature,
|
|
IndexSignature,
|
|
// Type
|
|
TypePredicate,
|
|
TypeReference,
|
|
FunctionType,
|
|
ConstructorType,
|
|
TypeQuery,
|
|
TypeLiteral,
|
|
ArrayType,
|
|
TupleType,
|
|
OptionalType,
|
|
RestType,
|
|
UnionType,
|
|
IntersectionType,
|
|
ConditionalType,
|
|
InferType,
|
|
ParenthesizedType,
|
|
ThisType,
|
|
TypeOperator,
|
|
IndexedAccessType,
|
|
MappedType,
|
|
LiteralType,
|
|
NamedTupleMember,
|
|
TemplateLiteralType,
|
|
TemplateLiteralTypeSpan,
|
|
ImportType,
|
|
// Binding patterns
|
|
ObjectBindingPattern,
|
|
ArrayBindingPattern,
|
|
BindingElement,
|
|
// Expression
|
|
ArrayLiteralExpression,
|
|
ObjectLiteralExpression,
|
|
PropertyAccessExpression,
|
|
ElementAccessExpression,
|
|
CallExpression,
|
|
NewExpression,
|
|
TaggedTemplateExpression,
|
|
TypeAssertionExpression,
|
|
ParenthesizedExpression,
|
|
FunctionExpression,
|
|
ArrowFunction,
|
|
DeleteExpression,
|
|
TypeOfExpression,
|
|
VoidExpression,
|
|
AwaitExpression,
|
|
PrefixUnaryExpression,
|
|
PostfixUnaryExpression,
|
|
BinaryExpression,
|
|
ConditionalExpression,
|
|
TemplateExpression,
|
|
YieldExpression,
|
|
SpreadElement,
|
|
ClassExpression,
|
|
OmittedExpression,
|
|
ExpressionWithTypeArguments,
|
|
AsExpression,
|
|
NonNullExpression,
|
|
MetaProperty,
|
|
SyntheticExpression,
|
|
SatisfiesExpression,
|
|
|
|
// Misc
|
|
TemplateSpan,
|
|
SemicolonClassElement,
|
|
// Element
|
|
Block,
|
|
EmptyStatement,
|
|
VariableStatement,
|
|
ExpressionStatement,
|
|
IfStatement,
|
|
DoStatement,
|
|
WhileStatement,
|
|
ForStatement,
|
|
ForInStatement,
|
|
ForOfStatement,
|
|
ContinueStatement,
|
|
BreakStatement,
|
|
ReturnStatement,
|
|
WithStatement,
|
|
SwitchStatement,
|
|
LabeledStatement,
|
|
ThrowStatement,
|
|
TryStatement,
|
|
DebuggerStatement,
|
|
VariableDeclaration,
|
|
VariableDeclarationList,
|
|
FunctionDeclaration,
|
|
ClassDeclaration,
|
|
InterfaceDeclaration,
|
|
TypeAliasDeclaration,
|
|
EnumDeclaration,
|
|
ModuleDeclaration,
|
|
ModuleBlock,
|
|
CaseBlock,
|
|
NamespaceExportDeclaration,
|
|
ImportEqualsDeclaration,
|
|
ImportDeclaration,
|
|
ImportClause,
|
|
NamespaceImport,
|
|
NamedImports,
|
|
ImportSpecifier,
|
|
ExportAssignment,
|
|
ExportDeclaration,
|
|
NamedExports,
|
|
NamespaceExport,
|
|
ExportSpecifier,
|
|
MissingDeclaration,
|
|
|
|
// Module references
|
|
ExternalModuleReference,
|
|
|
|
// JSX
|
|
JsxElement,
|
|
JsxSelfClosingElement,
|
|
JsxOpeningElement,
|
|
JsxClosingElement,
|
|
JsxFragment,
|
|
JsxOpeningFragment,
|
|
JsxClosingFragment,
|
|
JsxAttribute,
|
|
JsxAttributes,
|
|
JsxSpreadAttribute,
|
|
JsxExpression,
|
|
JsxNamespacedName,
|
|
|
|
// Clauses
|
|
CaseClause,
|
|
DefaultClause,
|
|
HeritageClause,
|
|
CatchClause,
|
|
|
|
ImportAttributes,
|
|
ImportAttribute,
|
|
/** @deprecated */ AssertClause = ImportAttributes,
|
|
/** @deprecated */ AssertEntry = ImportAttribute,
|
|
/** @deprecated */ ImportTypeAssertionContainer,
|
|
|
|
// Property assignments
|
|
PropertyAssignment,
|
|
ShorthandPropertyAssignment,
|
|
SpreadAssignment,
|
|
|
|
// Enum
|
|
EnumMember,
|
|
|
|
// Top-level nodes
|
|
SourceFile,
|
|
Bundle,
|
|
|
|
// JSDoc nodes
|
|
JSDocTypeExpression,
|
|
JSDocNameReference,
|
|
JSDocMemberName, // C#p
|
|
JSDocAllType, // The * type
|
|
JSDocUnknownType, // The ? type
|
|
JSDocNullableType,
|
|
JSDocNonNullableType,
|
|
JSDocOptionalType,
|
|
JSDocFunctionType,
|
|
JSDocVariadicType,
|
|
JSDocNamepathType, // https://jsdoc.app/about-namepaths.html
|
|
JSDoc,
|
|
/** @deprecated Use SyntaxKind.JSDoc */
|
|
JSDocComment = JSDoc,
|
|
JSDocText,
|
|
JSDocTypeLiteral,
|
|
JSDocSignature,
|
|
JSDocLink,
|
|
JSDocLinkCode,
|
|
JSDocLinkPlain,
|
|
JSDocTag,
|
|
JSDocAugmentsTag,
|
|
JSDocImplementsTag,
|
|
JSDocAuthorTag,
|
|
JSDocDeprecatedTag,
|
|
JSDocClassTag,
|
|
JSDocPublicTag,
|
|
JSDocPrivateTag,
|
|
JSDocProtectedTag,
|
|
JSDocReadonlyTag,
|
|
JSDocOverrideTag,
|
|
JSDocCallbackTag,
|
|
JSDocOverloadTag,
|
|
JSDocEnumTag,
|
|
JSDocParameterTag,
|
|
JSDocReturnTag,
|
|
JSDocThisTag,
|
|
JSDocTypeTag,
|
|
JSDocTemplateTag,
|
|
JSDocTypedefTag,
|
|
JSDocSeeTag,
|
|
JSDocPropertyTag,
|
|
JSDocThrowsTag,
|
|
JSDocSatisfiesTag,
|
|
JSDocImportTag,
|
|
|
|
// Synthesized list
|
|
SyntaxList,
|
|
|
|
// Transformation nodes
|
|
NotEmittedStatement,
|
|
NotEmittedTypeElement,
|
|
PartiallyEmittedExpression,
|
|
CommaListExpression,
|
|
SyntheticReferenceExpression,
|
|
|
|
// Enum value count
|
|
Count,
|
|
|
|
// Markers
|
|
FirstAssignment = EqualsToken,
|
|
LastAssignment = CaretEqualsToken,
|
|
FirstCompoundAssignment = PlusEqualsToken,
|
|
LastCompoundAssignment = CaretEqualsToken,
|
|
FirstReservedWord = BreakKeyword,
|
|
LastReservedWord = WithKeyword,
|
|
FirstKeyword = BreakKeyword,
|
|
LastKeyword = OfKeyword,
|
|
FirstFutureReservedWord = ImplementsKeyword,
|
|
LastFutureReservedWord = YieldKeyword,
|
|
FirstTypeNode = TypePredicate,
|
|
LastTypeNode = ImportType,
|
|
FirstPunctuation = OpenBraceToken,
|
|
LastPunctuation = CaretEqualsToken,
|
|
FirstToken = Unknown,
|
|
LastToken = LastKeyword,
|
|
FirstTriviaToken = SingleLineCommentTrivia,
|
|
LastTriviaToken = ConflictMarkerTrivia,
|
|
FirstLiteralToken = NumericLiteral,
|
|
LastLiteralToken = NoSubstitutionTemplateLiteral,
|
|
FirstTemplateToken = NoSubstitutionTemplateLiteral,
|
|
LastTemplateToken = TemplateTail,
|
|
FirstBinaryOperator = LessThanToken,
|
|
LastBinaryOperator = CaretEqualsToken,
|
|
FirstStatement = VariableStatement,
|
|
LastStatement = DebuggerStatement,
|
|
FirstNode = QualifiedName,
|
|
FirstJSDocNode = JSDocTypeExpression,
|
|
LastJSDocNode = JSDocImportTag,
|
|
FirstJSDocTagNode = JSDocTag,
|
|
LastJSDocTagNode = JSDocImportTag,
|
|
/** @internal */ FirstContextualKeyword = AbstractKeyword,
|
|
/** @internal */ LastContextualKeyword = OfKeyword,
|
|
}
|
|
|
|
export type TriviaSyntaxKind =
|
|
| SyntaxKind.SingleLineCommentTrivia
|
|
| SyntaxKind.MultiLineCommentTrivia
|
|
| SyntaxKind.NewLineTrivia
|
|
| SyntaxKind.WhitespaceTrivia
|
|
| SyntaxKind.ShebangTrivia
|
|
| SyntaxKind.ConflictMarkerTrivia;
|
|
|
|
export type LiteralSyntaxKind =
|
|
| SyntaxKind.NumericLiteral
|
|
| SyntaxKind.BigIntLiteral
|
|
| SyntaxKind.StringLiteral
|
|
| SyntaxKind.JsxText
|
|
| SyntaxKind.JsxTextAllWhiteSpaces
|
|
| SyntaxKind.RegularExpressionLiteral
|
|
| SyntaxKind.NoSubstitutionTemplateLiteral;
|
|
|
|
export type PseudoLiteralSyntaxKind =
|
|
| SyntaxKind.TemplateHead
|
|
| SyntaxKind.TemplateMiddle
|
|
| SyntaxKind.TemplateTail;
|
|
|
|
export type PunctuationSyntaxKind =
|
|
| SyntaxKind.OpenBraceToken
|
|
| SyntaxKind.CloseBraceToken
|
|
| SyntaxKind.OpenParenToken
|
|
| SyntaxKind.CloseParenToken
|
|
| SyntaxKind.OpenBracketToken
|
|
| SyntaxKind.CloseBracketToken
|
|
| SyntaxKind.DotToken
|
|
| SyntaxKind.DotDotDotToken
|
|
| SyntaxKind.SemicolonToken
|
|
| SyntaxKind.CommaToken
|
|
| SyntaxKind.QuestionDotToken
|
|
| SyntaxKind.LessThanToken
|
|
| SyntaxKind.LessThanSlashToken
|
|
| SyntaxKind.GreaterThanToken
|
|
| SyntaxKind.LessThanEqualsToken
|
|
| SyntaxKind.GreaterThanEqualsToken
|
|
| SyntaxKind.EqualsEqualsToken
|
|
| SyntaxKind.ExclamationEqualsToken
|
|
| SyntaxKind.EqualsEqualsEqualsToken
|
|
| SyntaxKind.ExclamationEqualsEqualsToken
|
|
| SyntaxKind.EqualsGreaterThanToken
|
|
| SyntaxKind.PlusToken
|
|
| SyntaxKind.MinusToken
|
|
| SyntaxKind.AsteriskToken
|
|
| SyntaxKind.AsteriskAsteriskToken
|
|
| SyntaxKind.SlashToken
|
|
| SyntaxKind.PercentToken
|
|
| SyntaxKind.PlusPlusToken
|
|
| SyntaxKind.MinusMinusToken
|
|
| SyntaxKind.LessThanLessThanToken
|
|
| SyntaxKind.GreaterThanGreaterThanToken
|
|
| SyntaxKind.GreaterThanGreaterThanGreaterThanToken
|
|
| SyntaxKind.AmpersandToken
|
|
| SyntaxKind.BarToken
|
|
| SyntaxKind.CaretToken
|
|
| SyntaxKind.ExclamationToken
|
|
| SyntaxKind.TildeToken
|
|
| SyntaxKind.AmpersandAmpersandToken
|
|
| SyntaxKind.AmpersandAmpersandEqualsToken
|
|
| SyntaxKind.BarBarToken
|
|
| SyntaxKind.BarBarEqualsToken
|
|
| SyntaxKind.QuestionQuestionToken
|
|
| SyntaxKind.QuestionQuestionEqualsToken
|
|
| SyntaxKind.QuestionToken
|
|
| SyntaxKind.ColonToken
|
|
| SyntaxKind.AtToken
|
|
| SyntaxKind.BacktickToken
|
|
| SyntaxKind.HashToken
|
|
| SyntaxKind.EqualsToken
|
|
| SyntaxKind.PlusEqualsToken
|
|
| SyntaxKind.MinusEqualsToken
|
|
| SyntaxKind.AsteriskEqualsToken
|
|
| SyntaxKind.AsteriskAsteriskEqualsToken
|
|
| SyntaxKind.SlashEqualsToken
|
|
| SyntaxKind.PercentEqualsToken
|
|
| SyntaxKind.LessThanLessThanEqualsToken
|
|
| SyntaxKind.GreaterThanGreaterThanEqualsToken
|
|
| SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken
|
|
| SyntaxKind.AmpersandEqualsToken
|
|
| SyntaxKind.BarEqualsToken
|
|
| SyntaxKind.CaretEqualsToken;
|
|
|
|
/** @internal */
|
|
export type PunctuationOrKeywordSyntaxKind = PunctuationSyntaxKind | KeywordSyntaxKind;
|
|
|
|
export type KeywordSyntaxKind =
|
|
| SyntaxKind.AbstractKeyword
|
|
| SyntaxKind.AccessorKeyword
|
|
| SyntaxKind.AnyKeyword
|
|
| SyntaxKind.AsKeyword
|
|
| SyntaxKind.AssertsKeyword
|
|
| SyntaxKind.AssertKeyword
|
|
| SyntaxKind.AsyncKeyword
|
|
| SyntaxKind.AwaitKeyword
|
|
| SyntaxKind.BigIntKeyword
|
|
| SyntaxKind.BooleanKeyword
|
|
| SyntaxKind.BreakKeyword
|
|
| SyntaxKind.CaseKeyword
|
|
| SyntaxKind.CatchKeyword
|
|
| SyntaxKind.ClassKeyword
|
|
| SyntaxKind.ConstKeyword
|
|
| SyntaxKind.ConstructorKeyword
|
|
| SyntaxKind.ContinueKeyword
|
|
| SyntaxKind.DebuggerKeyword
|
|
| SyntaxKind.DeclareKeyword
|
|
| SyntaxKind.DefaultKeyword
|
|
| SyntaxKind.DeleteKeyword
|
|
| SyntaxKind.DoKeyword
|
|
| SyntaxKind.ElseKeyword
|
|
| SyntaxKind.EnumKeyword
|
|
| SyntaxKind.ExportKeyword
|
|
| SyntaxKind.ExtendsKeyword
|
|
| SyntaxKind.FalseKeyword
|
|
| SyntaxKind.FinallyKeyword
|
|
| SyntaxKind.ForKeyword
|
|
| SyntaxKind.FromKeyword
|
|
| SyntaxKind.FunctionKeyword
|
|
| SyntaxKind.GetKeyword
|
|
| SyntaxKind.GlobalKeyword
|
|
| SyntaxKind.IfKeyword
|
|
| SyntaxKind.ImplementsKeyword
|
|
| SyntaxKind.ImportKeyword
|
|
| SyntaxKind.InferKeyword
|
|
| SyntaxKind.InKeyword
|
|
| SyntaxKind.InstanceOfKeyword
|
|
| SyntaxKind.InterfaceKeyword
|
|
| SyntaxKind.IntrinsicKeyword
|
|
| SyntaxKind.IsKeyword
|
|
| SyntaxKind.KeyOfKeyword
|
|
| SyntaxKind.LetKeyword
|
|
| SyntaxKind.ModuleKeyword
|
|
| SyntaxKind.NamespaceKeyword
|
|
| SyntaxKind.NeverKeyword
|
|
| SyntaxKind.NewKeyword
|
|
| SyntaxKind.NullKeyword
|
|
| SyntaxKind.NumberKeyword
|
|
| SyntaxKind.ObjectKeyword
|
|
| SyntaxKind.OfKeyword
|
|
| SyntaxKind.PackageKeyword
|
|
| SyntaxKind.PrivateKeyword
|
|
| SyntaxKind.ProtectedKeyword
|
|
| SyntaxKind.PublicKeyword
|
|
| SyntaxKind.ReadonlyKeyword
|
|
| SyntaxKind.OutKeyword
|
|
| SyntaxKind.OverrideKeyword
|
|
| SyntaxKind.RequireKeyword
|
|
| SyntaxKind.ReturnKeyword
|
|
| SyntaxKind.SatisfiesKeyword
|
|
| SyntaxKind.SetKeyword
|
|
| SyntaxKind.StaticKeyword
|
|
| SyntaxKind.StringKeyword
|
|
| SyntaxKind.SuperKeyword
|
|
| SyntaxKind.SwitchKeyword
|
|
| SyntaxKind.SymbolKeyword
|
|
| SyntaxKind.ThisKeyword
|
|
| SyntaxKind.ThrowKeyword
|
|
| SyntaxKind.TrueKeyword
|
|
| SyntaxKind.TryKeyword
|
|
| SyntaxKind.TypeKeyword
|
|
| SyntaxKind.TypeOfKeyword
|
|
| SyntaxKind.UndefinedKeyword
|
|
| SyntaxKind.UniqueKeyword
|
|
| SyntaxKind.UnknownKeyword
|
|
| SyntaxKind.UsingKeyword
|
|
| SyntaxKind.VarKeyword
|
|
| SyntaxKind.VoidKeyword
|
|
| SyntaxKind.WhileKeyword
|
|
| SyntaxKind.WithKeyword
|
|
| SyntaxKind.YieldKeyword;
|
|
|
|
export type ModifierSyntaxKind =
|
|
| SyntaxKind.AbstractKeyword
|
|
| SyntaxKind.AccessorKeyword
|
|
| SyntaxKind.AsyncKeyword
|
|
| SyntaxKind.ConstKeyword
|
|
| SyntaxKind.DeclareKeyword
|
|
| SyntaxKind.DefaultKeyword
|
|
| SyntaxKind.ExportKeyword
|
|
| SyntaxKind.InKeyword
|
|
| SyntaxKind.PrivateKeyword
|
|
| SyntaxKind.ProtectedKeyword
|
|
| SyntaxKind.PublicKeyword
|
|
| SyntaxKind.ReadonlyKeyword
|
|
| SyntaxKind.OutKeyword
|
|
| SyntaxKind.OverrideKeyword
|
|
| SyntaxKind.StaticKeyword;
|
|
|
|
export type KeywordTypeSyntaxKind =
|
|
| SyntaxKind.AnyKeyword
|
|
| SyntaxKind.BigIntKeyword
|
|
| SyntaxKind.BooleanKeyword
|
|
| SyntaxKind.IntrinsicKeyword
|
|
| SyntaxKind.NeverKeyword
|
|
| SyntaxKind.NumberKeyword
|
|
| SyntaxKind.ObjectKeyword
|
|
| SyntaxKind.StringKeyword
|
|
| SyntaxKind.SymbolKeyword
|
|
| SyntaxKind.UndefinedKeyword
|
|
| SyntaxKind.UnknownKeyword
|
|
| SyntaxKind.VoidKeyword;
|
|
|
|
export type TypeNodeSyntaxKind =
|
|
| KeywordTypeSyntaxKind
|
|
| SyntaxKind.TypePredicate
|
|
| SyntaxKind.TypeReference
|
|
| SyntaxKind.FunctionType
|
|
| SyntaxKind.ConstructorType
|
|
| SyntaxKind.TypeQuery
|
|
| SyntaxKind.TypeLiteral
|
|
| SyntaxKind.ArrayType
|
|
| SyntaxKind.TupleType
|
|
| SyntaxKind.NamedTupleMember
|
|
| SyntaxKind.OptionalType
|
|
| SyntaxKind.RestType
|
|
| SyntaxKind.UnionType
|
|
| SyntaxKind.IntersectionType
|
|
| SyntaxKind.ConditionalType
|
|
| SyntaxKind.InferType
|
|
| SyntaxKind.ParenthesizedType
|
|
| SyntaxKind.ThisType
|
|
| SyntaxKind.TypeOperator
|
|
| SyntaxKind.IndexedAccessType
|
|
| SyntaxKind.MappedType
|
|
| SyntaxKind.LiteralType
|
|
| SyntaxKind.TemplateLiteralType
|
|
| SyntaxKind.TemplateLiteralTypeSpan
|
|
| SyntaxKind.ImportType
|
|
| SyntaxKind.ExpressionWithTypeArguments
|
|
| SyntaxKind.JSDocTypeExpression
|
|
| SyntaxKind.JSDocAllType
|
|
| SyntaxKind.JSDocUnknownType
|
|
| SyntaxKind.JSDocNonNullableType
|
|
| SyntaxKind.JSDocNullableType
|
|
| SyntaxKind.JSDocOptionalType
|
|
| SyntaxKind.JSDocFunctionType
|
|
| SyntaxKind.JSDocVariadicType
|
|
| SyntaxKind.JSDocNamepathType
|
|
| SyntaxKind.JSDocSignature
|
|
| SyntaxKind.JSDocTypeLiteral;
|
|
|
|
export type TokenSyntaxKind =
|
|
| SyntaxKind.Unknown
|
|
| SyntaxKind.EndOfFileToken
|
|
| TriviaSyntaxKind
|
|
| LiteralSyntaxKind
|
|
| PseudoLiteralSyntaxKind
|
|
| PunctuationSyntaxKind
|
|
| SyntaxKind.Identifier
|
|
| SyntaxKind.PrivateIdentifier
|
|
| KeywordSyntaxKind;
|
|
|
|
export type JsxTokenSyntaxKind =
|
|
| SyntaxKind.LessThanSlashToken
|
|
| SyntaxKind.EndOfFileToken
|
|
| SyntaxKind.ConflictMarkerTrivia
|
|
| SyntaxKind.JsxText
|
|
| SyntaxKind.JsxTextAllWhiteSpaces
|
|
| SyntaxKind.OpenBraceToken
|
|
| SyntaxKind.LessThanToken;
|
|
|
|
export type JSDocSyntaxKind =
|
|
| SyntaxKind.EndOfFileToken
|
|
| SyntaxKind.WhitespaceTrivia
|
|
| SyntaxKind.AtToken
|
|
| SyntaxKind.NewLineTrivia
|
|
| SyntaxKind.AsteriskToken
|
|
| SyntaxKind.OpenBraceToken
|
|
| SyntaxKind.CloseBraceToken
|
|
| SyntaxKind.LessThanToken
|
|
| SyntaxKind.GreaterThanToken
|
|
| SyntaxKind.OpenBracketToken
|
|
| SyntaxKind.CloseBracketToken
|
|
| SyntaxKind.OpenParenToken
|
|
| SyntaxKind.CloseParenToken
|
|
| SyntaxKind.EqualsToken
|
|
| SyntaxKind.CommaToken
|
|
| SyntaxKind.DotToken
|
|
| SyntaxKind.Identifier
|
|
| SyntaxKind.BacktickToken
|
|
| SyntaxKind.HashToken
|
|
| SyntaxKind.Unknown
|
|
| KeywordSyntaxKind;
|
|
|
|
// dprint-ignore
|
|
export const enum NodeFlags {
|
|
None = 0,
|
|
Let = 1 << 0, // Variable declaration
|
|
Const = 1 << 1, // Variable declaration
|
|
Using = 1 << 2, // Variable declaration
|
|
AwaitUsing = Const | Using, // Variable declaration (NOTE: on a single node these flags would otherwise be mutually exclusive)
|
|
NestedNamespace = 1 << 3, // Namespace declaration
|
|
Synthesized = 1 << 4, // Node was synthesized during transformation
|
|
Namespace = 1 << 5, // Namespace declaration
|
|
OptionalChain = 1 << 6, // Chained MemberExpression rooted to a pseudo-OptionalExpression
|
|
ExportContext = 1 << 7, // Export context (initialized by binding)
|
|
ContainsThis = 1 << 8, // Interface contains references to "this"
|
|
HasImplicitReturn = 1 << 9, // If function implicitly returns on one of codepaths (initialized by binding)
|
|
HasExplicitReturn = 1 << 10, // If function has explicit reachable return on one of codepaths (initialized by binding)
|
|
GlobalAugmentation = 1 << 11, // Set if module declaration is an augmentation for the global scope
|
|
HasAsyncFunctions = 1 << 12, // If the file has async functions (initialized by binding)
|
|
DisallowInContext = 1 << 13, // If node was parsed in a context where 'in-expressions' are not allowed
|
|
YieldContext = 1 << 14, // If node was parsed in the 'yield' context created when parsing a generator
|
|
DecoratorContext = 1 << 15, // If node was parsed as part of a decorator
|
|
AwaitContext = 1 << 16, // If node was parsed in the 'await' context created when parsing an async function
|
|
DisallowConditionalTypesContext = 1 << 17, // If node was parsed in a context where conditional types are not allowed
|
|
ThisNodeHasError = 1 << 18, // If the parser encountered an error when parsing the code that created this node
|
|
JavaScriptFile = 1 << 19, // If node was parsed in a JavaScript
|
|
ThisNodeOrAnySubNodesHasError = 1 << 20, // If this node or any of its children had an error
|
|
HasAggregatedChildData = 1 << 21, // If we've computed data from children and cached it in this node
|
|
|
|
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
|
|
// walking the tree if the flags are not set. However, these flags are just a approximation
|
|
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
|
|
// During editing, if a dynamic import is removed, incremental parsing will *NOT* clear this flag.
|
|
// This means that the tree will always be traversed during module resolution, or when looking for external module indicators.
|
|
// However, the removal operation should not occur often and in the case of the
|
|
// removal, it is likely that users will add the import anyway.
|
|
// The advantage of this approach is its simplicity. For the case of batch compilation,
|
|
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
|
|
/** @internal */ PossiblyContainsDynamicImport = 1 << 22,
|
|
/** @internal */ PossiblyContainsImportMeta = 1 << 23,
|
|
|
|
JSDoc = 1 << 24, // If node was parsed inside jsdoc
|
|
/** @internal */ Ambient = 1 << 25, // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier.
|
|
/** @internal */ InWithStatement = 1 << 26, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
|
|
JsonFile = 1 << 27, // If node was parsed in a Json
|
|
/** @internal */ TypeCached = 1 << 28, // If a type was cached for node at any point
|
|
/** @internal */ Deprecated = 1 << 29, // If has '@deprecated' JSDoc tag
|
|
|
|
BlockScoped = Let | Const | Using,
|
|
Constant = Const | Using,
|
|
|
|
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
|
|
ReachabilityAndEmitFlags = ReachabilityCheckFlags | HasAsyncFunctions,
|
|
|
|
// Parsing context flags
|
|
ContextFlags = DisallowInContext | DisallowConditionalTypesContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile | InWithStatement | Ambient,
|
|
|
|
// Exclude these flags when parsing a Type
|
|
TypeExcludesFlags = YieldContext | AwaitContext,
|
|
|
|
// Represents all flags that are potentially set once and
|
|
// never cleared on SourceFiles which get re-used in between incremental parses.
|
|
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
|
|
/** @internal */ PermanentlySetIncrementalFlags = PossiblyContainsDynamicImport | PossiblyContainsImportMeta,
|
|
|
|
// The following flags repurpose other NodeFlags as different meanings for Identifier nodes
|
|
/** @internal */ IdentifierHasExtendedUnicodeEscape = ContainsThis, // Indicates whether the identifier contains an extended unicode escape sequence
|
|
/** @internal */ IdentifierIsInJSDocNamespace = HasAsyncFunctions, // Indicates whether the identifier is part of a JSDoc namespace
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum ModifierFlags {
|
|
None = 0,
|
|
|
|
// Syntactic/JSDoc modifiers
|
|
Public = 1 << 0, // Property/Method
|
|
Private = 1 << 1, // Property/Method
|
|
Protected = 1 << 2, // Property/Method
|
|
Readonly = 1 << 3, // Property/Method
|
|
Override = 1 << 4, // Override method.
|
|
|
|
// Syntactic-only modifiers
|
|
Export = 1 << 5, // Declarations
|
|
Abstract = 1 << 6, // Class/Method/ConstructSignature
|
|
Ambient = 1 << 7, // Declarations
|
|
Static = 1 << 8, // Property/Method
|
|
Accessor = 1 << 9, // Property
|
|
Async = 1 << 10, // Property/Method/Function
|
|
Default = 1 << 11, // Function/Class (export default declaration)
|
|
Const = 1 << 12, // Const enum
|
|
In = 1 << 13, // Contravariance modifier
|
|
Out = 1 << 14, // Covariance modifier
|
|
Decorator = 1 << 15, // Contains a decorator.
|
|
|
|
// JSDoc-only modifiers
|
|
Deprecated = 1 << 16, // Deprecated tag.
|
|
|
|
// Cache-only JSDoc-modifiers. Should match order of Syntactic/JSDoc modifiers, above.
|
|
/** @internal */ JSDocPublic = 1 << 23, // if this value changes, `selectEffectiveModifierFlags` must change accordingly
|
|
/** @internal */ JSDocPrivate = 1 << 24,
|
|
/** @internal */ JSDocProtected = 1 << 25,
|
|
/** @internal */ JSDocReadonly = 1 << 26,
|
|
/** @internal */ JSDocOverride = 1 << 27,
|
|
|
|
/** @internal */ SyntacticOrJSDocModifiers = Public | Private | Protected | Readonly | Override,
|
|
/** @internal */ SyntacticOnlyModifiers = Export | Ambient | Abstract | Static | Accessor | Async | Default | Const | In | Out | Decorator,
|
|
/** @internal */ SyntacticModifiers = SyntacticOrJSDocModifiers | SyntacticOnlyModifiers,
|
|
/** @internal */ JSDocCacheOnlyModifiers = JSDocPublic | JSDocPrivate | JSDocProtected | JSDocReadonly | JSDocOverride,
|
|
/** @internal */ JSDocOnlyModifiers = Deprecated,
|
|
/** @internal */ NonCacheOnlyModifiers = SyntacticOrJSDocModifiers | SyntacticOnlyModifiers | JSDocOnlyModifiers,
|
|
|
|
HasComputedJSDocModifiers = 1 << 28, // Indicates the computed modifier flags include modifiers from JSDoc.
|
|
HasComputedFlags = 1 << 29, // Modifier flags have been computed
|
|
|
|
AccessibilityModifier = Public | Private | Protected,
|
|
// Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property.
|
|
ParameterPropertyModifier = AccessibilityModifier | Readonly | Override,
|
|
NonPublicAccessibilityModifier = Private | Protected,
|
|
|
|
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out,
|
|
ExportDefault = Export | Default,
|
|
All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Accessor | Async | Default | Const | Deprecated | Override | In | Out | Decorator,
|
|
Modifier = All & ~Decorator,
|
|
}
|
|
|
|
export const enum JsxFlags {
|
|
None = 0,
|
|
/** An element from a named property of the JSX.IntrinsicElements interface */
|
|
IntrinsicNamedElement = 1 << 0,
|
|
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
|
|
IntrinsicIndexedElement = 1 << 1,
|
|
|
|
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement,
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum RelationComparisonResult {
|
|
None = 0,
|
|
Succeeded = 1 << 0, // Should be truthy
|
|
Failed = 1 << 1,
|
|
|
|
ReportsUnmeasurable = 1 << 3,
|
|
ReportsUnreliable = 1 << 4,
|
|
ReportsMask = ReportsUnmeasurable | ReportsUnreliable,
|
|
|
|
ComplexityOverflow = 1 << 5,
|
|
StackDepthOverflow = 1 << 6,
|
|
Overflow = ComplexityOverflow | StackDepthOverflow,
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum PredicateSemantics {
|
|
None = 0,
|
|
Always = 1 << 0,
|
|
Never = 1 << 1,
|
|
Sometimes = Always | Never,
|
|
}
|
|
|
|
/** @internal */
|
|
export type NodeId = number;
|
|
|
|
export type NodeConstructor<N extends Node> = new (ast: AstNode<Node<N["kind"], N["data"]>>) => N; // TODO: avoid indexed access type
|
|
|
|
// dprint-ignore
|
|
export class Node<
|
|
K extends SyntaxKind = SyntaxKind,
|
|
T extends AstData = AstData
|
|
> implements ReadonlyTextRange {
|
|
readonly ast: AstNode<this> = undefined!;
|
|
|
|
constructor(ast: AstNode<Node<K, T>>) {
|
|
this.ast = ast as AstNode<this>;
|
|
Object.preventExtensions(this);
|
|
}
|
|
|
|
get kind(): K { return this.ast.kind; }
|
|
get data(): T { return this.ast.data; }
|
|
get pos(): number { return this.ast.pos; }
|
|
get end(): number { return this.ast.end; }
|
|
get flags(): NodeFlags { return this.ast.flags; }
|
|
get parent(): Node { return this.ast.parent?.node!; }
|
|
|
|
/** @internal */ set pos(value) { this.ast.pos = value; }
|
|
/** @internal */ set end(value) { this.ast.end = value; }
|
|
/** @internal */ set flags(value) { this.ast.flags = value; }
|
|
/** @internal */ set parent(value) { this.ast.parent = value?.ast; }
|
|
/** @internal */ get modifierFlagsCache(): ModifierFlags { return this.ast.modifierFlagsCache; }
|
|
/** @internal */ set modifierFlagsCache(value) { this.ast.modifierFlagsCache = value; }
|
|
/** @internal */ get transformFlags(): TransformFlags { return this.ast.transformFlags; }
|
|
/** @internal */ set transformFlags(value) { this.ast.transformFlags = value; }
|
|
/** @internal */ get id(): number { return this.ast.id; }
|
|
/** @internal */ set id(value) { this.ast.id = value; }
|
|
/** @internal */ get original(): Node | undefined { return this.ast.original?.node; }
|
|
/** @internal */ set original(value) { this.ast.original = value?.ast; }
|
|
/** @internal */ get emitNode(): EmitNode | undefined { return this.ast.emitNode; }
|
|
/** @internal */ set emitNode(value) { this.ast.emitNode = value; }
|
|
/** @internal */ get __pos(): number | undefined { return this.ast.__pos; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
/** @internal */ set __pos(value) { this.ast.__pos = value; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
/** @internal */ get __end(): number | undefined { return this.ast.__end; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
/** @internal */ set __end(value) { this.ast.__end = value; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
|
|
/** @internal @private */ _assertHasRealPosition(message?: string): void {
|
|
// eslint-disable-next-line local/debug-assert
|
|
Debug.assert(!positionIsSynthesized(this.pos) && !positionIsSynthesized(this.end), message || "Node must have a real position for this operation");
|
|
}
|
|
|
|
getSourceFile(): SourceFile {
|
|
return getSourceFileOfNode(this);
|
|
}
|
|
|
|
getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number {
|
|
this._assertHasRealPosition();
|
|
return getTokenPosOfNode(this, sourceFile, includeJsDocComment);
|
|
}
|
|
|
|
getFullStart(): number {
|
|
this._assertHasRealPosition();
|
|
return this.pos;
|
|
}
|
|
|
|
getEnd(): number {
|
|
this._assertHasRealPosition();
|
|
return this.end;
|
|
}
|
|
|
|
getWidth(sourceFile?: SourceFileLike): number {
|
|
this._assertHasRealPosition();
|
|
return this.getEnd() - this.getStart(sourceFile);
|
|
}
|
|
|
|
getFullWidth(): number {
|
|
this._assertHasRealPosition();
|
|
return this.end - this.pos;
|
|
}
|
|
|
|
getLeadingTriviaWidth(sourceFile?: SourceFileLike): number {
|
|
this._assertHasRealPosition();
|
|
return this.getStart(sourceFile) - this.pos;
|
|
}
|
|
|
|
getFullText(sourceFile?: SourceFileLike): string {
|
|
this._assertHasRealPosition();
|
|
sourceFile ??= this.getSourceFile();
|
|
return sourceFile.text.substring(this.pos, this.end);
|
|
}
|
|
|
|
getText(sourceFile?: SourceFileLike): string {
|
|
this._assertHasRealPosition();
|
|
sourceFile ??= this.getSourceFile();
|
|
return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd());
|
|
}
|
|
|
|
getChildCount(sourceFile?: SourceFileLike): number {
|
|
return this.getChildren(sourceFile).length;
|
|
}
|
|
|
|
getChildAt(index: number, sourceFile?: SourceFileLike): Node {
|
|
return this.getChildren(sourceFile)[index];
|
|
}
|
|
|
|
getChildren(sourceFile?: SourceFileLike): readonly Node[] {
|
|
this._assertHasRealPosition("Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine");
|
|
sourceFile ??= this.getSourceFile();
|
|
return getNodeChildren(this, sourceFile) ?? setNodeChildren(this, sourceFile, createChildren(this, sourceFile));
|
|
}
|
|
|
|
getFirstToken(sourceFile?: SourceFileLike): Node | undefined {
|
|
this._assertHasRealPosition();
|
|
sourceFile ??= this.getSourceFile();
|
|
const children = this.getChildren(sourceFile);
|
|
if (!children.length) {
|
|
return undefined;
|
|
}
|
|
|
|
const child = find(children, kid => kid.kind < SyntaxKind.FirstJSDocNode || kid.kind > SyntaxKind.LastJSDocNode);
|
|
return !child || child.kind < SyntaxKind.FirstNode ?
|
|
child :
|
|
child.getFirstToken(sourceFile);
|
|
}
|
|
|
|
getLastToken(sourceFile?: SourceFileLike): Node | undefined {
|
|
this._assertHasRealPosition();
|
|
const children = this.getChildren(sourceFile);
|
|
const child = lastOrUndefined(children);
|
|
if (!child) {
|
|
return undefined;
|
|
}
|
|
|
|
return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile);
|
|
}
|
|
|
|
forEachChild<T>(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
|
|
return forEachChild(this, cbNode, cbNodeArray);
|
|
}
|
|
}
|
|
|
|
Debug.registerDebugInfo(() => {
|
|
if (!hasProperty(Node.prototype, "__debugKind")) {
|
|
const weakNodeTextMap = new WeakMap<Node, string>();
|
|
|
|
Object.defineProperties(Node.prototype, {
|
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
__tsDebuggerDisplay: {
|
|
value(this: Node) { // TODO(rbuckton): This is probably no longer needed now that every node has a unique class
|
|
const nodeHeader = isGeneratedIdentifier(this) ? "GeneratedIdentifier" :
|
|
isIdentifier(this) ? `Identifier '${idText(this)}'` :
|
|
isPrivateIdentifier(this) ? `PrivateIdentifier '${idText(this)}'` :
|
|
isStringLiteral(this) ? `StringLiteral ${JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")}` :
|
|
isNumericLiteral(this) ? `NumericLiteral ${this.text}` :
|
|
isBigIntLiteral(this) ? `BigIntLiteral ${this.text}n` :
|
|
isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" :
|
|
isParameter(this) ? "ParameterDeclaration" :
|
|
isConstructorDeclaration(this) ? "ConstructorDeclaration" :
|
|
isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" :
|
|
isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" :
|
|
isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" :
|
|
isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" :
|
|
isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" :
|
|
isTypePredicateNode(this) ? "TypePredicateNode" :
|
|
isTypeReferenceNode(this) ? "TypeReferenceNode" :
|
|
isFunctionTypeNode(this) ? "FunctionTypeNode" :
|
|
isConstructorTypeNode(this) ? "ConstructorTypeNode" :
|
|
isTypeQueryNode(this) ? "TypeQueryNode" :
|
|
isTypeLiteralNode(this) ? "TypeLiteralNode" :
|
|
isArrayTypeNode(this) ? "ArrayTypeNode" :
|
|
isTupleTypeNode(this) ? "TupleTypeNode" :
|
|
isOptionalTypeNode(this) ? "OptionalTypeNode" :
|
|
isRestTypeNode(this) ? "RestTypeNode" :
|
|
isUnionTypeNode(this) ? "UnionTypeNode" :
|
|
isIntersectionTypeNode(this) ? "IntersectionTypeNode" :
|
|
isConditionalTypeNode(this) ? "ConditionalTypeNode" :
|
|
isInferTypeNode(this) ? "InferTypeNode" :
|
|
isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" :
|
|
isThisTypeNode(this) ? "ThisTypeNode" :
|
|
isTypeOperatorNode(this) ? "TypeOperatorNode" :
|
|
isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" :
|
|
isMappedTypeNode(this) ? "MappedTypeNode" :
|
|
isLiteralTypeNode(this) ? "LiteralTypeNode" :
|
|
isNamedTupleMember(this) ? "NamedTupleMember" :
|
|
isImportTypeNode(this) ? "ImportTypeNode" :
|
|
Debug.formatSyntaxKind(this.kind);
|
|
return `${nodeHeader}${this.flags ? ` (${Debug.formatNodeFlags(this.flags)})` : ""}`;
|
|
},
|
|
},
|
|
__debugKind: {
|
|
get(this: Node) {
|
|
return Debug.formatSyntaxKind(this.kind);
|
|
},
|
|
},
|
|
__debugNodeFlags: {
|
|
get(this: Node) {
|
|
return Debug.formatNodeFlags(this.flags);
|
|
},
|
|
},
|
|
__debugModifierFlags: {
|
|
get(this: Node) {
|
|
return Debug.formatModifierFlags(getEffectiveModifierFlagsNoCache(this));
|
|
},
|
|
},
|
|
__debugTransformFlags: {
|
|
get(this: Node) {
|
|
return Debug.formatTransformFlags(this.transformFlags);
|
|
},
|
|
},
|
|
__debugIsParseTreeNode: {
|
|
get(this: Node) {
|
|
return isParseTreeNode(this);
|
|
},
|
|
},
|
|
__debugEmitFlags: {
|
|
get(this: Node) {
|
|
return Debug.formatEmitFlags(getEmitFlags(this));
|
|
},
|
|
},
|
|
__debugGetText: {
|
|
value(this: Node, includeTrivia?: boolean) {
|
|
if (nodeIsSynthesized(this)) return "";
|
|
// avoid recomputing
|
|
let text = weakNodeTextMap.get(this);
|
|
if (text === undefined) {
|
|
const parseNode = getParseTreeNode(this);
|
|
const sourceFile = parseNode && getSourceFileOfNode(parseNode);
|
|
text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
|
|
weakNodeTextMap.set(this, text);
|
|
}
|
|
return text;
|
|
},
|
|
},
|
|
});
|
|
}
|
|
});
|
|
|
|
export interface JSDocContainer extends Node {
|
|
_jsdocContainerBrand: any;
|
|
/** @internal */ jsDoc: JSDocArray | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface JSDocArray extends Array<JSDoc> {
|
|
jsDocCache?: readonly JSDocTag[]; // Cache for getJSDocTags
|
|
}
|
|
|
|
export interface LocalsContainer extends Node {
|
|
_localsContainerBrand: any;
|
|
/** @internal */ locals: SymbolTable | undefined; // Locals associated with node (initialized by binding)
|
|
/** @internal */ nextContainer: HasLocals | undefined; // Next container in declaration order (initialized by binding)
|
|
}
|
|
|
|
export interface FlowContainer extends Node {
|
|
_flowContainerBrand: any;
|
|
/** @internal */ flowNode: FlowNode | undefined; // Associated FlowNode (initialized by binding)
|
|
}
|
|
|
|
/** @internal */
|
|
export type HasFlowNode =
|
|
| Identifier
|
|
| ThisExpression
|
|
| SuperExpression
|
|
| QualifiedName
|
|
| MetaProperty
|
|
| ElementAccessExpression
|
|
| PropertyAccessExpression
|
|
| BindingElement
|
|
| FunctionExpression
|
|
| ArrowFunction
|
|
| MethodDeclaration
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| VariableStatement
|
|
| ExpressionStatement
|
|
| IfStatement
|
|
| DoStatement
|
|
| WhileStatement
|
|
| ForStatement
|
|
| ForInStatement
|
|
| ForOfStatement
|
|
| ContinueStatement
|
|
| BreakStatement
|
|
| ReturnStatement
|
|
| WithStatement
|
|
| SwitchStatement
|
|
| LabeledStatement
|
|
| ThrowStatement
|
|
| TryStatement
|
|
| DebuggerStatement;
|
|
|
|
// Ideally, `ForEachChildNodes` and `VisitEachChildNodes` would not differ.
|
|
// However, `forEachChild` currently processes JSDoc comment syntax and missing declarations more thoroughly.
|
|
// On the other hand, `visitEachChild` actually processes `Identifier`s (which really *shouldn't* have children,
|
|
// but are constructed as if they could for faked-up `QualifiedName`s in the language service.)
|
|
|
|
/** @internal */
|
|
export type ForEachChildNodes =
|
|
| HasChildren
|
|
| MissingDeclaration
|
|
| JSDocTypeExpression
|
|
| JSDocNonNullableType
|
|
| JSDocNullableType
|
|
| JSDocOptionalType
|
|
| JSDocVariadicType
|
|
| JSDocFunctionType
|
|
| JSDoc
|
|
| JSDocSeeTag
|
|
| JSDocNameReference
|
|
| JSDocMemberName
|
|
| JSDocParameterTag
|
|
| JSDocPropertyTag
|
|
| JSDocAuthorTag
|
|
| JSDocImplementsTag
|
|
| JSDocAugmentsTag
|
|
| JSDocTemplateTag
|
|
| JSDocTypedefTag
|
|
| JSDocCallbackTag
|
|
| JSDocReturnTag
|
|
| JSDocTypeTag
|
|
| JSDocThisTag
|
|
| JSDocEnumTag
|
|
| JSDocSignature
|
|
| JSDocLink
|
|
| JSDocLinkCode
|
|
| JSDocLinkPlain
|
|
| JSDocTypeLiteral
|
|
| JSDocUnknownTag
|
|
| JSDocClassTag
|
|
| JSDocPublicTag
|
|
| JSDocPrivateTag
|
|
| JSDocProtectedTag
|
|
| JSDocReadonlyTag
|
|
| JSDocDeprecatedTag
|
|
| JSDocThrowsTag
|
|
| JSDocOverrideTag
|
|
| JSDocSatisfiesTag
|
|
| JSDocOverloadTag
|
|
| JSDocImportTag;
|
|
|
|
/** @internal */
|
|
export type HasChildren =
|
|
| QualifiedName
|
|
| ComputedPropertyName
|
|
| TypeParameterDeclaration
|
|
| ParameterDeclaration
|
|
| Decorator
|
|
| PropertySignature
|
|
| PropertyDeclaration
|
|
| MethodSignature
|
|
| MethodDeclaration
|
|
| ConstructorDeclaration
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| ClassStaticBlockDeclaration
|
|
| CallSignatureDeclaration
|
|
| ConstructSignatureDeclaration
|
|
| IndexSignatureDeclaration
|
|
| TypePredicateNode
|
|
| TypeReferenceNode
|
|
| FunctionTypeNode
|
|
| ConstructorTypeNode
|
|
| TypeQueryNode
|
|
| TypeLiteralNode
|
|
| ArrayTypeNode
|
|
| TupleTypeNode
|
|
| OptionalTypeNode
|
|
| RestTypeNode
|
|
| UnionTypeNode
|
|
| IntersectionTypeNode
|
|
| ConditionalTypeNode
|
|
| InferTypeNode
|
|
| ImportTypeNode
|
|
| ImportTypeAssertionContainer
|
|
| NamedTupleMember
|
|
| ParenthesizedTypeNode
|
|
| TypeOperatorNode
|
|
| IndexedAccessTypeNode
|
|
| MappedTypeNode
|
|
| LiteralTypeNode
|
|
| TemplateLiteralTypeNode
|
|
| TemplateLiteralTypeSpan
|
|
| ObjectBindingPattern
|
|
| ArrayBindingPattern
|
|
| BindingElement
|
|
| ArrayLiteralExpression
|
|
| ObjectLiteralExpression
|
|
| PropertyAccessExpression
|
|
| ElementAccessExpression
|
|
| CallExpression
|
|
| NewExpression
|
|
| TaggedTemplateExpression
|
|
| TypeAssertionExpression
|
|
| ParenthesizedExpression
|
|
| FunctionExpression
|
|
| ArrowFunction
|
|
| DeleteExpression
|
|
| TypeOfExpression
|
|
| VoidExpression
|
|
| AwaitExpression
|
|
| PrefixUnaryExpression
|
|
| PostfixUnaryExpression
|
|
| BinaryExpression
|
|
| ConditionalExpression
|
|
| TemplateExpression
|
|
| YieldExpression
|
|
| SpreadElement
|
|
| ClassExpression
|
|
| ExpressionWithTypeArguments
|
|
| AsExpression
|
|
| NonNullExpression
|
|
| SatisfiesExpression
|
|
| MetaProperty
|
|
| TemplateSpan
|
|
| Block
|
|
| VariableStatement
|
|
| ExpressionStatement
|
|
| IfStatement
|
|
| DoStatement
|
|
| WhileStatement
|
|
| ForStatement
|
|
| ForInStatement
|
|
| ForOfStatement
|
|
| ContinueStatement
|
|
| BreakStatement
|
|
| ReturnStatement
|
|
| WithStatement
|
|
| SwitchStatement
|
|
| LabeledStatement
|
|
| ThrowStatement
|
|
| TryStatement
|
|
| VariableDeclaration
|
|
| VariableDeclarationList
|
|
| FunctionDeclaration
|
|
| ClassDeclaration
|
|
| InterfaceDeclaration
|
|
| TypeAliasDeclaration
|
|
| EnumDeclaration
|
|
| ModuleDeclaration
|
|
| ModuleBlock
|
|
| CaseBlock
|
|
| NamespaceExportDeclaration
|
|
| ImportEqualsDeclaration
|
|
| ImportDeclaration
|
|
| AssertClause
|
|
| AssertEntry
|
|
| ImportAttributes
|
|
| ImportAttribute
|
|
| ImportClause
|
|
| NamespaceImport
|
|
| NamespaceExport
|
|
| NamedImports
|
|
| ImportSpecifier
|
|
| ExportAssignment
|
|
| ExportDeclaration
|
|
| NamedExports
|
|
| ExportSpecifier
|
|
| ExternalModuleReference
|
|
| JsxElement
|
|
| JsxSelfClosingElement
|
|
| JsxOpeningElement
|
|
| JsxClosingElement
|
|
| JsxFragment
|
|
| JsxAttribute
|
|
| JsxAttributes
|
|
| JsxSpreadAttribute
|
|
| JsxExpression
|
|
| JsxNamespacedName
|
|
| CaseClause
|
|
| DefaultClause
|
|
| HeritageClause
|
|
| CatchClause
|
|
| PropertyAssignment
|
|
| ShorthandPropertyAssignment
|
|
| SpreadAssignment
|
|
| EnumMember
|
|
| SourceFile
|
|
| PartiallyEmittedExpression
|
|
| CommaListExpression;
|
|
|
|
export type HasJSDoc =
|
|
| AccessorDeclaration
|
|
| ArrowFunction
|
|
| BinaryExpression
|
|
| Block
|
|
| BreakStatement
|
|
| CallSignatureDeclaration
|
|
| CaseClause
|
|
| ClassLikeDeclaration
|
|
| ClassStaticBlockDeclaration
|
|
| ConstructorDeclaration
|
|
| ConstructorTypeNode
|
|
| ConstructSignatureDeclaration
|
|
| ContinueStatement
|
|
| DebuggerStatement
|
|
| DoStatement
|
|
| ElementAccessExpression
|
|
| EmptyStatement
|
|
| EndOfFileToken
|
|
| EnumDeclaration
|
|
| EnumMember
|
|
| ExportAssignment
|
|
| ExportDeclaration
|
|
| ExportSpecifier
|
|
| ExpressionStatement
|
|
| ForInStatement
|
|
| ForOfStatement
|
|
| ForStatement
|
|
| FunctionDeclaration
|
|
| FunctionExpression
|
|
| FunctionTypeNode
|
|
| Identifier
|
|
| IfStatement
|
|
| ImportDeclaration
|
|
| ImportEqualsDeclaration
|
|
| IndexSignatureDeclaration
|
|
| InterfaceDeclaration
|
|
| JSDocFunctionType
|
|
| JSDocSignature
|
|
| LabeledStatement
|
|
| MethodDeclaration
|
|
| MethodSignature
|
|
| ModuleDeclaration
|
|
| NamedTupleMember
|
|
| NamespaceExportDeclaration
|
|
| ObjectLiteralExpression
|
|
| ParameterDeclaration
|
|
| ParenthesizedExpression
|
|
| PropertyAccessExpression
|
|
| PropertyAssignment
|
|
| PropertyDeclaration
|
|
| PropertySignature
|
|
| ReturnStatement
|
|
| SemicolonClassElement
|
|
| ShorthandPropertyAssignment
|
|
| SpreadAssignment
|
|
| SwitchStatement
|
|
| ThrowStatement
|
|
| TryStatement
|
|
| TypeAliasDeclaration
|
|
| TypeParameterDeclaration
|
|
| VariableDeclaration
|
|
| VariableStatement
|
|
| WhileStatement
|
|
| WithStatement
|
|
| ModuleBlock
|
|
| MissingDeclaration
|
|
| NotEmittedStatement;
|
|
|
|
export type HasType =
|
|
| SignatureDeclaration
|
|
| VariableDeclaration
|
|
| ParameterDeclaration
|
|
| PropertySignature
|
|
| PropertyDeclaration
|
|
| TypePredicateNode
|
|
| ParenthesizedTypeNode
|
|
| TypeOperatorNode
|
|
| MappedTypeNode
|
|
| AssertionExpression
|
|
| TypeAliasDeclaration
|
|
| JSDocTypeExpression
|
|
| JSDocNonNullableType
|
|
| JSDocNullableType
|
|
| JSDocOptionalType
|
|
| JSDocVariadicType;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveIllegalType` in factory/utilities.ts
|
|
/** @internal */
|
|
export type HasIllegalType =
|
|
| ConstructorDeclaration
|
|
| SetAccessorDeclaration;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveIllegalTypeParameters` in factory/utilities.ts
|
|
/** @internal */
|
|
export type HasIllegalTypeParameters =
|
|
| ConstructorDeclaration
|
|
| SetAccessorDeclaration
|
|
| GetAccessorDeclaration;
|
|
|
|
export type HasTypeArguments =
|
|
| CallExpression
|
|
| NewExpression
|
|
| TaggedTemplateExpression
|
|
| JsxOpeningElement
|
|
| JsxSelfClosingElement;
|
|
|
|
export type HasInitializer =
|
|
| HasExpressionInitializer
|
|
| ForStatement
|
|
| ForInStatement
|
|
| ForOfStatement
|
|
| JsxAttribute;
|
|
|
|
export type HasExpressionInitializer =
|
|
| VariableDeclaration
|
|
| ParameterDeclaration
|
|
| BindingElement
|
|
| PropertyDeclaration
|
|
| PropertyAssignment
|
|
| EnumMember;
|
|
|
|
/** @internal @knipignore */
|
|
export type HasIllegalExpressionInitializer = PropertySignature;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveDecorators` in factory/utilities.ts
|
|
// - `updateModifiers` in factory/nodeFactory.ts
|
|
export type HasDecorators =
|
|
| ParameterDeclaration
|
|
| PropertyDeclaration
|
|
| MethodDeclaration
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| ClassExpression
|
|
| ClassDeclaration;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveIllegalDecorators` in factory/utilities.ts
|
|
/** @internal */
|
|
export type HasIllegalDecorators =
|
|
| PropertyAssignment
|
|
| ShorthandPropertyAssignment
|
|
| FunctionDeclaration
|
|
| ConstructorDeclaration
|
|
| IndexSignatureDeclaration
|
|
| ClassStaticBlockDeclaration
|
|
| MissingDeclaration
|
|
| VariableStatement
|
|
| InterfaceDeclaration
|
|
| TypeAliasDeclaration
|
|
| EnumDeclaration
|
|
| ModuleDeclaration
|
|
| ImportEqualsDeclaration
|
|
| ImportDeclaration
|
|
| NamespaceExportDeclaration
|
|
| ExportDeclaration
|
|
| ExportAssignment;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveModifiers` in factory/utilitiesPublic.ts
|
|
// - `updateModifiers` in factory/nodeFactory.ts
|
|
export type HasModifiers =
|
|
| TypeParameterDeclaration
|
|
| ParameterDeclaration
|
|
| ConstructorTypeNode
|
|
| PropertySignature
|
|
| PropertyDeclaration
|
|
| MethodSignature
|
|
| MethodDeclaration
|
|
| ConstructorDeclaration
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| IndexSignatureDeclaration
|
|
| FunctionExpression
|
|
| ArrowFunction
|
|
| ClassExpression
|
|
| VariableStatement
|
|
| FunctionDeclaration
|
|
| ClassDeclaration
|
|
| InterfaceDeclaration
|
|
| TypeAliasDeclaration
|
|
| EnumDeclaration
|
|
| ModuleDeclaration
|
|
| ImportEqualsDeclaration
|
|
| ImportDeclaration
|
|
| ExportAssignment
|
|
| ExportDeclaration;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveIllegalModifiers` in factory/utilities.ts
|
|
/** @internal */
|
|
export type HasIllegalModifiers =
|
|
| ClassStaticBlockDeclaration
|
|
| PropertyAssignment
|
|
| ShorthandPropertyAssignment
|
|
| MissingDeclaration
|
|
| NamespaceExportDeclaration;
|
|
|
|
/** @internal */
|
|
export type PrimitiveLiteral =
|
|
| BooleanLiteral
|
|
| NumericLiteral
|
|
| StringLiteral
|
|
| NoSubstitutionTemplateLiteral
|
|
| BigIntLiteral
|
|
| PrefixUnaryExpression & { operator: SyntaxKind.PlusToken; operand: NumericLiteral; }
|
|
| PrefixUnaryExpression & { operator: SyntaxKind.MinusToken; operand: NumericLiteral | BigIntLiteral; };
|
|
|
|
/**
|
|
* Declarations that can contain other declarations. Corresponds with `ContainerFlags.IsContainer` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsContainer =
|
|
| ClassExpression
|
|
| ClassDeclaration
|
|
| EnumDeclaration
|
|
| ObjectLiteralExpression
|
|
| TypeLiteralNode
|
|
| JSDocTypeLiteral
|
|
| JsxAttributes
|
|
| InterfaceDeclaration
|
|
| ModuleDeclaration
|
|
| TypeAliasDeclaration
|
|
| MappedTypeNode
|
|
| IndexSignatureDeclaration
|
|
| SourceFile
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| MethodDeclaration
|
|
| ConstructorDeclaration
|
|
| FunctionDeclaration
|
|
| MethodSignature
|
|
| CallSignatureDeclaration
|
|
| JSDocSignature
|
|
| JSDocFunctionType
|
|
| FunctionTypeNode
|
|
| ConstructSignatureDeclaration
|
|
| ConstructorTypeNode
|
|
| ClassStaticBlockDeclaration
|
|
| FunctionExpression
|
|
| ArrowFunction;
|
|
|
|
/**
|
|
* Nodes that introduce a new block scope. Corresponds with `ContainerFlags.IsBlockScopedContainer` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsBlockScopedContainer =
|
|
| IsContainer
|
|
| CatchClause
|
|
| ForStatement
|
|
| ForInStatement
|
|
| ForOfStatement
|
|
| CaseBlock
|
|
| Block;
|
|
|
|
/**
|
|
* Corresponds with `ContainerFlags.IsControlFlowContainer` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsControlFlowContainer =
|
|
| SourceFile
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| MethodDeclaration
|
|
| ConstructorDeclaration
|
|
| FunctionDeclaration
|
|
| MethodSignature
|
|
| CallSignatureDeclaration
|
|
| JSDocSignature
|
|
| JSDocFunctionType
|
|
| FunctionTypeNode
|
|
| ConstructSignatureDeclaration
|
|
| ConstructorTypeNode
|
|
| ClassStaticBlockDeclaration
|
|
| FunctionExpression
|
|
| ArrowFunction
|
|
| ModuleBlock
|
|
| PropertyDeclaration;
|
|
|
|
/**
|
|
* Corresponds with `ContainerFlags.IsFunctionLike` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsFunctionLike =
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| MethodDeclaration
|
|
| ConstructorDeclaration
|
|
| FunctionDeclaration
|
|
| MethodSignature
|
|
| CallSignatureDeclaration
|
|
| JSDocSignature
|
|
| JSDocFunctionType
|
|
| FunctionTypeNode
|
|
| ConstructSignatureDeclaration
|
|
| ConstructorTypeNode
|
|
| ClassStaticBlockDeclaration
|
|
| FunctionExpression
|
|
| ArrowFunction;
|
|
|
|
/**
|
|
* Corresponds with `ContainerFlags.IsFunctionExpression` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsFunctionExpression =
|
|
| FunctionExpression
|
|
| ArrowFunction;
|
|
|
|
/**
|
|
* Nodes that can have local symbols. Corresponds with `ContainerFlags.HasLocals`. Constituents should extend
|
|
* {@link LocalsContainer}.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type HasLocals =
|
|
| ArrowFunction
|
|
| Block
|
|
| CallSignatureDeclaration
|
|
| CaseBlock
|
|
| CatchClause
|
|
| ClassStaticBlockDeclaration
|
|
| ConditionalTypeNode
|
|
| ConstructorDeclaration
|
|
| ConstructorTypeNode
|
|
| ConstructSignatureDeclaration
|
|
| ForStatement
|
|
| ForInStatement
|
|
| ForOfStatement
|
|
| FunctionDeclaration
|
|
| FunctionExpression
|
|
| FunctionTypeNode
|
|
| GetAccessorDeclaration
|
|
| IndexSignatureDeclaration
|
|
| JSDocCallbackTag
|
|
| JSDocEnumTag
|
|
| JSDocFunctionType
|
|
| JSDocSignature
|
|
| JSDocTypedefTag
|
|
| MappedTypeNode
|
|
| MethodDeclaration
|
|
| MethodSignature
|
|
| ModuleDeclaration
|
|
| SetAccessorDeclaration
|
|
| SourceFile
|
|
| TypeAliasDeclaration;
|
|
|
|
/**
|
|
* Corresponds with `ContainerFlags.IsInterface` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsInterface = InterfaceDeclaration;
|
|
|
|
/**
|
|
* Corresponds with `ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type IsObjectLiteralOrClassExpressionMethodOrAccessor =
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| MethodDeclaration;
|
|
|
|
/**
|
|
* Corresponds with `ContainerFlags` in binder.ts.
|
|
*
|
|
* @internal
|
|
*/
|
|
export type HasContainerFlags =
|
|
| IsContainer
|
|
| IsBlockScopedContainer
|
|
| IsControlFlowContainer
|
|
| IsFunctionLike
|
|
| IsFunctionExpression
|
|
| HasLocals
|
|
| IsInterface
|
|
| IsObjectLiteralOrClassExpressionMethodOrAccessor;
|
|
|
|
/** @internal */
|
|
export interface MutableNodeArray<T extends Node> extends Array<T>, TextRange {
|
|
hasTrailingComma: boolean;
|
|
/** @internal */ transformFlags: TransformFlags; // Flags for transforms, possibly undefined
|
|
}
|
|
|
|
const ReadonlyArray = Array as new <T>(...items: readonly T[]) => readonly T[];
|
|
|
|
// dprint-ignore
|
|
export class NodeArray<N extends Node> extends ReadonlyArray<N> {
|
|
readonly ast: AstNodeArray<N["ast"]> = undefined!;
|
|
|
|
constructor(ast: AstNodeArray<N["ast"]>) {
|
|
super(...ast.items.map(item => item.node as N));
|
|
this.ast = ast;
|
|
Object.preventExtensions(this);
|
|
}
|
|
|
|
static get [globalThis.Symbol.species](): ArrayConstructor { return Array; }
|
|
|
|
get pos(): number { return this.ast.pos; }
|
|
get end(): number { return this.ast.end; }
|
|
get hasTrailingComma(): boolean { return this.ast.hasTrailingComma; }
|
|
|
|
/** @internal */ set pos(value) { this.ast.pos = value; }
|
|
/** @internal */ set end(value) { this.ast.end = value; }
|
|
/** @internal */ set hasTrailingComma(value) { this.ast.hasTrailingComma = value; }
|
|
/** @internal */ get transformFlags(): TransformFlags { return this.ast.transformFlags; }
|
|
/** @internal */ set transformFlags(value) { this.ast.transformFlags = value; }
|
|
/** @internal */ get __pos(): number | undefined { return this.ast.__pos; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
/** @internal */ set __pos(value) { this.ast.__pos = value; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
/** @internal */ get __end(): number | undefined { return this.ast.__end; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
/** @internal */ set __end(value) { this.ast.__end = value; } // eslint-disable-line @typescript-eslint/naming-convention
|
|
}
|
|
|
|
Debug.registerDebugInfo(() => {
|
|
if (!("__tsDebuggerDisplay" in NodeArray.prototype)) { // eslint-disable-line local/no-in-operator
|
|
Object.defineProperties(NodeArray.prototype, {
|
|
__tsDebuggerDisplay: {
|
|
value(this: NodeArray<Node>, defaultValue: string) {
|
|
// An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of
|
|
// these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the
|
|
// formatted string.
|
|
// This regex can trigger slow backtracking because of overlapping potential captures.
|
|
// We don't care, this is debug code that's only enabled with a debugger attached -
|
|
// we're just taking note of it for anyone checking regex performance in the future.
|
|
defaultValue = String(defaultValue).replace(/(?:,[\s\w]+:[^,]+)+\]$/, "]");
|
|
return `NodeArray ${defaultValue}`;
|
|
},
|
|
},
|
|
});
|
|
}
|
|
});
|
|
|
|
// dprint-ignore
|
|
export class Token<K extends TokenSyntaxKind = TokenSyntaxKind, T extends AstTokenData = AstTokenData> extends Node<K, T> {
|
|
override getChildCount(_sourceFile?: SourceFileLike): number {
|
|
return this.getChildren().length;
|
|
}
|
|
|
|
override getChildAt(index: number, _sourceFile?: SourceFileLike): Node {
|
|
return this.getChildren()[index];
|
|
}
|
|
|
|
override getChildren(_sourceFile?: SourceFileLike): readonly Node[] {
|
|
return this.kind === SyntaxKind.EndOfFileToken ? (this as Node as EndOfFileToken).jsDoc ?? emptyArray : emptyArray;
|
|
}
|
|
|
|
override getFirstToken(_sourceFile?: SourceFileLike): Node | undefined {
|
|
return undefined;
|
|
}
|
|
|
|
override getLastToken(_sourceFile?: SourceFileLike): Node | undefined {
|
|
return undefined;
|
|
}
|
|
|
|
override forEachChild<T>(_cbNode: (node: Node) => T | undefined, _cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class EndOfFileToken extends Token<SyntaxKind.EndOfFileToken, AstEndOfFileTokenData> implements JSDocContainer {
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstEndOfFileToken;
|
|
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// Punctuation
|
|
export interface PunctuationToken<TKind extends PunctuationSyntaxKind> extends Token<TKind> {
|
|
}
|
|
|
|
export type DotToken = PunctuationToken<SyntaxKind.DotToken>;
|
|
export type DotDotDotToken = PunctuationToken<SyntaxKind.DotDotDotToken>;
|
|
export type QuestionToken = PunctuationToken<SyntaxKind.QuestionToken>;
|
|
export type ExclamationToken = PunctuationToken<SyntaxKind.ExclamationToken>;
|
|
export type ColonToken = PunctuationToken<SyntaxKind.ColonToken>;
|
|
export type EqualsToken = PunctuationToken<SyntaxKind.EqualsToken>;
|
|
export type AmpersandAmpersandEqualsToken = PunctuationToken<SyntaxKind.AmpersandAmpersandEqualsToken>;
|
|
export type BarBarEqualsToken = PunctuationToken<SyntaxKind.BarBarEqualsToken>;
|
|
export type QuestionQuestionEqualsToken = PunctuationToken<SyntaxKind.QuestionQuestionEqualsToken>;
|
|
export type AsteriskToken = PunctuationToken<SyntaxKind.AsteriskToken>;
|
|
export type EqualsGreaterThanToken = PunctuationToken<SyntaxKind.EqualsGreaterThanToken>;
|
|
export type PlusToken = PunctuationToken<SyntaxKind.PlusToken>;
|
|
export type MinusToken = PunctuationToken<SyntaxKind.MinusToken>;
|
|
export type QuestionDotToken = PunctuationToken<SyntaxKind.QuestionDotToken>;
|
|
|
|
// Keywords
|
|
export interface KeywordToken<TKind extends KeywordSyntaxKind> extends Token<TKind> {
|
|
}
|
|
|
|
export type AssertsKeyword = KeywordToken<SyntaxKind.AssertsKeyword>;
|
|
export type AssertKeyword = KeywordToken<SyntaxKind.AssertKeyword>;
|
|
export type AwaitKeyword = KeywordToken<SyntaxKind.AwaitKeyword>;
|
|
export type CaseKeyword = KeywordToken<SyntaxKind.CaseKeyword>;
|
|
|
|
export interface ModifierToken<TKind extends ModifierSyntaxKind> extends KeywordToken<TKind> {
|
|
}
|
|
|
|
export type AbstractKeyword = ModifierToken<SyntaxKind.AbstractKeyword>;
|
|
export type AccessorKeyword = ModifierToken<SyntaxKind.AccessorKeyword>;
|
|
export type AsyncKeyword = ModifierToken<SyntaxKind.AsyncKeyword>;
|
|
export type ConstKeyword = ModifierToken<SyntaxKind.ConstKeyword>;
|
|
export type DeclareKeyword = ModifierToken<SyntaxKind.DeclareKeyword>;
|
|
export type DefaultKeyword = ModifierToken<SyntaxKind.DefaultKeyword>;
|
|
export type ExportKeyword = ModifierToken<SyntaxKind.ExportKeyword>;
|
|
export type InKeyword = ModifierToken<SyntaxKind.InKeyword>;
|
|
export type PrivateKeyword = ModifierToken<SyntaxKind.PrivateKeyword>;
|
|
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
|
|
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
|
|
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
|
|
export type OutKeyword = ModifierToken<SyntaxKind.OutKeyword>;
|
|
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
|
|
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
|
|
|
|
export type Modifier =
|
|
| AbstractKeyword
|
|
| AccessorKeyword
|
|
| AsyncKeyword
|
|
| ConstKeyword
|
|
| DeclareKeyword
|
|
| DefaultKeyword
|
|
| ExportKeyword
|
|
| InKeyword
|
|
| PrivateKeyword
|
|
| ProtectedKeyword
|
|
| PublicKeyword
|
|
| OutKeyword
|
|
| OverrideKeyword
|
|
| ReadonlyKeyword
|
|
| StaticKeyword;
|
|
|
|
export type ModifierLike = Modifier | Decorator;
|
|
|
|
export type AccessibilityModifier =
|
|
| PublicKeyword
|
|
| PrivateKeyword
|
|
| ProtectedKeyword;
|
|
|
|
export type ParameterPropertyModifier =
|
|
| AccessibilityModifier
|
|
| ReadonlyKeyword;
|
|
|
|
export type ClassMemberModifier =
|
|
| AccessibilityModifier
|
|
| ReadonlyKeyword
|
|
| StaticKeyword
|
|
| AccessorKeyword;
|
|
|
|
export type ModifiersArray = NodeArray<Modifier>;
|
|
|
|
export interface KeywordExpression<TKind extends KeywordSyntaxKind = KeywordSyntaxKind> extends PrimaryExpression, KeywordToken<TKind> {
|
|
// readonly ast: AstKeywordExpression<TKind>;
|
|
readonly kind: TKind;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum GeneratedIdentifierFlags {
|
|
// Kinds
|
|
None = 0, // Not automatically generated.
|
|
/** @internal */ Auto = 1, // Automatically generated identifier.
|
|
/** @internal */ Loop = 2, // Automatically generated identifier with a preference for '_i'.
|
|
/** @internal */ Unique = 3, // Unique name based on the 'text' property.
|
|
/** @internal */ Node = 4, // Unique name based on the node in the 'original' property.
|
|
/** @internal */ KindMask = 7, // Mask to extract the kind of identifier from its flags.
|
|
|
|
// Flags
|
|
ReservedInNestedScopes = 1 << 3, // Reserve the generated name in nested scopes
|
|
Optimistic = 1 << 4, // First instance won't use '_#' if there's no conflict
|
|
FileLevel = 1 << 5, // Use only the file identifiers list and not generated names to search for conflicts
|
|
AllowNameSubstitution = 1 << 6, // Used by `module.ts` to indicate generated nodes which can have substitutions performed upon them (as they were generated by an earlier transform phase)
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class Identifier extends Token<SyntaxKind.Identifier, AstIdentifierData> implements PrimaryExpression, Declaration, JSDocContainer, FlowContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstIdentifier;
|
|
|
|
/**
|
|
* Prefer to use {@link text}.
|
|
* Text of identifier, but if the identifier begins with two underscores, this will begin with three.
|
|
*/
|
|
get escapedText(): __String { return this.ast.data.escapedText; }
|
|
get text(): string { return idText(this); }
|
|
|
|
/** @internal */ set escapedText(value: __String) { this.ast.data.escapedText = value; }
|
|
/** @internal */ get resolvedSymbol(): Symbol { return this.ast.data.resolvedSymbol; }
|
|
/** @internal */ set resolvedSymbol(value: Symbol) { this.ast.data.resolvedSymbol = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value) { this.ast.data.flowNode = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface AutoGenerateInfo {
|
|
flags: GeneratedIdentifierFlags; // Specifies whether to auto-generate the text for an identifier.
|
|
readonly id: number; // Ensures unique generated identifiers get unique names, but clones get the same name.
|
|
readonly prefix?: string | GeneratedNamePart;
|
|
readonly suffix?: string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface GeneratedIdentifier extends Identifier {
|
|
readonly emitNode: EmitNode & { autoGenerate: AutoGenerateInfo; };
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class QualifiedName extends Node<SyntaxKind.QualifiedName, AstQualifiedNameData> implements FlowContainer {
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstQualifiedName;
|
|
|
|
get left(): EntityName { return this.ast.data.left?.node; }
|
|
get right(): Identifier { return this.ast.data.right?.node; }
|
|
|
|
/** @internal */ set left(value: EntityName) { this.ast.data.left = value?.ast; }
|
|
/** @internal */ set right(value: Identifier) { this.ast.data.right = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
export type EntityName = Identifier | QualifiedName;
|
|
|
|
export type PropertyName =
|
|
| Identifier
|
|
| StringLiteral
|
|
| NoSubstitutionTemplateLiteral
|
|
| NumericLiteral
|
|
| ComputedPropertyName
|
|
| PrivateIdentifier
|
|
| BigIntLiteral;
|
|
|
|
export type MemberName = Identifier | PrivateIdentifier;
|
|
|
|
export type DeclarationName =
|
|
| PropertyName
|
|
| JsxAttributeName
|
|
| StringLiteralLike
|
|
| ElementAccessExpression
|
|
| BindingPattern
|
|
| EntityNameExpression;
|
|
|
|
export interface Declaration extends Node {
|
|
_declarationBrand: any;
|
|
// readonly ast: AstDeclaration;
|
|
/** @internal */ symbol: Symbol; // Symbol declared by node (initialized by binding)
|
|
/** @internal */ localSymbol: Symbol | undefined; // Local symbol declared by node (initialized by binding only for exported nodes)
|
|
}
|
|
|
|
export interface NamedDeclaration extends Declaration {
|
|
readonly name?: DeclarationName | undefined;
|
|
}
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveName` in utilitiesPublic.ts
|
|
/** @internal */
|
|
export type HasName =
|
|
| FunctionDeclaration
|
|
| FunctionExpression
|
|
| ClassExpression
|
|
| ClassDeclaration
|
|
| MethodDeclaration
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| PropertyDeclaration
|
|
| InterfaceDeclaration
|
|
| MethodSignature
|
|
| PropertySignature
|
|
| TypeAliasDeclaration
|
|
| EnumDeclaration
|
|
| EnumMember
|
|
| ModuleDeclaration
|
|
| VariableDeclaration
|
|
| ParameterDeclaration
|
|
| BindingElement
|
|
| TypeParameterDeclaration
|
|
| ImportEqualsDeclaration
|
|
| NamespaceExportDeclaration
|
|
| ImportClause
|
|
| NamespaceImport
|
|
| NamespaceExport
|
|
| ImportSpecifier
|
|
| ExportSpecifier
|
|
| JSDocTypedefTag
|
|
| JSDocCallbackTag
|
|
| PropertyAssignment
|
|
| ShorthandPropertyAssignment
|
|
| NamedTupleMember
|
|
| PropertyAccessExpression
|
|
| MetaProperty
|
|
| ImportAttribute
|
|
| JsxAttribute
|
|
| JsxNamespacedName
|
|
| JSDocNameReference
|
|
| JSDocLink
|
|
| JSDocLinkCode
|
|
| JSDocLinkPlain
|
|
| JSDocParameterTag
|
|
| JSDocSeeTag
|
|
| JSDocPropertyTag
|
|
| MissingDeclaration;
|
|
|
|
/** @internal */
|
|
export interface DynamicNamedDeclaration extends NamedDeclaration {
|
|
readonly name: ComputedPropertyName;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface DynamicNamedBinaryExpression extends BinaryExpression {
|
|
readonly left: ElementAccessExpression;
|
|
}
|
|
|
|
/** @internal */
|
|
// A declaration that supports late-binding (used in checker)
|
|
export interface LateBoundDeclaration extends DynamicNamedDeclaration {
|
|
readonly name: LateBoundName;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface LateBoundBinaryExpressionDeclaration extends DynamicNamedBinaryExpression {
|
|
readonly left: LateBoundElementAccessExpression;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface LateBoundElementAccessExpression extends ElementAccessExpression {
|
|
readonly argumentExpression: EntityNameExpression;
|
|
}
|
|
|
|
export interface DeclarationStatement extends NamedDeclaration, Statement {
|
|
// readonly ast: AstNode<Declaration & Statement>;
|
|
readonly name?: Identifier | StringLiteral | NumericLiteral | undefined;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ComputedPropertyName extends Node<SyntaxKind.ComputedPropertyName, AstComputedPropertyNameData> {
|
|
// declare readonly ast: AstComputedPropertyName;
|
|
|
|
override get parent(): Declaration { return super.parent as Declaration; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ override set parent(value: Declaration) { super.parent = value; }
|
|
/** @internal */ set expression(value: Expression) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// Typed as a PrimaryExpression due to its presence in BinaryExpressions (#field in expr)
|
|
// dprint-ignore
|
|
export class PrivateIdentifier extends Token<SyntaxKind.PrivateIdentifier, AstPrivateIdentifierData> {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstPrivateIdentifier;
|
|
|
|
get escapedText(): __String { return this.ast.data.escapedText; }
|
|
get text(): string { return idText(this); }
|
|
|
|
/** @internal */ set escapedText(value: __String) { this.ast.data.escapedText = value; }
|
|
}
|
|
|
|
/** @internal */
|
|
export interface GeneratedPrivateIdentifier extends PrivateIdentifier {
|
|
readonly emitNode: EmitNode & { autoGenerate: AutoGenerateInfo; };
|
|
}
|
|
|
|
/** @internal */
|
|
// A name that supports late-binding (used in checker)
|
|
export interface LateBoundName extends ComputedPropertyName {
|
|
readonly expression: EntityNameExpression;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class Decorator extends Node<SyntaxKind.Decorator, AstDecoratorData> {
|
|
// declare readonly ast: AstDecorator;
|
|
|
|
override get parent(): Declaration { return super.parent as Declaration; }
|
|
|
|
get expression(): LeftHandSideExpression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ override set parent(value: Declaration) { super.parent = value; }
|
|
/** @internal */ set expression(value: LeftHandSideExpression) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypeParameterDeclaration extends Node<SyntaxKind.TypeParameter, AstTypeParameterDeclarationData> implements Declaration, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstTypeParameterDeclaration;
|
|
|
|
override get parent(): DeclarationWithTypeParameterChildren | InferTypeNode { return super.parent as DeclarationWithTypeParameterChildren | InferTypeNode; }
|
|
|
|
get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
/**
|
|
* NOTE: Consider calling `getEffectiveConstraintOfTypeParameter`
|
|
*/
|
|
get constraint(): TypeNode | undefined { return this.ast.data.constraint?.node; }
|
|
get default(): TypeNode | undefined { return this.ast.data.default?.node; }
|
|
|
|
/** @internal */ override set parent(value: DeclarationWithTypeParameterChildren | InferTypeNode) { super.parent = value; }
|
|
/** @internal */ set modifiers(value: NodeArray<Modifier> | undefined) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value: Identifier) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set constraint(value: TypeNode | undefined) { this.ast.data.constraint = value?.ast; }
|
|
/** @internal */ set default(value: TypeNode | undefined) { this.ast.data.default = value?.ast; }
|
|
/** @internal */ get expression(): Expression | undefined { return this.ast.data.expression?.node; }
|
|
/** @internal */ set expression(value: Expression | undefined) { this.ast.data.expression = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer {
|
|
// readonly ast: AstNode<Declaration & JSDocContainer>;
|
|
readonly kind: SignatureDeclaration["kind"];
|
|
readonly name?: PropertyName | undefined;
|
|
readonly typeParameters?: NodeArray<TypeParameterDeclaration> | undefined;
|
|
readonly parameters: NodeArray<ParameterDeclaration>;
|
|
readonly type?: TypeNode | undefined;
|
|
/** @internal */ typeArguments?: NodeArray<TypeNode> | undefined; // Used for quick info, replaces typeParameters for instantiated signatures
|
|
}
|
|
|
|
export type SignatureDeclaration =
|
|
| CallSignatureDeclaration
|
|
| ConstructSignatureDeclaration
|
|
| MethodSignature
|
|
| IndexSignatureDeclaration
|
|
| FunctionTypeNode
|
|
| ConstructorTypeNode
|
|
| JSDocFunctionType
|
|
| FunctionDeclaration
|
|
| MethodDeclaration
|
|
| ConstructorDeclaration
|
|
| AccessorDeclaration
|
|
| FunctionExpression
|
|
| ArrowFunction;
|
|
|
|
// dprint-ignore
|
|
export class CallSignatureDeclaration extends Node<SyntaxKind.CallSignature, AstCallSignatureDeclarationData> implements SignatureDeclarationBase, TypeElement, LocalsContainer {
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _typeElementBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstCallSignatureDeclaration;
|
|
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ConstructSignatureDeclaration extends Node<SyntaxKind.ConstructSignature, AstConstructSignatureDeclarationData> implements SignatureDeclarationBase, TypeElement, LocalsContainer {
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _typeElementBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstConstructSignatureDeclaration;
|
|
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
export type BindingName = Identifier | BindingPattern;
|
|
|
|
// dprint-ignore
|
|
export class VariableDeclaration extends Node<SyntaxKind.VariableDeclaration, AstVariableDeclarationData> implements Declaration, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstVariableDeclaration;
|
|
|
|
override get parent() { return super.parent as VariableDeclarationList | CatchClause; }
|
|
|
|
/**
|
|
* Declared variable name
|
|
*/
|
|
get name(): BindingName { return this.ast.data.name.node; }
|
|
/**
|
|
* Optional definite assignment assertion
|
|
*/
|
|
get exclamationToken(): ExclamationToken | undefined { return this.ast.data.exclamationToken?.node; }
|
|
/**
|
|
* Optional type annotation
|
|
*/
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
/**
|
|
* Optional initializer
|
|
*/
|
|
get initializer(): Expression | undefined { return this.ast.data.initializer?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value: BindingName) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set exclamationToken(value: ExclamationToken | undefined) { this.ast.data.exclamationToken = value?.ast; }
|
|
/** @internal */ set type(value: TypeNode | undefined) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set initializer(value: Expression | undefined) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
|
|
/** @internal */
|
|
export type InitializedVariableDeclaration = VariableDeclaration & { readonly initializer: Expression; };
|
|
|
|
// dprint-ignore
|
|
export class VariableDeclarationList extends Node<SyntaxKind.VariableDeclarationList, AstVariableDeclarationListData> {
|
|
// declare readonly ast: AstVariableDeclarationList;
|
|
|
|
override get parent() { return super.parent as VariableStatement | ForStatement | ForOfStatement | ForInStatement; }
|
|
|
|
get declarations(): NodeArray<VariableDeclaration> { return this.ast.data.declarations.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set declarations(value) { this.ast.data.declarations = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ParameterDeclaration extends Node<SyntaxKind.Parameter, AstParameterDeclarationData> implements Declaration, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstParameterDeclaration;
|
|
|
|
override get parent(): SignatureDeclaration { return super.parent as SignatureDeclaration; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get dotDotDotToken(): DotDotDotToken | undefined { return this.ast.data.dotDotDotToken?.node; }
|
|
// TODO(rbuckton): `name` can be undefined for JSDoc signature parameters
|
|
get name(): BindingName { return this.ast.data.name?.node; }
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get initializer(): Expression | undefined { return this.ast.data.initializer?.node; }
|
|
|
|
/** @internal */ override set parent(value: SignatureDeclaration) { super.parent = value; }
|
|
/** @internal */ set modifiers(value: NodeArray<ModifierLike> | undefined) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set dotDotDotToken(value: DotDotDotToken | undefined) { this.ast.data.dotDotDotToken = value?.ast; }
|
|
// TODO(rbuckton): `name` can be undefined for JSDoc signature parameters
|
|
/** @internal */ set name(value: BindingName) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set questionToken(value: QuestionToken | undefined) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set type(value: TypeNode | undefined) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set initializer(value: Expression | undefined) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class BindingElement extends Node<SyntaxKind.BindingElement, AstBindingElementData> implements Declaration, FlowContainer {
|
|
declare _declarationBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstBindingElement;
|
|
|
|
override get parent() { return super.parent as BindingPattern; }
|
|
|
|
/**
|
|
* Binding property name (in object binding pattern)
|
|
*/
|
|
get propertyName(): PropertyName | undefined { return this.ast.data.propertyName?.node; }
|
|
/**
|
|
* Present on rest element (in object binding pattern)
|
|
*/
|
|
get dotDotDotToken(): DotDotDotToken | undefined { return this.ast.data.dotDotDotToken?.node; }
|
|
/**
|
|
* Declared binding element name
|
|
*/
|
|
get name(): BindingName { return this.ast.data.name.node; }
|
|
/**
|
|
* Optional initializer
|
|
*/
|
|
get initializer(): Expression | undefined { return this.ast.data.initializer?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set propertyName(value) { this.ast.data.propertyName = value?.ast; }
|
|
/** @internal */ set dotDotDotToken(value) { this.ast.data.dotDotDotToken = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
/** @internal */
|
|
export type BindingElementGrandparent = BindingElement["parent"]["parent"];
|
|
|
|
// dprint-ignore
|
|
export class PropertySignature extends Node<SyntaxKind.PropertySignature, AstPropertySignatureData> implements TypeElement, JSDocContainer {
|
|
declare _typeElementBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstPropertySignature;
|
|
|
|
override get parent() { return super.parent as TypeLiteralNode | InterfaceDeclaration; }
|
|
|
|
get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
/**
|
|
* Declared property name
|
|
*/
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
/**
|
|
* Present on optional property
|
|
*/
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
/**
|
|
* Optional type annotation
|
|
*/
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value: NodeArray<Modifier> | undefined) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get initializer(): Expression | undefined { return this.ast.data.initializer?.node; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class PropertyDeclaration extends Node<SyntaxKind.PropertyDeclaration, AstPropertyDeclarationData> implements ClassElement, JSDocContainer {
|
|
declare _classElementBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstPropertyDeclaration;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
/**
|
|
* Optional field. Disallowed for auto-accessors and only used to report a grammar error (see `isGrammarError` in utilities.ts)
|
|
*/
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get exclamationToken(): ExclamationToken | undefined { return this.ast.data.exclamationToken?.node; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
/**
|
|
* Optional initializer
|
|
*/
|
|
get initializer(): Expression | undefined { return this.ast.data.initializer?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set exclamationToken(value) { this.ast.data.exclamationToken = value?.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export interface AutoAccessorPropertyDeclaration extends PropertyDeclaration {
|
|
_autoAccessorBrand: any;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PrivateIdentifierPropertyDeclaration extends PropertyDeclaration {
|
|
name: PrivateIdentifier;
|
|
}
|
|
/** @internal */
|
|
export interface PrivateIdentifierAutoAccessorPropertyDeclaration extends AutoAccessorPropertyDeclaration {
|
|
name: PrivateIdentifier;
|
|
}
|
|
/** @internal */
|
|
export interface PrivateIdentifierMethodDeclaration extends MethodDeclaration {
|
|
name: PrivateIdentifier;
|
|
}
|
|
/** @internal */
|
|
export interface PrivateIdentifierGetAccessorDeclaration extends GetAccessorDeclaration {
|
|
name: PrivateIdentifier;
|
|
}
|
|
/** @internal */
|
|
export interface PrivateIdentifierSetAccessorDeclaration extends SetAccessorDeclaration {
|
|
name: PrivateIdentifier;
|
|
}
|
|
/** @internal */
|
|
export type PrivateIdentifierAccessorDeclaration = PrivateIdentifierGetAccessorDeclaration | PrivateIdentifierSetAccessorDeclaration;
|
|
/** @internal */
|
|
export type PrivateClassElementDeclaration =
|
|
| PrivateIdentifierPropertyDeclaration
|
|
| PrivateIdentifierAutoAccessorPropertyDeclaration
|
|
| PrivateIdentifierMethodDeclaration
|
|
| PrivateIdentifierGetAccessorDeclaration
|
|
| PrivateIdentifierSetAccessorDeclaration;
|
|
|
|
/** @internal */
|
|
export type InitializedPropertyDeclaration = PropertyDeclaration & { readonly initializer: Expression; };
|
|
|
|
export interface ObjectLiteralElement extends NamedDeclaration {
|
|
_objectLiteralBrand: any;
|
|
// readonly ast: AstObjectLiteralElement;
|
|
|
|
// TODO(rbuckton): remove this?
|
|
readonly name?: PropertyName | undefined;
|
|
}
|
|
|
|
/** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */
|
|
export type ObjectLiteralElementLike =
|
|
| PropertyAssignment
|
|
| ShorthandPropertyAssignment
|
|
| SpreadAssignment
|
|
| MethodDeclaration
|
|
| AccessorDeclaration;
|
|
|
|
// dprint-ignore
|
|
export class PropertyAssignment extends Node<SyntaxKind.PropertyAssignment, AstPropertyAssignmentData> implements ObjectLiteralElement, Declaration, JSDocContainer {
|
|
declare _objectLiteralBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstPropertyAssignment;
|
|
|
|
override get parent() { return super.parent as ObjectLiteralExpression; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get exclamationToken(): ExclamationToken | undefined { return this.ast.data.exclamationToken?.node; }
|
|
get initializer(): Expression { return this.ast.data.initializer.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set exclamationToken(value) { this.ast.data.exclamationToken = value?.ast; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ShorthandPropertyAssignment extends Node<SyntaxKind.ShorthandPropertyAssignment, AstShorthandPropertyAssignmentData> implements ObjectLiteralElement, Declaration, JSDocContainer {
|
|
declare _objectLiteralBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstShorthandPropertyAssignment;
|
|
|
|
override get parent() { return super.parent as ObjectLiteralExpression; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get exclamationToken(): ExclamationToken | undefined { return this.ast.data.exclamationToken?.node; }
|
|
get equalsToken(): EqualsToken | undefined { return this.ast.data.equalsToken?.node; }
|
|
get objectAssignmentInitializer(): Expression | undefined { return this.ast.data.objectAssignmentInitializer?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set exclamationToken(value) { this.ast.data.exclamationToken = value?.ast; }
|
|
/** @internal */ set equalsToken(value) { this.ast.data.equalsToken = value?.ast; }
|
|
/** @internal */ set objectAssignmentInitializer(value) { this.ast.data.objectAssignmentInitializer = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class SpreadAssignment extends Node<SyntaxKind.SpreadAssignment, AstSpreadAssignmentData> implements ObjectLiteralElement, JSDocContainer {
|
|
declare _objectLiteralBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstSpreadAssignment;
|
|
|
|
override get parent() { return super.parent as ObjectLiteralExpression; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type VariableLikeDeclaration =
|
|
| VariableDeclaration
|
|
| ParameterDeclaration
|
|
| BindingElement
|
|
| PropertyDeclaration
|
|
| PropertyAssignment
|
|
| PropertySignature
|
|
| JsxAttribute
|
|
| ShorthandPropertyAssignment
|
|
| EnumMember
|
|
| JSDocPropertyTag
|
|
| JSDocParameterTag;
|
|
|
|
// dprint-ignore
|
|
export class ObjectBindingPattern extends Node<SyntaxKind.ObjectBindingPattern, AstObjectBindingPatternData> {
|
|
// declare readonly ast: AstObjectBindingPattern;
|
|
|
|
override get parent() { return super.parent as VariableDeclaration | ParameterDeclaration | BindingElement; }
|
|
|
|
get elements(): NodeArray<BindingElement> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set elements(value) { this.ast.data.elements = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ArrayBindingPattern extends Node<SyntaxKind.ArrayBindingPattern, AstArrayBindingPatternData> {
|
|
// declare readonly ast: AstArrayBindingPattern;
|
|
|
|
override get parent() { return super.parent as VariableDeclaration | ParameterDeclaration | BindingElement; }
|
|
|
|
get elements(): NodeArray<ArrayBindingElement> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set elements(value) { this.ast.data.elements = value.ast; }
|
|
}
|
|
|
|
export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern;
|
|
|
|
export type ArrayBindingElement = BindingElement | OmittedExpression;
|
|
|
|
/**
|
|
* Several node kinds share function-like features such as a signature,
|
|
* a name, and a body. These nodes should extend FunctionLikeDeclarationBase.
|
|
* Examples:
|
|
* - FunctionDeclaration
|
|
* - MethodDeclaration
|
|
* - AccessorDeclaration
|
|
*/
|
|
export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase {
|
|
_functionLikeDeclarationBrand: any;
|
|
|
|
readonly asteriskToken?: AsteriskToken | undefined;
|
|
readonly questionToken?: QuestionToken | undefined;
|
|
readonly exclamationToken?: ExclamationToken | undefined;
|
|
readonly body?: Block | Expression | undefined;
|
|
/** @internal */ endFlowNode?: FlowNode | undefined;
|
|
/** @internal */ returnFlowNode?: FlowNode | undefined;
|
|
}
|
|
|
|
export type FunctionLikeDeclaration =
|
|
| FunctionDeclaration
|
|
| MethodDeclaration
|
|
| GetAccessorDeclaration
|
|
| SetAccessorDeclaration
|
|
| ConstructorDeclaration
|
|
| FunctionExpression
|
|
| ArrowFunction;
|
|
|
|
/** @deprecated Use SignatureDeclaration */
|
|
export type FunctionLike = SignatureDeclaration;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveQuestionToken` in utilitiesPublic.ts
|
|
/** @internal */
|
|
export type HasQuestionToken =
|
|
| ParameterDeclaration
|
|
| PropertySignature
|
|
| PropertyDeclaration
|
|
| MethodSignature
|
|
| MethodDeclaration
|
|
| ShorthandPropertyAssignment
|
|
| MappedTypeNode
|
|
| NamedTupleMember
|
|
| ConditionalExpression
|
|
| PropertyAssignment;
|
|
|
|
// NOTE: Changing the following list requires changes to:
|
|
// - `canHaveAsteriskToken` in utilitiesPublic.ts
|
|
/** @internal */
|
|
export type HasAsteriskToken =
|
|
| FunctionDeclaration
|
|
| FunctionExpression
|
|
| MethodDeclaration
|
|
| YieldExpression;
|
|
|
|
// dprint-ignore
|
|
export class FunctionDeclaration extends Node<SyntaxKind.FunctionDeclaration, AstFunctionDeclarationData> implements FunctionLikeDeclarationBase, DeclarationStatement, LocalsContainer {
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstFunctionDeclaration;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get asteriskToken(): AsteriskToken | undefined { return this.ast.data.asteriskToken?.node; }
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get body(): Block | undefined { return this.ast.data.body?.node; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set asteriskToken(value) { this.ast.data.asteriskToken = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
}
|
|
|
|
|
|
// dprint-ignore
|
|
export class MethodSignature extends Node<SyntaxKind.MethodSignature, AstMethodSignatureData> implements SignatureDeclarationBase, TypeElement, LocalsContainer {
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _typeElementBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstMethodSignature;
|
|
|
|
override get parent() { return super.parent as TypeLiteralNode | InterfaceDeclaration; }
|
|
|
|
get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// Note that a MethodDeclaration is considered both a ClassElement and an ObjectLiteralElement.
|
|
// Both the grammars for ClassDeclaration and ObjectLiteralExpression allow for MethodDeclarations
|
|
// as child elements, and so a MethodDeclaration satisfies both interfaces. This avoids the
|
|
// alternative where we would need separate kinds/types for ClassMethodDeclaration and
|
|
// ObjectLiteralMethodDeclaration, which would look identical.
|
|
//
|
|
// Because of this, it may be necessary to determine what sort of MethodDeclaration you have
|
|
// at later stages of the compiler pipeline. In that case, you can either check the parent kind
|
|
// of the method, or use helpers like isObjectLiteralMethodDeclaration
|
|
// dprint-ignore
|
|
export class MethodDeclaration extends Node<SyntaxKind.MethodDeclaration, AstMethodDeclarationData> implements FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, LocalsContainer, FlowContainer {
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _classElementBrand: any;
|
|
declare _objectLiteralBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstMethodDeclaration;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration | ObjectLiteralExpression; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get asteriskToken(): AsteriskToken | undefined { return this.ast.data.asteriskToken?.node; }
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get body(): Block | undefined { return this.ast.data.body?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set asteriskToken(value) { this.ast.data.asteriskToken = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/**
|
|
* used only to report grammar errors (see `isGrammarError` in utilities.ts)
|
|
* @internal
|
|
*/
|
|
get exclamationToken(): ExclamationToken | undefined { return this.ast.data.exclamationToken?.node; }
|
|
/** @internal */ set exclamationToken(value) { this.ast.data.exclamationToken = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ConstructorDeclaration extends Node<SyntaxKind.Constructor, AstConstructorDeclarationData> implements FunctionLikeDeclarationBase, ClassElement, JSDocContainer, LocalsContainer {
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _classElementBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstConstructorDeclaration;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get body(): Block | undefined { return this.ast.data.body?.node; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value?.ast; }
|
|
/** @internal */ get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
/** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */
|
|
// dprint-ignore
|
|
export class SemicolonClassElement extends Node<SyntaxKind.SemicolonClassElement, AstSemicolonClassElementData> implements ClassElement, JSDocContainer {
|
|
declare _classElementBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare symbol: never;
|
|
declare localSymbol: never;
|
|
// declare readonly ast: AstSemicolonClassElement;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a
|
|
// ClassElement and an ObjectLiteralElement.
|
|
// dprint-ignore
|
|
export class GetAccessorDeclaration extends Node<SyntaxKind.GetAccessor, AstGetAccessorDeclarationData> implements FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _classElementBrand: any;
|
|
declare _typeElementBrand: any;
|
|
declare _objectLiteralBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstGetAccessorDeclaration;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration | ObjectLiteralExpression | InterfaceDeclaration | TypeLiteralNode; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
get body(): Block | undefined { return this.ast.data.body?.node; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value?.ast; }
|
|
/** @internal */ get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
// See the comment on MethodDeclaration for the intuition behind SetAccessorDeclaration being a
|
|
// ClassElement and an ObjectLiteralElement.
|
|
// dprint-ignore
|
|
export class SetAccessorDeclaration extends Node<SyntaxKind.SetAccessor, AstSetAccessorDeclarationData> implements FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _classElementBrand: any;
|
|
declare _typeElementBrand: any;
|
|
declare _objectLiteralBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstSetAccessorDeclaration;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration | ObjectLiteralExpression | InterfaceDeclaration | TypeLiteralNode; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
get body(): Block | undefined { return this.ast.data.body?.node; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value?.ast; }
|
|
/** @internal */ get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
|
|
|
// dprint-ignore
|
|
export class IndexSignatureDeclaration extends Node<SyntaxKind.IndexSignature, AstIndexSignatureDeclarationData> implements SignatureDeclarationBase, ClassElement, TypeElement, LocalsContainer {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _classElementBrand: any;
|
|
declare _typeElementBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstIndexSignatureDeclaration;
|
|
|
|
override get parent() { return super.parent as ObjectTypeDeclaration; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode { return this.ast.data.type?.node!; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ClassStaticBlockDeclaration extends Node<SyntaxKind.ClassStaticBlockDeclaration, AstClassStaticBlockDeclarationData> implements ClassElement, JSDocContainer, LocalsContainer {
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _classElementBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstClassStaticBlockDeclaration;
|
|
|
|
override get parent() { return super.parent as ClassLikeDeclaration; }
|
|
|
|
get body(): Block { return this.ast.data.body.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
export interface TypeNode<TKind extends TypeNodeSyntaxKind = TypeNodeSyntaxKind> extends Node<TKind> {
|
|
_typeNodeBrand: any;
|
|
// readonly ast: AstTypeNode<TKind>;
|
|
}
|
|
|
|
export interface KeywordTypeNode<TKind extends KeywordTypeSyntaxKind = KeywordTypeSyntaxKind> extends KeywordToken<TKind>, TypeNode<TKind> {
|
|
// readonly ast: AstKeywordTypeNode<TKind>;
|
|
readonly kind: TKind;
|
|
}
|
|
|
|
/** @deprecated */
|
|
// dprint-ignore
|
|
export class ImportTypeAssertionContainer extends Node<SyntaxKind.ImportTypeAssertionContainer, AstImportTypeAssertionContainerData> {
|
|
// declare readonly ast: AstImportTypeAssertionContainer;
|
|
|
|
override get parent() { return super.parent as ImportTypeNode; }
|
|
|
|
/** @deprecated */
|
|
get assertClause(): ImportAttributes { return this.ast.data.assertClause.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set assertClause(value) { this.ast.data.assertClause = value.ast; }
|
|
/** @internal */ get multiLine(): boolean { return this.ast.data.multiLine; }
|
|
/** @internal */ set multiLine(value) { this.ast.data.multiLine = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ImportTypeNode extends Node<SyntaxKind.ImportType, AstImportTypeNodeData> implements TypeNode, NodeWithTypeArguments {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstImportTypeNode;
|
|
|
|
get isTypeOf(): boolean { return this.ast.data.isTypeOf; }
|
|
get argument(): TypeNode { return this.ast.data.argument.node; }
|
|
get attributes(): ImportAttributes | undefined { return this.ast.data.attributes?.node; }
|
|
/** @deprecated */
|
|
get assertions(): ImportTypeAssertionContainer | undefined { return this.ast.data.assertions?.node; }
|
|
get qualifier(): EntityName | undefined { return this.ast.data.qualifier?.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
|
|
/** @internal */ set isTypeOf(value) { this.ast.data.isTypeOf = value; }
|
|
/** @internal */ set argument(value) { this.ast.data.argument = value.ast; }
|
|
/** @internal */ set attributes(value) { this.ast.data.attributes = value?.ast; }
|
|
/** @internal */ set assertions(value) { this.ast.data.assertions = value?.ast; }
|
|
/** @internal */ set qualifier(value) { this.ast.data.qualifier = value?.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
}
|
|
|
|
/** @internal */
|
|
export type LiteralImportTypeNode = ImportTypeNode & { readonly argument: LiteralTypeNode & { readonly literal: StringLiteral; }; };
|
|
|
|
// dprint-ignore
|
|
export class ThisTypeNode extends Node<SyntaxKind.ThisType, AstThisTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstThisTypeNode;
|
|
}
|
|
|
|
export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode;
|
|
|
|
export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase {
|
|
// readonly ast: AstNode<TypeNode & SignatureDeclarationBase>;
|
|
readonly kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType;
|
|
readonly type: TypeNode;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class FunctionTypeNode extends Node<SyntaxKind.FunctionType, AstFunctionTypeNodeData> implements FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstFunctionTypeNode;
|
|
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ConstructorTypeNode extends Node<SyntaxKind.ConstructorType, AstConstructorTypeNodeData> implements FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
|
// declare readonly ast: AstConstructorTypeNode;
|
|
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
|
|
get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
export interface NodeWithTypeArguments extends TypeNode {
|
|
readonly typeArguments?: NodeArray<TypeNode> | undefined;
|
|
}
|
|
|
|
export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments;
|
|
|
|
// dprint-ignore
|
|
export class TypeReferenceNode extends Node<SyntaxKind.TypeReference, AstTypeReferenceNodeData> implements NodeWithTypeArguments {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTypeReferenceNode;
|
|
|
|
get typeName(): Identifier | QualifiedName { return this.ast.data.typeName.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
|
|
/** @internal */ set typeName(value) { this.ast.data.typeName = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypePredicateNode extends Node<SyntaxKind.TypePredicate, AstTypePredicateNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTypePredicateNode;
|
|
|
|
override get parent() { return super.parent as SignatureDeclaration | JSDocTypeExpression; }
|
|
|
|
get assertsModifier(): AssertsKeyword | undefined { return this.ast.data.assertsModifier?.node; }
|
|
get parameterName(): Identifier | ThisTypeNode { return this.ast.data.parameterName.node; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set assertsModifier(value) { this.ast.data.assertsModifier = value?.ast; }
|
|
/** @internal */ set parameterName(value) { this.ast.data.parameterName = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypeQueryNode extends Node<SyntaxKind.TypeQuery, AstTypeQueryNodeData> implements NodeWithTypeArguments {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTypeQueryNode;
|
|
|
|
get exprName(): Identifier | QualifiedName { return this.ast.data.exprName.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
|
|
/** @internal */ set exprName(value) { this.ast.data.exprName = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
}
|
|
|
|
// A TypeLiteral is the declaration node for an anonymous symbol.
|
|
// dprint-ignore
|
|
export class TypeLiteralNode extends Node<SyntaxKind.TypeLiteral, AstTypeLiteralNodeData> implements TypeNode, Declaration {
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstTypeLiteralNode;
|
|
|
|
get members(): NodeArray<TypeElement> { return this.ast.data.members.nodes; }
|
|
|
|
/** @internal */ set members(value) { this.ast.data.members = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ArrayTypeNode extends Node<SyntaxKind.ArrayType, AstArrayTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstArrayTypeNode;
|
|
|
|
get elementType(): TypeNode { return this.ast.data.elementType.node; }
|
|
|
|
/** @internal */ set elementType(value) { this.ast.data.elementType = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TupleTypeNode extends Node<SyntaxKind.TupleType, AstTupleTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTupleTypeNode;
|
|
|
|
get elements(): NodeArray<TypeNode | NamedTupleMember> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ set elements(value: NodeArray<TypeNode | NamedTupleMember>) { this.ast.data.elements = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NamedTupleMember extends Node<SyntaxKind.NamedTupleMember, AstNamedTupleMemberData> implements TypeNode, Declaration, JSDocContainer {
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstNamedTupleMember;
|
|
|
|
get dotDotDotToken(): DotDotDotToken | undefined { return this.ast.data.dotDotDotToken?.node; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get questionToken(): QuestionToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set dotDotDotToken(value) { this.ast.data.dotDotDotToken = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class OptionalTypeNode extends Node<SyntaxKind.OptionalType, AstOptionalTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstOptionalTypeNode;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class RestTypeNode extends Node<SyntaxKind.RestType, AstRestTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstRestTypeNode;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode;
|
|
|
|
// dprint-ignore
|
|
export class UnionTypeNode extends Node<SyntaxKind.UnionType, AstUnionTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstUnionTypeNode;
|
|
|
|
get types(): NodeArray<TypeNode> { return this.ast.data.types.nodes; }
|
|
|
|
/** @internal */ set types(value) { this.ast.data.types = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class IntersectionTypeNode extends Node<SyntaxKind.IntersectionType, AstIntersectionTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstIntersectionTypeNode;
|
|
|
|
get types(): NodeArray<TypeNode> { return this.ast.data.types.nodes; }
|
|
|
|
/** @internal */ set types(value) { this.ast.data.types = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ConditionalTypeNode extends Node<SyntaxKind.ConditionalType, AstConditionalTypeNodeData> implements TypeNode, LocalsContainer {
|
|
declare _typeNodeBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstConditionalTypeNode;
|
|
|
|
get checkType(): TypeNode { return this.ast.data.checkType.node; }
|
|
get extendsType(): TypeNode { return this.ast.data.extendsType.node; }
|
|
get trueType(): TypeNode { return this.ast.data.trueType.node; }
|
|
get falseType(): TypeNode { return this.ast.data.falseType.node; }
|
|
|
|
/** @internal */ set checkType(value) { this.ast.data.checkType = value.ast; }
|
|
/** @internal */ set extendsType(value) { this.ast.data.extendsType = value.ast; }
|
|
/** @internal */ set trueType(value) { this.ast.data.trueType = value.ast; }
|
|
/** @internal */ set falseType(value) { this.ast.data.falseType = value.ast; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class InferTypeNode extends Node<SyntaxKind.InferType, AstInferTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstInferTypeNode;
|
|
|
|
get typeParameter(): TypeParameterDeclaration { return this.ast.data.typeParameter.node; }
|
|
|
|
/** @internal */ set typeParameter(value) { this.ast.data.typeParameter = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ParenthesizedTypeNode extends Node<SyntaxKind.ParenthesizedType, AstParenthesizedTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstParenthesizedTypeNode;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypeOperatorNode extends Node<SyntaxKind.TypeOperator, AstTypeOperatorNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTypeOperatorNode;
|
|
|
|
get operator(): SyntaxKind.KeyOfKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.UniqueKeyword { return this.ast.data.operator; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set operator(value) { this.ast.data.operator = value; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
/** @internal @knipignore */
|
|
export interface UniqueTypeOperatorNode extends TypeOperatorNode {
|
|
readonly operator: SyntaxKind.UniqueKeyword;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class IndexedAccessTypeNode extends Node<SyntaxKind.IndexedAccessType, AstIndexedAccessTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstIndexedAccessTypeNode;
|
|
|
|
get objectType(): TypeNode { return this.ast.data.objectType.node; }
|
|
get indexType(): TypeNode { return this.ast.data.indexType.node; }
|
|
|
|
/** @internal */ set objectType(value) { this.ast.data.objectType = value.ast; }
|
|
/** @internal */ set indexType(value) { this.ast.data.indexType = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class MappedTypeNode extends Node<SyntaxKind.MappedType, AstMappedTypeNodeData> implements TypeNode, Declaration, LocalsContainer {
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstMappedTypeNode;
|
|
|
|
get readonlyToken(): PlusToken | MinusToken | ReadonlyKeyword | undefined { return this.ast.data.readonlyToken?.node; }
|
|
get typeParameter(): TypeParameterDeclaration { return this.ast.data.typeParameter.node; }
|
|
get nameType(): TypeNode | undefined { return this.ast.data.nameType?.node; }
|
|
get questionToken(): QuestionToken | PlusToken | MinusToken | undefined { return this.ast.data.questionToken?.node; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get members(): NodeArray<TypeElement> | undefined { return this.ast.data.members?.nodes; }
|
|
|
|
/** @internal */ set readonlyToken(value) { this.ast.data.readonlyToken = value?.ast; }
|
|
/** @internal */ set typeParameter(value) { this.ast.data.typeParameter = value.ast; }
|
|
/** @internal */ set nameType(value) { this.ast.data.nameType = value?.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value?.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set members(value) { this.ast.data.members = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class LiteralTypeNode extends Node<SyntaxKind.LiteralType, AstLiteralTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstLiteralTypeNode;
|
|
|
|
get literal(): NullLiteral | TrueLiteral | FalseLiteral | PrefixUnaryExpression | LiteralExpression { return this.ast.data.literal.node; }
|
|
|
|
/** @internal */ set literal(value) { this.ast.data.literal = value.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move string literal adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class StringLiteral extends Token<SyntaxKind.StringLiteral, AstStringLiteralData> implements LiteralExpression, StringLiteralLikeNode, Declaration {
|
|
declare _literalExpressionBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstStringLiteral;
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get isUnterminated(): boolean { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/**
|
|
* NOTE: This is only set when synthesizing a node, not during parsing.
|
|
* @internal
|
|
*/
|
|
get singleQuote(): boolean | undefined { return this.ast.data.singleQuote; }
|
|
/** @internal */ set singleQuote(value) { this.ast.data.singleQuote = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
/** @internal */ get textSourceNode(): Identifier | PrivateIdentifier | NumericLiteral | BigIntLiteral | JsxNamespacedName | StringLiteralLike | undefined { return this.ast.data.textSourceNode?.node; }
|
|
/** @internal */ set textSourceNode(value) { this.ast.data.textSourceNode = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral;
|
|
export type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName | BigIntLiteral;
|
|
|
|
// dprint-ignore
|
|
export class TemplateLiteralTypeNode extends Node<SyntaxKind.TemplateLiteralType, AstTemplateLiteralTypeNodeData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTemplateLiteralTypeNode;
|
|
|
|
get head(): TemplateHead { return this.ast.data.head.node; }
|
|
get templateSpans(): NodeArray<TemplateLiteralTypeSpan> { return this.ast.data.templateSpans.nodes; }
|
|
|
|
/** @internal */ set head(value) { this.ast.data.head = value.ast; }
|
|
/** @internal */ set templateSpans(value) { this.ast.data.templateSpans = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TemplateLiteralTypeSpan extends Node<SyntaxKind.TemplateLiteralTypeSpan, AstTemplateLiteralTypeSpanData> {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstTemplateLiteralTypeSpan;
|
|
|
|
override get parent() { return super.parent as TemplateLiteralTypeNode; }
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
get literal(): TemplateMiddle | TemplateTail { return this.ast.data.literal.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ set literal(value) { this.ast.data.literal = value.ast; }
|
|
}
|
|
|
|
// Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing.
|
|
// Consider 'Expression'. Without the brand, 'Expression' is actually no different
|
|
// (structurally) than 'Node'. Because of this you can pass any Node to a function that
|
|
// takes an Expression without any error. By using the 'brands' we ensure that the type
|
|
// checker actually thinks you have something of the right type. Note: the brands are
|
|
// never actually given values. At runtime they have zero cost.
|
|
|
|
export interface Expression extends Node {
|
|
_expressionBrand: any;
|
|
// readonly ast: AstExpression;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class OmittedExpression extends Node<SyntaxKind.OmittedExpression, AstOmittedExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstOmittedExpression;
|
|
}
|
|
|
|
// Represents an expression that is elided as part of a transformation to emit comments on a
|
|
// not-emitted node. The 'expression' property of a PartiallyEmittedExpression should be emitted.
|
|
// dprint-ignore
|
|
export class PartiallyEmittedExpression extends Node<SyntaxKind.PartiallyEmittedExpression, AstPartiallyEmittedExpressionData> implements LeftHandSideExpression {
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstPartiallyEmittedExpression;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value: Expression) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
export interface UnaryExpression extends Expression {
|
|
_unaryExpressionBrand: any;
|
|
// readonly ast: AstUnaryExpression;
|
|
}
|
|
|
|
/** @deprecated use UpdateExpression instead */
|
|
export type IncrementExpression = UpdateExpression;
|
|
|
|
export interface UpdateExpression extends UnaryExpression {
|
|
_updateExpressionBrand: any;
|
|
// readonly ast: AstUpdateExpression;
|
|
}
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-UpdateExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-UnaryExpression
|
|
export type PrefixUnaryOperator =
|
|
| SyntaxKind.PlusPlusToken
|
|
| SyntaxKind.MinusMinusToken
|
|
| SyntaxKind.PlusToken
|
|
| SyntaxKind.MinusToken
|
|
| SyntaxKind.TildeToken
|
|
| SyntaxKind.ExclamationToken;
|
|
|
|
// dprint-ignore
|
|
export class PrefixUnaryExpression extends Node<SyntaxKind.PrefixUnaryExpression, AstPrefixUnaryExpressionData> implements UpdateExpression {
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstPrefixUnaryExpression;
|
|
|
|
get operator(): PrefixUnaryOperator { return this.ast.data.operator; }
|
|
get operand(): UnaryExpression { return this.ast.data.operand.node; }
|
|
|
|
/** @internal */ set operator(value) { this.ast.data.operator = value; }
|
|
/** @internal */ set operand(value) { this.ast.data.operand = value.ast; }
|
|
}
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-UpdateExpression
|
|
export type PostfixUnaryOperator =
|
|
| SyntaxKind.PlusPlusToken
|
|
| SyntaxKind.MinusMinusToken;
|
|
|
|
// dprint-ignore
|
|
export class PostfixUnaryExpression extends Node<SyntaxKind.PostfixUnaryExpression, AstPostfixUnaryExpressionData> implements UpdateExpression {
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstPostfixUnaryExpression;
|
|
|
|
get operand(): LeftHandSideExpression { return this.ast.data.operand.node; }
|
|
get operator(): PostfixUnaryOperator { return this.ast.data.operator; }
|
|
|
|
/** @internal */ set operand(value) { this.ast.data.operand = value.ast; }
|
|
/** @internal */ set operator(value) { this.ast.data.operator = value; }
|
|
}
|
|
|
|
export interface LeftHandSideExpression extends UpdateExpression {
|
|
_leftHandSideExpressionBrand: any;
|
|
// readonly ast: AstLeftHandSideExpression;
|
|
}
|
|
|
|
export interface MemberExpression extends LeftHandSideExpression {
|
|
_memberExpressionBrand: any;
|
|
// readonly ast: AstMemberExpression;
|
|
}
|
|
|
|
export interface PrimaryExpression extends MemberExpression {
|
|
_primaryExpressionBrand: any;
|
|
// readonly ast: AstPrimaryExpression;
|
|
}
|
|
|
|
// TODO(rbuckton): Move literal token nodes adjacent to other tokens and literals.
|
|
// dprint-ignore
|
|
export class NullLiteral extends Token<SyntaxKind.NullKeyword> implements KeywordExpression<SyntaxKind.NullKeyword> {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstNullLiteral;
|
|
}
|
|
|
|
// TODO(rbuckton): Move literal token nodes adjacent to other tokens and literals.
|
|
// dprint-ignore
|
|
export class TrueLiteral extends Token<SyntaxKind.TrueKeyword> implements KeywordExpression<SyntaxKind.TrueKeyword> {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstTrueLiteral;
|
|
}
|
|
|
|
// TODO(rbuckton): Move literal token nodes adjacent to other tokens and literals.
|
|
// dprint-ignore
|
|
export class FalseLiteral extends Token<SyntaxKind.FalseKeyword> implements KeywordExpression<SyntaxKind.FalseKeyword> {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstFalseLiteral;
|
|
}
|
|
|
|
export type BooleanLiteral = TrueLiteral | FalseLiteral;
|
|
|
|
// dprint-ignore
|
|
export class ThisExpression extends Token<SyntaxKind.ThisKeyword, AstThisExpressionData> implements KeywordExpression<SyntaxKind.ThisKeyword>, FlowContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstThisExpression;
|
|
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class SuperExpression extends Token<SyntaxKind.SuperKeyword, AstSuperExpressionData> implements KeywordExpression<SyntaxKind.SuperKeyword>, FlowContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstSuperExpression;
|
|
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ImportExpression extends Token<SyntaxKind.ImportKeyword> implements KeywordExpression<SyntaxKind.ImportKeyword> {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstImportExpression;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class DeleteExpression extends Node<SyntaxKind.DeleteExpression, AstDeleteExpressionData> implements UnaryExpression {
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstDeleteExpression;
|
|
|
|
get expression(): UnaryExpression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypeOfExpression extends Node<SyntaxKind.TypeOfExpression, AstTypeOfExpressionData> implements UnaryExpression {
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstTypeOfExpression;
|
|
|
|
get expression(): UnaryExpression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class VoidExpression extends Node<SyntaxKind.VoidExpression, AstVoidExpressionData> implements UnaryExpression {
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstVoidExpression;
|
|
|
|
get expression(): UnaryExpression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class AwaitExpression extends Node<SyntaxKind.AwaitExpression, AstAwaitExpressionData> implements UnaryExpression {
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstAwaitExpression;
|
|
|
|
get expression(): UnaryExpression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class YieldExpression extends Node<SyntaxKind.YieldExpression, AstYieldExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstYieldExpression;
|
|
|
|
get asteriskToken(): AsteriskToken | undefined { return this.ast.data.asteriskToken?.node; }
|
|
get expression(): Expression | undefined { return this.ast.data.expression?.node; }
|
|
|
|
/** @internal */ set asteriskToken(value) { this.ast.data.asteriskToken = value?.ast; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class SyntheticExpression extends Node<SyntaxKind.SyntheticExpression, AstSyntheticExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstSyntheticExpression;
|
|
|
|
get isSpread(): boolean { return this.ast.data.isSpread; }
|
|
get type(): Type { return this.ast.data.type; }
|
|
get tupleNameSource(): ParameterDeclaration | NamedTupleMember | undefined { return this.ast.data.tupleNameSource?.node; }
|
|
|
|
/** @internal */ set isSpread(value: boolean) { this.ast.data.isSpread = value; }
|
|
/** @internal */ set type(value: Type) { this.ast.data.type = value; }
|
|
/** @internal */ set tupleNameSource(value: ParameterDeclaration | NamedTupleMember | undefined) { this.ast.data.tupleNameSource = value?.ast; }
|
|
}
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-ExponentiationExpression
|
|
export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-MultiplicativeOperator
|
|
export type MultiplicativeOperator =
|
|
| SyntaxKind.AsteriskToken
|
|
| SyntaxKind.SlashToken
|
|
| SyntaxKind.PercentToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-MultiplicativeExpression
|
|
export type MultiplicativeOperatorOrHigher =
|
|
| ExponentiationOperator
|
|
| MultiplicativeOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-AdditiveExpression
|
|
export type AdditiveOperator =
|
|
| SyntaxKind.PlusToken
|
|
| SyntaxKind.MinusToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-AdditiveExpression
|
|
export type AdditiveOperatorOrHigher =
|
|
| MultiplicativeOperatorOrHigher
|
|
| AdditiveOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-ShiftExpression
|
|
export type ShiftOperator =
|
|
| SyntaxKind.LessThanLessThanToken
|
|
| SyntaxKind.GreaterThanGreaterThanToken
|
|
| SyntaxKind.GreaterThanGreaterThanGreaterThanToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-ShiftExpression
|
|
export type ShiftOperatorOrHigher =
|
|
| AdditiveOperatorOrHigher
|
|
| ShiftOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-RelationalExpression
|
|
export type RelationalOperator =
|
|
| SyntaxKind.LessThanToken
|
|
| SyntaxKind.LessThanEqualsToken
|
|
| SyntaxKind.GreaterThanToken
|
|
| SyntaxKind.GreaterThanEqualsToken
|
|
| SyntaxKind.InstanceOfKeyword
|
|
| SyntaxKind.InKeyword;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-RelationalExpression
|
|
export type RelationalOperatorOrHigher =
|
|
| ShiftOperatorOrHigher
|
|
| RelationalOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-EqualityExpression
|
|
export type EqualityOperator =
|
|
| SyntaxKind.EqualsEqualsToken
|
|
| SyntaxKind.EqualsEqualsEqualsToken
|
|
| SyntaxKind.ExclamationEqualsEqualsToken
|
|
| SyntaxKind.ExclamationEqualsToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-EqualityExpression
|
|
export type EqualityOperatorOrHigher =
|
|
| RelationalOperatorOrHigher
|
|
| EqualityOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-BitwiseANDExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-BitwiseXORExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-BitwiseORExpression
|
|
export type BitwiseOperator =
|
|
| SyntaxKind.AmpersandToken
|
|
| SyntaxKind.BarToken
|
|
| SyntaxKind.CaretToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-BitwiseANDExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-BitwiseXORExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-BitwiseORExpression
|
|
export type BitwiseOperatorOrHigher =
|
|
| EqualityOperatorOrHigher
|
|
| BitwiseOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-LogicalANDExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-LogicalORExpression
|
|
export type LogicalOperator =
|
|
| SyntaxKind.AmpersandAmpersandToken
|
|
| SyntaxKind.BarBarToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-LogicalANDExpression
|
|
// see: https://tc39.github.io/ecma262/#prod-LogicalORExpression
|
|
export type LogicalOperatorOrHigher =
|
|
| BitwiseOperatorOrHigher
|
|
| LogicalOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-AssignmentOperator
|
|
export type CompoundAssignmentOperator =
|
|
| SyntaxKind.PlusEqualsToken
|
|
| SyntaxKind.MinusEqualsToken
|
|
| SyntaxKind.AsteriskAsteriskEqualsToken
|
|
| SyntaxKind.AsteriskEqualsToken
|
|
| SyntaxKind.SlashEqualsToken
|
|
| SyntaxKind.PercentEqualsToken
|
|
| SyntaxKind.AmpersandEqualsToken
|
|
| SyntaxKind.BarEqualsToken
|
|
| SyntaxKind.CaretEqualsToken
|
|
| SyntaxKind.LessThanLessThanEqualsToken
|
|
| SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken
|
|
| SyntaxKind.GreaterThanGreaterThanEqualsToken
|
|
| SyntaxKind.BarBarEqualsToken
|
|
| SyntaxKind.AmpersandAmpersandEqualsToken
|
|
| SyntaxKind.QuestionQuestionEqualsToken;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-AssignmentExpression
|
|
export type AssignmentOperator =
|
|
| SyntaxKind.EqualsToken
|
|
| CompoundAssignmentOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-AssignmentExpression
|
|
export type AssignmentOperatorOrHigher =
|
|
| SyntaxKind.QuestionQuestionToken
|
|
| LogicalOperatorOrHigher
|
|
| AssignmentOperator;
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-Expression
|
|
export type BinaryOperator =
|
|
| AssignmentOperatorOrHigher
|
|
| SyntaxKind.CommaToken;
|
|
|
|
export type LogicalOrCoalescingAssignmentOperator =
|
|
| SyntaxKind.AmpersandAmpersandEqualsToken
|
|
| SyntaxKind.BarBarEqualsToken
|
|
| SyntaxKind.QuestionQuestionEqualsToken;
|
|
|
|
export type BinaryOperatorToken = Token<BinaryOperator>;
|
|
|
|
// dprint-ignore
|
|
export class BinaryExpression extends Node<SyntaxKind.BinaryExpression, AstBinaryExpressionData> implements Expression, Declaration, JSDocContainer {
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstBinaryExpression;
|
|
|
|
get left(): Expression { return this.ast.data.left.node; }
|
|
get operatorToken(): BinaryOperatorToken { return this.ast.data.operatorToken.node; }
|
|
get right(): Expression { return this.ast.data.right.node; }
|
|
|
|
/** @internal */ set left(value) { this.ast.data.left = value.ast; }
|
|
/** @internal */ set operatorToken(value) { this.ast.data.operatorToken = value.ast; }
|
|
/** @internal */ set right(value) { this.ast.data.right = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type AssignmentOperatorToken = Token<AssignmentOperator>;
|
|
|
|
export interface AssignmentExpression<TOperator extends AssignmentOperatorToken> extends BinaryExpression {
|
|
readonly left: LeftHandSideExpression;
|
|
readonly operatorToken: TOperator;
|
|
}
|
|
|
|
export interface ObjectDestructuringAssignment extends AssignmentExpression<EqualsToken> {
|
|
readonly left: ObjectLiteralExpression;
|
|
}
|
|
|
|
export interface ArrayDestructuringAssignment extends AssignmentExpression<EqualsToken> {
|
|
readonly left: ArrayLiteralExpression;
|
|
}
|
|
|
|
export type DestructuringAssignment =
|
|
| ObjectDestructuringAssignment
|
|
| ArrayDestructuringAssignment;
|
|
|
|
export type BindingOrAssignmentElement =
|
|
| VariableDeclaration
|
|
| ParameterDeclaration
|
|
| ObjectBindingOrAssignmentElement
|
|
| ArrayBindingOrAssignmentElement;
|
|
|
|
export type ObjectBindingOrAssignmentElement =
|
|
| BindingElement
|
|
| PropertyAssignment // AssignmentProperty
|
|
| ShorthandPropertyAssignment // AssignmentProperty
|
|
| SpreadAssignment // AssignmentRestProperty
|
|
;
|
|
|
|
/** @internal @knipignore */
|
|
export type ObjectAssignmentElement = Exclude<ObjectBindingOrAssignmentElement, BindingElement>;
|
|
|
|
export type ArrayBindingOrAssignmentElement =
|
|
| BindingElement
|
|
| OmittedExpression // Elision
|
|
| SpreadElement // AssignmentRestElement
|
|
| ArrayLiteralExpression // ArrayAssignmentPattern
|
|
| ObjectLiteralExpression // ObjectAssignmentPattern
|
|
| AssignmentExpression<EqualsToken> // AssignmentElement
|
|
| Identifier // DestructuringAssignmentTarget
|
|
| PropertyAccessExpression // DestructuringAssignmentTarget
|
|
| ElementAccessExpression // DestructuringAssignmentTarget
|
|
;
|
|
|
|
/** @internal */
|
|
export type ArrayAssignmentElement = Exclude<ArrayBindingOrAssignmentElement, BindingElement>;
|
|
|
|
export type BindingOrAssignmentElementRestIndicator =
|
|
| DotDotDotToken // from BindingElement
|
|
| SpreadElement // AssignmentRestElement
|
|
| SpreadAssignment // AssignmentRestProperty
|
|
;
|
|
|
|
export type BindingOrAssignmentElementTarget =
|
|
| BindingOrAssignmentPattern
|
|
| Identifier
|
|
| PropertyAccessExpression
|
|
| ElementAccessExpression
|
|
| OmittedExpression;
|
|
|
|
/** @internal @knipignore */
|
|
export type AssignmentElementTarget = Exclude<BindingOrAssignmentElementTarget, BindingPattern>;
|
|
|
|
export type ObjectBindingOrAssignmentPattern =
|
|
| ObjectBindingPattern
|
|
| ObjectLiteralExpression // ObjectAssignmentPattern
|
|
;
|
|
|
|
export type ArrayBindingOrAssignmentPattern =
|
|
| ArrayBindingPattern
|
|
| ArrayLiteralExpression // ArrayAssignmentPattern
|
|
;
|
|
|
|
export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression;
|
|
|
|
export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern;
|
|
|
|
export interface InstanceofExpression extends BinaryExpression {
|
|
readonly operatorToken: Token<SyntaxKind.InstanceOfKeyword>;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ConditionalExpression extends Node<SyntaxKind.ConditionalExpression, AstConditionalExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstConditionalExpression;
|
|
|
|
get condition(): Expression { return this.ast.data.condition.node; }
|
|
get questionToken(): QuestionToken { return this.ast.data.questionToken.node; }
|
|
get whenTrue(): Expression { return this.ast.data.whenTrue.node; }
|
|
get colonToken(): ColonToken { return this.ast.data.colonToken.node; }
|
|
get whenFalse(): Expression { return this.ast.data.whenFalse.node; }
|
|
|
|
/** @internal */ set condition(value) { this.ast.data.condition = value.ast; }
|
|
/** @internal */ set questionToken(value) { this.ast.data.questionToken = value.ast; }
|
|
/** @internal */ set whenTrue(value) { this.ast.data.whenTrue = value.ast; }
|
|
/** @internal */ set colonToken(value) { this.ast.data.colonToken = value.ast; }
|
|
/** @internal */ set whenFalse(value) { this.ast.data.whenFalse = value.ast; }
|
|
}
|
|
|
|
export type FunctionBody = Block;
|
|
export type ConciseBody = FunctionBody | Expression;
|
|
|
|
// dprint-ignore
|
|
export class FunctionExpression extends Node<SyntaxKind.FunctionExpression, AstFunctionExpressionData> implements PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstFunctionExpression;
|
|
|
|
get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get asteriskToken(): AsteriskToken | undefined { return this.ast.data.asteriskToken?.node; }
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get body(): Block { return this.ast.data.body.node; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set asteriskToken(value) { this.ast.data.asteriskToken = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ArrowFunction extends Node<SyntaxKind.ArrowFunction, AstArrowFunctionData> implements Expression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
|
declare _expressionBrand: any;
|
|
declare _functionLikeDeclarationBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstArrowFunction;
|
|
|
|
get modifiers(): NodeArray<Modifier> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get equalsGreaterThanToken(): EqualsGreaterThanToken { return this.ast.data.equalsGreaterThanToken.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get body(): Block | Expression { return this.ast.data.body.node; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set equalsGreaterThanToken(value) { this.ast.data.equalsGreaterThanToken = value.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value.ast; }
|
|
/** @internal */ get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get returnFlowNode(): FlowNode | undefined { return this.ast.data.returnFlowNode; }
|
|
/** @internal */ set returnFlowNode(value) { this.ast.data.returnFlowNode = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
|
// or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters.
|
|
// For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1".
|
|
export interface LiteralLikeNode extends Node {
|
|
// readonly ast: AstLiteralLikeNode;
|
|
readonly data: AstLiteralLikeNodeData;
|
|
|
|
get text(): string;
|
|
|
|
/** @internal */ set text(value: string);
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
export interface StringLiteralLikeNode extends LiteralLikeNode {
|
|
// readonly ast: AstStringLiteralLikeNode;
|
|
readonly data: AstStringLiteralLikeNodeData;
|
|
|
|
get isUnterminated(): boolean | undefined;
|
|
get hasExtendedUnicodeEscape(): boolean | undefined;
|
|
|
|
/** @internal */ set isUnterminated(value: boolean | undefined);
|
|
/** @internal */ set hasExtendedUnicodeEscape(value: boolean | undefined);
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
export interface TemplateLiteralLikeNode extends StringLiteralLikeNode {
|
|
// readonly ast: AstTemplateLiteralLikeNode;
|
|
readonly data: AstTemplateLiteralLikeNodeData;
|
|
|
|
get rawText(): string | undefined;
|
|
|
|
/** @internal */ set rawText(value: string | undefined);
|
|
/** @internal */ get templateFlags(): TokenFlags | undefined;
|
|
/** @internal */ set templateFlags(value: TokenFlags | undefined);
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
|
// or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters.
|
|
// For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1".
|
|
export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression {
|
|
_literalExpressionBrand: any;
|
|
// readonly ast: AstLiteralExpression;
|
|
readonly data: AstLiteralExpressionData;
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class RegularExpressionLiteral extends Token<SyntaxKind.RegularExpressionLiteral, AstRegularExpressionLiteralData> implements StringLiteralLikeNode {
|
|
declare _literalExpressionBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstRegularExpressionLiteral;
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get isUnterminated(): boolean | undefined { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean | undefined { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum RegularExpressionFlags {
|
|
None = 0,
|
|
HasIndices = 1 << 0, // d
|
|
Global = 1 << 1, // g
|
|
IgnoreCase = 1 << 2, // i
|
|
Multiline = 1 << 3, // m
|
|
DotAll = 1 << 4, // s
|
|
Unicode = 1 << 5, // u
|
|
UnicodeSets = 1 << 6, // v
|
|
Sticky = 1 << 7, // y
|
|
AnyUnicodeMode = Unicode | UnicodeSets,
|
|
Modifiers = IgnoreCase | Multiline | DotAll,
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class NoSubstitutionTemplateLiteral extends Token<SyntaxKind.NoSubstitutionTemplateLiteral, AstNoSubstitutionTemplateLiteralData> implements LiteralExpression, TemplateLiteralLikeNode, Declaration {
|
|
declare _literalExpressionBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstNoSubstitutionTemplateLiteral;
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get rawText(): string | undefined { return this.ast.data.rawText; }
|
|
get isUnterminated(): boolean | undefined { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean | undefined { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ set rawText(value) { this.ast.data.rawText = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
/** @internal */ get templateFlags(): TokenFlags { return this.ast.data.templateFlags; }
|
|
/** @internal */ set templateFlags(value) { this.ast.data.templateFlags = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export const enum TokenFlags {
|
|
None = 0,
|
|
/** @internal */
|
|
PrecedingLineBreak = 1 << 0,
|
|
/** @internal */
|
|
PrecedingJSDocComment = 1 << 1,
|
|
/** @internal */
|
|
Unterminated = 1 << 2,
|
|
/** @internal */
|
|
ExtendedUnicodeEscape = 1 << 3, // e.g. `\u{10ffff}`
|
|
Scientific = 1 << 4, // e.g. `10e2`
|
|
Octal = 1 << 5, // e.g. `0777`
|
|
HexSpecifier = 1 << 6, // e.g. `0x00000000`
|
|
BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000`
|
|
OctalSpecifier = 1 << 8, // e.g. `0o777`
|
|
/** @internal */
|
|
ContainsSeparator = 1 << 9, // e.g. `0b1100_0101`
|
|
/** @internal */
|
|
UnicodeEscape = 1 << 10, // e.g. `\u00a0`
|
|
/** @internal */
|
|
ContainsInvalidEscape = 1 << 11, // e.g. `\uhello`
|
|
/** @internal */
|
|
HexEscape = 1 << 12, // e.g. `\xa0`
|
|
/** @internal */
|
|
ContainsLeadingZero = 1 << 13, // e.g. `0888`
|
|
/** @internal */
|
|
ContainsInvalidSeparator = 1 << 14, // e.g. `0_1`
|
|
/** @internal */
|
|
PrecedingJSDocLeadingAsterisks = 1 << 15,
|
|
/** @internal */
|
|
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier,
|
|
/** @internal */
|
|
WithSpecifier = HexSpecifier | BinaryOrOctalSpecifier,
|
|
/** @internal */
|
|
StringLiteralFlags = HexEscape | UnicodeEscape | ExtendedUnicodeEscape | ContainsInvalidEscape,
|
|
/** @internal */
|
|
NumericLiteralFlags = Scientific | Octal | ContainsLeadingZero | WithSpecifier | ContainsSeparator | ContainsInvalidSeparator,
|
|
/** @internal */
|
|
TemplateLiteralLikeFlags = HexEscape | UnicodeEscape | ExtendedUnicodeEscape | ContainsInvalidEscape,
|
|
/** @internal */
|
|
IsInvalid = Octal | ContainsLeadingZero | ContainsInvalidSeparator | ContainsInvalidEscape,
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class NumericLiteral extends Token<SyntaxKind.NumericLiteral, AstNumericLiteralData> implements LiteralExpression, LiteralLikeNode, Declaration {
|
|
declare _literalExpressionBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstNumericLiteral;
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ get numericLiteralFlags(): TokenFlags { return this.ast.data.numericLiteralFlags; }
|
|
/** @internal */ set numericLiteralFlags(value) { this.ast.data.numericLiteralFlags = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class BigIntLiteral extends Token<SyntaxKind.BigIntLiteral, AstBigIntLiteralData> implements LiteralExpression, LiteralLikeNode {
|
|
declare _literalExpressionBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstBigIntLiteral;
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
export type LiteralToken =
|
|
| NumericLiteral
|
|
| BigIntLiteral
|
|
| StringLiteral
|
|
| JsxText
|
|
| RegularExpressionLiteral
|
|
| NoSubstitutionTemplateLiteral;
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class TemplateHead extends Token<SyntaxKind.TemplateHead, AstTemplateHeadData> implements TemplateLiteralLikeNode {
|
|
// declare readonly ast: AstTemplateHead;
|
|
|
|
override get parent() { return super.parent as TemplateExpression | TemplateLiteralTypeNode; }
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get isUnterminated(): boolean | undefined { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean | undefined { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
get rawText(): string | undefined { return this.ast.data.rawText; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
/** @internal */ set rawText(value) { this.ast.data.rawText = value; }
|
|
/** @internal */ get templateFlags(): TokenFlags { return this.ast.data.templateFlags; }
|
|
/** @internal */ set templateFlags(value) { this.ast.data.templateFlags = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class TemplateMiddle extends Token<SyntaxKind.TemplateMiddle, AstTemplateMiddleData> implements TemplateLiteralLikeNode {
|
|
// declare readonly ast: AstTemplateMiddle;
|
|
|
|
override get parent() { return super.parent as TemplateSpan | TemplateLiteralTypeSpan; }
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get isUnterminated(): boolean | undefined { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean | undefined { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
get rawText(): string | undefined { return this.ast.data.rawText; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
/** @internal */ set rawText(value) { this.ast.data.rawText = value; }
|
|
/** @internal */ get templateFlags(): TokenFlags { return this.ast.data.templateFlags; }
|
|
/** @internal */ set templateFlags(value) { this.ast.data.templateFlags = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
// dprint-ignore
|
|
export class TemplateTail extends Token<SyntaxKind.TemplateTail, AstTemplateTailData> implements TemplateLiteralLikeNode {
|
|
// declare readonly ast: AstTemplateTail;
|
|
|
|
override get parent() { return super.parent as TemplateSpan | TemplateLiteralTypeSpan; }
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get isUnterminated(): boolean | undefined { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean | undefined { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
get rawText(): string | undefined { return this.ast.data.rawText; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
/** @internal */ set rawText(value) { this.ast.data.rawText = value; }
|
|
/** @internal */ get templateFlags(): TokenFlags { return this.ast.data.templateFlags; }
|
|
/** @internal */ set templateFlags(value) { this.ast.data.templateFlags = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
export type PseudoLiteralToken =
|
|
| TemplateHead
|
|
| TemplateMiddle
|
|
| TemplateTail;
|
|
|
|
// TODO(rbuckton): Move adjacent to tokens and other literals.
|
|
export type TemplateLiteralToken =
|
|
| NoSubstitutionTemplateLiteral
|
|
| PseudoLiteralToken;
|
|
|
|
// dprint-ignore
|
|
export class TemplateExpression extends Node<SyntaxKind.TemplateExpression, AstTemplateExpressionData> implements PrimaryExpression {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstTemplateExpression;
|
|
|
|
get head(): TemplateHead { return this.ast.data.head.node; }
|
|
get templateSpans(): NodeArray<TemplateSpan> { return this.ast.data.templateSpans.nodes; }
|
|
|
|
/** @internal */ set head(value) { this.ast.data.head = value.ast; }
|
|
/** @internal */ set templateSpans(value) { this.ast.data.templateSpans = value.ast; }
|
|
}
|
|
|
|
export type TemplateLiteral =
|
|
| TemplateExpression
|
|
| NoSubstitutionTemplateLiteral;
|
|
|
|
// Each of these corresponds to a substitution expression and a template literal, in that order.
|
|
// The template literal must have kind TemplateMiddleLiteral or TemplateTailLiteral.
|
|
// dprint-ignore
|
|
export class TemplateSpan extends Node<SyntaxKind.TemplateSpan, AstTemplateSpanData> {
|
|
// declare readonly ast: AstTemplateSpan;
|
|
|
|
override get parent() { return super.parent as TemplateExpression; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get literal(): TemplateMiddle | TemplateTail { return this.ast.data.literal.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set literal(value) { this.ast.data.literal = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ParenthesizedExpression extends Node<SyntaxKind.ParenthesizedExpression, AstParenthesizedExpressionData> implements PrimaryExpression, JSDocContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstParenthesizedExpression;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
/** @internal */
|
|
export interface JSDocTypeAssertion extends ParenthesizedExpression {
|
|
readonly _jsDocTypeAssertionBrand: never;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ArrayLiteralExpression extends Node<SyntaxKind.ArrayLiteralExpression, AstArrayLiteralExpressionData> implements PrimaryExpression {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstArrayLiteralExpression;
|
|
|
|
get elements(): NodeArray<Expression> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ set elements(value: NodeArray<Expression>) { this.ast.data.elements = value.ast; }
|
|
/** @internal */ get multiLine(): boolean | undefined { return this.ast.data.multiLine; }
|
|
/** @internal */ set multiLine(value) { this.ast.data.multiLine = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class SpreadElement extends Node<SyntaxKind.SpreadElement, AstSpreadElementData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstSpreadElement;
|
|
|
|
override get parent() { return super.parent as ArrayLiteralExpression | CallExpression | NewExpression; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Is this still needed?
|
|
/**
|
|
* This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to
|
|
* ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be
|
|
* JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type
|
|
* ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.)
|
|
*/
|
|
export interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration {
|
|
// readonly ast: AstNode<PrimaryExpression & Declaration>;
|
|
readonly properties: NodeArray<T>;
|
|
}
|
|
|
|
// An ObjectLiteralExpression is the declaration node for an anonymous symbol.
|
|
// dprint-ignore
|
|
export class ObjectLiteralExpression extends Node<SyntaxKind.ObjectLiteralExpression, AstObjectLiteralExpressionData> implements ObjectLiteralExpressionBase<ObjectLiteralElementLike>, JSDocContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstObjectLiteralExpression;
|
|
|
|
get properties(): NodeArray<ObjectLiteralElementLike> { return this.ast.data.properties.nodes; }
|
|
|
|
/** @internal */ set properties(value) { this.ast.data.properties = value.ast; }
|
|
/** @internal */ get multiLine(): boolean | undefined { return this.ast.data.multiLine; }
|
|
/** @internal */ set multiLine(value) { this.ast.data.multiLine = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression;
|
|
export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
|
export type AccessExpression = PropertyAccessExpression | ElementAccessExpression;
|
|
|
|
// dprint-ignore
|
|
export class PropertyAccessExpression extends Node<SyntaxKind.PropertyAccessExpression, AstPropertyAccessExpressionData> implements MemberExpression, NamedDeclaration, JSDocContainer, FlowContainer {
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstPropertyAccessExpression;
|
|
|
|
get expression(): LeftHandSideExpression { return this.ast.data.expression.node; }
|
|
get questionDotToken(): QuestionDotToken | undefined { return this.ast.data.questionDotToken?.node; }
|
|
get name(): Identifier | PrivateIdentifier { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set questionDotToken(value) { this.ast.data.questionDotToken = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PrivateIdentifierPropertyAccessExpression extends PropertyAccessExpression {
|
|
readonly name: PrivateIdentifier;
|
|
}
|
|
|
|
export interface JsxTagNamePropertyAccess extends PropertyAccessExpression {
|
|
// readonly ast: AstJsxTagNamePropertyAccess;
|
|
readonly data: AstJsxTagNamePropertyAccessData;
|
|
readonly expression: Identifier | ThisExpression | JsxTagNamePropertyAccess;
|
|
}
|
|
|
|
export type PropertyAccessChain = PropertyAccessExpression & {
|
|
_optionalChainBrand: any;
|
|
readonly name: MemberName;
|
|
readonly data: {
|
|
readonly name: AstMemberName;
|
|
};
|
|
};
|
|
|
|
/** @internal */
|
|
export type PropertyAccessChainRoot = PropertyAccessChain & {
|
|
readonly questionDotToken: QuestionDotToken;
|
|
readonly data: {
|
|
readonly questionDotToken: AstQuestionDotToken;
|
|
};
|
|
};
|
|
|
|
export type SuperPropertyAccessExpression = PropertyAccessExpression & {
|
|
readonly expression: SuperExpression;
|
|
readonly data: {
|
|
readonly expression: AstSuperExpression;
|
|
};
|
|
};
|
|
|
|
/** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */
|
|
export type PropertyAccessEntityNameExpression = PropertyAccessExpression & {
|
|
_propertyAccessExpressionLikeQualifiedNameBrand?: any;
|
|
readonly expression: EntityNameExpression;
|
|
readonly name: Identifier;
|
|
readonly data: {
|
|
readonly expression: AstEntityNameExpression;
|
|
readonly name: AstIdentifier;
|
|
};
|
|
};
|
|
|
|
// dprint-ignore
|
|
export class ElementAccessExpression extends Node<SyntaxKind.ElementAccessExpression, AstElementAccessExpressionData> implements MemberExpression, Declaration, JSDocContainer, FlowContainer {
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstElementAccessExpression;
|
|
|
|
get expression(): LeftHandSideExpression { return this.ast.data.expression.node; }
|
|
get questionDotToken(): QuestionDotToken | undefined { return this.ast.data.questionDotToken?.node; }
|
|
get argumentExpression(): Expression { return this.ast.data.argumentExpression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set questionDotToken(value) { this.ast.data.questionDotToken = value?.ast; }
|
|
/** @internal */ set argumentExpression(value) { this.ast.data.argumentExpression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
export interface ElementAccessChain extends ElementAccessExpression {
|
|
_optionalChainBrand: any;
|
|
// readonly ast: AstElementAccessChain;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ElementAccessChainRoot extends ElementAccessChain {
|
|
readonly questionDotToken: QuestionDotToken;
|
|
}
|
|
|
|
export interface SuperElementAccessExpression extends ElementAccessExpression {
|
|
readonly expression: SuperExpression;
|
|
}
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-SuperProperty
|
|
export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression;
|
|
|
|
// dprint-ignore
|
|
export class CallExpression extends Node<SyntaxKind.CallExpression, AstCallExpressionData> implements LeftHandSideExpression, Declaration {
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstCallExpression;
|
|
|
|
get expression(): LeftHandSideExpression { return this.ast.data.expression.node; }
|
|
get questionDotToken(): QuestionDotToken | undefined { return this.ast.data.questionDotToken?.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
get arguments(): NodeArray<Expression> { return this.ast.data.arguments.nodes; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set questionDotToken(value) { this.ast.data.questionDotToken = value?.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ set arguments(value) { this.ast.data.arguments = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export interface CallChain extends CallExpression {
|
|
_optionalChainBrand: any;
|
|
// readonly ast: AstCallChain;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CallChainRoot extends CallChain {
|
|
readonly questionDotToken: QuestionDotToken;
|
|
}
|
|
|
|
export type OptionalChain =
|
|
| PropertyAccessChain
|
|
| ElementAccessChain
|
|
| CallChain
|
|
| NonNullChain;
|
|
|
|
/** @internal */
|
|
export type OptionalChainRoot =
|
|
| PropertyAccessChainRoot
|
|
| ElementAccessChainRoot
|
|
| CallChainRoot;
|
|
|
|
/** @internal */
|
|
export type BindableObjectDefinePropertyCall = CallExpression & {
|
|
readonly arguments: readonly [BindableStaticNameExpression, StringLiteralLike | NumericLiteral, ObjectLiteralExpression] & Readonly<TextRange>;
|
|
};
|
|
|
|
/** @internal */
|
|
export type BindableStaticNameExpression =
|
|
| EntityNameExpression
|
|
| BindableStaticElementAccessExpression;
|
|
|
|
/** @internal */
|
|
export type LiteralLikeElementAccessExpression = ElementAccessExpression & Declaration & {
|
|
readonly argumentExpression: StringLiteralLike | NumericLiteral;
|
|
};
|
|
|
|
/** @internal */
|
|
export type BindableStaticElementAccessExpression = LiteralLikeElementAccessExpression & {
|
|
readonly expression: BindableStaticNameExpression;
|
|
};
|
|
|
|
/** @internal */
|
|
export type BindableElementAccessExpression = ElementAccessExpression & {
|
|
readonly expression: BindableStaticNameExpression;
|
|
};
|
|
|
|
/** @internal */
|
|
export type BindableStaticAccessExpression =
|
|
| PropertyAccessEntityNameExpression
|
|
| BindableStaticElementAccessExpression;
|
|
|
|
/** @internal */
|
|
export type BindableAccessExpression =
|
|
| PropertyAccessEntityNameExpression
|
|
| BindableElementAccessExpression;
|
|
|
|
/** @internal */
|
|
export interface BindableStaticPropertyAssignmentExpression extends BinaryExpression {
|
|
readonly left: BindableStaticAccessExpression;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface BindablePropertyAssignmentExpression extends BinaryExpression {
|
|
readonly left: BindableAccessExpression;
|
|
}
|
|
|
|
// see: https://tc39.github.io/ecma262/#prod-SuperCall
|
|
export interface SuperCall extends CallExpression {
|
|
readonly expression: SuperExpression;
|
|
}
|
|
|
|
export interface ImportCall extends CallExpression {
|
|
readonly expression: ImportExpression;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ExpressionWithTypeArguments extends Node<SyntaxKind.ExpressionWithTypeArguments, AstExpressionWithTypeArgumentsData> implements MemberExpression, NodeWithTypeArguments {
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstExpressionWithTypeArguments;
|
|
|
|
get expression(): LeftHandSideExpression { return this.ast.data.expression.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NewExpression extends Node<SyntaxKind.NewExpression, AstNewExpressionData> implements PrimaryExpression, Declaration {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstNewExpression;
|
|
|
|
get expression(): LeftHandSideExpression { return this.ast.data.expression.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
get arguments(): NodeArray<Expression> | undefined { return this.ast.data.arguments?.nodes; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ set arguments(value) { this.ast.data.arguments = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TaggedTemplateExpression extends Node<SyntaxKind.TaggedTemplateExpression, AstTaggedTemplateExpressionData> implements MemberExpression {
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstTaggedTemplateExpression;
|
|
|
|
get tag(): LeftHandSideExpression { return this.ast.data.tag.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
get template(): NoSubstitutionTemplateLiteral | TemplateExpression { return this.ast.data.template.node; }
|
|
|
|
/** @internal */ set tag(value) { this.ast.data.tag = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ set template(value) { this.ast.data.template = value.ast; }
|
|
/** @internal */ get questionDotToken(): QuestionDotToken | undefined { return this.ast.data.questionDotToken?.node; }
|
|
/** @internal */ set questionDotToken(value) { this.ast.data.questionDotToken = value?.ast; }
|
|
}
|
|
|
|
export type CallLikeExpression =
|
|
| CallExpression
|
|
| NewExpression
|
|
| TaggedTemplateExpression
|
|
| Decorator
|
|
| JsxOpeningLikeElement
|
|
| InstanceofExpression;
|
|
|
|
// dprint-ignore
|
|
export class AsExpression extends Node<SyntaxKind.AsExpression, AstAsExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstAsExpression;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypeAssertionExpression extends Node<SyntaxKind.TypeAssertionExpression, AstTypeAssertionData> implements UnaryExpression {
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstTypeAssertion;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
get expression(): UnaryExpression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
/** @deprecated Use `TypeAssertionExpression` instead */
|
|
export type TypeAssertion = TypeAssertionExpression;
|
|
|
|
export type AssertionExpression =
|
|
| TypeAssertionExpression
|
|
| AsExpression;
|
|
|
|
// dprint-ignore
|
|
export class SatisfiesExpression extends Node<SyntaxKind.SatisfiesExpression, AstSatisfiesExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstSatisfiesExpression;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NonNullExpression extends Node<SyntaxKind.NonNullExpression, AstNonNullExpressionData> implements LeftHandSideExpression {
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstNonNullExpression;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value: Expression) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
export interface NonNullChain extends NonNullExpression {
|
|
_optionalChainBrand: any;
|
|
// readonly ast: AstNonNullChain;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class MetaProperty extends Node<SyntaxKind.MetaProperty, AstMetaPropertyData> implements PrimaryExpression, FlowContainer {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstMetaProperty;
|
|
|
|
get keywordToken(): SyntaxKind.ImportKeyword | SyntaxKind.NewKeyword { return this.ast.data.keywordToken; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ set keywordToken(value: SyntaxKind.ImportKeyword | SyntaxKind.NewKeyword) { this.ast.data.keywordToken = value; }
|
|
/** @internal */ set name(value: Identifier) { this.ast.data.name = value.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ImportMetaProperty extends MetaProperty {
|
|
readonly keywordToken: SyntaxKind.ImportKeyword;
|
|
readonly name: Identifier & { readonly escapedText: __String & "meta"; };
|
|
}
|
|
|
|
/// A JSX expression of the form <TagName attrs>...</TagName>
|
|
// dprint-ignore
|
|
export class JsxElement extends Node<SyntaxKind.JsxElement, AstJsxElementData> implements PrimaryExpression {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxElement;
|
|
|
|
get openingElement(): JsxOpeningElement { return this.ast.data.openingElement.node; }
|
|
get children(): NodeArray<JsxChild> { return this.ast.data.children.nodes; }
|
|
get closingElement(): JsxClosingElement { return this.ast.data.closingElement.node; }
|
|
|
|
/** @internal */ set openingElement(value: JsxOpeningElement) { this.ast.data.openingElement = value.ast; }
|
|
/** @internal */ set children(value: NodeArray<JsxChild>) { this.ast.data.children = value.ast; }
|
|
/** @internal */ set closingElement(value: JsxClosingElement) { this.ast.data.closingElement = value.ast; }
|
|
}
|
|
|
|
/// Either the opening tag in a <Tag>...</Tag> pair or the lone <Tag /> in a self-closing form
|
|
export type JsxOpeningLikeElement =
|
|
| JsxSelfClosingElement
|
|
| JsxOpeningElement;
|
|
|
|
export type JsxAttributeLike =
|
|
| JsxAttribute
|
|
| JsxSpreadAttribute;
|
|
|
|
export type JsxAttributeName =
|
|
| Identifier
|
|
| JsxNamespacedName;
|
|
|
|
export type JsxTagNameExpression =
|
|
| Identifier
|
|
| ThisExpression
|
|
| JsxTagNamePropertyAccess
|
|
| JsxNamespacedName;
|
|
|
|
// dprint-ignore
|
|
export class JsxAttributes extends Node<SyntaxKind.JsxAttributes, AstJsxAttributesData> implements PrimaryExpression, Declaration {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstJsxAttributes;
|
|
|
|
override get parent() { return super.parent as JsxOpeningLikeElement; }
|
|
|
|
get properties(): NodeArray<JsxAttributeLike> { return this.ast.data.properties.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set properties(value) { this.ast.data.properties = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JsxNamespacedName extends Node<SyntaxKind.JsxNamespacedName, AstJsxNamespacedNameData> {
|
|
// declare readonly ast: AstJsxNamespacedName;
|
|
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get namespace(): Identifier { return this.ast.data.namespace.node; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set namespace(value) { this.ast.data.namespace = value.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Is this actually an expression or just a part of JsxElement?
|
|
/// The opening element of a <Tag>...</Tag> JsxElement
|
|
// dprint-ignore
|
|
export class JsxOpeningElement extends Node<SyntaxKind.JsxOpeningElement, AstJsxOpeningElementData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxOpeningElement;
|
|
|
|
override get parent() { return super.parent as JsxElement; }
|
|
|
|
get tagName(): JsxTagNameExpression { return this.ast.data.tagName.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
get attributes(): JsxAttributes { return this.ast.data.attributes.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set tagName(value) { this.ast.data.tagName = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ set attributes(value) { this.ast.data.attributes = value.ast; }
|
|
}
|
|
|
|
/// A JSX expression of the form <TagName attrs />
|
|
// dprint-ignore
|
|
export class JsxSelfClosingElement extends Node<SyntaxKind.JsxSelfClosingElement, AstJsxSelfClosingElementData> implements PrimaryExpression {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxSelfClosingElement;
|
|
|
|
get tagName(): JsxTagNameExpression { return this.ast.data.tagName.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
get attributes(): JsxAttributes { return this.ast.data.attributes.node; }
|
|
|
|
/** @internal */ set tagName(value) { this.ast.data.tagName = value.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ set attributes(value) { this.ast.data.attributes = value.ast; }
|
|
}
|
|
|
|
/// A JSX expression of the form <>...</>
|
|
// dprint-ignore
|
|
export class JsxFragment extends Node<SyntaxKind.JsxFragment, AstJsxFragmentData> implements PrimaryExpression {
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxFragment;
|
|
|
|
get openingFragment(): JsxOpeningFragment { return this.ast.data.openingFragment.node; }
|
|
get children(): NodeArray<JsxChild> { return this.ast.data.children.nodes; }
|
|
get closingFragment(): JsxClosingFragment { return this.ast.data.closingFragment.node; }
|
|
|
|
/** @internal */ set openingFragment(value: JsxOpeningFragment) { this.ast.data.openingFragment = value.ast; }
|
|
/** @internal */ set children(value: NodeArray<JsxChild>) { this.ast.data.children = value.ast; }
|
|
/** @internal */ set closingFragment(value: JsxClosingFragment) { this.ast.data.closingFragment = value.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Is this actually an expression or just a part of JsxFragment?
|
|
/// The opening element of a <>...</> JsxFragment
|
|
// dprint-ignore
|
|
export class JsxOpeningFragment extends Node<SyntaxKind.JsxOpeningFragment, AstJsxOpeningFragmentData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxOpeningFragment;
|
|
|
|
override get parent() { return super.parent as JsxFragment; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Is this actually an expression or just a part of JsxFragment?
|
|
/// The closing element of a <>...</> JsxFragment
|
|
// dprint-ignore
|
|
export class JsxClosingFragment extends Node<SyntaxKind.JsxClosingFragment, AstJsxClosingFragmentData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxClosingFragment;
|
|
|
|
override get parent() { return super.parent as JsxFragment; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JsxAttribute extends Node<SyntaxKind.JsxAttribute, AstJsxAttributeData> implements Declaration {
|
|
// declare readonly ast: AstJsxAttribute;
|
|
|
|
declare _declarationBrand: any;
|
|
|
|
override get parent() { return super.parent as JsxAttributes; }
|
|
|
|
get name(): JsxAttributeName { return this.ast.data.name.node; }
|
|
// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} />
|
|
get initializer(): JsxAttributeValue | undefined { return this.ast.data.initializer?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type JsxAttributeValue =
|
|
| StringLiteral
|
|
| JsxExpression
|
|
| JsxElement
|
|
| JsxSelfClosingElement
|
|
| JsxFragment;
|
|
|
|
// TODO(rbuckton): Does this need to implement ObjectLiteralElement?
|
|
// dprint-ignore
|
|
export class JsxSpreadAttribute extends Node<SyntaxKind.JsxSpreadAttribute, AstJsxSpreadAttributeData> implements ObjectLiteralElement {
|
|
declare _objectLiteralBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstJsxSpreadAttribute;
|
|
|
|
/** @internal*/ declare symbol: never; // not actually a declaration
|
|
/** @internal*/ declare localSymbol: never; // not actually a declaration
|
|
|
|
override get parent() { return super.parent as JsxAttributes; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to JsxOpeningElement
|
|
// dprint-ignore
|
|
export class JsxClosingElement extends Node<SyntaxKind.JsxClosingElement, AstJsxClosingElementData> {
|
|
// declare readonly ast: AstJsxClosingElement;
|
|
|
|
override get parent() { return super.parent as JsxElement; }
|
|
|
|
get tagName(): JsxTagNameExpression { return this.ast.data.tagName.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set tagName(value) { this.ast.data.tagName = value.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Is this actually an expression?
|
|
// dprint-ignore
|
|
export class JsxExpression extends Node<SyntaxKind.JsxExpression, AstJsxExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstJsxExpression;
|
|
|
|
override get parent() { return super.parent as JsxElement | JsxFragment | JsxAttributeLike; }
|
|
|
|
get dotDotDotToken(): DotDotDotToken | undefined { return this.ast.data.dotDotDotToken?.node; }
|
|
get expression(): Expression | undefined { return this.ast.data.expression?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set dotDotDotToken(value) { this.ast.data.dotDotDotToken = value?.ast; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JsxText extends Token<SyntaxKind.JsxText, AstJsxTextData> implements LiteralLikeNode {
|
|
// declare readonly ast: AstJsxText;
|
|
|
|
override get parent() { return super.parent as JsxElement | JsxFragment; }
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
get isUnterminated(): boolean | undefined { return this.ast.data.isUnterminated; }
|
|
get hasExtendedUnicodeEscape(): boolean | undefined { return this.ast.data.hasExtendedUnicodeEscape; }
|
|
get containsOnlyTriviaWhiteSpaces(): boolean { return this.ast.data.containsOnlyTriviaWhiteSpaces; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ set isUnterminated(value) { this.ast.data.isUnterminated = value; }
|
|
/** @internal */ set hasExtendedUnicodeEscape(value) { this.ast.data.hasExtendedUnicodeEscape = value; }
|
|
/** @internal */ set containsOnlyTriviaWhiteSpaces(value) { this.ast.data.containsOnlyTriviaWhiteSpaces = value; }
|
|
}
|
|
|
|
export type JsxChild =
|
|
| JsxText
|
|
| JsxExpression
|
|
| JsxElement
|
|
| JsxSelfClosingElement
|
|
| JsxFragment;
|
|
|
|
export interface Statement extends JSDocContainer {
|
|
_statementBrand: any;
|
|
// readonly ast: AstStatement;
|
|
}
|
|
|
|
// Represents a statement that is elided as part of a transformation to emit comments on a
|
|
// not-emitted node.
|
|
// dprint-ignore
|
|
export class NotEmittedStatement extends Node<SyntaxKind.NotEmittedStatement, AstNotEmittedStatementData> implements Statement {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstNotEmittedStatement;
|
|
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move adjacent to other type elements
|
|
// dprint-ignore
|
|
export class NotEmittedTypeElement extends Node<SyntaxKind.NotEmittedTypeElement, AstNotEmittedTypeElementData> implements TypeElement {
|
|
declare _typeElementBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstNotEmittedTypeElement;
|
|
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value: Symbol) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value: Symbol | undefined) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
/**
|
|
* A list of comma-separated expressions. This node is only created by transformations.
|
|
*/
|
|
// dprint-ignore
|
|
export class CommaListExpression extends Node<SyntaxKind.CommaListExpression, AstCommaListExpressionData> implements Expression {
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstCommaListExpression;
|
|
|
|
get elements(): NodeArray<Expression> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ set elements(value: NodeArray<Expression>) { this.ast.data.elements = value.ast; }
|
|
}
|
|
|
|
/** @internal */
|
|
// dprint-ignore
|
|
export class SyntheticReferenceExpression extends Node<SyntaxKind.SyntheticReferenceExpression, AstSyntheticReferenceExpressionData> implements LeftHandSideExpression {
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstSyntheticReferenceExpression;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get thisArg(): Expression { return this.ast.data.thisArg.node; }
|
|
|
|
/** @internal */ set expression(value: Expression) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set thisArg(value: Expression) { this.ast.data.thisArg = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class EmptyStatement extends Node<SyntaxKind.EmptyStatement, AstEmptyStatementData> implements Statement, JSDocContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstEmptyStatement;
|
|
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class DebuggerStatement extends Node<SyntaxKind.DebuggerStatement, AstDebuggerStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstDebuggerStatement;
|
|
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class MissingDeclaration extends Node<SyntaxKind.MissingDeclaration, AstMissingDeclarationData> implements DeclarationStatement {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstMissingDeclaration;
|
|
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type BlockLike =
|
|
| SourceFile
|
|
| Block
|
|
| ModuleBlock
|
|
| CaseOrDefaultClause;
|
|
|
|
// dprint-ignore
|
|
export class Block extends Node<SyntaxKind.Block, AstBlockData> implements Statement, LocalsContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstBlock;
|
|
|
|
get statements(): NodeArray<Statement> { return this.ast.data.statements.nodes; }
|
|
|
|
/** @internal */ set statements(value) { this.ast.data.statements = value.ast; }
|
|
/** @internal */ get multiLine(): boolean | undefined { return this.ast.data.multiLine; }
|
|
/** @internal */ set multiLine(value) { this.ast.data.multiLine = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class VariableStatement extends Node<SyntaxKind.VariableStatement, AstVariableStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstVariableStatement;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get declarationList(): VariableDeclarationList { return this.ast.data.declarationList.node; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set declarationList(value) { this.ast.data.declarationList = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ExpressionStatement extends Node<SyntaxKind.ExpressionStatement, AstExpressionStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstExpressionStatement;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PrologueDirective extends ExpressionStatement {
|
|
readonly expression: StringLiteral;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class IfStatement extends Node<SyntaxKind.IfStatement, AstIfStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstIfStatement;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get thenStatement(): Statement { return this.ast.data.thenStatement.node; }
|
|
get elseStatement(): Statement | undefined { return this.ast.data.elseStatement?.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set thenStatement(value) { this.ast.data.thenStatement = value.ast; }
|
|
/** @internal */ set elseStatement(value) { this.ast.data.elseStatement = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
export interface IterationStatement extends Statement {
|
|
readonly statement: Statement;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class DoStatement extends Node<SyntaxKind.DoStatement, AstDoStatementData> implements IterationStatement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstDoStatement;
|
|
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class WhileStatement extends Node<SyntaxKind.WhileStatement, AstWhileStatementData> implements IterationStatement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstWhileStatement;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
export type ForInitializer =
|
|
| VariableDeclarationList
|
|
| Expression;
|
|
|
|
// dprint-ignore
|
|
export class ForStatement extends Node<SyntaxKind.ForStatement, AstForStatementData> implements IterationStatement, LocalsContainer, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstForStatement;
|
|
|
|
get initializer(): ForInitializer | undefined { return this.ast.data.initializer?.node; }
|
|
get condition(): Expression | undefined { return this.ast.data.condition?.node; }
|
|
get incrementor(): Expression | undefined { return this.ast.data.incrementor?.node; }
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ set condition(value) { this.ast.data.condition = value?.ast; }
|
|
/** @internal */ set incrementor(value) { this.ast.data.incrementor = value?.ast; }
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
export type ForInOrOfStatement =
|
|
| ForInStatement
|
|
| ForOfStatement;
|
|
|
|
// dprint-ignore
|
|
export class ForInStatement extends Node<SyntaxKind.ForInStatement, AstForInStatementData> implements IterationStatement, LocalsContainer, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstForInStatement;
|
|
|
|
get initializer(): ForInitializer { return this.ast.data.initializer.node; }
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value.ast; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ForOfStatement extends Node<SyntaxKind.ForOfStatement, AstForOfStatementData> implements IterationStatement, LocalsContainer, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstForOfStatement;
|
|
|
|
get awaitModifier(): AwaitKeyword | undefined { return this.ast.data.awaitModifier?.node; }
|
|
get initializer(): ForInitializer { return this.ast.data.initializer.node; }
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
|
|
/** @internal */ set awaitModifier(value) { this.ast.data.awaitModifier = value?.ast; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value.ast; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class BreakStatement extends Node<SyntaxKind.BreakStatement, AstBreakStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstBreakStatement;
|
|
|
|
get label(): Identifier | undefined { return this.ast.data.label?.node; }
|
|
|
|
/** @internal */ set label(value) { this.ast.data.label = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ContinueStatement extends Node<SyntaxKind.ContinueStatement, AstContinueStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstContinueStatement;
|
|
|
|
get label(): Identifier | undefined { return this.ast.data.label?.node; }
|
|
|
|
/** @internal */ set label(value) { this.ast.data.label = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
export type BreakOrContinueStatement =
|
|
| BreakStatement
|
|
| ContinueStatement;
|
|
|
|
// dprint-ignore
|
|
export class ReturnStatement extends Node<SyntaxKind.ReturnStatement, AstReturnStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstReturnStatement;
|
|
|
|
get expression(): Expression | undefined { return this.ast.data.expression?.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class WithStatement extends Node<SyntaxKind.WithStatement, AstWithStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstWithStatement;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class SwitchStatement extends Node<SyntaxKind.SwitchStatement, AstSwitchStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstSwitchStatement;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get caseBlock(): CaseBlock { return this.ast.data.caseBlock.node; }
|
|
get possiblyExhaustive(): boolean | undefined { return this.ast.data.possiblyExhaustive; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set caseBlock(value) { this.ast.data.caseBlock = value.ast; }
|
|
/** @internal */ set possiblyExhaustive(value) { this.ast.data.possiblyExhaustive = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class CaseBlock extends Node<SyntaxKind.CaseBlock, AstCaseBlockData> implements LocalsContainer {
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstCaseBlock;
|
|
|
|
override get parent() { return super.parent as SwitchStatement; }
|
|
|
|
get clauses(): NodeArray<CaseOrDefaultClause> { return this.ast.data.clauses.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set clauses(value) { this.ast.data.clauses = value.ast; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class CaseClause extends Node<SyntaxKind.CaseClause, AstCaseClauseData> implements JSDocContainer {
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstCaseClause;
|
|
|
|
override get parent() { return super.parent as CaseBlock; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
get statements(): NodeArray<Statement> { return this.ast.data.statements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ set statements(value) { this.ast.data.statements = value.ast; }
|
|
/** @internal */ get fallthroughFlowNode(): FlowNode | undefined { return this.ast.data.fallthroughFlowNode; }
|
|
/** @internal */ set fallthroughFlowNode(value) { this.ast.data.fallthroughFlowNode = value; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class DefaultClause extends Node<SyntaxKind.DefaultClause, AstDefaultClauseData> {
|
|
// declare readonly ast: AstDefaultClause;
|
|
|
|
override get parent() { return super.parent as CaseBlock; }
|
|
|
|
get statements(): NodeArray<Statement> { return this.ast.data.statements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set statements(value) { this.ast.data.statements = value.ast; }
|
|
/** @internal */ get fallthroughFlowNode(): FlowNode | undefined { return this.ast.data.fallthroughFlowNode; }
|
|
/** @internal */ set fallthroughFlowNode(value) { this.ast.data.fallthroughFlowNode = value; }
|
|
}
|
|
|
|
export type CaseOrDefaultClause =
|
|
| CaseClause
|
|
| DefaultClause;
|
|
|
|
// dprint-ignore
|
|
export class LabeledStatement extends Node<SyntaxKind.LabeledStatement, AstLabeledStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstLabeledStatement;
|
|
|
|
get label(): Identifier { return this.ast.data.label.node; }
|
|
get statement(): Statement { return this.ast.data.statement.node; }
|
|
|
|
/** @internal */ set label(value) { this.ast.data.label = value.ast; }
|
|
/** @internal */ set statement(value) { this.ast.data.statement = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ThrowStatement extends Node<SyntaxKind.ThrowStatement, AstThrowStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstThrowStatement;
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TryStatement extends Node<SyntaxKind.TryStatement, AstTryStatementData> implements Statement, FlowContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _flowContainerBrand: any;
|
|
// declare readonly ast: AstTryStatement;
|
|
|
|
get tryBlock(): Block { return this.ast.data.tryBlock.node; }
|
|
get catchClause(): CatchClause | undefined { return this.ast.data.catchClause?.node; }
|
|
get finallyBlock(): Block | undefined { return this.ast.data.finallyBlock?.node; }
|
|
|
|
/** @internal */ set tryBlock(value) { this.ast.data.tryBlock = value.ast; }
|
|
/** @internal */ set catchClause(value) { this.ast.data.catchClause = value?.ast; }
|
|
/** @internal */ set finallyBlock(value) { this.ast.data.finallyBlock = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get flowNode(): FlowNode | undefined { return this.ast.data.flowNode; }
|
|
/** @internal */ set flowNode(value: FlowNode | undefined) { this.ast.data.flowNode = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class CatchClause extends Node<SyntaxKind.CatchClause, AstCatchClauseData> implements LocalsContainer {
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstCatchClause;
|
|
|
|
override get parent() { return super.parent as TryStatement; }
|
|
|
|
get variableDeclaration(): VariableDeclaration | undefined { return this.ast.data.variableDeclaration?.node; }
|
|
get block(): Block { return this.ast.data.block.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set variableDeclaration(value) { this.ast.data.variableDeclaration = value?.ast; }
|
|
/** @internal */ set block(value) { this.ast.data.block = value.ast; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
export type ObjectTypeDeclaration =
|
|
| ClassLikeDeclaration
|
|
| InterfaceDeclaration
|
|
| TypeLiteralNode;
|
|
|
|
export type DeclarationWithTypeParameters =
|
|
| DeclarationWithTypeParameterChildren
|
|
| JSDocTypedefTag
|
|
| JSDocCallbackTag
|
|
| JSDocSignature;
|
|
|
|
export type DeclarationWithTypeParameterChildren =
|
|
| SignatureDeclaration
|
|
| ClassLikeDeclaration
|
|
| InterfaceDeclaration
|
|
| TypeAliasDeclaration
|
|
| JSDocTemplateTag;
|
|
|
|
export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
|
|
// readonly ast: AstNode<NamedDeclaration & JSDocContainer>;
|
|
readonly kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
|
|
readonly name?: Identifier | undefined;
|
|
readonly typeParameters?: NodeArray<TypeParameterDeclaration> | undefined;
|
|
readonly heritageClauses?: NodeArray<HeritageClause> | undefined;
|
|
readonly members: NodeArray<ClassElement>;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ClassDeclaration extends Node<SyntaxKind.ClassDeclaration, AstClassDeclarationData> implements ClassLikeDeclarationBase, DeclarationStatement {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstClassDeclaration;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get heritageClauses(): NodeArray<HeritageClause> | undefined { return this.ast.data.heritageClauses?.nodes; }
|
|
get members(): NodeArray<ClassElement> { return this.ast.data.members.nodes; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set heritageClauses(value) { this.ast.data.heritageClauses = value?.ast; }
|
|
/** @internal */ set members(value: NodeArray<ClassElement>) { this.ast.data.members = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ClassExpression extends Node<SyntaxKind.ClassExpression, AstClassExpressionData> implements ClassLikeDeclarationBase, PrimaryExpression {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _primaryExpressionBrand: any;
|
|
declare _memberExpressionBrand: any;
|
|
declare _leftHandSideExpressionBrand: any;
|
|
declare _updateExpressionBrand: any;
|
|
declare _unaryExpressionBrand: any;
|
|
declare _expressionBrand: any;
|
|
// declare readonly ast: AstClassExpression;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
/** May be undefined in `export default class { ... }`. */
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get heritageClauses(): NodeArray<HeritageClause> | undefined { return this.ast.data.heritageClauses?.nodes; }
|
|
get members(): NodeArray<ClassElement> { return this.ast.data.members.nodes; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set heritageClauses(value) { this.ast.data.heritageClauses = value?.ast; }
|
|
/** @internal */ set members(value) { this.ast.data.members = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type ClassLikeDeclaration =
|
|
| ClassDeclaration
|
|
| ClassExpression;
|
|
|
|
export interface ClassElement extends Declaration {
|
|
_classElementBrand: any;
|
|
// readonly ast: AstClassElement;
|
|
|
|
// TODO(rbuckton): remove this?
|
|
readonly name?: PropertyName | undefined;
|
|
}
|
|
|
|
export interface TypeElement extends Declaration {
|
|
_typeElementBrand: any;
|
|
// readonly ast: AstTypeElement;
|
|
|
|
// TODO(rbuckton): remove these?
|
|
readonly name?: PropertyName | undefined;
|
|
readonly questionToken?: QuestionToken | undefined;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class InterfaceDeclaration extends Node<SyntaxKind.InterfaceDeclaration, AstInterfaceDeclarationData> implements DeclarationStatement, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstInterfaceDeclaration;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get heritageClauses(): NodeArray<HeritageClause> | undefined { return this.ast.data.heritageClauses?.nodes; }
|
|
get members(): NodeArray<TypeElement> { return this.ast.data.members.nodes; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set heritageClauses(value) { this.ast.data.heritageClauses = value?.ast; }
|
|
/** @internal */ set members(value) { this.ast.data.members = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class HeritageClause extends Node<SyntaxKind.HeritageClause, AstHeritageClauseData> {
|
|
// declare readonly ast: AstHeritageClause;
|
|
|
|
override get parent() { return super.parent as InterfaceDeclaration | ClassLikeDeclaration; }
|
|
|
|
get token(): SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword { return this.ast.data.token; }
|
|
get types(): NodeArray<ExpressionWithTypeArguments> { return this.ast.data.types.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set token(value) { this.ast.data.token = value; }
|
|
/** @internal */ set types(value) { this.ast.data.types = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class TypeAliasDeclaration extends Node<SyntaxKind.TypeAliasDeclaration, AstTypeAliasDeclarationData> implements DeclarationStatement, JSDocContainer, LocalsContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstTypeAliasDeclaration;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class EnumMember extends Node<SyntaxKind.EnumMember, AstEnumMemberData> implements NamedDeclaration, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstEnumMember;
|
|
|
|
override get parent() { return super.parent as EnumDeclaration; }
|
|
|
|
get name(): PropertyName { return this.ast.data.name.node; }
|
|
get initializer(): Expression | undefined { return this.ast.data.initializer?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set initializer(value) { this.ast.data.initializer = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class EnumDeclaration extends Node<SyntaxKind.EnumDeclaration, AstEnumDeclarationData> implements DeclarationStatement, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstEnumDeclaration;
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get members(): NodeArray<EnumMember> { return this.ast.data.members.nodes; }
|
|
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set members(value) { this.ast.data.members = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type ModuleName =
|
|
| Identifier
|
|
| StringLiteral;
|
|
|
|
export type ModuleBody =
|
|
| NamespaceBody
|
|
| JSDocNamespaceBody;
|
|
|
|
// TODO(rbuckton): Move after ModuleDeclaration
|
|
/** @internal */
|
|
export interface AmbientModuleDeclaration extends ModuleDeclaration {
|
|
readonly body: ModuleBlock | undefined;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ModuleDeclaration extends Node<SyntaxKind.ModuleDeclaration, AstModuleDeclarationData> implements DeclarationStatement, JSDocContainer, LocalsContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstModuleDeclaration;
|
|
|
|
override get parent() { return super.parent as ModuleDeclaration | ModuleBlock | SourceFile; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): ModuleName { return this.ast.data.name.node; }
|
|
get body(): ModuleBody | JSDocNamespaceDeclaration | undefined { return this.ast.data.body?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set body(value) { this.ast.data.body = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
export type NamespaceBody =
|
|
| ModuleBlock
|
|
| NamespaceDeclaration;
|
|
|
|
export interface NamespaceDeclaration extends ModuleDeclaration {
|
|
// readonly ast: AstNamespaceDeclaration;
|
|
readonly data: AstNamespaceDeclarationData;
|
|
readonly name: Identifier;
|
|
readonly body: NamespaceBody;
|
|
}
|
|
|
|
export type JSDocNamespaceBody =
|
|
| Identifier
|
|
| JSDocNamespaceDeclaration;
|
|
|
|
export interface JSDocNamespaceDeclaration extends ModuleDeclaration {
|
|
// readonly ast: AstJSDocNamespaceDeclaration;
|
|
readonly data: AstJSDocNamespaceDeclarationData;
|
|
readonly name: Identifier;
|
|
readonly body: JSDocNamespaceBody | undefined;
|
|
}
|
|
|
|
// TODO(rbuckton): Is this actually a Statement?
|
|
// dprint-ignore
|
|
export class ModuleBlock extends Node<SyntaxKind.ModuleBlock, AstModuleBlockData> implements Statement, JSDocContainer {
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstModuleBlock;
|
|
|
|
override get parent() { return super.parent as ModuleDeclaration; }
|
|
|
|
get statements(): NodeArray<Statement> { return this.ast.data.statements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set statements(value) { this.ast.data.statements = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
}
|
|
|
|
export type ModuleReference =
|
|
| EntityName
|
|
| ExternalModuleReference;
|
|
|
|
/**
|
|
* One of:
|
|
* - import x = require("mod");
|
|
* - import x = M.x;
|
|
*/
|
|
// dprint-ignore
|
|
export class ImportEqualsDeclaration extends Node<SyntaxKind.ImportEqualsDeclaration, AstImportEqualsDeclarationData> implements DeclarationStatement, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstImportEqualsDeclaration;
|
|
|
|
override get parent() { return super.parent as ModuleBlock | SourceFile; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
get isTypeOnly(): boolean { return this.ast.data.isTypeOnly; }
|
|
/**
|
|
* 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external module reference.
|
|
*/
|
|
get moduleReference(): ModuleReference { return this.ast.data.moduleReference.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set isTypeOnly(value) { this.ast.data.isTypeOnly = value; }
|
|
/** @internal */ set moduleReference(value) { this.ast.data.moduleReference = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ExternalModuleReference extends Node<SyntaxKind.ExternalModuleReference, AstExternalModuleReferenceData> {
|
|
// declare readonly ast: AstExternalModuleReference;
|
|
|
|
override get parent() { return super.parent as ImportEqualsDeclaration; }
|
|
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
}
|
|
|
|
// In case of:
|
|
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
|
|
// In rest of the cases, module specifier is string literal corresponding to module
|
|
// ImportClause information is shown at its declaration below.
|
|
// dprint-ignore
|
|
export class ImportDeclaration extends Node<SyntaxKind.ImportDeclaration, AstImportDeclarationData> implements Declaration, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstImportDeclaration;
|
|
|
|
override get parent() { return super.parent as ModuleBlock | SourceFile; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get importClause(): ImportClause | undefined { return this.ast.data.importClause?.node; }
|
|
/** If this is not a StringLiteral it will be a grammar error. */
|
|
get moduleSpecifier(): Expression { return this.ast.data.moduleSpecifier.node; }
|
|
/** @deprecated */
|
|
get assertClause(): ImportAttributes | undefined { return this.ast.data.attributes?.node; }
|
|
get attributes(): ImportAttributes | undefined { return this.ast.data.attributes?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set importClause(value) { this.ast.data.importClause = value?.ast; }
|
|
/** @internal */ set moduleSpecifier(value) { this.ast.data.moduleSpecifier = value.ast; }
|
|
/** @internal */ set attributes(value) { this.ast.data.attributes = value?.ast; }
|
|
/** @internal */ set assertClause(value) { this.ast.data.attributes = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type NamedImportBindings =
|
|
| NamespaceImport
|
|
| NamedImports;
|
|
|
|
export type NamedExportBindings =
|
|
| NamespaceExport
|
|
| NamedExports;
|
|
|
|
// In case of:
|
|
// import d from "mod" => name = d, namedBinding = undefined
|
|
// import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns }
|
|
// import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns }
|
|
// import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
|
|
// import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]}
|
|
// dprint-ignore
|
|
export class ImportClause extends Node<SyntaxKind.ImportClause, AstImportClauseData> implements NamedDeclaration {
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstImportClause;
|
|
|
|
override get parent() { return super.parent as ImportDeclaration | JSDocImportTag; }
|
|
|
|
get isTypeOnly(): boolean { return this.ast.data.isTypeOnly; }
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get namedBindings(): NamedImportBindings | undefined { return this.ast.data.namedBindings?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set isTypeOnly(value) { this.ast.data.isTypeOnly = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set namedBindings(value) { this.ast.data.namedBindings = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
/** @deprecated */
|
|
export type AssertionKey = ImportAttributeName;
|
|
|
|
/** @deprecated */
|
|
export interface AssertEntry extends ImportAttribute {}
|
|
|
|
/** @deprecated */
|
|
export interface AssertClause extends ImportAttributes {}
|
|
|
|
export type ImportAttributeName = Identifier | StringLiteral;
|
|
|
|
// dprint-ignore
|
|
export class ImportAttribute extends Node<SyntaxKind.ImportAttribute, AstImportAttributeData> {
|
|
// declare readonly ast: AstImportAttribute;
|
|
|
|
override get parent() { return super.parent as ImportAttributes; }
|
|
|
|
get name(): ImportAttributeName { return this.ast.data.name.node; }
|
|
get value(): Expression { return this.ast.data.value.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set value(value) { this.ast.data.value = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ImportAttributes extends Node<SyntaxKind.ImportAttributes, AstImportAttributesData> {
|
|
// declare readonly ast: AstImportAttributes;
|
|
|
|
override get parent() { return super.parent as ImportDeclaration | ExportDeclaration; }
|
|
|
|
get token(): SyntaxKind.WithKeyword | SyntaxKind.AssertKeyword { return this.ast.data.token; }
|
|
get elements(): NodeArray<ImportAttribute> { return this.ast.data.elements.nodes; }
|
|
// TODO(rbuckton): Should this be internal like Block, ObjectLiteralExpression, etc.?
|
|
get multiLine(): boolean | undefined { return this.ast.data.multiLine; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set token(value) { this.ast.data.token = value; }
|
|
/** @internal */ set elements(value) { this.ast.data.elements = value.ast; }
|
|
/** @internal */ set multiLine(value) { this.ast.data.multiLine = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NamespaceImport extends Node<SyntaxKind.NamespaceImport, AstNamespaceImportData> implements NamedDeclaration {
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstNamespaceImport;
|
|
|
|
override get parent() { return super.parent as ImportClause; }
|
|
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NamespaceExport extends Node<SyntaxKind.NamespaceExport, AstNamespaceExportData> implements NamedDeclaration {
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstNamespaceExport;
|
|
|
|
override get parent() { return super.parent as ExportDeclaration; }
|
|
|
|
get name(): ModuleExportName { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NamespaceExportDeclaration extends Node<SyntaxKind.NamespaceExportDeclaration, AstNamespaceExportDeclarationData> implements DeclarationStatement, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstNamespaceExportDeclaration;
|
|
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ExportDeclaration extends Node<SyntaxKind.ExportDeclaration, AstExportDeclarationData> implements DeclarationStatement, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstExportDeclaration;
|
|
|
|
override get parent() { return super.parent as SourceFile | ModuleBlock; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get isTypeOnly(): boolean { return this.ast.data.isTypeOnly; }
|
|
get exportClause(): NamedExportBindings | undefined { return this.ast.data.exportClause?.node; }
|
|
get moduleSpecifier(): Expression | undefined { return this.ast.data.moduleSpecifier?.node; }
|
|
/** @deprecated */
|
|
get assertClause(): ImportAttributes | undefined { return this.ast.data.attributes?.node; }
|
|
get attributes(): ImportAttributes | undefined { return this.ast.data.attributes?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set isTypeOnly(value) { this.ast.data.isTypeOnly = value; }
|
|
/** @internal */ set exportClause(value) { this.ast.data.exportClause = value?.ast; }
|
|
/** @internal */ set moduleSpecifier(value) { this.ast.data.moduleSpecifier = value?.ast; }
|
|
/** @internal */ set attributes(value) { this.ast.data.attributes = value?.ast; }
|
|
/** @internal */ set assertClause(value) { this.ast.data.attributes = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NamedImports extends Node<SyntaxKind.NamedImports, AstNamedImportsData> {
|
|
// declare readonly ast: AstNamedImports;
|
|
|
|
override get parent() { return super.parent as ImportClause; }
|
|
|
|
get elements(): NodeArray<ImportSpecifier> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set elements(value) { this.ast.data.elements = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class NamedExports extends Node<SyntaxKind.NamedExports, AstNamedExportsData> {
|
|
// declare readonly ast: AstNamedExports;
|
|
|
|
override get parent() { return super.parent as ExportDeclaration; }
|
|
|
|
get elements(): NodeArray<ExportSpecifier> { return this.ast.data.elements.nodes; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set elements(value) { this.ast.data.elements = value.ast; }
|
|
}
|
|
|
|
export type NamedImportsOrExports = NamedImports | NamedExports;
|
|
|
|
// dprint-ignore
|
|
export class ImportSpecifier extends Node<SyntaxKind.ImportSpecifier, AstImportSpecifierData> implements NamedDeclaration {
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstImportSpecifier;
|
|
|
|
override get parent() { return super.parent as NamedImports; }
|
|
|
|
get isTypeOnly(): boolean { return this.ast.data.isTypeOnly; }
|
|
/**
|
|
* Name preceding "as" keyword (or undefined when "as" is absent)
|
|
*/
|
|
get propertyName(): ModuleExportName | undefined { return this.ast.data.propertyName?.node; }
|
|
/**
|
|
* Declared name
|
|
*/
|
|
get name(): Identifier { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set propertyName(value) { this.ast.data.propertyName = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set isTypeOnly(value) { this.ast.data.isTypeOnly = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class ExportSpecifier extends Node<SyntaxKind.ExportSpecifier, AstExportSpecifierData> implements NamedDeclaration, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstExportSpecifier;
|
|
|
|
override get parent() { return super.parent as NamedExports; }
|
|
|
|
get isTypeOnly(): boolean { return this.ast.data.isTypeOnly; }
|
|
/**
|
|
* Name preceding "as" keyword (or undefined when "as" is absent)
|
|
*/
|
|
get propertyName(): ModuleExportName | undefined { return this.ast.data.propertyName?.node; }
|
|
/**
|
|
* Declared name
|
|
*/
|
|
get name(): ModuleExportName { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set isTypeOnly(value) { this.ast.data.isTypeOnly = value; }
|
|
/** @internal */ set propertyName(value) { this.ast.data.propertyName = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export type ModuleExportName = Identifier | StringLiteral;
|
|
|
|
export type ImportOrExportSpecifier =
|
|
| ImportSpecifier
|
|
| ExportSpecifier;
|
|
|
|
export type TypeOnlyCompatibleAliasDeclaration =
|
|
| ImportClause
|
|
| ImportEqualsDeclaration
|
|
| NamespaceImport
|
|
| ImportOrExportSpecifier
|
|
| ExportDeclaration
|
|
| NamespaceExport;
|
|
|
|
export type TypeOnlyImportDeclaration =
|
|
| ImportClause & { readonly isTypeOnly: true; readonly name: Identifier; }
|
|
| ImportEqualsDeclaration & { readonly isTypeOnly: true; }
|
|
| NamespaceImport & { readonly parent: ImportClause & { readonly isTypeOnly: true; }; }
|
|
| ImportSpecifier & ({ readonly isTypeOnly: true; } | { readonly parent: NamedImports & { readonly parent: ImportClause & { readonly isTypeOnly: true; }; }; });
|
|
|
|
export type TypeOnlyExportDeclaration =
|
|
| ExportSpecifier & ({ readonly isTypeOnly: true; } | { readonly parent: NamedExports & { readonly parent: ExportDeclaration & { readonly isTypeOnly: true; }; }; })
|
|
| ExportDeclaration & { readonly isTypeOnly: true; readonly moduleSpecifier: Expression; } // export * from "mod"
|
|
| NamespaceExport & { readonly parent: ExportDeclaration & { readonly isTypeOnly: true; readonly moduleSpecifier: Expression; }; } // export * as ns from "mod"
|
|
;
|
|
|
|
export type TypeOnlyAliasDeclaration = TypeOnlyImportDeclaration | TypeOnlyExportDeclaration;
|
|
|
|
/**
|
|
* This is either an `export =` or an `export default` declaration.
|
|
* Unless `isExportEquals` is set, this node was parsed as an `export default`.
|
|
*/
|
|
// dprint-ignore
|
|
export class ExportAssignment extends Node<SyntaxKind.ExportAssignment, AstExportAssignmentData> implements DeclarationStatement, JSDocContainer {
|
|
declare _declarationBrand: any;
|
|
declare _statementBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
// declare readonly ast: AstExportAssignment;
|
|
|
|
override get parent() { return super.parent as SourceFile; }
|
|
|
|
get modifiers(): NodeArray<ModifierLike> | undefined { return this.ast.data.modifiers?.nodes; }
|
|
get isExportEquals(): boolean | undefined { return this.ast.data.isExportEquals; }
|
|
get expression(): Expression { return this.ast.data.expression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set modifiers(value) { this.ast.data.modifiers = value?.ast; }
|
|
/** @internal */ set isExportEquals(value) { this.ast.data.isExportEquals = value; }
|
|
/** @internal */ set expression(value) { this.ast.data.expression = value.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value: JSDocArray | undefined) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
export interface FileReference extends TextRange {
|
|
fileName: string;
|
|
resolutionMode?: ResolutionMode;
|
|
preserve?: boolean;
|
|
}
|
|
|
|
export interface CheckJsDirective extends TextRange {
|
|
enabled: boolean;
|
|
}
|
|
|
|
export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia;
|
|
|
|
export interface CommentRange extends TextRange {
|
|
hasTrailingNewLine?: boolean;
|
|
kind: CommentKind;
|
|
}
|
|
|
|
export interface SynthesizedComment extends CommentRange {
|
|
text: string;
|
|
pos: -1;
|
|
end: -1;
|
|
hasLeadingNewline?: boolean;
|
|
}
|
|
|
|
// represents a top level: { type } expression in a JSDoc comment.
|
|
// dprint-ignore
|
|
export class JSDocTypeExpression extends Node<SyntaxKind.JSDocTypeExpression, AstJSDocTypeExpressionData> implements TypeNode {
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocTypeExpression;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocNameReference extends Node<SyntaxKind.JSDocNameReference, AstJSDocNameReferenceData> {
|
|
// declare readonly ast: AstJSDocNameReference;
|
|
|
|
get name(): EntityName | JSDocMemberName { return this.ast.data.name.node; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
}
|
|
|
|
|
|
/** Class#method reference in JSDoc */
|
|
// dprint-ignore
|
|
export class JSDocMemberName extends Node<SyntaxKind.JSDocMemberName, AstJSDocMemberNameData> {
|
|
// declare readonly ast: AstJSDocMemberName;
|
|
|
|
get left(): EntityName | JSDocMemberName { return this.ast.data.left.node; }
|
|
get right(): Identifier { return this.ast.data.right.node; }
|
|
|
|
/** @internal */ set left(value) { this.ast.data.left = value.ast; }
|
|
/** @internal */ set right(value) { this.ast.data.right = value.ast; }
|
|
}
|
|
|
|
export interface JSDocType extends TypeNode {
|
|
_jsDocTypeBrand: any;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocAllType extends Node<SyntaxKind.JSDocAllType, AstJSDocAllTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocAllType;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocUnknownType extends Node<SyntaxKind.JSDocUnknownType, AstJSDocUnknownTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocUnknownType;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocNonNullableType extends Node<SyntaxKind.JSDocNonNullableType, AstJSDocNonNullableTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocNonNullableType;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
get postfix(): boolean { return this.ast.data.postfix; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ set postfix(value) { this.ast.data.postfix = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocNullableType extends Node<SyntaxKind.JSDocNullableType, AstJSDocNullableTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocNullableType;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
get postfix(): boolean { return this.ast.data.postfix; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
/** @internal */ set postfix(value) { this.ast.data.postfix = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocOptionalType extends Node<SyntaxKind.JSDocOptionalType, AstJSDocOptionalTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocOptionalType;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocFunctionType extends Node<SyntaxKind.JSDocFunctionType, AstJSDocFunctionTypeData> implements JSDocType, SignatureDeclarationBase, LocalsContainer {
|
|
declare _signatureDeclarationBrand: any;
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstJSDocFunctionType;
|
|
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<ParameterDeclaration> { return this.ast.data.parameters.nodes; }
|
|
get type(): TypeNode | undefined { return this.ast.data.type?.node; }
|
|
get typeArguments(): NodeArray<TypeNode> | undefined { return this.ast.data.typeArguments?.nodes; }
|
|
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ set typeArguments(value) { this.ast.data.typeArguments = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocVariadicType extends Node<SyntaxKind.JSDocVariadicType, AstJSDocVariadicTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocVariadicType;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocNamepathType extends Node<SyntaxKind.JSDocNamepathType, AstJSDocNamepathTypeData> implements JSDocType {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
// declare readonly ast: AstJSDocNamepathType;
|
|
|
|
get type(): TypeNode { return this.ast.data.type.node; }
|
|
|
|
/** @internal */ set type(value) { this.ast.data.type = value.ast; }
|
|
}
|
|
|
|
export type JSDocTypeReferencingNode =
|
|
| JSDocVariadicType
|
|
| JSDocOptionalType
|
|
| JSDocNullableType
|
|
| JSDocNonNullableType;
|
|
|
|
// dprint-ignore
|
|
export class JSDoc extends Node<SyntaxKind.JSDoc, AstJSDocData> {
|
|
// declare readonly ast: AstJSDoc;
|
|
|
|
override get parent() { return super.parent as HasJSDoc; }
|
|
|
|
get tags(): NodeArray<JSDocTag> | undefined { return this.ast.data.tags?.nodes; }
|
|
get comment(): string | NodeArray<JSDocComment> | undefined {
|
|
const comment = this.ast.data.comment;
|
|
return typeof comment === "string" ? comment : comment?.nodes;
|
|
}
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set tags(value) { this.ast.data.tags = value?.ast; }
|
|
/** @internal */ set comment(value) { this.ast.data.comment = typeof value === "string" ? value : value?.ast; }
|
|
}
|
|
|
|
// TODO(rbuckton): Move after JSDocText
|
|
// dprint-ignore
|
|
export class JSDocTag<TKind extends SyntaxKind = SyntaxKind, T extends AstJSDocTagData = AstJSDocTagData> extends Node<TKind, T> {
|
|
// declare readonly ast: AstBaseJSDocTag<TKind, T>;
|
|
|
|
override get parent() { return super.parent as JSDoc | JSDocTypeLiteral; }
|
|
|
|
get tagName(): Identifier { return this.ast.data.tagName.node; }
|
|
get comment(): string | NodeArray<JSDocLink | JSDocLinkCode | JSDocLinkPlain | JSDocText> | undefined {
|
|
const comment = this.ast.data.comment;
|
|
return typeof comment === "string" ? comment : comment?.nodes;
|
|
}
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set tagName(value) { this.ast.data.tagName = value.ast; }
|
|
/** @internal */ set comment(value) { this.ast.data.comment = typeof value === "string" ? value : value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocLink extends Node<SyntaxKind.JSDocLink, AstJSDocLinkData> {
|
|
// declare readonly ast: AstJSDocLink;
|
|
|
|
get name(): EntityName | JSDocMemberName | undefined { return this.ast.data.name?.node; }
|
|
get text(): string { return this.ast.data.text; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocLinkCode extends Node<SyntaxKind.JSDocLinkCode, AstJSDocLinkCodeData> {
|
|
// declare readonly ast: AstJSDocLinkCode;
|
|
|
|
get name(): EntityName | JSDocMemberName | undefined { return this.ast.data.name?.node; }
|
|
get text(): string { return this.ast.data.text; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocLinkPlain extends Node<SyntaxKind.JSDocLinkPlain, AstJSDocLinkPlainData> {
|
|
// declare readonly ast: AstJSDocLinkPlain;
|
|
|
|
get name(): EntityName | JSDocMemberName | undefined { return this.ast.data.name?.node; }
|
|
get text(): string { return this.ast.data.text; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
}
|
|
|
|
export type JSDocComment = JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain;
|
|
|
|
// dprint-ignore
|
|
export class JSDocText extends Node<SyntaxKind.JSDocText, AstJSDocTextData> {
|
|
// declare readonly ast: AstJSDocText;
|
|
|
|
get text(): string { return this.ast.data.text; }
|
|
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocUnknownTag extends JSDocTag<SyntaxKind.JSDocTag, AstJSDocUnknownTagData> {
|
|
// declare readonly ast: AstJSDocUnknownTag;
|
|
}
|
|
|
|
export interface JSDocClassReference extends ExpressionWithTypeArguments {
|
|
// readonly ast: AstJSDocClassReference;
|
|
readonly data: AstJSDocClassReferenceData;
|
|
readonly expression: Identifier | PropertyAccessEntityNameExpression;
|
|
}
|
|
|
|
/**
|
|
* Note that `@extends` is a synonym of `@augments`.
|
|
* Both tags are represented by this interface.
|
|
*/
|
|
// dprint-ignore
|
|
export class JSDocAugmentsTag extends JSDocTag<SyntaxKind.JSDocAugmentsTag, AstJSDocAugmentsTagData> {
|
|
// declare readonly ast: AstJSDocAugmentsTag;
|
|
|
|
get class(): JSDocClassReference { return this.ast.data.class.node; }
|
|
|
|
/** @internal */ set class(value) { this.ast.data.class = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocImplementsTag extends JSDocTag<SyntaxKind.JSDocImplementsTag, AstJSDocImplementsTagData> {
|
|
// declare readonly ast: AstJSDocImplementsTag;
|
|
|
|
get class(): JSDocClassReference { return this.ast.data.class.node; }
|
|
|
|
/** @internal */ set class(value) { this.ast.data.class = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocAuthorTag extends JSDocTag<SyntaxKind.JSDocAuthorTag, AstJSDocAuthorTagData> {
|
|
// declare readonly ast: AstJSDocAuthorTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocDeprecatedTag extends JSDocTag<SyntaxKind.JSDocDeprecatedTag, AstJSDocDeprecatedTagData> {
|
|
// declare readonly ast: AstJSDocDeprecatedTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocClassTag extends JSDocTag<SyntaxKind.JSDocClassTag, AstJSDocClassTagData> {
|
|
// declare readonly ast: AstJSDocClassTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocPublicTag extends JSDocTag<SyntaxKind.JSDocPublicTag, AstJSDocPublicTagData> {
|
|
// declare readonly ast: AstJSDocPublicTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocPrivateTag extends JSDocTag<SyntaxKind.JSDocPrivateTag, AstJSDocPrivateTagData> {
|
|
// declare readonly ast: AstJSDocPrivateTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocProtectedTag extends JSDocTag<SyntaxKind.JSDocProtectedTag, AstJSDocProtectedTagData> {
|
|
// declare readonly ast: AstJSDocProtectedTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocReadonlyTag extends JSDocTag<SyntaxKind.JSDocReadonlyTag, AstJSDocReadonlyTagData> {
|
|
// declare readonly ast: AstJSDocReadonlyTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocOverrideTag extends JSDocTag<SyntaxKind.JSDocOverrideTag, AstJSDocOverrideTagData> {
|
|
// declare readonly ast: AstJSDocOverrideTag;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocEnumTag extends JSDocTag<SyntaxKind.JSDocEnumTag, AstJSDocEnumTagData> implements Declaration, LocalsContainer {
|
|
declare _declarationBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstJSDocEnumTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get typeExpression(): JSDocTypeExpression { return this.ast.data.typeExpression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocThisTag extends JSDocTag<SyntaxKind.JSDocThisTag, AstJSDocThisTagData> {
|
|
// declare readonly ast: AstJSDocThisTag;
|
|
|
|
get typeExpression(): JSDocTypeExpression { return this.ast.data.typeExpression.node; }
|
|
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocTemplateTag extends JSDocTag<SyntaxKind.JSDocTemplateTag, AstJSDocTemplateTagData> {
|
|
// declare readonly ast: AstJSDocTemplateTag;
|
|
|
|
get constraint(): JSDocTypeExpression | undefined { return this.ast.data.constraint?.node; }
|
|
get typeParameters(): NodeArray<TypeParameterDeclaration> { return this.ast.data.typeParameters.nodes; }
|
|
|
|
/** @internal */ set constraint(value) { this.ast.data.constraint = value?.ast; }
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocSeeTag extends JSDocTag<SyntaxKind.JSDocSeeTag, AstJSDocSeeTagData> {
|
|
// declare readonly ast: AstJSDocSeeTag;
|
|
|
|
get name(): JSDocNameReference | undefined { return this.ast.data.name?.node; }
|
|
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocReturnTag extends JSDocTag<SyntaxKind.JSDocReturnTag, AstJSDocReturnTagData> {
|
|
// declare readonly ast: AstJSDocReturnTag;
|
|
|
|
get typeExpression(): JSDocTypeExpression | undefined { return this.ast.data.typeExpression?.node; }
|
|
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocTypeTag extends JSDocTag<SyntaxKind.JSDocTypeTag, AstJSDocTypeTagData> {
|
|
// declare readonly ast: AstJSDocTypeTag;
|
|
|
|
get typeExpression(): JSDocTypeExpression { return this.ast.data.typeExpression.node; }
|
|
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocTypedefTag extends JSDocTag<SyntaxKind.JSDocTypedefTag, AstJSDocTypedefTagData> implements Declaration, LocalsContainer {
|
|
declare _declarationBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstJSDocTypedefTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get fullName(): Identifier | JSDocNamespaceDeclaration | undefined { return this.ast.data.fullName?.node; }
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get typeExpression(): JSDocTypeLiteral | JSDocTypeExpression | undefined { return this.ast.data.typeExpression?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set fullName(value) { this.ast.data.fullName = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value?.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocCallbackTag extends JSDocTag<SyntaxKind.JSDocCallbackTag, AstJSDocCallbackTagData> implements Declaration, LocalsContainer {
|
|
declare _declarationBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstJSDocCallbackTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get fullName(): Identifier | JSDocNamespaceDeclaration | undefined { return this.ast.data.fullName?.node; }
|
|
get name(): Identifier | undefined { return this.ast.data.name?.node; }
|
|
get typeExpression(): JSDocSignature { return this.ast.data.typeExpression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set fullName(value) { this.ast.data.fullName = value?.ast; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value?.ast; }
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value.ast; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocOverloadTag extends JSDocTag<SyntaxKind.JSDocOverloadTag, AstJSDocOverloadTagData> {
|
|
// declare readonly ast: AstJSDocOverloadTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get typeExpression(): JSDocSignature { return this.ast.data.typeExpression.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocThrowsTag extends JSDocTag<SyntaxKind.JSDocThrowsTag, AstJSDocThrowsTagData> {
|
|
// declare readonly ast: AstJSDocThrowsTag;
|
|
|
|
get typeExpression(): JSDocTypeExpression | undefined { return this.ast.data.typeExpression?.node; }
|
|
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value?.ast; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocSignature extends Node<SyntaxKind.JSDocSignature, AstJSDocSignatureData> implements JSDocType, Declaration, JSDocContainer, LocalsContainer {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
declare _jsdocContainerBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
declare _signatureDeclarationBrand: any;
|
|
// declare readonly ast: AstJSDocSignature;
|
|
|
|
get typeParameters(): NodeArray<JSDocTemplateTag> | undefined { return this.ast.data.typeParameters?.nodes; }
|
|
get parameters(): NodeArray<JSDocParameterTag> { return this.ast.data.parameters.nodes; }
|
|
get type(): JSDocReturnTag | undefined { return this.ast.data.type?.node; }
|
|
|
|
/** @internal */ set typeParameters(value) { this.ast.data.typeParameters = value?.ast; }
|
|
/** @internal */ set parameters(value) { this.ast.data.parameters = value.ast; }
|
|
/** @internal */ set type(value) { this.ast.data.type = value?.ast; }
|
|
/** @internal */ get jsDoc(): JSDocArray | undefined { return this.ast.data.jsDoc; }
|
|
/** @internal */ set jsDoc(value) { this.ast.data.jsDoc = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
}
|
|
|
|
export interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
|
|
// readonly ast: AstJSDocPropertyLikeTag;
|
|
readonly data: AstJSDocTagData & AstDeclarationData;
|
|
readonly parent: JSDoc;
|
|
readonly name: EntityName;
|
|
readonly typeExpression?: JSDocTypeExpression | undefined;
|
|
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
|
readonly isNameFirst: boolean;
|
|
readonly isBracketed: boolean;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocPropertyTag extends JSDocTag<SyntaxKind.JSDocPropertyTag, AstJSDocPropertyTagData> implements JSDocPropertyLikeTag, Declaration {
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstJSDocPropertyTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get name(): Identifier | QualifiedName { return this.ast.data.name.node; }
|
|
get typeExpression(): JSDocTypeExpression | undefined { return this.ast.data.typeExpression?.node; }
|
|
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
|
get isNameFirst(): boolean { return this.ast.data.isNameFirst; }
|
|
get isBracketed(): boolean { return this.ast.data.isBracketed; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value?.ast; }
|
|
/** @internal */ set isNameFirst(value) { this.ast.data.isNameFirst = value; }
|
|
/** @internal */ set isBracketed(value) { this.ast.data.isBracketed = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocParameterTag extends JSDocTag<SyntaxKind.JSDocParameterTag, AstJSDocParameterTagData> implements JSDocPropertyLikeTag {
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstJSDocParameterTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get name(): Identifier | QualifiedName { return this.ast.data.name.node; }
|
|
get typeExpression(): JSDocTypeExpression | undefined { return this.ast.data.typeExpression?.node; }
|
|
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
|
get isNameFirst(): boolean { return this.ast.data.isNameFirst; }
|
|
get isBracketed(): boolean { return this.ast.data.isBracketed; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set name(value) { this.ast.data.name = value.ast; }
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value?.ast; }
|
|
/** @internal */ set isNameFirst(value) { this.ast.data.isNameFirst = value; }
|
|
/** @internal */ set isBracketed(value) { this.ast.data.isBracketed = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocTypeLiteral extends Node<SyntaxKind.JSDocTypeLiteral, AstJSDocTypeLiteralData> implements JSDocType, Declaration {
|
|
declare _jsDocTypeBrand: any;
|
|
declare _typeNodeBrand: any;
|
|
declare _declarationBrand: any;
|
|
// declare readonly ast: AstJSDocTypeLiteral;
|
|
|
|
get jsDocPropertyTags(): NodeArray<JSDocPropertyLikeTag> | undefined { return this.ast.data.jsDocPropertyTags?.nodes; }
|
|
/** If true, then this type literal represents an *array* of its type. */
|
|
get isArrayType(): boolean { return this.ast.data.isArrayType; }
|
|
|
|
/** @internal */ set jsDocPropertyTags(value) { this.ast.data.jsDocPropertyTags = value?.ast; }
|
|
/** @internal */ set isArrayType(value) { this.ast.data.isArrayType = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.localSymbol = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocSatisfiesTag extends JSDocTag<SyntaxKind.JSDocSatisfiesTag, AstJSDocSatisfiesTagData> {
|
|
// declare readonly ast: AstJSDocSatisfiesTag;
|
|
|
|
get typeExpression(): JSDocTypeExpression { return this.ast.data.typeExpression.node; }
|
|
|
|
/** @internal */ set typeExpression(value) { this.ast.data.typeExpression = value.ast; }
|
|
}
|
|
|
|
/** @internal */
|
|
export interface JSDocSatisfiesExpression extends ParenthesizedExpression {
|
|
readonly _jsDocSatisfiesExpressionBrand: never;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class JSDocImportTag extends JSDocTag<SyntaxKind.JSDocImportTag, AstJSDocImportTagData> {
|
|
// declare readonly ast: AstJSDocImportTag;
|
|
|
|
override get parent() { return super.parent as JSDoc; }
|
|
|
|
get importClause(): ImportClause | undefined { return this.ast.data.importClause?.node; }
|
|
get moduleSpecifier(): Expression { return this.ast.data.moduleSpecifier.node; }
|
|
get attributes(): ImportAttributes | undefined { return this.ast.data.attributes?.node; }
|
|
|
|
/** @internal */ override set parent(value) { super.parent = value; }
|
|
/** @internal */ set importClause(value) { this.ast.data.importClause = value?.ast; }
|
|
/** @internal */ set moduleSpecifier(value) { this.ast.data.moduleSpecifier = value.ast; }
|
|
/** @internal */ set attributes(value) { this.ast.data.attributes = value?.ast; }
|
|
}
|
|
|
|
// NOTE: Ensure this is up-to-date with src/debug/debug.ts
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum FlowFlags {
|
|
Unreachable = 1 << 0, // Unreachable code
|
|
Start = 1 << 1, // Start of flow graph
|
|
BranchLabel = 1 << 2, // Non-looping junction
|
|
LoopLabel = 1 << 3, // Looping junction
|
|
Assignment = 1 << 4, // Assignment
|
|
TrueCondition = 1 << 5, // Condition known to be true
|
|
FalseCondition = 1 << 6, // Condition known to be false
|
|
SwitchClause = 1 << 7, // Switch statement clause
|
|
ArrayMutation = 1 << 8, // Potential array mutation
|
|
Call = 1 << 9, // Potential assertion call
|
|
ReduceLabel = 1 << 10, // Temporarily reduce antecedents of label
|
|
Referenced = 1 << 11, // Referenced as antecedent once
|
|
Shared = 1 << 12, // Referenced as antecedent more than once
|
|
|
|
Label = BranchLabel | LoopLabel,
|
|
Condition = TrueCondition | FalseCondition,
|
|
}
|
|
|
|
/** @internal */
|
|
export type FlowNode =
|
|
| FlowUnreachable
|
|
| FlowStart
|
|
| FlowLabel
|
|
| FlowAssignment
|
|
| FlowCondition
|
|
| FlowSwitchClause
|
|
| FlowArrayMutation
|
|
| FlowCall
|
|
| FlowReduceLabel;
|
|
|
|
/** @internal */
|
|
export interface FlowNodeBase {
|
|
flags: FlowFlags;
|
|
id: number; // Node id used by flow type cache in checker
|
|
node: unknown; // Node or other data
|
|
antecedent: FlowNode | FlowNode[] | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FlowUnreachable extends FlowNodeBase {
|
|
node: undefined;
|
|
antecedent: undefined;
|
|
}
|
|
|
|
// FlowStart represents the start of a control flow. For a function expression or arrow
|
|
// function, the node property references the function (which in turn has a flowNode
|
|
// property for the containing control flow).
|
|
/** @internal */
|
|
export interface FlowStart extends FlowNodeBase {
|
|
node: FunctionExpression | ArrowFunction | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | undefined;
|
|
antecedent: undefined;
|
|
}
|
|
|
|
// FlowLabel represents a junction with multiple possible preceding control flows.
|
|
/** @internal */
|
|
export interface FlowLabel extends FlowNodeBase {
|
|
node: undefined;
|
|
antecedent: FlowNode[] | undefined;
|
|
}
|
|
|
|
// FlowAssignment represents a node that assigns a value to a narrowable reference,
|
|
// i.e. an identifier or a dotted name that starts with an identifier or 'this'.
|
|
/** @internal */
|
|
export interface FlowAssignment extends FlowNodeBase {
|
|
node: Expression | VariableDeclaration | BindingElement;
|
|
antecedent: FlowNode;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FlowCall extends FlowNodeBase {
|
|
node: CallExpression;
|
|
antecedent: FlowNode;
|
|
}
|
|
|
|
// FlowCondition represents a condition that is known to be true or false at the
|
|
// node's location in the control flow.
|
|
/** @internal */
|
|
export interface FlowCondition extends FlowNodeBase {
|
|
node: Expression;
|
|
antecedent: FlowNode;
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface FlowSwitchClause extends FlowNodeBase {
|
|
node: FlowSwitchClauseData;
|
|
antecedent: FlowNode;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FlowSwitchClauseData {
|
|
switchStatement: SwitchStatement;
|
|
clauseStart: number; // Start index of case/default clause range
|
|
clauseEnd: number; // End index of case/default clause range
|
|
}
|
|
|
|
// FlowArrayMutation represents a node potentially mutates an array, i.e. an
|
|
// operation of the form 'x.push(value)', 'x.unshift(value)' or 'x[n] = value'.
|
|
/** @internal */
|
|
export interface FlowArrayMutation extends FlowNodeBase {
|
|
node: CallExpression | BinaryExpression;
|
|
antecedent: FlowNode;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FlowReduceLabel extends FlowNodeBase {
|
|
node: FlowReduceLabelData;
|
|
antecedent: FlowNode;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FlowReduceLabelData {
|
|
target: FlowLabel;
|
|
antecedents: FlowNode[];
|
|
}
|
|
|
|
export type FlowType = Type | IncompleteType;
|
|
|
|
// Incomplete types occur during control flow analysis of loops. An IncompleteType
|
|
// is distinguished from a regular type by a flags value of zero. Incomplete type
|
|
// objects are internal to the getFlowTypeOfReference function and never escape it.
|
|
// dprint-ignore
|
|
export interface IncompleteType {
|
|
flags: TypeFlags | 0; // No flags set
|
|
type: Type; // The type marked incomplete
|
|
}
|
|
|
|
export interface AmdDependency {
|
|
path: string;
|
|
name?: string;
|
|
}
|
|
|
|
/**
|
|
* Subset of properties from SourceFile that are used in multiple utility functions
|
|
*/
|
|
export interface SourceFileLike {
|
|
readonly text: string;
|
|
/** @internal */
|
|
lineMap?: readonly number[] | undefined;
|
|
/** @internal */
|
|
getPositionOfLineAndCharacter?(line: number, character: number, allowEdits?: true): number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FutureSourceFile {
|
|
readonly path: Path;
|
|
readonly fileName: string;
|
|
readonly impliedNodeFormat?: ResolutionMode | undefined;
|
|
readonly packageJsonScope?: PackageJsonInfo | undefined;
|
|
readonly externalModuleIndicator?: true | undefined;
|
|
readonly commonJsModuleIndicator?: true | undefined;
|
|
readonly statements: readonly never[];
|
|
readonly imports: readonly never[];
|
|
}
|
|
|
|
/** @internal */
|
|
export interface RedirectInfo {
|
|
/** Source file this redirects to. */
|
|
readonly redirectTarget: SourceFile;
|
|
/**
|
|
* Source file for the duplicate package. This will not be used by the Program,
|
|
* but we need to keep this around so we can watch for changes in underlying.
|
|
*/
|
|
readonly unredirected: SourceFile;
|
|
}
|
|
|
|
export type ResolutionMode = ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
|
|
|
|
// Source files are declarations when they are external modules.
|
|
// dprint-ignore
|
|
export class SourceFile extends Node<SyntaxKind.SourceFile, AstSourceFileData> implements Declaration, LocalsContainer, ReadonlyPragmaContext {
|
|
declare _declarationBrand: any;
|
|
declare _localsContainerBrand: any;
|
|
// declare readonly ast: AstSourceFile;
|
|
|
|
get statements(): NodeArray<Statement> { return this.ast.data.statements.nodes; }
|
|
get endOfFileToken(): EndOfFileToken { return this.ast.data.endOfFileToken.node; }
|
|
get fileName(): string { return this.ast.data.fileName; }
|
|
get text(): string { return this.ast.data.text; }
|
|
get amdDependencies(): AmdDependency[] { return this.ast.data.amdDependencies; }
|
|
get moduleName(): string | undefined { return this.ast.data.moduleName; }
|
|
get referencedFiles(): readonly FileReference[] { return this.ast.data.referencedFiles; }
|
|
get typeReferenceDirectives(): readonly FileReference[] { return this.ast.data.typeReferenceDirectives; }
|
|
get libReferenceDirectives(): readonly FileReference[] { return this.ast.data.libReferenceDirectives; }
|
|
get languageVariant(): LanguageVariant { return this.ast.data.languageVariant; }
|
|
get isDeclarationFile(): boolean { return this.ast.data.isDeclarationFile; }
|
|
/**
|
|
* lib.d.ts should have a reference comment like
|
|
*
|
|
* /// <reference no-default-lib="true"/>
|
|
*
|
|
* If any other file has this comment, it signals not to include lib.d.ts
|
|
* because this containing file is intended to act as a default library.
|
|
*/
|
|
get hasNoDefaultLib(): boolean { return this.ast.data.hasNoDefaultLib; }
|
|
get languageVersion(): ScriptTarget { return this.ast.data.languageVersion; }
|
|
/**
|
|
* When `module` is `Node16` or `NodeNext`, this field controls whether the
|
|
* source file in question is an ESNext-output-format file, or a CommonJS-output-format
|
|
* module. This is derived by the module resolver as it looks up the file, since
|
|
* it is derived from either the file extension of the module, or the containing
|
|
* `package.json` context, and affects both checking and emit.
|
|
*
|
|
* It is _public_ so that (pre)transformers can set this field,
|
|
* since it switches the builtin `node` module transform. Generally speaking, if unset,
|
|
* the field is treated as though it is `ModuleKind.CommonJS`.
|
|
*
|
|
* Note that this field is only set by the module resolution process when
|
|
* `moduleResolution` is `Node16` or `NodeNext`, which is implied by the `module` setting
|
|
* of `Node16` or `NodeNext`, respectively, but may be overriden (eg, by a `moduleResolution`
|
|
* of `node`). If so, this field will be unset and source files will be considered to be
|
|
* CommonJS-output-format by the node module transformer and type checker, regardless of extension or context.
|
|
*/
|
|
get impliedNodeFormat(): ResolutionMode { return this.ast.data.impliedNodeFormat; }
|
|
|
|
/** @internal */ set statements(value) { this.ast.data.statements = value.ast; }
|
|
/** @internal */ set endOfFileToken(value) { this.ast.data.endOfFileToken = value.ast; }
|
|
/** @internal */ set fileName(value) { this.ast.data.fileName = value; }
|
|
/** @internal */ get path(): Path { return this.ast.data.path; }
|
|
/** @internal */ set path(value) { this.ast.data.path = value; }
|
|
/** @internal */ set text(value) { this.ast.data.text = value; }
|
|
/** @internal */ get resolvedPath(): Path { return this.ast.data.resolvedPath; }
|
|
/** @internal */ set resolvedPath(value) { this.ast.data.resolvedPath = value; }
|
|
/** @internal */ get originalFileName(): string { return this.ast.data.originalFileName; }
|
|
/** @internal */ set originalFileName(value) { this.ast.data.originalFileName = value; }
|
|
/** @internal */ set amdDependencies(value) { this.ast.data.amdDependencies = value; }
|
|
/** @internal */ set moduleName(value) { this.ast.data.moduleName = value; }
|
|
/** @internal */ set referencedFiles(value) { this.ast.data.referencedFiles = value; }
|
|
/** @internal */ set typeReferenceDirectives(value) { this.ast.data.typeReferenceDirectives = value; }
|
|
/** @internal */ set libReferenceDirectives(value) { this.ast.data.libReferenceDirectives = value; }
|
|
/** @internal */ set languageVariant(value) { this.ast.data.languageVariant = value; }
|
|
/** @internal */ set isDeclarationFile(value) { this.ast.data.isDeclarationFile = value; }
|
|
/** @internal */ get renamedDependencies(): Map<string, string> { return this.ast.data.renamedDependencies; }
|
|
/** @internal */ set renamedDependencies(value) { this.ast.data.renamedDependencies = value; }
|
|
/** @internal */ set hasNoDefaultLib(value) { this.ast.data.hasNoDefaultLib = value; }
|
|
/** @internal */ set languageVersion(value) { this.ast.data.languageVersion = value; }
|
|
/** @internal */ set impliedNodeFormat(value) { this.ast.data.impliedNodeFormat = value; }
|
|
/** @internal */ get scriptKind(): ScriptKind { return this.ast.data.scriptKind; }
|
|
/** @internal */ set scriptKind(value) { this.ast.data.scriptKind = value; }
|
|
/** @internal */ get pragmas(): ReadonlyPragmaMap { return this.ast.data.pragmas; }
|
|
/** @internal */ set pragmas(value) { this.ast.data.pragmas = value; }
|
|
/** @internal */ get externalModuleIndicator(): true | Node | undefined { return this.ast.data.externalModuleIndicator; }
|
|
/** @internal */ set externalModuleIndicator(value) { this.ast.data.externalModuleIndicator = value; }
|
|
/** @internal */ get commonJsModuleIndicator(): Node | undefined { return this.ast.data.commonJsModuleIndicator; }
|
|
/** @internal */ set commonJsModuleIndicator(value) { this.ast.data.commonJsModuleIndicator = value; }
|
|
/** @internal */ get identifiers(): Map<string, string> { return this.ast.data.identifiers; }
|
|
/** @internal */ set identifiers(value) { this.ast.data.identifiers = value; }
|
|
/** @internal */ get parseDiagnostics(): DiagnosticWithLocation[] { return this.ast.data.parseDiagnostics; }
|
|
/** @internal */ set parseDiagnostics(value) { this.ast.data.parseDiagnostics = value; }
|
|
/** @internal */ get bindDiagnostics(): DiagnosticWithLocation[] { return this.ast.data.bindDiagnostics; }
|
|
/** @internal */ set bindDiagnostics(value) { this.ast.data.bindDiagnostics = value; }
|
|
/** @internal */ get bindSuggestionDiagnostics(): DiagnosticWithLocation[] | undefined { return this.ast.data.bindSuggestionDiagnostics; }
|
|
/** @internal */ set bindSuggestionDiagnostics(value) { this.ast.data.bindSuggestionDiagnostics = value; }
|
|
/** @internal */ get lineMap(): readonly number[] { return this.ast.data.lineMap; }
|
|
/** @internal */ set lineMap(value) { this.ast.data.lineMap = value; }
|
|
/** @internal */ get jsDocDiagnostics(): DiagnosticWithLocation[] | undefined { return this.ast.data.jsDocDiagnostics; }
|
|
/** @internal */ set jsDocDiagnostics(value) { this.ast.data.jsDocDiagnostics = value; }
|
|
/** @internal */ get commentDirectives(): CommentDirective[] | undefined { return this.ast.data.commentDirectives; }
|
|
/** @internal */ set commentDirectives(value) { this.ast.data.commentDirectives = value; }
|
|
/** @internal */ get checkJsDirective(): CheckJsDirective | undefined { return this.ast.data.checkJsDirective; }
|
|
/** @internal */ set checkJsDirective(value) { this.ast.data.checkJsDirective = value; }
|
|
/** @internal */ get version(): string { return this.ast.data.version; }
|
|
/** @internal */ set version(value) { this.ast.data.version = value; }
|
|
/** @internal */ get symbol(): Symbol { return this.ast.data.declaration.symbol; }
|
|
/** @internal */ set symbol(value) { this.ast.data.declaration.symbol = value; }
|
|
/** @internal */ get localSymbol(): Symbol | undefined { return this.ast.data.declaration.localSymbol; }
|
|
/** @internal */ set localSymbol(value) { this.ast.data.declaration.localSymbol = value; }
|
|
/** @internal */ get locals(): SymbolTable | undefined { return this.ast.data.locals; }
|
|
/** @internal */ set locals(value) { this.ast.data.locals = value; }
|
|
/** @internal */ get redirectInfo(): RedirectInfo | undefined { return this.ast.data.redirectInfo; }
|
|
/** @internal */ set redirectInfo(value) { this.ast.data.redirectInfo = value; }
|
|
/** @internal */ get packageJsonLocations(): readonly string[] | undefined { return this.ast.data.packageJsonLocations; }
|
|
/** @internal */ set packageJsonLocations(value) { this.ast.data.packageJsonLocations = value; }
|
|
/** @internal */ get packageJsonScope(): PackageJsonInfo | undefined { return this.ast.data.packageJsonScope; }
|
|
/** @internal */ set packageJsonScope(value) { this.ast.data.packageJsonScope = value; }
|
|
/** @internal */ get setExternalModuleIndicator(): ((file: SourceFile) => void) | undefined { return this.ast.data.setExternalModuleIndicator; }
|
|
/** @internal */ set setExternalModuleIndicator(value) { this.ast.data.setExternalModuleIndicator = value; }
|
|
/** @internal */ get jsGlobalAugmentations(): SymbolTable | undefined { return this.ast.data.jsGlobalAugmentations; }
|
|
/** @internal */ set jsGlobalAugmentations(value) { this.ast.data.jsGlobalAugmentations = value; }
|
|
/** @internal */ get nodeCount(): number { return this.ast.data.nodeCount; }
|
|
/** @internal */ set nodeCount(value) { this.ast.data.nodeCount = value; }
|
|
/** @internal */ get identifierCount(): number { return this.ast.data.identifierCount; }
|
|
/** @internal */ set identifierCount(value) { this.ast.data.identifierCount = value; }
|
|
/** @internal */ get symbolCount(): number { return this.ast.data.symbolCount; }
|
|
/** @internal */ set symbolCount(value) { this.ast.data.symbolCount = value; }
|
|
/** @internal */ get additionalSyntacticDiagnostics(): readonly DiagnosticWithLocation[] | undefined { return this.ast.data.additionalSyntacticDiagnostics; }
|
|
/** @internal */ set additionalSyntacticDiagnostics(value) { this.ast.data.additionalSyntacticDiagnostics = value; }
|
|
/** @internal */ get classifiableNames(): ReadonlySet<__String> | undefined { return this.ast.data.classifiableNames; }
|
|
/** @internal */ set classifiableNames(value) { this.ast.data.classifiableNames = value; }
|
|
/** @internal */ get imports(): readonly StringLiteralLike[] { return this.ast.data.imports; }
|
|
/** @internal */ set imports(value) { this.ast.data.imports = value; }
|
|
/** @internal */ get moduleAugmentations(): readonly (Identifier | StringLiteral)[] { return this.ast.data.moduleAugmentations; }
|
|
/** @internal */ set moduleAugmentations(value) { this.ast.data.moduleAugmentations = value; }
|
|
/** @internal */ get patternAmbientModules(): PatternAmbientModule[] | undefined { return this.ast.data.patternAmbientModules; }
|
|
/** @internal */ set patternAmbientModules(value) { this.ast.data.patternAmbientModules = value; }
|
|
/** @internal */ get ambientModuleNames(): readonly string[] { return this.ast.data.ambientModuleNames; }
|
|
/** @internal */ set ambientModuleNames(value) { this.ast.data.ambientModuleNames = value; }
|
|
/** @internal */ get localJsxNamespace(): __String | undefined { return this.ast.data.localJsxNamespace; }
|
|
/** @internal */ set localJsxNamespace(value) { this.ast.data.localJsxNamespace = value; }
|
|
/** @internal */ get localJsxFragmentNamespace(): __String | undefined { return this.ast.data.localJsxFragmentNamespace; }
|
|
/** @internal */ set localJsxFragmentNamespace(value) { this.ast.data.localJsxFragmentNamespace = value; }
|
|
/** @internal */ get localJsxFactory(): EntityName | undefined { return this.ast.data.localJsxFactory; }
|
|
/** @internal */ set localJsxFactory(value) { this.ast.data.localJsxFactory = value; }
|
|
/** @internal */ get localJsxFragmentFactory(): EntityName | undefined { return this.ast.data.localJsxFragmentFactory; }
|
|
/** @internal */ set localJsxFragmentFactory(value) { this.ast.data.localJsxFragmentFactory = value; }
|
|
/** @internal */ get endFlowNode(): FlowNode | undefined { return this.ast.data.endFlowNode; }
|
|
/** @internal */ set endFlowNode(value) { this.ast.data.endFlowNode = value; }
|
|
/** @internal */ get jsDocParsingMode(): JSDocParsingMode | undefined { return this.ast.data.jsDocParsingMode; }
|
|
/** @internal */ set jsDocParsingMode(value) { this.ast.data.jsDocParsingMode = value; }
|
|
/** @internal */ get scriptSnapshot(): IScriptSnapshot | undefined { return this.ast.data.scriptSnapshot; }
|
|
/** @internal */ set scriptSnapshot(value) { this.ast.data.scriptSnapshot = value; }
|
|
/** @internal */ get nameTable(): Map<__String, number> | undefined { return this.ast.data.nameTable; }
|
|
/** @internal */ set nameTable(value) { this.ast.data.nameTable = value; }
|
|
/** @internal */ get nextContainer(): HasLocals | undefined { return this.ast.data.nextContainer?.node; }
|
|
/** @internal */ set nextContainer(value) { this.ast.data.nextContainer = value?.ast; }
|
|
/** @internal */ get extendedSourceFiles(): string[] | undefined { return this.ast.data.extendedSourceFiles; }
|
|
/** @internal */ set extendedSourceFiles(value) { this.ast.data.extendedSourceFiles = value; }
|
|
/** @internal */ get configFileSpecs(): ConfigFileSpecs | undefined { return this.ast.data.configFileSpecs; }
|
|
/** @internal */ set configFileSpecs(value) { this.ast.data.configFileSpecs = value; }
|
|
|
|
update(newText: string, textChangeRange: TextChangeRange): SourceFile {
|
|
return updateSourceFile(this, newText, textChangeRange);
|
|
}
|
|
|
|
getLineAndCharacterOfPosition(position: number): LineAndCharacter {
|
|
return getLineAndCharacterOfPosition(this, position);
|
|
}
|
|
|
|
getLineStarts(): readonly number[] {
|
|
return getLineStarts(this);
|
|
}
|
|
|
|
getPositionOfLineAndCharacter(line: number, character: number): number;
|
|
/** @internal */
|
|
getPositionOfLineAndCharacter(line: number, character: number, allowEdits?: true): number; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
getPositionOfLineAndCharacter(line: number, character: number, allowEdits?: true): number {
|
|
return computePositionOfLineAndCharacter(getLineStarts(this), line, character, this.text, allowEdits);
|
|
}
|
|
|
|
getLineEndOfPosition(pos: number): number {
|
|
const { line } = this.getLineAndCharacterOfPosition(pos);
|
|
const lineStarts = this.getLineStarts();
|
|
|
|
let lastCharPos: number | undefined;
|
|
if (line + 1 >= lineStarts.length) {
|
|
lastCharPos = this.getEnd();
|
|
}
|
|
if (!lastCharPos) {
|
|
lastCharPos = lineStarts[line + 1] - 1;
|
|
}
|
|
|
|
const fullText = this.getFullText();
|
|
// if the new line is "\r\n", we should return the last non-new-line-character position
|
|
return fullText[lastCharPos] === "\n" && fullText[lastCharPos - 1] === "\r" ? lastCharPos - 1 : lastCharPos;
|
|
}
|
|
|
|
/** @internal */
|
|
getNamedDeclarations(): Map<string, Declaration[]> {
|
|
if (!this.ast.data.namedDeclarations) {
|
|
this.ast.data.namedDeclarations = this._computeNamedDeclarations();
|
|
}
|
|
|
|
return this.ast.data.namedDeclarations;
|
|
}
|
|
|
|
/** @internal @private */
|
|
_computeNamedDeclarations(): Map<string, Declaration[]> {
|
|
const result = createMultiMap<string, Declaration>();
|
|
|
|
this.forEachChild(visit);
|
|
|
|
return result;
|
|
|
|
function addDeclaration(declaration: Declaration) {
|
|
const name = getDeclarationName(declaration);
|
|
if (name) {
|
|
result.add(name, declaration);
|
|
}
|
|
}
|
|
|
|
function getDeclarations(name: string) {
|
|
let declarations = result.get(name);
|
|
if (!declarations) {
|
|
result.set(name, declarations = []);
|
|
}
|
|
return declarations;
|
|
}
|
|
|
|
function getDeclarationName(declaration: Declaration) {
|
|
const name = getNonAssignedNameOfDeclaration(declaration);
|
|
if (name) {
|
|
if (isComputedPropertyName(name) && isPropertyAccessExpression(name.expression)) {
|
|
return (name.expression.name as MemberName).text
|
|
}
|
|
if (isPropertyName(name)) {
|
|
return name.kind === SyntaxKind.ComputedPropertyName
|
|
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
|
? isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined
|
|
: isPrivateIdentifier(name) ? idText(name) : getTextOfIdentifierOrLiteral(name);
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
function visit(node: Node): void {
|
|
switch (node.kind) {
|
|
case SyntaxKind.FunctionDeclaration:
|
|
case SyntaxKind.FunctionExpression:
|
|
case SyntaxKind.MethodDeclaration:
|
|
case SyntaxKind.MethodSignature:
|
|
const functionDeclaration = node as FunctionLikeDeclaration;
|
|
const declarationName = getDeclarationName(functionDeclaration);
|
|
|
|
if (declarationName) {
|
|
const declarations = getDeclarations(declarationName);
|
|
const lastDeclaration = lastOrUndefined(declarations);
|
|
|
|
// Check whether this declaration belongs to an "overload group".
|
|
if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) {
|
|
// Overwrite the last declaration if it was an overload
|
|
// and this one is an implementation.
|
|
if (functionDeclaration.body && !(lastDeclaration as FunctionLikeDeclaration).body) {
|
|
declarations[declarations.length - 1] = functionDeclaration;
|
|
}
|
|
}
|
|
else {
|
|
declarations.push(functionDeclaration);
|
|
}
|
|
}
|
|
forEachChild(node, visit);
|
|
break;
|
|
|
|
case SyntaxKind.ClassDeclaration:
|
|
case SyntaxKind.ClassExpression:
|
|
case SyntaxKind.InterfaceDeclaration:
|
|
case SyntaxKind.TypeAliasDeclaration:
|
|
case SyntaxKind.EnumDeclaration:
|
|
case SyntaxKind.ModuleDeclaration:
|
|
case SyntaxKind.ImportEqualsDeclaration:
|
|
case SyntaxKind.ExportSpecifier:
|
|
case SyntaxKind.ImportSpecifier:
|
|
case SyntaxKind.ImportClause:
|
|
case SyntaxKind.NamespaceImport:
|
|
case SyntaxKind.GetAccessor:
|
|
case SyntaxKind.SetAccessor:
|
|
case SyntaxKind.TypeLiteral:
|
|
addDeclaration(node as Declaration);
|
|
forEachChild(node, visit);
|
|
break;
|
|
|
|
case SyntaxKind.Parameter:
|
|
// Only consider parameter properties
|
|
if (!hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
|
|
break;
|
|
}
|
|
// falls through
|
|
|
|
case SyntaxKind.VariableDeclaration:
|
|
case SyntaxKind.BindingElement: {
|
|
const decl = node as VariableDeclaration;
|
|
if (isBindingPattern(decl.name)) {
|
|
forEachChild(decl.name, visit);
|
|
break;
|
|
}
|
|
if (decl.initializer) {
|
|
visit(decl.initializer);
|
|
}
|
|
}
|
|
// falls through
|
|
case SyntaxKind.EnumMember:
|
|
case SyntaxKind.PropertyDeclaration:
|
|
case SyntaxKind.PropertySignature:
|
|
addDeclaration(node as Declaration);
|
|
break;
|
|
|
|
case SyntaxKind.ExportDeclaration:
|
|
// Handle named exports case e.g.:
|
|
// export {a, b as B} from "mod";
|
|
const exportDeclaration = node as ExportDeclaration;
|
|
if (exportDeclaration.exportClause) {
|
|
if (isNamedExports(exportDeclaration.exportClause)) {
|
|
forEach(exportDeclaration.exportClause.elements, visit);
|
|
}
|
|
else {
|
|
visit(exportDeclaration.exportClause.name);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case SyntaxKind.ImportDeclaration:
|
|
const importClause = (node as ImportDeclaration).importClause;
|
|
if (importClause) {
|
|
// Handle default import case e.g.:
|
|
// import d from "mod";
|
|
if (importClause.name) {
|
|
addDeclaration(importClause.name);
|
|
}
|
|
|
|
// Handle named bindings in imports e.g.:
|
|
// import * as NS from "mod";
|
|
// import {a, b as B} from "mod";
|
|
if (importClause.namedBindings) {
|
|
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
|
addDeclaration(importClause.namedBindings);
|
|
}
|
|
else {
|
|
forEach(importClause.namedBindings.elements, visit);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case SyntaxKind.BinaryExpression:
|
|
if (getAssignmentDeclarationKind(node as BinaryExpression) !== AssignmentDeclarationKind.None) {
|
|
addDeclaration(node as BinaryExpression);
|
|
}
|
|
// falls through
|
|
|
|
default:
|
|
forEachChild(node, visit);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/** @internal */
|
|
export type PartialSourceFile<OptionalKeys extends keyof SourceFile = never> =
|
|
& Pick<SourceFile, "fileName">
|
|
& Partial<Pick<SourceFile, OptionalKeys>>;
|
|
|
|
/**
|
|
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
|
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
|
|
* the same values.
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
export interface IScriptSnapshot {
|
|
/** Gets a portion of the script snapshot specified by [start, end). */
|
|
getText(start: number, end: number): string;
|
|
|
|
/** Gets the length of this script snapshot. */
|
|
getLength(): number;
|
|
|
|
/**
|
|
* Gets the TextChangeRange that describe how the text changed between this text and
|
|
* an older version. This information is used by the incremental parser to determine
|
|
* what sections of the script need to be re-parsed. 'undefined' can be returned if the
|
|
* change range cannot be determined. However, in that case, incremental parsing will
|
|
* not happen and the entire document will be re - parsed.
|
|
*/
|
|
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined;
|
|
|
|
/** Releases all resources held by this script snapshot */
|
|
dispose?(): void;
|
|
}
|
|
|
|
export interface ReadonlyPragmaContext {
|
|
readonly languageVersion: ScriptTarget;
|
|
/** @internal */ readonly pragmas?: ReadonlyPragmaMap | undefined;
|
|
/** @internal */ readonly checkJsDirective?: CheckJsDirective | undefined;
|
|
readonly referencedFiles: readonly FileReference[];
|
|
readonly typeReferenceDirectives: readonly FileReference[];
|
|
readonly libReferenceDirectives: readonly FileReference[];
|
|
readonly amdDependencies: readonly AmdDependency[];
|
|
readonly hasNoDefaultLib?: boolean | undefined;
|
|
/** @internal */ readonly moduleName?: string | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PragmaContext extends ReadonlyPragmaContext {
|
|
languageVersion: ScriptTarget;
|
|
pragmas?: PragmaMap;
|
|
checkJsDirective?: CheckJsDirective | undefined;
|
|
referencedFiles: FileReference[];
|
|
typeReferenceDirectives: FileReference[];
|
|
libReferenceDirectives: FileReference[];
|
|
amdDependencies: AmdDependency[];
|
|
hasNoDefaultLib?: boolean | undefined;
|
|
moduleName?: string | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommentDirective {
|
|
range: TextRange;
|
|
type: CommentDirectiveType;
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum CommentDirectiveType {
|
|
ExpectError,
|
|
Ignore,
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class Bundle extends Node<SyntaxKind.Bundle, AstBundleData> {
|
|
// declare readonly ast: AstBundle;
|
|
|
|
get sourceFiles(): readonly SourceFile[] { return this.ast.data.sourceFiles; }
|
|
|
|
/** @internal */ set sourceFiles(value: readonly SourceFile[]) { this.ast.data.sourceFiles = value; }
|
|
/** @internal */ get syntheticFileReferences(): readonly FileReference[] | undefined { return this.ast.data.syntheticFileReferences; }
|
|
/** @internal */ set syntheticFileReferences(value: readonly FileReference[] | undefined) { this.ast.data.syntheticFileReferences = value; }
|
|
/** @internal */ get syntheticTypeReferences(): readonly FileReference[] | undefined { return this.ast.data.syntheticTypeReferences; }
|
|
/** @internal */ set syntheticTypeReferences(value: readonly FileReference[] | undefined) { this.ast.data.syntheticTypeReferences = value; }
|
|
/** @internal */ get syntheticLibReferences(): readonly FileReference[] | undefined { return this.ast.data.syntheticLibReferences; }
|
|
/** @internal */ set syntheticLibReferences(value: readonly FileReference[] | undefined) { this.ast.data.syntheticLibReferences = value; }
|
|
/** @internal */ get hasNoDefaultLib(): boolean | undefined { return this.ast.data.hasNoDefaultLib; }
|
|
/** @internal */ set hasNoDefaultLib(value: boolean | undefined) { this.ast.data.hasNoDefaultLib = value; }
|
|
}
|
|
|
|
export interface JsonSourceFile extends SourceFile {
|
|
// readonly ast: AstJsonSourceFile;
|
|
readonly data: AstJsonSourceFileData;
|
|
readonly statements: NodeArray<JsonObjectExpressionStatement>;
|
|
}
|
|
|
|
export interface TsConfigSourceFile extends JsonSourceFile {
|
|
extendedSourceFiles: string[] | undefined;
|
|
/** @internal */ configFileSpecs: ConfigFileSpecs | undefined;
|
|
}
|
|
|
|
export interface JsonMinusNumericLiteral extends PrefixUnaryExpression {
|
|
// readonly ast: AstJsonMinusNumericLiteral;
|
|
readonly data: AstJsonMinusNumericLiteralData;
|
|
readonly operator: SyntaxKind.MinusToken;
|
|
readonly operand: NumericLiteral;
|
|
}
|
|
|
|
export type JsonObjectExpression =
|
|
| ObjectLiteralExpression
|
|
| ArrayLiteralExpression
|
|
| JsonMinusNumericLiteral
|
|
| NumericLiteral
|
|
| StringLiteral
|
|
| BooleanLiteral
|
|
| NullLiteral;
|
|
|
|
export interface JsonObjectExpressionStatement extends ExpressionStatement {
|
|
// readonly ast: AstJsonObjectExpressionStatement;
|
|
readonly data: AstJsonObjectExpressionStatementData;
|
|
readonly expression: JsonObjectExpression;
|
|
}
|
|
|
|
export interface ScriptReferenceHost {
|
|
getCompilerOptions(): CompilerOptions;
|
|
getSourceFile(fileName: string): SourceFile | undefined;
|
|
getSourceFileByPath(path: Path): SourceFile | undefined;
|
|
getCurrentDirectory(): string;
|
|
}
|
|
|
|
export interface ParseConfigHost extends ModuleResolutionHost {
|
|
useCaseSensitiveFileNames: boolean;
|
|
|
|
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[];
|
|
|
|
/**
|
|
* Gets a value indicating whether the specified path exists and is a file.
|
|
* @param path The path to test.
|
|
*/
|
|
fileExists(path: string): boolean;
|
|
|
|
readFile(path: string): string | undefined;
|
|
trace?(s: string): void;
|
|
}
|
|
|
|
/**
|
|
* Branded string for keeping track of when we've turned an ambiguous path
|
|
* specified like "./blah" to an absolute path to an actual
|
|
* tsconfig file, e.g. "/root/blah/tsconfig.json"
|
|
*/
|
|
export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; };
|
|
|
|
export interface WriteFileCallbackData {
|
|
/** @internal */ sourceMapUrlPos?: number;
|
|
/** @internal */ buildInfo?: BuildInfo;
|
|
/** @internal */ diagnostics?: readonly DiagnosticWithLocation[];
|
|
/** @internal */ differsOnlyInMap?: true;
|
|
/** @internal */ skippedDtsWrite?: true;
|
|
}
|
|
export type WriteFileCallback = (
|
|
fileName: string,
|
|
text: string,
|
|
writeByteOrderMark: boolean,
|
|
onError?: (message: string) => void,
|
|
sourceFiles?: readonly SourceFile[],
|
|
data?: WriteFileCallbackData,
|
|
) => void;
|
|
|
|
export class OperationCanceledException {}
|
|
|
|
export interface CancellationToken {
|
|
isCancellationRequested(): boolean;
|
|
|
|
/** @throws OperationCanceledException if isCancellationRequested is true */
|
|
throwIfCancellationRequested(): void;
|
|
}
|
|
|
|
/** @internal */
|
|
export enum FileIncludeKind {
|
|
RootFile,
|
|
SourceFromProjectReference,
|
|
OutputFromProjectReference,
|
|
Import,
|
|
ReferenceFile,
|
|
TypeReferenceDirective,
|
|
LibFile,
|
|
LibReferenceDirective,
|
|
AutomaticTypeDirectiveFile,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface RootFile {
|
|
kind: FileIncludeKind.RootFile;
|
|
index: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface LibFile {
|
|
kind: FileIncludeKind.LibFile;
|
|
index?: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export type ProjectReferenceFileKind =
|
|
| FileIncludeKind.SourceFromProjectReference
|
|
| FileIncludeKind.OutputFromProjectReference;
|
|
|
|
/** @internal */
|
|
export interface ProjectReferenceFile {
|
|
kind: ProjectReferenceFileKind;
|
|
index: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export type ReferencedFileKind =
|
|
| FileIncludeKind.Import
|
|
| FileIncludeKind.ReferenceFile
|
|
| FileIncludeKind.TypeReferenceDirective
|
|
| FileIncludeKind.LibReferenceDirective;
|
|
|
|
/** @internal */
|
|
export interface ReferencedFile {
|
|
kind: ReferencedFileKind;
|
|
file: Path;
|
|
index: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface AutomaticTypeDirectiveFile {
|
|
kind: FileIncludeKind.AutomaticTypeDirectiveFile;
|
|
typeReference: string;
|
|
packageId: PackageId | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export type FileIncludeReason =
|
|
| RootFile
|
|
| LibFile
|
|
| ProjectReferenceFile
|
|
| ReferencedFile
|
|
| AutomaticTypeDirectiveFile;
|
|
|
|
/** @internal */
|
|
export const enum FilePreprocessingDiagnosticsKind {
|
|
FilePreprocessingLibReferenceDiagnostic,
|
|
FilePreprocessingFileExplainingDiagnostic,
|
|
ResolutionDiagnostics,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FilePreprocessingLibReferenceDiagnostic {
|
|
kind: FilePreprocessingDiagnosticsKind.FilePreprocessingLibReferenceDiagnostic;
|
|
reason: ReferencedFile & { kind: FileIncludeKind.LibReferenceDirective; };
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FilePreprocessingFileExplainingDiagnostic {
|
|
kind: FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic;
|
|
file: Path | undefined;
|
|
fileProcessingReason: FileIncludeReason;
|
|
diagnostic: DiagnosticMessage;
|
|
args: DiagnosticArguments;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ResolutionDiagnostics {
|
|
kind: FilePreprocessingDiagnosticsKind.ResolutionDiagnostics;
|
|
diagnostics: readonly Diagnostic[];
|
|
}
|
|
|
|
/** @internal */
|
|
export type FilePreprocessingDiagnostics = FilePreprocessingLibReferenceDiagnostic | FilePreprocessingFileExplainingDiagnostic | ResolutionDiagnostics;
|
|
|
|
/** @internal */
|
|
export const enum EmitOnly {
|
|
Js,
|
|
Dts,
|
|
BuilderSignature,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface LibResolution<T extends ResolvedModuleWithFailedLookupLocations = ResolvedModuleWithFailedLookupLocations> {
|
|
resolution: T;
|
|
actual: string;
|
|
}
|
|
export interface Program extends ScriptReferenceHost {
|
|
getCurrentDirectory(): string;
|
|
/**
|
|
* Get a list of root file names that were passed to a 'createProgram'
|
|
*/
|
|
getRootFileNames(): readonly string[];
|
|
|
|
/**
|
|
* Get a list of files in the program
|
|
*/
|
|
getSourceFiles(): readonly SourceFile[];
|
|
|
|
/**
|
|
* Get a list of file names that were passed to 'createProgram' or referenced in a
|
|
* program source file but could not be located.
|
|
*
|
|
* @internal
|
|
*/
|
|
getMissingFilePaths(): Map<Path, string>;
|
|
/** @internal */
|
|
getModuleResolutionCache(): ModuleResolutionCache | undefined;
|
|
/** @internal */
|
|
getFilesByNameMap(): Map<Path, SourceFile | false | undefined>;
|
|
|
|
/** @internal */
|
|
resolvedModules: Map<Path, ModeAwareCache<ResolvedModuleWithFailedLookupLocations>> | undefined;
|
|
/** @internal */
|
|
resolvedTypeReferenceDirectiveNames: Map<Path, ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>> | undefined;
|
|
/** @internal */
|
|
getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined;
|
|
/** @internal */
|
|
getResolvedModuleFromModuleSpecifier(moduleSpecifier: StringLiteralLike, sourceFile?: SourceFile): ResolvedModuleWithFailedLookupLocations | undefined;
|
|
/** @internal */
|
|
getResolvedTypeReferenceDirective(f: SourceFile, typeDirectiveName: string, mode: ResolutionMode): ResolvedTypeReferenceDirectiveWithFailedLookupLocations | undefined;
|
|
/** @internal */
|
|
getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typedRef: FileReference, sourceFile: SourceFile): ResolvedTypeReferenceDirectiveWithFailedLookupLocations | undefined;
|
|
/** @internal */
|
|
forEachResolvedModule(
|
|
callback: (resolution: ResolvedModuleWithFailedLookupLocations, moduleName: string, mode: ResolutionMode, filePath: Path) => void,
|
|
file?: SourceFile,
|
|
): void;
|
|
/** @internal */
|
|
forEachResolvedTypeReferenceDirective(
|
|
callback: (resolution: ResolvedTypeReferenceDirectiveWithFailedLookupLocations, moduleName: string, mode: ResolutionMode, filePath: Path) => void,
|
|
file?: SourceFile,
|
|
): void;
|
|
|
|
/**
|
|
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
|
* the JavaScript and declaration files will be produced for all the files in this program.
|
|
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
|
* specific file will be generated.
|
|
*
|
|
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
|
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
|
* will be invoked when writing the JavaScript and declaration files.
|
|
*/
|
|
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
|
|
/** @internal */
|
|
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnly?: boolean | EmitOnly, customTransformers?: CustomTransformers, forceDtsEmit?: boolean, skipBuildInfo?: boolean): EmitResult;
|
|
|
|
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
|
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
|
|
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
|
/** The first time this is called, it will return global diagnostics (no location). */
|
|
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
|
/** @internal */
|
|
getSemanticDiagnostics(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken | undefined, nodesToCheck: Node[]): readonly Diagnostic[];
|
|
|
|
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
|
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
|
|
/** @internal */ getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
|
|
|
/** @internal */ getBindAndCheckDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
|
/** @internal */ getProgramDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
|
|
|
|
/**
|
|
* Gets a type checker that can be used to semantically analyze source files in the program.
|
|
*/
|
|
getTypeChecker(): TypeChecker;
|
|
|
|
/** @internal */ getCommonSourceDirectory(): string;
|
|
|
|
/** @internal */ getCachedSemanticDiagnostics(sourceFile: SourceFile): readonly Diagnostic[] | undefined;
|
|
|
|
/** @internal */ getClassifiableNames(): Set<__String>;
|
|
|
|
getNodeCount(): number;
|
|
getIdentifierCount(): number;
|
|
getSymbolCount(): number;
|
|
getTypeCount(): number;
|
|
getInstantiationCount(): number;
|
|
getRelationCacheSizes(): { assignable: number; identity: number; subtype: number; strictSubtype: number; };
|
|
|
|
/** @internal */ getFileProcessingDiagnostics(): FilePreprocessingDiagnostics[] | undefined;
|
|
/** @internal */ getAutomaticTypeDirectiveNames(): string[];
|
|
/** @internal */ getAutomaticTypeDirectiveResolutions(): ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>;
|
|
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
|
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
|
/**
|
|
* Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
|
|
* settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
|
|
* which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
|
|
* overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
|
|
* Some examples:
|
|
*
|
|
* ```ts
|
|
* // tsc foo.mts --module nodenext
|
|
* import {} from "mod";
|
|
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
|
*
|
|
* // tsc foo.cts --module nodenext
|
|
* import {} from "mod";
|
|
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
|
*
|
|
* // tsc foo.ts --module preserve --moduleResolution bundler
|
|
* import {} from "mod";
|
|
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
|
* // supports conditional imports/exports
|
|
*
|
|
* // tsc foo.ts --module preserve --moduleResolution node10
|
|
* import {} from "mod";
|
|
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
|
* // does not support conditional imports/exports
|
|
*
|
|
* // tsc foo.ts --module commonjs --moduleResolution node10
|
|
* import type {} from "mod" with { "resolution-mode": "import" };
|
|
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
|
* ```
|
|
*/
|
|
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
|
/**
|
|
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This function only returns a result
|
|
* when module resolution settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided
|
|
* via import attributes, which cause an `import` or `require` condition to be used during resolution regardless of module resolution
|
|
* settings. In absence of overriding attributes, and in modes that support differing resolution, the result indicates the syntax the
|
|
* usage would emit to JavaScript. Some examples:
|
|
*
|
|
* ```ts
|
|
* // tsc foo.mts --module nodenext
|
|
* import {} from "mod";
|
|
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
|
*
|
|
* // tsc foo.cts --module nodenext
|
|
* import {} from "mod";
|
|
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
|
*
|
|
* // tsc foo.ts --module preserve --moduleResolution bundler
|
|
* import {} from "mod";
|
|
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
|
* // supports conditional imports/exports
|
|
*
|
|
* // tsc foo.ts --module preserve --moduleResolution node10
|
|
* import {} from "mod";
|
|
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
|
* // does not support conditional imports/exports
|
|
*
|
|
* // tsc foo.ts --module commonjs --moduleResolution node10
|
|
* import type {} from "mod" with { "resolution-mode": "import" };
|
|
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
|
* ```
|
|
*/
|
|
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
|
/**
|
|
* @internal
|
|
* The resolution mode to use for module resolution or module specifier resolution
|
|
* outside the context of an existing module reference, where
|
|
* `program.getModeForUsageLocation` should be used instead.
|
|
*/
|
|
getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode;
|
|
/** @internal */ getImpliedNodeFormatForEmit(sourceFile: SourceFile): ResolutionMode;
|
|
/** @internal */ getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind;
|
|
/** @internal */ shouldTransformImportCall(sourceFile: SourceFile): boolean;
|
|
|
|
// For testing purposes only.
|
|
// This is set on created program to let us know how the program was created using old program
|
|
/** @internal */ readonly structureIsReused: StructureIsReused;
|
|
|
|
/** @internal */ getSourceFileFromReference(referencingFile: SourceFile, ref: FileReference): SourceFile | undefined;
|
|
/** @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined;
|
|
|
|
/**
|
|
* Given a source file, get the name of the package it was imported from.
|
|
*
|
|
* @internal
|
|
*/
|
|
sourceFileToPackageName: Map<Path, string>;
|
|
/**
|
|
* Set of all source files that some other source file redirects to.
|
|
*
|
|
* @internal
|
|
*/
|
|
redirectTargetsMap: MultiMap<Path, string>;
|
|
/**
|
|
* Whether any (non-external, non-declaration) source files use `node:`-prefixed module specifiers
|
|
* (except for those that are not available without the prefix).
|
|
* `false` indicates that an unprefixed builtin module was seen; `undefined` indicates that no
|
|
* builtin modules (or only modules exclusively available with the prefix) were seen.
|
|
*
|
|
* @internal
|
|
*/
|
|
readonly usesUriStyleNodeCoreModules: boolean | undefined;
|
|
/**
|
|
* Map from libFileName to actual resolved location of the lib
|
|
* @internal
|
|
*/
|
|
resolvedLibReferences: Map<string, LibResolution> | undefined;
|
|
/** @internal */ getCurrentPackagesMap(): Map<string, boolean> | undefined;
|
|
/**
|
|
* Is the file emitted file
|
|
*
|
|
* @internal
|
|
*/
|
|
isEmittedFile(file: string): boolean;
|
|
/** @internal */ getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>;
|
|
/** @internal */ useCaseSensitiveFileNames(): boolean;
|
|
/** @internal */ getCanonicalFileName: GetCanonicalFileName;
|
|
|
|
getProjectReferences(): readonly ProjectReference[] | undefined;
|
|
getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
|
|
/** @internal */ getProjectReferenceRedirect(fileName: string): string | undefined;
|
|
/**
|
|
* @internal
|
|
* Get the referenced project if the file is input file from that reference project
|
|
*/
|
|
getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined;
|
|
/** @internal */ forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference) => T | undefined): T | undefined;
|
|
/** @internal */ getResolvedProjectReferenceByPath(projectReferencePath: Path): ResolvedProjectReference | undefined;
|
|
/** @internal */ getRedirectReferenceForResolutionFromSourceOfProject(filePath: Path): ResolvedProjectReference | undefined;
|
|
/** @internal */ isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
|
/** @internal */ getCompilerOptionsForFile(file: SourceFile): CompilerOptions;
|
|
/** @internal */ getBuildInfo?(): BuildInfo;
|
|
/** @internal */ emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
|
|
/**
|
|
* This implementation handles file exists to be true if file is source of project reference redirect when program is created using useSourceOfProjectReferenceRedirect
|
|
*
|
|
* @internal
|
|
*/
|
|
fileExists(fileName: string): boolean;
|
|
/**
|
|
* Call compilerHost.writeFile on host program was created with
|
|
*
|
|
* @internal
|
|
*/
|
|
writeFile: WriteFileCallback;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface Program extends TypeCheckerHost, ModuleSpecifierResolutionHost {
|
|
}
|
|
|
|
/** @internal */
|
|
export type RedirectTargetsMap = ReadonlyMap<Path, readonly string[]>;
|
|
|
|
export interface ResolvedProjectReference {
|
|
commandLine: ParsedCommandLine;
|
|
sourceFile: SourceFile;
|
|
references?: readonly (ResolvedProjectReference | undefined)[];
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum StructureIsReused {
|
|
Not,
|
|
SafeModules,
|
|
Completely,
|
|
}
|
|
|
|
export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer;
|
|
|
|
export interface CustomTransformer {
|
|
transformSourceFile(node: SourceFile): SourceFile;
|
|
transformBundle(node: Bundle): Bundle;
|
|
}
|
|
|
|
export interface CustomTransformers {
|
|
/** Custom transformers to evaluate before built-in .js transformations. */
|
|
before?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[];
|
|
/** Custom transformers to evaluate after built-in .js transformations. */
|
|
after?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[];
|
|
/** Custom transformers to evaluate after built-in .d.ts transformations. */
|
|
afterDeclarations?: (TransformerFactory<Bundle | SourceFile> | CustomTransformerFactory)[];
|
|
}
|
|
|
|
/** @internal */
|
|
export interface EmitTransformers {
|
|
scriptTransformers: readonly TransformerFactory<SourceFile | Bundle>[];
|
|
declarationTransformers: readonly TransformerFactory<SourceFile | Bundle>[];
|
|
}
|
|
|
|
export interface SourceMapSpan {
|
|
/** Line number in the .js file. */
|
|
emittedLine: number;
|
|
/** Column number in the .js file. */
|
|
emittedColumn: number;
|
|
/** Line number in the .ts file. */
|
|
sourceLine: number;
|
|
/** Column number in the .ts file. */
|
|
sourceColumn: number;
|
|
/** Optional name (index into names array) associated with this span. */
|
|
nameIndex?: number;
|
|
/** .ts file (index into sources array) associated with this span */
|
|
sourceIndex: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SourceMapEmitResult {
|
|
inputSourceFileNames: readonly string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMap.sources list
|
|
sourceMap: RawSourceMap;
|
|
}
|
|
|
|
/** Return code used by getEmitOutput function to indicate status of the function */
|
|
export enum ExitStatus {
|
|
// Compiler ran successfully. Either this was a simple do-nothing compilation (for example,
|
|
// when -version or -help was provided, or this was a normal compilation, no diagnostics
|
|
// were produced, and all outputs were generated successfully.
|
|
Success = 0,
|
|
|
|
// Diagnostics were produced and because of them no code was generated.
|
|
DiagnosticsPresent_OutputsSkipped = 1,
|
|
|
|
// Diagnostics were produced and outputs were generated in spite of them.
|
|
DiagnosticsPresent_OutputsGenerated = 2,
|
|
|
|
// When build skipped because passed in project is invalid
|
|
InvalidProject_OutputsSkipped = 3,
|
|
|
|
// When build is skipped because project references form cycle
|
|
ProjectReferenceCycle_OutputsSkipped = 4,
|
|
}
|
|
|
|
export interface EmitResult {
|
|
emitSkipped: boolean;
|
|
/** Contains declaration emit diagnostics */
|
|
diagnostics: readonly Diagnostic[];
|
|
emittedFiles?: string[]; // Array of files the compiler wrote to disk
|
|
/** @internal */ sourceMaps?: SourceMapEmitResult[]; // Array of sourceMapData if compiler emitted sourcemaps
|
|
}
|
|
|
|
/** @internal */
|
|
export interface TypeCheckerHost extends ModuleSpecifierResolutionHost {
|
|
getCompilerOptions(): CompilerOptions;
|
|
|
|
getSourceFiles(): readonly SourceFile[];
|
|
getSourceFile(fileName: string): SourceFile | undefined;
|
|
getProjectReferenceRedirect(fileName: string): string | undefined;
|
|
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
|
getEmitSyntaxForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
|
getRedirectReferenceForResolutionFromSourceOfProject(filePath: Path): ResolvedProjectReference | undefined;
|
|
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
|
getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode;
|
|
getImpliedNodeFormatForEmit(sourceFile: SourceFile): ResolutionMode;
|
|
getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind;
|
|
|
|
getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined;
|
|
|
|
readonly redirectTargetsMap: RedirectTargetsMap;
|
|
|
|
typesPackageExists(packageName: string): boolean;
|
|
packageBundlesTypes(packageName: string): boolean;
|
|
}
|
|
|
|
export interface TypeChecker {
|
|
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
|
getTypeOfSymbol(symbol: Symbol): Type;
|
|
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
|
getPropertiesOfType(type: Type): Symbol[];
|
|
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
|
|
getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined;
|
|
/** @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
|
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
|
getIndexInfosOfType(type: Type): readonly IndexInfo[];
|
|
getIndexInfosOfIndexSymbol: (indexSymbol: Symbol) => IndexInfo[];
|
|
getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
|
|
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
|
|
/** @internal */ getIndexType(type: Type): Type;
|
|
getBaseTypes(type: InterfaceType): BaseType[];
|
|
getBaseTypeOfLiteralType(type: Type): Type;
|
|
getWidenedType(type: Type): Type;
|
|
/** @internal */
|
|
getWidenedLiteralType(type: Type): Type;
|
|
/** @internal */
|
|
getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type | undefined;
|
|
/**
|
|
* Gets the "awaited type" of a type.
|
|
*
|
|
* If an expression has a Promise-like type, the "awaited type" of the expression is
|
|
* derived from the type of the first argument of the fulfillment callback for that
|
|
* Promise's `then` method. If the "awaited type" is itself a Promise-like, it is
|
|
* recursively unwrapped in the same manner until a non-promise type is found.
|
|
*
|
|
* If an expression does not have a Promise-like type, its "awaited type" is the type
|
|
* of the expression.
|
|
*
|
|
* If the resulting "awaited type" is a generic object type, then it is wrapped in
|
|
* an `Awaited<T>`.
|
|
*
|
|
* In the event the "awaited type" circularly references itself, or is a non-Promise
|
|
* object-type with a callable `then()` method, an "awaited type" cannot be determined
|
|
* and the value `undefined` will be returned.
|
|
*
|
|
* This is used to reflect the runtime behavior of the `await` keyword.
|
|
*/
|
|
getAwaitedType(type: Type): Type | undefined;
|
|
/** @internal */
|
|
isEmptyAnonymousObjectType(type: Type): boolean;
|
|
getReturnTypeOfSignature(signature: Signature): Type;
|
|
/**
|
|
* Gets the type of a parameter at a given position in a signature.
|
|
* Returns `any` if the index is not valid.
|
|
*
|
|
* @internal
|
|
*/
|
|
getParameterType(signature: Signature, parameterIndex: number): Type;
|
|
/** @internal */ getParameterIdentifierInfoAtPosition(signature: Signature, parameterIndex: number): { parameter: Identifier; parameterName: __String; isRestParameter: boolean; } | undefined;
|
|
getNullableType(type: Type, flags: TypeFlags): Type;
|
|
getNonNullableType(type: Type): Type;
|
|
/** @internal */ getNonOptionalType(type: Type): Type;
|
|
/** @internal */ isNullableType(type: Type): boolean;
|
|
getTypeArguments(type: TypeReference): readonly Type[];
|
|
|
|
// TODO: GH#18217 `xToDeclaration` calls are frequently asserted as defined.
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined;
|
|
/** @internal */ typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
/** @internal */ typePredicateToTypePredicateNode(typePredicate: TypePredicate, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): TypePredicateNode | undefined;
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined;
|
|
/** @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined;
|
|
/** @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined;
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Expression | undefined;
|
|
/**
|
|
* Note that the resulting nodes cannot be checked.
|
|
*
|
|
* @internal
|
|
*/
|
|
symbolToNode(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags: InternalNodeBuilderFlags | undefined): Node | undefined;
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray<TypeParameterDeclaration> | undefined;
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined;
|
|
/** Note that the resulting nodes cannot be checked. */
|
|
typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined;
|
|
|
|
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
|
getSymbolAtLocation(node: Node): Symbol | undefined;
|
|
/** @internal */ getIndexInfosAtLocation(node: Node): readonly IndexInfo[] | undefined;
|
|
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
|
/**
|
|
* The function returns the value (local variable) symbol of an identifier in the short-hand property assignment.
|
|
* This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value.
|
|
*/
|
|
getShorthandAssignmentValueSymbol(location: Node | undefined): Symbol | undefined;
|
|
|
|
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined;
|
|
/**
|
|
* If a symbol is a local symbol with an associated exported symbol, returns the exported symbol.
|
|
* Otherwise returns its input.
|
|
* For example, at `export type T = number;`:
|
|
* - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`.
|
|
* - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol.
|
|
* - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol.
|
|
*/
|
|
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
|
|
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
|
|
getTypeOfAssignmentPattern(pattern: AssignmentPattern): Type;
|
|
getTypeAtLocation(node: Node): Type;
|
|
getTypeFromTypeNode(node: TypeNode): Type;
|
|
|
|
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
|
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
|
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string;
|
|
typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
|
|
|
/** @internal */ writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter): string;
|
|
/** @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string;
|
|
/** @internal */ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string;
|
|
/** @internal */ writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string;
|
|
|
|
getFullyQualifiedName(symbol: Symbol): string;
|
|
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
|
|
|
getRootSymbols(symbol: Symbol): readonly Symbol[];
|
|
getSymbolOfExpando(node: Node, allowDeclaration: boolean): Symbol | undefined;
|
|
getContextualType(node: Expression): Type | undefined;
|
|
/** @internal */ getContextualType(node: Expression, contextFlags?: ContextFlags): Type | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
/** @internal */ getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike): Type | undefined;
|
|
/** @internal */ getContextualTypeForArgumentAtIndex(call: CallLikeExpression, argIndex: number): Type | undefined;
|
|
/** @internal */ getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute): Type | undefined;
|
|
/** @internal */ isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike): boolean;
|
|
/** @internal */ getTypeOfPropertyOfContextualType(type: Type, name: __String): Type | undefined;
|
|
|
|
/**
|
|
* returns unknownSignature in the case of an error.
|
|
* returns undefined if the node is not valid.
|
|
* @param argumentCount Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`.
|
|
*/
|
|
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
|
|
/** @internal */ getResolvedSignatureForSignatureHelp(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined;
|
|
/** @internal */ getCandidateSignaturesForStringLiteralCompletions(call: CallLikeExpression, editingArgument: Node): Signature[];
|
|
/** @internal */ getExpandedParameters(sig: Signature): readonly (readonly Symbol[])[];
|
|
/** @internal */ hasEffectiveRestParameter(sig: Signature): boolean;
|
|
/** @internal */ containsArgumentsReference(declaration: SignatureDeclaration): boolean;
|
|
|
|
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
|
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
|
isUndefinedSymbol(symbol: Symbol): boolean;
|
|
isArgumentsSymbol(symbol: Symbol): boolean;
|
|
isUnknownSymbol(symbol: Symbol): boolean;
|
|
getMergedSymbol(symbol: Symbol): Symbol;
|
|
/** @internal */ symbolIsValue(symbol: Symbol, includeTypeOnlyMembers?: boolean): boolean;
|
|
|
|
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
|
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName | ImportTypeNode, propertyName: string): boolean;
|
|
/**
|
|
* Exclude accesses to private properties.
|
|
*
|
|
* @internal
|
|
*/
|
|
isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean;
|
|
/** Follow all aliases to get the original symbol. */
|
|
getAliasedSymbol(symbol: Symbol): Symbol;
|
|
/** Follow a *single* alias to get the immediately aliased symbol. */
|
|
getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined;
|
|
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
|
/**
|
|
* Unlike `getExportsOfModule`, this includes properties of an `export =` value.
|
|
*
|
|
* @internal
|
|
*/
|
|
getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
|
|
/** @internal */ forEachExportAndPropertyOfModule(moduleSymbol: Symbol, cb: (symbol: Symbol, key: __String) => void): void;
|
|
getJsxIntrinsicTagNamesAt(location: Node): Symbol[];
|
|
isOptionalParameter(node: ParameterDeclaration): boolean;
|
|
getAmbientModules(): Symbol[];
|
|
|
|
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
|
/**
|
|
* Unlike `tryGetMemberInModuleExports`, this includes properties of an `export =` value.
|
|
* Does *not* return properties of primitive types.
|
|
*
|
|
* @internal
|
|
*/
|
|
tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
|
getApparentType(type: Type): Type;
|
|
/** @internal */ getSuggestedSymbolForNonexistentProperty(name: MemberName | string, containingType: Type): Symbol | undefined;
|
|
/** @internal */ getSuggestedSymbolForNonexistentJSXAttribute(name: Identifier | string, containingType: Type): Symbol | undefined;
|
|
/** @internal */ getSuggestedSymbolForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined;
|
|
/** @internal */ getSuggestedSymbolForNonexistentModule(node: Identifier, target: Symbol): Symbol | undefined;
|
|
/** @internal */ getSuggestedSymbolForNonexistentClassMember(name: string, baseType: Type): Symbol | undefined;
|
|
getBaseConstraintOfType(type: Type): Type | undefined;
|
|
getDefaultFromTypeParameter(type: Type): Type | undefined;
|
|
|
|
/**
|
|
* Gets the intrinsic `any` type. There are multiple types that act as `any` used internally in the compiler,
|
|
* so the type returned by this function should not be used in equality checks to determine if another type
|
|
* is `any`. Instead, use `type.flags & TypeFlags.Any`.
|
|
*/
|
|
getAnyType(): Type;
|
|
getStringType(): Type;
|
|
getStringLiteralType(value: string): StringLiteralType;
|
|
getNumberType(): Type;
|
|
getNumberLiteralType(value: number): NumberLiteralType;
|
|
getBigIntType(): Type;
|
|
getBigIntLiteralType(value: PseudoBigInt): BigIntLiteralType;
|
|
getBooleanType(): Type;
|
|
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
/** @internal */
|
|
getFalseType(fresh?: boolean): Type;
|
|
getFalseType(): Type;
|
|
/** @internal */
|
|
getTrueType(fresh?: boolean): Type;
|
|
getTrueType(): Type;
|
|
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
getVoidType(): Type;
|
|
/**
|
|
* Gets the intrinsic `undefined` type. There are multiple types that act as `undefined` used internally in the compiler
|
|
* depending on compiler options, so the type returned by this function should not be used in equality checks to determine
|
|
* if another type is `undefined`. Instead, use `type.flags & TypeFlags.Undefined`.
|
|
*/
|
|
getUndefinedType(): Type;
|
|
/**
|
|
* Gets the intrinsic `null` type. There are multiple types that act as `null` used internally in the compiler,
|
|
* so the type returned by this function should not be used in equality checks to determine if another type
|
|
* is `null`. Instead, use `type.flags & TypeFlags.Null`.
|
|
*/
|
|
getNullType(): Type;
|
|
getESSymbolType(): Type;
|
|
/**
|
|
* Gets the intrinsic `never` type. There are multiple types that act as `never` used internally in the compiler,
|
|
* so the type returned by this function should not be used in equality checks to determine if another type
|
|
* is `never`. Instead, use `type.flags & TypeFlags.Never`.
|
|
*/
|
|
getNeverType(): Type;
|
|
/** @internal */ getOptionalType(): Type;
|
|
/** @internal */ getUnionType(types: Type[], subtypeReduction?: UnionReduction): Type;
|
|
/** @internal */ createArrayType(elementType: Type): Type;
|
|
/** @internal */ getElementTypeOfArrayType(arrayType: Type): Type | undefined;
|
|
/** @internal */ createPromiseType(type: Type): Type;
|
|
/** @internal */ getPromiseType(): Type;
|
|
/** @internal */ getPromiseLikeType(): Type;
|
|
/** @internal */ getAnyAsyncIterableType(): Type | undefined;
|
|
|
|
/**
|
|
* Returns true if the "source" type is assignable to the "target" type.
|
|
*
|
|
* ```ts
|
|
* declare const abcLiteral: ts.Type; // Type of "abc"
|
|
* declare const stringType: ts.Type; // Type of string
|
|
*
|
|
* isTypeAssignableTo(abcLiteral, abcLiteral); // true; "abc" is assignable to "abc"
|
|
* isTypeAssignableTo(abcLiteral, stringType); // true; "abc" is assignable to string
|
|
* isTypeAssignableTo(stringType, abcLiteral); // false; string is not assignable to "abc"
|
|
* isTypeAssignableTo(stringType, stringType); // true; string is assignable to string
|
|
* ```
|
|
*/
|
|
isTypeAssignableTo(source: Type, target: Type): boolean;
|
|
/** @internal */ createAnonymousType(symbol: Symbol | undefined, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], indexInfos: IndexInfo[]): Type;
|
|
/** @internal */ createSignature(
|
|
declaration: SignatureDeclaration | undefined,
|
|
typeParameters: readonly TypeParameter[] | undefined,
|
|
thisParameter: Symbol | undefined,
|
|
parameters: readonly Symbol[],
|
|
resolvedReturnType: Type,
|
|
typePredicate: TypePredicate | undefined,
|
|
minArgumentCount: number,
|
|
flags: SignatureFlags,
|
|
): Signature;
|
|
/** @internal */ createSymbol(flags: SymbolFlags, name: __String): TransientSymbol;
|
|
/** @internal */ createIndexInfo(keyType: Type, type: Type, isReadonly: boolean, declaration?: SignatureDeclaration): IndexInfo;
|
|
/** @internal */ isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
|
/** @internal */ tryFindAmbientModule(moduleName: string): Symbol | undefined;
|
|
|
|
/** @internal */ getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker;
|
|
|
|
// Should not be called directly. Should only be accessed through the Program instance.
|
|
/** @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken, nodesToCheck?: Node[]): Diagnostic[];
|
|
/** @internal */ getGlobalDiagnostics(): Diagnostic[];
|
|
/** @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken, forceDts?: boolean): EmitResolver;
|
|
/** @internal */ requiresAddingImplicitUndefined(parameter: ParameterDeclaration | JSDocParameterTag, enclosingDeclaration: Node | undefined): boolean;
|
|
|
|
/** @internal */ getNodeCount(): number;
|
|
/** @internal */ getIdentifierCount(): number;
|
|
/** @internal */ getSymbolCount(): number;
|
|
/** @internal */ getTypeCount(): number;
|
|
/** @internal */ getInstantiationCount(): number;
|
|
/** @internal */ getRelationCacheSizes(): { assignable: number; identity: number; subtype: number; strictSubtype: number; };
|
|
/** @internal */ getRecursionIdentity(type: Type): object | undefined;
|
|
/** @internal */ getUnmatchedProperties(source: Type, target: Type, requireOptionalProperties: boolean, matchDiscriminantProperties: boolean): IterableIterator<Symbol>;
|
|
|
|
/**
|
|
* True if this type is the `Array` or `ReadonlyArray` type from lib.d.ts.
|
|
* This function will _not_ return true if passed a type which
|
|
* extends `Array` (for example, the TypeScript AST's `NodeArray` type).
|
|
*/
|
|
isArrayType(type: Type): boolean;
|
|
/**
|
|
* True if this type is a tuple type. This function will _not_ return true if
|
|
* passed a type which extends from a tuple.
|
|
*/
|
|
isTupleType(type: Type): boolean;
|
|
/**
|
|
* True if this type is assignable to `ReadonlyArray<any>`.
|
|
*/
|
|
isArrayLikeType(type: Type): boolean;
|
|
|
|
/**
|
|
* True if `contextualType` should not be considered for completions because
|
|
* e.g. it specifies `kind: "a"` and obj has `kind: "b"`.
|
|
*
|
|
* @internal
|
|
*/
|
|
isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean;
|
|
/** @internal */ getExactOptionalProperties(type: Type): Symbol[];
|
|
/**
|
|
* For a union, will include a property if it's defined in *any* of the member types.
|
|
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
|
* Does not include properties of primitive types.
|
|
*
|
|
* @internal
|
|
*/
|
|
getAllPossiblePropertiesOfTypes(type: readonly Type[]): Symbol[];
|
|
resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
|
|
/** @internal */ getJsxNamespace(location?: Node): string;
|
|
/** @internal */ getJsxFragmentFactory(location: Node): string | undefined;
|
|
|
|
/**
|
|
* Note that this will return undefined in the following case:
|
|
* // a.ts
|
|
* export namespace N { export class C { } }
|
|
* // b.ts
|
|
* <<enclosingDeclaration>>
|
|
* Where `C` is the symbol we're looking for.
|
|
* This should be called in a loop climbing parents of the symbol, so we'll get `N`.
|
|
*
|
|
* @internal
|
|
*/
|
|
getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined;
|
|
getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
|
|
/** @internal */ resolveExternalModuleName(moduleSpecifier: Expression): Symbol | undefined;
|
|
/**
|
|
* An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
|
|
* and an external module with no 'export =' declaration resolves to the module itself.
|
|
*
|
|
* @internal
|
|
*/
|
|
resolveExternalModuleSymbol(symbol: Symbol): Symbol;
|
|
/**
|
|
* @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression.
|
|
*
|
|
* @internal
|
|
*/
|
|
tryGetThisTypeAt(node: Node, includeGlobalThis?: boolean, container?: ThisContainer): Type | undefined;
|
|
/** @internal */ getTypeArgumentConstraint(node: TypeNode): Type | undefined;
|
|
|
|
/**
|
|
* Does *not* get *all* suggestion diagnostics, just the ones that were convenient to report in the checker.
|
|
* Others are added in computeSuggestionDiagnostics.
|
|
*
|
|
* @internal
|
|
*/
|
|
getSuggestionDiagnostics(file: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
|
|
|
|
/**
|
|
* Depending on the operation performed, it may be appropriate to throw away the checker
|
|
* if the cancellation token is triggered. Typically, if it is used for error checking
|
|
* and the operation is cancelled, then it should be discarded, otherwise it is safe to keep.
|
|
*/
|
|
runWithCancellationToken<T>(token: CancellationToken, cb: (checker: TypeChecker) => T): T;
|
|
/**@internal */
|
|
runWithCancellationToken<T>(token: CancellationToken | undefined, cb: (checker: TypeChecker) => T): T; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
|
|
/** @internal */ getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): readonly TypeParameter[] | undefined;
|
|
/** @internal */ isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean;
|
|
/** @internal */ isPropertyAccessible(node: Node, isSuper: boolean, isWrite: boolean, containingType: Type, property: Symbol): boolean;
|
|
/** @internal */ getTypeOnlyAliasDeclaration(symbol: Symbol): TypeOnlyAliasDeclaration | undefined;
|
|
/** @internal */ getMemberOverrideModifierStatus(node: ClassLikeDeclaration, member: ClassElement, memberSymbol: Symbol): MemberOverrideStatus;
|
|
/** @internal */ isTypeParameterPossiblyReferenced(tp: TypeParameter, node: Node): boolean;
|
|
/** @internal */ typeHasCallOrConstructSignatures(type: Type): boolean;
|
|
/** @internal */ getSymbolFlags(symbol: Symbol): SymbolFlags;
|
|
/** @internal */ fillMissingTypeArguments(typeArguments: readonly Type[], typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[];
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum MemberOverrideStatus {
|
|
Ok,
|
|
NeedsOverride,
|
|
HasInvalidOverride,
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum UnionReduction {
|
|
None = 0,
|
|
Literal,
|
|
Subtype,
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum IntersectionFlags {
|
|
None = 0,
|
|
NoSupertypeReduction = 1 << 0,
|
|
NoConstraintReduction = 1 << 1,
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum ContextFlags {
|
|
None = 0,
|
|
Signature = 1 << 0, // Obtaining contextual signature
|
|
NoConstraints = 1 << 1, // Don't obtain type variable constraints
|
|
Completions = 1 << 2, // Ignore inference to current node and parent nodes out to the containing call for completions
|
|
SkipBindingPatterns = 1 << 3, // Ignore contextual types applied by binding patterns
|
|
}
|
|
|
|
// NOTE: If modifying this enum, must modify `TypeFormatFlags` too!
|
|
// dprint-ignore
|
|
export const enum NodeBuilderFlags {
|
|
None = 0,
|
|
// Options
|
|
NoTruncation = 1 << 0, // Don't truncate result
|
|
WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[]
|
|
GenerateNamesForShadowedTypeParams = 1 << 2, // When a type parameter T is shadowing another T, generate a name for it so it can still be referenced
|
|
UseStructuralFallback = 1 << 3, // When an alias cannot be named by its symbol, rather than report an error, fallback to a structural printout if possible
|
|
ForbidIndexedAccessSymbolReferences = 1 << 4, // Forbid references like `I["a"]["b"]` - print `typeof I.a<x>.b<y>` instead
|
|
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature
|
|
UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
|
UseOnlyExternalAliasing = 1 << 7, // Only use external aliases for a symbol
|
|
SuppressAnyReturnType = 1 << 8, // If the return type is any-like and can be elided, don't offer a return type.
|
|
WriteTypeParametersInQualifiedName = 1 << 9,
|
|
MultilineObjectLiterals = 1 << 10, // Always write object literals across multiple lines
|
|
WriteClassExpressionAsTypeLiteral = 1 << 11, // Write class {} as { new(): {} } - used for mixin declaration emit
|
|
UseTypeOfFunction = 1 << 12, // Build using typeof instead of function type literal
|
|
OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters
|
|
UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases
|
|
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
|
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
|
OmitThisParameter = 1 << 25,
|
|
|
|
// Error handling
|
|
AllowThisInObjectLiteral = 1 << 15,
|
|
AllowQualifiedNameInPlaceOfIdentifier = 1 << 16,
|
|
AllowAnonymousIdentifier = 1 << 17,
|
|
AllowEmptyUnionOrIntersection = 1 << 18,
|
|
AllowEmptyTuple = 1 << 19,
|
|
AllowUniqueESSymbolType = 1 << 20,
|
|
AllowEmptyIndexInfoType = 1 << 21,
|
|
// Errors (cont.)
|
|
AllowNodeModulesRelativePaths = 1 << 26,
|
|
|
|
|
|
IgnoreErrors = AllowThisInObjectLiteral | AllowQualifiedNameInPlaceOfIdentifier | AllowAnonymousIdentifier | AllowEmptyUnionOrIntersection | AllowEmptyTuple | AllowEmptyIndexInfoType | AllowNodeModulesRelativePaths,
|
|
|
|
// State
|
|
InObjectTypeLiteral = 1 << 22,
|
|
InTypeAlias = 1 << 23, // Writing type in type alias declaration
|
|
InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression
|
|
}
|
|
|
|
/** @internal */
|
|
// dprint-ignore
|
|
export const enum InternalNodeBuilderFlags {
|
|
None = 0,
|
|
WriteComputedProps = 1 << 0, // { [E.A]: 1 }
|
|
NoSyntacticPrinter = 1 << 1,
|
|
DoNotIncludeSymbolChain = 1 << 2, // Skip looking up and printing an accessible symbol chain
|
|
AllowUnresolvedNames = 1 << 3,
|
|
}
|
|
|
|
// Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment
|
|
// dprint-ignore
|
|
export const enum TypeFormatFlags {
|
|
None = 0,
|
|
NoTruncation = 1 << 0, // Don't truncate typeToString result
|
|
WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[]
|
|
GenerateNamesForShadowedTypeParams = 1 << 2, // When a type parameter T is shadowing another T, generate a name for it so it can still be referenced
|
|
UseStructuralFallback = 1 << 3, // When an alias cannot be named by its symbol, rather than report an error, fallback to a structural printout if possible
|
|
// hole because there's a hole in node builder flags
|
|
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature
|
|
UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
|
// hole because `UseOnlyExternalAliasing` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` instead
|
|
SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type.
|
|
// hole because `WriteTypeParametersInQualifiedName` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` for this instead
|
|
MultilineObjectLiterals = 1 << 10, // Always print object literals across multiple lines (only used to map into node builder flags)
|
|
WriteClassExpressionAsTypeLiteral = 1 << 11, // Write a type literal instead of (Anonymous class)
|
|
UseTypeOfFunction = 1 << 12, // Write typeof instead of function type literal
|
|
OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters
|
|
|
|
UseAliasDefinedOutsideCurrentScope = 1 << 14, // For a `type T = ... ` defined in a different file, write `T` instead of its value, even though `T` can't be accessed in the current scope.
|
|
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
|
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
|
OmitThisParameter = 1 << 25,
|
|
|
|
// Error Handling
|
|
AllowUniqueESSymbolType = 1 << 20, // This is bit 20 to align with the same bit in `NodeBuilderFlags`
|
|
|
|
// TypeFormatFlags exclusive
|
|
AddUndefined = 1 << 17, // Add undefined to types of initialized, non-optional parameters
|
|
WriteArrowStyleSignature = 1 << 18, // Write arrow style signature
|
|
|
|
// State
|
|
InArrayType = 1 << 19, // Writing an array element type
|
|
InElementType = 1 << 21, // Writing an array or union element type
|
|
InFirstTypeArgument = 1 << 22, // Writing first type argument of the instantiated type
|
|
InTypeAlias = 1 << 23, // Writing type in type alias declaration
|
|
|
|
NodeBuilderFlagsMask = NoTruncation | WriteArrayAsGenericType | GenerateNamesForShadowedTypeParams | UseStructuralFallback | WriteTypeArgumentsOfSignature |
|
|
UseFullyQualifiedType | SuppressAnyReturnType | MultilineObjectLiterals | WriteClassExpressionAsTypeLiteral |
|
|
UseTypeOfFunction | OmitParameterModifiers | UseAliasDefinedOutsideCurrentScope | AllowUniqueESSymbolType | InTypeAlias |
|
|
UseSingleQuotesForStringLiteralType | NoTypeReduction | OmitThisParameter,
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum SymbolFormatFlags {
|
|
None = 0,
|
|
|
|
// Write symbols's type argument if it is instantiated symbol
|
|
// eg. class C<T> { p: T } <-- Show p as C<T>.p here
|
|
// var a: C<number>;
|
|
// var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p
|
|
WriteTypeParametersOrArguments = 1 << 0,
|
|
|
|
// Use only external alias information to get the symbol name in the given context
|
|
// eg. module m { export class c { } } import x = m.c;
|
|
// When this flag is specified m.c will be used to refer to the class instead of alias symbol x
|
|
UseOnlyExternalAliasing = 1 << 1,
|
|
|
|
// Build symbol name using any nodes needed, instead of just components of an entity name
|
|
AllowAnyNodeKind = 1 << 2,
|
|
|
|
// Prefer aliases which are not directly visible
|
|
UseAliasDefinedOutsideCurrentScope = 1 << 3,
|
|
|
|
// { [E.A]: 1 }
|
|
/** @internal */ WriteComputedProps = 1 << 4,
|
|
|
|
// Skip building an accessible symbol chain
|
|
/** @internal */ DoNotIncludeSymbolChain = 1 << 5,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SymbolWalker {
|
|
/** Note: Return values are not ordered. */
|
|
walkType(root: Type): { visitedTypes: readonly Type[]; visitedSymbols: readonly Symbol[]; };
|
|
/** Note: Return values are not ordered. */
|
|
walkSymbol(root: Symbol): { visitedTypes: readonly Type[]; visitedSymbols: readonly Symbol[]; };
|
|
}
|
|
|
|
// This was previously deprecated in our public API, but is still used internally
|
|
/** @internal */
|
|
export interface SymbolWriter {
|
|
writeKeyword(text: string): void;
|
|
writeOperator(text: string): void;
|
|
writePunctuation(text: string): void;
|
|
writeSpace(text: string): void;
|
|
writeStringLiteral(text: string): void;
|
|
writeParameter(text: string): void;
|
|
writeProperty(text: string): void;
|
|
writeSymbol(text: string, symbol: Symbol): void;
|
|
writeLine(force?: boolean): void;
|
|
increaseIndent(): void;
|
|
decreaseIndent(): void;
|
|
clear(): void;
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum SymbolAccessibility {
|
|
Accessible,
|
|
NotAccessible,
|
|
CannotBeNamed,
|
|
NotResolved,
|
|
}
|
|
|
|
export const enum TypePredicateKind {
|
|
This,
|
|
Identifier,
|
|
AssertsThis,
|
|
AssertsIdentifier,
|
|
}
|
|
|
|
export interface TypePredicateBase {
|
|
kind: TypePredicateKind;
|
|
type: Type | undefined;
|
|
}
|
|
|
|
export interface ThisTypePredicate extends TypePredicateBase {
|
|
kind: TypePredicateKind.This;
|
|
parameterName: undefined;
|
|
parameterIndex: undefined;
|
|
type: Type;
|
|
}
|
|
|
|
export interface IdentifierTypePredicate extends TypePredicateBase {
|
|
kind: TypePredicateKind.Identifier;
|
|
parameterName: string;
|
|
parameterIndex: number;
|
|
type: Type;
|
|
}
|
|
|
|
export interface AssertsThisTypePredicate extends TypePredicateBase {
|
|
kind: TypePredicateKind.AssertsThis;
|
|
parameterName: undefined;
|
|
parameterIndex: undefined;
|
|
type: Type | undefined;
|
|
}
|
|
|
|
export interface AssertsIdentifierTypePredicate extends TypePredicateBase {
|
|
kind: TypePredicateKind.AssertsIdentifier;
|
|
parameterName: string;
|
|
parameterIndex: number;
|
|
type: Type | undefined;
|
|
}
|
|
|
|
export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate;
|
|
|
|
/** @internal */
|
|
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
|
|
|
/** @internal */
|
|
export type AnyImportOrJsDocImport = AnyImportSyntax | JSDocImportTag;
|
|
|
|
/** @internal */
|
|
export type AnyImportOrRequire = AnyImportOrJsDocImport | VariableDeclarationInitializedTo<RequireOrImportCall>;
|
|
|
|
/** @internal */
|
|
export type AnyImportOrBareOrAccessedRequire = AnyImportSyntax | VariableDeclarationInitializedTo<RequireOrImportCall | AccessExpression>;
|
|
|
|
/** @internal */
|
|
export type AliasDeclarationNode =
|
|
| ImportEqualsDeclaration
|
|
| VariableDeclarationInitializedTo<
|
|
| RequireOrImportCall
|
|
| AccessExpression
|
|
>
|
|
| ImportClause
|
|
| NamespaceImport
|
|
| ImportSpecifier
|
|
| ExportSpecifier
|
|
| NamespaceExport
|
|
| BindingElementOfBareOrAccessedRequire;
|
|
|
|
/** @internal */
|
|
export type BindingElementOfBareOrAccessedRequire = BindingElement & { parent: { parent: VariableDeclarationInitializedTo<RequireOrImportCall | AccessExpression>; }; };
|
|
|
|
/** @internal */
|
|
export type AnyImportOrRequireStatement = AnyImportSyntax | RequireVariableStatement;
|
|
|
|
/** @internal */
|
|
export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration;
|
|
|
|
/** @internal */
|
|
export interface ValidImportTypeNode extends ImportTypeNode {
|
|
argument: LiteralTypeNode & { literal: StringLiteral; };
|
|
}
|
|
|
|
/** @internal */
|
|
export type AnyValidImportOrReExport =
|
|
| (ImportDeclaration | ExportDeclaration | JSDocImportTag) & { moduleSpecifier: StringLiteral; }
|
|
| ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral; }; }
|
|
| RequireOrImportCall
|
|
| ValidImportTypeNode;
|
|
|
|
/** @internal */
|
|
export type RequireOrImportCall = CallExpression & { expression: Identifier; arguments: [StringLiteralLike]; };
|
|
|
|
/** @internal */
|
|
export interface VariableDeclarationInitializedTo<T extends Expression> extends VariableDeclaration {
|
|
readonly initializer: T;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface RequireVariableStatement extends VariableStatement {
|
|
readonly declarationList: RequireVariableDeclarationList;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface RequireVariableDeclarationList extends VariableDeclarationList {
|
|
readonly declarations: NodeArray<VariableDeclarationInitializedTo<RequireOrImportCall>>;
|
|
}
|
|
|
|
/** @internal */
|
|
export type CanHaveModuleSpecifier = AnyImportOrBareOrAccessedRequire | AliasDeclarationNode | ExportDeclaration | ImportTypeNode;
|
|
|
|
/** @internal */
|
|
export type LateVisibilityPaintedStatement =
|
|
| AnyImportOrJsDocImport
|
|
| VariableStatement
|
|
| ClassDeclaration
|
|
| FunctionDeclaration
|
|
| ModuleDeclaration
|
|
| TypeAliasDeclaration
|
|
| InterfaceDeclaration
|
|
| EnumDeclaration;
|
|
|
|
/** @internal */
|
|
export interface SymbolVisibilityResult {
|
|
accessibility: SymbolAccessibility;
|
|
aliasesToMakeVisible?: LateVisibilityPaintedStatement[]; // aliases that need to have this symbol visible
|
|
errorSymbolName?: string; // Optional symbol name that results in error
|
|
errorNode?: Node; // optional node that results in error
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SymbolAccessibilityResult extends SymbolVisibilityResult {
|
|
errorModuleName?: string; // If the symbol is not visible from module, module's name
|
|
}
|
|
|
|
/** @internal */
|
|
export interface AllAccessorDeclarations {
|
|
firstAccessor: AccessorDeclaration;
|
|
secondAccessor: AccessorDeclaration | undefined;
|
|
getAccessor: GetAccessorDeclaration | undefined;
|
|
setAccessor: SetAccessorDeclaration | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface AllDecorators {
|
|
decorators: readonly Decorator[] | undefined;
|
|
parameters?: readonly (readonly Decorator[] | undefined)[];
|
|
getDecorators?: readonly Decorator[] | undefined;
|
|
setDecorators?: readonly Decorator[] | undefined;
|
|
}
|
|
|
|
/**
|
|
* Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata
|
|
*
|
|
* @internal
|
|
*/
|
|
export enum TypeReferenceSerializationKind {
|
|
// The TypeReferenceNode could not be resolved.
|
|
// The type name should be emitted using a safe fallback.
|
|
Unknown,
|
|
|
|
// The TypeReferenceNode resolves to a type with a constructor
|
|
// function that can be reached at runtime (e.g. a `class`
|
|
// declaration or a `var` declaration for the static side
|
|
// of a type, such as the global `Promise` type in lib.d.ts).
|
|
TypeWithConstructSignatureAndValue,
|
|
|
|
// The TypeReferenceNode resolves to a Void-like, Nullable, or Never type.
|
|
VoidNullableOrNeverType,
|
|
|
|
// The TypeReferenceNode resolves to a Number-like type.
|
|
NumberLikeType,
|
|
|
|
// The TypeReferenceNode resolves to a BigInt-like type.
|
|
BigIntLikeType,
|
|
|
|
// The TypeReferenceNode resolves to a String-like type.
|
|
StringLikeType,
|
|
|
|
// The TypeReferenceNode resolves to a Boolean-like type.
|
|
BooleanType,
|
|
|
|
// The TypeReferenceNode resolves to an Array-like type.
|
|
ArrayLikeType,
|
|
|
|
// The TypeReferenceNode resolves to the ESSymbol type.
|
|
ESSymbolType,
|
|
|
|
// The TypeReferenceNode resolved to the global Promise constructor symbol.
|
|
Promise,
|
|
|
|
// The TypeReferenceNode resolves to a Function type or a type with call signatures.
|
|
TypeWithCallSignature,
|
|
|
|
// The TypeReferenceNode resolves to any other type.
|
|
ObjectType,
|
|
}
|
|
|
|
/** @internal */
|
|
export type LazyNodeCheckFlags =
|
|
| NodeCheckFlags.SuperInstance
|
|
| NodeCheckFlags.SuperStatic
|
|
| NodeCheckFlags.MethodWithSuperPropertyAccessInAsync
|
|
| NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync
|
|
| NodeCheckFlags.ContainsSuperPropertyInStaticInitializer
|
|
| NodeCheckFlags.CaptureArguments
|
|
| NodeCheckFlags.ContainsCapturedBlockScopeBinding
|
|
| NodeCheckFlags.NeedsLoopOutParameter
|
|
| NodeCheckFlags.ContainsConstructorReference
|
|
| NodeCheckFlags.ConstructorReference
|
|
| NodeCheckFlags.CapturedBlockScopedBinding
|
|
| NodeCheckFlags.BlockScopedBindingInLoop
|
|
| NodeCheckFlags.LoopWithCapturedBlockScopedBinding;
|
|
|
|
/** @internal */
|
|
export interface EmitResolver {
|
|
hasGlobalName(name: string): boolean;
|
|
getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration | undefined;
|
|
getReferencedImportDeclaration(node: Identifier): Declaration | undefined;
|
|
getReferencedDeclarationWithCollidingName(node: Identifier): Declaration | undefined;
|
|
isDeclarationWithCollidingName(node: Declaration): boolean;
|
|
isValueAliasDeclaration(node: Node): boolean;
|
|
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
|
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
|
hasNodeCheckFlag(node: Node, flags: LazyNodeCheckFlags): boolean;
|
|
isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean;
|
|
isLateBound(node: Declaration): node is LateBoundDeclaration;
|
|
collectLinkedAliases(node: ModuleExportName, setVisibility?: boolean): Node[] | undefined;
|
|
markLinkedReferences(node: Node): void;
|
|
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
|
requiresAddingImplicitUndefined(node: ParameterDeclaration, enclosingDeclaration: Node | undefined): boolean;
|
|
isExpandoFunctionDeclaration(node: FunctionDeclaration | VariableDeclaration): boolean;
|
|
getPropertiesOfContainerFunction(node: Declaration): Symbol[];
|
|
createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration | PropertyAccessExpression | ElementAccessExpression | BinaryExpression, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
|
createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
|
createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
|
createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, tracker: SymbolTracker): Expression;
|
|
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags | undefined, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
|
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
|
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
|
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
|
getEnumMemberValue(node: EnumMember): EvaluatorResult | undefined;
|
|
getReferencedValueDeclaration(reference: Identifier): Declaration | undefined;
|
|
getReferencedValueDeclarations(reference: Identifier): Declaration[] | undefined;
|
|
getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind;
|
|
isOptionalParameter(node: ParameterDeclaration): boolean;
|
|
isArgumentsLocalBinding(node: Identifier): boolean;
|
|
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode | ImportCall): SourceFile | undefined;
|
|
isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean;
|
|
getJsxFactoryEntity(location?: Node): EntityName | undefined;
|
|
getJsxFragmentFactoryEntity(location?: Node): EntityName | undefined;
|
|
isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean;
|
|
getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): Statement[] | undefined;
|
|
isImportRequiredByAugmentation(decl: ImportDeclaration): boolean;
|
|
isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum SymbolFlags {
|
|
None = 0,
|
|
FunctionScopedVariable = 1 << 0, // Variable (var) or parameter
|
|
BlockScopedVariable = 1 << 1, // A block-scoped variable (let or const)
|
|
Property = 1 << 2, // Property or enum member
|
|
EnumMember = 1 << 3, // Enum member
|
|
Function = 1 << 4, // Function
|
|
Class = 1 << 5, // Class
|
|
Interface = 1 << 6, // Interface
|
|
ConstEnum = 1 << 7, // Const enum
|
|
RegularEnum = 1 << 8, // Enum
|
|
ValueModule = 1 << 9, // Instantiated module
|
|
NamespaceModule = 1 << 10, // Uninstantiated module
|
|
TypeLiteral = 1 << 11, // Type Literal or mapped type
|
|
ObjectLiteral = 1 << 12, // Object Literal
|
|
Method = 1 << 13, // Method
|
|
Constructor = 1 << 14, // Constructor
|
|
GetAccessor = 1 << 15, // Get accessor
|
|
SetAccessor = 1 << 16, // Set accessor
|
|
Signature = 1 << 17, // Call, construct, or index signature
|
|
TypeParameter = 1 << 18, // Type parameter
|
|
TypeAlias = 1 << 19, // Type alias
|
|
ExportValue = 1 << 20, // Exported value marker (see comment in declareModuleMember in binder)
|
|
Alias = 1 << 21, // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker)
|
|
Prototype = 1 << 22, // Prototype property (no source representation)
|
|
ExportStar = 1 << 23, // Export * declaration
|
|
Optional = 1 << 24, // Optional property
|
|
Transient = 1 << 25, // Transient symbol (created during type check)
|
|
Assignment = 1 << 26, // Assignment treated as declaration (eg `this.prop = 1`)
|
|
ModuleExports = 1 << 27, // Symbol for CommonJS `module` of `module.exports`
|
|
All = -1,
|
|
|
|
Enum = RegularEnum | ConstEnum,
|
|
Variable = FunctionScopedVariable | BlockScopedVariable,
|
|
Value = Variable | Property | EnumMember | ObjectLiteral | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor,
|
|
Type = Class | Interface | Enum | EnumMember | TypeLiteral | TypeParameter | TypeAlias,
|
|
Namespace = ValueModule | NamespaceModule | Enum,
|
|
Module = ValueModule | NamespaceModule,
|
|
Accessor = GetAccessor | SetAccessor,
|
|
|
|
// Variables can be redeclared, but can not redeclare a block-scoped declaration with the
|
|
// same name, or any other value that is not a variable, e.g. ValueModule or Class
|
|
FunctionScopedVariableExcludes = Value & ~FunctionScopedVariable,
|
|
|
|
// Block-scoped declarations are not allowed to be re-declared
|
|
// they can not merge with anything in the value space
|
|
BlockScopedVariableExcludes = Value,
|
|
|
|
ParameterExcludes = Value,
|
|
PropertyExcludes = None,
|
|
EnumMemberExcludes = Value | Type,
|
|
FunctionExcludes = Value & ~(Function | ValueModule | Class),
|
|
ClassExcludes = (Value | Type) & ~(ValueModule | Interface | Function), // class-interface mergability done in checker.ts
|
|
InterfaceExcludes = Type & ~(Interface | Class),
|
|
RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules
|
|
ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums
|
|
ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule),
|
|
NamespaceModuleExcludes = 0,
|
|
MethodExcludes = Value & ~Method,
|
|
GetAccessorExcludes = Value & ~SetAccessor,
|
|
SetAccessorExcludes = Value & ~GetAccessor,
|
|
AccessorExcludes = Value & ~Accessor,
|
|
TypeParameterExcludes = Type & ~TypeParameter,
|
|
TypeAliasExcludes = Type,
|
|
AliasExcludes = Alias,
|
|
|
|
ModuleMember = Variable | Function | Class | Interface | Enum | Module | TypeAlias | Alias,
|
|
|
|
ExportHasLocal = Function | Class | Enum | ValueModule,
|
|
|
|
BlockScoped = BlockScopedVariable | Class | Enum,
|
|
|
|
PropertyOrAccessor = Property | Accessor,
|
|
|
|
ClassMember = Method | Accessor | Property,
|
|
|
|
/** @internal */
|
|
ExportSupportsDefaultModifier = Class | Function | Interface,
|
|
|
|
/** @internal */
|
|
ExportDoesNotSupportDefaultModifier = ~ExportSupportsDefaultModifier,
|
|
|
|
/** @internal */
|
|
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
|
// classification.
|
|
Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module | Alias,
|
|
|
|
/** @internal */
|
|
LateBindingContainer = Class | Interface | TypeLiteral | ObjectLiteral | Function,
|
|
}
|
|
|
|
/** @internal */
|
|
export type SymbolId = number;
|
|
|
|
// dprint-ignore
|
|
export interface Symbol {
|
|
flags: SymbolFlags; // Symbol flags
|
|
escapedName: __String; // Name of symbol
|
|
declarations?: Declaration[]; // Declarations associated with this symbol
|
|
valueDeclaration?: Declaration; // First value declaration of the symbol
|
|
members?: SymbolTable; // Class, interface or object literal instance members
|
|
exports?: SymbolTable; // Module exports
|
|
globalExports?: SymbolTable; // Conditional global UMD exports
|
|
/** @internal */ id: SymbolId; // Unique id (used to look up SymbolLinks)
|
|
/** @internal */ mergeId: number; // Merge id (used to look up merged symbol)
|
|
/** @internal */ parent?: Symbol; // Parent symbol
|
|
/** @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
|
/** @internal */ constEnumOnlyModule: boolean | undefined; // True if module contains only const enums or other modules with only const enums
|
|
/** @internal */ isReferenced?: SymbolFlags; // True if the symbol is referenced elsewhere. Keeps track of the meaning of a reference in case a symbol is both a type parameter and parameter.
|
|
/** @internal */ lastAssignmentPos?: number; // Source position of last node that assigns value to symbol. Negative if it is assigned anywhere definitely
|
|
/** @internal */ isReplaceableByMethod?: boolean; // Can this Javascript class property be replaced by a method symbol?
|
|
/** @internal */ assignmentDeclarationMembers?: Map<number, Declaration>; // detected late-bound assignment declarations associated with the symbol
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface SymbolLinks {
|
|
_symbolLinksBrand: any;
|
|
immediateTarget?: Symbol; // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead.
|
|
aliasTarget?: Symbol, // Resolved (non-alias) target of an alias
|
|
target?: Symbol; // Original version of an instantiated symbol
|
|
type?: Type; // Type of value symbol
|
|
writeType?: Type; // Type of value symbol in write contexts
|
|
nameType?: Type; // Type associated with a late-bound symbol
|
|
uniqueESSymbolType?: Type; // UniqueESSymbol type for a symbol
|
|
declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter
|
|
typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic)
|
|
instantiations?: Map<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
|
|
inferredClassSymbol?: Map<SymbolId, TransientSymbol>; // Symbol of an inferred ES5 constructor function
|
|
mapper?: TypeMapper; // Type mapper for instantiation alias
|
|
referenced?: boolean; // True if alias symbol has been referenced as a value that can be emitted
|
|
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
|
|
leftSpread?: Symbol; // Left source for synthetic spread property
|
|
rightSpread?: Symbol; // Right source for synthetic spread property
|
|
syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property
|
|
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
|
|
resolvedExports?: SymbolTable; // Resolved exports of module or combined early- and late-bound static members of a class.
|
|
resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol
|
|
exportsChecked?: boolean; // True if exports of external module have been checked
|
|
typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked.
|
|
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
|
|
bindingElement?: BindingElement; // Binding element associated with property symbol
|
|
originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is marked as uncallable but had call signatures in `resolveESModuleSymbol`
|
|
lateSymbol?: Symbol; // Late-bound symbol for a computed property
|
|
specifierCache?: Map<ModeAwareCacheKey, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
|
|
extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in
|
|
extendedContainersByFile?: Map<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
|
|
variances?: VarianceFlags[]; // Alias symbol type argument variance cache
|
|
deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type
|
|
deferralWriteConstituents?: Type[]; // Constituents of a deferred `writeType`
|
|
deferralParent?: Type; // Source union/intersection of a deferred type
|
|
cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target
|
|
typeOnlyDeclaration?: TypeOnlyAliasDeclaration | false; // First resolved alias declaration that makes the symbol only usable in type constructs
|
|
typeOnlyExportStarMap?: Map<__String, ExportDeclaration & { readonly isTypeOnly: true, readonly moduleSpecifier: Expression }>; // Set on a module symbol when some of its exports were resolved through a 'export type * from "mod"' declaration
|
|
typeOnlyExportStarName?: __String; // Set to the name of the symbol re-exported by an 'export type *' declaration, when different from the symbol name
|
|
isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor
|
|
tupleLabelDeclaration?: NamedTupleMember | ParameterDeclaration; // Declaration associated with the tuple's label
|
|
accessibleChainCache?: Map<string, Symbol[] | undefined>;
|
|
filteredIndexSymbolCache?: Map<string, Symbol> //Symbol with applicable declarations
|
|
requestedExternalEmitHelpers?: ExternalEmitHelpers; // External emit helpers already checked for this symbol.
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum CheckFlags {
|
|
None = 0,
|
|
Instantiated = 1 << 0, // Instantiated symbol
|
|
SyntheticProperty = 1 << 1, // Property in union or intersection type
|
|
SyntheticMethod = 1 << 2, // Method in union or intersection type
|
|
Readonly = 1 << 3, // Readonly transient symbol
|
|
ReadPartial = 1 << 4, // Synthetic property present in some but not all constituents
|
|
WritePartial = 1 << 5, // Synthetic property present in some but only satisfied by an index signature in others
|
|
HasNonUniformType = 1 << 6, // Synthetic property with non-uniform type in constituents
|
|
HasLiteralType = 1 << 7, // Synthetic property with at least one literal type in constituents
|
|
ContainsPublic = 1 << 8, // Synthetic property with public constituent(s)
|
|
ContainsProtected = 1 << 9, // Synthetic property with protected constituent(s)
|
|
ContainsPrivate = 1 << 10, // Synthetic property with private constituent(s)
|
|
ContainsStatic = 1 << 11, // Synthetic property with static constituent(s)
|
|
Late = 1 << 12, // Late-bound symbol for a computed property with a dynamic name
|
|
ReverseMapped = 1 << 13, // Property of reverse-inferred homomorphic mapped type
|
|
OptionalParameter = 1 << 14, // Optional parameter
|
|
RestParameter = 1 << 15, // Rest parameter
|
|
DeferredType = 1 << 16, // Calculation of the type of this symbol is deferred due to processing costs, should be fetched with `getTypeOfSymbolWithDeferredType`
|
|
HasNeverType = 1 << 17, // Synthetic property with at least one never type in constituents
|
|
Mapped = 1 << 18, // Property of mapped type
|
|
StripOptional = 1 << 19, // Strip optionality in mapped property
|
|
Unresolved = 1 << 20, // Unresolved type alias symbol
|
|
Synthetic = SyntheticProperty | SyntheticMethod,
|
|
Discriminant = HasNonUniformType | HasLiteralType,
|
|
Partial = ReadPartial | WritePartial,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface TransientSymbolLinks extends SymbolLinks {
|
|
checkFlags: CheckFlags;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface TransientSymbol extends Symbol {
|
|
links: TransientSymbolLinks;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface MappedSymbolLinks extends TransientSymbolLinks {
|
|
mappedType: MappedType;
|
|
keyType: Type;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface MappedSymbol extends TransientSymbol {
|
|
links: MappedSymbolLinks;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ReverseMappedSymbolLinks extends TransientSymbolLinks {
|
|
propertyType: Type;
|
|
mappedType: MappedType;
|
|
constraintType: IndexType;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ReverseMappedSymbol extends TransientSymbol {
|
|
links: ReverseMappedSymbolLinks;
|
|
}
|
|
|
|
export const enum InternalSymbolName {
|
|
Call = "__call", // Call signatures
|
|
Constructor = "__constructor", // Constructor implementations
|
|
New = "__new", // Constructor signatures
|
|
Index = "__index", // Index signatures
|
|
ExportStar = "__export", // Module export * declarations
|
|
Global = "__global", // Global self-reference
|
|
Missing = "__missing", // Indicates missing symbol
|
|
Type = "__type", // Anonymous type literal symbol
|
|
Object = "__object", // Anonymous object literal declaration
|
|
JSXAttributes = "__jsxAttributes", // Anonymous JSX attributes object literal declaration
|
|
Class = "__class", // Unnamed class expression
|
|
Function = "__function", // Unnamed function expression
|
|
Computed = "__computed", // Computed property name declaration with dynamic name
|
|
Resolving = "__resolving__", // Indicator symbol used to mark partially resolved type aliases
|
|
ExportEquals = "export=", // Export assignment symbol
|
|
Default = "default", // Default export symbol (technically not wholly internal, but included here for usability)
|
|
This = "this",
|
|
InstantiationExpression = "__instantiationExpression", // Instantiation expressions
|
|
ImportAttributes = "__importAttributes",
|
|
}
|
|
|
|
/**
|
|
* This represents a string whose leading underscore have been escaped by adding extra leading underscores.
|
|
* The shape of this brand is rather unique compared to others we've used.
|
|
* Instead of just an intersection of a string and an object, it is that union-ed
|
|
* with an intersection of void and an object. This makes it wholly incompatible
|
|
* with a normal string (which is good, it cannot be misused on assignment or on usage),
|
|
* while still being comparable with a normal string via === (also good) and castable from a string.
|
|
*/
|
|
export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName;
|
|
|
|
/** @deprecated Use ReadonlyMap<__String, T> instead. */
|
|
export type ReadonlyUnderscoreEscapedMap<T> = ReadonlyMap<__String, T>;
|
|
|
|
/** @deprecated Use Map<__String, T> instead. */
|
|
export type UnderscoreEscapedMap<T> = Map<__String, T>;
|
|
|
|
/** SymbolTable based on ES6 Map interface. */
|
|
export type SymbolTable = Map<__String, Symbol>;
|
|
|
|
/**
|
|
* Used to track a `declare module "foo*"`-like declaration.
|
|
*
|
|
* @internal
|
|
*/
|
|
export interface PatternAmbientModule {
|
|
pattern: Pattern;
|
|
symbol: Symbol;
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum NodeCheckFlags {
|
|
None = 0,
|
|
TypeChecked = 1 << 0, // Node has been type checked
|
|
LexicalThis = 1 << 1, // Lexical 'this' reference
|
|
CaptureThis = 1 << 2, // Lexical 'this' used in body
|
|
CaptureNewTarget = 1 << 3, // Lexical 'new.target' used in body
|
|
SuperInstance = 1 << 4, // Instance 'super' reference
|
|
SuperStatic = 1 << 5, // Static 'super' reference
|
|
ContextChecked = 1 << 6, // Contextual types have been assigned
|
|
MethodWithSuperPropertyAccessInAsync = 1 << 7, // A method that contains a SuperProperty access in an async context.
|
|
MethodWithSuperPropertyAssignmentInAsync = 1 << 8, // A method that contains a SuperProperty assignment in an async context.
|
|
CaptureArguments = 1 << 9, // Lexical 'arguments' used in body
|
|
EnumValuesComputed = 1 << 10, // Values for enum members have been computed, and any errors have been reported for them.
|
|
LexicalModuleMergesWithClass = 1 << 11, // Instantiated lexical module declaration is merged with a previous class declaration.
|
|
LoopWithCapturedBlockScopedBinding = 1 << 12, // Loop that contains block scoped variable captured in closure
|
|
ContainsCapturedBlockScopeBinding = 1 << 13, // Part of a loop that contains block scoped variable captured in closure
|
|
CapturedBlockScopedBinding = 1 << 14, // Block-scoped binding that is captured in some function
|
|
BlockScopedBindingInLoop = 1 << 15, // Block-scoped binding with declaration nested inside iteration statement
|
|
NeedsLoopOutParameter = 1 << 16, // Block scoped binding whose value should be explicitly copied outside of the converted loop
|
|
AssignmentsMarked = 1 << 17, // Parameter assignments have been marked
|
|
ContainsConstructorReference = 1 << 18, // Class or class element that contains a binding that references the class constructor.
|
|
ConstructorReference = 1 << 29, // Binding to a class constructor inside of the class's body.
|
|
ContainsClassWithPrivateIdentifiers = 1 << 20, // Marked on all block-scoped containers containing a class with private identifiers.
|
|
ContainsSuperPropertyInStaticInitializer = 1 << 21, // Marked on all block-scoped containers containing a static initializer with 'super.x' or 'super[x]'.
|
|
InCheckIdentifier = 1 << 22,
|
|
PartiallyTypeChecked = 1 << 23, // Node has been partially type checked
|
|
|
|
/** These flags are LazyNodeCheckFlags and can be calculated lazily by `hasNodeCheckFlag` */
|
|
LazyFlags = SuperInstance
|
|
| SuperStatic
|
|
| MethodWithSuperPropertyAccessInAsync
|
|
| MethodWithSuperPropertyAssignmentInAsync
|
|
| ContainsSuperPropertyInStaticInitializer
|
|
| CaptureArguments
|
|
| ContainsCapturedBlockScopeBinding
|
|
| NeedsLoopOutParameter
|
|
| ContainsConstructorReference
|
|
| ConstructorReference
|
|
| CapturedBlockScopedBinding
|
|
| BlockScopedBindingInLoop
|
|
| LoopWithCapturedBlockScopedBinding,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface EvaluatorResult<T extends string | number | undefined = string | number | undefined> {
|
|
value: T;
|
|
isSyntacticallyString: boolean;
|
|
resolvedOtherFiles: boolean;
|
|
hasExternalReferences: boolean;
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface NodeLinks {
|
|
flags: NodeCheckFlags; // Set of flags specific to Node
|
|
calculatedFlags: NodeCheckFlags; // Set of flags which have definitely been calculated already
|
|
resolvedType?: Type; // Cached type of type node
|
|
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
|
resolvedSymbol?: Symbol; // Cached name resolution result
|
|
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
|
effectsSignature?: Signature; // Signature with possible control flow effects
|
|
enumMemberValue?: EvaluatorResult; // Constant value of enum member
|
|
isVisible?: boolean; // Is this node visible
|
|
containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference
|
|
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
|
jsxFlags: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with
|
|
resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element
|
|
resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element
|
|
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
|
|
switchTypes?: Type[]; // Cached array of switch case expression types
|
|
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
|
|
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
|
|
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
|
|
deferredNodes?: Set<Node>; // Set of nodes whose checking has been deferred
|
|
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
|
|
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
|
|
isExhaustive?: boolean | 0; // Is node an exhaustive switch statement (0 indicates in-process resolution)
|
|
skipDirectInference?: true; // Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type
|
|
declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
|
|
serializedTypes?: Map<string, SerializedTypeEntry>; // Collection of types serialized at this location
|
|
decoratorSignature?: Signature; // Signature for decorator as if invoked by the runtime.
|
|
spreadIndices?: { first: number | undefined, last: number | undefined }; // Indices of first and last spread elements in array literal
|
|
parameterInitializerContainsUndefined?: boolean; // True if this is a parameter declaration whose type annotation contains "undefined".
|
|
fakeScopeForSignatureDeclaration?: "params" | "typeParams"; // If present, this is a fake scope injected into an enclosing declaration chain.
|
|
assertionExpressionType?: Type; // Cached type of the expression of a type assertion
|
|
potentialThisCollisions?: Node[];
|
|
potentialNewTargetCollisions?: Node[];
|
|
potentialWeakMapSetCollisions?: Node[];
|
|
potentialReflectCollisions?: Node[];
|
|
potentialUnusedRenamedBindingElementsInTypes?: BindingElement[];
|
|
externalHelpersModule?: Symbol; // Resolved symbol for the external helpers module
|
|
}
|
|
|
|
/** @internal */
|
|
export type TrackedSymbol = [symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags];
|
|
/** @internal */
|
|
export interface SerializedTypeEntry {
|
|
node: TypeNode;
|
|
truncating?: boolean;
|
|
addedLength: number;
|
|
trackedSymbols: readonly TrackedSymbol[] | undefined;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum TypeFlags {
|
|
Any = 1 << 0,
|
|
Unknown = 1 << 1,
|
|
String = 1 << 2,
|
|
Number = 1 << 3,
|
|
Boolean = 1 << 4,
|
|
Enum = 1 << 5, // Numeric computed enum member value
|
|
BigInt = 1 << 6,
|
|
StringLiteral = 1 << 7,
|
|
NumberLiteral = 1 << 8,
|
|
BooleanLiteral = 1 << 9,
|
|
EnumLiteral = 1 << 10, // Always combined with StringLiteral, NumberLiteral, or Union
|
|
BigIntLiteral = 1 << 11,
|
|
ESSymbol = 1 << 12, // Type of symbol primitive introduced in ES6
|
|
UniqueESSymbol = 1 << 13, // unique symbol
|
|
Void = 1 << 14,
|
|
Undefined = 1 << 15,
|
|
Null = 1 << 16,
|
|
Never = 1 << 17, // Never type
|
|
TypeParameter = 1 << 18, // Type parameter
|
|
Object = 1 << 19, // Object type
|
|
Union = 1 << 20, // Union (T | U)
|
|
Intersection = 1 << 21, // Intersection (T & U)
|
|
Index = 1 << 22, // keyof T
|
|
IndexedAccess = 1 << 23, // T[K]
|
|
Conditional = 1 << 24, // T extends U ? X : Y
|
|
Substitution = 1 << 25, // Type parameter substitution
|
|
NonPrimitive = 1 << 26, // intrinsic object type
|
|
TemplateLiteral = 1 << 27, // Template literal type
|
|
StringMapping = 1 << 28, // Uppercase/Lowercase type
|
|
/** @internal */
|
|
Reserved1 = 1 << 29, // Used by union/intersection type construction
|
|
/** @internal */
|
|
Reserved2 = 1 << 30, // Used by union/intersection type construction
|
|
|
|
/** @internal */
|
|
AnyOrUnknown = Any | Unknown,
|
|
/** @internal */
|
|
Nullable = Undefined | Null,
|
|
Literal = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral,
|
|
Unit = Enum | Literal | UniqueESSymbol | Nullable,
|
|
Freshable = Enum | Literal,
|
|
StringOrNumberLiteral = StringLiteral | NumberLiteral,
|
|
/** @internal */
|
|
StringOrNumberLiteralOrUnique = StringLiteral | NumberLiteral | UniqueESSymbol,
|
|
/** @internal */
|
|
DefinitelyFalsy = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral | Void | Undefined | Null,
|
|
PossiblyFalsy = DefinitelyFalsy | String | Number | BigInt | Boolean,
|
|
/** @internal */
|
|
Intrinsic = Any | Unknown | String | Number | BigInt | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
|
|
StringLike = String | StringLiteral | TemplateLiteral | StringMapping,
|
|
NumberLike = Number | NumberLiteral | Enum,
|
|
BigIntLike = BigInt | BigIntLiteral,
|
|
BooleanLike = Boolean | BooleanLiteral,
|
|
EnumLike = Enum | EnumLiteral,
|
|
ESSymbolLike = ESSymbol | UniqueESSymbol,
|
|
VoidLike = Void | Undefined,
|
|
/** @internal */
|
|
Primitive = StringLike | NumberLike | BigIntLike | BooleanLike | EnumLike | ESSymbolLike | VoidLike | Null,
|
|
/** @internal */
|
|
DefinitelyNonNullable = StringLike | NumberLike | BigIntLike | BooleanLike | EnumLike | ESSymbolLike | Object | NonPrimitive,
|
|
/** @internal */
|
|
DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null,
|
|
UnionOrIntersection = Union | Intersection,
|
|
StructuredType = Object | Union | Intersection,
|
|
TypeVariable = TypeParameter | IndexedAccess,
|
|
InstantiableNonPrimitive = TypeVariable | Conditional | Substitution,
|
|
InstantiablePrimitive = Index | TemplateLiteral | StringMapping,
|
|
Instantiable = InstantiableNonPrimitive | InstantiablePrimitive,
|
|
StructuredOrInstantiable = StructuredType | Instantiable,
|
|
/** @internal */
|
|
ObjectFlagsType = Any | Nullable | Never | Object | Union | Intersection,
|
|
/** @internal */
|
|
Simplifiable = IndexedAccess | Conditional,
|
|
/** @internal */
|
|
Singleton = Any | Unknown | String | Number | Boolean | BigInt | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
|
|
// 'Narrowable' types are types where narrowing actually narrows.
|
|
// This *should* be every type other than null, undefined, void, and never
|
|
Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive,
|
|
// The following flags are aggregated during union and intersection type construction
|
|
/** @internal */
|
|
IncludesMask = Any | Unknown | Primitive | Never | Object | Union | Intersection | NonPrimitive | TemplateLiteral | StringMapping,
|
|
// The following flags are used for different purposes during union and intersection type construction
|
|
/** @internal */
|
|
IncludesMissingType = TypeParameter,
|
|
/** @internal */
|
|
IncludesNonWideningType = Index,
|
|
/** @internal */
|
|
IncludesWildcard = IndexedAccess,
|
|
/** @internal */
|
|
IncludesEmptyObject = Conditional,
|
|
/** @internal */
|
|
IncludesInstantiable = Substitution,
|
|
/** @internal */
|
|
IncludesConstrainedTypeVariable = Reserved1,
|
|
/** @internal */
|
|
IncludesError = Reserved2,
|
|
/** @internal */
|
|
NotPrimitiveUnion = Any | Unknown | Void | Never | Object | Intersection | IncludesInstantiable,
|
|
}
|
|
|
|
export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
|
|
|
/** @internal */
|
|
export type TypeId = number;
|
|
|
|
// Properties common to all types
|
|
// dprint-ignore
|
|
export interface Type {
|
|
flags: TypeFlags; // Flags
|
|
/** @internal */ id: TypeId; // Unique ID
|
|
/** @internal */ checker: TypeChecker;
|
|
symbol: Symbol; // Symbol associated with type (if any)
|
|
pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any)
|
|
aliasSymbol?: Symbol; // Alias associated with type
|
|
aliasTypeArguments?: readonly Type[]; // Alias type arguments (if any)
|
|
/** @internal */
|
|
permissiveInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type
|
|
/** @internal */
|
|
restrictiveInstantiation?: Type; // Instantiation with type parameters mapped to unconstrained form
|
|
/** @internal */
|
|
immediateBaseConstraint?: Type; // Immediate base constraint cache
|
|
/** @internal */
|
|
widened?: Type; // Cached widened form of the type
|
|
}
|
|
|
|
/** @internal */
|
|
// Intrinsic types (TypeFlags.Intrinsic)
|
|
export interface IntrinsicType extends Type {
|
|
intrinsicName: string; // Name of intrinsic type
|
|
debugIntrinsicName: string | undefined;
|
|
objectFlags: ObjectFlags;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface NullableType extends IntrinsicType {
|
|
objectFlags: ObjectFlags;
|
|
}
|
|
|
|
export interface FreshableType extends Type {
|
|
freshType: FreshableType; // Fresh version of type
|
|
regularType: FreshableType; // Regular version of type
|
|
}
|
|
|
|
/** @internal */
|
|
export interface FreshableIntrinsicType extends FreshableType, IntrinsicType {
|
|
}
|
|
|
|
// String literal types (TypeFlags.StringLiteral)
|
|
// Numeric literal types (TypeFlags.NumberLiteral)
|
|
// BigInt literal types (TypeFlags.BigIntLiteral)
|
|
export interface LiteralType extends FreshableType {
|
|
value: string | number | PseudoBigInt; // Value of literal
|
|
}
|
|
|
|
// Unique symbol types (TypeFlags.UniqueESSymbol)
|
|
export interface UniqueESSymbolType extends Type {
|
|
symbol: Symbol;
|
|
escapedName: __String;
|
|
}
|
|
|
|
export interface StringLiteralType extends LiteralType {
|
|
value: string;
|
|
}
|
|
|
|
export interface NumberLiteralType extends LiteralType {
|
|
value: number;
|
|
}
|
|
|
|
export interface BigIntLiteralType extends LiteralType {
|
|
value: PseudoBigInt;
|
|
}
|
|
|
|
// Enum types (TypeFlags.Enum)
|
|
export interface EnumType extends FreshableType {
|
|
}
|
|
|
|
// Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags
|
|
// are specific to certain types and reuse the same bit position. Those ObjectFlags require a check
|
|
// for a certain TypeFlags value to determine their meaning.
|
|
// dprint-ignore
|
|
export const enum ObjectFlags {
|
|
None = 0,
|
|
Class = 1 << 0, // Class
|
|
Interface = 1 << 1, // Interface
|
|
Reference = 1 << 2, // Generic type reference
|
|
Tuple = 1 << 3, // Synthesized generic tuple type
|
|
Anonymous = 1 << 4, // Anonymous
|
|
Mapped = 1 << 5, // Mapped
|
|
Instantiated = 1 << 6, // Instantiated anonymous or mapped type
|
|
ObjectLiteral = 1 << 7, // Originates in an object literal
|
|
EvolvingArray = 1 << 8, // Evolving array type
|
|
ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties
|
|
ReverseMapped = 1 << 10, // Object contains a property from a reverse-mapped type
|
|
JsxAttributes = 1 << 11, // Jsx attributes type
|
|
JSLiteral = 1 << 12, // Object type declared in JS - disables errors on read/write of nonexisting members
|
|
FreshLiteral = 1 << 13, // Fresh object literal
|
|
ArrayLiteral = 1 << 14, // Originates in an array literal
|
|
/** @internal */
|
|
PrimitiveUnion = 1 << 15, // Union of only primitive types
|
|
/** @internal */
|
|
ContainsWideningType = 1 << 16, // Type is or contains undefined or null widening type
|
|
/** @internal */
|
|
ContainsObjectOrArrayLiteral = 1 << 17, // Type is or contains object literal type
|
|
/** @internal */
|
|
NonInferrableType = 1 << 18, // Type is or contains anyFunctionType or silentNeverType
|
|
/** @internal */
|
|
CouldContainTypeVariablesComputed = 1 << 19, // CouldContainTypeVariables flag has been computed
|
|
/** @internal */
|
|
CouldContainTypeVariables = 1 << 20, // Type could contain a type variable
|
|
|
|
ClassOrInterface = Class | Interface,
|
|
/** @internal */
|
|
RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral,
|
|
/** @internal */
|
|
PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType,
|
|
/** @internal */
|
|
InstantiatedMapped = Mapped | Instantiated,
|
|
// Object flags that uniquely identify the kind of ObjectType
|
|
/** @internal */
|
|
ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray,
|
|
|
|
// Flags that require TypeFlags.Object
|
|
ContainsSpread = 1 << 21, // Object literal contains spread operation
|
|
ObjectRestType = 1 << 22, // Originates in object rest declaration
|
|
InstantiationExpressionType = 1 << 23, // Originates in instantiation expression
|
|
SingleSignatureType = 1 << 27, // A single signature type extracted from a potentially broader type
|
|
/** @internal */
|
|
IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type
|
|
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
|
/** @internal */
|
|
IdenticalBaseTypeCalculated = 1 << 25, // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already
|
|
/** @internal */
|
|
IdenticalBaseTypeExists = 1 << 26, // has a defined cachedEquivalentBaseType member
|
|
|
|
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
|
/** @internal */
|
|
IsGenericTypeComputed = 1 << 21, // IsGenericObjectType flag has been computed
|
|
/** @internal */
|
|
IsGenericObjectType = 1 << 22, // Union or intersection contains generic object type
|
|
/** @internal */
|
|
IsGenericIndexType = 1 << 23, // Union or intersection contains generic index type
|
|
/** @internal */
|
|
IsGenericType = IsGenericObjectType | IsGenericIndexType,
|
|
|
|
// Flags that require TypeFlags.Union
|
|
/** @internal */
|
|
ContainsIntersections = 1 << 24, // Union contains intersections
|
|
/** @internal */
|
|
IsUnknownLikeUnionComputed = 1 << 25, // IsUnknownLikeUnion flag has been computed
|
|
/** @internal */
|
|
IsUnknownLikeUnion = 1 << 26, // Union of null, undefined, and empty object type
|
|
/** @internal */
|
|
|
|
// Flags that require TypeFlags.Intersection
|
|
/** @internal */
|
|
IsNeverIntersectionComputed = 1 << 24, // IsNeverLike flag has been computed
|
|
/** @internal */
|
|
IsNeverIntersection = 1 << 25, // Intersection reduces to never
|
|
/** @internal */
|
|
IsConstrainedTypeVariable = 1 << 26, // T & C, where T's constraint and C are primitives, object, or {}
|
|
}
|
|
|
|
/** @internal */
|
|
export type ObjectFlagsType = NullableType | ObjectType | UnionType | IntersectionType;
|
|
|
|
// Object types (TypeFlags.ObjectType)
|
|
// dprint-ignore
|
|
export interface ObjectType extends Type {
|
|
objectFlags: ObjectFlags;
|
|
/** @internal */ members?: SymbolTable; // Properties by name
|
|
/** @internal */ properties?: Symbol[]; // Properties
|
|
/** @internal */ callSignatures?: readonly Signature[]; // Call signatures of type
|
|
/** @internal */ constructSignatures?: readonly Signature[]; // Construct signatures of type
|
|
/** @internal */ indexInfos?: readonly IndexInfo[]; // Index signatures
|
|
/** @internal */ objectTypeWithoutAbstractConstructSignatures?: ObjectType;
|
|
}
|
|
|
|
/** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */
|
|
// dprint-ignore
|
|
export interface InterfaceType extends ObjectType {
|
|
typeParameters: TypeParameter[] | undefined; // Type parameters (undefined if non-generic)
|
|
outerTypeParameters: TypeParameter[] | undefined; // Outer type parameters (undefined if none)
|
|
localTypeParameters: TypeParameter[] | undefined; // Local type parameters (undefined if none)
|
|
thisType: TypeParameter | undefined; // The "this" type (undefined if none)
|
|
/** @internal */
|
|
resolvedBaseConstructorType?: Type; // Resolved base constructor type of class
|
|
/** @internal */
|
|
resolvedBaseTypes: BaseType[]; // Resolved base types
|
|
/** @internal */
|
|
baseTypesResolved?: boolean;
|
|
}
|
|
|
|
// Object type or intersection of object types
|
|
export type BaseType = ObjectType | IntersectionType | TypeVariable; // Also `any` and `object`
|
|
|
|
// dprint-ignore
|
|
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
|
declaredProperties: Symbol[]; // Declared members
|
|
declaredCallSignatures: Signature[]; // Declared call signatures
|
|
declaredConstructSignatures: Signature[]; // Declared construct signatures
|
|
declaredIndexInfos: IndexInfo[]; // Declared index signatures
|
|
}
|
|
|
|
/**
|
|
* Type references (ObjectFlags.Reference). When a class or interface has type parameters or
|
|
* a "this" type, references to the class or interface are made using type references. The
|
|
* typeArguments property specifies the types to substitute for the type parameters of the
|
|
* class or interface and optionally includes an extra element that specifies the type to
|
|
* substitute for "this" in the resulting instantiation. When no extra argument is present,
|
|
* the type reference itself is substituted for "this". The typeArguments property is undefined
|
|
* if the class or interface has no type parameters and the reference isn't specifying an
|
|
* explicit "this" argument.
|
|
*/
|
|
export interface TypeReference extends ObjectType {
|
|
target: GenericType; // Type reference target
|
|
node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode;
|
|
/** @internal */
|
|
mapper?: TypeMapper;
|
|
/** @internal */
|
|
resolvedTypeArguments?: readonly Type[]; // Resolved type reference type arguments
|
|
/** @internal */
|
|
literalType?: TypeReference; // Clone of type with ObjectFlags.ArrayLiteral set
|
|
/** @internal */
|
|
cachedEquivalentBaseType?: Type; // Only set on references to class or interfaces with a single base type and no augmentations
|
|
}
|
|
|
|
export interface DeferredTypeReference extends TypeReference {
|
|
/** @internal */
|
|
node: TypeReferenceNode | ArrayTypeNode | TupleTypeNode;
|
|
/** @internal */
|
|
mapper?: TypeMapper;
|
|
/** @internal */
|
|
instantiations?: Map<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum VarianceFlags {
|
|
Invariant = 0, // Neither covariant nor contravariant
|
|
Covariant = 1 << 0, // Covariant
|
|
Contravariant = 1 << 1, // Contravariant
|
|
Bivariant = Covariant | Contravariant, // Both covariant and contravariant
|
|
Independent = 1 << 2, // Unwitnessed type parameter
|
|
VarianceMask = Invariant | Covariant | Contravariant | Independent, // Mask containing all measured variances without the unmeasurable flag
|
|
Unmeasurable = 1 << 3, // Variance result is unusable - relationship relies on structural comparisons which are not reflected in generic relationships
|
|
Unreliable = 1 << 4, // Variance result is unreliable - checking may produce false negatives, but not false positives
|
|
AllowsStructuralFallback = Unmeasurable | Unreliable,
|
|
}
|
|
|
|
// Generic class and interface types
|
|
export interface GenericType extends InterfaceType, TypeReference {
|
|
/** @internal */
|
|
instantiations: Map<string, TypeReference>; // Generic instantiation cache
|
|
/** @internal */
|
|
variances?: VarianceFlags[]; // Variance of each type parameter
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum ElementFlags {
|
|
Required = 1 << 0, // T
|
|
Optional = 1 << 1, // T?
|
|
Rest = 1 << 2, // ...T[]
|
|
Variadic = 1 << 3, // ...T
|
|
Fixed = Required | Optional,
|
|
Variable = Rest | Variadic,
|
|
NonRequired = Optional | Rest | Variadic,
|
|
NonRest = Required | Optional | Variadic,
|
|
}
|
|
|
|
export interface TupleType extends GenericType {
|
|
elementFlags: readonly ElementFlags[];
|
|
/** Number of required or variadic elements */
|
|
minLength: number;
|
|
/** Number of initial required or optional elements */
|
|
fixedLength: number;
|
|
/**
|
|
* True if tuple has any rest or variadic elements
|
|
*
|
|
* @deprecated Use `.combinedFlags & ElementFlags.Variable` instead
|
|
*/
|
|
hasRestElement: boolean;
|
|
combinedFlags: ElementFlags;
|
|
readonly: boolean;
|
|
labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration | undefined)[];
|
|
}
|
|
|
|
export interface TupleTypeReference extends TypeReference {
|
|
target: TupleType;
|
|
}
|
|
|
|
export interface UnionOrIntersectionType extends Type {
|
|
types: Type[]; // Constituent types
|
|
/** @internal */
|
|
objectFlags: ObjectFlags;
|
|
/** @internal */
|
|
propertyCache?: SymbolTable; // Cache of resolved properties
|
|
/** @internal */
|
|
propertyCacheWithoutObjectFunctionPropertyAugment?: SymbolTable; // Cache of resolved properties that does not augment function or object type properties
|
|
/** @internal */
|
|
resolvedProperties: Symbol[];
|
|
/** @internal */
|
|
resolvedIndexType: IndexType;
|
|
/** @internal */
|
|
resolvedStringIndexType: IndexType;
|
|
/** @internal */
|
|
resolvedBaseConstraint: Type;
|
|
}
|
|
|
|
export interface UnionType extends UnionOrIntersectionType {
|
|
/** @internal */
|
|
resolvedReducedType?: Type;
|
|
/** @internal */
|
|
regularType?: UnionType;
|
|
/** @internal */
|
|
origin?: Type; // Denormalized union, intersection, or index type in which union originates
|
|
/** @internal */
|
|
keyPropertyName?: __String; // Property with unique unit type that exists in every object/intersection in union type
|
|
/** @internal */
|
|
constituentMap?: Map<TypeId, Type>; // Constituents keyed by unit type discriminants
|
|
/** @internal */
|
|
arrayFallbackSignatures?: readonly Signature[]; // Special remapped signature list for unions of arrays
|
|
}
|
|
|
|
export interface IntersectionType extends UnionOrIntersectionType {
|
|
/** @internal */
|
|
resolvedApparentType: Type;
|
|
/** @internal */
|
|
uniqueLiteralFilledInstantiation?: Type; // Instantiation with type parameters mapped to never type
|
|
}
|
|
|
|
export type StructuredType = ObjectType | UnionType | IntersectionType;
|
|
|
|
/** @internal */
|
|
// An instantiated anonymous type has a target and a mapper
|
|
export interface AnonymousType extends ObjectType {
|
|
target?: AnonymousType; // Instantiation target
|
|
mapper?: TypeMapper; // Instantiation mapper
|
|
instantiations?: Map<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
|
|
}
|
|
|
|
/** @internal */
|
|
// A SingleSignatureType may have bespoke outer type parameters to handle free type variable inferences
|
|
export interface SingleSignatureType extends AnonymousType {
|
|
outerTypeParameters?: TypeParameter[];
|
|
}
|
|
|
|
/** @internal */
|
|
export interface InstantiationExpressionType extends AnonymousType {
|
|
node: NodeWithTypeArguments;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface MappedType extends AnonymousType {
|
|
declaration: MappedTypeNode;
|
|
typeParameter?: TypeParameter;
|
|
constraintType?: Type;
|
|
nameType?: Type;
|
|
templateType?: Type;
|
|
modifiersType?: Type;
|
|
resolvedApparentType?: Type;
|
|
containsError?: boolean;
|
|
}
|
|
|
|
export interface EvolvingArrayType extends ObjectType {
|
|
elementType: Type; // Element expressions of evolving array type
|
|
finalArrayType?: Type; // Final array type of evolving array type
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ReverseMappedType extends ObjectType {
|
|
source: Type;
|
|
mappedType: MappedType;
|
|
constraintType: IndexType;
|
|
}
|
|
|
|
/** @internal */
|
|
// Resolved object, union, or intersection type
|
|
// dprint-ignore
|
|
export interface ResolvedType extends ObjectType, UnionOrIntersectionType {
|
|
members: SymbolTable; // Properties by name
|
|
properties: Symbol[]; // Properties
|
|
callSignatures: readonly Signature[]; // Call signatures of type
|
|
constructSignatures: readonly Signature[]; // Construct signatures of type
|
|
indexInfos: readonly IndexInfo[]; // Index signatures
|
|
}
|
|
|
|
/** @internal */
|
|
// Object literals are initially marked fresh. Freshness disappears following an assignment,
|
|
// before a type assertion, or when an object literal's type is widened. The regular
|
|
// version of a fresh type is identical except for the TypeFlags.FreshObjectLiteral flag.
|
|
export interface FreshObjectLiteralType extends ResolvedType {
|
|
regularType: ResolvedType; // Regular version of fresh type
|
|
}
|
|
|
|
/** @internal */
|
|
export interface IterationTypes {
|
|
readonly yieldType: Type;
|
|
readonly returnType: Type;
|
|
readonly nextType: Type;
|
|
}
|
|
|
|
// Just a place to cache element types of iterables and iterators
|
|
/** @internal */
|
|
export interface IterableOrIteratorType extends ObjectType, UnionType {
|
|
iterationTypesOfGeneratorReturnType?: IterationTypes;
|
|
iterationTypesOfAsyncGeneratorReturnType?: IterationTypes;
|
|
iterationTypesOfIterable?: IterationTypes;
|
|
iterationTypesOfIterator?: IterationTypes;
|
|
iterationTypesOfAsyncIterable?: IterationTypes;
|
|
iterationTypesOfAsyncIterator?: IterationTypes;
|
|
iterationTypesOfIteratorResult?: IterationTypes;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PromiseOrAwaitableType extends ObjectType, UnionType {
|
|
promiseTypeOfPromiseConstructor?: Type;
|
|
promisedTypeOfPromise?: Type;
|
|
awaitedTypeOfType?: Type;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SyntheticDefaultModuleType extends Type {
|
|
syntheticType?: Type;
|
|
defaultOnlyType?: Type;
|
|
}
|
|
|
|
export interface InstantiableType extends Type {
|
|
/** @internal */
|
|
resolvedBaseConstraint?: Type;
|
|
/** @internal */
|
|
resolvedIndexType?: IndexType;
|
|
/** @internal */
|
|
resolvedStringIndexType?: IndexType;
|
|
}
|
|
|
|
// Type parameters (TypeFlags.TypeParameter)
|
|
// dprint-ignore
|
|
export interface TypeParameter extends InstantiableType {
|
|
/**
|
|
* Retrieve using getConstraintFromTypeParameter
|
|
*
|
|
* @internal
|
|
*/
|
|
constraint?: Type; // Constraint
|
|
/** @internal */
|
|
default?: Type;
|
|
/** @internal */
|
|
target?: TypeParameter; // Instantiation target
|
|
/** @internal */
|
|
mapper?: TypeMapper; // Instantiation mapper
|
|
/** @internal */
|
|
isThisType?: boolean;
|
|
/** @internal */
|
|
resolvedDefaultType?: Type;
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum AccessFlags {
|
|
None = 0,
|
|
IncludeUndefined = 1 << 0,
|
|
NoIndexSignatures = 1 << 1,
|
|
Writing = 1 << 2,
|
|
CacheSymbol = 1 << 3,
|
|
AllowMissing = 1 << 4,
|
|
ExpressionPosition = 1 << 5,
|
|
ReportDeprecated = 1 << 6,
|
|
SuppressNoImplicitAnyError = 1 << 7,
|
|
Contextual = 1 << 8,
|
|
Persistent = IncludeUndefined,
|
|
}
|
|
|
|
// Indexed access types (TypeFlags.IndexedAccess)
|
|
// Possible forms are T[xxx], xxx[T], or xxx[keyof T], where T is a type variable
|
|
export interface IndexedAccessType extends InstantiableType {
|
|
objectType: Type;
|
|
indexType: Type;
|
|
/** @internal */
|
|
accessFlags: AccessFlags; // Only includes AccessFlags.Persistent
|
|
constraint?: Type;
|
|
simplifiedForReading?: Type;
|
|
simplifiedForWriting?: Type;
|
|
}
|
|
|
|
export type TypeVariable = TypeParameter | IndexedAccessType;
|
|
|
|
/** @internal */
|
|
export const enum IndexFlags {
|
|
None = 0,
|
|
StringsOnly = 1 << 0,
|
|
NoIndexSignatures = 1 << 1,
|
|
NoReducibleCheck = 1 << 2,
|
|
}
|
|
|
|
// keyof T types (TypeFlags.Index)
|
|
export interface IndexType extends InstantiableType {
|
|
type: InstantiableType | UnionOrIntersectionType;
|
|
/** @internal */
|
|
indexFlags: IndexFlags;
|
|
}
|
|
|
|
export interface ConditionalRoot {
|
|
node: ConditionalTypeNode;
|
|
checkType: Type;
|
|
extendsType: Type;
|
|
isDistributive: boolean;
|
|
inferTypeParameters?: TypeParameter[];
|
|
outerTypeParameters?: TypeParameter[];
|
|
instantiations?: Map<string, Type>;
|
|
aliasSymbol?: Symbol;
|
|
aliasTypeArguments?: Type[];
|
|
}
|
|
|
|
// T extends U ? X : Y (TypeFlags.Conditional)
|
|
export interface ConditionalType extends InstantiableType {
|
|
root: ConditionalRoot;
|
|
checkType: Type;
|
|
extendsType: Type;
|
|
resolvedTrueType?: Type;
|
|
resolvedFalseType?: Type;
|
|
/** @internal */
|
|
resolvedInferredTrueType?: Type; // The `trueType` instantiated with the `combinedMapper`, if present
|
|
/** @internal */
|
|
resolvedDefaultConstraint?: Type;
|
|
/** @internal */
|
|
resolvedConstraintOfDistributive?: Type | false;
|
|
/** @internal */
|
|
mapper?: TypeMapper;
|
|
/** @internal */
|
|
combinedMapper?: TypeMapper;
|
|
}
|
|
|
|
export interface TemplateLiteralType extends InstantiableType {
|
|
texts: readonly string[]; // Always one element longer than types
|
|
types: readonly Type[]; // Always at least one element
|
|
}
|
|
|
|
export interface StringMappingType extends InstantiableType {
|
|
symbol: Symbol;
|
|
type: Type;
|
|
}
|
|
|
|
// Type parameter substitution (TypeFlags.Substitution)
|
|
// Substitution types are created for type parameters or indexed access types that occur in the
|
|
// true branch of a conditional type. For example, in 'T extends string ? Foo<T> : Bar<T>', the
|
|
// reference to T in Foo<T> is resolved as a substitution type that substitutes 'string & T' for T.
|
|
// Thus, if Foo has a 'string' constraint on its type parameter, T will satisfy it.
|
|
// Substitution type are also created for NoInfer<T> types. Those are represented as substitution
|
|
// types where the constraint is type 'unknown' (which is never generated for the case above).
|
|
export interface SubstitutionType extends InstantiableType {
|
|
objectFlags: ObjectFlags;
|
|
baseType: Type; // Target type
|
|
constraint: Type; // Constraint that target type is known to satisfy
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum JsxReferenceKind {
|
|
Component,
|
|
Function,
|
|
Mixed,
|
|
}
|
|
|
|
export const enum SignatureKind {
|
|
Call,
|
|
Construct,
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum SignatureFlags {
|
|
None = 0,
|
|
|
|
// Propagating flags
|
|
HasRestParameter = 1 << 0, // Indicates last parameter is rest parameter
|
|
HasLiteralTypes = 1 << 1, // Indicates signature is specialized
|
|
Abstract = 1 << 2, // Indicates signature comes from an abstract class, abstract construct signature, or abstract constructor type
|
|
|
|
// Non-propagating flags
|
|
IsInnerCallChain = 1 << 3, // Indicates signature comes from a CallChain nested in an outer OptionalChain
|
|
IsOuterCallChain = 1 << 4, // Indicates signature comes from a CallChain that is the outermost chain of an optional expression
|
|
IsUntypedSignatureInJSFile = 1 << 5, // Indicates signature is from a js file and has no types
|
|
IsNonInferrable = 1 << 6, // Indicates signature comes from a non-inferrable type
|
|
IsSignatureCandidateForOverloadFailure = 1 << 7,
|
|
|
|
// We do not propagate `IsInnerCallChain` or `IsOuterCallChain` to instantiated signatures, as that would result in us
|
|
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
|
|
// instantiating the return type.
|
|
PropagatingFlags = HasRestParameter | HasLiteralTypes | Abstract | IsUntypedSignatureInJSFile | IsSignatureCandidateForOverloadFailure,
|
|
|
|
CallChainFlags = IsInnerCallChain | IsOuterCallChain,
|
|
}
|
|
|
|
// dprint-ignore
|
|
export interface Signature {
|
|
/** @internal */ flags: SignatureFlags;
|
|
/** @internal */ checker?: TypeChecker;
|
|
declaration?: SignatureDeclaration | JSDocSignature; // Originating declaration
|
|
typeParameters?: readonly TypeParameter[]; // Type parameters (undefined if non-generic)
|
|
parameters: readonly Symbol[]; // Parameters
|
|
thisParameter?: Symbol; // symbol of this-type parameter
|
|
/** @internal */
|
|
// See comment in `instantiateSignature` for why these are set lazily.
|
|
resolvedReturnType?: Type; // Lazily set by `getReturnTypeOfSignature`.
|
|
/** @internal */
|
|
// Lazily set by `getTypePredicateOfSignature`.
|
|
// `undefined` indicates a type predicate that has not yet been computed.
|
|
// Uses a special `noTypePredicate` sentinel value to indicate that there is no type predicate. This looks like a TypePredicate at runtime to avoid polymorphism.
|
|
resolvedTypePredicate?: TypePredicate;
|
|
/** @internal */
|
|
minArgumentCount: number; // Number of non-optional parameters
|
|
/** @internal */
|
|
resolvedMinArgumentCount?: number; // Number of non-optional parameters (excluding trailing `void`)
|
|
/** @internal */
|
|
target?: Signature; // Instantiation target
|
|
/** @internal */
|
|
mapper?: TypeMapper; // Instantiation mapper
|
|
/** @internal */
|
|
compositeSignatures?: Signature[]; // Underlying signatures of a union/intersection signature
|
|
/** @internal */
|
|
compositeKind?: TypeFlags; // TypeFlags.Union if the underlying signatures are from union members, otherwise TypeFlags.Intersection
|
|
/** @internal */
|
|
erasedSignatureCache?: Signature; // Erased version of signature (deferred)
|
|
/** @internal */
|
|
canonicalSignatureCache?: Signature; // Canonical version of signature (deferred)
|
|
/** @internal */
|
|
baseSignatureCache?: Signature; // Base version of signature (deferred)
|
|
/** @internal */
|
|
optionalCallSignatureCache?: { inner?: Signature, outer?: Signature }; // Optional chained call version of signature (deferred)
|
|
/** @internal */
|
|
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
|
|
/** @internal */
|
|
instantiations?: Map<string, Signature>; // Generic signature instantiation cache
|
|
/** @internal */
|
|
implementationSignatureCache?: Signature; // Copy of the signature with fresh type parameters to use in checking the body of a potentially self-referential generic function (deferred)
|
|
}
|
|
|
|
export const enum IndexKind {
|
|
String,
|
|
Number,
|
|
}
|
|
|
|
export interface IndexInfo {
|
|
keyType: Type;
|
|
type: Type;
|
|
isReadonly: boolean;
|
|
declaration?: IndexSignatureDeclaration;
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum TypeMapKind {
|
|
Simple,
|
|
Array,
|
|
Deferred,
|
|
Function,
|
|
Composite,
|
|
Merged,
|
|
}
|
|
|
|
/** @internal */
|
|
export type TypeMapper =
|
|
| { kind: TypeMapKind.Simple; source: Type; target: Type; }
|
|
| { kind: TypeMapKind.Array; sources: readonly Type[]; targets: readonly Type[] | undefined; }
|
|
| { kind: TypeMapKind.Deferred; sources: readonly Type[]; targets: (() => Type)[]; }
|
|
| { kind: TypeMapKind.Function; func: (t: Type) => Type; debugInfo?: () => string; }
|
|
| { kind: TypeMapKind.Composite | TypeMapKind.Merged; mapper1: TypeMapper; mapper2: TypeMapper; };
|
|
|
|
// dprint-ignore
|
|
export const enum InferencePriority {
|
|
None = 0,
|
|
NakedTypeVariable = 1 << 0, // Naked type variable in union or intersection type
|
|
SpeculativeTuple = 1 << 1, // Speculative tuple inference
|
|
SubstituteSource = 1 << 2, // Source of inference originated within a substitution type's substitute
|
|
HomomorphicMappedType = 1 << 3, // Reverse inference for homomorphic mapped type
|
|
PartialHomomorphicMappedType = 1 << 4, // Partial reverse inference for homomorphic mapped type
|
|
MappedTypeConstraint = 1 << 5, // Reverse inference for mapped type
|
|
ContravariantConditional = 1 << 6, // Conditional type in contravariant position
|
|
ReturnType = 1 << 7, // Inference made from return type of generic function
|
|
LiteralKeyof = 1 << 8, // Inference made from a string literal to a keyof T
|
|
NoConstraints = 1 << 9, // Don't infer from constraints of instantiable types
|
|
AlwaysStrict = 1 << 10, // Always use strict rules for contravariant inferences
|
|
MaxValue = 1 << 11, // Seed for inference priority tracking
|
|
|
|
PriorityImpliesCombination = ReturnType | MappedTypeConstraint | LiteralKeyof, // These priorities imply that the resulting type should be a combination of all candidates
|
|
Circularity = -1, // Inference circularity (value less than all other priorities)
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface InferenceInfo {
|
|
typeParameter: TypeParameter; // Type parameter for which inferences are being made
|
|
candidates: Type[] | undefined; // Candidates in covariant positions (or undefined)
|
|
contraCandidates: Type[] | undefined; // Candidates in contravariant positions (or undefined)
|
|
inferredType?: Type; // Cache for resolved inferred type
|
|
priority?: InferencePriority; // Priority of current inference set
|
|
topLevel: boolean; // True if all inferences are to top level occurrences
|
|
isFixed: boolean; // True if inferences are fixed
|
|
impliedArity?: number;
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum InferenceFlags {
|
|
None = 0, // No special inference behaviors
|
|
NoDefault = 1 << 0, // Infer silentNeverType for no inferences (otherwise anyType or unknownType)
|
|
AnyDefault = 1 << 1, // Infer anyType (in JS files) for no inferences (otherwise unknownType)
|
|
SkippedGenericFunction = 1 << 2, // A generic function was skipped during inference
|
|
}
|
|
|
|
/**
|
|
* Ternary values are defined such that
|
|
* x & y picks the lesser in the order False < Unknown < Maybe < True, and
|
|
* x | y picks the greater in the order False < Unknown < Maybe < True.
|
|
* Generally, Ternary.Maybe is used as the result of a relation that depends on itself, and
|
|
* Ternary.Unknown is used as the result of a variance check that depends on itself. We make
|
|
* a distinction because we don't want to cache circular variance check results.
|
|
*
|
|
* @internal
|
|
*/
|
|
export const enum Ternary {
|
|
False = 0,
|
|
Unknown = 1,
|
|
Maybe = 3,
|
|
True = -1,
|
|
}
|
|
|
|
/** @internal */
|
|
export type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary;
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface InferenceContext {
|
|
inferences: InferenceInfo[]; // Inferences made for each type parameter
|
|
signature?: Signature; // Generic signature for which inferences are made (if any)
|
|
flags: InferenceFlags; // Inference flags
|
|
compareTypes: TypeComparer; // Type comparer function
|
|
mapper: TypeMapper; // Mapper that fixes inferences
|
|
nonFixingMapper: TypeMapper; // Mapper that doesn't fix inferences
|
|
returnMapper?: TypeMapper; // Type mapper for inferences from return types (if any)
|
|
inferredTypeParameters?: readonly TypeParameter[]; // Inferred type parameters for function result
|
|
intraExpressionInferenceSites?: IntraExpressionInferenceSite[];
|
|
}
|
|
|
|
/** @internal */
|
|
export interface IntraExpressionInferenceSite {
|
|
node: Expression | MethodDeclaration;
|
|
type: Type;
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface WideningContext {
|
|
parent?: WideningContext; // Parent context
|
|
propertyName?: __String; // Name of property in parent
|
|
siblings?: Type[]; // Types of siblings
|
|
resolvedProperties?: Symbol[]; // Properties occurring in sibling object literals
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum AssignmentDeclarationKind {
|
|
None,
|
|
/// exports.name = expr
|
|
/// module.exports.name = expr
|
|
ExportsProperty,
|
|
/// module.exports = expr
|
|
ModuleExports,
|
|
/// className.prototype.name = expr
|
|
PrototypeProperty,
|
|
/// this.name = expr
|
|
ThisProperty,
|
|
// F.name = expr
|
|
Property,
|
|
// F.prototype = { ... }
|
|
Prototype,
|
|
// Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) });
|
|
// Object.defineProperty(x, 'name', { get: Function, set: Function });
|
|
// Object.defineProperty(x, 'name', { get: Function });
|
|
// Object.defineProperty(x, 'name', { set: Function });
|
|
ObjectDefinePropertyValue,
|
|
// Object.defineProperty(exports || module.exports, 'name', ...);
|
|
ObjectDefinePropertyExports,
|
|
// Object.defineProperty(Foo.prototype, 'name', ...);
|
|
ObjectDefinePrototypeProperty,
|
|
}
|
|
|
|
export interface FileExtensionInfo {
|
|
extension: string;
|
|
isMixedContent: boolean;
|
|
scriptKind?: ScriptKind;
|
|
}
|
|
|
|
export interface DiagnosticMessage {
|
|
key: string;
|
|
category: DiagnosticCategory;
|
|
code: number;
|
|
message: string;
|
|
reportsUnnecessary?: {};
|
|
reportsDeprecated?: {};
|
|
/** @internal */
|
|
elidedInCompatabilityPyramid?: boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface RepopulateModuleNotFoundDiagnosticChain {
|
|
moduleReference: string;
|
|
mode: ResolutionMode;
|
|
packageName: string | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export type RepopulateModeMismatchDiagnosticChain = true;
|
|
|
|
/** @internal */
|
|
export type RepopulateDiagnosticChainInfo = RepopulateModuleNotFoundDiagnosticChain | RepopulateModeMismatchDiagnosticChain;
|
|
|
|
/**
|
|
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
|
|
* It is built from the bottom up, leaving the head to be the "main" diagnostic.
|
|
* While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage,
|
|
* the difference is that messages are all preformatted in DMC.
|
|
*/
|
|
export interface DiagnosticMessageChain {
|
|
messageText: string;
|
|
category: DiagnosticCategory;
|
|
code: number;
|
|
next?: DiagnosticMessageChain[];
|
|
/** @internal */
|
|
repopulateInfo?: () => RepopulateDiagnosticChainInfo;
|
|
/** @internal */
|
|
canonicalHead?: CanonicalDiagnostic;
|
|
}
|
|
|
|
export interface Diagnostic extends DiagnosticRelatedInformation {
|
|
/** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */
|
|
reportsUnnecessary?: {};
|
|
|
|
reportsDeprecated?: {};
|
|
source?: string;
|
|
relatedInformation?: DiagnosticRelatedInformation[];
|
|
/** @internal */ skippedOn?: keyof CompilerOptions;
|
|
/**
|
|
* @internal
|
|
* Used for deduplication and comparison.
|
|
* Whenever it is possible for two diagnostics that report the same problem to be produced with
|
|
* different messages (e.g. "Cannot find name 'foo'" vs "Cannot find name 'foo'. Did you mean 'bar'?"),
|
|
* this property can be set to a canonical message,
|
|
* so that those two diagnostics are appropriately considered to be the same.
|
|
*/
|
|
canonicalHead?: CanonicalDiagnostic;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CanonicalDiagnostic {
|
|
code: number;
|
|
messageText: string;
|
|
}
|
|
|
|
/** @internal */
|
|
export type DiagnosticArguments = (string | number)[];
|
|
|
|
/** @internal */
|
|
export type DiagnosticAndArguments = [message: DiagnosticMessage, ...args: DiagnosticArguments];
|
|
|
|
export interface DiagnosticRelatedInformation {
|
|
category: DiagnosticCategory;
|
|
code: number;
|
|
file: SourceFile | undefined;
|
|
start: number | undefined;
|
|
length: number | undefined;
|
|
messageText: string | DiagnosticMessageChain;
|
|
}
|
|
|
|
export interface DiagnosticWithLocation extends Diagnostic {
|
|
file: SourceFile;
|
|
start: number;
|
|
length: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface DiagnosticWithDetachedLocation extends Diagnostic {
|
|
file: undefined;
|
|
fileName: string;
|
|
start: number;
|
|
length: number;
|
|
}
|
|
|
|
export enum DiagnosticCategory {
|
|
Warning,
|
|
Error,
|
|
Suggestion,
|
|
Message,
|
|
}
|
|
/** @internal */
|
|
export function diagnosticCategoryName(d: { category: DiagnosticCategory; }, lowerCase = true): string {
|
|
const name = DiagnosticCategory[d.category];
|
|
return lowerCase ? name.toLowerCase() : name;
|
|
}
|
|
|
|
export enum ModuleResolutionKind {
|
|
Classic = 1,
|
|
/**
|
|
* @deprecated
|
|
* `NodeJs` was renamed to `Node10` to better reflect the version of Node that it targets.
|
|
* Use the new name or consider switching to a modern module resolution target.
|
|
*/
|
|
NodeJs = 2,
|
|
Node10 = 2,
|
|
// Starting with node12, node's module resolver has significant departures from traditional cjs resolution
|
|
// to better support ECMAScript modules and their use within node - however more features are still being added.
|
|
// TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable
|
|
// version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMAScript 2022.
|
|
// In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target
|
|
Node16 = 3,
|
|
NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`)
|
|
Bundler = 100,
|
|
}
|
|
|
|
export enum ModuleDetectionKind {
|
|
/**
|
|
* Files with imports, exports and/or import.meta are considered modules
|
|
*/
|
|
Legacy = 1,
|
|
/**
|
|
* Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+
|
|
*/
|
|
Auto = 2,
|
|
/**
|
|
* Consider all non-declaration files modules, regardless of present syntax
|
|
*/
|
|
Force = 3,
|
|
}
|
|
|
|
export interface PluginImport {
|
|
name: string;
|
|
}
|
|
|
|
export interface ProjectReference {
|
|
/** A normalized path on disk */
|
|
path: string;
|
|
/** The path as the user originally wrote it */
|
|
originalPath?: string;
|
|
/** @deprecated */
|
|
prepend?: boolean;
|
|
/** True if it is intended that this reference form a circularity */
|
|
circular?: boolean;
|
|
}
|
|
|
|
export enum WatchFileKind {
|
|
FixedPollingInterval,
|
|
PriorityPollingInterval,
|
|
DynamicPriorityPolling,
|
|
FixedChunkSizePolling,
|
|
UseFsEvents,
|
|
UseFsEventsOnParentDirectory,
|
|
}
|
|
|
|
export enum WatchDirectoryKind {
|
|
UseFsEvents,
|
|
FixedPollingInterval,
|
|
DynamicPriorityPolling,
|
|
FixedChunkSizePolling,
|
|
}
|
|
|
|
export enum PollingWatchKind {
|
|
FixedInterval,
|
|
PriorityInterval,
|
|
DynamicPriority,
|
|
FixedChunkSize,
|
|
}
|
|
|
|
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[] | ProjectReference[] | null | undefined; // eslint-disable-line no-restricted-syntax
|
|
|
|
export interface CompilerOptions {
|
|
/** @internal */ all?: boolean;
|
|
allowImportingTsExtensions?: boolean;
|
|
allowJs?: boolean;
|
|
/** @internal */ allowNonTsExtensions?: boolean;
|
|
allowArbitraryExtensions?: boolean;
|
|
allowSyntheticDefaultImports?: boolean;
|
|
allowUmdGlobalAccess?: boolean;
|
|
allowUnreachableCode?: boolean;
|
|
allowUnusedLabels?: boolean;
|
|
alwaysStrict?: boolean; // Always combine with strict property
|
|
baseUrl?: string;
|
|
/**
|
|
* An error if set - this should only go through the -b pipeline and not actually be observed
|
|
*
|
|
* @internal
|
|
*/
|
|
build?: boolean;
|
|
/** @deprecated */
|
|
charset?: string;
|
|
checkJs?: boolean;
|
|
/** @internal */ configFilePath?: string;
|
|
/**
|
|
* configFile is set as non enumerable property so as to avoid checking of json source files
|
|
*
|
|
* @internal
|
|
*/
|
|
readonly configFile?: TsConfigSourceFile;
|
|
customConditions?: string[];
|
|
declaration?: boolean;
|
|
declarationMap?: boolean;
|
|
emitDeclarationOnly?: boolean;
|
|
declarationDir?: string;
|
|
/** @internal */ diagnostics?: boolean;
|
|
/** @internal */ extendedDiagnostics?: boolean;
|
|
disableSizeLimit?: boolean;
|
|
disableSourceOfProjectReferenceRedirect?: boolean;
|
|
disableSolutionSearching?: boolean;
|
|
disableReferencedProjectLoad?: boolean;
|
|
downlevelIteration?: boolean;
|
|
emitBOM?: boolean;
|
|
emitDecoratorMetadata?: boolean;
|
|
exactOptionalPropertyTypes?: boolean;
|
|
experimentalDecorators?: boolean;
|
|
forceConsistentCasingInFileNames?: boolean;
|
|
/** @internal */ generateCpuProfile?: string;
|
|
/** @internal */ generateTrace?: string;
|
|
/** @internal */ help?: boolean;
|
|
ignoreDeprecations?: string;
|
|
importHelpers?: boolean;
|
|
/** @deprecated */
|
|
importsNotUsedAsValues?: ImportsNotUsedAsValues;
|
|
/** @internal */ init?: boolean;
|
|
inlineSourceMap?: boolean;
|
|
inlineSources?: boolean;
|
|
isolatedModules?: boolean;
|
|
isolatedDeclarations?: boolean;
|
|
jsx?: JsxEmit;
|
|
/** @deprecated */
|
|
keyofStringsOnly?: boolean;
|
|
lib?: string[];
|
|
/** @internal */ listEmittedFiles?: boolean;
|
|
/** @internal */ listFiles?: boolean;
|
|
/** @internal */ explainFiles?: boolean;
|
|
/** @internal */ listFilesOnly?: boolean;
|
|
locale?: string;
|
|
mapRoot?: string;
|
|
maxNodeModuleJsDepth?: number;
|
|
module?: ModuleKind;
|
|
moduleResolution?: ModuleResolutionKind;
|
|
moduleSuffixes?: string[];
|
|
moduleDetection?: ModuleDetectionKind;
|
|
newLine?: NewLineKind;
|
|
noEmit?: boolean;
|
|
/** @internal */ noCheck?: boolean;
|
|
/** @internal */ noEmitForJsFiles?: boolean;
|
|
noEmitHelpers?: boolean;
|
|
noEmitOnError?: boolean;
|
|
noErrorTruncation?: boolean;
|
|
noFallthroughCasesInSwitch?: boolean;
|
|
noImplicitAny?: boolean; // Always combine with strict property
|
|
noImplicitReturns?: boolean;
|
|
noImplicitThis?: boolean; // Always combine with strict property
|
|
/** @deprecated */
|
|
noStrictGenericChecks?: boolean;
|
|
noUnusedLocals?: boolean;
|
|
noUnusedParameters?: boolean;
|
|
/** @deprecated */
|
|
noImplicitUseStrict?: boolean;
|
|
noPropertyAccessFromIndexSignature?: boolean;
|
|
assumeChangesOnlyAffectDirectDependencies?: boolean;
|
|
noLib?: boolean;
|
|
noResolve?: boolean;
|
|
/** @internal */
|
|
noDtsResolution?: boolean;
|
|
noUncheckedIndexedAccess?: boolean;
|
|
/** @deprecated */
|
|
out?: string;
|
|
outDir?: string;
|
|
outFile?: string;
|
|
paths?: MapLike<string[]>;
|
|
/**
|
|
* The directory of the config file that specified 'paths'. Used to resolve relative paths when 'baseUrl' is absent.
|
|
*
|
|
* @internal
|
|
*/
|
|
pathsBasePath?: string;
|
|
/** @internal */ plugins?: PluginImport[];
|
|
preserveConstEnums?: boolean;
|
|
noImplicitOverride?: boolean;
|
|
preserveSymlinks?: boolean;
|
|
/** @deprecated */
|
|
preserveValueImports?: boolean;
|
|
/** @internal */ preserveWatchOutput?: boolean;
|
|
project?: string;
|
|
/** @internal */ pretty?: boolean;
|
|
reactNamespace?: string;
|
|
jsxFactory?: string;
|
|
jsxFragmentFactory?: string;
|
|
jsxImportSource?: string;
|
|
composite?: boolean;
|
|
incremental?: boolean;
|
|
tsBuildInfoFile?: string;
|
|
removeComments?: boolean;
|
|
resolvePackageJsonExports?: boolean;
|
|
resolvePackageJsonImports?: boolean;
|
|
rootDir?: string;
|
|
rootDirs?: string[];
|
|
skipLibCheck?: boolean;
|
|
skipDefaultLibCheck?: boolean;
|
|
sourceMap?: boolean;
|
|
sourceRoot?: string;
|
|
strict?: boolean;
|
|
strictFunctionTypes?: boolean; // Always combine with strict property
|
|
strictBindCallApply?: boolean; // Always combine with strict property
|
|
strictNullChecks?: boolean; // Always combine with strict property
|
|
strictPropertyInitialization?: boolean; // Always combine with strict property
|
|
strictBuiltinIteratorReturn?: boolean; // Always combine with strict property
|
|
stripInternal?: boolean;
|
|
/** @deprecated */
|
|
suppressExcessPropertyErrors?: boolean;
|
|
/** @deprecated */
|
|
suppressImplicitAnyIndexErrors?: boolean;
|
|
/** @internal */ suppressOutputPathCheck?: boolean;
|
|
target?: ScriptTarget;
|
|
traceResolution?: boolean;
|
|
useUnknownInCatchVariables?: boolean;
|
|
noUncheckedSideEffectImports?: boolean;
|
|
resolveJsonModule?: boolean;
|
|
types?: string[];
|
|
/** Paths used to compute primary types search locations */
|
|
typeRoots?: string[];
|
|
verbatimModuleSyntax?: boolean;
|
|
/** @internal */ version?: boolean;
|
|
/** @internal */ watch?: boolean;
|
|
esModuleInterop?: boolean;
|
|
/** @internal */ showConfig?: boolean;
|
|
useDefineForClassFields?: boolean;
|
|
/** @internal */ tscBuild?: boolean;
|
|
|
|
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
|
}
|
|
|
|
export interface WatchOptions {
|
|
watchFile?: WatchFileKind;
|
|
watchDirectory?: WatchDirectoryKind;
|
|
fallbackPolling?: PollingWatchKind;
|
|
synchronousWatchDirectory?: boolean;
|
|
excludeDirectories?: string[];
|
|
excludeFiles?: string[];
|
|
|
|
[option: string]: CompilerOptionsValue | undefined;
|
|
}
|
|
|
|
export interface TypeAcquisition {
|
|
enable?: boolean;
|
|
include?: string[];
|
|
exclude?: string[];
|
|
disableFilenameBasedTypeAcquisition?: boolean;
|
|
[option: string]: CompilerOptionsValue | undefined;
|
|
}
|
|
|
|
export enum ModuleKind {
|
|
None = 0,
|
|
CommonJS = 1,
|
|
AMD = 2,
|
|
UMD = 3,
|
|
System = 4,
|
|
|
|
// NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind.
|
|
// Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES
|
|
// module kind).
|
|
ES2015 = 5,
|
|
ES2020 = 6,
|
|
ES2022 = 7,
|
|
ESNext = 99,
|
|
|
|
// Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext
|
|
Node16 = 100,
|
|
NodeNext = 199,
|
|
|
|
// Emit as written
|
|
Preserve = 200,
|
|
}
|
|
|
|
export const enum JsxEmit {
|
|
None = 0,
|
|
Preserve = 1,
|
|
React = 2,
|
|
ReactNative = 3,
|
|
ReactJSX = 4,
|
|
ReactJSXDev = 5,
|
|
}
|
|
|
|
/** @deprecated */
|
|
export const enum ImportsNotUsedAsValues {
|
|
Remove,
|
|
Preserve,
|
|
Error,
|
|
}
|
|
|
|
export const enum NewLineKind {
|
|
CarriageReturnLineFeed = 0,
|
|
LineFeed = 1,
|
|
}
|
|
|
|
export interface LineAndCharacter {
|
|
/** 0-based. */
|
|
line: number;
|
|
/*
|
|
* 0-based. This value denotes the character position in line and is different from the 'column' because of tab characters.
|
|
*/
|
|
character: number;
|
|
}
|
|
|
|
export const enum ScriptKind {
|
|
Unknown = 0,
|
|
JS = 1,
|
|
JSX = 2,
|
|
TS = 3,
|
|
TSX = 4,
|
|
External = 5,
|
|
JSON = 6,
|
|
/**
|
|
* Used on extensions that doesn't define the ScriptKind but the content defines it.
|
|
* Deferred extensions are going to be included in all project contexts.
|
|
*/
|
|
Deferred = 7,
|
|
}
|
|
|
|
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
|
|
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
|
|
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
|
|
export const enum ScriptTarget {
|
|
/** @deprecated */
|
|
ES3 = 0,
|
|
ES5 = 1,
|
|
ES2015 = 2,
|
|
ES2016 = 3,
|
|
ES2017 = 4,
|
|
ES2018 = 5,
|
|
ES2019 = 6,
|
|
ES2020 = 7,
|
|
ES2021 = 8,
|
|
ES2022 = 9,
|
|
ES2023 = 10,
|
|
ESNext = 99,
|
|
JSON = 100,
|
|
Latest = ESNext,
|
|
}
|
|
|
|
export const enum LanguageVariant {
|
|
Standard,
|
|
JSX,
|
|
}
|
|
|
|
/** Either a parsed command line or a parsed tsconfig.json */
|
|
export interface ParsedCommandLine {
|
|
options: CompilerOptions;
|
|
typeAcquisition?: TypeAcquisition;
|
|
fileNames: string[];
|
|
projectReferences?: readonly ProjectReference[];
|
|
watchOptions?: WatchOptions;
|
|
raw?: any;
|
|
errors: Diagnostic[];
|
|
wildcardDirectories?: MapLike<WatchDirectoryFlags>;
|
|
compileOnSave?: boolean;
|
|
}
|
|
|
|
export const enum WatchDirectoryFlags {
|
|
None = 0,
|
|
Recursive = 1 << 0,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ConfigFileSpecs {
|
|
filesSpecs: readonly string[] | undefined;
|
|
/**
|
|
* Present to report errors (user specified specs), validatedIncludeSpecs are used for file name matching
|
|
*/
|
|
includeSpecs: readonly string[] | undefined;
|
|
/**
|
|
* Present to report errors (user specified specs), validatedExcludeSpecs are used for file name matching
|
|
*/
|
|
excludeSpecs: readonly string[] | undefined;
|
|
validatedFilesSpec: readonly string[] | undefined;
|
|
validatedIncludeSpecs: readonly string[] | undefined;
|
|
validatedExcludeSpecs: readonly string[] | undefined;
|
|
validatedFilesSpecBeforeSubstitution: readonly string[] | undefined;
|
|
validatedIncludeSpecsBeforeSubstitution: readonly string[] | undefined;
|
|
validatedExcludeSpecsBeforeSubstitution: readonly string[] | undefined;
|
|
isDefaultIncludeSpec: boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export type ModuleImportResult<T = {}> =
|
|
| { module: T; modulePath?: string; error: undefined; }
|
|
| { module: undefined; modulePath?: undefined; error: { stack?: string; message?: string; }; };
|
|
|
|
export interface CreateProgramOptions {
|
|
rootNames: readonly string[];
|
|
options: CompilerOptions;
|
|
projectReferences?: readonly ProjectReference[];
|
|
host?: CompilerHost;
|
|
oldProgram?: Program;
|
|
configFileParsingDiagnostics?: readonly Diagnostic[];
|
|
/** @internal */
|
|
typeScriptVersion?: string;
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export interface CommandLineOptionBase {
|
|
name: string;
|
|
type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | Map<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
|
|
isFilePath?: boolean; // True if option value is a path or fileName
|
|
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
|
description?: DiagnosticMessage; // The message describing what the command line switch does.
|
|
defaultValueDescription?: string | number | boolean | DiagnosticMessage | undefined; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n.
|
|
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
|
|
isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file
|
|
isCommandLineOnly?: boolean;
|
|
showInSimplifiedHelpView?: boolean;
|
|
category?: DiagnosticMessage;
|
|
strictFlag?: true; // true if the option is one of the flag under strict
|
|
allowJsFlag?: true;
|
|
affectsSourceFile?: true; // true if we should recreate SourceFiles after this option changes
|
|
affectsModuleResolution?: true; // currently same effect as `affectsSourceFile`
|
|
affectsBindDiagnostics?: true; // true if this affects binding (currently same effect as `affectsSourceFile`)
|
|
affectsSemanticDiagnostics?: true; // true if option affects semantic diagnostics
|
|
affectsEmit?: true; // true if the options affects emit
|
|
affectsProgramStructure?: true; // true if program should be reconstructed from root files if option changes and does not affect module resolution as affectsModuleResolution indirectly means program needs to reconstructed
|
|
affectsDeclarationPath?: true; // true if the options affects declaration file path computed
|
|
affectsBuildInfo?: true; // true if this options should be emitted in buildInfo
|
|
transpileOptionValue?: boolean | undefined; // If set this means that the option should be set to this value when transpiling
|
|
extraValidation?: (value: CompilerOptionsValue) => [DiagnosticMessage, ...string[]] | undefined; // Additional validation to be performed for the value to be valid
|
|
disallowNullOrUndefined?: true; // If set option does not allow setting null
|
|
allowConfigDirTemplateSubstitution?: true; // If set option allows substitution of `${configDir}` in the value
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommandLineOptionOfStringType extends CommandLineOptionBase {
|
|
type: "string";
|
|
defaultValueDescription?: string | undefined | DiagnosticMessage;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommandLineOptionOfNumberType extends CommandLineOptionBase {
|
|
type: "number";
|
|
defaultValueDescription: number | undefined | DiagnosticMessage;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommandLineOptionOfBooleanType extends CommandLineOptionBase {
|
|
type: "boolean";
|
|
defaultValueDescription: boolean | undefined | DiagnosticMessage;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
|
|
type: Map<string, number | string>; // an object literal mapping named values to actual values
|
|
defaultValueDescription: number | string | undefined | DiagnosticMessage;
|
|
deprecatedKeys?: Set<string>;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface AlternateModeDiagnostics {
|
|
diagnostic: DiagnosticMessage;
|
|
getOptionsNameMap: () => OptionsNameMap;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface DidYouMeanOptionsDiagnostics {
|
|
alternateMode?: AlternateModeDiagnostics;
|
|
optionDeclarations: CommandLineOption[];
|
|
unknownOptionDiagnostic: DiagnosticMessage;
|
|
unknownDidYouMeanDiagnostic: DiagnosticMessage;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface TsConfigOnlyOption extends CommandLineOptionBase {
|
|
type: "object";
|
|
elementOptions?: Map<string, CommandLineOption>;
|
|
extraKeyDiagnostics?: DidYouMeanOptionsDiagnostics;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommandLineOptionOfListType extends CommandLineOptionBase {
|
|
type: "list" | "listOrElement";
|
|
element: CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption;
|
|
listPreserveFalsyValues?: boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption | CommandLineOptionOfListType;
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum CharacterCodes {
|
|
EOF = -1,
|
|
nullCharacter = 0,
|
|
maxAsciiCharacter = 0x7F,
|
|
|
|
lineFeed = 0x0A, // \n
|
|
carriageReturn = 0x0D, // \r
|
|
lineSeparator = 0x2028,
|
|
paragraphSeparator = 0x2029,
|
|
nextLine = 0x0085,
|
|
|
|
// Unicode 3.0 space characters
|
|
space = 0x0020, // " "
|
|
nonBreakingSpace = 0x00A0, //
|
|
enQuad = 0x2000,
|
|
emQuad = 0x2001,
|
|
enSpace = 0x2002,
|
|
emSpace = 0x2003,
|
|
threePerEmSpace = 0x2004,
|
|
fourPerEmSpace = 0x2005,
|
|
sixPerEmSpace = 0x2006,
|
|
figureSpace = 0x2007,
|
|
punctuationSpace = 0x2008,
|
|
thinSpace = 0x2009,
|
|
hairSpace = 0x200A,
|
|
zeroWidthSpace = 0x200B,
|
|
narrowNoBreakSpace = 0x202F,
|
|
ideographicSpace = 0x3000,
|
|
mathematicalSpace = 0x205F,
|
|
ogham = 0x1680,
|
|
|
|
// Unicode replacement character produced when a byte sequence is invalid
|
|
replacementCharacter = 0xFFFD,
|
|
|
|
_ = 0x5F,
|
|
$ = 0x24,
|
|
|
|
_0 = 0x30,
|
|
_1 = 0x31,
|
|
_2 = 0x32,
|
|
_3 = 0x33,
|
|
_4 = 0x34,
|
|
_5 = 0x35,
|
|
_6 = 0x36,
|
|
_7 = 0x37,
|
|
_8 = 0x38,
|
|
_9 = 0x39,
|
|
|
|
a = 0x61,
|
|
b = 0x62,
|
|
c = 0x63,
|
|
d = 0x64,
|
|
e = 0x65,
|
|
f = 0x66,
|
|
g = 0x67,
|
|
h = 0x68,
|
|
i = 0x69,
|
|
j = 0x6A,
|
|
k = 0x6B,
|
|
l = 0x6C,
|
|
m = 0x6D,
|
|
n = 0x6E,
|
|
o = 0x6F,
|
|
p = 0x70,
|
|
q = 0x71,
|
|
r = 0x72,
|
|
s = 0x73,
|
|
t = 0x74,
|
|
u = 0x75,
|
|
v = 0x76,
|
|
w = 0x77,
|
|
x = 0x78,
|
|
y = 0x79,
|
|
z = 0x7A,
|
|
|
|
A = 0x41,
|
|
B = 0x42,
|
|
C = 0x43,
|
|
D = 0x44,
|
|
E = 0x45,
|
|
F = 0x46,
|
|
G = 0x47,
|
|
H = 0x48,
|
|
I = 0x49,
|
|
J = 0x4A,
|
|
K = 0x4B,
|
|
L = 0x4C,
|
|
M = 0x4D,
|
|
N = 0x4E,
|
|
O = 0x4F,
|
|
P = 0x50,
|
|
Q = 0x51,
|
|
R = 0x52,
|
|
S = 0x53,
|
|
T = 0x54,
|
|
U = 0x55,
|
|
V = 0x56,
|
|
W = 0x57,
|
|
X = 0x58,
|
|
Y = 0x59,
|
|
Z = 0x5a,
|
|
|
|
ampersand = 0x26, // &
|
|
asterisk = 0x2A, // *
|
|
at = 0x40, // @
|
|
backslash = 0x5C, // \
|
|
backtick = 0x60, // `
|
|
bar = 0x7C, // |
|
|
caret = 0x5E, // ^
|
|
closeBrace = 0x7D, // }
|
|
closeBracket = 0x5D, // ]
|
|
closeParen = 0x29, // )
|
|
colon = 0x3A, // :
|
|
comma = 0x2C, // ,
|
|
dot = 0x2E, // .
|
|
doubleQuote = 0x22, // "
|
|
equals = 0x3D, // =
|
|
exclamation = 0x21, // !
|
|
greaterThan = 0x3E, // >
|
|
hash = 0x23, // #
|
|
lessThan = 0x3C, // <
|
|
minus = 0x2D, // -
|
|
openBrace = 0x7B, // {
|
|
openBracket = 0x5B, // [
|
|
openParen = 0x28, // (
|
|
percent = 0x25, // %
|
|
plus = 0x2B, // +
|
|
question = 0x3F, // ?
|
|
semicolon = 0x3B, // ;
|
|
singleQuote = 0x27, // '
|
|
slash = 0x2F, // /
|
|
tilde = 0x7E, // ~
|
|
|
|
backspace = 0x08, // \b
|
|
formFeed = 0x0C, // \f
|
|
byteOrderMark = 0xFEFF,
|
|
tab = 0x09, // \t
|
|
verticalTab = 0x0B, // \v
|
|
}
|
|
|
|
export interface ModuleResolutionHost {
|
|
// TODO: GH#18217 Optional methods frequently used as non-optional
|
|
|
|
fileExists(fileName: string): boolean;
|
|
// readFile function is used to read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json'
|
|
// to determine location of bundled typings for node module
|
|
readFile(fileName: string): string | undefined;
|
|
trace?(s: string): void;
|
|
directoryExists?(directoryName: string): boolean;
|
|
/**
|
|
* Resolve a symbolic link.
|
|
* @see https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options
|
|
*/
|
|
realpath?(path: string): string;
|
|
getCurrentDirectory?(): string;
|
|
getDirectories?(path: string): string[];
|
|
useCaseSensitiveFileNames?: boolean | (() => boolean) | undefined;
|
|
/** @internal */ getGlobalTypingsCacheLocation?(): string | undefined;
|
|
}
|
|
|
|
/**
|
|
* Used by services to specify the minimum host area required to set up source files under any compilation settings
|
|
*/
|
|
export interface MinimalResolutionCacheHost extends ModuleResolutionHost {
|
|
getCompilationSettings(): CompilerOptions;
|
|
getCompilerHost?(): CompilerHost | undefined;
|
|
}
|
|
|
|
/**
|
|
* Represents the result of module resolution.
|
|
* Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off.
|
|
* The Program will then filter results based on these flags.
|
|
*
|
|
* Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred.
|
|
*/
|
|
export interface ResolvedModule {
|
|
/** Path of the file the module was resolved to. */
|
|
resolvedFileName: string;
|
|
/** True if `resolvedFileName` comes from `node_modules`. */
|
|
isExternalLibraryImport?: boolean;
|
|
/**
|
|
* True if the original module reference used a .ts extension to refer directly to a .ts file,
|
|
* which should produce an error during checking if emit is enabled.
|
|
*/
|
|
resolvedUsingTsExtension?: boolean;
|
|
}
|
|
|
|
/**
|
|
* ResolvedModule with an explicitly provided `extension` property.
|
|
* Prefer this over `ResolvedModule`.
|
|
* If changing this, remember to change `moduleResolutionIsEqualTo`.
|
|
*/
|
|
export interface ResolvedModuleFull extends ResolvedModule {
|
|
/**
|
|
* @internal
|
|
* This is a file name with preserved original casing, not a normalized `Path`.
|
|
*/
|
|
readonly originalPath?: string;
|
|
/**
|
|
* Extension of resolvedFileName. This must match what's at the end of resolvedFileName.
|
|
* This is optional for backwards-compatibility, but will be added if not provided.
|
|
*/
|
|
extension: string;
|
|
packageId?: PackageId;
|
|
}
|
|
|
|
/**
|
|
* Unique identifier with a package name and version.
|
|
* If changing this, remember to change `packageIdIsEqual`.
|
|
*/
|
|
export interface PackageId {
|
|
/**
|
|
* Name of the package.
|
|
* Should not include `@types`.
|
|
* If accessing a non-index file, this should include its name e.g. "foo/bar".
|
|
*/
|
|
name: string;
|
|
/**
|
|
* Name of a submodule within this package.
|
|
* May be "".
|
|
*/
|
|
subModuleName: string;
|
|
/** Version of the package, e.g. "1.2.3" */
|
|
version: string;
|
|
/** @internal*/ peerDependencies?: string;
|
|
}
|
|
|
|
export const enum Extension {
|
|
Ts = ".ts",
|
|
Tsx = ".tsx",
|
|
Dts = ".d.ts",
|
|
Js = ".js",
|
|
Jsx = ".jsx",
|
|
Json = ".json",
|
|
TsBuildInfo = ".tsbuildinfo",
|
|
Mjs = ".mjs",
|
|
Mts = ".mts",
|
|
Dmts = ".d.mts",
|
|
Cjs = ".cjs",
|
|
Cts = ".cts",
|
|
Dcts = ".d.cts",
|
|
}
|
|
|
|
export interface ResolvedModuleWithFailedLookupLocations {
|
|
readonly resolvedModule: ResolvedModuleFull | undefined;
|
|
/** @internal */
|
|
failedLookupLocations?: string[];
|
|
/** @internal */
|
|
affectingLocations?: string[];
|
|
/** @internal */
|
|
resolutionDiagnostics?: Diagnostic[];
|
|
/**
|
|
* @internal
|
|
* Used to issue a better diagnostic when an unresolvable module may
|
|
* have been resolvable under different module resolution settings.
|
|
*/
|
|
alternateResult?: string;
|
|
}
|
|
|
|
export interface ResolvedTypeReferenceDirective {
|
|
// True if the type declaration file was found in a primary lookup location
|
|
primary: boolean;
|
|
// The location of the .d.ts file we located, or undefined if resolution failed
|
|
resolvedFileName: string | undefined;
|
|
/**
|
|
* @internal
|
|
* The location of the symlink to the .d.ts file we found, if `resolvedFileName` was the realpath.
|
|
* This is a file name with preserved original casing, not a normalized `Path`.
|
|
*/
|
|
originalPath?: string;
|
|
packageId?: PackageId;
|
|
/** True if `resolvedFileName` comes from `node_modules`. */
|
|
isExternalLibraryImport?: boolean;
|
|
}
|
|
|
|
export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
|
readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined;
|
|
/** @internal */ failedLookupLocations?: string[];
|
|
/** @internal */ affectingLocations?: string[];
|
|
/** @internal */ resolutionDiagnostics?: Diagnostic[];
|
|
}
|
|
|
|
/** @internal */
|
|
export type HasInvalidatedResolutions = (sourceFile: Path) => boolean;
|
|
/** @internal */
|
|
export type HasInvalidatedLibResolutions = (libFileName: string) => boolean;
|
|
/** @internal */
|
|
export type HasChangedAutomaticTypeDirectiveNames = () => boolean;
|
|
|
|
export interface CompilerHost extends ModuleResolutionHost {
|
|
getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
|
|
getSourceFileByPath?(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
|
|
getCancellationToken?(): CancellationToken;
|
|
getDefaultLibFileName(options: CompilerOptions): string;
|
|
getDefaultLibLocation?(): string;
|
|
writeFile: WriteFileCallback;
|
|
getCurrentDirectory(): string;
|
|
getCanonicalFileName(fileName: string): string;
|
|
useCaseSensitiveFileNames(): boolean;
|
|
getNewLine(): string;
|
|
readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[];
|
|
|
|
/*
|
|
* CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of
|
|
* module name resolution) or provide implementation for methods from ModuleResolutionHost (in this case compiler
|
|
* will apply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions).
|
|
* If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just
|
|
* 'throw new Error("NotImplemented")'
|
|
*/
|
|
/** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */
|
|
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
|
|
/**
|
|
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
|
|
*/
|
|
getModuleResolutionCache?(): ModuleResolutionCache | undefined;
|
|
/**
|
|
* @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext
|
|
*
|
|
* This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
|
|
*/
|
|
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[];
|
|
resolveModuleNameLiterals?(
|
|
moduleLiterals: readonly StringLiteralLike[],
|
|
containingFile: string,
|
|
redirectedReference: ResolvedProjectReference | undefined,
|
|
options: CompilerOptions,
|
|
containingSourceFile: SourceFile,
|
|
reusedNames: readonly StringLiteralLike[] | undefined,
|
|
): readonly ResolvedModuleWithFailedLookupLocations[];
|
|
resolveTypeReferenceDirectiveReferences?<T extends FileReference | string>(
|
|
typeDirectiveReferences: readonly T[],
|
|
containingFile: string,
|
|
redirectedReference: ResolvedProjectReference | undefined,
|
|
options: CompilerOptions,
|
|
containingSourceFile: SourceFile | undefined,
|
|
reusedNames: readonly T[] | undefined,
|
|
): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[];
|
|
/** @internal */
|
|
resolveLibrary?(
|
|
libraryName: string,
|
|
resolveFrom: string,
|
|
options: CompilerOptions,
|
|
libFileName: string,
|
|
): ResolvedModuleWithFailedLookupLocations;
|
|
/**
|
|
* If provided along with custom resolveLibrary, used to determine if we should redo library resolutions
|
|
* @internal
|
|
*/
|
|
hasInvalidatedLibResolutions?(libFileName: string): boolean;
|
|
getEnvironmentVariable?(name: string): string | undefined;
|
|
/** @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean, newSourceFileByResolvedPath: SourceFile | undefined): void;
|
|
/** @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void;
|
|
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
|
|
hasInvalidatedResolutions?(filePath: Path): boolean;
|
|
/** @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames;
|
|
createHash?(data: string): string;
|
|
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
|
|
/** @internal */ useSourceOfProjectReferenceRedirect?(): boolean;
|
|
|
|
// TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesn't use compilerHost as base
|
|
/** @internal */ createDirectory?(directory: string): void;
|
|
/** @internal */ getSymlinkCache?(): SymlinkCache;
|
|
|
|
// For testing:
|
|
/** @internal */ storeSignatureInfo?: boolean;
|
|
/** @internal */ getBuildInfo?(fileName: string, configFilePath: string | undefined): BuildInfo | undefined;
|
|
|
|
jsDocParsingMode?: JSDocParsingMode;
|
|
}
|
|
|
|
/** true if --out otherwise source file name *
|
|
* @internal
|
|
*/
|
|
export type SourceOfProjectReferenceRedirect = string | true;
|
|
|
|
/** @internal */
|
|
export const enum TransformFlags {
|
|
None = 0,
|
|
|
|
// Facts
|
|
// - Flags used to indicate that a node or subtree contains syntax that requires transformation.
|
|
ContainsTypeScript = 1 << 0,
|
|
ContainsJsx = 1 << 1,
|
|
ContainsESNext = 1 << 2,
|
|
ContainsES2022 = 1 << 3,
|
|
ContainsES2021 = 1 << 4,
|
|
ContainsES2020 = 1 << 5,
|
|
ContainsES2019 = 1 << 6,
|
|
ContainsES2018 = 1 << 7,
|
|
ContainsES2017 = 1 << 8,
|
|
ContainsES2016 = 1 << 9,
|
|
ContainsES2015 = 1 << 10,
|
|
ContainsGenerator = 1 << 11,
|
|
ContainsDestructuringAssignment = 1 << 12,
|
|
|
|
// Markers
|
|
// - Flags used to indicate that a subtree contains a specific transformation.
|
|
ContainsTypeScriptClassSyntax = 1 << 13, // Property Initializers, Parameter Property Initializers
|
|
ContainsLexicalThis = 1 << 14,
|
|
ContainsRestOrSpread = 1 << 15,
|
|
ContainsObjectRestOrSpread = 1 << 16,
|
|
ContainsComputedPropertyName = 1 << 17,
|
|
ContainsBlockScopedBinding = 1 << 18,
|
|
ContainsBindingPattern = 1 << 19,
|
|
ContainsYield = 1 << 20,
|
|
ContainsAwait = 1 << 21,
|
|
ContainsHoistedDeclarationOrCompletion = 1 << 22,
|
|
ContainsDynamicImport = 1 << 23,
|
|
ContainsClassFields = 1 << 24,
|
|
ContainsDecorators = 1 << 25,
|
|
ContainsPossibleTopLevelAwait = 1 << 26,
|
|
ContainsLexicalSuper = 1 << 27,
|
|
ContainsUpdateExpressionForIdentifier = 1 << 28,
|
|
ContainsPrivateIdentifierInExpression = 1 << 29,
|
|
|
|
HasComputedFlags = 1 << 31, // Transform flags have been computed.
|
|
|
|
// Assertions
|
|
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
|
|
AssertTypeScript = ContainsTypeScript,
|
|
AssertJsx = ContainsJsx,
|
|
AssertESNext = ContainsESNext,
|
|
AssertES2022 = ContainsES2022,
|
|
AssertES2021 = ContainsES2021,
|
|
AssertES2020 = ContainsES2020,
|
|
AssertES2019 = ContainsES2019,
|
|
AssertES2018 = ContainsES2018,
|
|
AssertES2017 = ContainsES2017,
|
|
AssertES2016 = ContainsES2016,
|
|
AssertES2015 = ContainsES2015,
|
|
AssertGenerator = ContainsGenerator,
|
|
AssertDestructuringAssignment = ContainsDestructuringAssignment,
|
|
|
|
// Scope Exclusions
|
|
// - Bitmasks that exclude flags from propagating out of a specific context
|
|
// into the subtree flags of their container.
|
|
OuterExpressionExcludes = HasComputedFlags,
|
|
PropertyAccessExcludes = OuterExpressionExcludes,
|
|
NodeExcludes = PropertyAccessExcludes,
|
|
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
|
FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
|
ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait,
|
|
MethodOrAccessorExcludes = NodeExcludes | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
|
|
PropertyExcludes = NodeExcludes | ContainsLexicalThis | ContainsLexicalSuper,
|
|
ClassExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName,
|
|
ModuleExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsLexicalSuper | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion | ContainsPossibleTopLevelAwait,
|
|
TypeExcludes = ~ContainsTypeScript,
|
|
ObjectLiteralExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName | ContainsObjectRestOrSpread,
|
|
ArrayLiteralOrCallOrNewExcludes = NodeExcludes | ContainsRestOrSpread,
|
|
VariableDeclarationListExcludes = NodeExcludes | ContainsBindingPattern | ContainsObjectRestOrSpread,
|
|
ParameterExcludes = NodeExcludes,
|
|
CatchClauseExcludes = NodeExcludes | ContainsObjectRestOrSpread,
|
|
BindingPatternExcludes = NodeExcludes | ContainsRestOrSpread,
|
|
ContainsLexicalThisOrSuper = ContainsLexicalThis | ContainsLexicalSuper,
|
|
|
|
// Propagating flags
|
|
// - Bitmasks for flags that should propagate from a child
|
|
PropertyNamePropagatingFlags = ContainsLexicalThis | ContainsLexicalSuper,
|
|
// Masks
|
|
// - Additional bitmasks
|
|
}
|
|
|
|
export interface SourceMapRange extends TextRange {
|
|
source?: SourceMapSource;
|
|
}
|
|
|
|
export interface SourceMapSource {
|
|
fileName: string;
|
|
text: string;
|
|
/** @internal */ lineMap: readonly number[];
|
|
skipTrivia?: (pos: number) => number;
|
|
}
|
|
|
|
/** @internal */
|
|
// NOTE: Any new properties should be accounted for in `mergeEmitNode` in factory/nodeFactory.ts
|
|
// dprint-ignore
|
|
export interface EmitNode {
|
|
flags: EmitFlags; // Flags that customize emit
|
|
internalFlags: InternalEmitFlags; // Internal flags that customize emit
|
|
annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup.
|
|
leadingComments?: SynthesizedComment[]; // Synthesized leading comments
|
|
trailingComments?: SynthesizedComment[]; // Synthesized trailing comments
|
|
commentRange?: TextRange; // The text range to use when emitting leading or trailing comments
|
|
sourceMapRange?: SourceMapRange; // The text range to use when emitting leading or trailing source mappings
|
|
tokenSourceMapRanges?: (SourceMapRange | undefined)[]; // The text range to use when emitting source mappings for tokens
|
|
constantValue?: string | number; // The constant value of an expression
|
|
externalHelpersModuleName?: Identifier; // The local name for an imported helpers module
|
|
externalHelpers?: boolean;
|
|
helpers?: EmitHelper[]; // Emit helpers for the node
|
|
startsOnNewLine?: boolean; // If the node should begin on a new line
|
|
snippetElement?: SnippetElement; // Snippet element of the node
|
|
typeNode?: TypeNode; // VariableDeclaration type
|
|
classThis?: Identifier; // Identifier that points to a captured static `this` for a class which may be updated after decorators are applied
|
|
assignedName?: Expression; // Expression used as the assigned name of a class or function
|
|
identifierTypeArguments?: NodeArray<TypeNode | TypeParameterDeclaration>; // Only defined on synthesized identifiers. Though not syntactically valid, used in emitting diagnostics, quickinfo, and signature help.
|
|
autoGenerate: AutoGenerateInfo | undefined; // Used for auto-generated identifiers and private identifiers.
|
|
generatedImportReference?: ImportSpecifier; // Reference to the generated import specifier this identifier refers to
|
|
}
|
|
|
|
/** @internal */
|
|
export type SnippetElement = TabStop | Placeholder;
|
|
|
|
/** @internal */
|
|
export interface TabStop {
|
|
kind: SnippetKind.TabStop;
|
|
order: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface Placeholder {
|
|
kind: SnippetKind.Placeholder;
|
|
order: number;
|
|
}
|
|
|
|
// Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum SnippetKind {
|
|
TabStop, // `$1`, `$2`
|
|
Placeholder, // `${1:foo}`
|
|
Choice, // `${1|one,two,three|}`
|
|
Variable, // `$name`, `${name:default}`
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum EmitFlags {
|
|
None = 0,
|
|
SingleLine = 1 << 0, // The contents of this node should be emitted on a single line.
|
|
MultiLine = 1 << 1,
|
|
AdviseOnEmitNode = 1 << 2, // The printer should invoke the onEmitNode callback when printing this node.
|
|
NoSubstitution = 1 << 3, // Disables further substitution of an expression.
|
|
CapturesThis = 1 << 4, // The function captures a lexical `this`
|
|
NoLeadingSourceMap = 1 << 5, // Do not emit a leading source map location for this node.
|
|
NoTrailingSourceMap = 1 << 6, // Do not emit a trailing source map location for this node.
|
|
NoSourceMap = NoLeadingSourceMap | NoTrailingSourceMap, // Do not emit a source map location for this node.
|
|
NoNestedSourceMaps = 1 << 7, // Do not emit source map locations for children of this node.
|
|
NoTokenLeadingSourceMaps = 1 << 8, // Do not emit leading source map location for token nodes.
|
|
NoTokenTrailingSourceMaps = 1 << 9, // Do not emit trailing source map location for token nodes.
|
|
NoTokenSourceMaps = NoTokenLeadingSourceMaps | NoTokenTrailingSourceMaps, // Do not emit source map locations for tokens of this node.
|
|
NoLeadingComments = 1 << 10, // Do not emit leading comments for this node.
|
|
NoTrailingComments = 1 << 11, // Do not emit trailing comments for this node.
|
|
NoComments = NoLeadingComments | NoTrailingComments, // Do not emit comments for this node.
|
|
NoNestedComments = 1 << 12,
|
|
HelperName = 1 << 13, // The Identifier refers to an *unscoped* emit helper (one that is emitted at the top of the file)
|
|
ExportName = 1 << 14, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
|
LocalName = 1 << 15, // Ensure an export prefix is not added for an identifier that points to an exported declaration.
|
|
InternalName = 1 << 16, // The name is internal to an ES5 class body function.
|
|
Indented = 1 << 17, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
|
NoIndentation = 1 << 18, // Do not indent the node.
|
|
AsyncFunctionBody = 1 << 19,
|
|
ReuseTempVariableScope = 1 << 20, // Reuse the existing temp variable scope during emit.
|
|
CustomPrologue = 1 << 21, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
|
|
NoHoisting = 1 << 22, // Do not hoist this declaration in --module system
|
|
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
|
NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions.
|
|
}
|
|
|
|
// dprint-ignore
|
|
/** @internal */
|
|
export const enum InternalEmitFlags {
|
|
None = 0,
|
|
TypeScriptClassWrapper = 1 << 0, // The node is an IIFE class wrapper created by the ts transform.
|
|
NeverApplyImportHelper = 1 << 1, // Indicates the node should never be wrapped with an import star helper (because, for example, it imports tslib itself)
|
|
IgnoreSourceNewlines = 1 << 2, // Overrides `printerOptions.preserveSourceNewlines` to print this node (and all descendants) with default whitespace.
|
|
Immutable = 1 << 3, // Indicates a node is a singleton intended to be reused in multiple locations. Any attempt to make further changes to the node will result in an error.
|
|
IndirectCall = 1 << 4, // Emit CallExpression as an indirect call: `(0, f)()`
|
|
TransformPrivateStaticElements = 1 << 5, // Indicates static private elements in a file or class should be transformed regardless of --target (used by esDecorators transform)
|
|
}
|
|
|
|
// dprint-ignore
|
|
export interface EmitHelperBase {
|
|
readonly name: string; // A unique name for this helper.
|
|
readonly scoped: boolean; // Indicates whether the helper MUST be emitted in the current scope.
|
|
readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); // ES3-compatible raw script text, or a function yielding such a string
|
|
readonly priority?: number; // Helpers with a higher priority are emitted earlier than other helpers on the node.
|
|
readonly dependencies?: EmitHelper[]
|
|
}
|
|
|
|
export interface ScopedEmitHelper extends EmitHelperBase {
|
|
readonly scoped: true;
|
|
}
|
|
|
|
// dprint-ignore
|
|
export interface UnscopedEmitHelper extends EmitHelperBase {
|
|
readonly scoped: false; // Indicates whether the helper MUST be emitted in the current scope.
|
|
/** @internal */
|
|
readonly importName?: string; // The name of the helper to use when importing via `--importHelpers`.
|
|
readonly text: string; // ES3-compatible raw script text, or a function yielding such a string
|
|
}
|
|
|
|
export type EmitHelper = ScopedEmitHelper | UnscopedEmitHelper;
|
|
|
|
export type EmitHelperUniqueNameCallback = (name: string) => string;
|
|
|
|
/** @internal */
|
|
export type LanugageFeatures =
|
|
// ES2015 Features
|
|
| "Classes"
|
|
| "ForOf"
|
|
| "Generators"
|
|
| "Iteration"
|
|
| "SpreadElements"
|
|
| "RestElements"
|
|
| "TaggedTemplates"
|
|
| "DestructuringAssignment"
|
|
| "BindingPatterns"
|
|
| "ArrowFunctions"
|
|
| "BlockScopedVariables"
|
|
| "ObjectAssign"
|
|
| "RegularExpressionFlagsUnicode"
|
|
| "RegularExpressionFlagsSticky"
|
|
// ES2016 Features
|
|
| "Exponentiation" // `x ** y`
|
|
// ES2017 Features
|
|
| "AsyncFunctions" // `async function f() {}`
|
|
// ES2018 Features
|
|
| "ForAwaitOf" // `for await (const x of y)`
|
|
| "AsyncGenerators" // `async function * f() { }`
|
|
| "AsyncIteration" // `Symbol.asyncIterator`
|
|
| "ObjectSpreadRest" // `{ ...obj }`
|
|
| "RegularExpressionFlagsDotAll"
|
|
// ES2019 Features
|
|
| "BindinglessCatch" // `try { } catch { }`
|
|
// ES2020 Features
|
|
| "BigInt" // `0n`
|
|
| "NullishCoalesce" // `a ?? b`
|
|
| "OptionalChaining" // `a?.b`
|
|
// ES2021 Features
|
|
| "LogicalAssignment" // `a ||= b`| `a &&= b`| `a ??= b`
|
|
// ES2022 Features
|
|
| "TopLevelAwait"
|
|
| "ClassFields"
|
|
| "PrivateNamesAndClassStaticBlocks" // `class C { static {} #x = y| #m() {} }`| `#x in y`
|
|
| "RegularExpressionFlagsHasIndices"
|
|
// ES2023 Features
|
|
| "ShebangComments"
|
|
// Upcoming Features
|
|
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
|
|
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
|
|
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
|
|
| "UsingAndAwaitUsing"
|
|
| "ClassAndClassElementDecorators" // `using x = y`, `await using x = y`
|
|
| "RegularExpressionFlagsUnicodeSets" // `@dec class C {}`, `class C { @dec m() {} }`
|
|
;
|
|
|
|
/**
|
|
* Indicates the minimum `ScriptTarget` (inclusive) after which a specific language feature is no longer transpiled.
|
|
*
|
|
* @internal
|
|
*/
|
|
export const LanguageFeatureMinimumTarget: Record<LanugageFeatures, ScriptTarget> = {
|
|
Classes: ScriptTarget.ES2015,
|
|
ForOf: ScriptTarget.ES2015,
|
|
Generators: ScriptTarget.ES2015,
|
|
Iteration: ScriptTarget.ES2015,
|
|
SpreadElements: ScriptTarget.ES2015,
|
|
RestElements: ScriptTarget.ES2015,
|
|
TaggedTemplates: ScriptTarget.ES2015,
|
|
DestructuringAssignment: ScriptTarget.ES2015,
|
|
BindingPatterns: ScriptTarget.ES2015,
|
|
ArrowFunctions: ScriptTarget.ES2015,
|
|
BlockScopedVariables: ScriptTarget.ES2015,
|
|
ObjectAssign: ScriptTarget.ES2015,
|
|
RegularExpressionFlagsUnicode: ScriptTarget.ES2015,
|
|
RegularExpressionFlagsSticky: ScriptTarget.ES2015,
|
|
Exponentiation: ScriptTarget.ES2016,
|
|
AsyncFunctions: ScriptTarget.ES2017,
|
|
ForAwaitOf: ScriptTarget.ES2018,
|
|
AsyncGenerators: ScriptTarget.ES2018,
|
|
AsyncIteration: ScriptTarget.ES2018,
|
|
ObjectSpreadRest: ScriptTarget.ES2018,
|
|
RegularExpressionFlagsDotAll: ScriptTarget.ES2018,
|
|
BindinglessCatch: ScriptTarget.ES2019,
|
|
BigInt: ScriptTarget.ES2020,
|
|
NullishCoalesce: ScriptTarget.ES2020,
|
|
OptionalChaining: ScriptTarget.ES2020,
|
|
LogicalAssignment: ScriptTarget.ES2021,
|
|
TopLevelAwait: ScriptTarget.ES2022,
|
|
ClassFields: ScriptTarget.ES2022,
|
|
PrivateNamesAndClassStaticBlocks: ScriptTarget.ES2022,
|
|
RegularExpressionFlagsHasIndices: ScriptTarget.ES2022,
|
|
ShebangComments: ScriptTarget.ESNext,
|
|
UsingAndAwaitUsing: ScriptTarget.ESNext,
|
|
ClassAndClassElementDecorators: ScriptTarget.ESNext,
|
|
RegularExpressionFlagsUnicodeSets: ScriptTarget.ESNext,
|
|
};
|
|
|
|
// dprint-ignore
|
|
/**
|
|
* Used by the checker, this enum keeps track of external emit helpers that should be type
|
|
* checked.
|
|
*
|
|
* @internal
|
|
*/
|
|
export const enum ExternalEmitHelpers {
|
|
Extends = 1 << 0, // __extends (used by the ES2015 class transformation)
|
|
Assign = 1 << 1, // __assign (used by Jsx and ESNext object spread transformations)
|
|
Rest = 1 << 2, // __rest (used by ESNext object rest transformation)
|
|
Decorate = 1 << 3, // __decorate (used by TypeScript decorators transformation)
|
|
ESDecorateAndRunInitializers = Decorate, // __esDecorate and __runInitializers (used by ECMAScript decorators transformation)
|
|
Metadata = 1 << 4, // __metadata (used by TypeScript decorators transformation)
|
|
Param = 1 << 5, // __param (used by TypeScript decorators transformation)
|
|
Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation)
|
|
Generator = 1 << 7, // __generator (used by ES2015 generator transformation)
|
|
Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations)
|
|
Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation)
|
|
SpreadArray = 1 << 10, // __spreadArray (used by ES2015 array spread and argument list spread transformations)
|
|
Await = 1 << 11, // __await (used by ES2017 async generator transformation)
|
|
AsyncGenerator = 1 << 12, // __asyncGenerator (used by ES2017 async generator transformation)
|
|
AsyncDelegator = 1 << 13, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
|
AsyncValues = 1 << 14, // __asyncValues (used by ES2017 for..await..of transformation)
|
|
ExportStar = 1 << 15, // __exportStar (used by CommonJS/AMD/UMD module transformation)
|
|
ImportStar = 1 << 16, // __importStar (used by CommonJS/AMD/UMD module transformation)
|
|
ImportDefault = 1 << 17, // __importStar (used by CommonJS/AMD/UMD module transformation)
|
|
MakeTemplateObject = 1 << 18, // __makeTemplateObject (used for constructing template string array objects)
|
|
ClassPrivateFieldGet = 1 << 19, // __classPrivateFieldGet (used by the class private field transformation)
|
|
ClassPrivateFieldSet = 1 << 20, // __classPrivateFieldSet (used by the class private field transformation)
|
|
ClassPrivateFieldIn = 1 << 21, // __classPrivateFieldIn (used by the class private field transformation)
|
|
SetFunctionName = 1 << 22, // __setFunctionName (used by class fields and ECMAScript decorators)
|
|
PropKey = 1 << 23, // __propKey (used by class fields and ECMAScript decorators)
|
|
AddDisposableResourceAndDisposeResources = 1 << 24, // __addDisposableResource and __disposeResources (used by ESNext transformations)
|
|
|
|
FirstEmitHelper = Extends,
|
|
LastEmitHelper = AddDisposableResourceAndDisposeResources,
|
|
|
|
// Helpers included by ES2015 for..of
|
|
ForOfIncludes = Values,
|
|
|
|
// Helpers included by ES2017 for..await..of
|
|
ForAwaitOfIncludes = AsyncValues,
|
|
|
|
// Helpers included by ES2017 async generators
|
|
AsyncGeneratorIncludes = Await | AsyncGenerator,
|
|
|
|
// Helpers included by yield* in ES2017 async generators
|
|
AsyncDelegatorIncludes = Await | AsyncDelegator | AsyncValues,
|
|
|
|
// Helpers included by ES2015 spread
|
|
SpreadIncludes = Read | SpreadArray,
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum EmitHint {
|
|
SourceFile, // Emitting a SourceFile
|
|
Expression, // Emitting an Expression
|
|
IdentifierName, // Emitting an IdentifierName
|
|
MappedTypeParameter, // Emitting a TypeParameterDeclaration inside of a MappedTypeNode
|
|
Unspecified, // Emitting an otherwise unspecified node
|
|
EmbeddedStatement, // Emitting an embedded statement
|
|
JsxAttributeValue, // Emitting a JSX attribute value
|
|
ImportTypeNodeAttributes,// Emitting attributes as part of an ImportTypeNode
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SourceFileMayBeEmittedHost {
|
|
getCompilerOptions(): CompilerOptions;
|
|
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
|
getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined;
|
|
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
|
getCurrentDirectory(): string;
|
|
getCanonicalFileName: GetCanonicalFileName;
|
|
useCaseSensitiveFileNames(): boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost, SourceFileMayBeEmittedHost {
|
|
getSourceFiles(): readonly SourceFile[];
|
|
useCaseSensitiveFileNames(): boolean;
|
|
getCurrentDirectory(): string;
|
|
|
|
getCommonSourceDirectory(): string;
|
|
getCanonicalFileName(fileName: string): string;
|
|
|
|
isEmitBlocked(emitFileName: string): boolean;
|
|
shouldTransformImportCall(sourceFile: SourceFile): boolean;
|
|
getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind;
|
|
|
|
writeFile: WriteFileCallback;
|
|
getBuildInfo(): BuildInfo | undefined;
|
|
getSourceFileFromReference: Program["getSourceFileFromReference"];
|
|
readonly redirectTargetsMap: RedirectTargetsMap;
|
|
createHash?(data: string): string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PropertyDescriptorAttributes {
|
|
enumerable?: boolean | Expression;
|
|
configurable?: boolean | Expression;
|
|
writable?: boolean | Expression;
|
|
value?: Expression;
|
|
get?: Expression;
|
|
set?: Expression;
|
|
}
|
|
|
|
export const enum OuterExpressionKinds {
|
|
Parentheses = 1 << 0,
|
|
TypeAssertions = 1 << 1,
|
|
NonNullAssertions = 1 << 2,
|
|
PartiallyEmittedExpressions = 1 << 3,
|
|
ExpressionsWithTypeArguments = 1 << 4,
|
|
|
|
Assertions = TypeAssertions | NonNullAssertions,
|
|
All = Parentheses | Assertions | PartiallyEmittedExpressions | ExpressionsWithTypeArguments,
|
|
|
|
ExcludeJSDocTypeAssertion = 1 << 31,
|
|
}
|
|
|
|
/** @internal */
|
|
export type OuterExpression =
|
|
| ParenthesizedExpression
|
|
| TypeAssertionExpression
|
|
| SatisfiesExpression
|
|
| AsExpression
|
|
| NonNullExpression
|
|
| ExpressionWithTypeArguments
|
|
| PartiallyEmittedExpression;
|
|
|
|
/** @internal */
|
|
export type WrappedExpression<T extends Expression> =
|
|
| OuterExpression & { readonly expression: WrappedExpression<T>; }
|
|
| T;
|
|
|
|
/** @internal */
|
|
export type TypeOfTag = "null" | "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function";
|
|
|
|
/** @internal */
|
|
export interface CallBinding {
|
|
target: LeftHandSideExpression;
|
|
thisArg: Expression;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ParenthesizerRules {
|
|
getParenthesizeLeftSideOfBinaryForOperator(binaryOperator: SyntaxKind): (leftSide: Expression) => Expression;
|
|
getParenthesizeRightSideOfBinaryForOperator(binaryOperator: SyntaxKind): (rightSide: Expression) => Expression;
|
|
parenthesizeLeftSideOfBinary(binaryOperator: SyntaxKind, leftSide: Expression): Expression;
|
|
parenthesizeRightSideOfBinary(binaryOperator: SyntaxKind, leftSide: Expression | undefined, rightSide: Expression): Expression;
|
|
parenthesizeExpressionOfComputedPropertyName(expression: Expression): Expression;
|
|
parenthesizeConditionOfConditionalExpression(condition: Expression): Expression;
|
|
parenthesizeBranchOfConditionalExpression(branch: Expression): Expression;
|
|
parenthesizeExpressionOfExportDefault(expression: Expression): Expression;
|
|
parenthesizeExpressionOfNew(expression: Expression): LeftHandSideExpression;
|
|
parenthesizeLeftSideOfAccess(expression: Expression, optionalChain?: boolean): LeftHandSideExpression;
|
|
parenthesizeOperandOfPostfixUnary(operand: Expression): LeftHandSideExpression;
|
|
parenthesizeOperandOfPrefixUnary(operand: Expression): UnaryExpression;
|
|
parenthesizeExpressionsOfCommaDelimitedList(elements: readonly Expression[]): NodeArray<Expression>;
|
|
parenthesizeExpressionForDisallowedComma(expression: Expression): Expression;
|
|
parenthesizeExpressionOfExpressionStatement(expression: Expression): Expression;
|
|
parenthesizeConciseBodyOfArrowFunction(body: Expression): Expression;
|
|
parenthesizeConciseBodyOfArrowFunction(body: ConciseBody): ConciseBody;
|
|
parenthesizeCheckTypeOfConditionalType(type: TypeNode): TypeNode;
|
|
parenthesizeExtendsTypeOfConditionalType(type: TypeNode): TypeNode;
|
|
parenthesizeOperandOfTypeOperator(type: TypeNode): TypeNode;
|
|
parenthesizeOperandOfReadonlyTypeOperator(type: TypeNode): TypeNode;
|
|
parenthesizeNonArrayTypeOfPostfixType(type: TypeNode): TypeNode;
|
|
parenthesizeElementTypesOfTupleType(types: readonly (TypeNode | NamedTupleMember)[]): NodeArray<TypeNode>;
|
|
parenthesizeElementTypeOfTupleType(type: TypeNode | NamedTupleMember): TypeNode | NamedTupleMember;
|
|
parenthesizeTypeOfOptionalType(type: TypeNode): TypeNode;
|
|
parenthesizeConstituentTypeOfUnionType(type: TypeNode): TypeNode;
|
|
parenthesizeConstituentTypesOfUnionType(constituents: readonly TypeNode[]): NodeArray<TypeNode>;
|
|
parenthesizeConstituentTypeOfIntersectionType(type: TypeNode): TypeNode;
|
|
parenthesizeConstituentTypesOfIntersectionType(constituents: readonly TypeNode[]): NodeArray<TypeNode>;
|
|
parenthesizeLeadingTypeArgument(typeNode: TypeNode): TypeNode;
|
|
parenthesizeTypeArguments(typeParameters: readonly TypeNode[] | undefined): NodeArray<TypeNode> | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface NodeConverters {
|
|
convertToFunctionBlock(node: ConciseBody, multiLine?: boolean): Block;
|
|
convertToFunctionExpression(node: FunctionDeclaration): FunctionExpression;
|
|
convertToClassExpression(node: ClassDeclaration): ClassExpression;
|
|
convertToArrayAssignmentElement(element: ArrayBindingOrAssignmentElement): Expression;
|
|
convertToObjectAssignmentElement(element: ObjectBindingOrAssignmentElement): ObjectLiteralElementLike;
|
|
convertToAssignmentPattern(node: BindingOrAssignmentPattern): AssignmentPattern;
|
|
convertToObjectAssignmentPattern(node: ObjectBindingOrAssignmentPattern): ObjectLiteralExpression;
|
|
convertToArrayAssignmentPattern(node: ArrayBindingOrAssignmentPattern): ArrayLiteralExpression;
|
|
convertToAssignmentElementTarget(node: BindingOrAssignmentElementTarget): Expression;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface GeneratedNamePart {
|
|
/** an additional prefix to insert before the text sourced from `node` */
|
|
prefix?: string;
|
|
node: Identifier | PrivateIdentifier;
|
|
/** an additional suffix to insert after the text sourced from `node` */
|
|
suffix?: string;
|
|
}
|
|
|
|
export type ImmediatelyInvokedFunctionExpression = CallExpression & { readonly expression: FunctionExpression; };
|
|
export type ImmediatelyInvokedArrowFunction = CallExpression & { readonly expression: ParenthesizedExpression & { readonly expression: ArrowFunction; }; };
|
|
|
|
export interface NodeFactory {
|
|
/** @internal */ readonly parenthesizer: ParenthesizerRules;
|
|
/** @internal */ readonly converters: NodeConverters;
|
|
/** @internal */ readonly flags: NodeFactoryFlags;
|
|
/** @internal */ readonly astFactory: AstNodeFactory;
|
|
|
|
createNodeArray<T extends Node>(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray<T>;
|
|
|
|
//
|
|
// Literals
|
|
//
|
|
|
|
createNumericLiteral(value: string | number, numericLiteralFlags?: TokenFlags): NumericLiteral;
|
|
createBigIntLiteral(value: string | PseudoBigInt): BigIntLiteral;
|
|
createStringLiteral(text: string, isSingleQuote?: boolean): StringLiteral;
|
|
/** @internal */ createStringLiteral(text: string, isSingleQuote?: boolean, hasExtendedUnicodeEscape?: boolean): StringLiteral; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
createStringLiteralFromNode(sourceNode: PropertyNameLiteral | PrivateIdentifier, isSingleQuote?: boolean): StringLiteral;
|
|
createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
|
|
|
|
//
|
|
// Identifiers
|
|
//
|
|
|
|
createIdentifier(text: string): Identifier;
|
|
/** @internal */ createIdentifier(text: string, originalKeywordKind?: SyntaxKind, hasExtendedUnicodeEscape?: boolean): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
|
|
/**
|
|
* Create a unique temporary variable.
|
|
* @param recordTempVariable An optional callback used to record the temporary variable name. This
|
|
* should usually be a reference to `hoistVariableDeclaration` from a `TransformationContext`, but
|
|
* can be `undefined` if you plan to record the temporary variable manually.
|
|
* @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes
|
|
* during emit so that the variable can be referenced in a nested function body. This is an alternative to
|
|
* setting `EmitFlags.ReuseTempVariableScope` on the nested function itself.
|
|
*/
|
|
createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): Identifier;
|
|
/** @internal */ createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean, prefix?: string | GeneratedNamePart, suffix?: string): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
|
|
/**
|
|
* Create a unique temporary variable for use in a loop.
|
|
* @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes
|
|
* during emit so that the variable can be referenced in a nested function body. This is an alternative to
|
|
* setting `EmitFlags.ReuseTempVariableScope` on the nested function itself.
|
|
*/
|
|
createLoopVariable(reservedInNestedScopes?: boolean): Identifier;
|
|
|
|
/** Create a unique name based on the supplied text. */
|
|
createUniqueName(text: string, flags?: GeneratedIdentifierFlags): Identifier;
|
|
/** @internal */ createUniqueName(text: string, flags?: GeneratedIdentifierFlags, prefix?: string | GeneratedNamePart, suffix?: string): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
|
|
/** Create a unique name generated for a node. */
|
|
getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier;
|
|
/** @internal */ getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags, prefix?: string | GeneratedNamePart, suffix?: string): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
|
|
createPrivateIdentifier(text: string): PrivateIdentifier;
|
|
createUniquePrivateName(text?: string): PrivateIdentifier;
|
|
/** @internal */ createUniquePrivateName(text?: string, prefix?: string | GeneratedNamePart, suffix?: string): PrivateIdentifier; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
getGeneratedPrivateNameForNode(node: Node): PrivateIdentifier;
|
|
/** @internal */ getGeneratedPrivateNameForNode(node: Node, prefix?: string | GeneratedNamePart, suffix?: string): PrivateIdentifier; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
|
|
//
|
|
// Punctuation
|
|
//
|
|
|
|
createToken(token: SyntaxKind.SuperKeyword): SuperExpression;
|
|
createToken(token: SyntaxKind.ThisKeyword): ThisExpression;
|
|
createToken(token: SyntaxKind.NullKeyword): NullLiteral;
|
|
createToken(token: SyntaxKind.TrueKeyword): TrueLiteral;
|
|
createToken(token: SyntaxKind.FalseKeyword): FalseLiteral;
|
|
createToken(token: SyntaxKind.EndOfFileToken): EndOfFileToken;
|
|
createToken(token: SyntaxKind.Unknown): Token<SyntaxKind.Unknown>;
|
|
createToken<TKind extends PunctuationSyntaxKind>(token: TKind): PunctuationToken<TKind>;
|
|
createToken<TKind extends KeywordTypeSyntaxKind>(token: TKind): KeywordTypeNode<TKind>;
|
|
createToken<TKind extends ModifierSyntaxKind>(token: TKind): ModifierToken<TKind>;
|
|
createToken<TKind extends KeywordSyntaxKind>(token: TKind): KeywordToken<TKind>;
|
|
/** @internal */ createToken<TKind extends TokenSyntaxKind>(token: TKind): Token<TKind>;
|
|
|
|
//
|
|
// Reserved words
|
|
//
|
|
|
|
createSuper(): SuperExpression;
|
|
createThis(): ThisExpression;
|
|
createNull(): NullLiteral;
|
|
createTrue(): TrueLiteral;
|
|
createFalse(): FalseLiteral;
|
|
|
|
//
|
|
// Modifiers
|
|
//
|
|
|
|
createModifier<T extends ModifierSyntaxKind>(kind: T): ModifierToken<T>;
|
|
createModifiersFromModifierFlags(flags: ModifierFlags): Modifier[] | undefined;
|
|
|
|
//
|
|
// Names
|
|
//
|
|
|
|
createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName;
|
|
updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
|
|
createComputedPropertyName(expression: Expression): ComputedPropertyName;
|
|
updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
|
|
|
|
//
|
|
// Signature elements
|
|
//
|
|
|
|
createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
|
updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
|
createParameterDeclaration(modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
|
updateParameterDeclaration(node: ParameterDeclaration, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
|
createDecorator(expression: Expression): Decorator;
|
|
updateDecorator(node: Decorator, expression: Expression): Decorator;
|
|
|
|
//
|
|
// Type Elements
|
|
//
|
|
|
|
createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature;
|
|
updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature;
|
|
createPropertyDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration;
|
|
updatePropertyDeclaration(node: PropertyDeclaration, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration;
|
|
createMethodSignature(modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): MethodSignature;
|
|
updateMethodSignature(node: MethodSignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): MethodSignature;
|
|
createMethodDeclaration(modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
|
updateMethodDeclaration(node: MethodDeclaration, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration;
|
|
createConstructorDeclaration(modifiers: readonly ModifierLike[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
|
updateConstructorDeclaration(node: ConstructorDeclaration, modifiers: readonly ModifierLike[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration;
|
|
createGetAccessorDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration;
|
|
updateGetAccessorDeclaration(node: GetAccessorDeclaration, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration;
|
|
createSetAccessorDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
|
updateSetAccessorDeclaration(node: SetAccessorDeclaration, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration;
|
|
createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration;
|
|
updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
|
createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
|
updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
|
createIndexSignature(modifiers: readonly ModifierLike[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
|
/** @internal */ createIndexSignature(modifiers: readonly ModifierLike[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): IndexSignatureDeclaration; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
updateIndexSignature(node: IndexSignatureDeclaration, modifiers: readonly ModifierLike[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
|
createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
|
|
updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan;
|
|
createClassStaticBlockDeclaration(body: Block): ClassStaticBlockDeclaration;
|
|
updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, body: Block): ClassStaticBlockDeclaration;
|
|
|
|
//
|
|
// Types
|
|
//
|
|
|
|
createKeywordTypeNode<TKind extends KeywordTypeSyntaxKind>(kind: TKind): KeywordTypeNode<TKind>;
|
|
createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode;
|
|
updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode;
|
|
createTypeReferenceNode(typeName: string | EntityName, typeArguments?: readonly TypeNode[]): TypeReferenceNode;
|
|
updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
|
createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): FunctionTypeNode;
|
|
updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): FunctionTypeNode;
|
|
createConstructorTypeNode(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode;
|
|
updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
|
createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
|
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
|
createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode;
|
|
updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
|
createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
|
updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
|
|
createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
|
|
updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode;
|
|
createNamedTupleMember(dotDotDotToken: DotDotDotToken | undefined, name: Identifier, questionToken: QuestionToken | undefined, type: TypeNode): NamedTupleMember;
|
|
updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: DotDotDotToken | undefined, name: Identifier, questionToken: QuestionToken | undefined, type: TypeNode): NamedTupleMember;
|
|
createOptionalTypeNode(type: TypeNode): OptionalTypeNode;
|
|
updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode;
|
|
createRestTypeNode(type: TypeNode): RestTypeNode;
|
|
updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode;
|
|
createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode;
|
|
updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode;
|
|
createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode;
|
|
updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray<TypeNode>): IntersectionTypeNode;
|
|
createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode;
|
|
updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode;
|
|
createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode;
|
|
updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode;
|
|
createImportTypeNode(argument: TypeNode, attributes?: ImportAttributes, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
|
|
updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, attributes: ImportAttributes | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode;
|
|
createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
|
|
updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
|
createThisTypeNode(): ThisTypeNode;
|
|
createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
|
|
updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
|
createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
|
updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
|
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
|
|
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
|
|
createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
|
updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
|
|
createTemplateLiteralType(head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode;
|
|
updateTemplateLiteralType(node: TemplateLiteralTypeNode, head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode;
|
|
|
|
//
|
|
// Binding Patterns
|
|
//
|
|
|
|
createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern;
|
|
updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern;
|
|
createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern;
|
|
updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern;
|
|
createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement;
|
|
updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement;
|
|
|
|
//
|
|
// Expression
|
|
//
|
|
|
|
createArrayLiteralExpression(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression;
|
|
updateArrayLiteralExpression(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression;
|
|
createObjectLiteralExpression(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression;
|
|
updateObjectLiteralExpression(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression;
|
|
createPropertyAccessExpression(expression: Expression, name: string | MemberName): PropertyAccessExpression;
|
|
updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: MemberName): PropertyAccessExpression;
|
|
createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName): PropertyAccessChain;
|
|
updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName): PropertyAccessChain;
|
|
createElementAccessExpression(expression: Expression, index: number | Expression): ElementAccessExpression;
|
|
updateElementAccessExpression(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression;
|
|
createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain;
|
|
updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain;
|
|
createCallExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression;
|
|
updateCallExpression(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression;
|
|
createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain;
|
|
updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain;
|
|
createNewExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression;
|
|
updateNewExpression(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression;
|
|
createTaggedTemplateExpression(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression;
|
|
updateTaggedTemplateExpression(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression;
|
|
createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertionExpression;
|
|
updateTypeAssertion(node: TypeAssertionExpression, type: TypeNode, expression: Expression): TypeAssertionExpression;
|
|
createParenthesizedExpression(expression: Expression): ParenthesizedExpression;
|
|
updateParenthesizedExpression(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression;
|
|
createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression;
|
|
updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression;
|
|
createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction;
|
|
updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction;
|
|
createDeleteExpression(expression: Expression): DeleteExpression;
|
|
updateDeleteExpression(node: DeleteExpression, expression: Expression): DeleteExpression;
|
|
createTypeOfExpression(expression: Expression): TypeOfExpression;
|
|
updateTypeOfExpression(node: TypeOfExpression, expression: Expression): TypeOfExpression;
|
|
createVoidExpression(expression: Expression): VoidExpression;
|
|
updateVoidExpression(node: VoidExpression, expression: Expression): VoidExpression;
|
|
createAwaitExpression(expression: Expression): AwaitExpression;
|
|
updateAwaitExpression(node: AwaitExpression, expression: Expression): AwaitExpression;
|
|
createPrefixUnaryExpression(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression;
|
|
updatePrefixUnaryExpression(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression;
|
|
createPostfixUnaryExpression(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression;
|
|
updatePostfixUnaryExpression(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression;
|
|
createBinaryExpression(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression;
|
|
updateBinaryExpression(node: BinaryExpression, left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression;
|
|
createConditionalExpression(condition: Expression, questionToken: QuestionToken | undefined, whenTrue: Expression, colonToken: ColonToken | undefined, whenFalse: Expression): ConditionalExpression;
|
|
updateConditionalExpression(node: ConditionalExpression, condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression;
|
|
createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression;
|
|
updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression;
|
|
createTemplateHead(text: string, rawText?: string, templateFlags?: TokenFlags): TemplateHead;
|
|
createTemplateHead(text: string | undefined, rawText: string, templateFlags?: TokenFlags): TemplateHead;
|
|
createTemplateMiddle(text: string, rawText?: string, templateFlags?: TokenFlags): TemplateMiddle;
|
|
createTemplateMiddle(text: string | undefined, rawText: string, templateFlags?: TokenFlags): TemplateMiddle;
|
|
createTemplateTail(text: string, rawText?: string, templateFlags?: TokenFlags): TemplateTail;
|
|
createTemplateTail(text: string | undefined, rawText: string, templateFlags?: TokenFlags): TemplateTail;
|
|
createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral;
|
|
createNoSubstitutionTemplateLiteral(text: string | undefined, rawText: string): NoSubstitutionTemplateLiteral;
|
|
/** @internal */ createLiteralLikeNode(kind: LiteralToken["kind"] | SyntaxKind.JsxTextAllWhiteSpaces, text: string): LiteralToken;
|
|
/** @internal */ createTemplateLiteralLikeNode(kind: TemplateLiteralToken["kind"], text: string, rawText: string, templateFlags: TokenFlags | undefined): TemplateLiteralLikeNode;
|
|
createYieldExpression(asteriskToken: AsteriskToken, expression: Expression): YieldExpression;
|
|
createYieldExpression(asteriskToken: undefined, expression: Expression | undefined): YieldExpression;
|
|
/** @internal */ createYieldExpression(asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
updateYieldExpression(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression;
|
|
createSpreadElement(expression: Expression): SpreadElement;
|
|
updateSpreadElement(node: SpreadElement, expression: Expression): SpreadElement;
|
|
createClassExpression(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression;
|
|
updateClassExpression(node: ClassExpression, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression;
|
|
createOmittedExpression(): OmittedExpression;
|
|
createExpressionWithTypeArguments(expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments;
|
|
updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments;
|
|
createAsExpression(expression: Expression, type: TypeNode): AsExpression;
|
|
updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression;
|
|
createNonNullExpression(expression: Expression): NonNullExpression;
|
|
updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression;
|
|
createNonNullChain(expression: Expression): NonNullChain;
|
|
updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain;
|
|
createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty;
|
|
updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty;
|
|
createSatisfiesExpression(expression: Expression, type: TypeNode): SatisfiesExpression;
|
|
updateSatisfiesExpression(node: SatisfiesExpression, expression: Expression, type: TypeNode): SatisfiesExpression;
|
|
|
|
//
|
|
// Misc
|
|
//
|
|
|
|
createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
|
updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan;
|
|
createSemicolonClassElement(): SemicolonClassElement;
|
|
|
|
//
|
|
// Element
|
|
//
|
|
|
|
createBlock(statements: readonly Statement[], multiLine?: boolean): Block;
|
|
updateBlock(node: Block, statements: readonly Statement[]): Block;
|
|
createVariableStatement(modifiers: readonly ModifierLike[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement;
|
|
updateVariableStatement(node: VariableStatement, modifiers: readonly ModifierLike[] | undefined, declarationList: VariableDeclarationList): VariableStatement;
|
|
createEmptyStatement(): EmptyStatement;
|
|
createExpressionStatement(expression: Expression): ExpressionStatement;
|
|
updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement;
|
|
createIfStatement(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement;
|
|
updateIfStatement(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement;
|
|
createDoStatement(statement: Statement, expression: Expression): DoStatement;
|
|
updateDoStatement(node: DoStatement, statement: Statement, expression: Expression): DoStatement;
|
|
createWhileStatement(expression: Expression, statement: Statement): WhileStatement;
|
|
updateWhileStatement(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement;
|
|
createForStatement(initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement;
|
|
updateForStatement(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement;
|
|
createForInStatement(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement;
|
|
updateForInStatement(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement;
|
|
createForOfStatement(awaitModifier: AwaitKeyword | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement;
|
|
updateForOfStatement(node: ForOfStatement, awaitModifier: AwaitKeyword | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement;
|
|
createContinueStatement(label?: string | Identifier): ContinueStatement;
|
|
updateContinueStatement(node: ContinueStatement, label: Identifier | undefined): ContinueStatement;
|
|
createBreakStatement(label?: string | Identifier): BreakStatement;
|
|
updateBreakStatement(node: BreakStatement, label: Identifier | undefined): BreakStatement;
|
|
createReturnStatement(expression?: Expression): ReturnStatement;
|
|
updateReturnStatement(node: ReturnStatement, expression: Expression | undefined): ReturnStatement;
|
|
createWithStatement(expression: Expression, statement: Statement): WithStatement;
|
|
updateWithStatement(node: WithStatement, expression: Expression, statement: Statement): WithStatement;
|
|
createSwitchStatement(expression: Expression, caseBlock: CaseBlock): SwitchStatement;
|
|
updateSwitchStatement(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement;
|
|
createLabeledStatement(label: string | Identifier, statement: Statement): LabeledStatement;
|
|
updateLabeledStatement(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement;
|
|
createThrowStatement(expression: Expression): ThrowStatement;
|
|
updateThrowStatement(node: ThrowStatement, expression: Expression): ThrowStatement;
|
|
createTryStatement(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
|
updateTryStatement(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement;
|
|
createDebuggerStatement(): DebuggerStatement;
|
|
createVariableDeclaration(name: string | BindingName, exclamationToken?: ExclamationToken, type?: TypeNode, initializer?: Expression): VariableDeclaration;
|
|
updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration;
|
|
createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList;
|
|
updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList;
|
|
createFunctionDeclaration(modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
|
updateFunctionDeclaration(node: FunctionDeclaration, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration;
|
|
createClassDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration;
|
|
updateClassDeclaration(node: ClassDeclaration, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration;
|
|
createInterfaceDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration;
|
|
updateInterfaceDeclaration(node: InterfaceDeclaration, modifiers: readonly ModifierLike[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration;
|
|
createTypeAliasDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
|
updateTypeAliasDeclaration(node: TypeAliasDeclaration, modifiers: readonly ModifierLike[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
|
|
createEnumDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration;
|
|
updateEnumDeclaration(node: EnumDeclaration, modifiers: readonly ModifierLike[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration;
|
|
createModuleDeclaration(modifiers: readonly ModifierLike[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration;
|
|
updateModuleDeclaration(node: ModuleDeclaration, modifiers: readonly ModifierLike[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration;
|
|
createModuleBlock(statements: readonly Statement[]): ModuleBlock;
|
|
updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock;
|
|
createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock;
|
|
updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock;
|
|
createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration;
|
|
updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration;
|
|
createImportEqualsDeclaration(modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
|
updateImportEqualsDeclaration(node: ImportEqualsDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
|
createImportDeclaration(modifiers: readonly ModifierLike[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes?: ImportAttributes): ImportDeclaration;
|
|
updateImportDeclaration(node: ImportDeclaration, modifiers: readonly ModifierLike[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes: ImportAttributes | undefined): ImportDeclaration;
|
|
createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
|
updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
|
/** @deprecated */ createAssertClause(elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
|
|
/** @deprecated */ updateAssertClause(node: AssertClause, elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
|
|
/** @deprecated */ createAssertEntry(name: AssertionKey, value: Expression): AssertEntry;
|
|
/** @deprecated */ updateAssertEntry(node: AssertEntry, name: AssertionKey, value: Expression): AssertEntry;
|
|
/** @deprecated */ createImportTypeAssertionContainer(clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer;
|
|
/** @deprecated */ updateImportTypeAssertionContainer(node: ImportTypeAssertionContainer, clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer;
|
|
createImportAttributes(elements: NodeArray<ImportAttribute>, multiLine?: boolean): ImportAttributes;
|
|
/** @internal */ createImportAttributes(elements: NodeArray<ImportAttribute>, multiLine?: boolean, token?: ImportAttributes["token"]): ImportAttributes; // eslint-disable-line @typescript-eslint/unified-signatures
|
|
updateImportAttributes(node: ImportAttributes, elements: NodeArray<ImportAttribute>, multiLine?: boolean): ImportAttributes;
|
|
createImportAttribute(name: ImportAttributeName, value: Expression): ImportAttribute;
|
|
updateImportAttribute(node: ImportAttribute, name: ImportAttributeName, value: Expression): ImportAttribute;
|
|
createNamespaceImport(name: Identifier): NamespaceImport;
|
|
updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport;
|
|
createNamespaceExport(name: ModuleExportName): NamespaceExport;
|
|
updateNamespaceExport(node: NamespaceExport, name: ModuleExportName): NamespaceExport;
|
|
createNamedImports(elements: readonly ImportSpecifier[]): NamedImports;
|
|
updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports;
|
|
createImportSpecifier(isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier;
|
|
updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier;
|
|
createExportAssignment(modifiers: readonly ModifierLike[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment;
|
|
updateExportAssignment(node: ExportAssignment, modifiers: readonly ModifierLike[] | undefined, expression: Expression): ExportAssignment;
|
|
createExportDeclaration(modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, attributes?: ImportAttributes): ExportDeclaration;
|
|
updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, attributes: ImportAttributes | undefined): ExportDeclaration;
|
|
createNamedExports(elements: readonly ExportSpecifier[]): NamedExports;
|
|
updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports;
|
|
createExportSpecifier(isTypeOnly: boolean, propertyName: string | ModuleExportName | undefined, name: string | ModuleExportName): ExportSpecifier;
|
|
updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName): ExportSpecifier;
|
|
/** @internal */ createMissingDeclaration(): MissingDeclaration;
|
|
|
|
//
|
|
// Module references
|
|
//
|
|
|
|
createExternalModuleReference(expression: Expression): ExternalModuleReference;
|
|
updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference;
|
|
|
|
//
|
|
// JSDoc
|
|
//
|
|
|
|
createJSDocAllType(): JSDocAllType;
|
|
createJSDocUnknownType(): JSDocUnknownType;
|
|
createJSDocNonNullableType(type: TypeNode, postfix?: boolean): JSDocNonNullableType;
|
|
updateJSDocNonNullableType(node: JSDocNonNullableType, type: TypeNode): JSDocNonNullableType;
|
|
createJSDocNullableType(type: TypeNode, postfix?: boolean): JSDocNullableType;
|
|
updateJSDocNullableType(node: JSDocNullableType, type: TypeNode): JSDocNullableType;
|
|
createJSDocOptionalType(type: TypeNode): JSDocOptionalType;
|
|
updateJSDocOptionalType(node: JSDocOptionalType, type: TypeNode): JSDocOptionalType;
|
|
createJSDocFunctionType(parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): JSDocFunctionType;
|
|
updateJSDocFunctionType(node: JSDocFunctionType, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): JSDocFunctionType;
|
|
createJSDocVariadicType(type: TypeNode): JSDocVariadicType;
|
|
updateJSDocVariadicType(node: JSDocVariadicType, type: TypeNode): JSDocVariadicType;
|
|
createJSDocNamepathType(type: TypeNode): JSDocNamepathType;
|
|
updateJSDocNamepathType(node: JSDocNamepathType, type: TypeNode): JSDocNamepathType;
|
|
createJSDocTypeExpression(type: TypeNode): JSDocTypeExpression;
|
|
updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression;
|
|
createJSDocNameReference(name: EntityName | JSDocMemberName): JSDocNameReference;
|
|
updateJSDocNameReference(node: JSDocNameReference, name: EntityName | JSDocMemberName): JSDocNameReference;
|
|
createJSDocMemberName(left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName;
|
|
updateJSDocMemberName(node: JSDocMemberName, left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName;
|
|
createJSDocLink(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink;
|
|
updateJSDocLink(node: JSDocLink, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink;
|
|
createJSDocLinkCode(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode;
|
|
updateJSDocLinkCode(node: JSDocLinkCode, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode;
|
|
createJSDocLinkPlain(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain;
|
|
updateJSDocLinkPlain(node: JSDocLinkPlain, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain;
|
|
createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral;
|
|
updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral;
|
|
createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature;
|
|
updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature;
|
|
createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray<JSDocComment>): JSDocTemplateTag;
|
|
updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray<JSDocComment> | undefined): JSDocTemplateTag;
|
|
createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray<JSDocComment>): JSDocTypedefTag;
|
|
updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocTypedefTag;
|
|
createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray<JSDocComment>): JSDocParameterTag;
|
|
updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray<JSDocComment> | undefined): JSDocParameterTag;
|
|
createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray<JSDocComment>): JSDocPropertyTag;
|
|
updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray<JSDocComment> | undefined): JSDocPropertyTag;
|
|
createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocTypeTag;
|
|
updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray<JSDocComment> | undefined): JSDocTypeTag;
|
|
createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray<JSDocComment>): JSDocSeeTag;
|
|
updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray<JSDocComment>): JSDocSeeTag;
|
|
createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocReturnTag;
|
|
updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocReturnTag;
|
|
createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocThisTag;
|
|
updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocThisTag;
|
|
createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocEnumTag;
|
|
updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray<JSDocComment> | undefined): JSDocEnumTag;
|
|
createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray<JSDocComment>): JSDocCallbackTag;
|
|
updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocCallbackTag;
|
|
createJSDocOverloadTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, comment?: string | NodeArray<JSDocComment>): JSDocOverloadTag;
|
|
updateJSDocOverloadTag(node: JSDocOverloadTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, comment: string | NodeArray<JSDocComment> | undefined): JSDocOverloadTag;
|
|
createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray<JSDocComment>): JSDocAugmentsTag;
|
|
updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray<JSDocComment> | undefined): JSDocAugmentsTag;
|
|
createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray<JSDocComment>): JSDocImplementsTag;
|
|
updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray<JSDocComment> | undefined): JSDocImplementsTag;
|
|
createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocAuthorTag;
|
|
updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocAuthorTag;
|
|
createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocClassTag;
|
|
updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocClassTag;
|
|
createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocPublicTag;
|
|
updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocPublicTag;
|
|
createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocPrivateTag;
|
|
updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocPrivateTag;
|
|
createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocProtectedTag;
|
|
updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocProtectedTag;
|
|
createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocReadonlyTag;
|
|
updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocReadonlyTag;
|
|
createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocUnknownTag;
|
|
updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocComment> | undefined): JSDocUnknownTag;
|
|
createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
|
|
updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
|
|
createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
|
|
updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
|
|
createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment>): JSDocThrowsTag;
|
|
updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment> | undefined): JSDocThrowsTag;
|
|
createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocSatisfiesTag;
|
|
updateJSDocSatisfiesTag(node: JSDocSatisfiesTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray<JSDocComment> | undefined): JSDocSatisfiesTag;
|
|
createJSDocImportTag(tagName: Identifier | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes?: ImportAttributes, comment?: string | NodeArray<JSDocComment>): JSDocImportTag;
|
|
updateJSDocImportTag(node: JSDocImportTag, tagName: Identifier | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes: ImportAttributes | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocImportTag;
|
|
createJSDocText(text: string): JSDocText;
|
|
updateJSDocText(node: JSDocText, text: string): JSDocText;
|
|
createJSDocComment(comment?: string | NodeArray<JSDocComment> | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc;
|
|
updateJSDocComment(node: JSDoc, comment: string | NodeArray<JSDocComment> | undefined, tags: readonly JSDocTag[] | undefined): JSDoc;
|
|
|
|
//
|
|
// JSX
|
|
//
|
|
|
|
createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement;
|
|
updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement;
|
|
createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement;
|
|
updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement;
|
|
createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement;
|
|
updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement;
|
|
createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement;
|
|
updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement;
|
|
createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment;
|
|
createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText;
|
|
updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText;
|
|
createJsxOpeningFragment(): JsxOpeningFragment;
|
|
createJsxClosingFragment(): JsxClosingFragment;
|
|
/** @deprecated*/ createJsxJsxClosingFragment(): JsxClosingFragment;
|
|
updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment;
|
|
createJsxAttribute(name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
|
updateJsxAttribute(node: JsxAttribute, name: JsxAttributeName, initializer: JsxAttributeValue | undefined): JsxAttribute;
|
|
createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes;
|
|
updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes;
|
|
createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
|
|
updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute;
|
|
createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression;
|
|
updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression;
|
|
createJsxNamespacedName(namespace: Identifier, name: Identifier): JsxNamespacedName;
|
|
updateJsxNamespacedName(node: JsxNamespacedName, namespace: Identifier, name: Identifier): JsxNamespacedName;
|
|
|
|
//
|
|
// Clauses
|
|
//
|
|
|
|
createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause;
|
|
updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause;
|
|
createDefaultClause(statements: readonly Statement[]): DefaultClause;
|
|
updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause;
|
|
createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause;
|
|
updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause;
|
|
createCatchClause(variableDeclaration: string | BindingName | VariableDeclaration | undefined, block: Block): CatchClause;
|
|
updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause;
|
|
|
|
//
|
|
// Property assignments
|
|
//
|
|
|
|
createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment;
|
|
updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment;
|
|
createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment;
|
|
updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined): ShorthandPropertyAssignment;
|
|
createSpreadAssignment(expression: Expression): SpreadAssignment;
|
|
updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment;
|
|
|
|
//
|
|
// Enum
|
|
//
|
|
|
|
createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember;
|
|
updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember;
|
|
|
|
//
|
|
// Top-level nodes
|
|
//
|
|
|
|
createSourceFile(statements: readonly Statement[], endOfFileToken: EndOfFileToken, flags: NodeFlags): SourceFile;
|
|
updateSourceFile(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: readonly FileReference[], typeReferences?: readonly FileReference[], hasNoDefaultLib?: boolean, libReferences?: readonly FileReference[]): SourceFile;
|
|
|
|
/** @internal */ createRedirectedSourceFile(redirectInfo: RedirectInfo): SourceFile;
|
|
|
|
//
|
|
// Synthetic Nodes
|
|
//
|
|
/** @internal */ createSyntheticExpression(type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember): SyntheticExpression;
|
|
/** @internal */ createSyntaxList(children: readonly Node[]): SyntaxList;
|
|
|
|
//
|
|
// Transformation nodes
|
|
//
|
|
|
|
createNotEmittedStatement(original: Node): NotEmittedStatement;
|
|
createNotEmittedTypeElement(): NotEmittedTypeElement;
|
|
createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression;
|
|
updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression;
|
|
/** @internal */ createSyntheticReferenceExpression(expression: Expression, thisArg: Expression): SyntheticReferenceExpression;
|
|
/** @internal */ updateSyntheticReferenceExpression(node: SyntheticReferenceExpression, expression: Expression, thisArg: Expression): SyntheticReferenceExpression;
|
|
createCommaListExpression(elements: readonly Expression[]): CommaListExpression;
|
|
updateCommaListExpression(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression;
|
|
createBundle(sourceFiles: readonly SourceFile[]): Bundle;
|
|
updateBundle(node: Bundle, sourceFiles: readonly SourceFile[]): Bundle;
|
|
|
|
//
|
|
// Common operators
|
|
//
|
|
|
|
createComma(left: Expression, right: Expression): BinaryExpression;
|
|
createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;
|
|
createAssignment(left: Expression, right: Expression): AssignmentExpression<EqualsToken>;
|
|
createLogicalOr(left: Expression, right: Expression): BinaryExpression;
|
|
createLogicalAnd(left: Expression, right: Expression): BinaryExpression;
|
|
createBitwiseOr(left: Expression, right: Expression): BinaryExpression;
|
|
createBitwiseXor(left: Expression, right: Expression): BinaryExpression;
|
|
createBitwiseAnd(left: Expression, right: Expression): BinaryExpression;
|
|
createStrictEquality(left: Expression, right: Expression): BinaryExpression;
|
|
createStrictInequality(left: Expression, right: Expression): BinaryExpression;
|
|
createEquality(left: Expression, right: Expression): BinaryExpression;
|
|
createInequality(left: Expression, right: Expression): BinaryExpression;
|
|
createLessThan(left: Expression, right: Expression): BinaryExpression;
|
|
createLessThanEquals(left: Expression, right: Expression): BinaryExpression;
|
|
createGreaterThan(left: Expression, right: Expression): BinaryExpression;
|
|
createGreaterThanEquals(left: Expression, right: Expression): BinaryExpression;
|
|
createLeftShift(left: Expression, right: Expression): BinaryExpression;
|
|
createRightShift(left: Expression, right: Expression): BinaryExpression;
|
|
createUnsignedRightShift(left: Expression, right: Expression): BinaryExpression;
|
|
createAdd(left: Expression, right: Expression): BinaryExpression;
|
|
createSubtract(left: Expression, right: Expression): BinaryExpression;
|
|
createMultiply(left: Expression, right: Expression): BinaryExpression;
|
|
createDivide(left: Expression, right: Expression): BinaryExpression;
|
|
createModulo(left: Expression, right: Expression): BinaryExpression;
|
|
createExponent(left: Expression, right: Expression): BinaryExpression;
|
|
createPrefixPlus(operand: Expression): PrefixUnaryExpression;
|
|
createPrefixMinus(operand: Expression): PrefixUnaryExpression;
|
|
createPrefixIncrement(operand: Expression): PrefixUnaryExpression;
|
|
createPrefixDecrement(operand: Expression): PrefixUnaryExpression;
|
|
createBitwiseNot(operand: Expression): PrefixUnaryExpression;
|
|
createLogicalNot(operand: Expression): PrefixUnaryExpression;
|
|
createPostfixIncrement(operand: Expression): PostfixUnaryExpression;
|
|
createPostfixDecrement(operand: Expression): PostfixUnaryExpression;
|
|
|
|
//
|
|
// Compound Nodes
|
|
//
|
|
|
|
createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression;
|
|
createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
|
createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): ImmediatelyInvokedArrowFunction;
|
|
createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedArrowFunction;
|
|
|
|
createVoidZero(): VoidExpression;
|
|
createExportDefault(expression: Expression): ExportAssignment;
|
|
createExternalModuleExport(exportName: Identifier): ExportDeclaration;
|
|
|
|
/** @internal */ createTypeCheck(value: Expression, tag: TypeOfTag): Expression;
|
|
/** @internal */ createIsNotTypeCheck(value: Expression, tag: TypeOfTag): Expression;
|
|
/** @internal */ createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]): CallExpression;
|
|
/** @internal */ createGlobalMethodCall(globalObjectName: string, globalMethodName: string, argumentsList: readonly Expression[]): CallExpression;
|
|
/** @internal */ createFunctionBindCall(target: Expression, thisArg: Expression, argumentsList: readonly Expression[]): CallExpression;
|
|
/** @internal */ createFunctionCallCall(target: Expression, thisArg: Expression, argumentsList: readonly Expression[]): CallExpression;
|
|
/** @internal */ createFunctionApplyCall(target: Expression, thisArg: Expression, argumentsExpression: Expression): CallExpression;
|
|
/** @internal */ createObjectDefinePropertyCall(target: Expression, propertyName: string | Expression, attributes: Expression): CallExpression;
|
|
/** @internal */ createObjectGetOwnPropertyDescriptorCall(target: Expression, propertyName: string | Expression): CallExpression;
|
|
/** @internal */ createReflectGetCall(target: Expression, propertyKey: Expression, receiver?: Expression): CallExpression;
|
|
/** @internal */ createReflectSetCall(target: Expression, propertyKey: Expression, value: Expression, receiver?: Expression): CallExpression;
|
|
/** @internal */ createPropertyDescriptor(attributes: PropertyDescriptorAttributes, singleLine?: boolean): ObjectLiteralExpression;
|
|
/** @internal */ createArraySliceCall(array: Expression, start?: number | Expression): CallExpression;
|
|
/** @internal */ createArrayConcatCall(array: Expression, values: readonly Expression[]): CallExpression;
|
|
/** @internal */ createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding;
|
|
/**
|
|
* Wraps an expression that cannot be an assignment target in an expression that can be.
|
|
*
|
|
* Given a `paramName` of `_a`:
|
|
* ```
|
|
* Reflect.set(obj, "x", _a)
|
|
* ```
|
|
* Becomes
|
|
* ```ts
|
|
* ({ set value(_a) { Reflect.set(obj, "x", _a); } }).value
|
|
* ```
|
|
*
|
|
* @param paramName
|
|
* @param expression
|
|
*
|
|
* @internal
|
|
*/
|
|
createAssignmentTargetWrapper(paramName: Identifier, expression: Expression): PropertyAccessExpression;
|
|
/** @internal */ inlineExpressions(expressions: readonly Expression[]): Expression;
|
|
/**
|
|
* Gets the internal name of a declaration. This is primarily used for declarations that can be
|
|
* referred to by name in the body of an ES5 class function body. An internal name will *never*
|
|
* be prefixed with an module or namespace export modifier like "exports." when emitted as an
|
|
* expression. An internal name will also *never* be renamed due to a collision with a block
|
|
* scoped variable.
|
|
*
|
|
* @param node The declaration.
|
|
* @param allowComments A value indicating whether comments may be emitted for the name.
|
|
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
|
*
|
|
* @internal
|
|
*/
|
|
getInternalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier;
|
|
/**
|
|
* Gets the local name of a declaration. This is primarily used for declarations that can be
|
|
* referred to by name in the declaration's immediate scope (classes, enums, namespaces). A
|
|
* local name will *never* be prefixed with an module or namespace export modifier like
|
|
* "exports." when emitted as an expression.
|
|
*
|
|
* @param node The declaration.
|
|
* @param allowComments A value indicating whether comments may be emitted for the name.
|
|
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
|
* @param ignoreAssignedName Indicates that the assigned name of a declaration shouldn't be considered.
|
|
*
|
|
* @internal
|
|
*/
|
|
getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean, ignoreAssignedName?: boolean): Identifier;
|
|
/**
|
|
* Gets the export name of a declaration. This is primarily used for declarations that can be
|
|
* referred to by name in the declaration's immediate scope (classes, enums, namespaces). An
|
|
* export name will *always* be prefixed with a module or namespace export modifier like
|
|
* `"exports."` when emitted as an expression if the name points to an exported symbol.
|
|
*
|
|
* @param node The declaration.
|
|
* @param allowComments A value indicating whether comments may be emitted for the name.
|
|
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
|
*
|
|
* @internal
|
|
*/
|
|
getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier;
|
|
/**
|
|
* Gets the name of a declaration for use in declarations.
|
|
*
|
|
* @param node The declaration.
|
|
* @param allowComments A value indicating whether comments may be emitted for the name.
|
|
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
|
*
|
|
* @internal
|
|
*/
|
|
getDeclarationName(node: Declaration | undefined, allowComments?: boolean, allowSourceMaps?: boolean): Identifier;
|
|
/**
|
|
* Gets a namespace-qualified name for use in expressions.
|
|
*
|
|
* @param ns The namespace identifier.
|
|
* @param name The name.
|
|
* @param allowComments A value indicating whether comments may be emitted for the name.
|
|
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
|
*
|
|
* @internal
|
|
*/
|
|
getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression;
|
|
/**
|
|
* Gets the exported name of a declaration for use in expressions.
|
|
*
|
|
* An exported name will *always* be prefixed with an module or namespace export modifier like
|
|
* "exports." if the name points to an exported symbol.
|
|
*
|
|
* @param ns The namespace identifier.
|
|
* @param node The declaration.
|
|
* @param allowComments A value indicating whether comments may be emitted for the name.
|
|
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
|
*
|
|
* @internal
|
|
*/
|
|
getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression;
|
|
|
|
//
|
|
// Utilities
|
|
//
|
|
|
|
restoreOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds?: OuterExpressionKinds): Expression;
|
|
/** @internal */ restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement | undefined, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement;
|
|
/** @internal */ createUseStrictPrologue(): PrologueDirective;
|
|
/**
|
|
* Copies any necessary standard and custom prologue-directives into target array.
|
|
* @param source origin statements array
|
|
* @param target result statements array
|
|
* @param ensureUseStrict boolean determining whether the function need to add prologue-directives
|
|
* @param visitor Optional callback used to visit any custom prologue directives.
|
|
*
|
|
* @internal
|
|
*/
|
|
copyPrologue(source: readonly Statement[], target: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult<Node | undefined>): number;
|
|
/**
|
|
* Copies only the standard (string-expression) prologue-directives into the target statement-array.
|
|
* @param source origin statements array
|
|
* @param target result statements array
|
|
* @param statementOffset The offset at which to begin the copy.
|
|
* @param ensureUseStrict boolean determining whether the function need to add prologue-directives
|
|
*
|
|
* @internal
|
|
*/
|
|
copyStandardPrologue(source: readonly Statement[], target: Statement[], statementOffset: number | undefined, ensureUseStrict?: boolean): number;
|
|
/**
|
|
* Copies only the custom prologue-directives into target statement-array.
|
|
* @param source origin statements array
|
|
* @param target result statements array
|
|
* @param statementOffset The offset at which to begin the copy.
|
|
* @param visitor Optional callback used to visit any custom prologue directives.
|
|
*
|
|
* @internal
|
|
*/
|
|
copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult<Node | undefined>, filter?: (node: Statement) => boolean): number;
|
|
/** @internal */ copyCustomPrologue(source: readonly Statement[], target: Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult<Node | undefined>, filter?: (node: Statement) => boolean): number | undefined;
|
|
/** @internal */ ensureUseStrict(statements: NodeArray<Statement>): NodeArray<Statement>;
|
|
/** @internal */ liftToBlock(nodes: readonly Node[]): Statement;
|
|
/**
|
|
* Merges generated lexical declarations into a new statement list.
|
|
*
|
|
* @internal
|
|
*/
|
|
mergeLexicalEnvironment(statements: NodeArray<Statement>, declarations: readonly Statement[] | undefined): NodeArray<Statement>;
|
|
/**
|
|
* Appends generated lexical declarations to an array of statements.
|
|
*
|
|
* @internal
|
|
*/
|
|
mergeLexicalEnvironment(statements: Statement[], declarations: readonly Statement[] | undefined): Statement[];
|
|
/**
|
|
* Creates a shallow, memberwise clone of a node.
|
|
* - The result will have its `original` pointer set to `node`.
|
|
* - The result will have its `pos` and `end` set to `-1`.
|
|
* - *DO NOT USE THIS* if a more appropriate function is available.
|
|
*
|
|
* @internal
|
|
*/
|
|
cloneNode<T extends Node | undefined>(node: T): T;
|
|
/**
|
|
* Updates a node that may contain modifiers, replacing only the modifiers of the node.
|
|
*/
|
|
replaceModifiers<T extends HasModifiers>(node: T, modifiers: readonly Modifier[] | ModifierFlags | undefined): T;
|
|
/**
|
|
* Updates a node that may contain decorators or modifiers, replacing only the decorators and modifiers of the node.
|
|
*/
|
|
replaceDecoratorsAndModifiers<T extends HasModifiers & HasDecorators>(node: T, modifiers: readonly ModifierLike[] | undefined): T;
|
|
/**
|
|
* Updates a node that contains a property name, replacing only the name of the node.
|
|
*/
|
|
replacePropertyName<T extends AccessorDeclaration | MethodDeclaration | MethodSignature | PropertyDeclaration | PropertySignature | PropertyAssignment>(node: T, name: T["name"]): T;
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum LexicalEnvironmentFlags {
|
|
None = 0,
|
|
InParameters = 1 << 0, // currently visiting a parameter list
|
|
VariablesHoistedInParameters = 1 << 1, // a temp variable was hoisted while visiting a parameter list
|
|
}
|
|
|
|
export interface CoreTransformationContext {
|
|
readonly factory: NodeFactory;
|
|
|
|
/** Gets the compiler options supplied to the transformer. */
|
|
getCompilerOptions(): CompilerOptions;
|
|
|
|
/** Starts a new lexical environment. */
|
|
startLexicalEnvironment(): void;
|
|
|
|
/** @internal */ setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void;
|
|
/** @internal */ getLexicalEnvironmentFlags(): LexicalEnvironmentFlags;
|
|
|
|
/** Suspends the current lexical environment, usually after visiting a parameter list. */
|
|
suspendLexicalEnvironment(): void;
|
|
|
|
/** Resumes a suspended lexical environment, usually before visiting a function body. */
|
|
resumeLexicalEnvironment(): void;
|
|
|
|
/** Ends a lexical environment, returning any declarations. */
|
|
endLexicalEnvironment(): Statement[] | undefined;
|
|
|
|
/** Hoists a function declaration to the containing scope. */
|
|
hoistFunctionDeclaration(node: FunctionDeclaration): void;
|
|
|
|
/** Hoists a variable declaration to the containing scope. */
|
|
hoistVariableDeclaration(node: Identifier): void;
|
|
|
|
/** @internal */ startBlockScope(): void;
|
|
|
|
/** @internal */ endBlockScope(): Statement[] | undefined;
|
|
|
|
/** @internal */ addBlockScopedVariable(node: Identifier): void;
|
|
|
|
/**
|
|
* Adds an initialization statement to the top of the lexical environment.
|
|
*
|
|
* @internal
|
|
*/
|
|
addInitializationStatement(node: Statement): void;
|
|
}
|
|
|
|
export interface TransformationContext extends CoreTransformationContext {
|
|
/** @internal */ getEmitResolver(): EmitResolver;
|
|
/** @internal */ getEmitHost(): EmitHost;
|
|
/** @internal */ getEmitHelperFactory(): EmitHelperFactory;
|
|
|
|
/** Records a request for a non-scoped emit helper in the current context. */
|
|
requestEmitHelper(helper: EmitHelper): void;
|
|
|
|
/** Gets and resets the requested non-scoped emit helpers. */
|
|
readEmitHelpers(): EmitHelper[] | undefined;
|
|
|
|
/** Enables expression substitutions in the pretty printer for the provided SyntaxKind. */
|
|
enableSubstitution(kind: SyntaxKind): void;
|
|
|
|
/** Determines whether expression substitutions are enabled for the provided node. */
|
|
isSubstitutionEnabled(node: Node): boolean;
|
|
|
|
/**
|
|
* Hook used by transformers to substitute expressions just before they
|
|
* are emitted by the pretty printer.
|
|
*
|
|
* NOTE: Transformation hooks should only be modified during `Transformer` initialization,
|
|
* before returning the `NodeTransformer` callback.
|
|
*/
|
|
onSubstituteNode: (hint: EmitHint, node: Node) => Node;
|
|
|
|
/**
|
|
* Enables before/after emit notifications in the pretty printer for the provided
|
|
* SyntaxKind.
|
|
*/
|
|
enableEmitNotification(kind: SyntaxKind): void;
|
|
|
|
/**
|
|
* Determines whether before/after emit notifications should be raised in the pretty
|
|
* printer when it emits a node.
|
|
*/
|
|
isEmitNotificationEnabled(node: Node): boolean;
|
|
|
|
/**
|
|
* Hook used to allow transformers to capture state before or after
|
|
* the printer emits a node.
|
|
*
|
|
* NOTE: Transformation hooks should only be modified during `Transformer` initialization,
|
|
* before returning the `NodeTransformer` callback.
|
|
*/
|
|
onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void;
|
|
|
|
/** @internal */ addDiagnostic(diag: DiagnosticWithLocation): void;
|
|
}
|
|
|
|
export interface TransformationResult<T extends Node> {
|
|
/** Gets the transformed source files. */
|
|
transformed: T[];
|
|
|
|
/** Gets diagnostics for the transformation. */
|
|
diagnostics?: DiagnosticWithLocation[];
|
|
|
|
/**
|
|
* Gets a substitute for a node, if one is available; otherwise, returns the original node.
|
|
*
|
|
* @param hint A hint as to the intended usage of the node.
|
|
* @param node The node to substitute.
|
|
*/
|
|
substituteNode(hint: EmitHint, node: Node): Node;
|
|
|
|
/**
|
|
* Emits a node with possible notification.
|
|
*
|
|
* @param hint A hint as to the intended usage of the node.
|
|
* @param node The node to emit.
|
|
* @param emitCallback A callback used to emit the node.
|
|
*/
|
|
emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void;
|
|
|
|
/**
|
|
* Indicates if a given node needs an emit notification
|
|
*
|
|
* @param node The node to emit.
|
|
*/
|
|
isEmitNotificationEnabled?(node: Node): boolean;
|
|
|
|
/**
|
|
* Clean up EmitNode entries on any parse-tree nodes.
|
|
*/
|
|
dispose(): void;
|
|
}
|
|
|
|
/**
|
|
* A function that is used to initialize and return a `Transformer` callback, which in turn
|
|
* will be used to transform one or more nodes.
|
|
*/
|
|
export type TransformerFactory<T extends Node> = (context: TransformationContext) => Transformer<T>;
|
|
|
|
/**
|
|
* A function that transforms a node.
|
|
*/
|
|
export type Transformer<T extends Node> = (node: T) => T;
|
|
|
|
/**
|
|
* A function that accepts and possibly transforms a node.
|
|
*/
|
|
export type Visitor<TIn extends Node = Node, TOut extends Node | undefined = TIn | undefined> = (node: TIn) => VisitResult<TOut>;
|
|
|
|
/**
|
|
* A function that walks a node using the given visitor, lifting node arrays into single nodes,
|
|
* returning an node which satisfies the test.
|
|
*
|
|
* - If the input node is undefined, then the output is undefined.
|
|
* - If the visitor returns undefined, then the output is undefined.
|
|
* - If the output node is not undefined, then it will satisfy the test function.
|
|
* - In order to obtain a return type that is more specific than `Node`, a test
|
|
* function _must_ be provided, and that function must be a type predicate.
|
|
*
|
|
* For the canonical implementation of this type, @see {visitNode}.
|
|
*/
|
|
export interface NodeVisitor {
|
|
<TIn extends Node | undefined, TVisited extends Node | undefined, TOut extends Node>(
|
|
node: TIn,
|
|
visitor: Visitor<NonNullable<TIn>, TVisited>,
|
|
test: (node: Node) => node is TOut,
|
|
lift?: (node: readonly Node[]) => Node,
|
|
): TOut | (TIn & undefined) | (TVisited & undefined);
|
|
<TIn extends Node | undefined, TVisited extends Node | undefined>(
|
|
node: TIn,
|
|
visitor: Visitor<NonNullable<TIn>, TVisited>,
|
|
test?: (node: Node) => boolean,
|
|
lift?: (node: readonly Node[]) => Node,
|
|
): Node | (TIn & undefined) | (TVisited & undefined);
|
|
}
|
|
|
|
/**
|
|
* A function that walks a node array using the given visitor, returning an array whose contents satisfy the test.
|
|
*
|
|
* - If the input node array is undefined, the output is undefined.
|
|
* - If the visitor can return undefined, the node it visits in the array will be reused.
|
|
* - If the output node array is not undefined, then its contents will satisfy the test.
|
|
* - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
|
|
* function _must_ be provided, and that function must be a type predicate.
|
|
*
|
|
* For the canonical implementation of this type, @see {visitNodes}.
|
|
*/
|
|
export interface NodesVisitor {
|
|
<TIn extends Node, TInArray extends NodeArray<TIn> | undefined, TOut extends Node>(
|
|
nodes: TInArray,
|
|
visitor: Visitor<TIn, Node | undefined>,
|
|
test: (node: Node) => node is TOut,
|
|
start?: number,
|
|
count?: number,
|
|
): NodeArray<TOut> | (TInArray & undefined);
|
|
<TIn extends Node, TInArray extends NodeArray<TIn> | undefined>(
|
|
nodes: TInArray,
|
|
visitor: Visitor<TIn, Node | undefined>,
|
|
test?: (node: Node) => boolean,
|
|
start?: number,
|
|
count?: number,
|
|
): NodeArray<Node> | (TInArray & undefined);
|
|
}
|
|
|
|
export type VisitResult<T extends Node | undefined> = T | readonly Node[];
|
|
|
|
export interface Printer {
|
|
/**
|
|
* Print a node and its subtree as-is, without any emit transformations.
|
|
* @param hint A value indicating the purpose of a node. This is primarily used to
|
|
* distinguish between an `Identifier` used in an expression position, versus an
|
|
* `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you
|
|
* should just pass `Unspecified`.
|
|
* @param node The node to print. The node and its subtree are printed as-is, without any
|
|
* emit transformations.
|
|
* @param sourceFile A source file that provides context for the node. The source text of
|
|
* the file is used to emit the original source content for literals and identifiers, while
|
|
* the identifiers of the source file are used when generating unique names to avoid
|
|
* collisions.
|
|
*/
|
|
printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string;
|
|
/**
|
|
* Prints a list of nodes using the given format flags
|
|
*/
|
|
printList<T extends Node>(format: ListFormat, list: NodeArray<T>, sourceFile: SourceFile): string;
|
|
/**
|
|
* Prints a source file as-is, without any emit transformations.
|
|
*/
|
|
printFile(sourceFile: SourceFile): string;
|
|
/**
|
|
* Prints a bundle of source files as-is, without any emit transformations.
|
|
*/
|
|
printBundle(bundle: Bundle): string;
|
|
/** @internal */ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void;
|
|
/** @internal */ writeList<T extends Node>(format: ListFormat, list: NodeArray<T> | undefined, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void;
|
|
/** @internal */ writeFile(sourceFile: SourceFile, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void;
|
|
/** @internal */ writeBundle(bundle: Bundle, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface BuildInfo {
|
|
version: string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface BuildInfoFileVersionMap {
|
|
fileInfos: Map<Path, string>;
|
|
roots: Map<Path, Path | undefined>;
|
|
}
|
|
|
|
export interface PrintHandlers {
|
|
/**
|
|
* A hook used by the Printer when generating unique names to avoid collisions with
|
|
* globally defined names that exist outside of the current source file.
|
|
*/
|
|
hasGlobalName?(name: string): boolean;
|
|
/**
|
|
* A hook used by the Printer to provide notifications prior to emitting a node. A
|
|
* compatible implementation **must** invoke `emitCallback` with the provided `hint` and
|
|
* `node` values.
|
|
* @param hint A hint indicating the intended purpose of the node.
|
|
* @param node The node to emit.
|
|
* @param emitCallback A callback that, when invoked, will emit the node.
|
|
* @example
|
|
* ```ts
|
|
* var printer = createPrinter(printerOptions, {
|
|
* onEmitNode(hint, node, emitCallback) {
|
|
* // set up or track state prior to emitting the node...
|
|
* emitCallback(hint, node);
|
|
* // restore state after emitting the node...
|
|
* }
|
|
* });
|
|
* ```
|
|
*/
|
|
onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void;
|
|
|
|
/**
|
|
* A hook used to check if an emit notification is required for a node.
|
|
* @param node The node to emit.
|
|
*/
|
|
isEmitNotificationEnabled?(node: Node): boolean;
|
|
/**
|
|
* A hook used by the Printer to perform just-in-time substitution of a node. This is
|
|
* primarily used by node transformations that need to substitute one node for another,
|
|
* such as replacing `myExportedVar` with `exports.myExportedVar`.
|
|
* @param hint A hint indicating the intended purpose of the node.
|
|
* @param node The node to emit.
|
|
* @example
|
|
* ```ts
|
|
* var printer = createPrinter(printerOptions, {
|
|
* substituteNode(hint, node) {
|
|
* // perform substitution if necessary...
|
|
* return node;
|
|
* }
|
|
* });
|
|
* ```
|
|
*/
|
|
substituteNode?(hint: EmitHint, node: Node): Node;
|
|
/** @internal */ onEmitSourceMapOfNode?: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void;
|
|
/** @internal */ onEmitSourceMapOfToken?: (node: Node | undefined, token: SyntaxKind, writer: (s: string) => void, pos: number, emitCallback: (token: SyntaxKind, writer: (s: string) => void, pos: number) => number) => number;
|
|
/** @internal */ onEmitSourceMapOfPosition?: (pos: number) => void;
|
|
/** @internal */ onSetSourceFile?: (node: SourceFile) => void;
|
|
/** @internal */ onBeforeEmitNode?: (node: Node | undefined) => void;
|
|
/** @internal */ onAfterEmitNode?: (node: Node | undefined) => void;
|
|
/** @internal */ onBeforeEmitNodeArray?: (nodes: NodeArray<any> | undefined) => void;
|
|
/** @internal */ onAfterEmitNodeArray?: (nodes: NodeArray<any> | undefined) => void;
|
|
/** @internal */ onBeforeEmitToken?: (node: Node) => void;
|
|
/** @internal */ onAfterEmitToken?: (node: Node) => void;
|
|
}
|
|
|
|
export interface PrinterOptions {
|
|
removeComments?: boolean;
|
|
newLine?: NewLineKind;
|
|
omitTrailingSemicolon?: boolean;
|
|
noEmitHelpers?: boolean;
|
|
/** @internal */ module?: CompilerOptions["module"];
|
|
/** @internal */ moduleResolution?: CompilerOptions["moduleResolution"];
|
|
/** @internal */ target?: CompilerOptions["target"];
|
|
/** @internal */ sourceMap?: boolean;
|
|
/** @internal */ inlineSourceMap?: boolean;
|
|
/** @internal */ inlineSources?: boolean;
|
|
/** @internal*/ omitBraceSourceMapPositions?: boolean;
|
|
/** @internal */ extendedDiagnostics?: boolean;
|
|
/** @internal */ onlyPrintJsDocStyle?: boolean;
|
|
/** @internal */ neverAsciiEscape?: boolean;
|
|
/** @internal */ stripInternal?: boolean;
|
|
/** @internal */ preserveSourceNewlines?: boolean;
|
|
/** @internal */ terminateUnterminatedLiterals?: boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface RawSourceMap {
|
|
version: 3;
|
|
file: string;
|
|
sourceRoot?: string | null; // eslint-disable-line no-restricted-syntax
|
|
sources: string[];
|
|
sourcesContent?: (string | null)[] | null; // eslint-disable-line no-restricted-syntax
|
|
mappings: string;
|
|
names?: string[] | null; // eslint-disable-line no-restricted-syntax
|
|
}
|
|
|
|
/**
|
|
* Generates a source map.
|
|
*
|
|
* @internal
|
|
*/
|
|
export interface SourceMapGenerator {
|
|
getSources(): readonly string[];
|
|
/**
|
|
* Adds a source to the source map.
|
|
*/
|
|
addSource(fileName: string): number;
|
|
/**
|
|
* Set the content for a source.
|
|
*/
|
|
setSourceContent(sourceIndex: number, content: string | null): void; // eslint-disable-line no-restricted-syntax
|
|
/**
|
|
* Adds a name.
|
|
*/
|
|
addName(name: string): number;
|
|
/**
|
|
* Adds a mapping without source information.
|
|
*/
|
|
addMapping(generatedLine: number, generatedCharacter: number): void;
|
|
/**
|
|
* Adds a mapping with source information.
|
|
*/
|
|
addMapping(generatedLine: number, generatedCharacter: number, sourceIndex: number, sourceLine: number, sourceCharacter: number, nameIndex?: number): void;
|
|
/**
|
|
* Appends a source map.
|
|
*/
|
|
appendSourceMap(generatedLine: number, generatedCharacter: number, sourceMap: RawSourceMap, sourceMapPath: string, start?: LineAndCharacter, end?: LineAndCharacter): void;
|
|
/**
|
|
* Gets the source map as a `RawSourceMap` object.
|
|
*/
|
|
toJSON(): RawSourceMap;
|
|
/**
|
|
* Gets the string representation of the source map.
|
|
*/
|
|
toString(): string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface DocumentPositionMapperHost {
|
|
getSourceFileLike(fileName: string): SourceFileLike | undefined;
|
|
getCanonicalFileName(path: string): string;
|
|
log(text: string): void;
|
|
}
|
|
|
|
/**
|
|
* Maps positions between source and generated files.
|
|
*
|
|
* @internal
|
|
*/
|
|
export interface DocumentPositionMapper {
|
|
getSourcePosition(input: DocumentPosition): DocumentPosition;
|
|
getGeneratedPosition(input: DocumentPosition): DocumentPosition;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface DocumentPosition {
|
|
fileName: string;
|
|
pos: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface EmitTextWriter extends SymbolWriter {
|
|
write(s: string): void;
|
|
writeTrailingSemicolon(text: string): void;
|
|
writeComment(text: string): void;
|
|
getText(): string;
|
|
rawWrite(s: string): void;
|
|
writeLiteral(s: string): void;
|
|
getTextPos(): number;
|
|
getLine(): number;
|
|
getColumn(): number;
|
|
getIndent(): number;
|
|
isAtStartOfLine(): boolean;
|
|
hasTrailingComment(): boolean;
|
|
hasTrailingWhitespace(): boolean;
|
|
nonEscapingWrite?(text: string): void;
|
|
}
|
|
|
|
export interface GetEffectiveTypeRootsHost {
|
|
getCurrentDirectory?(): string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface HasCurrentDirectory {
|
|
getCurrentDirectory(): string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ModuleSpecifierResolutionHost {
|
|
useCaseSensitiveFileNames?(): boolean;
|
|
fileExists(path: string): boolean;
|
|
getCurrentDirectory(): string;
|
|
directoryExists?(path: string): boolean;
|
|
readFile?(path: string): string | undefined;
|
|
realpath?(path: string): string;
|
|
getSymlinkCache?(): SymlinkCache;
|
|
getModuleSpecifierCache?(): ModuleSpecifierCache;
|
|
getPackageJsonInfoCache?(): PackageJsonInfoCache | undefined;
|
|
getGlobalTypingsCacheLocation?(): string | undefined;
|
|
getNearestAncestorDirectoryWithPackageJson?(fileName: string, rootDir?: string): string | undefined;
|
|
|
|
readonly redirectTargetsMap: RedirectTargetsMap;
|
|
getProjectReferenceRedirect(fileName: string): string | undefined;
|
|
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
|
getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>;
|
|
getCommonSourceDirectory(): string;
|
|
getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode;
|
|
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
|
|
|
getModuleResolutionCache?(): ModuleResolutionCache | undefined;
|
|
trace?(s: string): void;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ModulePath {
|
|
path: string;
|
|
isInNodeModules: boolean;
|
|
isRedirect: boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ResolvedModuleSpecifierInfo {
|
|
kind: "node_modules" | "paths" | "redirect" | "relative" | "ambient" | undefined;
|
|
modulePaths: readonly ModulePath[] | undefined;
|
|
packageName: string | undefined;
|
|
moduleSpecifiers: readonly string[] | undefined;
|
|
isBlockedByPackageJsonDependencies: boolean | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ModuleSpecifierOptions {
|
|
overrideImportMode?: ResolutionMode;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface ModuleSpecifierCache {
|
|
get(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions): Readonly<ResolvedModuleSpecifierInfo> | undefined;
|
|
set(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, kind: ResolvedModuleSpecifierInfo["kind"], modulePaths: readonly ModulePath[], moduleSpecifiers: readonly string[]): void;
|
|
setBlockedByPackageJsonDependencies(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, packageName: string | undefined, isBlockedByPackageJsonDependencies: boolean): void;
|
|
setModulePaths(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, modulePaths: readonly ModulePath[]): void;
|
|
clear(): void;
|
|
count(): number;
|
|
}
|
|
|
|
// Note: this used to be deprecated in our public API, but is still used internally
|
|
/** @internal */
|
|
export interface SymbolTracker {
|
|
// Called when the symbol writer encounters a symbol to write. Currently only used by the
|
|
// declaration emitter to help determine if it should patch up the final declaration file
|
|
// with import statements it previously saw (but chose not to emit).
|
|
trackSymbol?(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags): boolean;
|
|
reportInaccessibleThisError?(): void;
|
|
reportPrivateInBaseOfClassExpression?(propertyName: string): void;
|
|
reportInaccessibleUniqueSymbolError?(): void;
|
|
reportCyclicStructureError?(): void;
|
|
reportLikelyUnsafeImportRequiredError?(specifier: string): void;
|
|
reportTruncationError?(): void;
|
|
moduleResolverHost?: ModuleSpecifierResolutionHost & { getCommonSourceDirectory(): string; };
|
|
reportNonlocalAugmentation?(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): void;
|
|
reportNonSerializableProperty?(propertyName: string): void;
|
|
reportInferenceFallback?(node: Node): void;
|
|
}
|
|
|
|
export interface TextSpan {
|
|
start: number;
|
|
length: number;
|
|
}
|
|
|
|
export interface TextChangeRange {
|
|
span: TextSpan;
|
|
newLength: number;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface DiagnosticCollection {
|
|
// Adds a diagnostic to this diagnostic collection.
|
|
add(diagnostic: Diagnostic): void;
|
|
|
|
// Returns the first existing diagnostic that is equivalent to the given one (sans related information)
|
|
lookup(diagnostic: Diagnostic): Diagnostic | undefined;
|
|
|
|
// Gets all the diagnostics that aren't associated with a file.
|
|
getGlobalDiagnostics(): Diagnostic[];
|
|
|
|
// If fileName is provided, gets all the diagnostics associated with that file name.
|
|
// Otherwise, returns all the diagnostics (global and file associated) in this collection.
|
|
getDiagnostics(): Diagnostic[];
|
|
getDiagnostics(fileName: string): DiagnosticWithLocation[];
|
|
}
|
|
|
|
// dprint-ignore
|
|
export class SyntaxList extends Node<SyntaxKind.SyntaxList, AstSyntaxListData> {
|
|
/** @internal */ get _children(): readonly Node[] { return this.ast.data._children; }
|
|
/** @internal */ set _children(value: readonly Node[]) { this.ast.data._children = value; }
|
|
}
|
|
|
|
// dprint-ignore
|
|
export const enum ListFormat {
|
|
None = 0,
|
|
|
|
// Line separators
|
|
SingleLine = 0, // Prints the list on a single line (default).
|
|
MultiLine = 1 << 0, // Prints the list on multiple lines.
|
|
PreserveLines = 1 << 1, // Prints the list using line preservation if possible.
|
|
LinesMask = SingleLine | MultiLine | PreserveLines,
|
|
|
|
// Delimiters
|
|
NotDelimited = 0, // There is no delimiter between list items (default).
|
|
BarDelimited = 1 << 2, // Each list item is space-and-bar (" |") delimited.
|
|
AmpersandDelimited = 1 << 3, // Each list item is space-and-ampersand (" &") delimited.
|
|
CommaDelimited = 1 << 4, // Each list item is comma (",") delimited.
|
|
AsteriskDelimited = 1 << 5, // Each list item is asterisk ("\n *") delimited, used with JSDoc.
|
|
DelimitersMask = BarDelimited | AmpersandDelimited | CommaDelimited | AsteriskDelimited,
|
|
|
|
AllowTrailingComma = 1 << 6, // Write a trailing comma (",") if present.
|
|
|
|
// Whitespace
|
|
Indented = 1 << 7, // The list should be indented.
|
|
SpaceBetweenBraces = 1 << 8, // Inserts a space after the opening brace and before the closing brace.
|
|
SpaceBetweenSiblings = 1 << 9, // Inserts a space between each sibling node.
|
|
|
|
// Brackets/Braces
|
|
Braces = 1 << 10, // The list is surrounded by "{" and "}".
|
|
Parenthesis = 1 << 11, // The list is surrounded by "(" and ")".
|
|
AngleBrackets = 1 << 12, // The list is surrounded by "<" and ">".
|
|
SquareBrackets = 1 << 13, // The list is surrounded by "[" and "]".
|
|
BracketsMask = Braces | Parenthesis | AngleBrackets | SquareBrackets,
|
|
|
|
OptionalIfUndefined = 1 << 14, // Do not emit brackets if the list is undefined.
|
|
OptionalIfEmpty = 1 << 15, // Do not emit brackets if the list is empty.
|
|
Optional = OptionalIfUndefined | OptionalIfEmpty,
|
|
|
|
// Other
|
|
PreferNewLine = 1 << 16, // Prefer adding a LineTerminator between synthesized nodes.
|
|
NoTrailingNewLine = 1 << 17, // Do not emit a trailing NewLine for a MultiLine list.
|
|
NoInterveningComments = 1 << 18, // Do not emit comments between each node
|
|
NoSpaceIfEmpty = 1 << 19, // If the literal is empty, do not add spaces between braces.
|
|
SingleElement = 1 << 20,
|
|
SpaceAfterList = 1 << 21, // Add space after list
|
|
|
|
// Precomputed Formats
|
|
Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments | SpaceAfterList,
|
|
HeritageClauses = SingleLine | SpaceBetweenSiblings,
|
|
SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings,
|
|
MultiLineTypeLiteralMembers = MultiLine | Indented | OptionalIfEmpty,
|
|
|
|
SingleLineTupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine,
|
|
MultiLineTupleTypeElements = CommaDelimited | Indented | SpaceBetweenSiblings | MultiLine,
|
|
UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine,
|
|
IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine,
|
|
ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings | NoSpaceIfEmpty,
|
|
ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings | NoSpaceIfEmpty,
|
|
ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces | NoSpaceIfEmpty,
|
|
ImportAttributes = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces | NoSpaceIfEmpty,
|
|
/** @deprecated */ ImportClauseEntries = ImportAttributes,
|
|
ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets,
|
|
CommaListElements = CommaDelimited | SpaceBetweenSiblings | SingleLine,
|
|
CallExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis,
|
|
NewExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis | OptionalIfUndefined,
|
|
TemplateExpressionSpans = SingleLine | NoInterveningComments,
|
|
SingleLineBlockStatements = SpaceBetweenBraces | SpaceBetweenSiblings | SingleLine,
|
|
MultiLineBlockStatements = Indented | MultiLine,
|
|
VariableDeclarationList = CommaDelimited | SpaceBetweenSiblings | SingleLine,
|
|
SingleLineFunctionBodyStatements = SingleLine | SpaceBetweenSiblings | SpaceBetweenBraces,
|
|
MultiLineFunctionBodyStatements = MultiLine,
|
|
ClassHeritageClauses = SingleLine,
|
|
ClassMembers = Indented | MultiLine,
|
|
InterfaceMembers = Indented | MultiLine,
|
|
EnumMembers = CommaDelimited | Indented | MultiLine,
|
|
CaseBlockClauses = Indented | MultiLine,
|
|
NamedImportsOrExportsElements = CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | SingleLine | SpaceBetweenBraces | NoSpaceIfEmpty,
|
|
JsxElementOrFragmentChildren = SingleLine | NoInterveningComments,
|
|
JsxElementAttributes = SingleLine | SpaceBetweenSiblings | NoInterveningComments,
|
|
CaseOrDefaultClauseStatements = Indented | MultiLine | NoTrailingNewLine | OptionalIfEmpty,
|
|
HeritageClauseTypes = CommaDelimited | SpaceBetweenSiblings | SingleLine,
|
|
SourceFileStatements = MultiLine | NoTrailingNewLine,
|
|
Decorators = MultiLine | Optional | SpaceAfterList,
|
|
TypeArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | AngleBrackets | Optional,
|
|
TypeParameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | AngleBrackets | Optional,
|
|
Parameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis,
|
|
IndexSignatureParameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented | SquareBrackets,
|
|
JSDocComment = MultiLine | AsteriskDelimited,
|
|
}
|
|
|
|
/** @internal */
|
|
export const enum PragmaKindFlags {
|
|
None = 0,
|
|
/**
|
|
* Triple slash comment of the form
|
|
* /// <pragma-name argname="value" />
|
|
*/
|
|
TripleSlashXML = 1 << 0,
|
|
/**
|
|
* Single line comment of the form
|
|
* // @pragma-name argval1 argval2
|
|
* or
|
|
* /// @pragma-name argval1 argval2
|
|
*/
|
|
SingleLine = 1 << 1,
|
|
/**
|
|
* Multiline non-jsdoc pragma of the form
|
|
* /* @pragma-name argval1 argval2 * /
|
|
*/
|
|
MultiLine = 1 << 2,
|
|
All = TripleSlashXML | SingleLine | MultiLine,
|
|
Default = All,
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PragmaArgumentSpecification<TName extends string> {
|
|
name: TName; // Determines the name of the key in the resulting parsed type, type parameter to cause literal type inference
|
|
optional?: boolean;
|
|
captureSpan?: boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface PragmaDefinition<T1 extends string = string, T2 extends string = string, T3 extends string = string, T4 extends string = string> {
|
|
args?:
|
|
| readonly [PragmaArgumentSpecification<T1>]
|
|
| readonly [PragmaArgumentSpecification<T1>, PragmaArgumentSpecification<T2>]
|
|
| readonly [PragmaArgumentSpecification<T1>, PragmaArgumentSpecification<T2>, PragmaArgumentSpecification<T3>]
|
|
| readonly [PragmaArgumentSpecification<T1>, PragmaArgumentSpecification<T2>, PragmaArgumentSpecification<T3>, PragmaArgumentSpecification<T4>];
|
|
// If not present, defaults to PragmaKindFlags.Default
|
|
kind?: PragmaKindFlags;
|
|
}
|
|
|
|
// While not strictly a type, this is here because `PragmaMap` needs to be here to be used with `SourceFile`, and we don't
|
|
// fancy effectively defining it twice, once in value-space and once in type-space
|
|
/** @internal */
|
|
export const commentPragmas: ConcretePragmaSpecs = {
|
|
"reference": {
|
|
args: [
|
|
{ name: "types", optional: true, captureSpan: true },
|
|
{ name: "lib", optional: true, captureSpan: true },
|
|
{ name: "path", optional: true, captureSpan: true },
|
|
{ name: "no-default-lib", optional: true },
|
|
{ name: "resolution-mode", optional: true },
|
|
{ name: "preserve", optional: true },
|
|
],
|
|
kind: PragmaKindFlags.TripleSlashXML,
|
|
},
|
|
"amd-dependency": {
|
|
args: [{ name: "path" }, { name: "name", optional: true }],
|
|
kind: PragmaKindFlags.TripleSlashXML,
|
|
},
|
|
"amd-module": {
|
|
args: [{ name: "name" }],
|
|
kind: PragmaKindFlags.TripleSlashXML,
|
|
},
|
|
"ts-check": {
|
|
kind: PragmaKindFlags.SingleLine,
|
|
},
|
|
"ts-nocheck": {
|
|
kind: PragmaKindFlags.SingleLine,
|
|
},
|
|
"jsx": {
|
|
args: [{ name: "factory" }],
|
|
kind: PragmaKindFlags.MultiLine,
|
|
},
|
|
"jsxfrag": {
|
|
args: [{ name: "factory" }],
|
|
kind: PragmaKindFlags.MultiLine,
|
|
},
|
|
"jsximportsource": {
|
|
args: [{ name: "factory" }],
|
|
kind: PragmaKindFlags.MultiLine,
|
|
},
|
|
"jsxruntime": {
|
|
args: [{ name: "factory" }],
|
|
kind: PragmaKindFlags.MultiLine,
|
|
},
|
|
} as const;
|
|
|
|
export const enum JSDocParsingMode {
|
|
/**
|
|
* Always parse JSDoc comments and include them in the AST.
|
|
*
|
|
* This is the default if no mode is provided.
|
|
*/
|
|
ParseAll,
|
|
/**
|
|
* Never parse JSDoc comments, mo matter the file type.
|
|
*/
|
|
ParseNone,
|
|
/**
|
|
* Parse only JSDoc comments which are needed to provide correct type errors.
|
|
*
|
|
* This will always parse JSDoc in non-TS files, but only parse JSDoc comments
|
|
* containing `@see` and `@link` in TS files.
|
|
*/
|
|
ParseForTypeErrors,
|
|
/**
|
|
* Parse only JSDoc comments which are needed to provide correct type info.
|
|
*
|
|
* This will always parse JSDoc in non-TS files, but never in TS files.
|
|
*
|
|
* Note: Do not use this mode if you require accurate type errors; use {@link ParseForTypeErrors} instead.
|
|
*/
|
|
ParseForTypeInfo,
|
|
}
|
|
|
|
/** @internal */
|
|
export type PragmaArgTypeMaybeCapture<TDesc> = TDesc extends { captureSpan: true; } ? { value: string; pos: number; end: number; } : string;
|
|
|
|
/** @internal */
|
|
export type PragmaArgTypeOptional<TDesc, TName extends string> = TDesc extends { optional: true; } ? { [K in TName]?: PragmaArgTypeMaybeCapture<TDesc>; }
|
|
: { [K in TName]: PragmaArgTypeMaybeCapture<TDesc>; };
|
|
|
|
/** @internal */
|
|
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
|
|
/** @internal */
|
|
export type ArgumentDefinitionToFieldUnion<T extends readonly PragmaArgumentSpecification<any>[]> = {
|
|
[K in keyof T]: PragmaArgTypeOptional<T[K], T[K] extends { name: infer TName; } ? TName extends string ? TName : never : never>;
|
|
}[Extract<keyof T, number>]; // The mapped type maps over only the tuple members, but this reindex gets _all_ members - by extracting only `number` keys, we get only the tuple members
|
|
|
|
/**
|
|
* Maps a pragma definition into the desired shape for its arguments object
|
|
*
|
|
* @internal
|
|
*/
|
|
export type PragmaArgumentType<KPrag extends keyof ConcretePragmaSpecs> = ConcretePragmaSpecs[KPrag] extends { args: readonly PragmaArgumentSpecification<any>[]; } ? UnionToIntersection<ArgumentDefinitionToFieldUnion<ConcretePragmaSpecs[KPrag]["args"]>>
|
|
: never;
|
|
|
|
/** @internal */
|
|
export interface ConcretePragmaSpecs {
|
|
readonly "reference": {
|
|
readonly args: readonly [{
|
|
readonly name: "types";
|
|
readonly optional: true;
|
|
readonly captureSpan: true;
|
|
}, {
|
|
readonly name: "lib";
|
|
readonly optional: true;
|
|
readonly captureSpan: true;
|
|
}, {
|
|
readonly name: "path";
|
|
readonly optional: true;
|
|
readonly captureSpan: true;
|
|
}, {
|
|
readonly name: "no-default-lib";
|
|
readonly optional: true;
|
|
}, {
|
|
readonly name: "resolution-mode";
|
|
readonly optional: true;
|
|
}, {
|
|
readonly name: "preserve";
|
|
readonly optional: true;
|
|
}];
|
|
readonly kind: PragmaKindFlags.TripleSlashXML;
|
|
};
|
|
readonly "amd-dependency": {
|
|
readonly args: readonly [{
|
|
readonly name: "path";
|
|
}, {
|
|
readonly name: "name";
|
|
readonly optional: true;
|
|
}];
|
|
readonly kind: PragmaKindFlags.TripleSlashXML;
|
|
};
|
|
readonly "amd-module": {
|
|
readonly args: readonly [{
|
|
readonly name: "name";
|
|
}];
|
|
readonly kind: PragmaKindFlags.TripleSlashXML;
|
|
};
|
|
readonly "ts-check": {
|
|
readonly kind: PragmaKindFlags.SingleLine;
|
|
};
|
|
readonly "ts-nocheck": {
|
|
readonly kind: PragmaKindFlags.SingleLine;
|
|
};
|
|
readonly "jsx": {
|
|
readonly args: readonly [{
|
|
readonly name: "factory";
|
|
}];
|
|
readonly kind: PragmaKindFlags.MultiLine;
|
|
};
|
|
readonly "jsxfrag": {
|
|
readonly args: readonly [{
|
|
readonly name: "factory";
|
|
}];
|
|
readonly kind: PragmaKindFlags.MultiLine;
|
|
};
|
|
readonly "jsximportsource": {
|
|
readonly args: readonly [{
|
|
readonly name: "factory";
|
|
}];
|
|
readonly kind: PragmaKindFlags.MultiLine;
|
|
};
|
|
readonly "jsxruntime": {
|
|
readonly args: readonly [{
|
|
readonly name: "factory";
|
|
}];
|
|
readonly kind: PragmaKindFlags.MultiLine;
|
|
};
|
|
}
|
|
|
|
/** @internal */
|
|
export type PragmaPseudoMap = { [K in keyof ConcretePragmaSpecs]: { arguments: PragmaArgumentType<K>; range: CommentRange; }; };
|
|
|
|
/** @internal */
|
|
export type PragmaPseudoMapEntry = { [K in keyof PragmaPseudoMap]: { name: K; args: PragmaPseudoMap[K]; }; }[keyof PragmaPseudoMap];
|
|
|
|
/** @internal */
|
|
export interface ReadonlyPragmaMap extends ReadonlyMap<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]> {
|
|
get<TKey extends keyof PragmaPseudoMap>(key: TKey): PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][];
|
|
forEach(action: <TKey extends keyof PragmaPseudoMap>(value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][], key: TKey, map: ReadonlyPragmaMap) => void): void;
|
|
}
|
|
|
|
/**
|
|
* A strongly-typed es6 map of pragma entries, the values of which are either a single argument
|
|
* value (if only one was found), or an array of multiple argument values if the pragma is present
|
|
* in multiple places
|
|
*
|
|
* @internal
|
|
*/
|
|
export interface PragmaMap extends Map<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]>, ReadonlyPragmaMap {
|
|
set<TKey extends keyof PragmaPseudoMap>(key: TKey, value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][]): this;
|
|
get<TKey extends keyof PragmaPseudoMap>(key: TKey): PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][];
|
|
forEach(action: <TKey extends keyof PragmaPseudoMap>(value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][], key: TKey, map: PragmaMap) => void): void;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface CommentDirectivesMap {
|
|
getUnusedExpectations(): CommentDirective[];
|
|
markUsed(matchedLine: number): boolean;
|
|
}
|
|
|
|
export interface UserPreferences {
|
|
readonly disableSuggestions?: boolean;
|
|
readonly quotePreference?: "auto" | "double" | "single";
|
|
/**
|
|
* If enabled, TypeScript will search through all external modules' exports and add them to the completions list.
|
|
* This affects lone identifier completions but not completions on the right hand side of `obj.`.
|
|
*/
|
|
readonly includeCompletionsForModuleExports?: boolean;
|
|
/**
|
|
* Enables auto-import-style completions on partially-typed import statements. E.g., allows
|
|
* `import write|` to be completed to `import { writeFile } from "fs"`.
|
|
*/
|
|
readonly includeCompletionsForImportStatements?: boolean;
|
|
/**
|
|
* Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`.
|
|
*/
|
|
readonly includeCompletionsWithSnippetText?: boolean;
|
|
/**
|
|
* Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled,
|
|
* member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined
|
|
* values, with insertion text to replace preceding `.` tokens with `?.`.
|
|
*/
|
|
readonly includeAutomaticOptionalChainCompletions?: boolean;
|
|
/**
|
|
* If enabled, the completion list will include completions with invalid identifier names.
|
|
* For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`.
|
|
*/
|
|
readonly includeCompletionsWithInsertText?: boolean;
|
|
/**
|
|
* If enabled, completions for class members (e.g. methods and properties) will include
|
|
* a whole declaration for the member.
|
|
* E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of
|
|
* `class A { foo }`.
|
|
*/
|
|
readonly includeCompletionsWithClassMemberSnippets?: boolean;
|
|
/**
|
|
* If enabled, object literal methods will have a method declaration completion entry in addition
|
|
* to the regular completion entry containing just the method name.
|
|
* E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`,
|
|
* in addition to `const objectLiteral: T = { foo }`.
|
|
*/
|
|
readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
|
|
/**
|
|
* Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported.
|
|
* If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property.
|
|
*/
|
|
readonly useLabelDetailsInCompletionEntries?: boolean;
|
|
readonly allowIncompleteCompletions?: boolean;
|
|
readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
|
|
/** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */
|
|
readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js";
|
|
readonly allowTextChangesInNewFiles?: boolean;
|
|
readonly providePrefixAndSuffixTextForRename?: boolean;
|
|
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
|
|
readonly provideRefactorNotApplicableReason?: boolean;
|
|
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
|
|
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
|
|
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
|
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
|
readonly includeInlayVariableTypeHints?: boolean;
|
|
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
|
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
|
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
|
readonly includeInlayEnumMemberValueHints?: boolean;
|
|
readonly interactiveInlayHints?: boolean;
|
|
readonly allowRenameOfImportPath?: boolean;
|
|
readonly autoImportFileExcludePatterns?: string[];
|
|
readonly autoImportSpecifierExcludeRegexes?: string[];
|
|
readonly preferTypeOnlyAutoImports?: boolean;
|
|
/**
|
|
* Indicates whether imports should be organized in a case-insensitive manner.
|
|
*/
|
|
readonly organizeImportsIgnoreCase?: "auto" | boolean;
|
|
/**
|
|
* Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value
|
|
* of their code points, or via "unicode" collation (via the
|
|
* [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale
|
|
* specified in {@link organizeImportsCollationLocale}.
|
|
*
|
|
* Default: `"ordinal"`.
|
|
*/
|
|
readonly organizeImportsCollation?: "ordinal" | "unicode";
|
|
/**
|
|
* Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant
|
|
* for the sake of consistent sorting. Use `"auto"` to use the detected UI locale.
|
|
*
|
|
* This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`.
|
|
*
|
|
* Default: `"en"`
|
|
*/
|
|
readonly organizeImportsLocale?: string;
|
|
/**
|
|
* Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate
|
|
* strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`.
|
|
*
|
|
* This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`.
|
|
*
|
|
* Default: `false`
|
|
*/
|
|
readonly organizeImportsNumericCollation?: boolean;
|
|
/**
|
|
* Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When
|
|
* `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified
|
|
* in {@link organizeImportsCollationLocale}.
|
|
*
|
|
* This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`.
|
|
*
|
|
* Default: `true`
|
|
*/
|
|
readonly organizeImportsAccentCollation?: boolean;
|
|
/**
|
|
* Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale
|
|
* specified in {@link organizeImportsCollationLocale} is used.
|
|
*
|
|
* This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. This preference is also
|
|
* ignored if we are using case-insensitive sorting, which occurs when {@link organizeImportsIgnoreCase} is `true`,
|
|
* or if {@link organizeImportsIgnoreCase} is `"auto"` and the auto-detected case sensitivity is determined to be
|
|
* case-insensitive.
|
|
*
|
|
* Default: `false`
|
|
*/
|
|
readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
|
|
/**
|
|
* Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is
|
|
* type-only.
|
|
*
|
|
* Default: `last`
|
|
*/
|
|
readonly organizeImportsTypeOrder?: OrganizeImportsTypeOrder;
|
|
/**
|
|
* Indicates whether to exclude standard library and node_modules file symbols from navTo results.
|
|
*/
|
|
readonly excludeLibrarySymbolsInNavTo?: boolean;
|
|
readonly lazyConfiguredProjectsFromExternalProject?: boolean;
|
|
readonly displayPartsForJSDoc?: boolean;
|
|
readonly generateReturnInDocTemplate?: boolean;
|
|
readonly disableLineTextInReferences?: boolean;
|
|
}
|
|
|
|
export type OrganizeImportsTypeOrder = "last" | "inline" | "first";
|
|
|
|
/** Represents a bigint literal value without requiring bigint support */
|
|
export interface PseudoBigInt {
|
|
negative: boolean;
|
|
base10Value: string;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface Queue<T> {
|
|
enqueue(...items: T[]): void;
|
|
dequeue(): T;
|
|
isEmpty(): boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface EvaluationResolver {
|
|
evaluateEntityNameExpression(expr: EntityNameExpression, location: Declaration | undefined): EvaluatorResult;
|
|
evaluateElementAccessExpression(expr: ElementAccessExpression, location: Declaration | undefined): EvaluatorResult;
|
|
}
|
|
|
|
/** @internal */
|
|
export type HasInferredType =
|
|
| PropertyAssignment
|
|
| PropertyAccessExpression
|
|
| BinaryExpression
|
|
| ElementAccessExpression
|
|
| VariableDeclaration
|
|
| ParameterDeclaration
|
|
| BindingElement
|
|
| PropertyDeclaration
|
|
| PropertySignature
|
|
| ExportAssignment;
|
|
|
|
/** @internal */
|
|
export interface SyntacticTypeNodeBuilderContext {
|
|
tracker: Required<Pick<SymbolTracker, "reportInferenceFallback">>;
|
|
enclosingDeclaration: Node | undefined;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SyntacticTypeNodeBuilderResolver {
|
|
isUndefinedIdentifierExpression(name: Identifier): boolean;
|
|
isExpandoFunctionDeclaration(name: FunctionDeclaration | VariableDeclaration): boolean;
|
|
getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations;
|
|
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node, shouldComputeAliasToMakeVisible?: boolean): SymbolVisibilityResult;
|
|
requiresAddingImplicitUndefined(parameter: ParameterDeclaration | JSDocParameterTag, enclosingDeclaration: Node | undefined): boolean;
|
|
isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean;
|
|
}
|
|
|
|
/** @internal */
|
|
export interface SyntacticNodeBuilder {
|
|
typeFromExpression: (node: Expression, context: SyntacticTypeNodeBuilderContext, isConstContext?: boolean, requiresAddingUndefined?: boolean, preserveLiterals?: boolean) => boolean | undefined;
|
|
serializeTypeOfDeclaration: (node: HasInferredType, context: SyntacticTypeNodeBuilderContext) => boolean | undefined;
|
|
serializeReturnTypeForSignature: (node: SignatureDeclaration | JSDocSignature, context: SyntacticTypeNodeBuilderContext) => boolean | undefined;
|
|
serializeTypeOfExpression: (expr: Expression, context: SyntacticTypeNodeBuilderContext, addUndefined?: boolean, preserveLiterals?: boolean) => boolean;
|
|
}
|