-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix for expressionTo with Spread and Methods
# Conflicts: # src/utils/expressionTo.js
- Loading branch information
Showing
4 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
src/utils/__tests__/__snapshots__/resolveGenericTypeAnnotations-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`resolveGenericTypeAnnotation resolves type 1`] = ` | ||
Node { | ||
"callProperties": Array [], | ||
"end": 57, | ||
"exact": false, | ||
"indexers": Array [], | ||
"inexact": false, | ||
"internalSlots": Array [], | ||
"loc": SourceLocation { | ||
"end": Position { | ||
"column": 34, | ||
"line": 3, | ||
}, | ||
"filename": undefined, | ||
"identifierName": undefined, | ||
"start": Position { | ||
"column": 21, | ||
"line": 3, | ||
}, | ||
}, | ||
"properties": Array [ | ||
Node { | ||
"end": 55, | ||
"key": Node { | ||
"end": 47, | ||
"loc": SourceLocation { | ||
"end": Position { | ||
"column": 24, | ||
"line": 3, | ||
}, | ||
"filename": undefined, | ||
"identifierName": "x", | ||
"start": Position { | ||
"column": 23, | ||
"line": 3, | ||
}, | ||
}, | ||
"name": "x", | ||
"start": 46, | ||
"type": "Identifier", | ||
}, | ||
"kind": "init", | ||
"loc": SourceLocation { | ||
"end": Position { | ||
"column": 32, | ||
"line": 3, | ||
}, | ||
"filename": undefined, | ||
"identifierName": undefined, | ||
"start": Position { | ||
"column": 23, | ||
"line": 3, | ||
}, | ||
}, | ||
"method": false, | ||
"optional": false, | ||
"proto": false, | ||
"start": 46, | ||
"static": false, | ||
"type": "ObjectTypeProperty", | ||
"value": Node { | ||
"end": 55, | ||
"loc": SourceLocation { | ||
"end": Position { | ||
"column": 32, | ||
"line": 3, | ||
}, | ||
"filename": undefined, | ||
"identifierName": undefined, | ||
"start": Position { | ||
"column": 26, | ||
"line": 3, | ||
}, | ||
}, | ||
"start": 49, | ||
"type": "StringTypeAnnotation", | ||
}, | ||
"variance": null, | ||
}, | ||
], | ||
"start": 44, | ||
"type": "ObjectTypeAnnotation", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { expression, statement } from '../../../tests/utils'; | ||
import isUnreachableFlowType from '../isUnreachableFlowType'; | ||
|
||
describe('isUnreachableFlowType', () => { | ||
it('considers Identifier as unreachable', () => { | ||
expect(isUnreachableFlowType(expression('foo'))).toBe(true); | ||
}); | ||
|
||
it('considers ImportDeclaration as unreachable', () => { | ||
expect(isUnreachableFlowType(statement('import x from "";'))).toBe(true); | ||
}); | ||
|
||
it('considers CallExpression as unreachable', () => { | ||
expect(isUnreachableFlowType(expression('foo()'))).toBe(true); | ||
}); | ||
|
||
it('considers VariableDeclaration not as unreachable', () => { | ||
expect(isUnreachableFlowType(statement('const x = 1;'))).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { statement, noopImporter } from '../../../tests/utils'; | ||
import resolveGenericTypeAnnotation from '../resolveGenericTypeAnnotation'; | ||
|
||
describe('resolveGenericTypeAnnotation', () => { | ||
it('resolves type', () => { | ||
const code = ` | ||
var x: Props; | ||
type Props = { x: string }; | ||
`; | ||
expect( | ||
resolveGenericTypeAnnotation( | ||
statement(code).get( | ||
'declarations', | ||
0, | ||
'id', | ||
'typeAnnotation', | ||
'typeAnnotation', | ||
), | ||
noopImporter, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters