Skip to content

Commit

Permalink
Convert @babel/helper-fixtures to typescript (#12922)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxbodya committed Mar 1, 2021
1 parent d05fdbc commit a653b9c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
4 changes: 4 additions & 0 deletions packages/babel-helper-fixtures/package.json
Original file line number Diff line number Diff line change
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"
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit a653b9c

Please sign in to comment.