Comparing version 1.1.0 to 1.2.0
@@ -8,7 +8,10 @@ "use strict"; | ||
tslib_1.__exportStar(require("./JSDocClassTag"), exports); | ||
tslib_1.__exportStar(require("./JSDocFunctionType"), exports); | ||
tslib_1.__exportStar(require("./JSDocParameterTag"), exports); | ||
tslib_1.__exportStar(require("./JSDocPropertyTag"), exports); | ||
tslib_1.__exportStar(require("./JSDocReturnTag"), exports); | ||
tslib_1.__exportStar(require("./JSDocSignature"), exports); | ||
tslib_1.__exportStar(require("./JSDocTag"), exports); | ||
tslib_1.__exportStar(require("./JSDocTagInfo"), exports); | ||
tslib_1.__exportStar(require("./JSDocType"), exports); | ||
tslib_1.__exportStar(require("./JSDocTypedefTag"), exports); | ||
@@ -15,0 +18,0 @@ tslib_1.__exportStar(require("./JSDocTypeTag"), exports); |
@@ -13,4 +13,10 @@ "use strict"; | ||
} | ||
/** | ||
* Gets the type expression node of the JS doc property return tag. | ||
*/ | ||
JSDocReturnTag.prototype.getTypeExpression = function () { | ||
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression); | ||
}; | ||
return JSDocReturnTag; | ||
}(JSDocTag_1.JSDocTag)); | ||
exports.JSDocReturnTag = JSDocReturnTag; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var __1 = require(".."); | ||
var type_1 = require("../type"); | ||
/** | ||
@@ -20,3 +20,3 @@ * JS doc type expression node. | ||
return JSDocTypeExpression; | ||
}(__1.Node)); | ||
}(type_1.TypeNode)); | ||
exports.JSDocTypeExpression = JSDocTypeExpression; |
@@ -13,4 +13,14 @@ "use strict"; | ||
} | ||
/** | ||
* Gets the type expression node of the JS doc property type tag. | ||
*/ | ||
JSDocTypeTag.prototype.getTypeExpression = function () { | ||
// for some reason the compiler will still return a node when it doesn't exist | ||
var node = this.compilerNode.typeExpression; | ||
if (node != null && node.pos === node.end) | ||
return undefined; | ||
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression); | ||
}; | ||
return JSDocTypeTag; | ||
}(JSDocTag_1.JSDocTag)); | ||
exports.JSDocTypeTag = JSDocTypeTag; |
@@ -10,2 +10,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./ImportTypeNode"), exports); | ||
tslib_1.__exportStar(require("./IndexedAccessTypeNode"), exports); | ||
tslib_1.__exportStar(require("./IntersectionTypeNode"), exports); | ||
@@ -12,0 +13,0 @@ tslib_1.__exportStar(require("./LiteralTypeNode"), exports); |
@@ -61,4 +61,15 @@ "use strict"; | ||
}; | ||
/** | ||
* Gets the signature's declaration. | ||
*/ | ||
Signature.prototype.getDeclaration = function () { | ||
var compilerFactory = this._context.compilerFactory; | ||
// the compiler says this is non-nullable, but it can return undefined for an unknown signature | ||
// returned by calling `TypeChecker#getResolvedType()`; however, we're returning undefined in that scenario | ||
// and so this should never be null (hopefully) | ||
var compilerSignatureDeclaration = this.compilerSignature.getDeclaration(); | ||
return compilerFactory.getNodeFromCompilerNode(compilerSignatureDeclaration, compilerFactory.getSourceFileForNode(compilerSignatureDeclaration)); | ||
}; | ||
return Signature; | ||
}()); | ||
exports.Signature = Signature; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var typescript_1 = require("../../typescript"); | ||
var errors = require("../../errors"); | ||
/** | ||
@@ -158,2 +159,19 @@ * Wrapper around the TypeChecker. | ||
/** | ||
* Gets the resolved signature from a node or returns undefined if the signature can't be resolved. | ||
* @param node - Node to get the signature from. | ||
*/ | ||
TypeChecker.prototype.getResolvedSignature = function (node) { | ||
var resolvedSignature = this.compilerObject.getResolvedSignature(node.compilerNode); | ||
if (!resolvedSignature || !resolvedSignature.declaration) | ||
return undefined; | ||
return this._context.compilerFactory.getSignature(resolvedSignature); | ||
}; | ||
/** | ||
* Gets the resolved signature from a node or throws if the signature cannot be resolved. | ||
* @param node - Node to get the signature from. | ||
*/ | ||
TypeChecker.prototype.getResolvedSignatureOrThrow = function (node) { | ||
return errors.throwIfNullOrUndefined(this.getResolvedSignature(node), "Signature could not be resolved."); | ||
}; | ||
/** | ||
* Gets the base type of a literal type. | ||
@@ -160,0 +178,0 @@ * |
@@ -236,2 +236,8 @@ "use strict"; | ||
/** | ||
* Gets if this is an any type. | ||
*/ | ||
Type.prototype.isAny = function () { | ||
return this._hasTypeFlag(typescript_1.TypeFlags.Any); | ||
}; | ||
/** | ||
* Gets if this is an array type. | ||
@@ -359,2 +365,8 @@ */ | ||
/** | ||
* Gets if this is the unknown type. | ||
*/ | ||
Type.prototype.isUnknown = function () { | ||
return this._hasTypeFlag(typescript_1.TypeFlags.Unknown); | ||
}; | ||
/** | ||
* Gets if this is the null type. | ||
@@ -361,0 +373,0 @@ */ |
@@ -8,3 +8,3 @@ "use strict"; | ||
// that will automatically update all other parts of the application that need to be updated when this changes. | ||
// using an "any" type here because I couldn't figure out a way of getting the typescript compiler to understand this | ||
// using an "unknown" type here because I couldn't figure out a way of getting the typescript compiler to understand this | ||
exports.kindToWrapperMappings = (_a = {}, | ||
@@ -67,9 +67,12 @@ _a[typescript_1.SyntaxKind.SourceFile] = compiler.SourceFile, | ||
_a[typescript_1.SyntaxKind.ImportType] = compiler.ImportTypeNode, | ||
_a[typescript_1.SyntaxKind.IndexedAccessType] = compiler.IndexedAccessTypeNode, | ||
_a[typescript_1.SyntaxKind.IndexSignature] = compiler.IndexSignatureDeclaration, | ||
_a[typescript_1.SyntaxKind.InterfaceDeclaration] = compiler.InterfaceDeclaration, | ||
_a[typescript_1.SyntaxKind.IntersectionType] = compiler.IntersectionTypeNode, | ||
_a[typescript_1.SyntaxKind.JSDocTag] = compiler.JSDocUnknownTag, | ||
_a[typescript_1.SyntaxKind.JSDocAugmentsTag] = compiler.JSDocAugmentsTag, | ||
_a[typescript_1.SyntaxKind.JSDocClassTag] = compiler.JSDocClassTag, | ||
_a[typescript_1.SyntaxKind.JSDocFunctionType] = compiler.JSDocFunctionType, | ||
_a[typescript_1.SyntaxKind.JSDocReturnTag] = compiler.JSDocReturnTag, | ||
_a[typescript_1.SyntaxKind.JSDocSignature] = compiler.JSDocSignature, | ||
_a[typescript_1.SyntaxKind.JSDocTag] = compiler.JSDocUnknownTag, | ||
_a[typescript_1.SyntaxKind.JSDocTypeExpression] = compiler.JSDocTypeExpression, | ||
@@ -76,0 +79,0 @@ _a[typescript_1.SyntaxKind.JSDocTypeTag] = compiler.JSDocTypeTag, |
@@ -24,4 +24,4 @@ "use strict"; | ||
exports.TypeGuards = TypeGuards_1.TypeGuards; | ||
var WriterFunctions_1 = require("./utils/WriterFunctions"); | ||
var WriterFunctions_1 = require("./structurePrinters/WriterFunctions"); | ||
exports.WriterFunctions = WriterFunctions_1.WriterFunctions; | ||
tslib_1.__exportStar(require("./typescript/public"), exports); |
@@ -25,2 +25,1 @@ "use strict"; | ||
tslib_1.__exportStar(require("./TypeScriptVersionChecker"), exports); | ||
tslib_1.__exportStar(require("./WriterFunctions"), exports); |
{ | ||
"name": "ts-morph", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "TypeScript compiler wrapper for static analysis and code manipulation.", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1971193
529
42111