Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#59153 [@babel/core] Fixed babel.parse re…
Browse files Browse the repository at this point in the history
…turn type by @Andarist
  • Loading branch information
Andarist authored Mar 20, 2022
1 parent f96ee5b commit f20f103
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions types/babel__core/babel__core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ babel.transformFile('filename.js', options, (err, result) => {

babel.transformFileSync('filename.js', options)!.code;

function checkParseResult(_config: t.File) {}

const sourceCode = 'if (true) return;';
const parsedAst = babel.parse(sourceCode, options);

checkParseResult(parsedAst!);

babel.transformFromAst(parsedAst!, sourceCode, options, (err, result) => {
const { code, map, ast } = result!;
const { body } = ast!.program;
Expand Down
2 changes: 1 addition & 1 deletion types/babel__core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as t from '@babel/types';
export { ParserOptions, GeneratorOptions, t as types, template, traverse, NodePath, Visitor };

export type Node = t.Node;
export type ParseResult = t.File | t.Program;
export type ParseResult = ReturnType<typeof import('@babel/parser').parse>;
export const version: string;
export const DEFAULT_EXTENSIONS: ['.js', '.jsx', '.es6', '.es', '.mjs'];

Expand Down

0 comments on commit f20f103

Please sign in to comment.