Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

2 participants