Skip to content
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

convert @babel/helper-fixtures to typescript #12922

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/babel-helper-fixtures/package.json
Expand Up @@ -17,5 +17,9 @@
"dependencies": {
"lodash": "^4.17.19",
"semver": "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
},
"devDependencies": {
"@types/lodash": "^4.14.150",
"@types/semver": "^7.3.4"
}
}
Expand Up @@ -5,31 +5,34 @@ import fs from "fs";

const nodeVersion = semver.clean(process.version.slice(1));

function humanize(val, noext) {
function humanize(val, noext?) {
if (noext) val = path.basename(val, path.extname(val));
return val.replace(/-/g, " ");
}

type TestFile = {
loc: string,
code: string,
filename: string,
loc: string;
code: string;
filename: string;
};

type Test = {
title: string,
disabled: boolean,
options: Object,
exec: TestFile,
actual: TestFile,
expected: TestFile,
title: string;
disabled: boolean;
options: any;
exec: TestFile;
actual: TestFile;
expected: TestFile;
// todo(flow->ts): improve types here
sourceMappings;
sourceMap;
};

type Suite = {
options: Object,
tests: Array<Test>,
title: string,
filename: string,
options: any;
tests: Array<Test>;
title: string;
filename: string;
};

function tryResolve(module) {
Expand Down Expand Up @@ -60,7 +63,7 @@ function shouldIgnore(name, ignore?: Array<string>) {

const EXTENSIONS = [".js", ".mjs", ".ts", ".tsx"];

function findFile(filepath: string, allowJSON: boolean) {
function findFile(filepath: string, allowJSON?: boolean) {
const matches = [];

for (const ext of EXTENSIONS.concat(allowJSON ? ".json" : [])) {
Expand Down Expand Up @@ -148,6 +151,9 @@ function pushTask(taskName, taskDir, suite, suiteName) {
code: readFile(expectLoc),
filename: expectLocAlias,
},
sourceMappings: undefined,
sourceMap: undefined,
inputSourceMap: undefined,
};

delete taskOpts.BABEL_8_BREAKING;
Expand Down Expand Up @@ -293,7 +299,7 @@ function wrapPackagesArray(type, names, optionsDir) {
* @returns {{}} options whose plugins/presets are resolved
*/
export function resolveOptionPluginOrPreset(
options: {},
options: any,
optionsDir: string,
): {} {
if (options.plugins) {
Expand Down
9 changes: 9 additions & 0 deletions yarn.lock
Expand Up @@ -520,6 +520,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@babel/helper-fixtures@workspace:packages/babel-helper-fixtures"
dependencies:
"@types/lodash": ^4.14.150
"@types/semver": ^7.3.4
lodash: ^4.17.19
semver: "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
languageName: unknown
Expand Down Expand Up @@ -4087,6 +4089,13 @@ __metadata:
languageName: node
linkType: hard

"@types/semver@npm:^7.3.4":
version: 7.3.4
resolution: "@types/semver@npm:7.3.4"
checksum: 7e8588aa55ecb344eda6954674b83a3c568d97d478e70e4617bd3ab22902590ac416ccf2cea48b58fb2f0fbd80f9ad1896332c9b3c3189ffd24e4350ff22094a
languageName: node
linkType: hard

"@types/source-map@npm:^0.5.0":
version: 0.5.2
resolution: "@types/source-map@npm:0.5.2"
Expand Down