mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Merge branch 'master' into tsbuild
This commit is contained in:
commit
cf87bd446d
1932 files changed
+64965
-53047
No files matched your search
+11
-1
@@ -183,7 +183,7 @@ namespace compiler {
|
||||
|
||||
public getSourceMapRecord(): string | undefined {
|
||||
if (this.result!.sourceMaps && this.result!.sourceMaps!.length > 0) {
|
||||
return Harness.SourceMapRecorder.getSourceMapRecord(this.result!.sourceMaps!, this.program!, Array.from(this.js.values()), Array.from(this.dts.values()));
|
||||
return Harness.SourceMapRecorder.getSourceMapRecord(this.result!.sourceMaps!, this.program!, Array.from(this.js.values()).filter(d => !ts.fileExtensionIs(d.file, ts.Extension.Json)), Array.from(this.dts.values()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,16 @@ namespace compiler {
|
||||
}
|
||||
return vpath.changeExtension(path, ext);
|
||||
}
|
||||
|
||||
public getNumberOfJsFiles() {
|
||||
let count = this.js.size;
|
||||
this.js.forEach(document => {
|
||||
if (ts.fileExtensionIs(document.file, ts.Extension.Json)) {
|
||||
count--;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | undefined, compilerOptions: ts.CompilerOptions): CompilationResult {
|
||||
|
||||
+23
-11
@@ -1090,7 +1090,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
private getNode(): ts.Node {
|
||||
return ts.getTouchingPropertyName(this.getSourceFile(), this.currentCaretPosition, /*includeJsDocComment*/ false);
|
||||
return ts.getTouchingPropertyName(this.getSourceFile(), this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private goToAndGetNode(range: Range): ts.Node {
|
||||
@@ -2743,6 +2743,14 @@ Actual: ${stringify(fullActual)}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyJsxClosingTag(map: { [markerName: string]: ts.JsxClosingTagInfo | undefined }): void {
|
||||
for (const markerName in map) {
|
||||
this.goToMarker(markerName);
|
||||
const actual = this.languageService.getJsxClosingTagAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
assert.deepEqual(actual, map[markerName]);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) {
|
||||
const actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition);
|
||||
|
||||
@@ -3131,8 +3139,12 @@ Actual: ${stringify(fullActual)}`);
|
||||
assert(action.name === "Move to a new file" && action.description === "Move to a new file");
|
||||
|
||||
const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactor.name, action.name, options.preferences || ts.defaultPreferences)!;
|
||||
for (const edit of editInfo.edits) {
|
||||
const newContent = options.newFileContents[edit.fileName];
|
||||
this.testNewFileContents(editInfo.edits, options.newFileContents);
|
||||
}
|
||||
|
||||
private testNewFileContents(edits: ReadonlyArray<ts.FileTextChanges>, newFileContents: { [fileName: string]: string }): void {
|
||||
for (const edit of edits) {
|
||||
const newContent = newFileContents[edit.fileName];
|
||||
if (newContent === undefined) {
|
||||
this.raiseError(`There was an edit in ${edit.fileName} but new content was not specified.`);
|
||||
}
|
||||
@@ -3149,8 +3161,8 @@ Actual: ${stringify(fullActual)}`);
|
||||
}
|
||||
}
|
||||
|
||||
for (const fileName in options.newFileContents) {
|
||||
assert(editInfo.edits.some(e => e.fileName === fileName));
|
||||
for (const fileName in newFileContents) {
|
||||
assert(edits.some(e => e.fileName === fileName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3360,12 +3372,8 @@ Actual: ${stringify(fullActual)}`);
|
||||
}
|
||||
|
||||
public getEditsForFileRename(options: FourSlashInterface.GetEditsForFileRenameOptions): void {
|
||||
const changes = this.languageService.getEditsForFileRename(options.oldPath, options.newPath, this.formatCodeSettings);
|
||||
this.applyChanges(changes);
|
||||
for (const fileName in options.newFileContents) {
|
||||
this.openFile(fileName);
|
||||
this.verifyCurrentFileContent(options.newFileContents[fileName]);
|
||||
}
|
||||
const changes = this.languageService.getEditsForFileRename(options.oldPath, options.newPath, this.formatCodeSettings, ts.defaultPreferences);
|
||||
this.testNewFileContents(changes, options.newFileContents);
|
||||
}
|
||||
|
||||
private getApplicableRefactors(positionOrRange: number | ts.TextRange, preferences = ts.defaultPreferences): ReadonlyArray<ts.ApplicableRefactorInfo> {
|
||||
@@ -4079,6 +4087,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
|
||||
}
|
||||
|
||||
public jsxClosingTag(map: { [markerName: string]: ts.JsxClosingTagInfo | undefined }): void {
|
||||
this.state.verifyJsxClosingTag(map);
|
||||
}
|
||||
|
||||
public isInCommentAtPosition(onlyMultiLineDiverges?: boolean) {
|
||||
this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLineDiverges);
|
||||
}
|
||||
|
||||
@@ -1270,7 +1270,7 @@ namespace Harness {
|
||||
throw new Error("Only declaration files should be generated when emitDeclarationOnly:true");
|
||||
}
|
||||
}
|
||||
else if (result.dts.size !== result.js.size) {
|
||||
else if (result.dts.size !== result.getNumberOfJsFiles()) {
|
||||
throw new Error("There were no errors and declFiles generated did not match number of js files generated");
|
||||
}
|
||||
}
|
||||
@@ -1645,7 +1645,7 @@ namespace Harness {
|
||||
return;
|
||||
}
|
||||
else if (options.sourceMap || declMaps) {
|
||||
if (result.maps.size !== (result.js.size * (declMaps && options.sourceMap ? 2 : 1))) {
|
||||
if (result.maps.size !== (result.getNumberOfJsFiles() * (declMaps && options.sourceMap ? 2 : 1))) {
|
||||
throw new Error("Number of sourcemap files should be same as js files.");
|
||||
}
|
||||
|
||||
|
||||
@@ -509,6 +509,9 @@ namespace Harness.LanguageService {
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
|
||||
}
|
||||
getJsxClosingTagAtPosition(): never {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): ts.TextSpan {
|
||||
return unwrapJSONCallResult(this.shim.getSpanOfEnclosingComment(fileName, position, onlyMultiLine));
|
||||
}
|
||||
@@ -573,7 +576,8 @@ namespace Harness.LanguageService {
|
||||
importedFiles: [],
|
||||
ambientExternalModules: [],
|
||||
isLibFile: shimResult.isLibFile,
|
||||
typeReferenceDirectives: []
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: []
|
||||
};
|
||||
|
||||
ts.forEach(shimResult.referencedFiles, refFile => {
|
||||
@@ -794,7 +798,7 @@ namespace Harness.LanguageService {
|
||||
const proxy = makeDefaultProxy(info);
|
||||
proxy.getSemanticDiagnostics = filename => {
|
||||
const prev = info.languageService.getSemanticDiagnostics(filename);
|
||||
const sourceFile: ts.SourceFile = info.languageService.getSourceFile(filename);
|
||||
const sourceFile: ts.SourceFile = info.project.getSourceFile(ts.toPath(filename, /*basePath*/ undefined, ts.createGetCanonicalFileName(info.serverHost.useCaseSensitiveFileNames)))!;
|
||||
prev.push({
|
||||
category: ts.DiagnosticCategory.Warning,
|
||||
file: sourceFile,
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"../compiler/builderState.ts",
|
||||
"../compiler/builder.ts",
|
||||
"../compiler/resolutionCache.ts",
|
||||
"../compiler/moduleSpecifiers.ts",
|
||||
"../compiler/watch.ts",
|
||||
"../compiler/tsbuild.ts",
|
||||
"../compiler/commandLineParser.ts",
|
||||
@@ -116,7 +117,6 @@
|
||||
"../services/codefixes/inferFromUsage.ts",
|
||||
"../services/codefixes/fixInvalidImportSyntax.ts",
|
||||
"../services/codefixes/fixStrictClassInitialization.ts",
|
||||
"../services/codefixes/moduleSpecifiers.ts",
|
||||
"../services/codefixes/requireInTs.ts",
|
||||
"../services/codefixes/useDefaultImport.ts",
|
||||
"../services/codefixes/fixAddModuleReferTypeMissingTypeof.ts",
|
||||
|
||||
@@ -56,9 +56,19 @@ namespace ts {
|
||||
r => assert.exists(r.displayParts)
|
||||
);
|
||||
});
|
||||
|
||||
it("can cancel suggestion diagnostics mid-request", () => {
|
||||
verifyOperationCancelledAfter(file, 1, service => // The LS doesn't do any top-level checks on the token for suggestion diagnostics, so the first check is within the checker
|
||||
service.getSuggestionDiagnostics("file.js"),
|
||||
r => assert.notEqual(r.length, 0),
|
||||
"file.js",
|
||||
"function foo() { let a = 10; }",
|
||||
{ allowJs: true }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function verifyOperationCancelledAfter<T>(content: string, cancelAfter: number, operation: (service: LanguageService) => T, validator: (arg: T) => void) {
|
||||
function verifyOperationCancelledAfter<T>(content: string, cancelAfter: number, operation: (service: LanguageService) => T, validator: (arg: T) => void, fileName?: string, fileContent?: string, options?: CompilerOptions) {
|
||||
let checks = 0;
|
||||
const token: HostCancellationToken = {
|
||||
isCancellationRequested() {
|
||||
@@ -70,9 +80,9 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
};
|
||||
const adapter = new Harness.LanguageService.NativeLanguageServiceAdapter(token);
|
||||
const adapter = new Harness.LanguageService.NativeLanguageServiceAdapter(token, options);
|
||||
const host = adapter.getHost();
|
||||
host.addScript("file.ts", content, /*isRootFile*/ true);
|
||||
host.addScript(fileName || "file.ts", fileContent || content, /*isRootFile*/ true);
|
||||
const service = adapter.getLanguageService();
|
||||
assertCancelled(() => operation(service));
|
||||
validator(operation(service));
|
||||
@@ -92,4 +102,4 @@ namespace ts {
|
||||
assert.exists(caught, "Expected operation to be cancelled, but was not");
|
||||
assert.instanceOf(caught, OperationCanceledException);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
file: undefined,
|
||||
@@ -262,7 +262,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
file: undefined,
|
||||
@@ -281,7 +281,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
file: undefined,
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -299,7 +299,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -330,7 +330,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -361,7 +361,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.asynciterable'.",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable'.",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
|
||||
@@ -9,7 +9,7 @@ describe("forAwaitOfEvaluation", () => {
|
||||
case 0: return { value: 1, done: false };
|
||||
case 1: return { value: Promise.resolve(2), done: false };
|
||||
case 2: return { value: new Promise<number>(resolve => setTimeout(resolve, 100, 3)), done: false };
|
||||
default: return { value: undefined: done: true };
|
||||
default: return { value: undefined, done: true };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -35,7 +35,7 @@ describe("forAwaitOfEvaluation", () => {
|
||||
case 0: return { value: 1, done: false };
|
||||
case 1: return { value: Promise.resolve(2), done: false };
|
||||
case 2: return { value: new Promise<number>(resolve => setTimeout(resolve, 100, 3)), done: false };
|
||||
default: return { value: undefined: done: true };
|
||||
default: return { value: undefined, done: true };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -61,7 +61,7 @@ describe("forAwaitOfEvaluation", () => {
|
||||
case 0: return { value: 1, done: false };
|
||||
case 1: return { value: Promise.resolve(2), done: false };
|
||||
case 2: return { value: new Promise<number>(resolve => setTimeout(resolve, 100, 3)), done: false };
|
||||
default: return { value: undefined: done: true };
|
||||
default: return { value: undefined, done: true };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -87,7 +87,7 @@ describe("forAwaitOfEvaluation", () => {
|
||||
case 0: return { value: 1, done: false };
|
||||
case 1: return { value: Promise.resolve(2), done: false };
|
||||
case 2: return { value: new Promise<number>(resolve => setTimeout(resolve, 100, 3)), done: false };
|
||||
default: return { value: undefined: done: true };
|
||||
default: return { value: undefined, done: true };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -102,4 +102,4 @@ describe("forAwaitOfEvaluation", () => {
|
||||
assert.instanceOf(result.output[1], Promise);
|
||||
assert.instanceOf(result.output[2], Promise);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -9,6 +9,7 @@ describe("PreProcessFile:", () => {
|
||||
checkFileReferenceList("Imported files", expectedPreProcess.importedFiles, resultPreProcess.importedFiles);
|
||||
checkFileReferenceList("Referenced files", expectedPreProcess.referencedFiles, resultPreProcess.referencedFiles);
|
||||
checkFileReferenceList("Type reference directives", expectedPreProcess.typeReferenceDirectives, resultPreProcess.typeReferenceDirectives);
|
||||
checkFileReferenceList("Lib reference directives", expectedPreProcess.libReferenceDirectives, resultPreProcess.libReferenceDirectives);
|
||||
|
||||
assert.deepEqual(resultPreProcess.ambientExternalModules, expectedPreProcess.ambientExternalModules);
|
||||
}
|
||||
@@ -41,6 +42,7 @@ describe("PreProcessFile:", () => {
|
||||
{ fileName: "refFile3.ts", pos: 94, end: 105 }, { fileName: "..\\refFile4d.ts", pos: 131, end: 146 }],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
});
|
||||
@@ -54,6 +56,7 @@ describe("PreProcessFile:", () => {
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
});
|
||||
@@ -67,6 +70,7 @@ describe("PreProcessFile:", () => {
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
});
|
||||
@@ -80,6 +84,7 @@ describe("PreProcessFile:", () => {
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
});
|
||||
@@ -92,6 +97,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 20, end: 25 }, { fileName: "r2.ts", pos: 49, end: 54 }, { fileName: "r3.ts", pos: 78, end: 83 },
|
||||
{ fileName: "r4.ts", pos: 106, end: 111 }, { fileName: "r5.ts", pos: 138, end: 143 }],
|
||||
ambientExternalModules: undefined,
|
||||
@@ -106,6 +112,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
@@ -119,6 +126,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [{ fileName: "r3.ts", pos: 73, end: 78 }],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
@@ -132,6 +140,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 20, end: 31 }, { fileName: "refFile2.ts", pos: 57, end: 68 }],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 92, end: 97 }, { fileName: "r2.ts", pos: 121, end: 126 }],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
@@ -145,6 +154,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 20, end: 31 }],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 91, end: 96 }, { fileName: "r3.ts", pos: 148, end: 153 }],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
@@ -164,6 +174,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m1", pos: 20, end: 22 },
|
||||
{ fileName: "m2", pos: 51, end: 53 },
|
||||
@@ -188,6 +199,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m1", pos: 14, end: 16 },
|
||||
{ fileName: "m2", pos: 36, end: 38 },
|
||||
@@ -212,6 +224,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [],
|
||||
ambientExternalModules: ["B"],
|
||||
isLibFile: false
|
||||
@@ -225,6 +238,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m1", pos: 26, end: 28 }
|
||||
],
|
||||
@@ -244,6 +258,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m1", pos: 39, end: 41 },
|
||||
{ fileName: "m2", pos: 74, end: 76 },
|
||||
@@ -264,6 +279,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "mod1", pos: 21, end: 25 },
|
||||
{ fileName: "mod2", pos: 29, end: 33 },
|
||||
@@ -282,6 +298,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "mod1", pos: 28, end: 32 },
|
||||
{ fileName: "mod2", pos: 36, end: 40 },
|
||||
@@ -303,6 +320,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "../Observable", pos: 28, end: 41 }
|
||||
],
|
||||
@@ -323,6 +341,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m", pos: 123, end: 124 },
|
||||
{ fileName: "../Observable", pos: 28, end: 41 }
|
||||
@@ -344,6 +363,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m", pos: 123, end: 124 },
|
||||
{ fileName: "../Observable", pos: 28, end: 41 }
|
||||
@@ -365,6 +385,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "../Observable", pos: 28, end: 41 }
|
||||
],
|
||||
@@ -385,6 +406,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "../Observable", pos: 28, end: 41 }
|
||||
],
|
||||
@@ -404,6 +426,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "../Observable", pos: 28, end: 41 }
|
||||
],
|
||||
@@ -425,6 +448,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m2", pos: 65, end: 67 },
|
||||
{ fileName: "augmentation", pos: 102, end: 114 }
|
||||
@@ -449,6 +473,7 @@ describe("PreProcessFile:", () => {
|
||||
{
|
||||
referencedFiles: [],
|
||||
typeReferenceDirectives: [],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [
|
||||
{ fileName: "m2", pos: 127, end: 129 },
|
||||
{ fileName: "augmentation", pos: 164, end: 176 }
|
||||
@@ -475,6 +500,32 @@ describe("PreProcessFile:", () => {
|
||||
{ pos: 73, end: 75, fileName: "a1" },
|
||||
{ pos: 152, end: 154, fileName: "a3" }
|
||||
],
|
||||
libReferenceDirectives: [],
|
||||
importedFiles: [],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
});
|
||||
});
|
||||
it ("correctly recognizes lib reference directives", () => {
|
||||
test(`
|
||||
/// <reference path="a"/>
|
||||
/// <reference lib="a1"/>
|
||||
/// <reference path="a2"/>
|
||||
/// <reference lib="a3"/>
|
||||
`,
|
||||
/*readImportFile*/ true,
|
||||
/*detectJavaScriptImports*/ false,
|
||||
{
|
||||
referencedFiles: [
|
||||
{ pos: 34, end: 35, fileName: "a" },
|
||||
{ pos: 110, end: 112, fileName: "a2" }
|
||||
],
|
||||
typeReferenceDirectives: [
|
||||
],
|
||||
libReferenceDirectives: [
|
||||
{ pos: 71, end: 73, fileName: "a1" },
|
||||
{ pos: 148, end: 150, fileName: "a3" }
|
||||
],
|
||||
importedFiles: [],
|
||||
ambientExternalModules: undefined,
|
||||
isLibFile: false
|
||||
|
||||
@@ -224,6 +224,7 @@ namespace ts.server {
|
||||
CommandNames.Occurrences,
|
||||
CommandNames.DocumentHighlights,
|
||||
CommandNames.DocumentHighlightsFull,
|
||||
CommandNames.JsxClosingTag,
|
||||
CommandNames.Open,
|
||||
CommandNames.Quickinfo,
|
||||
CommandNames.QuickinfoFull,
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace ts {
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true, { documents: [new documents.TextDocument("/.src/index.ts", text)] });
|
||||
const host = new fakes.CompilerHost(fs, opts.compilerOptions);
|
||||
const program = createProgram(["/.src/index.ts"], opts.compilerOptions!, host);
|
||||
program.emit(program.getSourceFiles()[1], (p, s, bom) => host.writeFile(p, s, bom), /*cancellationToken*/ undefined, /*onlyDts*/ true, opts.transformers);
|
||||
program.emit(program.getSourceFile("/.src/index.ts"), (p, s, bom) => host.writeFile(p, s, bom), /*cancellationToken*/ undefined, /*onlyDts*/ true, opts.transformers);
|
||||
return fs.readFileSync("/.src/index.d.ts").toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -8400,15 +8400,23 @@ new C();`
|
||||
path: "/user.ts",
|
||||
content: 'import { x } from "./old";',
|
||||
};
|
||||
const newTs: File = {
|
||||
path: "/new.ts",
|
||||
content: "export const x = 0;",
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: "/tsconfig.json",
|
||||
content: "{}",
|
||||
};
|
||||
|
||||
const host = createServerHost([userTs]);
|
||||
const host = createServerHost([userTs, newTs, tsconfig]);
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(userTs.path);
|
||||
const project = first(projectService.inferredProjects);
|
||||
const project = projectService.configuredProjects.get(tsconfig.path)!;
|
||||
|
||||
Debug.assert(!!project.resolveModuleNames);
|
||||
|
||||
const edits = project.getLanguageService().getEditsForFileRename("/old.ts", "/new.ts", testFormatOptions);
|
||||
const edits = project.getLanguageService().getEditsForFileRename("/old.ts", "/new.ts", testFormatOptions, defaultPreferences);
|
||||
assert.deepEqual<ReadonlyArray<FileTextChanges>>(edits, [{
|
||||
fileName: "/user.ts",
|
||||
textChanges: [{
|
||||
|
||||
@@ -1340,6 +1340,27 @@ namespace ts.projectSystem {
|
||||
assert.deepEqual(result.newTypingNames, ["bar"]);
|
||||
});
|
||||
|
||||
it("should gracefully handle packages that have been removed from the types-registry", () => {
|
||||
const f = {
|
||||
path: "/a/b/app.js",
|
||||
content: ""
|
||||
};
|
||||
const node = {
|
||||
path: "/a/b/node.d.ts",
|
||||
content: ""
|
||||
};
|
||||
const host = createServerHost([f, node]);
|
||||
const cache = createMapFromTemplate<JsTyping.CachedTyping>({ node: { typingLocation: node.path, version: Semver.parse("1.3.0") } });
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(<Path>f.path), emptySafeList, cache, { enable: true }, ["fs", "bar"], emptyMap);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Inferred typings from unresolved imports: ["node","bar"]',
|
||||
'Result: {"cachedTypingPaths":[],"newTypingNames":["node","bar"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}',
|
||||
]);
|
||||
assert.deepEqual(result.cachedTypingPaths, []);
|
||||
assert.deepEqual(result.newTypingNames, ["node", "bar"]);
|
||||
});
|
||||
|
||||
it("should search only 2 levels deep", () => {
|
||||
const app = {
|
||||
path: "/app.js",
|
||||
|
||||
Reference in new issue
Block a user