Skip to content

Does typings support work? #113

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

Closed
ArturDorochowicz opened this issue Mar 22, 2016 · 4 comments
Closed

Does typings support work? #113

ArturDorochowicz opened this issue Mar 22, 2016 · 4 comments

Comments

@ArturDorochowicz
Copy link

I was looking at typings support which, according to the readme, is supposed to get configured from systemjs package configuration like this:

packages: {
    "angular2": {
      "meta": {
        "*.js": {
          "typings": true     // can also be path of a typings bundle 
        }
      }
    }
  }

However I couldn't make it work and it made me look at the source code. Please correct me if I'm wrong, but as far as I understand the source code this package configuration is not used at all.

The typing lookup seems to be implemented in resolver.ts in Resolver.lookupTyping [1] which uses metadata returned from this._lookup. This is implemented in plugin.ts with _lookup [2].
This method always returns an empty metadata object and therefore lookupTyping always hits the "no typings" path.

What's up with this?

[1]

private lookupTyping(importName: string, sourceName: string, address: string): Promise<string> {

[2]
function _lookup(address: string): Promise<any> {

@frankwallis
Copy link
Owner

The call to System.locate in plugin.ts populates the empty metadata object with the correct data from the systemjs configuration.

Recent changes to systemjs mean that you may need to use the fully resolved package name to get this working, e.g.

 "npm:[email protected]": {
      "meta": {
        "*.js": {
          "typings": true
        }
      }
    },

This is working in the angular2 example contained in this repository.

@ArturDorochowicz
Copy link
Author

Ok, sorry, I see it now. The api design got me confused.

NB I'd say it's a rather poor design on SystemJS part - modify the passed in argument and at the same time return a promise and not pass the result to the continuation.

Anyway, I still have a question about typings support. I actually was trying to get it working with Angular 1.4.6 installed with jspm and matching typings installed with typings tool. This means that the typings are in a completely different location than the package files. The readme says that instead of "typings": true I can use a string - i.e. the location of typings. So, my question is: is my scenario supported?

Feel free to close the issue. Thank you.

@frankwallis
Copy link
Owner

I think that you don't need any metadata configuration if you are using typings and angular1, you just need to make sure that typings/main.d.ts is included in the build. You can do this by adding it into the files array in tsconfig.json (or by adding a /// reference comment although that is no longer recommended.

See my comment here about the two different kinds of typings files. Metadata is only required for external typings.

@ArturDorochowicz
Copy link
Author

@frankwallis Thanks for the explanation. Indeed, /// reference comment is what I use now and it works perfectly, but, considering that it is marked deprecated, I have been looking for a different option and the readme points to meta typings configuration.

I will experiment with tsconfig.json files configuration or other means of including the typings/main.d.ts in the build.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants