Skip to content

Commit ea495c4

Browse files
committed
Use Set for checking for TypeScript
1 parent 8ec0724 commit ea495c4

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/react-docgen/src/babelParser.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@ import { loadPartialConfig, parseSync } from '@babel/core';
33
import type { File } from '@babel/types';
44
import { extname } from 'path';
55

6-
const TYPESCRIPT_EXTS = {
7-
'.cts': true,
8-
'.mts': true,
9-
'.ts': true,
10-
'.tsx': true,
11-
};
6+
const TYPESCRIPT_EXTS = new Set(['.cts', '.mts', '.ts', '.tsx']);
127

138
function getDefaultPlugins(
149
options: TransformOptions,
1510
): NonNullable<ParserOptions['plugins']> {
11+
const extension = extname(options.filename || '');
12+
1613
return [
1714
'jsx',
18-
TYPESCRIPT_EXTS[extname(options.filename || '')] ? 'typescript' : 'flow',
15+
TYPESCRIPT_EXTS.has(extension) ? 'typescript' : 'flow',
1916
'asyncDoExpressions',
2017
'decimal',
2118
['decorators', { decoratorsBeforeExport: false }],

0 commit comments

Comments
 (0)