-
Notifications
You must be signed in to change notification settings - Fork 4
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
cts, mts, cjs, mjs, etc extension support #67
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial comments -- mostly questions about the new Extension[][]
structure for supported extensions.
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[]; | ||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[] { | ||
const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts, Extension.Cts, Extension.Mts, Extension.Ts, Extension.Tsx, Extension.Cts, Extension.Mts]; | ||
export const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find where the non-flat version is used.
@typescript-bot pack this |
D'oh. |
Might be worth making this a separate draft PR to TypeScript so we can get |
microsoft#45774 should track this on the TS repo and be a place where you can run bot commands (versus usefully review code) |
@@ -6742,58 +6750,63 @@ namespace ts { | |||
} | |||
|
|||
/** | |||
* List of supported extensions in order of file resolution precedence. | |||
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) | |
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and separately, CTS > DCTS) |
Merged in microsoft#45884 |
This is my first followup to
microsoft#44501 which officially adds support for loading
.mjs
,.cjs
,.mts
,.cts
,.d.mts
, and.d.cts
files. In non-node
moduleResolution
modes, these are largely the same as.js
,.ts
, and.d.ts
- the only difference being the output path mappings - a.mts
or.mjs
input always makes a.mjs
and.d.mts
output, while a.cjs
or.cts
input always makes a.cjs
and.d.cts
output. Innode
ish module resolution modes,c
-prefixed files imply a commonjs emit format, whilem
-prefixed files imply an esm format. As we've discussed in design meetings, to avoid comitting to a direction, we also forbid ambiguous generic arrow functions and angle bracket type cast syntax in.cts
and.mts
files, so we can reserve the right to make these files parse as jsx in the future.The watch/build mode baseline tests currently don't show any changes with edits, due to the bug fixed in microsoft#44935 - that'll need to get pulled in, and, once it is, the baseline updated.