Add definitions for jscodeshift/src/testUtils (#36154)

* Add defns for testUtils module

* Import unecessary here, use a reference path instead

* Add testUtils.d.ts to files array instead of reference
This commit is contained in:
Brian Jacobel
2019-06-19 12:54:40 -04:00
committed by Daniel Rosenwasser
parent 4a4cf23ff4
commit e7b5b2048a
4 changed files with 16 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for jscodeshift 0.6
// Project: https://github.com/facebook/jscodeshift#readme
// Definitions by: Brie Bunge <https://github.com/brieb>
// Brian Jacobel <https://github.com/bjacobel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9

6
types/jscodeshift/src/testUtils.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
export function defineTest(
dirName: string,
transformName: string,
options: any,
testFilePrefix?: string
): () => any;

View File

@@ -1,4 +1,5 @@
import { ASTNode, FileInfo, API, Transform, Parser } from "jscodeshift";
import * as testUtils from "jscodeshift/src/testUtils";
// Can define transform with `function`.
function replaceWithFooTransform(fileInfo: FileInfo, api: API) {
@@ -73,3 +74,10 @@ const transformWithRecastParseOptions: Transform = (file, { j }) => {
}
}
}
// Can define a test
testUtils.defineTest(
"directory",
"transformName",
{ opt: true },
);

View File

@@ -24,6 +24,7 @@
"src/collections/Node.d.ts",
"src/collections/VariableDeclarator.d.ts",
"src/template.d.ts",
"src/testUtils.d.ts",
"test/jscodeshift-tests.ts",
"test/js-transforms/bind-this-to-bind-expression.ts",
"test/js-transforms/call-expression-bind-this-to-arrow-function-expression.ts",