Skip to content

Typescript Libraries #4363

@SonofNun15

Description

@SonofNun15

We are separating our application into distinct repositories to keep the pieces small and reusable.

We want something like DLLs in .NET where a TypeScript repository is compiled down to a distributable that can be imported into another TypeScript project and consumed. The compiled medium in TypeScript is JavaScript, so right now we're compiling down to a .js file and a .d.ts file.

Currently we are using TypeScript internal modules and referencing types in the library globally via namespace. I would rather use external modules with ES6 import statements.

What about adding a feature to the TypeScript compiler for compiling TS libraries into some format that can be imported via a TS ES6 import?

The compile process could check for errors and then bundle all of the included TS files into a single TS file. This solution would require the library TS file to ultimately be compiled to JS with the consuming code, which doesn't allow separate deployment. 😦

Another approach allowing for separate deployment would be dynamic import of .js + .d.ts file combinations in TS.

Thoughts? What is the best way to implement this type of architecture long term? Is there already a strategy for doing this that I missed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions