Skip to content

Commit 718d57f

Browse files
author
Andy Hanson
committed
Move helper functions to core (fix build)
1 parent 9130fbd commit 718d57f

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/compiler/core.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,4 +2094,33 @@ namespace ts {
20942094
// pos === undefined || pos === null || isNaN(pos) || pos < 0;
20952095
return !(pos >= 0);
20962096
}
2097+
2098+
/** True if an extension is one of the supported TypeScript extensions. */
2099+
export function extensionIsTypeScript(ext: Extension): boolean {
2100+
return ext <= Extension.LastTypeScriptExtension;
2101+
}
2102+
2103+
/**
2104+
* Gets the extension from a path.
2105+
* Path must have a valid extension.
2106+
*/
2107+
export function extensionFromPath(path: string): Extension {
2108+
if (fileExtensionIs(path, ".d.ts")) {
2109+
return Extension.Dts;
2110+
}
2111+
if (fileExtensionIs(path, ".ts")) {
2112+
return Extension.Ts;
2113+
}
2114+
if (fileExtensionIs(path, ".tsx")) {
2115+
return Extension.Tsx;
2116+
}
2117+
if (fileExtensionIs(path, ".js")) {
2118+
return Extension.Js;
2119+
}
2120+
if (fileExtensionIs(path, ".jsx")) {
2121+
return Extension.Jsx;
2122+
}
2123+
Debug.fail(`File ${path} has unknown extension.`);
2124+
return Extension.Js;
2125+
}
20972126
}

src/compiler/utilities.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,6 @@ namespace ts {
118118
oldResolution.resolvedFileName === newResolution.resolvedFileName;
119119
}
120120

121-
/** True if an extension is one of the supported TypeScript extensions. */
122-
export function extensionIsTypeScript(ext: Extension): boolean {
123-
return ext <= Extension.LastTypeScriptExtension;
124-
}
125-
126-
/**
127-
* Gets the extension from a path.
128-
* Path must have a valid extension.
129-
*/
130-
export function extensionFromPath(path: string): Extension {
131-
if (fileExtensionIs(path, ".d.ts")) {
132-
return Extension.Dts;
133-
}
134-
if (fileExtensionIs(path, ".ts")) {
135-
return Extension.Ts;
136-
}
137-
if (fileExtensionIs(path, ".tsx")) {
138-
return Extension.Tsx;
139-
}
140-
if (fileExtensionIs(path, ".js")) {
141-
return Extension.Js;
142-
}
143-
if (fileExtensionIs(path, ".jsx")) {
144-
return Extension.Jsx;
145-
}
146-
Debug.fail(`File ${path} has unknown extension.`);
147-
return Extension.Js;
148-
}
149-
150121
/* @internal */
151122
export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean {
152123
return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;

0 commit comments

Comments
 (0)