New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate babel-jest to TypeScript #7862
Merged
+130
−31
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b381374
chore: migrate babel-jest to TypeScript
SimenB 8a2dabd
sourcemap can be a string
SimenB 5feaa8d
update failing snapshots
SimenB 27bc37c
work around a ts-ignore
jeysal d80aa6d
simplify
SimenB 483fb49
add comment
SimenB 8c69b02
import sourcemap type from source-map
SimenB aa016d9
remove unused delete
SimenB fb36a69
failing snap
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build" | ||
}, | ||
// TODO: include `babel-preset-jest` even though we don't care about its types | ||
"references": [{"path": "../jest-types"}] | ||
SimenB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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
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,59 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {Script} from 'vm'; | ||
import {RawSourceMap} from 'source-map'; | ||
import {Path, ProjectConfig} from './Config'; | ||
|
||
// https://stackoverflow.com/a/48216010/1850276 | ||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
|
||
// This is fixed in a newer version, but that depends on Node 8 which is a | ||
// breaking change (engine warning when installing) | ||
interface FixedRawSourceMap extends Omit<RawSourceMap, 'version'> { | ||
version: number; | ||
} | ||
|
||
export type TransformedSource = { | ||
code: string; | ||
map?: FixedRawSourceMap | string | null; | ||
}; | ||
|
||
export type TransformResult = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this type is not use now - it will be by |
||
script: Script; | ||
mapCoverage: boolean; | ||
sourceMapPath?: string; | ||
}; | ||
|
||
export type TransformOptions = { | ||
instrument: boolean; | ||
}; | ||
|
||
export type CacheKeyOptions = { | ||
config: ProjectConfig; | ||
instrument: boolean; | ||
rootDir: string; | ||
}; | ||
|
||
export type Transformer = { | ||
canInstrument?: boolean; | ||
createTransformer?: (options: any) => Transformer; | ||
|
||
getCacheKey: ( | ||
fileData: string, | ||
filePath: Path, | ||
configStr: string, | ||
options: CacheKeyOptions, | ||
) => string; | ||
|
||
process: ( | ||
sourceText: string, | ||
sourcePath: Path, | ||
config: ProjectConfig, | ||
options?: TransformOptions, | ||
) => string | TransformedSource; | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overwritten on line 47 anyways