Skip to content

Commit a567dac

Browse files
author
Andy Hanson
committed
Merge branch 'master' into navtree
2 parents 9385b84 + 9f73ae5 commit a567dac

26 files changed

+840
-51
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ namespace ts {
975975
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
976976

977977
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json"
978-
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true }
978+
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true }
979979
: {};
980980
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
981981
return options;

src/compiler/diagnosticMessages.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3073,13 +3073,40 @@
30733073
"category": "Error",
30743074
"code": 17010
30753075
},
3076-
30773076
"Circularity detected while resolving configuration: {0}": {
30783077
"category": "Error",
30793078
"code": 18000
30803079
},
30813080
"The path in an 'extends' options must be relative or rooted.": {
30823081
"category": "Error",
30833082
"code": 18001
3083+
},
3084+
"Add missing 'super()' call.": {
3085+
"category": "Message",
3086+
"code": 90001
3087+
},
3088+
"Make 'super()' call the first statement in the constructor.": {
3089+
"category": "Message",
3090+
"code": 90002
3091+
},
3092+
"Change 'extends' to 'implements'": {
3093+
"category": "Message",
3094+
"code": 90003
3095+
},
3096+
"Remove unused identifiers": {
3097+
"category": "Message",
3098+
"code": 90004
3099+
},
3100+
"Implement interface on reference": {
3101+
"category": "Message",
3102+
"code": 90005
3103+
},
3104+
"Implement interface on class": {
3105+
"category": "Message",
3106+
"code": 90006
3107+
},
3108+
"Implement inherited abstract class": {
3109+
"category": "Message",
3110+
"code": 90007
30843111
}
30853112
}

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5352,7 +5352,7 @@ namespace ts {
53525352
parseExpected(SyntaxKind.EqualsToken);
53535353
node.type = parseType();
53545354
parseSemicolon();
5355-
return finishNode(node);
5355+
return addJSDocComment(finishNode(node));
53565356
}
53575357

53585358
// In an ambient declaration, the grammar only allows integer literals as initializers.

src/harness/fourslash.ts

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -427,7 +427,7 @@ namespace FourSlash {
427427

428428
if (exists !== negative) {
429429
this.printErrorLog(negative, this.getAllDiagnostics());
430-
throw new Error("Failure between markers: " + startMarkerName + ", " + endMarkerName);
430+
throw new Error(`Failure between markers: '${startMarkerName}', '${endMarkerName}'`);
431431
}
432432
}
433433

@@ -742,7 +742,6 @@ namespace FourSlash {
742742
}
743743
}
744744

745-
746745
public verifyCompletionListAllowsNewIdentifier(negative: boolean) {
747746
const completions = this.getCompletionListAtCaret();
748747

@@ -1611,7 +1610,7 @@ namespace FourSlash {
16111610
if (isFormattingEdit) {
16121611
const newContent = this.getFileContent(fileName);
16131612

1614-
if (newContent.replace(/\s/g, "") !== oldContent.replace(/\s/g, "")) {
1613+
if (this.removeWhitespace(newContent) !== this.removeWhitespace(oldContent)) {
16151614
this.raiseError("Formatting operation destroyed non-whitespace content");
16161615
}
16171616
}
@@ -1677,6 +1676,10 @@ namespace FourSlash {
16771676
}
16781677
}
16791678

1679+
private removeWhitespace(text: string): string {
1680+
return text.replace(/\s/g, "");
1681+
}
1682+
16801683
public goToBOF() {
16811684
this.goToPosition(0);
16821685
}
@@ -2038,6 +2041,47 @@ namespace FourSlash {
20382041
}
20392042
}
20402043

2044+
private getCodeFixes(errorCode?: number) {
2045+
const fileName = this.activeFile.fileName;
2046+
const diagnostics = this.getDiagnostics(fileName);
2047+
2048+
if (diagnostics.length === 0) {
2049+
this.raiseError("Errors expected.");
2050+
}
2051+
2052+
if (diagnostics.length > 1 && errorCode !== undefined) {
2053+
this.raiseError("When there's more than one error, you must specify the errror to fix.");
2054+
}
2055+
2056+
const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode);
2057+
2058+
return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]);
2059+
}
2060+
2061+
public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) {
2062+
const ranges = this.getRanges();
2063+
if (ranges.length == 0) {
2064+
this.raiseError("At least one range should be specified in the testfile.");
2065+
}
2066+
2067+
const actual = this.getCodeFixes(errorCode);
2068+
2069+
if (!actual || actual.length == 0) {
2070+
this.raiseError("No codefixes returned.");
2071+
}
2072+
2073+
if (actual.length > 1) {
2074+
this.raiseError("More than 1 codefix returned.");
2075+
}
2076+
2077+
this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false);
2078+
const actualText = this.rangeText(ranges[0]);
2079+
2080+
if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) {
2081+
this.raiseError(`Actual text doesn't match expected text. Actual: '${actualText}' Expected: '${expectedText}'`);
2082+
}
2083+
}
2084+
20412085
public verifyDocCommentTemplate(expected?: ts.TextInsertion) {
20422086
const name = "verifyDocCommentTemplate";
20432087
const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition);
@@ -2321,6 +2365,18 @@ namespace FourSlash {
23212365
}
23222366
}
23232367

2368+
public verifyCodeFixAvailable(negative: boolean, errorCode?: number) {
2369+
const fixes = this.getCodeFixes(errorCode);
2370+
2371+
if (negative && fixes && fixes.length > 0) {
2372+
this.raiseError(`verifyCodeFixAvailable failed - expected no fixes, actual: ${fixes.length}`);
2373+
}
2374+
2375+
if (!negative && (fixes === undefined || fixes.length === 0)) {
2376+
this.raiseError(`verifyCodeFixAvailable failed - expected code fixes, actual: 0`);
2377+
}
2378+
}
2379+
23242380
// Get the text of the entire line the caret is currently at
23252381
private getCurrentLineContent() {
23262382
const text = this.getFileContent(this.activeFile.fileName);
@@ -3108,6 +3164,10 @@ namespace FourSlashInterface {
31083164
public isValidBraceCompletionAtPosition(openingBrace: string) {
31093165
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
31103166
}
3167+
3168+
public codeFixAvailable(errorCode?: number) {
3169+
this.state.verifyCodeFixAvailable(this.negative, errorCode);
3170+
}
31113171
}
31123172

31133173
export class Verify extends VerifyNegatable {
@@ -3287,6 +3347,10 @@ namespace FourSlashInterface {
32873347
this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true);
32883348
}
32893349

3350+
public codeFixAtPosition(expectedText: string, errorCode?: number): void {
3351+
this.state.verifyCodeFixAtPosition(expectedText, errorCode);
3352+
}
3353+
32903354
public navigationBar(json: any) {
32913355
this.state.verifyNavigationBar(json);
32923356
}

src/harness/harnessLanguageService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ namespace Harness.LanguageService {
490490
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
491491
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
492492
}
493+
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] {
494+
throw new Error("Not supported on the shim.");
495+
}
493496
getEmitOutput(fileName: string): ts.EmitOutput {
494497
return unwrapJSONCallResult(this.shim.getEmitOutput(fileName));
495498
}

src/harness/unittests/convertCompilerOptionsFromJson.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ namespace ts {
405405
allowJs: true,
406406
maxNodeModuleJsDepth: 2,
407407
allowSyntheticDefaultImports: true,
408+
skipLibCheck: true,
408409
module: ModuleKind.CommonJS,
409410
target: ScriptTarget.ES5,
410411
noImplicitAny: false,
@@ -433,6 +434,7 @@ namespace ts {
433434
allowJs: false,
434435
maxNodeModuleJsDepth: 2,
435436
allowSyntheticDefaultImports: true,
437+
skipLibCheck: true,
436438
module: ModuleKind.CommonJS,
437439
target: ScriptTarget.ES5,
438440
noImplicitAny: false,
@@ -456,7 +458,8 @@ namespace ts {
456458
{
457459
allowJs: true,
458460
maxNodeModuleJsDepth: 2,
459-
allowSyntheticDefaultImports: true
461+
allowSyntheticDefaultImports: true,
462+
skipLibCheck: true
460463
},
461464
errors: [{
462465
file: undefined,
@@ -477,7 +480,8 @@ namespace ts {
477480
{
478481
allowJs: true,
479482
maxNodeModuleJsDepth: 2,
480-
allowSyntheticDefaultImports: true
483+
allowSyntheticDefaultImports: true,
484+
skipLibCheck: true
481485
},
482486
errors: <Diagnostic[]>[]
483487
}

0 commit comments

Comments
 (0)