Skip to content

Commit 42732bf

Browse files
SimenBthymikee
authored andcommitted
chore: migrate to typescript
1 parent 5017c20 commit 42732bf

16 files changed

+335
-1347
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"extends": "@callstack",
3+
"parser": "@typescript-eslint/parser",
34
"rules": {
45
"global-require": 0,
56
"flowtype/no-weak-types": 0,
67
"strict": [0, "global"],
7-
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
8+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
89
"react-native/no-raw-text": 0
910
}
1011
}

.flowconfig

Lines changed: 0 additions & 2 deletions
This file was deleted.

__tests__/getSnapshotDiffSerializer.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// @flow
2-
3-
const snapshotDiff = require('../src/index');
1+
const { snapshotDiff, getSnapshotDiffSerializer } = require('../src/index');
42
// $FlowFixMe – wrong type declaration in flow-typed/jest@20.x.x
5-
expect.addSnapshotSerializer(snapshotDiff.getSnapshotDiffSerializer());
3+
expect.addSnapshotSerializer(getSnapshotDiffSerializer());
64

75
test('serialize text diff output', () => {
86
expect(

__tests__/index.test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
test('public api', () => {
2-
const index = require('../src/index');
2+
const index = require('../build/index');
33

4-
expect(index).toBeInstanceOf(Function);
5-
expect(index.snapshotDiff).toBe(index);
4+
expect(index.snapshotDiff).toBeInstanceOf(Function);
65
expect(index.toMatchDiffSnapshot).toBeInstanceOf(Function);
76
expect(index.getSnapshotDiffSerializer).toBeInstanceOf(Function);
87

98
const {
10-
snapshotDiff,
119
toMatchDiffSnapshot,
1210
getSnapshotDiffSerializer,
13-
} = require('../src/index');
11+
} = require('../build/index');
1412

15-
expect(snapshotDiff).toBe(index);
1613
expect(toMatchDiffSnapshot).toBe(index.toMatchDiffSnapshot);
1714
expect(getSnapshotDiffSerializer).toBe(index.getSnapshotDiffSerializer);
1815
});

__tests__/setSerializers.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
// @flow
21
const React = require('react');
32
const { configure, shallow: enzymeShallow } = require('enzyme');
43
const ReactShallowRenderer = require('react-test-renderer/shallow');
54
const Adapter = require('enzyme-adapter-react-16');
65
const enzymeToJson = require('enzyme-to-json/serializer');
7-
const snapshotDiff = require('../src/index');
6+
const {
7+
snapshotDiff,
8+
setSerializers,
9+
defaultSerializers,
10+
} = require('../src/index');
811

912
configure({ adapter: new Adapter() });
1013
const reactShallow = new ReactShallowRenderer();
1114

12-
snapshotDiff.setSerializers([...snapshotDiff.defaultSerializers, enzymeToJson]);
13-
14-
type Props = {
15-
test: string,
16-
};
15+
setSerializers([...defaultSerializers, enzymeToJson]);
1716

1817
const Component = ({ value }) => <div>I have value {value}</div>;
1918

20-
const NestedComponent = (props: Props) => (
19+
const NestedComponent = (props) => (
2120
<div>
2221
<span>Hello World - {props.test}</span>
2322
<Component value={1234} />

__tests__/snapshotDiff.test.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
// @flow
2-
31
/* eslint-disable react/no-multi-comp */
42

53
const React = require('react');
6-
const snapshotDiff = require('../src/index');
4+
const { snapshotDiff } = require('../src/index');
75

86
const a = `
97
some
@@ -78,15 +76,7 @@ const noIndentB = `
7876
@script
7977
`;
8078

81-
type Props = {
82-
test?: string,
83-
unnamedFunction?: () => void,
84-
unnamedJestMock?: () => void,
85-
namedJestMock?: () => void,
86-
withSecond?: boolean,
87-
};
88-
89-
class Component extends React.Component<Props> {
79+
class Component extends React.Component {
9080
render() {
9181
return (
9282
<div>
@@ -171,7 +161,7 @@ class Component extends React.Component<Props> {
171161
}
172162
}
173163

174-
class FragmentComponent extends React.Component<Props> {
164+
class FragmentComponent extends React.Component {
175165
render() {
176166
return (
177167
<>

__tests__/toMatchDiffSnapshot.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @flow
2-
31
const snapshotDiff = require('../src/index');
42

53
const a = `
@@ -39,7 +37,7 @@ test('works with default options', () => {
3937
expect(a).toMatchDiffSnapshot(b);
4038
});
4139

42-
[{ expand: true }, { contextLines: 0 }].forEach((options: any) => {
40+
[{ expand: true }, { contextLines: 0 }].forEach((options) => {
4341
test(`proxies "${Object.keys(options).join(', ')}" option(s)`, () => {
4442
// $FlowFixMe
4543
expect(a).toMatchDiffSnapshot(b, options);

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
presets: [
33
'@babel/preset-react',
4-
'@babel/preset-flow',
4+
'@babel/preset-typescript',
55
['@babel/preset-env', { targets: { node: '12' } }],
66
],
77
};

0 commit comments

Comments
 (0)