Closed Maximvdw closed 2 years ago
Thanks for the issue!
I might have a PR that I am testing that could fix this issue by modifying: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/master/lib/resolution/ResolutionContext.ts#L67-L69
That should indeed be a good place to fix the issue.
One solution might be to first check if filePath
exists, and is a directory.
If so, /index.d.ts
could be appended to it, and it could be loaded.
If not, .d.ts
is appended, and loaded directly.
One solution might be to first check if
filePath
exists, and is a directory. If so,/index.d.ts
could be appended to it, and it could be loaded. If not,.d.ts
is appended, and loaded directly.
Hi, thanks for the fast reply. The reason why I was not certain is due to the relative exports in ./directory_1/index.d.ts
I added an example at the end of my original post of why/when it should fail
The reason why I was not certain is due to the relative exports in ./directory_1/index.d.ts I added an example at the end of my original post of why/when it should fail
Right, that may indeed cause issues. I suspect that some changes for that case might be needed in https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/master/lib/parse/ClassLoader.ts#L157 or https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/master/lib/parse/ClassLoader.ts#L534
It seems that the components-generator does not handle exports of directories with an index.d.ts
Directory structure:
index.d.ts
/directory_1
/index.d.ts
/SomeFile.d.ts
/directory_2
/index.d.ts
/SomeFile2.d.ts
Example index.d.ts (root)
Running the generator will throw the following error:
There is indeed no directory_1.d.ts, but there is a '..\directory_1\index.d.ts'
If I change the index.d.ts in the root to:
it will correctly generate the components
I might have a PR that I am testing that could fix this issue by modifying: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/master/lib/resolution/ResolutionContext.ts#L67-L69 to include a fallback. But I am not entirely sure it it would be the best place to fix it here, as the context of the relative paths within that index are incorrect (i.e. if you have an
export * from './SomeFile'
in./directory_1/index.d.ts
it will try to load./SomeFile
instead of./directory_1/SomeFile