File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99- ` [*] ` : Setup building, linting and testing of TypeScript ([ #7808 ] ( https://github.com/facebook/jest/pull/7808 ) )
1010- ` [pretty-format] ` : Migrate to TypeScript ([ #7809 ] ( https://github.com/facebook/jest/pull/7809 ) )
1111- ` [diff-sequences] ` : Migrate to Typescript ([ #7820 ] ( https://github.com/facebook/jest/pull/7820 ) )
12+ - ` [jest-get-type] ` : Migrate to TypeScript ([ #7818 ] ( https://github.com/facebook/jest/pull/7818 ) )
1213
1314### Performance
1415
Original file line number Diff line number Diff line change 1212 },
1313 "license" : " MIT" ,
1414 "main" : " build/index.js" ,
15+ "types" : " build/index.d.ts" ,
1516 "gitHead" : " 634e5a54f46b2a62d1dc81a170562e6f4e55ad60"
1617}
Original file line number Diff line number Diff line change 66 *
77 */
88
9- 'use strict' ;
10-
11- const getType = require ( '..' ) ;
9+ import getType from '..' ;
1210
1311describe ( '.getType()' , ( ) => {
1412 test ( 'null' , ( ) => expect ( getType ( null ) ) . toBe ( 'null' ) ) ;
Original file line number Diff line number Diff line change 33 *
44 * This source code is licensed under the MIT license found in the
55 * LICENSE file in the root directory of this source tree.
6- *
7- * @flow
86 */
97
10- 'use strict' ;
11-
12- export type ValueType =
8+ type ValueType =
139 | 'array'
1410 | 'boolean'
1511 | 'function'
@@ -26,7 +22,7 @@ export type ValueType =
2622
2723// get the type of a value with handling the edge cases like `typeof []`
2824// and `typeof null`
29- const getType = ( value : any ) : ValueType => {
25+ const getType = ( value : unknown ) : ValueType => {
3026 if ( value === undefined ) {
3127 return 'undefined' ;
3228 } else if ( value === null ) {
@@ -42,22 +38,23 @@ const getType = (value: any): ValueType => {
4238 } else if ( typeof value === 'string' ) {
4339 return 'string' ;
4440 } else if ( typeof value === 'object' ) {
45- if ( value . constructor === RegExp ) {
46- return 'regexp' ;
47- } else if ( value . constructor === Map ) {
48- return 'map' ;
49- } else if ( value . constructor === Set ) {
50- return 'set' ;
51- } else if ( value . constructor === Date ) {
52- return 'date' ;
41+ if ( value != null ) {
42+ if ( value . constructor === RegExp ) {
43+ return 'regexp' ;
44+ } else if ( value . constructor === Map ) {
45+ return 'map' ;
46+ } else if ( value . constructor === Set ) {
47+ return 'set' ;
48+ } else if ( value . constructor === Date ) {
49+ return 'date' ;
50+ }
5351 }
5452 return 'object' ;
55- // $FlowFixMe https://github.com/facebook/flow/issues/1015
5653 } else if ( typeof value === 'symbol' ) {
5754 return 'symbol' ;
5855 }
5956
6057 throw new Error ( `value of unknown type: ${ value } ` ) ;
6158} ;
6259
63- module . exports = getType ;
60+ export = getType ;
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ../../tsconfig.json" ,
3+ "compilerOptions" : {
4+ "rootDir" : " src" ,
5+ "outDir" : " build"
6+ }
7+ }
You can’t perform that action at this time.
0 commit comments