microsoft/rnx-kit

eslint-plugin: no-export-all misses exports defined with TS "export import ="

ecraig12345 opened this issue · 0 comments

What happened?

In TypeScript, it's possible to declare exports with the syntax export import Foo = /*name or require*/. The fixer for no-export-all currently misses these exports, causing erroneous code to be generated.

// common.ts
export type Foo = {};
export const bar = 'bar';

// stuff.ts (demonstrating various valid syntax...not whether it makes sense)
import * as common from './common';
export import utils = common;
export import Foo = common.Foo;
export import bar = common.bar;
export import common = require('./common');
namespace Baz {
  export const baz = 'baz';
}
export import baz = Baz.baz;
export const other = 'other';

// index.ts
export * from './stuff';

Current output for index.ts:

export { other } from './stuff';

Expected output (roughly):

export { utils, Foo, bar, common, baz, other }'

This is based on real code, and there are enough instances of it that I can't just remove the usage (at least not without another lint rule banning this usually-unnecessary syntax). With this syntax, it's not possible to determine whether the referenced identifier is actually a type or a value without additional complexity.

Affected Package

@rnx-kit/eslint-plugin

Version

0.4.1

Which platforms are you seeing this issue on?

n/a

System Information

n/a

Steps to Reproduce

see above

Code of Conduct

  • I agree to follow this project's Code of Conduct