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

TypeScript typings file node.d.ts versus index.d.ts #352

Closed
jfathman opened this issue Mar 19, 2016 · 10 comments
Closed

TypeScript typings file node.d.ts versus index.d.ts #352

jfathman opened this issue Mar 19, 2016 · 10 comments

Comments

@jfathman
Copy link

I've been experimenting with TypeScript on Node.js (and liking it a lot).

Somewhere along the way, I ended up with this node.d.ts which worked:

/// <reference path='./typings/main/ambient/node/node.d.ts' />  

Today I started a fresh project and typings gave me this instead:

/// <reference path='./typings/main/ambient/node/index.d.ts' />

It works, but I am wondering why the file name is now index.d.ts instead of node.d.ts.

@blakeembrey
Copy link
Member

Because when you have names with slashes, it becomes cumbersome. E.g. @foo/bar/@foo/bar.d.ts. There were some related bugs because of this.

@blakeembrey
Copy link
Member

Sorry for that breaking change though. You should be able to keep references to just typings/main.d.ts instead, and even use tsconfig.json instead too and never use references again. It's easier to use that way, but up to you, of course.

@jfathman
Copy link
Author

Thanks, @blakeembrey, but I am not quite understanding yet. My question is why 'node.d.ts' changed to 'index.d.ts'. Not complaining, just starting out with TypeScript and Typings and wanted to understand what I was seeing. I thought 'node.d.ts' was a better filename, but 'index.d.ts' is fine if it is intentional.

@jfathman
Copy link
Author

For example, the 'node.d.ts' filename is what I see here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts

@blakeembrey
Copy link
Member

Because when you have names with slashes, it becomes cumbersome.

The name was previously generated based on the module name. So every library install was <name>/<name>.d.ts.

@blakeembrey
Copy link
Member

The name in DefinitelyTyped doesn't have any relation to Typings. The old named locations were <name>/<name>.d.ts, now they are <name>/index.d.ts instead because of the reason mentioned above. Weirdness when it comes to names with slashes in them.

@jfathman
Copy link
Author

Roger that. I understand the motivation to make the change now. The name translation is intentional. Thanks @blakeembrey for the clarification. And thanks for your contributions to open source.

@blakeembrey
Copy link
Member

No worries, cheers. Sorry for the breaking change, it wasn't well communicated other than when I added a little notice to the README.

@blakeembrey
Copy link
Member

@jfathman I do recommend you use tsconfig.json though. It's much easier to manage the project 😄

@jfathman
Copy link
Author

Thanks for the suggestion, I will explore that. Very new to TypeScript.

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

No branches or pull requests

2 participants