Merge branch 'master' into requireJson

This commit is contained in:
Sheetal Nandi
2018-04-13 15:26:16 -07:00
400 changed files with 11097 additions and 11468 deletions
+2 -3
View File
@@ -1,5 +1,3 @@
/// <reference path="session.ts" />
namespace ts.server {
export interface SessionClientHost extends LanguageServiceHost {
writeMessage(message: string): void;
@@ -558,7 +556,8 @@ namespace ts.server {
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
const response = this.processResponse<protocol.CodeFixResponse>(request);
return response.body.map(({ description, changes, fixId, fixAllDescription }) => ({ description, changes: this.convertChanges(changes, file), fixId, fixAllDescription }));
return response.body.map<CodeFixAction>(({ fixName, description, changes, commands, fixId, fixAllDescription }) =>
({ fixName, description, changes: this.convertChanges(changes, file), commands: commands as CodeActionCommand[], fixId, fixAllDescription }));
}
getCombinedCodeFix = notImplemented;
+13 -15
View File
@@ -1,11 +1,3 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="utilities.ts" />
/// <reference path="session.ts" />
/// <reference path="scriptVersionCache.ts"/>
/// <reference path="project.ts"/>
/// <reference path="typingsCache.ts"/>
namespace ts.server {
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
@@ -392,6 +384,7 @@ namespace ts.server {
public readonly useSingleInferredProject: boolean;
public readonly useInferredProjectPerProjectRoot: boolean;
public readonly typingsInstaller: ITypingsInstaller;
private readonly globalCacheLocationDirectoryPath: Path;
public readonly throttleWaitMilliseconds?: number;
private readonly eventHandler?: ProjectServiceEventHandler;
private readonly suppressDiagnosticEvents?: boolean;
@@ -431,6 +424,8 @@ namespace ts.server {
}
this.currentDirectory = this.host.getCurrentDirectory();
this.toCanonicalFileName = createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation &&
ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation));
this.throttledOperations = new ThrottledOperations(this.host, this.logger);
if (this.typesMapLocation) {
@@ -548,10 +543,11 @@ namespace ts.server {
else {
if (this.pendingEnsureProjectForOpenFiles) {
this.ensureProjectForOpenFiles();
// Send the event to notify that there were background project updates
// send current list of open files
this.sendProjectsUpdatedInBackgroundEvent();
}
// Send the event to notify that there were background project updates
// send current list of open files
this.sendProjectsUpdatedInBackgroundEvent();
}
});
}
@@ -642,7 +638,6 @@ namespace ts.server {
return undefined;
}
if (isInferredProjectName(projectName)) {
this.ensureProjectStructuresUptoDate();
return findProjectByName(projectName, this.inferredProjects);
}
return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(toNormalizedPath(projectName));
@@ -1738,7 +1733,10 @@ namespace ts.server {
private watchClosedScriptInfo(info: ScriptInfo) {
Debug.assert(!info.fileWatcher);
// do not watch files with mixed content - server doesn't know how to interpret it
if (!info.isDynamicOrHasMixedContent()) {
// do not watch files in the global cache location
if (!info.isDynamicOrHasMixedContent() &&
(!this.globalCacheLocationDirectoryPath ||
!startsWith(info.path, this.globalCacheLocationDirectoryPath))) {
const { fileName } = info;
info.fileWatcher = this.watchFactory.watchFilePath(
this.host,
@@ -1836,11 +1834,11 @@ namespace ts.server {
this.logger.info(`Host information ${args.hostInfo}`);
}
if (args.formatOptions) {
mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions));
this.hostConfiguration.formatCodeOptions = { ...this.hostConfiguration.formatCodeOptions, ...convertFormatOptions(args.formatOptions) };
this.logger.info("Format host information updated");
}
if (args.preferences) {
mergeMapLikes(this.hostConfiguration.preferences, args.preferences);
this.hostConfiguration.preferences = { ...this.hostConfiguration.preferences, ...args.preferences };
}
if (args.extraFileExtensions) {
this.hostConfiguration.extraFileExtensions = args.extraFileExtensions;
-7
View File
@@ -1,10 +1,3 @@
/// <reference path="..\services\services.ts" />
/// <reference path="utilities.ts"/>
/// <reference path="scriptInfo.ts"/>
/// <reference path="..\compiler\resolutionCache.ts"/>
/// <reference path="typingsCache.ts"/>
/// <reference path="..\compiler\builderState.ts"/>
namespace ts.server {
export enum ProjectKind {
+5
View File
@@ -1698,6 +1698,8 @@ namespace ts.server.protocol {
}
export interface CodeFixAction extends CodeAction {
/** Short name to identify the fix, for use by telemetry. */
fixName: string;
/**
* If present, one may call 'getCombinedCodeFix' with this fixId.
* This may be omitted to indicate that the code fix can't be applied in a group.
@@ -2172,6 +2174,8 @@ namespace ts.server.protocol {
*/
category: string;
reportsUnnecessary?: {};
/**
* The error code of the diagnostic message.
*/
@@ -2638,6 +2642,7 @@ namespace ts.server.protocol {
}
export interface UserPreferences {
readonly disableSuggestions?: boolean;
readonly quotePreference?: "double" | "single";
/**
* If enabled, TypeScript will search through all external modules' exports and add them to the completions list.
+6 -5
View File
@@ -1,5 +1,3 @@
/// <reference path="scriptVersionCache.ts"/>
namespace ts.server {
/* @internal */
@@ -397,15 +395,18 @@ namespace ts.server {
if (formatSettings) {
if (!this.formatSettings) {
this.formatSettings = getDefaultFormatCodeSettings(this.host);
assign(this.formatSettings, formatSettings);
}
else {
this.formatSettings = { ...this.formatSettings, ...formatSettings };
}
mergeMapLikes(this.formatSettings, formatSettings);
}
if (preferences) {
if (!this.preferences) {
this.preferences = clone(defaultPreferences);
this.preferences = defaultPreferences;
}
mergeMapLikes(this.preferences, preferences);
this.preferences = { ...this.preferences, ...preferences };
}
}
-4
View File
@@ -1,7 +1,3 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="session.ts" />
/*@internal*/
namespace ts.server {
const lineCollectionCapacity = 4;
-9
View File
@@ -1,6 +1,3 @@
/// <reference path="shared.ts" />
/// <reference path="session.ts" />
namespace ts.server {
const childProcess: {
fork(modulePath: string, args: string[], options?: { execArgv: string[], env?: MapLike<string> }): NodeChildProcess;
@@ -211,12 +208,6 @@ namespace ts.server {
}
}
// E.g. "12:34:56.789"
function nowString() {
const d = new Date();
return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}`;
}
interface QueuedOperation {
operationId: string;
operation: () => void;
+23 -24
View File
@@ -1,8 +1,3 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="protocol.ts" />
/// <reference path="editorServices.ts" />
namespace ts.server {
interface StackTraceError extends Error {
stack?: string;
@@ -80,6 +75,7 @@ namespace ts.server {
text: flattenDiagnosticMessageText(diag.messageText, "\n"),
code: diag.code,
category: diagnosticCategoryName(diag),
reportsUnnecessary: diag.reportsUnnecessary,
source: diag.source
};
}
@@ -96,8 +92,8 @@ namespace ts.server {
const text = flattenDiagnosticMessageText(diag.messageText, "\n");
const { code, source } = diag;
const category = diagnosticCategoryName(diag);
return includeFileName ? { start, end, text, code, category, source, fileName: diag.file && diag.file.fileName } :
{ start, end, text, code, category, source };
return includeFileName ? { start, end, text, code, category, source, reportsUnnecessary: diag.reportsUnnecessary, fileName: diag.file && diag.file.fileName } :
{ start, end, text, code, category, reportsUnnecessary: diag.reportsUnnecessary, source };
}
export interface PendingErrorCheck {
@@ -484,7 +480,7 @@ namespace ts.server {
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag");
}
private infoCheck(file: NormalizedPath, project: Project) {
private suggestionCheck(file: NormalizedPath, project: Project) {
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
}
@@ -527,12 +523,20 @@ namespace ts.server {
return;
}
next.immediate(() => {
this.infoCheck(fileName, project);
const goNext = () => {
if (checkList.length > index) {
next.delay(followMs, checkOne);
}
});
};
if (this.getPreferences(fileName).disableSuggestions) {
goNext();
}
else {
next.immediate(() => {
this.suggestionCheck(fileName, project);
goNext();
});
}
});
};
@@ -1659,7 +1663,7 @@ namespace ts.server {
}
}
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CodeAction> | ReadonlyArray<CodeAction> {
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.CodeFixAction> | ReadonlyArray<CodeFixAction> {
if (args.errorCodes.length === 0) {
return undefined;
}
@@ -1669,15 +1673,7 @@ namespace ts.server {
const { startPosition, endPosition } = this.getStartAndEndPosition(args, scriptInfo);
const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file));
if (!codeActions) {
return undefined;
}
if (simplifiedResult) {
return codeActions.map(codeAction => this.mapCodeAction(project, codeAction));
}
else {
return codeActions;
}
return simplifiedResult ? codeActions.map(codeAction => this.mapCodeFixAction(project, codeAction)) : codeActions;
}
private getCombinedCodeFix({ scope, fixId }: protocol.GetCombinedCodeFixRequestArgs, simplifiedResult: boolean): protocol.CombinedCodeActions | CombinedCodeActions {
@@ -1725,9 +1721,12 @@ namespace ts.server {
return { startPosition, endPosition };
}
private mapCodeAction(project: Project, { description, changes: unmappedChanges, commands, fixId, fixAllDescription }: CodeFixAction): protocol.CodeFixAction {
const changes = unmappedChanges.map(change => this.mapTextChangesToCodeEditsUsingScriptinfo(change, project.getScriptInfoForNormalizedPath(toNormalizedPath(change.fileName))));
return { description, changes, commands, fixId, fixAllDescription };
private mapCodeAction(project: Project, { description, changes, commands }: CodeAction): protocol.CodeAction {
return { description, changes: this.mapTextChangesToCodeEdits(project, changes), commands };
}
private mapCodeFixAction(project: Project, { fixName, description, changes, commands, fixId, fixAllDescription }: CodeFixAction): protocol.CodeFixAction {
return { fixName, description, changes: this.mapTextChangesToCodeEdits(project, changes), commands, fixId, fixAllDescription };
}
private mapTextChangesToCodeEdits(project: Project, textChanges: ReadonlyArray<FileTextChanges>): protocol.FileCodeEdits[] {
+8 -3
View File
@@ -1,5 +1,3 @@
/// <reference path="types.ts" />
namespace ts.server {
// tslint:disable variable-name
export const ActionSet: ActionSet = "action::set";
@@ -33,4 +31,11 @@ namespace ts.server {
? sys.args[index + 1]
: undefined;
}
}
/*@internal*/
export function nowString() {
// E.g. "12:34:56.789"
const d = new Date();
return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}`;
}
}
+111 -3
View File
@@ -9,17 +9,125 @@
]
},
"files": [
"../services/shims.ts",
"../compiler/types.ts",
"../compiler/performance.ts",
"../compiler/core.ts",
"../compiler/sys.ts",
"../compiler/diagnosticInformationMap.generated.ts",
"../compiler/scanner.ts",
"../compiler/utilities.ts",
"../compiler/parser.ts",
"../compiler/binder.ts",
"../compiler/symbolWalker.ts",
"../compiler/moduleNameResolver.ts",
"../compiler/checker.ts",
"../compiler/factory.ts",
"../compiler/visitor.ts",
"../compiler/transformers/utilities.ts",
"../compiler/transformers/destructuring.ts",
"../compiler/transformers/ts.ts",
"../compiler/transformers/es2017.ts",
"../compiler/transformers/esnext.ts",
"../compiler/transformers/jsx.ts",
"../compiler/transformers/es2016.ts",
"../compiler/transformers/es2015.ts",
"../compiler/transformers/es5.ts",
"../compiler/transformers/generators.ts",
"../compiler/transformers/module/module.ts",
"../compiler/transformers/module/system.ts",
"../compiler/transformers/module/es2015.ts",
"../compiler/transformers/declarations/diagnostics.ts",
"../compiler/transformers/declarations.ts",
"../compiler/transformer.ts",
"../compiler/sourcemap.ts",
"../compiler/comments.ts",
"../compiler/emitter.ts",
"../compiler/watchUtilities.ts",
"../compiler/program.ts",
"../compiler/builderState.ts",
"../compiler/builder.ts",
"../compiler/resolutionCache.ts",
"../compiler/watch.ts",
"../compiler/commandLineParser.ts",
"../services/types.ts",
"../services/utilities.ts",
"../services/classifier.ts",
"../services/pathCompletions.ts",
"../services/completions.ts",
"../services/documentHighlights.ts",
"../services/documentRegistry.ts",
"../services/importTracker.ts",
"../services/findAllReferences.ts",
"../services/goToDefinition.ts",
"../services/jsDoc.ts",
"../services/semver.ts",
"../services/jsTyping.ts",
"../services/navigateTo.ts",
"../services/navigationBar.ts",
"../services/organizeImports.ts",
"../services/outliningElementsCollector.ts",
"../services/patternMatcher.ts",
"../services/preProcess.ts",
"../services/rename.ts",
"../services/signatureHelp.ts",
"../services/suggestionDiagnostics.ts",
"../services/symbolDisplay.ts",
"../services/transpile.ts",
"../services/formatting/formattingContext.ts",
"../services/formatting/formattingScanner.ts",
"../services/formatting/rule.ts",
"../services/formatting/rules.ts",
"../services/formatting/rulesMap.ts",
"../services/formatting/formatting.ts",
"../services/formatting/smartIndenter.ts",
"../services/textChanges.ts",
"../services/codeFixProvider.ts",
"../services/refactorProvider.ts",
"../services/codefixes/addMissingInvocationForDecorator.ts",
"../services/codefixes/annotateWithTypeFromJSDoc.ts",
"../services/codefixes/convertFunctionToEs6Class.ts",
"../services/codefixes/convertToEs6Module.ts",
"../services/codefixes/correctQualifiedNameToIndexedAccessType.ts",
"../services/codefixes/fixClassIncorrectlyImplementsInterface.ts",
"../services/codefixes/importFixes.ts",
"../services/codefixes/fixSpelling.ts",
"../services/codefixes/fixAddMissingMember.ts",
"../services/codefixes/fixCannotFindModule.ts",
"../services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
"../services/codefixes/fixClassSuperMustPrecedeThisAccess.ts",
"../services/codefixes/fixConstructorForDerivedNeedSuperCall.ts",
"../services/codefixes/fixExtendsInterfaceBecomesImplements.ts",
"../services/codefixes/fixForgottenThisPropertyAccess.ts",
"../services/codefixes/fixUnusedIdentifier.ts",
"../services/codefixes/fixJSDocTypes.ts",
"../services/codefixes/fixAwaitInSyncFunction.ts",
"../services/codefixes/disableJsDiagnostics.ts",
"../services/codefixes/helpers.ts",
"../services/codefixes/inferFromUsage.ts",
"../services/codefixes/fixInvalidImportSyntax.ts",
"../services/codefixes/fixStrictClassInitialization.ts",
"../services/codefixes/useDefaultImport.ts",
"../services/codefixes/fixes.ts",
"../services/refactors/extractSymbol.ts",
"../services/refactors/generateGetAccessorAndSetAccessor.ts",
"../services/refactors/refactors.ts",
"../services/sourcemaps.ts",
"../services/services.ts",
"../services/breakpoints.ts",
"../services/transform.ts",
"../services/shims.ts",
"types.ts",
"shared.ts",
"utilities.ts",
"scriptVersionCache.ts",
"protocol.ts",
"scriptInfo.ts",
"typingsCache.ts",
"project.ts",
"editorServices.ts",
"protocol.ts",
"session.ts",
"scriptVersionCache.ts",
"server.ts"
]
}
+116 -9
View File
@@ -15,17 +15,124 @@
"types": []
},
"files": [
"editorServices.ts",
"project.ts",
"../compiler/types.ts",
"../compiler/performance.ts",
"../compiler/core.ts",
"../compiler/sys.ts",
"../compiler/diagnosticInformationMap.generated.ts",
"../compiler/scanner.ts",
"../compiler/utilities.ts",
"../compiler/parser.ts",
"../compiler/binder.ts",
"../compiler/symbolWalker.ts",
"../compiler/moduleNameResolver.ts",
"../compiler/checker.ts",
"../compiler/factory.ts",
"../compiler/visitor.ts",
"../compiler/transformers/utilities.ts",
"../compiler/transformers/destructuring.ts",
"../compiler/transformers/ts.ts",
"../compiler/transformers/es2017.ts",
"../compiler/transformers/esnext.ts",
"../compiler/transformers/jsx.ts",
"../compiler/transformers/es2016.ts",
"../compiler/transformers/es2015.ts",
"../compiler/transformers/es5.ts",
"../compiler/transformers/generators.ts",
"../compiler/transformers/module/module.ts",
"../compiler/transformers/module/system.ts",
"../compiler/transformers/module/es2015.ts",
"../compiler/transformers/declarations/diagnostics.ts",
"../compiler/transformers/declarations.ts",
"../compiler/transformer.ts",
"../compiler/sourcemap.ts",
"../compiler/comments.ts",
"../compiler/emitter.ts",
"../compiler/watchUtilities.ts",
"../compiler/program.ts",
"../compiler/builderState.ts",
"../compiler/builder.ts",
"../compiler/resolutionCache.ts",
"../compiler/watch.ts",
"../compiler/commandLineParser.ts",
"../services/types.ts",
"../services/utilities.ts",
"../services/classifier.ts",
"../services/pathCompletions.ts",
"../services/completions.ts",
"../services/documentHighlights.ts",
"../services/documentRegistry.ts",
"../services/importTracker.ts",
"../services/findAllReferences.ts",
"../services/goToDefinition.ts",
"../services/jsDoc.ts",
"../services/semver.ts",
"../services/jsTyping.ts",
"../services/navigateTo.ts",
"../services/navigationBar.ts",
"../services/organizeImports.ts",
"../services/outliningElementsCollector.ts",
"../services/patternMatcher.ts",
"../services/preProcess.ts",
"../services/rename.ts",
"../services/signatureHelp.ts",
"../services/suggestionDiagnostics.ts",
"../services/symbolDisplay.ts",
"../services/transpile.ts",
"../services/formatting/formattingContext.ts",
"../services/formatting/formattingScanner.ts",
"../services/formatting/rule.ts",
"../services/formatting/rules.ts",
"../services/formatting/rulesMap.ts",
"../services/formatting/formatting.ts",
"../services/formatting/smartIndenter.ts",
"../services/textChanges.ts",
"../services/codeFixProvider.ts",
"../services/refactorProvider.ts",
"../services/codefixes/addMissingInvocationForDecorator.ts",
"../services/codefixes/annotateWithTypeFromJSDoc.ts",
"../services/codefixes/convertFunctionToEs6Class.ts",
"../services/codefixes/convertToEs6Module.ts",
"../services/codefixes/correctQualifiedNameToIndexedAccessType.ts",
"../services/codefixes/fixClassIncorrectlyImplementsInterface.ts",
"../services/codefixes/importFixes.ts",
"../services/codefixes/fixSpelling.ts",
"../services/codefixes/fixAddMissingMember.ts",
"../services/codefixes/fixCannotFindModule.ts",
"../services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
"../services/codefixes/fixClassSuperMustPrecedeThisAccess.ts",
"../services/codefixes/fixConstructorForDerivedNeedSuperCall.ts",
"../services/codefixes/fixExtendsInterfaceBecomesImplements.ts",
"../services/codefixes/fixForgottenThisPropertyAccess.ts",
"../services/codefixes/fixUnusedIdentifier.ts",
"../services/codefixes/fixJSDocTypes.ts",
"../services/codefixes/fixAwaitInSyncFunction.ts",
"../services/codefixes/disableJsDiagnostics.ts",
"../services/codefixes/helpers.ts",
"../services/codefixes/inferFromUsage.ts",
"../services/codefixes/fixInvalidImportSyntax.ts",
"../services/codefixes/fixStrictClassInitialization.ts",
"../services/codefixes/useDefaultImport.ts",
"../services/codefixes/fixes.ts",
"../services/refactors/extractSymbol.ts",
"../services/refactors/generateGetAccessorAndSetAccessor.ts",
"../services/refactors/refactors.ts",
"../services/sourcemaps.ts",
"../services/services.ts",
"../services/breakpoints.ts",
"../services/transform.ts",
"../services/shims.ts",
"types.ts",
"shared.ts",
"utilities.ts",
"protocol.ts",
"scriptInfo.ts",
"scriptVersionCache.ts",
"session.ts",
"shared.ts",
"types.ts",
"typingsCache.ts",
"utilities.ts",
"../services/shims.ts",
"../services/utilities.ts"
"project.ts",
"editorServices.ts",
"session.ts",
"scriptVersionCache.ts"
]
}
-4
View File
@@ -1,7 +1,3 @@
/// <reference path="../compiler/types.ts"/>
/// <reference path="../compiler/sys.ts"/>
/// <reference path="../services/jsTyping.ts"/>
declare namespace ts.server {
export interface CompressedData {
length: number;
-2
View File
@@ -1,5 +1,3 @@
/// <reference path="project.ts"/>
namespace ts.server {
export interface InstallPackageOptionsWithProject extends InstallPackageOptions {
projectName: string;
@@ -21,7 +21,7 @@ namespace ts.server.typingsInstaller {
}
writeLine = (text: string) => {
try {
fs.appendFileSync(this.logFile, text + sys.newLine);
fs.appendFileSync(this.logFile, `[${nowString()}] ${text}${sys.newLine}`);
}
catch (e) {
this.logEnabled = false;
@@ -184,9 +184,8 @@ namespace ts.server.typingsInstaller {
if (this.log.isEnabled()) {
this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(packageNames)}'.`);
}
const command = `${this.npmPath} install --ignore-scripts ${packageNames.join(" ")} --save-dev --user-agent="typesInstaller/${version}"`;
const start = Date.now();
const hasError = this.execSyncAndLog(command, { cwd });
const hasError = installNpmPackages(this.npmPath, version, packageNames, command => this.execSyncAndLog(command, { cwd }));
if (this.log.isEnabled()) {
this.log.writeLine(`npm install #${requestId} took: ${Date.now() - start} ms`);
}
@@ -30,6 +30,31 @@ namespace ts.server.typingsInstaller {
}
}
/*@internal*/
export function installNpmPackages(npmPath: string, tsVersion: string, packageNames: string[], install: (command: string) => boolean) {
let hasError = false;
for (let remaining = packageNames.length; remaining > 0;) {
const result = getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining);
remaining = result.remaining;
hasError = install(result.command) || hasError;
}
return hasError;
}
/*@internal*/
export function getNpmCommandForInstallation(npmPath: string, tsVersion: string, packageNames: string[], remaining: number) {
const sliceStart = packageNames.length - remaining;
let command: string, toSlice = remaining;
while (true) {
command = `${npmPath} install --ignore-scripts ${(toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ")} --save-dev --user-agent="typesInstaller/${tsVersion}"`;
if (command.length < 8000) {
break;
}
toSlice = toSlice - Math.floor(toSlice / 2);
}
return { command, remaining: remaining - toSlice };
}
export type RequestCompletedAction = (success: boolean) => void;
interface PendingRequest {
-11
View File
@@ -1,6 +1,3 @@
/// <reference path="types.ts" />
/// <reference path="shared.ts" />
namespace ts.server {
export enum LogLevel {
terse,
@@ -83,14 +80,6 @@ namespace ts.server {
};
}
export function mergeMapLikes<T extends object>(target: T, source: Partial<T>): void {
for (const key in source) {
if (hasProperty(source, key)) {
target[key] = source[key];
}
}
}
export type NormalizedPath = string & { __normalizedPathTag: any };
export function toNormalizedPath(fileName: string): NormalizedPath {