Skip to content
This repository was archived by the owner on Sep 21, 2019. It is now read-only.

Commit cd2d224

Browse files
committed
fix: TransformerFactory type should be SourceFile rather than Node
TypeScript will complain about: "Type 'Node' is not assignable to type 'SourceFile'."
1 parent 9381445 commit cd2d224

7 files changed

+10
-8
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export const allTransforms = [
3939
reactRemoveStaticPropTypesMemberTransformFactoryFactory,
4040
];
4141

42-
export type TransformFactoryFactory = (typeChecker: ts.TypeChecker) => ts.TransformerFactory<ts.Node>;
42+
export type TransformFactoryFactory = (typeChecker: ts.TypeChecker) => ts.TransformerFactory<ts.SourceFile>;
4343

4444
/**
4545
* Run React JavaScript to TypeScript transform for file at `filePath`
4646
* @param filePath
4747
*/
4848
export function run(filePath: string): string {
4949
return compile(filePath, allTransforms);
50-
}
50+
}

src/transforms/collapse-intersection-interfaces-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as helpers from '../helpers';
1414
*/
1515
export function collapseIntersectionInterfacesTransformFactoryFactory(
1616
typeChecker: ts.TypeChecker,
17-
): ts.TransformerFactory<ts.Node> {
17+
): ts.TransformerFactory<ts.SourceFile> {
1818
return function collapseIntersectionInterfacesTransformFactory(context: ts.TransformationContext) {
1919
return function collapseIntersectionInterfacesTransform(sourceFile: ts.SourceFile) {
2020
const visited = ts.visitEachChild(sourceFile, visitor, context);

src/transforms/react-hoist-generics-transform.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as ts from 'typescript';
22

33
import * as helpers from '../helpers';
44

5+
export type Factory = ts.TransformerFactory<ts.SourceFile>;
6+
57
/**
68
* Hoist generics to top of a class declarations in a React component
79
*
@@ -14,7 +16,7 @@ import * as helpers from '../helpers';
1416
* type SomeComponentState = {bar: string;};
1517
* class SomeComponent extends React.Component<SomeComponentProps, SomeComponentState> {}
1618
*/
17-
export function reactHoistGenericsTransformFactoryFactory(typeChecker: ts.TypeChecker): ts.TransformerFactory<ts.Node> {
19+
export function reactHoistGenericsTransformFactoryFactory(typeChecker: ts.TypeChecker): Factory {
1820
return function reactHoistGenericsTransformFactory(context: ts.TransformationContext) {
1921
return function reactHoistGenericsTransform(node: ts.SourceFile) {
2022
return visitSourceFile(node);

src/transforms/react-js-make-props-and-state-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
22

33
import * as helpers from '../helpers';
44

5-
export type Factory = ts.TransformerFactory<ts.Node>;
5+
export type Factory = ts.TransformerFactory<ts.SourceFile>;
66

77
/**
88
* Get transform for transforming React code originally written in JS which does not have

src/transforms/react-move-prop-types-to-class-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
22

33
import * as helpers from '../helpers';
44

5-
export type Factory = ts.TransformerFactory<ts.Node>;
5+
export type Factory = ts.TransformerFactory<ts.SourceFile>;
66

77
/**
88
* Move Component.propTypes statements into class as a static member of the class

src/transforms/react-remove-prop-types-assignment-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
22

33
import * as helpers from '../helpers';
44

5-
export type Factory = ts.TransformerFactory<ts.Node>;
5+
export type Factory = ts.TransformerFactory<ts.SourceFile>;
66

77
/**
88
* Remove Component.propTypes statements

src/transforms/react-remove-static-prop-types-member-transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
22

33
import * as helpers from '../helpers';
44

5-
export type Factory = ts.TransformerFactory<ts.Node>;
5+
export type Factory = ts.TransformerFactory<ts.SourceFile>;
66

77
/**
88
* Remove static propTypes

0 commit comments

Comments
 (0)