Skip to content

Allow importing directories with index.ts files as relative external modules. #207

Closed
@coreh

Description

@coreh

Hi there,

├ foo/
│  └ index.ts
└ bar/
   └ index.ts

Assume you have the project structure above, and that you'd like to require the file foo/index.ts, from file bar/index.ts.

With the current version of TypeScript you must use the

import foo = require('../foo/index')

CommonJS-based environments like node and browserify allow you to omit the index part, and use just require('../foo'). I think it would make sense for the typescript compiler to also allow that. (Considering it does look for index.ts in global external modules)

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions