Skip to content

Commit

Permalink
2016-08-20 [ci skip] Version: 1.201608200007.1+a531b87b3c668f56a41406…
Browse files Browse the repository at this point in the history
…99f89b7fcc4160dfbc
  • Loading branch information
basarat committed Aug 20, 2016
1 parent f64556a commit cbb948c
Show file tree
Hide file tree
Showing 16 changed files with 275 additions and 127 deletions.
2 changes: 1 addition & 1 deletion TypeScript
Submodule TypeScript updated 49 files
+164 −153 Jakefile.js
+14 −9 src/compiler/checker.ts
+24 −4 src/compiler/core.ts
+4 −0 src/compiler/diagnosticMessages.json
+3 −0 src/compiler/parser.ts
+29 −26 src/compiler/program.ts
+5 −0 src/compiler/utilities.ts
+9 −217 src/harness/compilerRunner.ts
+3 −9 src/harness/fourslash.ts
+248 −50 src/harness/harness.ts
+5 −5 src/harness/projectsRunner.ts
+18 −13 src/harness/rwcRunner.ts
+6 −6 src/harness/test262Runner.ts
+1 −1 src/harness/unittests/initializeTSConfig.ts
+4 −4 src/harness/unittests/moduleResolution.ts
+4 −4 src/harness/unittests/transpile.ts
+1 −1 src/services/shims.ts
+28 −0 tests/baselines/reference/castOfAwait.js
+11 −0 tests/baselines/reference/castOfAwait.symbols
+35 −0 tests/baselines/reference/castOfAwait.types
+12 −0 tests/baselines/reference/castOfYield.errors.txt
+15 −0 tests/baselines/reference/castOfYield.js
+3 −3 tests/baselines/reference/exportDefaultProperty2.js
+1 −1 tests/baselines/reference/exportDefaultProperty2.symbols
+1 −1 tests/baselines/reference/exportDefaultProperty2.types
+2 −2 tests/baselines/reference/exportEqualsProperty2.js
+1 −1 tests/baselines/reference/exportEqualsProperty2.symbols
+1 −1 tests/baselines/reference/exportEqualsProperty2.types
+27 −0 tests/baselines/reference/getterControlFlowStrictNull.errors.txt
+47 −0 tests/baselines/reference/getterControlFlowStrictNull.js
+1 −1 tests/baselines/reference/missingFunctionImplementation2.errors.txt
+1 −1 tests/baselines/reference/missingFunctionImplementation2.js
+31 −0 tests/baselines/reference/moduleResolutionNoTs.errors.txt
+33 −0 tests/baselines/reference/moduleResolutionNoTs.js
+0 −7 tests/baselines/reference/moduleResolutionWithExtensions.js
+0 −5 tests/baselines/reference/moduleResolutionWithExtensions.symbols
+0 −6 tests/baselines/reference/moduleResolutionWithExtensions.trace.json
+0 −5 tests/baselines/reference/moduleResolutionWithExtensions.types
+1 −1 tests/baselines/reference/staticInstanceResolution5.errors.txt
+1 −1 tests/baselines/reference/staticInstanceResolution5.js
+8 −0 tests/cases/compiler/castOfAwait.ts
+5 −0 tests/cases/compiler/castOfYield.ts
+1 −1 tests/cases/compiler/exportDefaultProperty2.ts
+1 −1 tests/cases/compiler/exportEqualsProperty2.ts
+20 −0 tests/cases/compiler/getterControlFlowStrictNull.ts
+1 −1 tests/cases/compiler/missingFunctionImplementation2.ts
+19 −0 tests/cases/compiler/moduleResolutionNoTs.ts
+1 −1 tests/cases/compiler/staticInstanceResolution5.ts
+0 −4 tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts
22 changes: 19 additions & 3 deletions bin/ntypescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2261,8 +2261,13 @@ declare namespace ts {
* If no such value is found, the callback is applied to each element of array and undefined is returned.
*/
function forEach<T, U>(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined;
/** Like `forEach`, but assumes existence of array and fails if no truthy value is found. */
function find<T, U>(array: T[], callback: (element: T, index: number) => U | undefined): U;
/** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */
function find<T>(array: T[], predicate: (element: T, index: number) => boolean): T | undefined;
/**
* Returns the first truthy result of `callback`, or else fails.
* This is like `forEach`, but never returns undefined.
*/
function findMap<T, U>(array: T[], callback: (element: T, index: number) => U | undefined): U;
function contains<T>(array: T[], value: T): boolean;
function indexOf<T>(array: T[], value: T): number;
function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number;
Expand Down Expand Up @@ -2457,6 +2462,8 @@ declare namespace ts {
* List of supported extensions in order of file resolution precedence.
*/
const supportedTypeScriptExtensions: string[];
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
const supportedTypescriptExtensionsForExtractExtension: string[];
const supportedJavascriptExtensions: string[];
function getSupportedExtensions(options?: CompilerOptions): string[];
function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions): boolean;
Expand All @@ -2482,7 +2489,8 @@ declare namespace ts {
*/
function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority;
function removeFileExtension(path: string): string;
function tryRemoveExtension(path: string, extension: string): string;
function tryRemoveExtension(path: string, extension: string): string | undefined;
function removeExtension(path: string, extension: string): string;
function isJsxOrTsxExtension(ext: string): boolean;
function changeExtension<T extends string | Path>(path: T, newExtension: string): T;
interface ObjectAllocator {
Expand Down Expand Up @@ -2847,6 +2855,8 @@ declare namespace ts {
function getLocalSymbolForExportDefault(symbol: Symbol): Symbol;
function hasJavaScriptFileExtension(fileName: string): boolean;
function hasTypeScriptFileExtension(fileName: string): boolean;
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
function tryExtractTypeScriptExtension(fileName: string): string | undefined;
/**
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph
* as the fallback implementation does not check for circular references by default.
Expand Down Expand Up @@ -5821,6 +5831,12 @@ declare namespace ts {
key: string;
message: string;
};
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Import_declaration_0_is_using_private_name_1: {
code: number;
category: DiagnosticCategory;
Expand Down
115 changes: 76 additions & 39 deletions bin/ntypescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,22 @@ var ts;
return undefined;
}
ts.forEach = forEach;
/** Like `forEach`, but assumes existence of array and fails if no truthy value is found. */
function find(array, callback) {
/** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */
function find(array, predicate) {
for (var i = 0, len = array.length; i < len; i++) {
var value = array[i];
if (predicate(value, i)) {
return value;
}
}
return undefined;
}
ts.find = find;
/**
* Returns the first truthy result of `callback`, or else fails.
* This is like `forEach`, but never returns undefined.
*/
function findMap(array, callback) {
for (var i = 0, len = array.length; i < len; i++) {
var result = callback(array[i], i);
if (result) {
Expand All @@ -1098,7 +1112,7 @@ var ts;
}
Debug.fail();
}
ts.find = find;
ts.findMap = findMap;
function contains(array, value) {
if (array) {
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
Expand Down Expand Up @@ -2224,6 +2238,8 @@ var ts;
* List of supported extensions in order of file resolution precedence.
*/
ts.supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"];
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
ts.supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
ts.supportedJavascriptExtensions = [".js", ".jsx"];
var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions);
function getSupportedExtensions(options) {
Expand Down Expand Up @@ -2307,9 +2323,13 @@ var ts;
}
ts.removeFileExtension = removeFileExtension;
function tryRemoveExtension(path, extension) {
return fileExtensionIs(path, extension) ? path.substring(0, path.length - extension.length) : undefined;
return fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
}
ts.tryRemoveExtension = tryRemoveExtension;
function removeExtension(path, extension) {
return path.substring(0, path.length - extension.length);
}
ts.removeExtension = removeExtension;
function isJsxOrTsxExtension(ext) {
return ext === ".jsx" || ext === ".tsx";
}
Expand Down Expand Up @@ -5378,6 +5398,11 @@ var ts;
return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
}
ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension;
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
function tryExtractTypeScriptExtension(fileName) {
return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
}
ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension;
/**
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
* representing the UTF-8 encoding of the character, and return the expanded char code list.
Expand Down Expand Up @@ -6232,6 +6257,7 @@ var ts;
Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." },
Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" },
A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." },
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
Expand Down Expand Up @@ -11173,6 +11199,7 @@ var ts;
* 6) - UnaryExpression[?yield]
* 7) ~ UnaryExpression[?yield]
* 8) ! UnaryExpression[?yield]
* 9) [+Await] await UnaryExpression[?yield]
*/
function parseSimpleUnaryExpression() {
switch (token()) {
Expand All @@ -11187,6 +11214,8 @@ var ts;
return parseTypeOfExpression();
case 103 /* VoidKeyword */:
return parseVoidExpression();
case 119 /* AwaitKeyword */:
return parseAwaitExpression();
case 25 /* LessThanToken */:
// This is modified UnaryExpression grammar in TypeScript
// UnaryExpression (modified):
Expand Down Expand Up @@ -17358,7 +17387,7 @@ var ts;
}
}
function getDeclarationOfAliasSymbol(symbol) {
return ts.find(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
return ts.findMap(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
}
function getTargetOfImportEqualsDeclaration(node) {
if (node.moduleReference.kind === 240 /* ExternalModuleReference */) {
Expand Down Expand Up @@ -17662,7 +17691,14 @@ var ts;
}
if (moduleNotFoundError) {
// report errors only if it was requested
error(moduleReferenceLiteral, moduleNotFoundError, moduleName);
var tsExtension = ts.tryExtractTypeScriptExtension(moduleName);
if (tsExtension) {
var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
error(moduleReferenceLiteral, diag, tsExtension, ts.removeExtension(moduleName, tsExtension));
}
else {
error(moduleReferenceLiteral, moduleNotFoundError, moduleName);
}
}
return undefined;
}
Expand Down Expand Up @@ -29282,12 +29318,7 @@ var ts;
checkSignatureDeclaration(node);
if (node.kind === 149 /* GetAccessor */) {
if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 32768 /* HasImplicitReturn */)) {
if (node.flags & 65536 /* HasExplicitReturn */) {
if (compilerOptions.noImplicitReturns) {
error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value);
}
}
else {
if (!(node.flags & 65536 /* HasExplicitReturn */)) {
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
}
}
Expand Down Expand Up @@ -29316,7 +29347,10 @@ var ts;
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
}
}
getTypeOfAccessors(getSymbolOfNode(node));
var returnType = getTypeOfAccessors(getSymbolOfNode(node));
if (node.kind === 149 /* GetAccessor */) {
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
}
}
if (node.parent.kind !== 171 /* ObjectLiteralExpression */) {
checkSourceElement(node.body);
Expand Down Expand Up @@ -45595,48 +45629,49 @@ var ts;
* in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations.
*/
function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) {
// First try to keep/add an extension: importing "./foo.ts" can be matched by a file "./foo.ts", and "./foo" by "./foo.d.ts"
var resolvedByAddingOrKeepingExtension = loadModuleFromFileWorker(candidate, extensions, failedLookupLocation, onlyRecordFailures, state);
if (resolvedByAddingOrKeepingExtension) {
return resolvedByAddingOrKeepingExtension;
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state);
if (resolvedByAddingExtension) {
return resolvedByAddingExtension;
}
// Then try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one, e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
if (ts.hasJavaScriptFileExtension(candidate)) {
var extensionless = ts.removeFileExtension(candidate);
if (state.traceEnabled) {
var extension = candidate.substring(extensionless.length);
trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
}
return loadModuleFromFileWorker(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state);
return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state);
}
}
function loadModuleFromFileWorker(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) {
/** Try to return an existing file that adds one of the `extensions` to `candidate`. */
function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) {
if (!onlyRecordFailures) {
// check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
var directory = ts.getDirectoryPath(candidate);
if (directory) {
onlyRecordFailures = !directoryProbablyExists(directory, state.host);
}
}
return ts.forEach(extensions, tryLoad);
function tryLoad(ext) {
if (state.skipTsx && ts.isJsxOrTsxExtension(ext)) {
return undefined;
}
var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (!onlyRecordFailures && state.host.fileExists(fileName)) {
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
}
return fileName;
return ts.forEach(extensions, function (ext) {
return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state);
});
}
/** Return the file if it exists. */
function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) {
if (!onlyRecordFailures && state.host.fileExists(fileName)) {
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
}
else {
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
}
failedLookupLocation.push(fileName);
return undefined;
return fileName;
}
else {
if (state.traceEnabled) {
trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
}
failedLookupLocation.push(fileName);
return undefined;
}
}
function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) {
Expand All @@ -45648,7 +45683,9 @@ var ts;
}
var typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
if (typesFile) {
var result = loadModuleFromFile(typesFile, extensions, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host), state);
var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host);
// The package.json "typings" property must specify the file with extension, so just try that exact filename.
var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state);
if (result) {
return result;
}
Expand Down Expand Up @@ -62056,7 +62093,7 @@ var TypeScript;
// 'toolsVersion' gets consumed by the managed side, so it's not unused.
// TODO: it should be moved into a namespace though.
/* @internal */
var toolsVersion = "1.9";
var toolsVersion = "2.1";
/* tslint:enable:no-unused-variable */
/**
* Sample: add a new utility function
Expand Down
Loading

0 comments on commit cbb948c

Please sign in to comment.