Skip to content

Commit

Permalink
remove the right code
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoux committed Sep 24, 2023
1 parent 86b4055 commit 1938c83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/plugins/typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ts from 'typescript';
import { compact } from '../../util/array.js';
import { dirname, isInternal, toAbsolute } from '../../util/path.js';
import { timerify } from '../../util/Performance.js';
Expand Down Expand Up @@ -33,6 +34,8 @@ const resolveExtensibleConfig = async (configFilePath: string) => {
return config;
};

const jsxWithReact = [ts.JsxEmit.React, ts.JsxEmit.ReactJSX, ts.JsxEmit.ReactJSXDev, ts.JsxEmit.ReactNative];

Check failure on line 37 in src/plugins/typescript/index.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest (Node v16)

'jsxWithReact' is assigned a value but never used

Check failure on line 37 in src/plugins/typescript/index.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest (Node v18)

'jsxWithReact' is assigned a value but never used

Check failure on line 37 in src/plugins/typescript/index.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest (Node v20)

'jsxWithReact' is assigned a value but never used

export const findTypeScriptDependencies: GenericPluginCallback = async configFilePath => {
const compilerOptions: CompilerOptions = await loadTSConfig(configFilePath);
const config: TsConfigJson = await resolveExtensibleConfig(configFilePath); // Dual loader to get external `extends` dependencies
Expand All @@ -45,8 +48,8 @@ export const findTypeScriptDependencies: GenericPluginCallback = async configFil
? compilerOptions.plugins.map(plugin => (typeof plugin === 'object' && 'name' in plugin ? plugin.name : ''))
: [];
const importHelpers = compilerOptions?.importHelpers ? ['tslib'] : [];

return compact([...extend, ...types, ...plugins, ...importHelpers]);
const jsx = compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : [];
return compact([...extend, ...types, ...plugins, ...importHelpers, ...jsx]);
};

export const findDependencies = timerify(findTypeScriptDependencies);
2 changes: 1 addition & 1 deletion tests/plugins/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('Find dependencies in typescript configuration (jsx-preserve)', async () =>
test('Find dependencies in typescript configuration (jsx)', async () => {
const configFilePath = join(cwd, 'tsconfig-jsx.json');
const dependencies = await typescript.findDependencies(configFilePath);
assert.deepEqual(dependencies, ['react']);
assert.deepEqual(dependencies, []);
});

test('Find dependencies in typescript configuration (jsx-import-source)', async () => {
Expand Down

0 comments on commit 1938c83

Please sign in to comment.