Skip to content

Commit 959b6b6

Browse files
committed
remove unused dependencies to reduce the size of output file
1 parent b1871a5 commit 959b6b6

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/compiler/core.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ namespace ts {
942942
* [^./] # matches everything up to the first . character (excluding directory seperators)
943943
* (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
944944
*/
945-
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
945+
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
946946
const singleAsteriskRegexFragmentOther = "[^/]*";
947947

948948
export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") {
@@ -1196,6 +1196,14 @@ namespace ts {
11961196
return options && options.allowJs ? allSupportedExtensions : supportedTypeScriptExtensions;
11971197
}
11981198

1199+
export function hasJavaScriptFileExtension(fileName: string) {
1200+
return forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
1201+
}
1202+
1203+
export function hasTypeScriptFileExtension(fileName: string) {
1204+
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
1205+
}
1206+
11991207
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions) {
12001208
if (!fileName) { return false; }
12011209

src/compiler/utilities.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,14 +2718,6 @@ namespace ts {
27182718
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
27192719
}
27202720

2721-
export function hasJavaScriptFileExtension(fileName: string) {
2722-
return forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
2723-
}
2724-
2725-
export function hasTypeScriptFileExtension(fileName: string) {
2726-
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
2727-
}
2728-
27292721
/**
27302722
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
27312723
* representing the UTF-8 encoding of the character, and return the expanded char code list.

src/server/typingsInstaller/typingsInstaller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference path="../../services/JsTyping.ts"/>
2-
/// <reference path="../../services/shims.ts"/>
32
/// <reference path="../types.d.ts"/>
43

54
namespace ts.server.typingsInstaller {

src/services/jsTyping.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
22
// See LICENSE.txt in the project root for complete license information.
33

4-
/// <reference path='services.ts' />
4+
/// <reference path='../compiler/types.ts' />
5+
/// <reference path='../compiler/core.ts' />
6+
/// <reference path='../compiler/commandLineParser.ts' />
57

68
/* @internal */
79
namespace ts.JsTyping {
@@ -54,7 +56,10 @@ namespace ts.JsTyping {
5456
}
5557

5658
// Only infer typings for .js and .jsx files
57-
fileNames = filter(map(fileNames, normalizePath), f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JS, ScriptKind.JSX));
59+
fileNames = filter(map(fileNames, normalizePath), f => {
60+
const kind = ensureScriptKind(f, getScriptKindFromFileName(f));
61+
return kind === ScriptKind.JS || kind === ScriptKind.JSX;
62+
});
5863

5964
if (!safeList) {
6065
const result = readConfigFile(safeListPath, (path: string) => host.readFile(path));
@@ -170,7 +175,7 @@ namespace ts.JsTyping {
170175
mergeTypings(filter(cleanedTypingNames, f => hasProperty(safeList, f)));
171176
}
172177

173-
const hasJsxFile = forEach(fileNames, f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JSX));
178+
const hasJsxFile = forEach(fileNames, f => ensureScriptKind(f, getScriptKindFromFileName(f)) === ScriptKind.JSX);
174179
if (hasJsxFile) {
175180
mergeTypings(["react"]);
176181
}

0 commit comments

Comments
 (0)