import ts from 'typescript'; import { RttiContext } from './rtti-context'; export declare function assert(check: () => boolean): void; export declare function isInterfaceType(type: ts.Type): boolean; export declare function getRootNameOfQualifiedName(qualifiedName: ts.QualifiedName): string; export declare function getRootNameOfEntityName(entityName: ts.EntityName): string; export declare function hasFlag(flags: number, flag: number): boolean; export declare function hasAnyFlag(flags: number, possibleFlags: number[]): boolean; export declare function isFlagType(type: ts.Type, flag: number): type is T; export declare function cloneQualifiedName(qualifiedName: ts.QualifiedName, rootName?: string): any; export declare function cloneEntityNameAsExpr(entityName: ts.EntityName, rootName?: string): any; export declare function qualifiedNameToString(qualifiedName: ts.QualifiedName): any; export declare function entityNameToString(entityName: ts.EntityName): any; export type SerializedEntityNameAsExpression = ts.Identifier | ts.BinaryExpression | ts.PropertyAccessExpression; export type Mutable = { -readonly [K in keyof T]: T[K]; }; /** * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw * * @param node The entity name to serialize. */ export declare function serializeEntityNameAsExpressionFallback(node: ts.EntityName, context: ts.TransformationContext, currentLexicalScope: ts.SourceFile | ts.Block | ts.ModuleBlock | ts.CaseBlock): ts.BinaryExpression; /** * Serializes an entity name as an expression for decorator type metadata. * * @param node The entity name to serialize. */ export declare function serializeEntityNameAsExpression(node: ts.EntityName, currentLexicalScope: ts.SourceFile | ts.Block | ts.ModuleBlock | ts.CaseBlock): ts.Identifier | ts.PropertyAccessExpression; export declare function dottedNameToExpr(dottedName: string): ts.Identifier | ts.PropertyAccessExpression; export declare function replacePropertyRoot(propertyExpr: ts.PropertyAccessExpression, newRootExpr: ts.Expression): any; export declare function getPropertyRoot(propertyExpr: ts.PropertyAccessExpression): any; /** * Uses the `oe` utility function to perform a dynamic access of an object. This is used to ensure that * RTTI-specific exports which may not be present do not cause problems in build systems which statically * analyze whether the referenced export exists. (ie Angular's build process). * * Given optionalExportRef(, ), * outputs: __RΦ.oe(, '') * * Given optionalExportRef(, ), * outputs: __RΦ.oe(, '')[] * * @returns */ export declare function optionalExportRef(object: ts.Expression, expr: ts.Identifier | ts.PropertyAccessExpression): any; export declare function propertyPrepend(expr: ts.Expression, propAccess: ts.PropertyAccessExpression | ts.Identifier): ts.Expression; export declare function expressionForPropertyName(propName: ts.PropertyName): ts.Expression; export declare function propertyNameToString(propName: ts.PropertyName): string; export declare function hasModifier(modifiers: readonly ts.Modifier[] | undefined, modifier: ts.SyntaxKind): boolean; export declare function hasModifiers(modifiersArray: readonly ts.Modifier[] | undefined, modifiers: ts.SyntaxKind[]): boolean; export declare function getModifiers(node: ts.Node): readonly ts.Modifier[]; export declare function getDecorators(node: ts.Node): readonly ts.Decorator[]; export declare function referenceImportedSymbol(ctx: RttiContext, modulePath: string, identifier: string, hasValue?: boolean, importDecl?: ts.Statement): ts.PropertyAccessExpression | ts.BinaryExpression; export declare function isExternalOrCommonJsModule(file: ts.SourceFile): boolean; export declare function externalModules(program: ts.Program): Generator<[ts.Symbol, ts.SourceFile?]>; export declare function removeTrailingSlash(path: string): string; export declare function getDirectoryPath(path: string): string; export type Path = string & { __pathBrand: any; }; /** * Determines whether a path has a trailing separator (`/` or `\\`). */ export declare function hasTrailingDirectorySeparator(path: string): boolean; /** * Determines whether a charCode corresponds to `/` or `\`. */ export declare function isAnyDirectorySeparator(charCode: number): boolean; /** * Removes a trailing directory separator from a path, if it does not already have one. * * ```ts * removeTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext" * removeTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext" * ``` */ export declare function removeTrailingDirectorySeparator(path: Path): Path; export declare function removeTrailingDirectorySeparator(path: string): string; /** * Returns the path except for its containing directory name. * Semantics align with NodeJS's `path.basename` except that we support URL's as well. * * ```ts * // POSIX * getBaseFileName("/path/to/file.ext") === "file.ext" * getBaseFileName("/path/to/") === "to" * getBaseFileName("/") === "" * // DOS * getBaseFileName("c:/path/to/file.ext") === "file.ext" * getBaseFileName("c:/path/to/") === "to" * getBaseFileName("c:/") === "" * getBaseFileName("c:") === "" * // URL * getBaseFileName("http://typescriptlang.org/path/to/file.ext") === "file.ext" * getBaseFileName("http://typescriptlang.org/path/to/") === "to" * getBaseFileName("http://typescriptlang.org/") === "" * getBaseFileName("http://typescriptlang.org") === "" * getBaseFileName("file://server/path/to/file.ext") === "file.ext" * getBaseFileName("file://server/path/to/") === "to" * getBaseFileName("file://server/") === "" * getBaseFileName("file://server") === "" * getBaseFileName("file:///path/to/file.ext") === "file.ext" * getBaseFileName("file:///path/to/") === "to" * getBaseFileName("file:///") === "" * getBaseFileName("file://") === "" * ``` */ export declare function getBaseFileName(path: string): string; /** * Gets the portion of a path following the last (non-terminal) separator (`/`). * Semantics align with NodeJS's `path.basename` except that we support URL's as well. * If the base name has any one of the provided extensions, it is removed. * * ```ts * getBaseFileName("/path/to/file.ext", ".ext", true) === "file" * getBaseFileName("/path/to/file.js", ".ext", true) === "file.js" * getBaseFileName("/path/to/file.js", [".ext", ".js"], true) === "file" * getBaseFileName("/path/to/file.ext", ".EXT", false) === "file.ext" * ``` */ export declare function getBaseFileName(path: string, extensions: string | readonly string[], ignoreCase: boolean): string; export declare const directorySeparator = "/"; export declare const altDirectorySeparator = "\\"; /** * Compare the equality of two strings using a case-sensitive ordinal comparison. * * Case-sensitive comparisons compare both strings one code-point at a time using the integer * value of each code-point after applying `toUpperCase` to each string. We always map both * strings to their upper-case form as some unicode characters do not properly round-trip to * lowercase (such as `ẞ` (German sharp capital s)). */ export declare function equateStringsCaseInsensitive(a: string, b: string): boolean; /** * Compare the equality of two strings using a case-sensitive ordinal comparison. * * Case-sensitive comparisons compare both strings one code-point at a time using the * integer value of each code-point. */ export declare function equateStringsCaseSensitive(a: string, b: string): boolean; /** * Gets the file extension for a path, provided it is one of the provided extensions. * * ```ts * getAnyExtensionFromPath("/path/to/file.ext", ".ext", true) === ".ext" * getAnyExtensionFromPath("/path/to/file.js", ".ext", true) === "" * getAnyExtensionFromPath("/path/to/file.js", [".ext", ".js"], true) === ".js" * getAnyExtensionFromPath("/path/to/file.ext", ".EXT", false) === "" */ export declare function getAnyExtensionFromPath(path: string, extensions: string | readonly string[], ignoreCase: boolean): string; /** * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). * * For example: * ```ts * getRootLength("a") === 0 // "" * getRootLength("/") === 1 // "/" * getRootLength("c:") === 2 // "c:" * getRootLength("c:d") === 0 // "" * getRootLength("c:/") === 3 // "c:/" * getRootLength("c:\\") === 3 // "c:\\" * getRootLength("//server") === 7 // "//server" * getRootLength("//server/share") === 8 // "//server/" * getRootLength("\\\\server") === 7 // "\\\\server" * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" * getRootLength("file:///path") === 8 // "file:///" * getRootLength("file:///c:") === 10 // "file:///c:" * getRootLength("file:///c:d") === 8 // "file:///" * getRootLength("file:///c:/path") === 11 // "file:///c:/" * getRootLength("file://server") === 13 // "file://server" * getRootLength("file://server/path") === 14 // "file://server/" * getRootLength("http://server") === 13 // "http://server" * getRootLength("http://server/path") === 14 // "http://server/" * ``` */ export declare function getRootLength(path: string): number; /** * Normalize path separators, converting `\` into `/`. */ export declare function normalizeSlashes(path: string): string; export declare function getParentOfSymbol(symbol: ts.Symbol): ts.Symbol; export declare const enum ImportKind { Named = 0, Default = 1, Namespace = 2, CommonJS = 3 } export declare function getDefaultLikeExportInfo(importingFile: ts.SourceFile, moduleSymbol: ts.Symbol, checker: ts.TypeChecker, compilerOptions: ts.CompilerOptions): { readonly symbol: ts.Symbol; readonly symbolForMeaning: ts.Symbol; readonly name?: string; readonly kind: ImportKind; } | undefined; export declare function getNameForExportedSymbol(symbol: ts.Symbol, scriptTarget: ts.ScriptTarget | undefined): string; export declare function getNameForExportDefault(symbol: ts.Symbol): string | undefined; export declare function getDefaultLikeExportWorker(importingFile: ts.SourceFile, moduleSymbol: ts.Symbol, checker: ts.TypeChecker, compilerOptions: ts.CompilerOptions): { readonly symbol: ts.Symbol; readonly kind: ImportKind; } | undefined; export declare function getExportEqualsImportKind(importingFile: ts.SourceFile, compilerOptions: ts.CompilerOptions): ImportKind; export declare function getEmitModuleKind(compilerOptions: { module?: ts.CompilerOptions["module"]; target?: ts.CompilerOptions["target"]; }): ts.ModuleKind; export declare function getEmitScriptTarget(compilerOptions: ts.CompilerOptions): ts.ScriptTarget; export declare function getAllowSyntheticDefaultImports(compilerOptions: ts.CompilerOptions): boolean; export declare function isInJSFile(node: ts.Node | undefined): boolean; export declare function isExternalModule(file: ts.SourceFile): boolean; export declare function getLocalSymbolForExportDefault(symbol: ts.Symbol): any; export declare function isExportDefaultSymbol(symbol: ts.Symbol): boolean; export declare function skipOuterExpressions(node: ts.Expression, kinds?: ts.OuterExpressionKinds): ts.Expression; export declare function skipOuterExpressions(node: ts.Node, kinds?: ts.OuterExpressionKinds): ts.Node; export declare function isOuterExpression(node: ts.Node, kinds?: ts.OuterExpressionKinds): node is OuterExpression; export declare function isExportAssignment(node: ts.Node): node is ts.ExportAssignment; export type OuterExpression = ts.ParenthesizedExpression | ts.TypeAssertion | ts.AsExpression | ts.NonNullExpression | ts.PartiallyEmittedExpression; export declare function moduleSymbolToValidIdentifier(moduleSymbol: ts.Symbol, target: ts.ScriptTarget | undefined): string; export declare function removeSuffix(str: string, suffix: string): string; export declare function getRttiDocTagFromNode(element: ts.Node, tagName: string): string; export declare function getRttiDocTagFromSignature(signature: ts.Signature, tagName: string): string; export declare function isUnicodeIdentifierStart(code: number, languageVersion: ts.ScriptTarget | undefined): boolean; export declare function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target: ts.ScriptTarget | undefined): string; export declare function isIdentifierStart(ch: number, languageVersion: ts.ScriptTarget | undefined): boolean; export declare function isIdentifierPart(ch: number, languageVersion: ts.ScriptTarget | undefined, identifierVariant?: ts.LanguageVariant): boolean; export declare function isStringANonContextualKeyword(name: string): boolean; export declare function isNonContextualKeyword(token: ts.SyntaxKind): boolean; export declare function isKeyword(token: ts.SyntaxKind): boolean; export declare function isContextualKeyword(token: ts.SyntaxKind): boolean; export interface MapLike { [index: string]: T; } export declare function getEntries(obj: MapLike): [string, T][]; /** * Gets the owned, enumerable property keys of a map-like. */ export declare function getOwnKeys(map: MapLike): string[]; export declare function stringToToken(s: string): ts.SyntaxKind | undefined; /** * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ export declare function stripQuotes(name: string): string; export declare function isQuoteOrBacktick(charCode: number): boolean; export declare function removeFileExtension(path: string): string; export declare function tryRemoveExtension(path: string, extension: string): string | undefined; export declare function removeExtension(path: string, extension: string): string; export declare const enum CharacterCodes { nullCharacter = 0, maxAsciiCharacter = 127, lineFeed = 10, carriageReturn = 13, lineSeparator = 8232, paragraphSeparator = 8233, nextLine = 133, space = 32, nonBreakingSpace = 160, enQuad = 8192, emQuad = 8193, enSpace = 8194, emSpace = 8195, threePerEmSpace = 8196, fourPerEmSpace = 8197, sixPerEmSpace = 8198, figureSpace = 8199, punctuationSpace = 8200, thinSpace = 8201, hairSpace = 8202, zeroWidthSpace = 8203, narrowNoBreakSpace = 8239, ideographicSpace = 12288, mathematicalSpace = 8287, ogham = 5760, _ = 95, $ = 36, _0 = 48, _1 = 49, _2 = 50, _3 = 51, _4 = 52, _5 = 53, _6 = 54, _7 = 55, _8 = 56, _9 = 57, a = 97, b = 98, c = 99, d = 100, e = 101, f = 102, g = 103, h = 104, i = 105, j = 106, k = 107, l = 108, m = 109, n = 110, o = 111, p = 112, q = 113, r = 114, s = 115, t = 116, u = 117, v = 118, w = 119, x = 120, y = 121, z = 122, A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85, V = 86, W = 87, X = 88, Y = 89, Z = 90, ampersand = 38, asterisk = 42, at = 64, backslash = 92, backtick = 96, bar = 124, caret = 94, closeBrace = 125, closeBracket = 93, closeParen = 41, colon = 58, comma = 44, dot = 46, doubleQuote = 34, equals = 61, exclamation = 33, greaterThan = 62, hash = 35, lessThan = 60, minus = 45, openBrace = 123, openBracket = 91, openParen = 40, percent = 37, plus = 43, question = 63, semicolon = 59, singleQuote = 39, slash = 47, tilde = 126, backspace = 8, formFeed = 12, byteOrderMark = 65279, tab = 9, verticalTab = 11 } export declare function isTypeOnlySymbol(s: ts.Symbol, checker: ts.TypeChecker): boolean; export declare function skipAlias(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol; /** * True if this type has a value at runtime (ie a class, Promise, or other reified type) * @param type * @returns */ export declare function typeHasValue(type: ts.Type): boolean; export declare function isNodeJS(): boolean; export declare function hasGlobalFlag(name: string): boolean; export declare function setGlobalFlag(name: string, value: any): void; export declare function resolveName(checker: ts.TypeChecker, location: ts.Node, name: string, meaning: ts.SymbolFlags, excludeGlobals: boolean): ts.Symbol; export declare function isStatement(node: ts.Node): node is ts.Statement; export declare function getTypeLocality(ctx: RttiContext, type: ts.Type, typeNode: ts.TypeNode): 'local' | 'imported' | 'global'; export declare function hasFilesystemAccess(): boolean; export declare function fileExists(filename: string): any; //# sourceMappingURL=utils.d.ts.map