compatfactory
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -0,43 +1,76 @@ | ||
## [0.0.9](https://github.com/wessberg/compatfactory/compare/v0.0.8...v0.0.9) (2021-08-30) | ||
### Features | ||
* add support for TypeScript v4.4 and add more compatibility fixes ([285ae96](https://github.com/wessberg/compatfactory/commit/285ae96bd83c1420fe7ff1b8130ab72eaf7370f8)) | ||
## [0.0.8](https://github.com/wessberg/compatfactory/compare/v0.0.7...v0.0.8) (2021-06-11) | ||
### Features | ||
- **property-access-chain:** add compatibility for TypeScript < 3.6 when generating PropertyAccessChains ([909ab22](https://github.com/wessberg/compatfactory/commit/909ab22084c9070b1bb974c281c5c7b9a0548a76)) | ||
* **property-access-chain:** add compatibility for TypeScript < 3.6 when generating PropertyAccessChains ([909ab22](https://github.com/wessberg/compatfactory/commit/909ab22084c9070b1bb974c281c5c7b9a0548a76)) | ||
## [0.0.7](https://github.com/wessberg/compatfactory/compare/v0.0.6...v0.0.7) (2021-05-29) | ||
### Bug Fixes | ||
- use provided modifiers when creating/updating MethodSignatures ([cfac75f](https://github.com/wessberg/compatfactory/commit/cfac75fcd593384d5d3b1c1a4066f5f769f50eaf)) | ||
* use provided modifiers when creating/updating MethodSignatures ([cfac75f](https://github.com/wessberg/compatfactory/commit/cfac75fcd593384d5d3b1c1a4066f5f769f50eaf)) | ||
## [0.0.6](https://github.com/wessberg/compatfactory/compare/v0.0.5...v0.0.6) (2021-05-29) | ||
### Bug Fixes | ||
- allow passing an already wrapped TypeScript object to ensureNodeFactory without performing any additional wrapping ([913abb8](https://github.com/wessberg/compatfactory/commit/913abb8f7e7218876013a5f3cf48dd3f748f404e)) | ||
* allow passing an already wrapped TypeScript object to ensureNodeFactory without performing any additional wrapping ([913abb8](https://github.com/wessberg/compatfactory/commit/913abb8f7e7218876013a5f3cf48dd3f748f404e)) | ||
## [0.0.5](https://github.com/wessberg/compatfactory/compare/v0.0.4...v0.0.5) (2021-05-29) | ||
### Bug Fixes | ||
- fix signature for createVariableDeclaration ([a311bc1](https://github.com/wessberg/compatfactory/commit/a311bc17ca73c8d899f160afed606f6ef49d3fa5)) | ||
* fix signature for createVariableDeclaration ([a311bc1](https://github.com/wessberg/compatfactory/commit/a311bc17ca73c8d899f160afed606f6ef49d3fa5)) | ||
## [0.0.4](https://github.com/wessberg/compatfactory/compare/v0.0.3...v0.0.4) (2021-05-28) | ||
### Features | ||
- add additional JSDoc factory functions for older TypeScript versions ([99ced96](https://github.com/wessberg/compatfactory/commit/99ced9601698114282b4a57c1d3afec6fc51c960)) | ||
* add additional JSDoc factory functions for older TypeScript versions ([99ced96](https://github.com/wessberg/compatfactory/commit/99ced9601698114282b4a57c1d3afec6fc51c960)) | ||
## [0.0.3](https://github.com/wessberg/compatfactory/compare/v0.0.2...v0.0.3) (2021-05-28) | ||
### Features | ||
- unify signatures for createImportEqualsDeclaration and createMappedTypeNode with latest TypeScript versions for TypeScript <4 ([ed7e4e0](https://github.com/wessberg/compatfactory/commit/ed7e4e07e11749f487ad7663e6a5e662f34f9c8f)) | ||
* unify signatures for createImportEqualsDeclaration and createMappedTypeNode with latest TypeScript versions for TypeScript <4 ([ed7e4e0](https://github.com/wessberg/compatfactory/commit/ed7e4e07e11749f487ad7663e6a5e662f34f9c8f)) | ||
## [0.0.2](https://github.com/wessberg/compatfactory/compare/v0.0.1...v0.0.2) (2021-05-28) | ||
### Features | ||
- unify signatures for createImportEqualsDeclaration and createMappedTypeNode with latest TypeScript versions for v4.0 and v4.1 ([a4e3f5f](https://github.com/wessberg/compatfactory/commit/a4e3f5f9b04108f0c1d188ed6a3d5eff689aff09)) | ||
* unify signatures for createImportEqualsDeclaration and createMappedTypeNode with latest TypeScript versions for v4.0 and v4.1 ([a4e3f5f](https://github.com/wessberg/compatfactory/commit/a4e3f5f9b04108f0c1d188ed6a3d5eff689aff09)) | ||
## 0.0.1 (2021-05-28) | ||
@@ -15,7 +15,45 @@ "use strict"; | ||
function normalizeNodeFactory(factory) { | ||
const needsModifications = factory.createImportEqualsDeclaration.length === 4 || factory.createMappedTypeNode.length === 4; | ||
const badCreateImportEqualsDeclaration = factory.createImportEqualsDeclaration.length === 4; | ||
const badCreateMappedTypeNode = factory.createMappedTypeNode.length === 4; | ||
const missingCreateClassStaticBlockDeclaration = factory.createClassStaticBlockDeclaration == null; | ||
const missingCreateJSDocMemberName = factory.createJSDocMemberName == null; | ||
const missingCreateJSDocLinkCode = factory.createJSDocLinkCode == null; | ||
const missingCreateJSDocLinkPlain = factory.createJSDocLinkPlain == null; | ||
const needsModifications = badCreateImportEqualsDeclaration || badCreateMappedTypeNode || missingCreateClassStaticBlockDeclaration; | ||
if (needsModifications) { | ||
/** | ||
* The following helpers are internal TypeScript helpers that have been inlined for reuse inside factory helpers when the full TypeScript namespace is not available | ||
*/ | ||
const withOriginal = "original" in factory.updateBlock(factory.createBlock([]), []); | ||
const setOriginalNode = (node, original) => { | ||
node.original = original; | ||
return node; | ||
}; | ||
const setTextRangeEnd = (range, end) => { | ||
range.end = end; | ||
return range; | ||
}; | ||
const setTextRangePos = (range, pos) => { | ||
range.pos = pos; | ||
return range; | ||
}; | ||
const setTextRangePosEnd = (range, pos, end) => setTextRangeEnd(setTextRangePos(range, pos), end); | ||
const setTextRange = (range, loc) => (loc != null ? setTextRangePosEnd(range, loc.pos, loc.end) : range); | ||
const updateWithoutOriginal = (updated, original) => { | ||
if (updated !== original) { | ||
setTextRange(updated, original); | ||
} | ||
return updated; | ||
}; | ||
const updateWithOriginal = (updated, original) => { | ||
if (updated !== original) { | ||
setOriginalNode(updated, original); | ||
setTextRange(updated, original); | ||
} | ||
return updated; | ||
}; | ||
const update = withOriginal ? updateWithOriginal : updateWithoutOriginal; | ||
return { | ||
...factory, | ||
...(factory.createImportEqualsDeclaration.length === 4 | ||
...(badCreateImportEqualsDeclaration | ||
? { | ||
@@ -27,3 +65,3 @@ createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { | ||
: {}), | ||
...(factory.createMappedTypeNode.length === 4 | ||
...(badCreateMappedTypeNode | ||
? { | ||
@@ -34,2 +72,85 @@ createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { | ||
} | ||
: {}), | ||
...(missingCreateClassStaticBlockDeclaration | ||
? (() => { | ||
function createClassStaticBlockDeclaration(decorators, modifiers, body) { | ||
// The closest we'll get at representing these nodes in a way that won't break the printer is with SemicolonClassElements | ||
const node = factory.createSemicolonClassElement(); | ||
node.body = body; | ||
node.decorators = decorators == null ? undefined : factory.createNodeArray(decorators); | ||
node.modifiers = modifiers == null ? undefined : factory.createNodeArray(modifiers); | ||
node.body = body; | ||
node.transformFlags = 8388608 /* ContainsClassFields */; | ||
return node; | ||
} | ||
function updateClassStaticBlockDeclaration(node, decorators, modifiers, body) { | ||
return decorators === node.decorators && modifiers === node.modifiers && body === node.body | ||
? node | ||
: update(createClassStaticBlockDeclaration(decorators, modifiers, body), node); | ||
} | ||
return { | ||
createClassStaticBlockDeclaration, | ||
updateClassStaticBlockDeclaration | ||
}; | ||
})() | ||
: {}), | ||
...(missingCreateJSDocMemberName | ||
? (() => { | ||
function createJSDocMemberName(left, right) { | ||
const base = factory.createJSDocComment(undefined, undefined); | ||
delete base.comment; | ||
delete base.tags; | ||
const node = base; | ||
node.left = left; | ||
node.right = right; | ||
return node; | ||
} | ||
function updateJSDocMemberName(node, left, right) { | ||
return left === node.left && right === node.right ? node : update(createJSDocMemberName(left, right), node); | ||
} | ||
return { | ||
createJSDocMemberName, | ||
updateJSDocMemberName | ||
}; | ||
})() | ||
: {}), | ||
...(missingCreateJSDocLinkCode | ||
? (() => { | ||
function createJSDocLinkCode(name, text) { | ||
const base = factory.createJSDocComment(undefined, undefined); | ||
delete base.comment; | ||
delete base.tags; | ||
const node = base; | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function updateJSDocLinkCode(node, name, text) { | ||
return name === node.name && text === node.text ? node : update(createJSDocLinkCode(name, text), node); | ||
} | ||
return { | ||
createJSDocLinkCode, | ||
updateJSDocLinkCode | ||
}; | ||
})() | ||
: {}), | ||
...(missingCreateJSDocLinkPlain | ||
? (() => { | ||
function createJSDocLinkPlain(name, text) { | ||
const base = factory.createJSDocComment(undefined, undefined); | ||
delete base.comment; | ||
delete base.tags; | ||
const node = base; | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function updateJSDocLinkPlain(node, name, text) { | ||
return name === node.name && text === node.text ? node : update(createJSDocLinkPlain(name, text), node); | ||
} | ||
return { | ||
createJSDocLinkPlain, | ||
updateJSDocLinkPlain | ||
}; | ||
})() | ||
: {}) | ||
@@ -58,3 +179,3 @@ }; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.NamedTupleMember) !== null && _a !== void 0 ? _a : 193); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.NamedTupleMember) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.TupleType); | ||
node.dotDotDotToken = dotDotDotToken; | ||
@@ -68,7 +189,6 @@ node.name = name; | ||
function createJSDocComment(comment, tags) { | ||
var _a; | ||
if ("createJSDocComment" in typescript) { | ||
return typescript.createJSDocComment(comment, tags); | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocComment) !== null && _a !== void 0 ? _a : 312); | ||
const node = typescript.createNode(typescript.SyntaxKind.JSDocComment); | ||
node.comment = comment; | ||
@@ -83,3 +203,3 @@ node.tags = typescript.createNodeArray(tags); | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocParameterTag) !== null && _a !== void 0 ? _a : 330); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocParameterTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -100,3 +220,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPrivateTag) !== null && _a !== void 0 ? _a : 324); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPrivateTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -112,3 +232,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAugmentsTag) !== null && _a !== void 0 ? _a : 318); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAugmentsTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -122,3 +242,3 @@ node.tagName = tagName; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocDeprecatedTag) !== null && _a !== void 0 ? _a : 321); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocDeprecatedTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.tagName = tagName; | ||
@@ -130,3 +250,3 @@ node.comment = comment; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocFunctionType) !== null && _a !== void 0 ? _a : 309); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocFunctionType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.parameters = typescript.createNodeArray(parameters); | ||
@@ -138,3 +258,3 @@ node.type = type; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLink) !== null && _a !== void 0 ? _a : 316); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLink) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
@@ -146,3 +266,3 @@ node.text = text; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNameReference) !== null && _a !== void 0 ? _a : 303); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNameReference) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
@@ -153,3 +273,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNamepathType) !== null && _a !== void 0 ? _a : 311); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNamepathType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -160,3 +280,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNonNullableType) !== null && _a !== void 0 ? _a : 307); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNonNullableType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -167,3 +287,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNullableType) !== null && _a !== void 0 ? _a : 306); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNullableType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -174,3 +294,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOptionalType) !== null && _a !== void 0 ? _a : 308); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOptionalType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -181,3 +301,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOverrideTag) !== null && _a !== void 0 ? _a : 327); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOverrideTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.tagName = tagName; | ||
@@ -189,3 +309,3 @@ node.comment = comment; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSeeTag) !== null && _a !== void 0 ? _a : 336); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSeeTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) { | ||
@@ -200,3 +320,3 @@ node.tagName = tagName; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocText) !== null && _a !== void 0 ? _a : 313); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocText) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.text = text; | ||
@@ -207,3 +327,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTag) !== null && _a !== void 0 ? _a : 317); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.tagName = tagName; | ||
@@ -215,7 +335,7 @@ node.comment = comment; | ||
var _a; | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocUnknownType) !== null && _a !== void 0 ? _a : 305); | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocUnknownType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
} | ||
function createJSDocVariadicType(type) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocVariadicType) !== null && _a !== void 0 ? _a : 310); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocVariadicType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -226,7 +346,7 @@ return node; | ||
var _a; | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocAllType) !== null && _a !== void 0 ? _a : 304); | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocAllType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
} | ||
function createTemplateLiteralType(head, templateSpans) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralType) !== null && _a !== void 0 ? _a : 194); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.StringLiteral); | ||
node.head = head; | ||
@@ -239,3 +359,3 @@ node.templateSpans = typescript.createNodeArray(templateSpans); | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralTypeSpan) !== null && _a !== void 0 ? _a : 195); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralTypeSpan) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.StringLiteral); | ||
node.type = type; | ||
@@ -251,3 +371,3 @@ node.literal = literal; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAuthorTag) !== null && _a !== void 0 ? _a : 320); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAuthorTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -263,3 +383,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocCallbackTag) !== null && _a !== void 0 ? _a : 328); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocCallbackTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -277,3 +397,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocClassTag) !== null && _a !== void 0 ? _a : 322); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocClassTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -289,3 +409,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocEnumTag) !== null && _a !== void 0 ? _a : 329); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocEnumTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -302,3 +422,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocImplementsTag) !== null && _a !== void 0 ? _a : 319); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocImplementsTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -315,3 +435,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPropertyTag) !== null && _a !== void 0 ? _a : 337); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPropertyTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -332,3 +452,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocProtectedTag) !== null && _a !== void 0 ? _a : 325); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocProtectedTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -344,3 +464,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPublicTag) !== null && _a !== void 0 ? _a : 323); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPublicTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -356,3 +476,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReadonlyTag) !== null && _a !== void 0 ? _a : 326); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReadonlyTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -368,3 +488,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReturnTag) !== null && _a !== void 0 ? _a : 331); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReturnTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -381,3 +501,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSignature) !== null && _a !== void 0 ? _a : 315); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSignature) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.typeParameters = typeParameters; | ||
@@ -393,3 +513,3 @@ node.parameters = parameters; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTemplateTag) !== null && _a !== void 0 ? _a : 334); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTemplateTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -407,3 +527,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocThisTag) !== null && _a !== void 0 ? _a : 332); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocThisTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -420,3 +540,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeExpression) !== null && _a !== void 0 ? _a : 302); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeExpression) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -430,3 +550,3 @@ return node; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeLiteral) !== null && _a !== void 0 ? _a : 314); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeLiteral) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.jsDocPropertyTags = jsDocPropertyTags; | ||
@@ -442,3 +562,3 @@ if (isArrayType != null) | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeTag) !== null && _a !== void 0 ? _a : 333); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -455,3 +575,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypedefTag) !== null && _a !== void 0 ? _a : 335); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypedefTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -464,2 +584,32 @@ node.tagName = tagName; | ||
} | ||
function createJSDocMemberName(left, right) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocMemberName) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.left = left; | ||
node.right = right; | ||
return node; | ||
} | ||
function createJSDocLinkCode(name, text) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLinkCode) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function createJSDocLinkPlain(name, text) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLinkPlain) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function createClassStaticBlockDeclaration(decorators, modifiers, body) { | ||
// The closest we'll get at representing these nodes in a way that won't break the printer is with SemicolonClassElements | ||
const node = typescript.createSemicolonClassElement(); | ||
node.body = body; | ||
node.decorators = decorators == null ? undefined : typescript.createNodeArray(decorators); | ||
node.modifiers = modifiers == null ? undefined : typescript.createNodeArray(modifiers); | ||
node.transformFlags = 8388608 /* ContainsClassFields */; | ||
return node; | ||
} | ||
const { updateSourceFileNode, ...common } = typescript; | ||
@@ -507,4 +657,8 @@ return { | ||
createJSDocVariadicType, | ||
createJSDocMemberName, | ||
createJSDocLinkCode, | ||
createJSDocLinkPlain, | ||
createTemplateLiteralType, | ||
createTemplateLiteralTypeSpan, | ||
createClassStaticBlockDeclaration, | ||
createComma(left, right) { | ||
@@ -555,3 +709,2 @@ return typescript.createComma(left, right); | ||
return methodSignature; | ||
return methodSignature; | ||
}, | ||
@@ -916,2 +1069,11 @@ updateMethodSignature(node, modifiers, name, questionToken, typeParameters, parameters, type) { | ||
}, | ||
updateJSDocMemberName(node, left, right) { | ||
return left === node.left && right === node.right ? node : typescript.setTextRange(createJSDocMemberName(left, right), node); | ||
}, | ||
updateJSDocLinkCode(node, name, text) { | ||
return name === node.name && text === node.text ? node : typescript.setTextRange(createJSDocLinkCode(name, text), node); | ||
}, | ||
updateJSDocLinkPlain(node, name, text) { | ||
return name === node.name && text === node.text ? node : typescript.setTextRange(createJSDocLinkPlain(name, text), node); | ||
}, | ||
updateLabeledStatement(node, label, statement) { | ||
@@ -973,2 +1135,7 @@ return typescript.updateLabel(node, label, statement); | ||
}, | ||
updateClassStaticBlockDeclaration(node, decorators, modifiers, body) { | ||
return decorators === node.decorators && modifiers === node.modifiers && body === node.body | ||
? node | ||
: typescript.setTextRange(createClassStaticBlockDeclaration(decorators, modifiers, body), node); | ||
}, | ||
updateThrowStatement(node, expression) { | ||
@@ -1077,2 +1244,8 @@ return typescript.updateThrow(node, expression); | ||
return typescript.updateConstructor(node, decorators, modifiers, parameters, body); | ||
}, | ||
/** | ||
* Some TypeScript versions require that the value is a string argument | ||
*/ | ||
createNumericLiteral(value, numericLiteralFlags) { | ||
return typescript.createNumericLiteral(String(value), numericLiteralFlags); | ||
} | ||
@@ -1079,0 +1252,0 @@ }; |
@@ -11,7 +11,45 @@ export function ensureNodeFactory(factoryLike) { | ||
function normalizeNodeFactory(factory) { | ||
const needsModifications = factory.createImportEqualsDeclaration.length === 4 || factory.createMappedTypeNode.length === 4; | ||
const badCreateImportEqualsDeclaration = factory.createImportEqualsDeclaration.length === 4; | ||
const badCreateMappedTypeNode = factory.createMappedTypeNode.length === 4; | ||
const missingCreateClassStaticBlockDeclaration = factory.createClassStaticBlockDeclaration == null; | ||
const missingCreateJSDocMemberName = factory.createJSDocMemberName == null; | ||
const missingCreateJSDocLinkCode = factory.createJSDocLinkCode == null; | ||
const missingCreateJSDocLinkPlain = factory.createJSDocLinkPlain == null; | ||
const needsModifications = badCreateImportEqualsDeclaration || badCreateMappedTypeNode || missingCreateClassStaticBlockDeclaration; | ||
if (needsModifications) { | ||
/** | ||
* The following helpers are internal TypeScript helpers that have been inlined for reuse inside factory helpers when the full TypeScript namespace is not available | ||
*/ | ||
const withOriginal = "original" in factory.updateBlock(factory.createBlock([]), []); | ||
const setOriginalNode = (node, original) => { | ||
node.original = original; | ||
return node; | ||
}; | ||
const setTextRangeEnd = (range, end) => { | ||
range.end = end; | ||
return range; | ||
}; | ||
const setTextRangePos = (range, pos) => { | ||
range.pos = pos; | ||
return range; | ||
}; | ||
const setTextRangePosEnd = (range, pos, end) => setTextRangeEnd(setTextRangePos(range, pos), end); | ||
const setTextRange = (range, loc) => (loc != null ? setTextRangePosEnd(range, loc.pos, loc.end) : range); | ||
const updateWithoutOriginal = (updated, original) => { | ||
if (updated !== original) { | ||
setTextRange(updated, original); | ||
} | ||
return updated; | ||
}; | ||
const updateWithOriginal = (updated, original) => { | ||
if (updated !== original) { | ||
setOriginalNode(updated, original); | ||
setTextRange(updated, original); | ||
} | ||
return updated; | ||
}; | ||
const update = withOriginal ? updateWithOriginal : updateWithoutOriginal; | ||
return { | ||
...factory, | ||
...(factory.createImportEqualsDeclaration.length === 4 | ||
...(badCreateImportEqualsDeclaration | ||
? { | ||
@@ -23,3 +61,3 @@ createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { | ||
: {}), | ||
...(factory.createMappedTypeNode.length === 4 | ||
...(badCreateMappedTypeNode | ||
? { | ||
@@ -30,2 +68,85 @@ createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { | ||
} | ||
: {}), | ||
...(missingCreateClassStaticBlockDeclaration | ||
? (() => { | ||
function createClassStaticBlockDeclaration(decorators, modifiers, body) { | ||
// The closest we'll get at representing these nodes in a way that won't break the printer is with SemicolonClassElements | ||
const node = factory.createSemicolonClassElement(); | ||
node.body = body; | ||
node.decorators = decorators == null ? undefined : factory.createNodeArray(decorators); | ||
node.modifiers = modifiers == null ? undefined : factory.createNodeArray(modifiers); | ||
node.body = body; | ||
node.transformFlags = 8388608 /* ContainsClassFields */; | ||
return node; | ||
} | ||
function updateClassStaticBlockDeclaration(node, decorators, modifiers, body) { | ||
return decorators === node.decorators && modifiers === node.modifiers && body === node.body | ||
? node | ||
: update(createClassStaticBlockDeclaration(decorators, modifiers, body), node); | ||
} | ||
return { | ||
createClassStaticBlockDeclaration, | ||
updateClassStaticBlockDeclaration | ||
}; | ||
})() | ||
: {}), | ||
...(missingCreateJSDocMemberName | ||
? (() => { | ||
function createJSDocMemberName(left, right) { | ||
const base = factory.createJSDocComment(undefined, undefined); | ||
delete base.comment; | ||
delete base.tags; | ||
const node = base; | ||
node.left = left; | ||
node.right = right; | ||
return node; | ||
} | ||
function updateJSDocMemberName(node, left, right) { | ||
return left === node.left && right === node.right ? node : update(createJSDocMemberName(left, right), node); | ||
} | ||
return { | ||
createJSDocMemberName, | ||
updateJSDocMemberName | ||
}; | ||
})() | ||
: {}), | ||
...(missingCreateJSDocLinkCode | ||
? (() => { | ||
function createJSDocLinkCode(name, text) { | ||
const base = factory.createJSDocComment(undefined, undefined); | ||
delete base.comment; | ||
delete base.tags; | ||
const node = base; | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function updateJSDocLinkCode(node, name, text) { | ||
return name === node.name && text === node.text ? node : update(createJSDocLinkCode(name, text), node); | ||
} | ||
return { | ||
createJSDocLinkCode, | ||
updateJSDocLinkCode | ||
}; | ||
})() | ||
: {}), | ||
...(missingCreateJSDocLinkPlain | ||
? (() => { | ||
function createJSDocLinkPlain(name, text) { | ||
const base = factory.createJSDocComment(undefined, undefined); | ||
delete base.comment; | ||
delete base.tags; | ||
const node = base; | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function updateJSDocLinkPlain(node, name, text) { | ||
return name === node.name && text === node.text ? node : update(createJSDocLinkPlain(name, text), node); | ||
} | ||
return { | ||
createJSDocLinkPlain, | ||
updateJSDocLinkPlain | ||
}; | ||
})() | ||
: {}) | ||
@@ -54,3 +175,3 @@ }; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.NamedTupleMember) !== null && _a !== void 0 ? _a : 193); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.NamedTupleMember) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.TupleType); | ||
node.dotDotDotToken = dotDotDotToken; | ||
@@ -64,7 +185,6 @@ node.name = name; | ||
function createJSDocComment(comment, tags) { | ||
var _a; | ||
if ("createJSDocComment" in typescript) { | ||
return typescript.createJSDocComment(comment, tags); | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocComment) !== null && _a !== void 0 ? _a : 312); | ||
const node = typescript.createNode(typescript.SyntaxKind.JSDocComment); | ||
node.comment = comment; | ||
@@ -79,3 +199,3 @@ node.tags = typescript.createNodeArray(tags); | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocParameterTag) !== null && _a !== void 0 ? _a : 330); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocParameterTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -96,3 +216,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPrivateTag) !== null && _a !== void 0 ? _a : 324); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPrivateTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -108,3 +228,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAugmentsTag) !== null && _a !== void 0 ? _a : 318); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAugmentsTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -118,3 +238,3 @@ node.tagName = tagName; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocDeprecatedTag) !== null && _a !== void 0 ? _a : 321); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocDeprecatedTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.tagName = tagName; | ||
@@ -126,3 +246,3 @@ node.comment = comment; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocFunctionType) !== null && _a !== void 0 ? _a : 309); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocFunctionType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.parameters = typescript.createNodeArray(parameters); | ||
@@ -134,3 +254,3 @@ node.type = type; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLink) !== null && _a !== void 0 ? _a : 316); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLink) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
@@ -142,3 +262,3 @@ node.text = text; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNameReference) !== null && _a !== void 0 ? _a : 303); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNameReference) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
@@ -149,3 +269,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNamepathType) !== null && _a !== void 0 ? _a : 311); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNamepathType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -156,3 +276,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNonNullableType) !== null && _a !== void 0 ? _a : 307); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNonNullableType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -163,3 +283,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNullableType) !== null && _a !== void 0 ? _a : 306); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocNullableType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -170,3 +290,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOptionalType) !== null && _a !== void 0 ? _a : 308); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOptionalType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -177,3 +297,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOverrideTag) !== null && _a !== void 0 ? _a : 327); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocOverrideTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.tagName = tagName; | ||
@@ -185,3 +305,3 @@ node.comment = comment; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSeeTag) !== null && _a !== void 0 ? _a : 336); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSeeTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) { | ||
@@ -196,3 +316,3 @@ node.tagName = tagName; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocText) !== null && _a !== void 0 ? _a : 313); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocText) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.text = text; | ||
@@ -203,3 +323,3 @@ return node; | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTag) !== null && _a !== void 0 ? _a : 317); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.tagName = tagName; | ||
@@ -211,7 +331,7 @@ node.comment = comment; | ||
var _a; | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocUnknownType) !== null && _a !== void 0 ? _a : 305); | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocUnknownType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
} | ||
function createJSDocVariadicType(type) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocVariadicType) !== null && _a !== void 0 ? _a : 310); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocVariadicType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -222,7 +342,7 @@ return node; | ||
var _a; | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocAllType) !== null && _a !== void 0 ? _a : 304); | ||
return typescript.createNode((_a = typescript.SyntaxKind.JSDocAllType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
} | ||
function createTemplateLiteralType(head, templateSpans) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralType) !== null && _a !== void 0 ? _a : 194); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralType) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.StringLiteral); | ||
node.head = head; | ||
@@ -235,3 +355,3 @@ node.templateSpans = typescript.createNodeArray(templateSpans); | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralTypeSpan) !== null && _a !== void 0 ? _a : 195); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.TemplateLiteralTypeSpan) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.StringLiteral); | ||
node.type = type; | ||
@@ -247,3 +367,3 @@ node.literal = literal; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAuthorTag) !== null && _a !== void 0 ? _a : 320); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocAuthorTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -259,3 +379,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocCallbackTag) !== null && _a !== void 0 ? _a : 328); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocCallbackTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -273,3 +393,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocClassTag) !== null && _a !== void 0 ? _a : 322); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocClassTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -285,3 +405,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocEnumTag) !== null && _a !== void 0 ? _a : 329); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocEnumTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -298,3 +418,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocImplementsTag) !== null && _a !== void 0 ? _a : 319); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocImplementsTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -311,3 +431,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPropertyTag) !== null && _a !== void 0 ? _a : 337); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPropertyTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -328,3 +448,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocProtectedTag) !== null && _a !== void 0 ? _a : 325); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocProtectedTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -340,3 +460,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPublicTag) !== null && _a !== void 0 ? _a : 323); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocPublicTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -352,3 +472,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReadonlyTag) !== null && _a !== void 0 ? _a : 326); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReadonlyTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -364,3 +484,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReturnTag) !== null && _a !== void 0 ? _a : 331); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocReturnTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -377,3 +497,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSignature) !== null && _a !== void 0 ? _a : 315); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocSignature) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.typeParameters = typeParameters; | ||
@@ -389,3 +509,3 @@ node.parameters = parameters; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTemplateTag) !== null && _a !== void 0 ? _a : 334); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTemplateTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -403,3 +523,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocThisTag) !== null && _a !== void 0 ? _a : 332); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocThisTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -416,3 +536,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeExpression) !== null && _a !== void 0 ? _a : 302); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeExpression) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.type = type; | ||
@@ -426,3 +546,3 @@ return node; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeLiteral) !== null && _a !== void 0 ? _a : 314); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeLiteral) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.jsDocPropertyTags = jsDocPropertyTags; | ||
@@ -438,3 +558,3 @@ if (isArrayType != null) | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeTag) !== null && _a !== void 0 ? _a : 333); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypeTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -451,3 +571,3 @@ node.tagName = tagName; | ||
} | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypedefTag) !== null && _a !== void 0 ? _a : 335); | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocTypedefTag) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
if (tagName != null) | ||
@@ -460,2 +580,32 @@ node.tagName = tagName; | ||
} | ||
function createJSDocMemberName(left, right) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocMemberName) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.left = left; | ||
node.right = right; | ||
return node; | ||
} | ||
function createJSDocLinkCode(name, text) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLinkCode) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function createJSDocLinkPlain(name, text) { | ||
var _a; | ||
const node = typescript.createNode((_a = typescript.SyntaxKind.JSDocLinkPlain) !== null && _a !== void 0 ? _a : typescript.SyntaxKind.JSDocComment); | ||
node.name = name; | ||
node.text = text; | ||
return node; | ||
} | ||
function createClassStaticBlockDeclaration(decorators, modifiers, body) { | ||
// The closest we'll get at representing these nodes in a way that won't break the printer is with SemicolonClassElements | ||
const node = typescript.createSemicolonClassElement(); | ||
node.body = body; | ||
node.decorators = decorators == null ? undefined : typescript.createNodeArray(decorators); | ||
node.modifiers = modifiers == null ? undefined : typescript.createNodeArray(modifiers); | ||
node.transformFlags = 8388608 /* ContainsClassFields */; | ||
return node; | ||
} | ||
const { updateSourceFileNode, ...common } = typescript; | ||
@@ -503,4 +653,8 @@ return { | ||
createJSDocVariadicType, | ||
createJSDocMemberName, | ||
createJSDocLinkCode, | ||
createJSDocLinkPlain, | ||
createTemplateLiteralType, | ||
createTemplateLiteralTypeSpan, | ||
createClassStaticBlockDeclaration, | ||
createComma(left, right) { | ||
@@ -551,3 +705,2 @@ return typescript.createComma(left, right); | ||
return methodSignature; | ||
return methodSignature; | ||
}, | ||
@@ -912,2 +1065,11 @@ updateMethodSignature(node, modifiers, name, questionToken, typeParameters, parameters, type) { | ||
}, | ||
updateJSDocMemberName(node, left, right) { | ||
return left === node.left && right === node.right ? node : typescript.setTextRange(createJSDocMemberName(left, right), node); | ||
}, | ||
updateJSDocLinkCode(node, name, text) { | ||
return name === node.name && text === node.text ? node : typescript.setTextRange(createJSDocLinkCode(name, text), node); | ||
}, | ||
updateJSDocLinkPlain(node, name, text) { | ||
return name === node.name && text === node.text ? node : typescript.setTextRange(createJSDocLinkPlain(name, text), node); | ||
}, | ||
updateLabeledStatement(node, label, statement) { | ||
@@ -969,2 +1131,7 @@ return typescript.updateLabel(node, label, statement); | ||
}, | ||
updateClassStaticBlockDeclaration(node, decorators, modifiers, body) { | ||
return decorators === node.decorators && modifiers === node.modifiers && body === node.body | ||
? node | ||
: typescript.setTextRange(createClassStaticBlockDeclaration(decorators, modifiers, body), node); | ||
}, | ||
updateThrowStatement(node, expression) { | ||
@@ -1073,2 +1240,8 @@ return typescript.updateThrow(node, expression); | ||
return typescript.updateConstructor(node, decorators, modifiers, parameters, body); | ||
}, | ||
/** | ||
* Some TypeScript versions require that the value is a string argument | ||
*/ | ||
createNumericLiteral(value, numericLiteralFlags) { | ||
return typescript.createNumericLiteral(String(value), numericLiteralFlags); | ||
} | ||
@@ -1075,0 +1248,0 @@ }; |
{ | ||
"name": "compatfactory", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A library that unifies the TypeScript Compiler API factory functions across all versions of TypeScript and makes them conform with the Node Factory API", | ||
@@ -49,26 +49,26 @@ "scripts": { | ||
"dependencies": { | ||
"helpertypes": "^0.0.3" | ||
"helpertypes": "^0.0.4" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"@types/semver": "^7.3.6", | ||
"@typescript-eslint/eslint-plugin": "^4.30.0", | ||
"@typescript-eslint/parser": "^4.30.0", | ||
"@types/semver": "^7.3.8", | ||
"@wessberg/ts-config": "^1.1.2", | ||
"sandhog": "^1.0.41", | ||
"ava": "^3.15.0", | ||
"eslint": "^7.28.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-jsdoc": "^35.1.3", | ||
"husky": "^6.0.0", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint-plugin-jsdoc": "^36.0.8", | ||
"husky": "^7.0.2", | ||
"np": "7.5.0", | ||
"pnpm": "^6.7.4", | ||
"prettier": "^2.3.1", | ||
"pretty-quick": "^3.1.0", | ||
"pnpm": "^6.14.5", | ||
"prettier": "^2.3.2", | ||
"pretty-quick": "^3.1.1", | ||
"rimraf": "^3.0.2", | ||
"standard-changelog": "^2.0.27", | ||
"ts-node": "^10.0.0", | ||
"npm-check-updates": "^11.6.0", | ||
"ts-node": "^10.2.1", | ||
"npm-check-updates": "^11.8.3", | ||
"semver": "^7.3.5", | ||
"typescript": "^4.3.2", | ||
"typescript": "^4.4.2", | ||
"typescript-3-0-1": "npm:typescript@3.0.1", | ||
@@ -86,3 +86,4 @@ "typescript-3-1-1": "npm:typescript@3.1.1", | ||
"typescript-4-1-2": "npm:typescript@4.1.2", | ||
"typescript-4-2-4": "npm:typescript@4.2.4" | ||
"typescript-4-2-4": "npm:typescript@4.2.4", | ||
"typescript-4-3-5": "npm:typescript@4.3.5" | ||
}, | ||
@@ -89,0 +90,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
240867
2414
35
+ Addedhelpertypes@0.0.4(transitive)
- Removedhelpertypes@0.0.3(transitive)
Updatedhelpertypes@^0.0.4