Skip to content

Commit 8fc17af

Browse files
author
Andy Hanson
committed
Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeScriptExtensions and rename
1 parent 2eb159e commit 8fc17af

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/compiler/core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,8 @@ namespace ts {
12431243
* List of supported extensions in order of file resolution precedence.
12441244
*/
12451245
export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"];
1246+
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
1247+
export const supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
12461248
export const supportedJavascriptExtensions = [".js", ".jsx"];
12471249
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
12481250

src/compiler/utilities.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,12 +2713,10 @@ namespace ts {
27132713
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
27142714
}
27152715

2716-
/** Return ".ts" or ".tsx" if that is the extension. */
2716+
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
27172717
export function tryExtractTypeScriptExtension(fileName: string): string | undefined {
2718-
return find(supportedTypescriptExtensionsWithDtsFirst, extension => fileExtensionIs(fileName, extension));
2718+
return find(supportedTypescriptExtensionsForExtractExtension, extension => fileExtensionIs(fileName, extension));
27192719
}
2720-
// Must have '.d.ts' first because if '.ts' goes first, that will be detected as the extension instead of '.d.ts'.
2721-
const supportedTypescriptExtensionsWithDtsFirst = supportedTypeScriptExtensions.slice().reverse();
27222720

27232721
/**
27242722
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences

0 commit comments

Comments
 (0)