Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts-loader doesnot pick up definitions from the typings field in package.json if the main field points to a .ts file #250

Closed
bipinpoudyal opened this issue Jul 19, 2016 · 7 comments

Comments

@bipinpoudyal
Copy link

ts-loader is loading the typings if the main field points to a js file but if it points to a ts file, it doesnot load the typings folder. I have created a sample project with the recreation steps.

I tried compiling the same using tsc and it compiles properly without any issues.

Refer to #170 for a discussion on the same issue.

@bipinpoudyal
Copy link
Author

@blakeembrey I understand what you mean by the comment that we maynot need a typings field if the main is a .ts file.

Like I said earlier, I was able to workaround this issue by exporting the definitions from the main .ts file which you can check in this branch.

However TSC and IDE(Visual Studio) is able to resolve the definitions by just looking at the typings field in package.json whereas tsloader is not able to do the same.

@blakeembrey
Copy link
Member

@bipinpoudyal Correct. Webpack will be resolving both type definition time (typings) and runtime (main) which will result in a lot of broken code in this example. I'd still love to see if it makes sense to fix it, I'm just trying to say it will probably still break after this is fixed. In my opinion, it seems reasonable to resolve main.ts even over the typings field since that's what would be used in runtime.

@xogeny
Copy link

xogeny commented Dec 12, 2016

@blakeembrey I came across this issue when trying to resolve a "related" issue. I can open a separate issue if you want, but I at least wanted to make some kind of report about this. I had a case where main pointed to an incorrect file in one of my dependencies. Running tsc was no problem and didn't complain. But when running ts-loader (via webpack), it came back with a:

Module not found: Error: Can't resolve '...'

I could not understand what was going on. I mean tsc didn't report an error. It would, of course, be nice if the error message said something more along the lines of "The 'main' entry for dependency '...' points to a non-existent file".

I'm not even sure if this is actually related to ts-loader or more to webpack. In any case, as I said, I'm happy to open a separate issue if you want.

@aryzing
Copy link

aryzing commented Jan 11, 2018

Was having this issue with version 2.x.x, it seems that it's gone in version 3.x.x. Perhaps we could close this issue?

Could anyone else confirm that it's working with v3 for them as well? Thanks!

@stale
Copy link

stale bot commented Jan 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

1 similar comment
@stale
Copy link

stale bot commented Mar 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 20, 2019
@stale
Copy link

stale bot commented Mar 27, 2019

Closing as stale. Please reopen if you'd like to work on this further.

@stale stale bot closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants