diff --git a/package.json b/package.json index 17bbe40..e74bf93 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,8 @@ "runner": "ts-node ./src/runner.ts" }, "typings": "dist/index.d.ts", - "dependencies": { - "ts-is-kind": "^1.0.0" - }, "peerDependencies": { - "typescript": "^2.5.2" + "typescript": "^2.5.2 || ^3.0" }, "devDependencies": { "@types/jest": "^19.2.4", diff --git a/src/createTransformer.ts b/src/createTransformer.ts index c476596..3421e53 100644 --- a/src/createTransformer.ts +++ b/src/createTransformer.ts @@ -6,7 +6,7 @@ import { isVariableDeclaration, isExportAssignment, isTaggedTemplateExpression, -} from 'ts-is-kind'; +} from './ts-is-kind'; import {Options} from './models/Options'; diff --git a/src/ts-is-kind.ts b/src/ts-is-kind.ts new file mode 100644 index 0000000..044c62a --- /dev/null +++ b/src/ts-is-kind.ts @@ -0,0 +1,52 @@ +// The source code is kindly borrowed from `ts-is-kind` npm module. +// Original repo: https://github.com/mohsen1/ts-is-kind by @mohsen1 + +import * as ts from 'typescript'; + +/** + * Return true if node is `PropertyAccessExpression` + * @param node A TypeScript node + */ +export function isPropertyAccessExpression(node: ts.Node): node is ts.PropertyAccessExpression { + return node.kind === ts.SyntaxKind.PropertyAccessExpression; +} + +/** + * Return true if node is `CallExpression` + * @param node A TypeScript node + */ +export function isCallExpression(node: ts.Node): node is ts.CallExpression { + return node.kind === ts.SyntaxKind.CallExpression; +} + +/** + * Return true if node is `Identifier` + * @param node A TypeScript node + */ +export function isIdentifier(node: ts.Node): node is ts.Identifier { + return node.kind === ts.SyntaxKind.Identifier; +} + +/** + * Return true if node is `VariableDeclaration` + * @param node A TypeScript node + */ +export function isVariableDeclaration(node: ts.Node): node is ts.VariableDeclaration { + return node.kind === ts.SyntaxKind.VariableDeclaration; +} + +/** + * Return true if node is `ExportAssignment` + * @param node A TypeScript node + */ +export function isExportAssignment(node: ts.Node): node is ts.ExportAssignment { + return node.kind === ts.SyntaxKind.ExportAssignment; +} + +/** + * Return true if node is `TaggedTemplateExpression` + * @param node A TypeScript node + */ +export function isTaggedTemplateExpression(node: ts.Node): node is ts.TaggedTemplateExpression { + return node.kind === ts.SyntaxKind.TaggedTemplateExpression; +} diff --git a/yarn.lock b/yarn.lock index 4ec564a..e29bcce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2209,10 +2209,6 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" -ts-is-kind@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/ts-is-kind/-/ts-is-kind-1.0.0.tgz#f9ca9c1af07ddb82d7a06744d8928952d4bd2426" - ts-jest@20: version "20.0.6" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-20.0.6.tgz#39c2810c05d6f6908dac15929dae206b494b73f4"