Skip to content

Looking under wrong directory for index.d.ts #154

New issue

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

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

Already on GitHub? # to your account

Closed
bmayen opened this issue Sep 1, 2016 · 5 comments
Closed

Looking under wrong directory for index.d.ts #154

bmayen opened this issue Sep 1, 2016 · 5 comments

Comments

@bmayen
Copy link

bmayen commented Sep 1, 2016

I just updated to Angular 2 rc6. Each package.json file points 'main' to a umd bundle under a 'bundles' folder but the 'index.d.ts' file is located under each package root. Previously I had config for all of these packages set like:

let ngPkgNames = [
    '@angular/common',
    '@angular/compiler',
    '@angular/core', 
    ...
];
ngPkgNames.forEach(function(pkgName) {
    packages[pkgName] = {
      meta: {
        '*.js': {
          typings: true
        }
      }
    };
  });

This no longer works as it looks for a .d.ts file with the same name as the umd bundle. I assume I instead need to tell it to pull typings from 'index.d.ts', correct? If I change this to typings: 'index.d.ts', I get the following error: "Error on fetch for @angular/index.d.ts!github:frankwallis/plugin-typescript@5.0.19/plugin.js". It's looking under the parent '@angular' folder instead of the package folders' roots.

Side note: This may have come up before, but is it not possible to read the typings path from the package.json files and avoid this config entirely?

@bmayen
Copy link
Author

bmayen commented Sep 1, 2016

The cause is this line in resolver.js: var packageName = importName.split('/')[0];

What is the intent of this vs using importName as is?

@bmayen
Copy link
Author

bmayen commented Sep 1, 2016

How about something like:

var pkgSegments = importName.split('/');
var packageName = pkgSegments[0];

if (packageName.indexOf('@') === 0) {
    packageName += '/' + pkgSegments[1];
}

@bmayen
Copy link
Author

bmayen commented Sep 3, 2016

Tested the release for this. Looks good! 🎉

@bmayen bmayen closed this as completed Sep 3, 2016
@frankwallis
Copy link
Owner

Thanks - getting typings information from package.json isn't going to happen for reasons discussed in #102 (and sometimes it is not there anyway). However in 5.1.1 I have added a new compiler option typings which you can use instead of systemjs metadata. I hope that this will make it much easier to configure external typings and I also think it aligns better with the new types compiler option.

@aluanhaddad
Copy link
Contributor

@frankwallis That is fantastic. If only the TypeScript compiler would implement this behavior.

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

No branches or pull requests

3 participants