Skip to content

Add --import compiler options to specify module imports that should happen for every module. #2911

Closed
@rbuckton

Description

@rbuckton

The --import compiler option can be specified multiple times on the command line, or would be a string array in tsconfig.json. Its argument is a module name which would be imported at the top of every external module in the project.

For example, the following command line:

tsc app.ts --import module

Would be the equivalent of:

// app.ts
import "module";

The named module will be resolved in the same way the above import declaration's module would be resolved, so the module name must either be declared as an ambient external module or resolve to a valid path relative to each external module in the list of sources, unless that would mean importing itself.

This is to support loading an external library of TypeScript helper functions as well as various polyfill and shim libraries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions