Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Creating typings without a main d.ts #108

Closed
mribichich opened this issue Jan 13, 2016 · 8 comments
Closed

Creating typings without a main d.ts #108

mribichich opened this issue Jan 13, 2016 · 8 comments

Comments

@mribichich
Copy link

Hi there, Is there a way to create typings without a main d.ts ?

I have a project that doesn't have a main export, but a couple of modules export.

It would be something like angular2 has, that it doesn't have a index.d.ts or angular.d.ts or main.d.ts

If you want something you go 'angular2/....' something.

is this possible?

Thanks!

@blakeembrey
Copy link
Member

@siulung4073 In the current version, no. However, it is simple to support this and something I've been meaning to add (see #43). If you use a files array in typings.json and reference .d.ts files, I'll support it ASAP.

@mribichich
Copy link
Author

Great! And what about cases where you dont own the library o package you are trying to create typings for, like with angular2 that it doesn't have a typings.json and one can't specify this files array.

Wouldn't be possible to just specify a base folder so that typings install can work with every d.ts it finds. After all one could import any file that exports something inside that base folder, so creating a bundle for every d.ts file there wouldn't be that bad. Something like dts-generator does when the library doesn't have a main.d.ts

For typings install path wouldn't be a problem, for github you could download the base folder specified in the url and make the evaluation later.

@blakeembrey
Copy link
Member

Could you give more information on what you're trying to type? Is it actually angular2? I'd prefer not to do glob expansions right now, since it'll increase complexity quickly (I'll need to implement glob ignore, figure out how to expose this in typings.json, etc). Also, typings install works over HTTP where you can't just do an ls. It would certainly need some tweaking to make something like this work, so I'd like to understand the use-case more before I ride blindly into implementing it.

@mribichich
Copy link
Author

No, is not angular2 specifically, but it could.

For example, on one hand I have an angular app, where I use JSPM. I installed angular2 there, and as you know VS and tsc are complaining about not finding modules. The angular2 installed folder has the d.ts files along with the generated js files, but without ambient modules. Since they dont have a main.d.ts I can not use typings. So this would be one possible case.

On the other hand, I have an angular package I created. where I wanted to expose a couple of modules but not through the main one, instead each one separately (something like angular2 does).

This is the repo and this one is the release repo.

If you see, I have the entities and servicies modules that I wish to expose on their own.
Right know i'm re exporting them through the index module, so I can use typings to create the d.ts bundle.

I honestly dont know how typings does things so I can't comment on that, but probably in the case of specifying a folder and not a main file, you could bundle every d.ts without filtering or globs support. Where you can select a main file or a base folder.

If you check dts-generator, they dont filter anything, they just grab everything inside the base folder.
And I think that wouldn't be that bad or wrong since you could potentially import any module inside any package.
I know you want to do it correctly, but it could be something like a minor feature, with room for future improvements, like globs, ignores, etc.

Just a thought. Thanks!

@blakeembrey
Copy link
Member

Thanks for the awesome feedback. It's definitely helpful. Would it be reasonable if I just start with files for now, then expand to additional features if there's a need for it? Installation is quite straightforward and pretty well-defined for now, so I'd love to keep it that way as long as possible.

@mribichich
Copy link
Author

ok, great. And if we keep going with the angular2 example, how would you do
it in this case?
Imagine I have it installed in jspm_packages\npm\angular2@2.0.0-beta.1
, which it doesn't have an index.d.ts or typings.json file.

How would you do it with files?

On Wed, Jan 13, 2016 at 7:11 PM Blake Embrey notifications@github.com
wrote:

Thanks for the awesome feedback. It's definitely helpful. Would it be
reasonable if I just start with files for now, then expand to additional
features if there's a need for it? Installation is quite straightforward
and pretty well-defined for now, so I'd love to keep it that way as long as
possible.


Reply to this email directly or view it on GitHub
#108 (comment).

@blakeembrey
Copy link
Member

It was never a goal, unfortunately, to make projects that aren't related to the type definitions work. Typings was designed to consume type definitions and resolve over typings.json recursively. The fact it works with NPM modules is because some modules work flawlessly without any typings.json dependencies (either they have no dependencies or all their dependencies have inlined type definitions themselves).

The fact it has worked is a pleasant coincidence, but I don't know how far I want to go to make this use-case work when it should be obsoleted by the compiler anyway.

What I can do though, is open a PR to the team that uses typings.json once the files field is supported. That feels like the best way to support it. Sorry though, I know it's not the preferred answer.

@hbakhtiyor
Copy link

👍

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

No branches or pull requests

3 participants