dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Correct mainFields type

aaronadamsCA opened this issue · comments

The type of mainFields is set to string[] in a few places, including the signature of createMatchPathAsync.

The correct type is (string | string[])[]:

https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/types.d.ts#L9767

This test case confirms the type is correct:

https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/test/TestCases.template.js#L149-L156

For type safety, it would be great if this package were compatible with the Webpack type of mainFields, foregoing the need for type assertions. Thanks!

Here's the reason this syntax exists:

webpack/webpack#7204 (comment)

It's probably not very commonly used, but it'd still be good to be compatible with Webpack here.