Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow JavaScript extensions for TypeScript imports #2

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

lukeed
Copy link
Owner

@lukeed lukeed commented Oct 5, 2021

Closes #1

When inside any TypeScript file (.ts, .tsx, .cts, or .mts) you may now write import statements to other TypeScript files, but using their would-be JavaScript extensions.

For example, assume this file structure:

demo
├── aaa.ts
├── bbb.cts
├── ccc.mts
└── main.ts

And now the main.ts file includes the following:

import aaa from './aaa.js';
// => loads the "aaa.ts" file

import bbb from './bbb.cjs';
// => loads the "bbb.cts" file

import ccc from './ccc.mjs';
// => loads the "ccc.mts" file

This is/will be supported officially by TypeScript. See here for more info

@lukeed lukeed merged commit c935537 into master Oct 5, 2021
@lukeed lukeed deleted the fix/ts-import-js branch October 5, 2021 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support .js extension for imports in .ts files
1 participant