Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeS…
…criptExtensions and rename
  • Loading branch information
Andy Hanson committed Aug 18, 2016
commit 8fc17afa003d53aa7baf914883f2b20606e8a879
2 changes: 2 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,8 @@ namespace ts {
* List of supported extensions in order of file resolution precedence.
*/
export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"];
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
export const supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
export const supportedJavascriptExtensions = [".js", ".jsx"];
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);

Expand Down
6 changes: 2 additions & 4 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2713,12 +2713,10 @@ namespace ts {
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
}

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

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