Skip to content

Commit facbe84

Browse files
committed
Merge branch 'master' into APISamples
Conflicts: tests/baselines/reference/APISample_compile.js tests/baselines/reference/APISample_compile.types tests/baselines/reference/APISample_linter.js tests/baselines/reference/APISample_linter.types tests/baselines/reference/APISample_linter.types.pull tests/baselines/reference/APISample_transform.js tests/baselines/reference/APISample_transform.types tests/baselines/reference/APISample_watcher.js tests/baselines/reference/APISample_watcher.types
2 parents 86f4040 + 65cbd91 commit facbe84

34 files changed

+7194
-86
lines changed

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,22 @@ module ts {
506506
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
507507
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
508508
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
509+
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
510+
export_can_only_be_used_in_a_ts_file: { code: 8003, category: DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." },
511+
type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." },
512+
implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." },
513+
interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." },
514+
module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." },
515+
type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." },
516+
_0_can_only_be_used_in_a_ts_file: { code: 8009, category: DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." },
517+
types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." },
518+
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." },
519+
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." },
520+
can_only_be_used_in_a_ts_file: { code: 8013, category: DiagnosticCategory.Error, key: "'?' can only be used in a .ts file." },
521+
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." },
522+
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
523+
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
524+
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
509525
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
510526
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
511527
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },

src/compiler/diagnosticMessages.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,71 @@
20172017
"category": "Error",
20182018
"code": 8001
20192019
},
2020+
"'import ... =' can only be used in a .ts file.": {
2021+
"category": "Error",
2022+
"code": 8002
2023+
},
2024+
"'export=' can only be used in a .ts file.": {
2025+
"category": "Error",
2026+
"code": 8003
2027+
},
2028+
"'type parameter declarations' can only be used in a .ts file.": {
2029+
"category": "Error",
2030+
"code": 8004
2031+
},
2032+
"'implements clauses' can only be used in a .ts file.": {
2033+
"category": "Error",
2034+
"code": 8005
2035+
},
2036+
"'interface declarations' can only be used in a .ts file.": {
2037+
"category": "Error",
2038+
"code": 8006
2039+
},
2040+
"'module declarations' can only be used in a .ts file.": {
2041+
"category": "Error",
2042+
"code": 8007
2043+
},
2044+
"'type aliases' can only be used in a .ts file.": {
2045+
"category": "Error",
2046+
"code": 8008
2047+
},
2048+
"'{0}' can only be used in a .ts file.": {
2049+
"category": "Error",
2050+
"code": 8009
2051+
},
2052+
"'types' can only be used in a .ts file.": {
2053+
"category": "Error",
2054+
"code": 8010
2055+
},
2056+
"'type arguments' can only be used in a .ts file.": {
2057+
"category": "Error",
2058+
"code": 8011
2059+
},
2060+
"'parameter modifiers' can only be used in a .ts file.": {
2061+
"category": "Error",
2062+
"code": 8012
2063+
},
2064+
"'?' can only be used in a .ts file.": {
2065+
"category": "Error",
2066+
"code": 8013
2067+
},
2068+
"'property declarations' can only be used in a .ts file.": {
2069+
"category": "Error",
2070+
"code": 8014
2071+
},
2072+
"'enum declarations' can only be used in a .ts file.": {
2073+
"category": "Error",
2074+
"code": 8015
2075+
},
2076+
"'type assertion expressions' can only be used in a .ts file.": {
2077+
"category": "Error",
2078+
"code": 8016
2079+
},
2080+
"'decorators' can only be used in a .ts file.": {
2081+
"category": "Error",
2082+
"code": 8017
2083+
},
2084+
20202085
"'yield' expressions are not currently supported.": {
20212086
"category": "Error",
20222087
"code": 9000

src/compiler/parser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ module ts {
828828
// to reuse are already at the appropriate position in the new text. That way when we
829829
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
830830
// it very easy to determine if we can reuse a node. If the node's position is at where
831-
// we are in the text, then we can reuse it. Otherwise we can't. If hte node's position
831+
// we are in the text, then we can reuse it. Otherwise we can't. If the node's position
832832
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
833833
// us, then we'll need to skip it or crumble it as appropriate
834834
//
@@ -1033,7 +1033,7 @@ module ts {
10331033
// that some tokens that would be considered identifiers may be considered keywords.
10341034
//
10351035
// When adding more parser context flags, consider which is the more common case that the
1036-
// flag will be in. This should be hte 'false' state for that flag. The reason for this is
1036+
// flag will be in. This should be the 'false' state for that flag. The reason for this is
10371037
// that we don't store data in our nodes unless the value is in the *non-default* state. So,
10381038
// for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for
10391039
// 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost
@@ -1044,7 +1044,7 @@ module ts {
10441044
//
10451045
// An important thing about these context concepts. By default they are effectively inherited
10461046
// while parsing through every grammar production. i.e. if you don't change them, then when
1047-
// you parse a sub-production, it will have the same context values as hte parent production.
1047+
// you parse a sub-production, it will have the same context values as the parent production.
10481048
// This is great most of the time. After all, consider all the 'expression' grammar productions
10491049
// and how nearly all of them pass along the 'in' and 'yield' context values:
10501050
//
@@ -1836,7 +1836,7 @@ module ts {
18361836
// some node, then we cannot get a node from the old source tree. This is because we
18371837
// want to mark the next node we encounter as being unusable.
18381838
//
1839-
// Note: This may be too conservative. Perhaps we could reuse hte node and set the bit
1839+
// Note: This may be too conservative. Perhaps we could reuse the node and set the bit
18401840
// on it (or its leftmost child) as having the error. For now though, being conservative
18411841
// is nice and likely won't ever affect perf.
18421842
if (parseErrorBeforeNextFinishedNode) {

src/harness/fourslash.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515

1616
/// <reference path='..\services\services.ts' />
17+
/// <reference path='..\services\shims.ts' />
1718
/// <reference path='harnessLanguageService.ts' />
1819
/// <reference path='harness.ts' />
1920
/// <reference path='fourslashRunner.ts' />
@@ -115,7 +116,7 @@ module FourSlash {
115116
// Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions
116117
// To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
117118
// Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
118-
var testOptMetadataNames = {
119+
var metadataOptionNames = {
119120
baselineFile: 'BaselineFile',
120121
declaration: 'declaration',
121122
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
@@ -126,28 +127,32 @@ module FourSlash {
126127
outDir: 'outDir',
127128
sourceMap: 'sourceMap',
128129
sourceRoot: 'sourceRoot',
130+
allowNonTsExtensions: 'allowNonTsExtensions',
129131
resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
130132
};
131133

132134
// List of allowed metadata names
133-
var fileMetadataNames = [testOptMetadataNames.fileName, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
134-
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
135-
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
136-
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
135+
var fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
136+
var globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration,
137+
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,
138+
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]
137139

138140
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
139141
var settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
140142
// Convert all property in globalOptions into ts.CompilationSettings
141143
for (var prop in globalOptions) {
142144
if (globalOptions.hasOwnProperty(prop)) {
143145
switch (prop) {
144-
case testOptMetadataNames.declaration:
146+
case metadataOptionNames.allowNonTsExtensions:
147+
settings.allowNonTsExtensions = true;
148+
break;
149+
case metadataOptionNames.declaration:
145150
settings.declaration = true;
146151
break;
147-
case testOptMetadataNames.mapRoot:
152+
case metadataOptionNames.mapRoot:
148153
settings.mapRoot = globalOptions[prop];
149154
break;
150-
case testOptMetadataNames.module:
155+
case metadataOptionNames.module:
151156
// create appropriate external module target for CompilationSettings
152157
switch (globalOptions[prop]) {
153158
case "AMD":
@@ -162,16 +167,16 @@ module FourSlash {
162167
break;
163168
}
164169
break;
165-
case testOptMetadataNames.out:
170+
case metadataOptionNames.out:
166171
settings.out = globalOptions[prop];
167172
break;
168-
case testOptMetadataNames.outDir:
173+
case metadataOptionNames.outDir:
169174
settings.outDir = globalOptions[prop];
170175
break;
171-
case testOptMetadataNames.sourceMap:
176+
case metadataOptionNames.sourceMap:
172177
settings.sourceMap = true;
173178
break;
174-
case testOptMetadataNames.sourceRoot:
179+
case metadataOptionNames.sourceRoot:
175180
settings.sourceRoot = globalOptions[prop];
176181
break;
177182
}
@@ -303,7 +308,7 @@ module FourSlash {
303308
ts.forEach(testData.files, file => {
304309
// Create map between fileName and its content for easily looking up when resolveReference flag is specified
305310
this.inputFiles[file.fileName] = file.content;
306-
if (!startResolveFileRef && file.fileOptions[testOptMetadataNames.resolveReference]) {
311+
if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference]) {
307312
startResolveFileRef = file;
308313
} else if (startResolveFileRef) {
309314
// If entry point for resolving file references is already specified, report duplication error
@@ -793,6 +798,13 @@ module FourSlash {
793798
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
794799
}
795800

801+
public getSemanticDiagnostics(expected: string) {
802+
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
803+
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
804+
var actual = JSON.stringify(realized, null, " ");
805+
assert.equal(actual, expected);
806+
}
807+
796808
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
797809
[expectedText, expectedDocumentation].forEach(str => {
798810
if (str) {
@@ -1131,7 +1143,7 @@ module FourSlash {
11311143

11321144
Harness.Baseline.runBaseline(
11331145
"Breakpoint Locations for " + this.activeFile.fileName,
1134-
this.testData.globalOptions[testOptMetadataNames.baselineFile],
1146+
this.testData.globalOptions[metadataOptionNames.baselineFile],
11351147
() => {
11361148
return this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos));
11371149
},
@@ -1146,7 +1158,7 @@ module FourSlash {
11461158
var allFourSlashFiles = this.testData.files;
11471159
for (var idx = 0; idx < allFourSlashFiles.length; ++idx) {
11481160
var file = allFourSlashFiles[idx];
1149-
if (file.fileOptions[testOptMetadataNames.emitThisFile]) {
1161+
if (file.fileOptions[metadataOptionNames.emitThisFile]) {
11501162
// Find a file with the flag emitThisFile turned on
11511163
emitFiles.push(file);
11521164
}
@@ -1159,7 +1171,7 @@ module FourSlash {
11591171

11601172
Harness.Baseline.runBaseline(
11611173
"Generate getEmitOutput baseline : " + emitFiles.join(" "),
1162-
this.testData.globalOptions[testOptMetadataNames.baselineFile],
1174+
this.testData.globalOptions[metadataOptionNames.baselineFile],
11631175
() => {
11641176
var resultString = "";
11651177
// Loop through all the emittedFiles and emit them one by one
@@ -1704,7 +1716,7 @@ module FourSlash {
17041716

17051717
Harness.Baseline.runBaseline(
17061718
"Name OrDottedNameSpans for " + this.activeFile.fileName,
1707-
this.testData.globalOptions[testOptMetadataNames.baselineFile],
1719+
this.testData.globalOptions[metadataOptionNames.baselineFile],
17081720
() => {
17091721
return this.baselineCurrentFileLocations(pos =>
17101722
this.getNameOrDottedNameSpan(pos));
@@ -2280,7 +2292,7 @@ module FourSlash {
22802292
if (globalMetadataNamesIndex === -1) {
22812293
if (fileMetadataNamesIndex === -1) {
22822294
throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', '));
2283-
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.fileName)) {
2295+
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) {
22842296
// Found an @FileName directive, if this is not the first then create a new subfile
22852297
if (currentFileContent) {
22862298
var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);

src/server/protocol.d.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,29 @@ declare module ts.server.protocol {
617617
* Optional modifiers for the kind (such as 'public').
618618
*/
619619
kindModifiers: string;
620+
/**
621+
* A string that is used for comparing completion items so that they can be ordered. This
622+
* is often the same as the name but may be different in certain circumstances.
623+
*/
624+
sortText: string;
620625
}
621626

622627
/**
623628
* Additional completion entry details, available on demand
624629
*/
625-
export interface CompletionEntryDetails extends CompletionEntry {
630+
export interface CompletionEntryDetails {
631+
/**
632+
* The symbol's name.
633+
*/
634+
name: string;
635+
/**
636+
* The symbol's kind (such as 'className' or 'parameterName').
637+
*/
638+
kind: string;
639+
/**
640+
* Optional modifiers for the kind (such as 'public').
641+
*/
642+
kindModifiers: string;
626643
/**
627644
* Display parts of the symbol (similar to quick info).
628645
*/

src/services/navigateTo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module ts.NavigateTo {
2222
continue;
2323
}
2424

25-
// It was a match! If the pattern has dots in it, then also see if hte
25+
// It was a match! If the pattern has dots in it, then also see if the
2626
// declaration container matches as well.
2727
if (patternMatcher.patternContainsDots) {
2828
let containers = getContainers(declaration);

src/services/patternMatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ module ts {
471471

472472
// Helper function to compare two matches to determine which is better. Matches are first
473473
// ordered by kind (so all prefix matches always beat all substring matches). Then, if the
474-
// match is a camel case match, the relative weights of hte match are used to determine
474+
// match is a camel case match, the relative weights of the match are used to determine
475475
// which is better (with a greater weight being better). Then if the match is of the same
476476
// type, then a case sensitive match is considered better than an insensitive one.
477477
function patternMatchCompareTo(match1: PatternMatch, match2: PatternMatch): number {

0 commit comments

Comments
 (0)