Merge remote-tracking branch 'origin/master' into explicitly_included_globs

This commit is contained in:
Richard Knoll 2016-07-22 12:04:50 -07:00
commit bd48e55878
136 changed files with 2787 additions and 820 deletions

View File

@ -6,3 +6,10 @@ node_js:
- '0.10'
sudo: false
os:
- linux
- osx
matrix:
fast_finish: true

View File

@ -694,6 +694,12 @@ gulp.task(nodeServerOutFile, false, [servicesFile], () => {
.pipe(gulp.dest(path.dirname(nodeServerOutFile)));
});
import convertMap = require("convert-source-map");
import sorcery = require("sorcery");
declare module "convert-source-map" {
export function fromSource(source: string, largeSource?: boolean): SourceMapConverter;
}
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
return testProject.src()
@ -701,14 +707,37 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
.pipe(sourcemaps.init())
.pipe(tsc(testProject))
.pipe(through2.obj((file, enc, next) => {
browserify(intoStream(file.contents))
const originalMap = file.sourceMap;
const prebundledContent = file.contents.toString();
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
originalMap.file = "built/local/_stream_0.js";
browserify(intoStream(file.contents), { debug: true })
.bundle((err, res) => {
// assumes file.contents is a Buffer
file.contents = res;
const maps = JSON.parse(convertMap.fromSource(res.toString(), /*largeSource*/true).toJSON());
delete maps.sourceRoot;
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
file.contents = new Buffer(convertMap.removeComments(res.toString()));
const chain = sorcery.loadSync("built/local/bundle.js", {
content: {
"built/local/_stream_0.js": prebundledContent,
"built/local/bundle.js": file.contents.toString()
},
sourcemaps: {
"built/local/_stream_0.js": originalMap,
"built/local/bundle.js": maps,
}
});
const finalMap = chain.apply();
file.sourceMap = finalMap;
next(undefined, file);
});
}))
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
.pipe(sourcemaps.write(".", { includeContent: false }))
.pipe(gulp.dest("."));
});

View File

@ -34,6 +34,7 @@ if (process.env.path !== undefined) {
var compilerSources = [
"core.ts",
"performance.ts",
"sys.ts",
"types.ts",
"scanner.ts",
@ -54,6 +55,7 @@ var compilerSources = [
var servicesSources = [
"core.ts",
"performance.ts",
"sys.ts",
"types.ts",
"scanner.ts",
@ -466,15 +468,6 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r
exec(cmd);
});
var scriptsTsdJson = path.join(scriptsDirectory, "tsd.json");
file(scriptsTsdJson);
task("tsd-scripts", [scriptsTsdJson], function () {
var cmd = "tsd --config " + scriptsTsdJson + " install";
console.log(cmd);
exec(cmd);
}, { async: true });
var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests");
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts");

View File

@ -825,10 +825,17 @@ var ts;
return true;
}
ts.containsPath = containsPath;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
function fileExtensionIs(path, extension) {
var pathLen = path.length;
var extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
return path.length > extension.length && endsWith(path, extension);
}
ts.fileExtensionIs = fileExtensionIs;
function fileExtensionIsAny(path, extensions) {
@ -1093,6 +1100,8 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function () { return Node; },
getTokenConstructor: function () { return Node; },
getIdentifierConstructor: function () { return Node; },
getSourceFileConstructor: function () { return Node; },
getSymbolConstructor: function () { return Symbol; },
getTypeConstructor: function () { return Type; },
@ -1224,7 +1233,7 @@ var ts;
function readDirectory(path, extensions, excludes, includes) {
return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
}
return {
var wscriptSystem = {
args: args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
@ -1243,7 +1252,7 @@ var ts;
return fso.FolderExists(path);
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!wscriptSystem.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
@ -1263,6 +1272,7 @@ var ts;
}
}
};
return wscriptSystem;
}
function getNodeSystem() {
var _fs = require("fs");
@ -1435,7 +1445,7 @@ var ts;
function getDirectories(path) {
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1); });
}
return {
var nodeSystem = {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@ -1485,7 +1495,7 @@ var ts;
fileExists: fileExists,
directoryExists: directoryExists,
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!nodeSystem.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
@ -1533,6 +1543,7 @@ var ts;
return _fs.realpathSync(path);
}
};
return nodeSystem;
}
function getChakraSystem() {
var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); });
@ -2282,8 +2293,8 @@ var ts;
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" },
_0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." },
Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." },
Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." },
Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." },
Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." },
The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" },
No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
@ -4836,7 +4847,7 @@ var ts;
}
ts.isExpression = isExpression;
function isExternalModuleNameRelative(moduleName) {
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
return /^\.\.?($|[\\/])/.test(moduleName);
}
ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
function isInstantiatedModule(node, preserveConstEnums) {
@ -6344,25 +6355,24 @@ var ts;
return node.flags & 92 && node.parent.kind === 148 && ts.isClassLike(node.parent.parent);
}
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
})(ts || (ts = {}));
var ts;
(function (ts) {
ts.parseTime = 0;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
function createNode(kind, pos, end) {
if (kind === 256) {
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else if (kind === 69) {
return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
}
else if (kind < 139) {
return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
}
@ -6785,6 +6795,8 @@ var ts;
var scanner = ts.createScanner(2, true);
var disallowInAndDecoratorContext = 4194304 | 16777216;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
var sourceFile;
var parseDiagnostics;
@ -6810,6 +6822,8 @@ var ts;
}
function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) {
NodeConstructor = ts.objectAllocator.getNodeConstructor();
TokenConstructor = ts.objectAllocator.getTokenConstructor();
IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
sourceText = _sourceText;
syntaxCursor = _syntaxCursor;
@ -7116,7 +7130,9 @@ var ts;
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
return new NodeConstructor(kind, pos, pos);
return kind >= 139 ? new NodeConstructor(kind, pos, pos) :
kind === 69 ? new IdentifierConstructor(kind, pos, pos) :
new TokenConstructor(kind, pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -10892,6 +10908,9 @@ var ts;
case 55:
if (canParseTag) {
parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral);
if (!parentTagTerminated) {
resumePos = scanner.getStartPos();
}
}
seenAsterisk = false;
break;
@ -15418,17 +15437,18 @@ var ts;
if (declaration.kind === 235) {
return links.type = checkExpression(declaration.expression);
}
if (declaration.flags & 134217728 && declaration.kind === 280 && declaration.typeExpression) {
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
}
if (!pushTypeResolution(symbol, 0)) {
return unknownType;
}
var type = undefined;
if (declaration.kind === 187) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); }));
}
else if (declaration.kind === 172) {
if (declaration.parent.kind === 187) {
type = checkExpressionCached(declaration.parent.right);
}
if (declaration.kind === 187 ||
declaration.kind === 172 && declaration.parent.kind === 187) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ?
checkExpressionCached(decl.right) :
checkExpressionCached(decl.parent.right); }));
}
if (type === undefined) {
type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
@ -21935,7 +21955,7 @@ var ts;
function getInferredClassType(symbol) {
var links = getSymbolLinks(symbol);
if (!links.inferredClassType) {
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, undefined, undefined);
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, undefined, undefined);
}
return links.inferredClassType;
}
@ -23155,7 +23175,7 @@ var ts;
checkAsyncFunctionReturnType(node);
}
}
if (!node.body) {
if (noUnusedIdentifiers && !node.body) {
checkUnusedTypeParameters(node);
}
}
@ -24051,6 +24071,7 @@ var ts;
var parameter = local_1.valueDeclaration;
if (compilerOptions.noUnusedParameters &&
!ts.isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(parameter)) {
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
}
@ -24066,6 +24087,9 @@ var ts;
}
}
}
function parameterIsThisKeyword(parameter) {
return parameter.name && parameter.name.originalKeywordKind === 97;
}
function parameterNameStartsWithUnderscore(parameter) {
return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95;
}
@ -24094,9 +24118,14 @@ var ts;
function checkUnusedTypeParameters(node) {
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
if (node.typeParameters) {
var symbol = getSymbolOfNode(node);
var lastDeclaration = symbol && symbol.declarations && ts.lastOrUndefined(symbol.declarations);
if (lastDeclaration !== node) {
return;
}
for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
var typeParameter = _a[_i];
if (!typeParameter.symbol.isReferenced) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
@ -25173,7 +25202,7 @@ var ts;
ts.forEach(node.members, checkSourceElement);
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
checkUnusedTypeParameters(node);
registerForUnusedIdentifiersCheck(node);
}
}
function checkTypeAliasDeclaration(node) {
@ -29896,7 +29925,7 @@ var ts;
writeLine();
var sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
write("//# sourceMappingURL=" + sourceMappingURL);
write("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
}
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, compilerOptions.emitBOM, sourceFiles);
sourceMap.reset();
@ -33546,13 +33575,13 @@ var ts;
if (isES6ExportedDeclaration(node) && !(node.flags & 512) && decoratedClassAlias === undefined) {
write("export ");
}
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
if (decoratedClassAlias !== undefined) {
write("" + decoratedClassAlias);
write("let " + decoratedClassAlias);
}
else {
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
emitDeclarationName(node);
}
write(" = ");
@ -35796,7 +35825,7 @@ var ts;
ts.emitTime = 0;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "2.0.0";
ts.version = "2.1.0";
var emptyArray = [];
var defaultTypeRoots = ["node_modules/@types"];
function findConfigFile(searchPath, fileExists) {
@ -35876,12 +35905,7 @@ var ts;
return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations };
}
function moduleHasNonRelativeName(moduleName) {
if (ts.isRootedDiskPath(moduleName)) {
return false;
}
var i = moduleName.lastIndexOf("./", 1);
var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46);
return !startsWithDotSlashOrDotDotSlash;
return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName));
}
function tryReadTypesSection(packageJsonPath, baseDirectory, state) {
var jsonContent;
@ -36537,6 +36561,22 @@ var ts;
return ts.sortAndDeduplicateDiagnostics(diagnostics);
}
ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
function formatDiagnostics(diagnostics, host) {
var output = "";
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
var diagnostic = diagnostics_1[_i];
if (diagnostic.file) {
var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
var fileName = diagnostic.file.fileName;
var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
}
return output;
}
ts.formatDiagnostics = formatDiagnostics;
function flattenDiagnosticMessageText(messageText, newLine) {
if (typeof messageText === "string") {
return messageText;
@ -36612,7 +36652,7 @@ var ts;
var resolvedTypeReferenceDirectives = {};
var fileProcessingDiagnostics = ts.createDiagnosticCollection();
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
var currentNodeModulesJsDepth = 0;
var currentNodeModulesDepth = 0;
var modulesWithElidedImports = {};
var sourceFilesFoundSearchingNodeModules = {};
var start = new Date().getTime();
@ -36836,8 +36876,7 @@ var ts;
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
}
function emit(sourceFile, writeFileCallback, cancellationToken) {
var _this = this;
return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); });
return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); });
}
function isEmitBlocked(emitFileName) {
return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName));
@ -37244,8 +37283,17 @@ var ts;
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
}
if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) {
if (file_1 && ts.lookUp(sourceFilesFoundSearchingNodeModules, file_1.path) && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file_1.path] = false;
if (!options.noResolve) {
processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib);
processTypeReferenceDirectives(file_1);
}
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
else if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
@ -37262,6 +37310,7 @@ var ts;
});
filesByName.set(path, file);
if (file) {
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
file.path = path;
if (host.useCaseSensitiveFileNames()) {
var existingFile = filesByNameIgnoreCase.get(path);
@ -37362,12 +37411,9 @@ var ts;
var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName);
if (isFromNodeModulesSearch) {
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
currentNodeModulesDepth++;
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth++;
}
var elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth;
var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;
if (elideImport) {
modulesWithElidedImports[file.path] = true;
@ -37375,8 +37421,8 @@ var ts;
else if (shouldAddFile) {
findSourceFile(resolution.resolvedFileName, resolvedPath, false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth--;
if (isFromNodeModulesSearch) {
currentNodeModulesDepth--;
}
}
}
@ -37695,12 +37741,12 @@ var ts;
{
name: "noUnusedLocals",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Locals
description: ts.Diagnostics.Report_errors_on_unused_locals
},
{
name: "noUnusedParameters",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Parameters
description: ts.Diagnostics.Report_errors_on_unused_parameters
},
{
name: "noLib",
@ -38479,10 +38525,18 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
var reportDiagnostic = reportDiagnosticSimply;
var defaultFormatDiagnosticsHost = {
getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
getNewLine: function () { return ts.sys.newLine; },
getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
};
var reportDiagnosticWorker = reportDiagnosticSimply;
function reportDiagnostic(diagnostic, host) {
reportDiagnosticWorker(diagnostic, host || defaultFormatDiagnosticsHost);
}
function reportDiagnostics(diagnostics, host) {
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
var diagnostic = diagnostics_1[_i];
for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) {
var diagnostic = diagnostics_2[_i];
reportDiagnostic(diagnostic, host);
}
}
@ -38553,19 +38607,8 @@ var ts;
var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
return diagnostic.messageText;
}
function getRelativeFileName(fileName, host) {
return host ? ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : fileName;
}
function reportDiagnosticSimply(diagnostic, host) {
var output = "";
if (diagnostic.file) {
var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
var relativeFileName = getRelativeFileName(diagnostic.file.fileName, host);
output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine;
ts.sys.write(output);
ts.sys.write(ts.formatDiagnostics([diagnostic], host));
}
var redForegroundEscapeSequence = "\u001b[91m";
var yellowForegroundEscapeSequence = "\u001b[93m";
@ -38590,7 +38633,7 @@ var ts;
var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
var _b = ts.getLineAndCharacterOfPosition(file, start + length_3), lastLine = _b.line, lastLineChar = _b.character;
var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
var relativeFileName = getRelativeFileName(file.fileName, host);
var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
var gutterWidth = (lastLine + 1 + "").length;
if (hasMoreThanFiveLines) {
@ -38779,7 +38822,8 @@ var ts;
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
return;
}
var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), ts.sys.getCurrentDirectory()), commandLine.options, configFileName);
var cwd = ts.sys.getCurrentDirectory();
var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), commandLine.options, ts.getNormalizedAbsolutePath(configFileName, cwd));
if (configParseResult.errors.length > 0) {
reportDiagnostics(configParseResult.errors, undefined);
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
@ -38816,7 +38860,7 @@ var ts;
compilerHost.fileExists = cachedFileExists;
}
if (compilerOptions.pretty) {
reportDiagnostic = reportDiagnosticWithColorAndContext;
reportDiagnosticWorker = reportDiagnosticWithColorAndContext;
}
cachedExistingFiles = {};
var compileResult = compile(rootFileNames, compilerOptions, compilerHost);
@ -38979,7 +39023,7 @@ var ts;
output += ts.sys.newLine + ts.sys.newLine;
var padding = makePadding(marginLength);
output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine;
output += padding + "tsc --out file.js file.ts" + ts.sys.newLine;
output += padding + "tsc --outFile file.js file.ts" + ts.sys.newLine;
output += padding + "tsc @args.txt" + ts.sys.newLine;
output += ts.sys.newLine;
output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine;

View File

@ -830,10 +830,17 @@ var ts;
return true;
}
ts.containsPath = containsPath;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
function fileExtensionIs(path, extension) {
var pathLen = path.length;
var extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
return path.length > extension.length && endsWith(path, extension);
}
ts.fileExtensionIs = fileExtensionIs;
function fileExtensionIsAny(path, extensions) {
@ -1098,6 +1105,8 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function () { return Node; },
getTokenConstructor: function () { return Node; },
getIdentifierConstructor: function () { return Node; },
getSourceFileConstructor: function () { return Node; },
getSymbolConstructor: function () { return Symbol; },
getTypeConstructor: function () { return Type; },
@ -1229,7 +1238,7 @@ var ts;
function readDirectory(path, extensions, excludes, includes) {
return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
}
return {
var wscriptSystem = {
args: args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
@ -1248,7 +1257,7 @@ var ts;
return fso.FolderExists(path);
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!wscriptSystem.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
@ -1268,6 +1277,7 @@ var ts;
}
}
};
return wscriptSystem;
}
function getNodeSystem() {
var _fs = require("fs");
@ -1440,7 +1450,7 @@ var ts;
function getDirectories(path) {
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1); });
}
return {
var nodeSystem = {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@ -1490,7 +1500,7 @@ var ts;
fileExists: fileExists,
directoryExists: directoryExists,
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!nodeSystem.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
@ -1538,6 +1548,7 @@ var ts;
return _fs.realpathSync(path);
}
};
return nodeSystem;
}
function getChakraSystem() {
var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); });
@ -2287,8 +2298,8 @@ var ts;
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" },
_0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." },
Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." },
Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." },
Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." },
Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." },
The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" },
No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
@ -3966,12 +3977,12 @@ var ts;
{
name: "noUnusedLocals",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Locals
description: ts.Diagnostics.Report_errors_on_unused_locals
},
{
name: "noUnusedParameters",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Parameters
description: ts.Diagnostics.Report_errors_on_unused_parameters
},
{
name: "noLib",
@ -5754,7 +5765,7 @@ var ts;
}
ts.isExpression = isExpression;
function isExternalModuleNameRelative(moduleName) {
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
return /^\.\.?($|[\\/])/.test(moduleName);
}
ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
function isInstantiatedModule(node, preserveConstEnums) {
@ -7262,25 +7273,24 @@ var ts;
return node.flags & 92 && node.parent.kind === 148 && ts.isClassLike(node.parent.parent);
}
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
})(ts || (ts = {}));
var ts;
(function (ts) {
ts.parseTime = 0;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
function createNode(kind, pos, end) {
if (kind === 256) {
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else if (kind === 69) {
return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
}
else if (kind < 139) {
return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
}
@ -7703,6 +7713,8 @@ var ts;
var scanner = ts.createScanner(2, true);
var disallowInAndDecoratorContext = 4194304 | 16777216;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
var sourceFile;
var parseDiagnostics;
@ -7728,6 +7740,8 @@ var ts;
}
function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) {
NodeConstructor = ts.objectAllocator.getNodeConstructor();
TokenConstructor = ts.objectAllocator.getTokenConstructor();
IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
sourceText = _sourceText;
syntaxCursor = _syntaxCursor;
@ -8034,7 +8048,9 @@ var ts;
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
return new NodeConstructor(kind, pos, pos);
return kind >= 139 ? new NodeConstructor(kind, pos, pos) :
kind === 69 ? new IdentifierConstructor(kind, pos, pos) :
new TokenConstructor(kind, pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -11810,6 +11826,9 @@ var ts;
case 55:
if (canParseTag) {
parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral);
if (!parentTagTerminated) {
resumePos = scanner.getStartPos();
}
}
seenAsterisk = false;
break;
@ -16336,17 +16355,18 @@ var ts;
if (declaration.kind === 235) {
return links.type = checkExpression(declaration.expression);
}
if (declaration.flags & 134217728 && declaration.kind === 280 && declaration.typeExpression) {
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
}
if (!pushTypeResolution(symbol, 0)) {
return unknownType;
}
var type = undefined;
if (declaration.kind === 187) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); }));
}
else if (declaration.kind === 172) {
if (declaration.parent.kind === 187) {
type = checkExpressionCached(declaration.parent.right);
}
if (declaration.kind === 187 ||
declaration.kind === 172 && declaration.parent.kind === 187) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ?
checkExpressionCached(decl.right) :
checkExpressionCached(decl.parent.right); }));
}
if (type === undefined) {
type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
@ -22853,7 +22873,7 @@ var ts;
function getInferredClassType(symbol) {
var links = getSymbolLinks(symbol);
if (!links.inferredClassType) {
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, undefined, undefined);
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, undefined, undefined);
}
return links.inferredClassType;
}
@ -24073,7 +24093,7 @@ var ts;
checkAsyncFunctionReturnType(node);
}
}
if (!node.body) {
if (noUnusedIdentifiers && !node.body) {
checkUnusedTypeParameters(node);
}
}
@ -24969,6 +24989,7 @@ var ts;
var parameter = local_1.valueDeclaration;
if (compilerOptions.noUnusedParameters &&
!ts.isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(parameter)) {
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
}
@ -24984,6 +25005,9 @@ var ts;
}
}
}
function parameterIsThisKeyword(parameter) {
return parameter.name && parameter.name.originalKeywordKind === 97;
}
function parameterNameStartsWithUnderscore(parameter) {
return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95;
}
@ -25012,9 +25036,14 @@ var ts;
function checkUnusedTypeParameters(node) {
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
if (node.typeParameters) {
var symbol = getSymbolOfNode(node);
var lastDeclaration = symbol && symbol.declarations && ts.lastOrUndefined(symbol.declarations);
if (lastDeclaration !== node) {
return;
}
for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
var typeParameter = _a[_i];
if (!typeParameter.symbol.isReferenced) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
@ -26091,7 +26120,7 @@ var ts;
ts.forEach(node.members, checkSourceElement);
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
checkUnusedTypeParameters(node);
registerForUnusedIdentifiersCheck(node);
}
}
function checkTypeAliasDeclaration(node) {
@ -30814,7 +30843,7 @@ var ts;
writeLine();
var sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
write("//# sourceMappingURL=" + sourceMappingURL);
write("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
}
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, compilerOptions.emitBOM, sourceFiles);
sourceMap.reset();
@ -34464,13 +34493,13 @@ var ts;
if (isES6ExportedDeclaration(node) && !(node.flags & 512) && decoratedClassAlias === undefined) {
write("export ");
}
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
if (decoratedClassAlias !== undefined) {
write("" + decoratedClassAlias);
write("let " + decoratedClassAlias);
}
else {
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
emitDeclarationName(node);
}
write(" = ");
@ -36714,7 +36743,7 @@ var ts;
ts.emitTime = 0;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "2.0.0";
ts.version = "2.1.0";
var emptyArray = [];
var defaultTypeRoots = ["node_modules/@types"];
function findConfigFile(searchPath, fileExists) {
@ -36794,12 +36823,7 @@ var ts;
return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations };
}
function moduleHasNonRelativeName(moduleName) {
if (ts.isRootedDiskPath(moduleName)) {
return false;
}
var i = moduleName.lastIndexOf("./", 1);
var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46);
return !startsWithDotSlashOrDotDotSlash;
return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName));
}
function tryReadTypesSection(packageJsonPath, baseDirectory, state) {
var jsonContent;
@ -37455,6 +37479,22 @@ var ts;
return ts.sortAndDeduplicateDiagnostics(diagnostics);
}
ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
function formatDiagnostics(diagnostics, host) {
var output = "";
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
var diagnostic = diagnostics_1[_i];
if (diagnostic.file) {
var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
var fileName = diagnostic.file.fileName;
var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
}
return output;
}
ts.formatDiagnostics = formatDiagnostics;
function flattenDiagnosticMessageText(messageText, newLine) {
if (typeof messageText === "string") {
return messageText;
@ -37530,7 +37570,7 @@ var ts;
var resolvedTypeReferenceDirectives = {};
var fileProcessingDiagnostics = ts.createDiagnosticCollection();
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
var currentNodeModulesJsDepth = 0;
var currentNodeModulesDepth = 0;
var modulesWithElidedImports = {};
var sourceFilesFoundSearchingNodeModules = {};
var start = new Date().getTime();
@ -37754,8 +37794,7 @@ var ts;
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
}
function emit(sourceFile, writeFileCallback, cancellationToken) {
var _this = this;
return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); });
return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); });
}
function isEmitBlocked(emitFileName) {
return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName));
@ -38162,8 +38201,17 @@ var ts;
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
}
if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) {
if (file_1 && ts.lookUp(sourceFilesFoundSearchingNodeModules, file_1.path) && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file_1.path] = false;
if (!options.noResolve) {
processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib);
processTypeReferenceDirectives(file_1);
}
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
else if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
@ -38180,6 +38228,7 @@ var ts;
});
filesByName.set(path, file);
if (file) {
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
file.path = path;
if (host.useCaseSensitiveFileNames()) {
var existingFile = filesByNameIgnoreCase.get(path);
@ -38280,12 +38329,9 @@ var ts;
var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName);
if (isFromNodeModulesSearch) {
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
currentNodeModulesDepth++;
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth++;
}
var elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth;
var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;
if (elideImport) {
modulesWithElidedImports[file.path] = true;
@ -38293,8 +38339,8 @@ var ts;
else if (shouldAddFile) {
findSourceFile(resolution.resolvedFileName, resolvedPath, false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth--;
if (isFromNodeModulesSearch) {
currentNodeModulesDepth--;
}
}
}
@ -39887,7 +39933,7 @@ var ts;
return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text);
}
else {
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text));
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, ts.startsWith(candidate, chunk.text));
}
}
var isLowercase = chunk.isLowerCase;
@ -40059,14 +40105,6 @@ var ts;
var str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function startsWith(string, search) {
for (var i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
}
return true;
}
function indexOfIgnoringCase(string, value) {
for (var i = 0, n = string.length - value.length; i <= n; i++) {
if (startsWithIgnoringCase(string, value, i)) {
@ -41551,6 +41589,9 @@ var ts;
}
return false;
}
function shouldRescanJsxText(node) {
return node && node.kind === 244;
}
function shouldRescanSlashToken(container) {
return container.kind === 10;
}
@ -41578,7 +41619,9 @@ var ts;
? 3
: shouldRescanJsxIdentifier(n)
? 4
: 0;
: shouldRescanJsxText(n)
? 5
: 0;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
return fixTokenKind(lastTokenInfo, n);
}
@ -41606,6 +41649,10 @@ var ts;
currentToken = scanner.scanJsxIdentifier();
lastScanAction = 4;
}
else if (expectedScanAction === 5) {
currentToken = scanner.reScanJsxToken();
lastScanAction = 5;
}
else {
lastScanAction = 0;
}
@ -43854,19 +43901,20 @@ var ts;
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new NodeObject(kind, pos, end);
node.flags = flags;
function createNode(kind, pos, end, parent) {
var node = kind >= 139 ? new NodeObject(kind, pos, end) :
kind === 69 ? new IdentifierObject(kind, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
return node;
}
var NodeObject = (function () {
function NodeObject(kind, pos, end) {
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
this.kind = kind;
}
NodeObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
@ -43901,14 +43949,14 @@ var ts;
var token = useJSDocScanner ? scanner.scanJSDocToken() : scanner.scan();
var textPos = scanner.getTextPos();
if (textPos <= end) {
nodes.push(createNode(token, pos, textPos, 0, this));
nodes.push(createNode(token, pos, textPos, this));
}
pos = textPos;
}
return pos;
};
NodeObject.prototype.createSyntaxList = function (nodes) {
var list = createNode(282, nodes.pos, nodes.end, 0, this);
var list = createNode(282, nodes.pos, nodes.end, this);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
@ -43993,6 +44041,73 @@ var ts;
};
return NodeObject;
}());
var TokenOrIdentifierObject = (function () {
function TokenOrIdentifierObject(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
}
TokenOrIdentifierObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
};
TokenOrIdentifierObject.prototype.getStart = function (sourceFile, includeJsDocComment) {
return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment);
};
TokenOrIdentifierObject.prototype.getFullStart = function () {
return this.pos;
};
TokenOrIdentifierObject.prototype.getEnd = function () {
return this.end;
};
TokenOrIdentifierObject.prototype.getWidth = function (sourceFile) {
return this.getEnd() - this.getStart(sourceFile);
};
TokenOrIdentifierObject.prototype.getFullWidth = function () {
return this.end - this.pos;
};
TokenOrIdentifierObject.prototype.getLeadingTriviaWidth = function (sourceFile) {
return this.getStart(sourceFile) - this.pos;
};
TokenOrIdentifierObject.prototype.getFullText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end);
};
TokenOrIdentifierObject.prototype.getText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
};
TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) {
return 0;
};
TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) {
return emptyArray;
};
TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) {
return undefined;
};
return TokenOrIdentifierObject;
}());
var TokenObject = (function (_super) {
__extends(TokenObject, _super);
function TokenObject(kind, pos, end) {
_super.call(this, pos, end);
this.kind = kind;
}
return TokenObject;
}(TokenOrIdentifierObject));
var IdentifierObject = (function (_super) {
__extends(IdentifierObject, _super);
function IdentifierObject(kind, pos, end) {
_super.call(this, pos, end);
}
return IdentifierObject;
}(TokenOrIdentifierObject));
IdentifierObject.prototype.kind = 69;
var SymbolObject = (function () {
function SymbolObject(flags, name) {
this.flags = flags;
@ -49673,6 +49788,8 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function () { return NodeObject; },
getTokenConstructor: function () { return TokenObject; },
getIdentifierConstructor: function () { return IdentifierObject; },
getSourceFileConstructor: function () { return SourceFileObject; },
getSymbolConstructor: function () { return SymbolObject; },
getTypeConstructor: function () { return TypeObject; },
@ -50793,7 +50910,6 @@ var ts;
if (isOpen === void 0) { isOpen = false; }
this.host = host;
this.fileName = fileName;
this.content = content;
this.isOpen = isOpen;
this.children = [];
this.formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host));
@ -52419,7 +52535,7 @@ var ts;
done: false,
leaf: function (relativeStart, relativeLength, ll) {
if (!f(ll, relativeStart, relativeLength)) {
this.done = true;
walkFns.done = true;
}
}
};
@ -53069,7 +53185,7 @@ var ts;
ioSession.listen();
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
var debugObjectHost = this;
var debugObjectHost = new Function("return this")();
var ts;
(function (ts) {
function logInternalError(logger, err) {
@ -53197,7 +53313,7 @@ var ts;
return this.shimHost.getCurrentDirectory();
};
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
return this.shimHost.getDirectories(path);
return JSON.parse(this.shimHost.getDirectories(path));
};
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

View File

@ -405,7 +405,10 @@ declare namespace ts {
interface ModifiersArray extends NodeArray<Modifier> {
flags: NodeFlags;
}
interface Modifier extends Node {
interface Token extends Node {
__tokenTag: any;
}
interface Modifier extends Token {
}
interface Identifier extends PrimaryExpression {
text: string;
@ -2050,7 +2053,6 @@ declare namespace ts {
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
getDefaultLibLocation?(): string;
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
@ -2156,6 +2158,8 @@ declare namespace ts {
function ensureTrailingDirectorySeparator(path: string): string;
function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison;
function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean;
function startsWith(str: string, prefix: string): boolean;
function endsWith(str: string, suffix: string): boolean;
function fileExtensionIs(path: string, extension: string): boolean;
function fileExtensionIsAny(path: string, extensions: string[]): boolean;
function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string;
@ -2193,6 +2197,8 @@ declare namespace ts {
function changeExtension<T extends string | Path>(path: T, newExtension: string): T;
interface ObjectAllocator {
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
getTokenConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
getIdentifierConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
@ -6456,13 +6462,13 @@ declare namespace ts {
key: string;
message: string;
};
Report_Errors_on_Unused_Locals: {
Report_errors_on_unused_locals: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Report_Errors_on_Unused_Parameters: {
Report_errors_on_unused_parameters: {
code: number;
category: DiagnosticCategory;
key: string;
@ -7143,8 +7149,6 @@ declare namespace ts {
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean;
function startsWith(str: string, prefix: string): boolean;
function endsWith(str: string, suffix: string): boolean;
}
declare namespace ts {
let parseTime: number;
@ -7225,6 +7229,12 @@ declare namespace ts {
const defaultInitCompilerOptions: CompilerOptions;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
interface FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
}
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
@ -8388,7 +8398,6 @@ declare namespace ts.server {
class ScriptInfo {
private host;
fileName: string;
content: string;
isOpen: boolean;
svc: ScriptVersionCache;
children: ScriptInfo[];
@ -8729,7 +8738,7 @@ declare namespace ts {
getLocalizedDiagnosticMessages(): string;
getCancellationToken(): HostCancellationToken;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getDirectories(path: string): string;
getDefaultLibFileName(options: string): string;
getNewLine?(): string;
getProjectVersion?(): string;

View File

@ -830,10 +830,17 @@ var ts;
return true;
}
ts.containsPath = containsPath;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
function fileExtensionIs(path, extension) {
var pathLen = path.length;
var extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
return path.length > extension.length && endsWith(path, extension);
}
ts.fileExtensionIs = fileExtensionIs;
function fileExtensionIsAny(path, extensions) {
@ -1098,6 +1105,8 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function () { return Node; },
getTokenConstructor: function () { return Node; },
getIdentifierConstructor: function () { return Node; },
getSourceFileConstructor: function () { return Node; },
getSymbolConstructor: function () { return Symbol; },
getTypeConstructor: function () { return Type; },
@ -1229,7 +1238,7 @@ var ts;
function readDirectory(path, extensions, excludes, includes) {
return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
}
return {
var wscriptSystem = {
args: args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
@ -1248,7 +1257,7 @@ var ts;
return fso.FolderExists(path);
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!wscriptSystem.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
@ -1268,6 +1277,7 @@ var ts;
}
}
};
return wscriptSystem;
}
function getNodeSystem() {
var _fs = require("fs");
@ -1440,7 +1450,7 @@ var ts;
function getDirectories(path) {
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1); });
}
return {
var nodeSystem = {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@ -1490,7 +1500,7 @@ var ts;
fileExists: fileExists,
directoryExists: directoryExists,
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!nodeSystem.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
@ -1538,6 +1548,7 @@ var ts;
return _fs.realpathSync(path);
}
};
return nodeSystem;
}
function getChakraSystem() {
var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); });
@ -2287,8 +2298,8 @@ var ts;
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" },
_0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." },
Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." },
Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." },
Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." },
Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." },
The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" },
No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
@ -3966,12 +3977,12 @@ var ts;
{
name: "noUnusedLocals",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Locals
description: ts.Diagnostics.Report_errors_on_unused_locals
},
{
name: "noUnusedParameters",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Parameters
description: ts.Diagnostics.Report_errors_on_unused_parameters
},
{
name: "noLib",
@ -5754,7 +5765,7 @@ var ts;
}
ts.isExpression = isExpression;
function isExternalModuleNameRelative(moduleName) {
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
return /^\.\.?($|[\\/])/.test(moduleName);
}
ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
function isInstantiatedModule(node, preserveConstEnums) {
@ -7262,25 +7273,24 @@ var ts;
return node.flags & 92 && node.parent.kind === 148 && ts.isClassLike(node.parent.parent);
}
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
})(ts || (ts = {}));
var ts;
(function (ts) {
ts.parseTime = 0;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
function createNode(kind, pos, end) {
if (kind === 256) {
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else if (kind === 69) {
return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
}
else if (kind < 139) {
return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
}
@ -7703,6 +7713,8 @@ var ts;
var scanner = ts.createScanner(2, true);
var disallowInAndDecoratorContext = 4194304 | 16777216;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
var sourceFile;
var parseDiagnostics;
@ -7728,6 +7740,8 @@ var ts;
}
function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) {
NodeConstructor = ts.objectAllocator.getNodeConstructor();
TokenConstructor = ts.objectAllocator.getTokenConstructor();
IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
sourceText = _sourceText;
syntaxCursor = _syntaxCursor;
@ -8034,7 +8048,9 @@ var ts;
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
return new NodeConstructor(kind, pos, pos);
return kind >= 139 ? new NodeConstructor(kind, pos, pos) :
kind === 69 ? new IdentifierConstructor(kind, pos, pos) :
new TokenConstructor(kind, pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -11810,6 +11826,9 @@ var ts;
case 55:
if (canParseTag) {
parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral);
if (!parentTagTerminated) {
resumePos = scanner.getStartPos();
}
}
seenAsterisk = false;
break;
@ -16336,17 +16355,18 @@ var ts;
if (declaration.kind === 235) {
return links.type = checkExpression(declaration.expression);
}
if (declaration.flags & 134217728 && declaration.kind === 280 && declaration.typeExpression) {
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
}
if (!pushTypeResolution(symbol, 0)) {
return unknownType;
}
var type = undefined;
if (declaration.kind === 187) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); }));
}
else if (declaration.kind === 172) {
if (declaration.parent.kind === 187) {
type = checkExpressionCached(declaration.parent.right);
}
if (declaration.kind === 187 ||
declaration.kind === 172 && declaration.parent.kind === 187) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ?
checkExpressionCached(decl.right) :
checkExpressionCached(decl.parent.right); }));
}
if (type === undefined) {
type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
@ -22853,7 +22873,7 @@ var ts;
function getInferredClassType(symbol) {
var links = getSymbolLinks(symbol);
if (!links.inferredClassType) {
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, undefined, undefined);
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, undefined, undefined);
}
return links.inferredClassType;
}
@ -24073,7 +24093,7 @@ var ts;
checkAsyncFunctionReturnType(node);
}
}
if (!node.body) {
if (noUnusedIdentifiers && !node.body) {
checkUnusedTypeParameters(node);
}
}
@ -24969,6 +24989,7 @@ var ts;
var parameter = local_1.valueDeclaration;
if (compilerOptions.noUnusedParameters &&
!ts.isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(parameter)) {
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
}
@ -24984,6 +25005,9 @@ var ts;
}
}
}
function parameterIsThisKeyword(parameter) {
return parameter.name && parameter.name.originalKeywordKind === 97;
}
function parameterNameStartsWithUnderscore(parameter) {
return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95;
}
@ -25012,9 +25036,14 @@ var ts;
function checkUnusedTypeParameters(node) {
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
if (node.typeParameters) {
var symbol = getSymbolOfNode(node);
var lastDeclaration = symbol && symbol.declarations && ts.lastOrUndefined(symbol.declarations);
if (lastDeclaration !== node) {
return;
}
for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
var typeParameter = _a[_i];
if (!typeParameter.symbol.isReferenced) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
@ -26091,7 +26120,7 @@ var ts;
ts.forEach(node.members, checkSourceElement);
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
checkUnusedTypeParameters(node);
registerForUnusedIdentifiersCheck(node);
}
}
function checkTypeAliasDeclaration(node) {
@ -30814,7 +30843,7 @@ var ts;
writeLine();
var sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
write("//# sourceMappingURL=" + sourceMappingURL);
write("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
}
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, compilerOptions.emitBOM, sourceFiles);
sourceMap.reset();
@ -34464,13 +34493,13 @@ var ts;
if (isES6ExportedDeclaration(node) && !(node.flags & 512) && decoratedClassAlias === undefined) {
write("export ");
}
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
if (decoratedClassAlias !== undefined) {
write("" + decoratedClassAlias);
write("let " + decoratedClassAlias);
}
else {
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
emitDeclarationName(node);
}
write(" = ");
@ -36714,7 +36743,7 @@ var ts;
ts.emitTime = 0;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
ts.version = "2.0.0";
ts.version = "2.1.0";
var emptyArray = [];
var defaultTypeRoots = ["node_modules/@types"];
function findConfigFile(searchPath, fileExists) {
@ -36794,12 +36823,7 @@ var ts;
return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations };
}
function moduleHasNonRelativeName(moduleName) {
if (ts.isRootedDiskPath(moduleName)) {
return false;
}
var i = moduleName.lastIndexOf("./", 1);
var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46);
return !startsWithDotSlashOrDotDotSlash;
return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName));
}
function tryReadTypesSection(packageJsonPath, baseDirectory, state) {
var jsonContent;
@ -37455,6 +37479,22 @@ var ts;
return ts.sortAndDeduplicateDiagnostics(diagnostics);
}
ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
function formatDiagnostics(diagnostics, host) {
var output = "";
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
var diagnostic = diagnostics_1[_i];
if (diagnostic.file) {
var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
var fileName = diagnostic.file.fileName;
var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
}
return output;
}
ts.formatDiagnostics = formatDiagnostics;
function flattenDiagnosticMessageText(messageText, newLine) {
if (typeof messageText === "string") {
return messageText;
@ -37530,7 +37570,7 @@ var ts;
var resolvedTypeReferenceDirectives = {};
var fileProcessingDiagnostics = ts.createDiagnosticCollection();
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
var currentNodeModulesJsDepth = 0;
var currentNodeModulesDepth = 0;
var modulesWithElidedImports = {};
var sourceFilesFoundSearchingNodeModules = {};
var start = new Date().getTime();
@ -37754,8 +37794,7 @@ var ts;
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
}
function emit(sourceFile, writeFileCallback, cancellationToken) {
var _this = this;
return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); });
return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); });
}
function isEmitBlocked(emitFileName) {
return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName));
@ -38162,8 +38201,17 @@ var ts;
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
}
if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) {
if (file_1 && ts.lookUp(sourceFilesFoundSearchingNodeModules, file_1.path) && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file_1.path] = false;
if (!options.noResolve) {
processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib);
processTypeReferenceDirectives(file_1);
}
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
else if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
@ -38180,6 +38228,7 @@ var ts;
});
filesByName.set(path, file);
if (file) {
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
file.path = path;
if (host.useCaseSensitiveFileNames()) {
var existingFile = filesByNameIgnoreCase.get(path);
@ -38280,12 +38329,9 @@ var ts;
var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName);
if (isFromNodeModulesSearch) {
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
currentNodeModulesDepth++;
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth++;
}
var elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth;
var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;
if (elideImport) {
modulesWithElidedImports[file.path] = true;
@ -38293,8 +38339,8 @@ var ts;
else if (shouldAddFile) {
findSourceFile(resolution.resolvedFileName, resolvedPath, false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth--;
if (isFromNodeModulesSearch) {
currentNodeModulesDepth--;
}
}
}
@ -39887,7 +39933,7 @@ var ts;
return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text);
}
else {
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text));
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, ts.startsWith(candidate, chunk.text));
}
}
var isLowercase = chunk.isLowerCase;
@ -40059,14 +40105,6 @@ var ts;
var str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function startsWith(string, search) {
for (var i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
}
return true;
}
function indexOfIgnoringCase(string, value) {
for (var i = 0, n = string.length - value.length; i <= n; i++) {
if (startsWithIgnoringCase(string, value, i)) {
@ -41551,6 +41589,9 @@ var ts;
}
return false;
}
function shouldRescanJsxText(node) {
return node && node.kind === 244;
}
function shouldRescanSlashToken(container) {
return container.kind === 10;
}
@ -41578,7 +41619,9 @@ var ts;
? 3
: shouldRescanJsxIdentifier(n)
? 4
: 0;
: shouldRescanJsxText(n)
? 5
: 0;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
return fixTokenKind(lastTokenInfo, n);
}
@ -41606,6 +41649,10 @@ var ts;
currentToken = scanner.scanJsxIdentifier();
lastScanAction = 4;
}
else if (expectedScanAction === 5) {
currentToken = scanner.reScanJsxToken();
lastScanAction = 5;
}
else {
lastScanAction = 0;
}
@ -43854,19 +43901,20 @@ var ts;
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new NodeObject(kind, pos, end);
node.flags = flags;
function createNode(kind, pos, end, parent) {
var node = kind >= 139 ? new NodeObject(kind, pos, end) :
kind === 69 ? new IdentifierObject(kind, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
return node;
}
var NodeObject = (function () {
function NodeObject(kind, pos, end) {
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
this.kind = kind;
}
NodeObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
@ -43901,14 +43949,14 @@ var ts;
var token = useJSDocScanner ? scanner.scanJSDocToken() : scanner.scan();
var textPos = scanner.getTextPos();
if (textPos <= end) {
nodes.push(createNode(token, pos, textPos, 0, this));
nodes.push(createNode(token, pos, textPos, this));
}
pos = textPos;
}
return pos;
};
NodeObject.prototype.createSyntaxList = function (nodes) {
var list = createNode(282, nodes.pos, nodes.end, 0, this);
var list = createNode(282, nodes.pos, nodes.end, this);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
@ -43993,6 +44041,73 @@ var ts;
};
return NodeObject;
}());
var TokenOrIdentifierObject = (function () {
function TokenOrIdentifierObject(pos, end) {
this.pos = pos;
this.end = end;
this.flags = 0;
this.parent = undefined;
}
TokenOrIdentifierObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
};
TokenOrIdentifierObject.prototype.getStart = function (sourceFile, includeJsDocComment) {
return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment);
};
TokenOrIdentifierObject.prototype.getFullStart = function () {
return this.pos;
};
TokenOrIdentifierObject.prototype.getEnd = function () {
return this.end;
};
TokenOrIdentifierObject.prototype.getWidth = function (sourceFile) {
return this.getEnd() - this.getStart(sourceFile);
};
TokenOrIdentifierObject.prototype.getFullWidth = function () {
return this.end - this.pos;
};
TokenOrIdentifierObject.prototype.getLeadingTriviaWidth = function (sourceFile) {
return this.getStart(sourceFile) - this.pos;
};
TokenOrIdentifierObject.prototype.getFullText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end);
};
TokenOrIdentifierObject.prototype.getText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
};
TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) {
return 0;
};
TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) {
return emptyArray;
};
TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) {
return undefined;
};
return TokenOrIdentifierObject;
}());
var TokenObject = (function (_super) {
__extends(TokenObject, _super);
function TokenObject(kind, pos, end) {
_super.call(this, pos, end);
this.kind = kind;
}
return TokenObject;
}(TokenOrIdentifierObject));
var IdentifierObject = (function (_super) {
__extends(IdentifierObject, _super);
function IdentifierObject(kind, pos, end) {
_super.call(this, pos, end);
}
return IdentifierObject;
}(TokenOrIdentifierObject));
IdentifierObject.prototype.kind = 69;
var SymbolObject = (function () {
function SymbolObject(flags, name) {
this.flags = flags;
@ -49673,6 +49788,8 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function () { return NodeObject; },
getTokenConstructor: function () { return TokenObject; },
getIdentifierConstructor: function () { return IdentifierObject; },
getSourceFileConstructor: function () { return SourceFileObject; },
getSymbolConstructor: function () { return SymbolObject; },
getTypeConstructor: function () { return TypeObject; },
@ -50793,7 +50910,6 @@ var ts;
if (isOpen === void 0) { isOpen = false; }
this.host = host;
this.fileName = fileName;
this.content = content;
this.isOpen = isOpen;
this.children = [];
this.formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host));
@ -52419,7 +52535,7 @@ var ts;
done: false,
leaf: function (relativeStart, relativeLength, ll) {
if (!f(ll, relativeStart, relativeLength)) {
this.done = true;
walkFns.done = true;
}
}
};
@ -52835,7 +52951,7 @@ var ts;
server.LineLeaf = LineLeaf;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
var debugObjectHost = this;
var debugObjectHost = new Function("return this")();
var ts;
(function (ts) {
function logInternalError(logger, err) {
@ -52963,7 +53079,7 @@ var ts;
return this.shimHost.getCurrentDirectory();
};
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
return this.shimHost.getDirectories(path);
return JSON.parse(this.shimHost.getDirectories(path));
};
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

14
lib/typescript.d.ts vendored
View File

@ -409,7 +409,10 @@ declare namespace ts {
interface ModifiersArray extends NodeArray<Modifier> {
flags: NodeFlags;
}
interface Modifier extends Node {
interface Token extends Node {
__tokenTag: any;
}
interface Modifier extends Token {
}
interface Identifier extends PrimaryExpression {
text: string;
@ -1696,7 +1699,6 @@ declare namespace ts {
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
getDefaultLibLocation?(): string;
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
@ -1842,8 +1844,6 @@ declare namespace ts {
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean;
function startsWith(str: string, prefix: string): boolean;
function endsWith(str: string, suffix: string): boolean;
}
declare namespace ts {
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
@ -1868,6 +1868,12 @@ declare namespace ts {
function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
interface FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
}
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
/**
* Given a set of options and a set of root files, returns the set of type directive names

View File

@ -1756,10 +1756,19 @@ var ts;
return true;
}
ts.containsPath = containsPath;
/* @internal */
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
/* @internal */
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
function fileExtensionIs(path, extension) {
var pathLen = path.length;
var extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
return path.length > extension.length && endsWith(path, extension);
}
ts.fileExtensionIs = fileExtensionIs;
function fileExtensionIsAny(path, extensions) {
@ -2070,6 +2079,8 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function () { return Node; },
getTokenConstructor: function () { return Node; },
getIdentifierConstructor: function () { return Node; },
getSourceFileConstructor: function () { return Node; },
getSymbolConstructor: function () { return Symbol; },
getTypeConstructor: function () { return Type; },
@ -2216,7 +2227,7 @@ var ts;
function readDirectory(path, extensions, excludes, includes) {
return ts.matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
}
return {
var wscriptSystem = {
args: args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
@ -2235,7 +2246,7 @@ var ts;
return fso.FolderExists(path);
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!wscriptSystem.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
@ -2255,6 +2266,7 @@ var ts;
}
}
};
return wscriptSystem;
}
function getNodeSystem() {
var _fs = require("fs");
@ -2444,7 +2456,7 @@ var ts;
function getDirectories(path) {
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1 /* Directory */); });
}
return {
var nodeSystem = {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@ -2500,7 +2512,7 @@ var ts;
fileExists: fileExists,
directoryExists: directoryExists,
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!nodeSystem.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
@ -2548,6 +2560,7 @@ var ts;
return _fs.realpathSync(path);
}
};
return nodeSystem;
}
function getChakraSystem() {
var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); });
@ -3304,8 +3317,8 @@ var ts;
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" },
_0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." },
Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." },
Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." },
Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." },
Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." },
The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" },
No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
@ -6153,7 +6166,7 @@ var ts;
function isExternalModuleNameRelative(moduleName) {
// TypeScript 1.0 spec (April 2014): 11.2.1
// An external module name is "relative" if the first term is "." or "..".
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
return /^\.\.?($|[\\/])/.test(moduleName);
}
ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
function isInstantiatedModule(node, preserveConstEnums) {
@ -7916,15 +7929,6 @@ var ts;
return node.flags & 92 /* ParameterPropertyModifier */ && node.parent.kind === 148 /* Constructor */ && ts.isClassLike(node.parent.parent);
}
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
})(ts || (ts = {}));
/// <reference path="utilities.ts"/>
/// <reference path="scanner.ts"/>
@ -7932,11 +7936,19 @@ var ts;
(function (ts) {
/* @internal */ ts.parseTime = 0;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
function createNode(kind, pos, end) {
if (kind === 256 /* SourceFile */) {
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else if (kind === 69 /* Identifier */) {
return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
}
else if (kind < 139 /* FirstNode */) {
return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
}
@ -8386,6 +8398,8 @@ var ts;
var disallowInAndDecoratorContext = 4194304 /* DisallowInContext */ | 16777216 /* DecoratorContext */;
// capture constructors in 'initializeState' to avoid null checks
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
var sourceFile;
var parseDiagnostics;
@ -8485,6 +8499,8 @@ var ts;
}
function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) {
NodeConstructor = ts.objectAllocator.getNodeConstructor();
TokenConstructor = ts.objectAllocator.getTokenConstructor();
IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
sourceText = _sourceText;
syntaxCursor = _syntaxCursor;
@ -8855,7 +8871,9 @@ var ts;
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
return new NodeConstructor(kind, pos, pos);
return kind >= 139 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) :
kind === 69 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) :
new TokenConstructor(kind, pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -13524,6 +13542,9 @@ var ts;
case 55 /* AtToken */:
if (canParseTag) {
parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral);
if (!parentTagTerminated) {
resumePos = scanner.getStartPos();
}
}
seenAsterisk = false;
break;
@ -18991,22 +19012,24 @@ var ts;
if (declaration.kind === 235 /* ExportAssignment */) {
return links.type = checkExpression(declaration.expression);
}
if (declaration.flags & 134217728 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) {
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
}
// Handle variable, parameter or property
if (!pushTypeResolution(symbol, 0 /* Type */)) {
return unknownType;
}
var type = undefined;
// Handle module.exports = expr or this.p = expr
if (declaration.kind === 187 /* BinaryExpression */) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); }));
}
else if (declaration.kind === 172 /* PropertyAccessExpression */) {
// Declarations only exist for property access expressions for certain
// special assignment kinds
if (declaration.parent.kind === 187 /* BinaryExpression */) {
// Handle exports.p = expr or className.prototype.method = expr
type = checkExpressionCached(declaration.parent.right);
}
// Handle certain special assignment kinds, which happen to union across multiple declarations:
// * module.exports = expr
// * exports.p = expr
// * this.p = expr
// * className.prototype.method = expr
if (declaration.kind === 187 /* BinaryExpression */ ||
declaration.kind === 172 /* PropertyAccessExpression */ && declaration.parent.kind === 187 /* BinaryExpression */) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return decl.kind === 187 /* BinaryExpression */ ?
checkExpressionCached(decl.right) :
checkExpressionCached(decl.parent.right); }));
}
if (type === undefined) {
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
@ -26761,7 +26784,7 @@ var ts;
function getInferredClassType(symbol) {
var links = getSymbolLinks(symbol);
if (!links.inferredClassType) {
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
}
return links.inferredClassType;
}
@ -28202,7 +28225,7 @@ var ts;
checkAsyncFunctionReturnType(node);
}
}
if (!node.body) {
if (noUnusedIdentifiers && !node.body) {
checkUnusedTypeParameters(node);
}
}
@ -29341,6 +29364,7 @@ var ts;
var parameter = local_1.valueDeclaration;
if (compilerOptions.noUnusedParameters &&
!ts.isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(parameter)) {
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
}
@ -29356,6 +29380,9 @@ var ts;
}
}
}
function parameterIsThisKeyword(parameter) {
return parameter.name && parameter.name.originalKeywordKind === 97 /* ThisKeyword */;
}
function parameterNameStartsWithUnderscore(parameter) {
return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */;
}
@ -29384,9 +29411,16 @@ var ts;
function checkUnusedTypeParameters(node) {
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
if (node.typeParameters) {
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
var symbol = getSymbolOfNode(node);
var lastDeclaration = symbol && symbol.declarations && ts.lastOrUndefined(symbol.declarations);
if (lastDeclaration !== node) {
return;
}
for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
var typeParameter = _a[_i];
if (!typeParameter.symbol.isReferenced) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
@ -30719,7 +30753,7 @@ var ts;
ts.forEach(node.members, checkSourceElement);
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
checkUnusedTypeParameters(node);
registerForUnusedIdentifiersCheck(node);
}
}
function checkTypeAliasDeclaration(node) {
@ -35983,7 +36017,7 @@ var ts;
writeLine();
var sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
write("//# sourceMappingURL=" + sourceMappingURL);
write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment
}
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM, sourceFiles);
// reset the state
@ -37880,7 +37914,7 @@ var ts;
* if we should also export the value after its it changed
* - check if node is a source level declaration to emit it differently,
* i.e non-exported variable statement 'var x = 1' is hoisted so
* we we emit variable statement 'var' should be dropped.
* when we emit variable statement 'var' should be dropped.
*/
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
if (!node || !isCurrentFileSystemExternalModule()) {
@ -40347,13 +40381,13 @@ var ts;
if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */) && decoratedClassAlias === undefined) {
write("export ");
}
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
if (decoratedClassAlias !== undefined) {
write("" + decoratedClassAlias);
write("let " + decoratedClassAlias);
}
else {
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
emitDeclarationName(node);
}
write(" = ");
@ -40372,7 +40406,9 @@ var ts;
//
// We'll emit:
//
// (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp)
// let C_1 = class C{};
// C_1.a = 1;
// C_1.b = 2; // so forth and so on
//
// This keeps the expression as an expression, while ensuring that the static parts
// of it have been initialized by the time it is used.
@ -42936,7 +42972,7 @@ var ts;
/* @internal */ ts.ioReadTime = 0;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
ts.version = "2.0.0";
ts.version = "2.1.0";
var emptyArray = [];
var defaultTypeRoots = ["node_modules/@types"];
function findConfigFile(searchPath, fileExists) {
@ -43025,12 +43061,7 @@ var ts;
return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations };
}
function moduleHasNonRelativeName(moduleName) {
if (ts.isRootedDiskPath(moduleName)) {
return false;
}
var i = moduleName.lastIndexOf("./", 1);
var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46 /* dot */);
return !startsWithDotSlashOrDotDotSlash;
return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName));
}
function tryReadTypesSection(packageJsonPath, baseDirectory, state) {
var jsonContent;
@ -43797,6 +43828,22 @@ var ts;
return ts.sortAndDeduplicateDiagnostics(diagnostics);
}
ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
function formatDiagnostics(diagnostics, host) {
var output = "";
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
var diagnostic = diagnostics_1[_i];
if (diagnostic.file) {
var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
var fileName = diagnostic.file.fileName;
var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
}
return output;
}
ts.formatDiagnostics = formatDiagnostics;
function flattenDiagnosticMessageText(messageText, newLine) {
if (typeof messageText === "string") {
return messageText;
@ -43889,11 +43936,11 @@ var ts;
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
var currentNodeModulesJsDepth = 0;
var currentNodeModulesDepth = 0;
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
// this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed.
var modulesWithElidedImports = {};
// Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled.
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
var sourceFilesFoundSearchingNodeModules = {};
var start = new Date().getTime();
host = host || createCompilerHost(options);
@ -44150,8 +44197,7 @@ var ts;
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
}
function emit(sourceFile, writeFileCallback, cancellationToken) {
var _this = this;
return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); });
return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); });
}
function isEmitBlocked(emitFileName) {
return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName));
@ -44603,9 +44649,19 @@ var ts;
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
}
// See if we need to reprocess the imports due to prior skipped imports
if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) {
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
if (file_1 && ts.lookUp(sourceFilesFoundSearchingNodeModules, file_1.path) && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file_1.path] = false;
if (!options.noResolve) {
processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib);
processTypeReferenceDirectives(file_1);
}
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
else if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
@ -44623,6 +44679,7 @@ var ts;
});
filesByName.set(path, file);
if (file) {
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
file.path = path;
if (host.useCaseSensitiveFileNames()) {
// for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
@ -44737,12 +44794,9 @@ var ts;
var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName);
if (isFromNodeModulesSearch) {
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
currentNodeModulesDepth++;
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth++;
}
var elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth;
var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;
if (elideImport) {
modulesWithElidedImports[file.path] = true;
@ -44751,8 +44805,8 @@ var ts;
findSourceFile(resolution.resolvedFileName, resolvedPath,
/*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth--;
if (isFromNodeModulesSearch) {
currentNodeModulesDepth--;
}
}
}
@ -45090,12 +45144,12 @@ var ts;
{
name: "noUnusedLocals",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Locals
description: ts.Diagnostics.Report_errors_on_unused_locals
},
{
name: "noUnusedParameters",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Parameters
description: ts.Diagnostics.Report_errors_on_unused_parameters
},
{
name: "noLib",
@ -47087,7 +47141,7 @@ var ts;
else {
// b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive
// manner. If it does, return that there was a prefix match.
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text));
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ ts.startsWith(candidate, chunk.text));
}
}
var isLowercase = chunk.isLowerCase;
@ -47353,14 +47407,6 @@ var ts;
var str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function startsWith(string, search) {
for (var i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
}
return true;
}
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(string, value) {
for (var i = 0, n = string.length - value.length; i <= n; i++) {
@ -49205,6 +49251,7 @@ var ts;
ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken";
ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken";
ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier";
ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText";
})(ScanAction || (ScanAction = {}));
function getFormattingScanner(sourceFile, startPos, endPos) {
ts.Debug.assert(scanner === undefined);
@ -49296,6 +49343,9 @@ var ts;
}
return false;
}
function shouldRescanJsxText(node) {
return node && node.kind === 244 /* JsxText */;
}
function shouldRescanSlashToken(container) {
return container.kind === 10 /* RegularExpressionLiteral */;
}
@ -49326,7 +49376,9 @@ var ts;
? 3 /* RescanTemplateToken */
: shouldRescanJsxIdentifier(n)
? 4 /* RescanJsxIdentifier */
: 0 /* Scan */;
: shouldRescanJsxText(n)
? 5 /* RescanJsxText */
: 0 /* Scan */;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
// readTokenInfo was called before with the same expected scan action.
// No need to re-scan text, return existing 'lastTokenInfo'
@ -49361,6 +49413,10 @@ var ts;
currentToken = scanner.scanJsxIdentifier();
lastScanAction = 4 /* RescanJsxIdentifier */;
}
else if (expectedScanAction === 5 /* RescanJsxText */) {
currentToken = scanner.reScanJsxToken();
lastScanAction = 5 /* RescanJsxText */;
}
else {
lastScanAction = 0 /* Scan */;
}
@ -52033,19 +52089,20 @@ var ts;
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new NodeObject(kind, pos, end);
node.flags = flags;
function createNode(kind, pos, end, parent) {
var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) :
kind === 69 /* Identifier */ ? new IdentifierObject(kind, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
return node;
}
var NodeObject = (function () {
function NodeObject(kind, pos, end) {
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
this.kind = kind;
}
NodeObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
@ -52080,14 +52137,14 @@ var ts;
var token = useJSDocScanner ? scanner.scanJSDocToken() : scanner.scan();
var textPos = scanner.getTextPos();
if (textPos <= end) {
nodes.push(createNode(token, pos, textPos, 0, this));
nodes.push(createNode(token, pos, textPos, this));
}
pos = textPos;
}
return pos;
};
NodeObject.prototype.createSyntaxList = function (nodes) {
var list = createNode(282 /* SyntaxList */, nodes.pos, nodes.end, 0, this);
var list = createNode(282 /* SyntaxList */, nodes.pos, nodes.end, this);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
@ -52173,6 +52230,74 @@ var ts;
};
return NodeObject;
}());
var TokenOrIdentifierObject = (function () {
function TokenOrIdentifierObject(pos, end) {
// Set properties in same order as NodeObject
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
}
TokenOrIdentifierObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
};
TokenOrIdentifierObject.prototype.getStart = function (sourceFile, includeJsDocComment) {
return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment);
};
TokenOrIdentifierObject.prototype.getFullStart = function () {
return this.pos;
};
TokenOrIdentifierObject.prototype.getEnd = function () {
return this.end;
};
TokenOrIdentifierObject.prototype.getWidth = function (sourceFile) {
return this.getEnd() - this.getStart(sourceFile);
};
TokenOrIdentifierObject.prototype.getFullWidth = function () {
return this.end - this.pos;
};
TokenOrIdentifierObject.prototype.getLeadingTriviaWidth = function (sourceFile) {
return this.getStart(sourceFile) - this.pos;
};
TokenOrIdentifierObject.prototype.getFullText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end);
};
TokenOrIdentifierObject.prototype.getText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
};
TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) {
return 0;
};
TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) {
return emptyArray;
};
TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) {
return undefined;
};
return TokenOrIdentifierObject;
}());
var TokenObject = (function (_super) {
__extends(TokenObject, _super);
function TokenObject(kind, pos, end) {
_super.call(this, pos, end);
this.kind = kind;
}
return TokenObject;
}(TokenOrIdentifierObject));
var IdentifierObject = (function (_super) {
__extends(IdentifierObject, _super);
function IdentifierObject(kind, pos, end) {
_super.call(this, pos, end);
}
return IdentifierObject;
}(TokenOrIdentifierObject));
IdentifierObject.prototype.kind = 69 /* Identifier */;
var SymbolObject = (function () {
function SymbolObject(flags, name) {
this.flags = flags;
@ -58937,6 +59062,8 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function () { return NodeObject; },
getTokenConstructor: function () { return TokenObject; },
getIdentifierConstructor: function () { return IdentifierObject; },
getSourceFileConstructor: function () { return SourceFileObject; },
getSymbolConstructor: function () { return SymbolObject; },
getTypeConstructor: function () { return TypeObject; },
@ -59562,7 +59689,7 @@ var ts;
//
/// <reference path='services.ts' />
/* @internal */
var debugObjectHost = this;
var debugObjectHost = new Function("return this")();
// We need to use 'null' to interface with the managed side.
/* tslint:disable:no-null-keyword */
/* tslint:disable:no-in-operator */
@ -59701,7 +59828,7 @@ var ts;
return this.shimHost.getCurrentDirectory();
};
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
return this.shimHost.getDirectories(path);
return JSON.parse(this.shimHost.getDirectories(path));
};
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

View File

@ -409,7 +409,10 @@ declare namespace ts {
interface ModifiersArray extends NodeArray<Modifier> {
flags: NodeFlags;
}
interface Modifier extends Node {
interface Token extends Node {
__tokenTag: any;
}
interface Modifier extends Token {
}
interface Identifier extends PrimaryExpression {
text: string;
@ -1696,7 +1699,6 @@ declare namespace ts {
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
getDefaultLibLocation?(): string;
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
@ -1842,8 +1844,6 @@ declare namespace ts {
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean;
function startsWith(str: string, prefix: string): boolean;
function endsWith(str: string, suffix: string): boolean;
}
declare namespace ts {
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
@ -1868,6 +1868,12 @@ declare namespace ts {
function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
interface FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
}
function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string;
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
/**
* Given a set of options and a set of root files, returns the set of type directive names

View File

@ -1756,10 +1756,19 @@ var ts;
return true;
}
ts.containsPath = containsPath;
/* @internal */
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
/* @internal */
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
function fileExtensionIs(path, extension) {
var pathLen = path.length;
var extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
return path.length > extension.length && endsWith(path, extension);
}
ts.fileExtensionIs = fileExtensionIs;
function fileExtensionIsAny(path, extensions) {
@ -2070,6 +2079,8 @@ var ts;
}
ts.objectAllocator = {
getNodeConstructor: function () { return Node; },
getTokenConstructor: function () { return Node; },
getIdentifierConstructor: function () { return Node; },
getSourceFileConstructor: function () { return Node; },
getSymbolConstructor: function () { return Symbol; },
getTypeConstructor: function () { return Type; },
@ -2216,7 +2227,7 @@ var ts;
function readDirectory(path, extensions, excludes, includes) {
return ts.matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
}
return {
var wscriptSystem = {
args: args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
@ -2235,7 +2246,7 @@ var ts;
return fso.FolderExists(path);
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!wscriptSystem.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
@ -2255,6 +2266,7 @@ var ts;
}
}
};
return wscriptSystem;
}
function getNodeSystem() {
var _fs = require("fs");
@ -2444,7 +2456,7 @@ var ts;
function getDirectories(path) {
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1 /* Directory */); });
}
return {
var nodeSystem = {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@ -2500,7 +2512,7 @@ var ts;
fileExists: fileExists,
directoryExists: directoryExists,
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
if (!nodeSystem.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
@ -2548,6 +2560,7 @@ var ts;
return _fs.realpathSync(path);
}
};
return nodeSystem;
}
function getChakraSystem() {
var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); });
@ -3304,8 +3317,8 @@ var ts;
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" },
_0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." },
Report_Errors_on_Unused_Locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Locals_6134", message: "Report Errors on Unused Locals." },
Report_Errors_on_Unused_Parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_Errors_on_Unused_Parameters_6135", message: "Report Errors on Unused Parameters." },
Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." },
Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." },
The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" },
No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
@ -6153,7 +6166,7 @@ var ts;
function isExternalModuleNameRelative(moduleName) {
// TypeScript 1.0 spec (April 2014): 11.2.1
// An external module name is "relative" if the first term is "." or "..".
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
return /^\.\.?($|[\\/])/.test(moduleName);
}
ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
function isInstantiatedModule(node, preserveConstEnums) {
@ -7916,15 +7929,6 @@ var ts;
return node.flags & 92 /* ParameterPropertyModifier */ && node.parent.kind === 148 /* Constructor */ && ts.isClassLike(node.parent.parent);
}
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
ts.startsWith = startsWith;
function endsWith(str, suffix) {
var expectedPos = str.length - suffix.length;
return str.indexOf(suffix, expectedPos) === expectedPos;
}
ts.endsWith = endsWith;
})(ts || (ts = {}));
/// <reference path="utilities.ts"/>
/// <reference path="scanner.ts"/>
@ -7932,11 +7936,19 @@ var ts;
(function (ts) {
/* @internal */ ts.parseTime = 0;
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
function createNode(kind, pos, end) {
if (kind === 256 /* SourceFile */) {
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else if (kind === 69 /* Identifier */) {
return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
}
else if (kind < 139 /* FirstNode */) {
return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
}
@ -8386,6 +8398,8 @@ var ts;
var disallowInAndDecoratorContext = 4194304 /* DisallowInContext */ | 16777216 /* DecoratorContext */;
// capture constructors in 'initializeState' to avoid null checks
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var SourceFileConstructor;
var sourceFile;
var parseDiagnostics;
@ -8485,6 +8499,8 @@ var ts;
}
function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) {
NodeConstructor = ts.objectAllocator.getNodeConstructor();
TokenConstructor = ts.objectAllocator.getTokenConstructor();
IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
sourceText = _sourceText;
syntaxCursor = _syntaxCursor;
@ -8855,7 +8871,9 @@ var ts;
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
return new NodeConstructor(kind, pos, pos);
return kind >= 139 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) :
kind === 69 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) :
new TokenConstructor(kind, pos, pos);
}
function finishNode(node, end) {
node.end = end === undefined ? scanner.getStartPos() : end;
@ -13524,6 +13542,9 @@ var ts;
case 55 /* AtToken */:
if (canParseTag) {
parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral);
if (!parentTagTerminated) {
resumePos = scanner.getStartPos();
}
}
seenAsterisk = false;
break;
@ -18991,22 +19012,24 @@ var ts;
if (declaration.kind === 235 /* ExportAssignment */) {
return links.type = checkExpression(declaration.expression);
}
if (declaration.flags & 134217728 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) {
return links.type = getTypeFromTypeNode(declaration.typeExpression.type);
}
// Handle variable, parameter or property
if (!pushTypeResolution(symbol, 0 /* Type */)) {
return unknownType;
}
var type = undefined;
// Handle module.exports = expr or this.p = expr
if (declaration.kind === 187 /* BinaryExpression */) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); }));
}
else if (declaration.kind === 172 /* PropertyAccessExpression */) {
// Declarations only exist for property access expressions for certain
// special assignment kinds
if (declaration.parent.kind === 187 /* BinaryExpression */) {
// Handle exports.p = expr or className.prototype.method = expr
type = checkExpressionCached(declaration.parent.right);
}
// Handle certain special assignment kinds, which happen to union across multiple declarations:
// * module.exports = expr
// * exports.p = expr
// * this.p = expr
// * className.prototype.method = expr
if (declaration.kind === 187 /* BinaryExpression */ ||
declaration.kind === 172 /* PropertyAccessExpression */ && declaration.parent.kind === 187 /* BinaryExpression */) {
type = getUnionType(ts.map(symbol.declarations, function (decl) { return decl.kind === 187 /* BinaryExpression */ ?
checkExpressionCached(decl.right) :
checkExpressionCached(decl.parent.right); }));
}
if (type === undefined) {
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
@ -26761,7 +26784,7 @@ var ts;
function getInferredClassType(symbol) {
var links = getSymbolLinks(symbol);
if (!links.inferredClassType) {
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
}
return links.inferredClassType;
}
@ -28202,7 +28225,7 @@ var ts;
checkAsyncFunctionReturnType(node);
}
}
if (!node.body) {
if (noUnusedIdentifiers && !node.body) {
checkUnusedTypeParameters(node);
}
}
@ -29341,6 +29364,7 @@ var ts;
var parameter = local_1.valueDeclaration;
if (compilerOptions.noUnusedParameters &&
!ts.isParameterPropertyDeclaration(parameter) &&
!parameterIsThisKeyword(parameter) &&
!parameterNameStartsWithUnderscore(parameter)) {
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
}
@ -29356,6 +29380,9 @@ var ts;
}
}
}
function parameterIsThisKeyword(parameter) {
return parameter.name && parameter.name.originalKeywordKind === 97 /* ThisKeyword */;
}
function parameterNameStartsWithUnderscore(parameter) {
return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */;
}
@ -29384,9 +29411,16 @@ var ts;
function checkUnusedTypeParameters(node) {
if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) {
if (node.typeParameters) {
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
var symbol = getSymbolOfNode(node);
var lastDeclaration = symbol && symbol.declarations && ts.lastOrUndefined(symbol.declarations);
if (lastDeclaration !== node) {
return;
}
for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
var typeParameter = _a[_i];
if (!typeParameter.symbol.isReferenced) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
@ -30719,7 +30753,7 @@ var ts;
ts.forEach(node.members, checkSourceElement);
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
checkUnusedTypeParameters(node);
registerForUnusedIdentifiersCheck(node);
}
}
function checkTypeAliasDeclaration(node) {
@ -35983,7 +36017,7 @@ var ts;
writeLine();
var sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
write("//# sourceMappingURL=" + sourceMappingURL);
write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment
}
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM, sourceFiles);
// reset the state
@ -37880,7 +37914,7 @@ var ts;
* if we should also export the value after its it changed
* - check if node is a source level declaration to emit it differently,
* i.e non-exported variable statement 'var x = 1' is hoisted so
* we we emit variable statement 'var' should be dropped.
* when we emit variable statement 'var' should be dropped.
*/
function isSourceFileLevelDeclarationInSystemJsModule(node, isExported) {
if (!node || !isCurrentFileSystemExternalModule()) {
@ -40347,13 +40381,13 @@ var ts;
if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */) && decoratedClassAlias === undefined) {
write("export ");
}
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
if (decoratedClassAlias !== undefined) {
write("" + decoratedClassAlias);
write("let " + decoratedClassAlias);
}
else {
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
emitDeclarationName(node);
}
write(" = ");
@ -40372,7 +40406,9 @@ var ts;
//
// We'll emit:
//
// (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp)
// let C_1 = class C{};
// C_1.a = 1;
// C_1.b = 2; // so forth and so on
//
// This keeps the expression as an expression, while ensuring that the static parts
// of it have been initialized by the time it is used.
@ -42936,7 +42972,7 @@ var ts;
/* @internal */ ts.ioReadTime = 0;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
ts.version = "2.0.0";
ts.version = "2.1.0";
var emptyArray = [];
var defaultTypeRoots = ["node_modules/@types"];
function findConfigFile(searchPath, fileExists) {
@ -43025,12 +43061,7 @@ var ts;
return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations };
}
function moduleHasNonRelativeName(moduleName) {
if (ts.isRootedDiskPath(moduleName)) {
return false;
}
var i = moduleName.lastIndexOf("./", 1);
var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46 /* dot */);
return !startsWithDotSlashOrDotDotSlash;
return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName));
}
function tryReadTypesSection(packageJsonPath, baseDirectory, state) {
var jsonContent;
@ -43797,6 +43828,22 @@ var ts;
return ts.sortAndDeduplicateDiagnostics(diagnostics);
}
ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
function formatDiagnostics(diagnostics, host) {
var output = "";
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
var diagnostic = diagnostics_1[_i];
if (diagnostic.file) {
var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
var fileName = diagnostic.file.fileName;
var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
}
return output;
}
ts.formatDiagnostics = formatDiagnostics;
function flattenDiagnosticMessageText(messageText, newLine) {
if (typeof messageText === "string") {
return messageText;
@ -43889,11 +43936,11 @@ var ts;
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
var currentNodeModulesJsDepth = 0;
var currentNodeModulesDepth = 0;
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
// this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed.
var modulesWithElidedImports = {};
// Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled.
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
var sourceFilesFoundSearchingNodeModules = {};
var start = new Date().getTime();
host = host || createCompilerHost(options);
@ -44150,8 +44197,7 @@ var ts;
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
}
function emit(sourceFile, writeFileCallback, cancellationToken) {
var _this = this;
return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); });
return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); });
}
function isEmitBlocked(emitFileName) {
return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName));
@ -44603,9 +44649,19 @@ var ts;
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
}
// See if we need to reprocess the imports due to prior skipped imports
if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesJsDepth < maxNodeModulesJsDepth) {
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
if (file_1 && ts.lookUp(sourceFilesFoundSearchingNodeModules, file_1.path) && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file_1.path] = false;
if (!options.noResolve) {
processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib);
processTypeReferenceDirectives(file_1);
}
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
else if (file_1 && ts.lookUp(modulesWithElidedImports, file_1.path)) {
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
modulesWithElidedImports[file_1.path] = false;
processImportedModules(file_1, ts.getDirectoryPath(fileName));
}
@ -44623,6 +44679,7 @@ var ts;
});
filesByName.set(path, file);
if (file) {
sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0);
file.path = path;
if (host.useCaseSensitiveFileNames()) {
// for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
@ -44737,12 +44794,9 @@ var ts;
var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName);
if (isFromNodeModulesSearch) {
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
currentNodeModulesDepth++;
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth++;
}
var elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth;
var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;
if (elideImport) {
modulesWithElidedImports[file.path] = true;
@ -44751,8 +44805,8 @@ var ts;
findSourceFile(resolution.resolvedFileName, resolvedPath,
/*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth--;
if (isFromNodeModulesSearch) {
currentNodeModulesDepth--;
}
}
}
@ -45090,12 +45144,12 @@ var ts;
{
name: "noUnusedLocals",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Locals
description: ts.Diagnostics.Report_errors_on_unused_locals
},
{
name: "noUnusedParameters",
type: "boolean",
description: ts.Diagnostics.Report_Errors_on_Unused_Parameters
description: ts.Diagnostics.Report_errors_on_unused_parameters
},
{
name: "noLib",
@ -47087,7 +47141,7 @@ var ts;
else {
// b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive
// manner. If it does, return that there was a prefix match.
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text));
return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ ts.startsWith(candidate, chunk.text));
}
}
var isLowercase = chunk.isLowerCase;
@ -47353,14 +47407,6 @@ var ts;
var str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function startsWith(string, search) {
for (var i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
}
return true;
}
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(string, value) {
for (var i = 0, n = string.length - value.length; i <= n; i++) {
@ -49205,6 +49251,7 @@ var ts;
ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken";
ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken";
ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier";
ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText";
})(ScanAction || (ScanAction = {}));
function getFormattingScanner(sourceFile, startPos, endPos) {
ts.Debug.assert(scanner === undefined);
@ -49296,6 +49343,9 @@ var ts;
}
return false;
}
function shouldRescanJsxText(node) {
return node && node.kind === 244 /* JsxText */;
}
function shouldRescanSlashToken(container) {
return container.kind === 10 /* RegularExpressionLiteral */;
}
@ -49326,7 +49376,9 @@ var ts;
? 3 /* RescanTemplateToken */
: shouldRescanJsxIdentifier(n)
? 4 /* RescanJsxIdentifier */
: 0 /* Scan */;
: shouldRescanJsxText(n)
? 5 /* RescanJsxText */
: 0 /* Scan */;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
// readTokenInfo was called before with the same expected scan action.
// No need to re-scan text, return existing 'lastTokenInfo'
@ -49361,6 +49413,10 @@ var ts;
currentToken = scanner.scanJsxIdentifier();
lastScanAction = 4 /* RescanJsxIdentifier */;
}
else if (expectedScanAction === 5 /* RescanJsxText */) {
currentToken = scanner.reScanJsxToken();
lastScanAction = 5 /* RescanJsxText */;
}
else {
lastScanAction = 0 /* Scan */;
}
@ -52033,19 +52089,20 @@ var ts;
"version"
];
var jsDocCompletionEntries;
function createNode(kind, pos, end, flags, parent) {
var node = new NodeObject(kind, pos, end);
node.flags = flags;
function createNode(kind, pos, end, parent) {
var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) :
kind === 69 /* Identifier */ ? new IdentifierObject(kind, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
return node;
}
var NodeObject = (function () {
function NodeObject(kind, pos, end) {
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
this.kind = kind;
}
NodeObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
@ -52080,14 +52137,14 @@ var ts;
var token = useJSDocScanner ? scanner.scanJSDocToken() : scanner.scan();
var textPos = scanner.getTextPos();
if (textPos <= end) {
nodes.push(createNode(token, pos, textPos, 0, this));
nodes.push(createNode(token, pos, textPos, this));
}
pos = textPos;
}
return pos;
};
NodeObject.prototype.createSyntaxList = function (nodes) {
var list = createNode(282 /* SyntaxList */, nodes.pos, nodes.end, 0, this);
var list = createNode(282 /* SyntaxList */, nodes.pos, nodes.end, this);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
@ -52173,6 +52230,74 @@ var ts;
};
return NodeObject;
}());
var TokenOrIdentifierObject = (function () {
function TokenOrIdentifierObject(pos, end) {
// Set properties in same order as NodeObject
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
}
TokenOrIdentifierObject.prototype.getSourceFile = function () {
return ts.getSourceFileOfNode(this);
};
TokenOrIdentifierObject.prototype.getStart = function (sourceFile, includeJsDocComment) {
return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment);
};
TokenOrIdentifierObject.prototype.getFullStart = function () {
return this.pos;
};
TokenOrIdentifierObject.prototype.getEnd = function () {
return this.end;
};
TokenOrIdentifierObject.prototype.getWidth = function (sourceFile) {
return this.getEnd() - this.getStart(sourceFile);
};
TokenOrIdentifierObject.prototype.getFullWidth = function () {
return this.end - this.pos;
};
TokenOrIdentifierObject.prototype.getLeadingTriviaWidth = function (sourceFile) {
return this.getStart(sourceFile) - this.pos;
};
TokenOrIdentifierObject.prototype.getFullText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end);
};
TokenOrIdentifierObject.prototype.getText = function (sourceFile) {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
};
TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) {
return 0;
};
TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) {
return emptyArray;
};
TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) {
return undefined;
};
TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) {
return undefined;
};
return TokenOrIdentifierObject;
}());
var TokenObject = (function (_super) {
__extends(TokenObject, _super);
function TokenObject(kind, pos, end) {
_super.call(this, pos, end);
this.kind = kind;
}
return TokenObject;
}(TokenOrIdentifierObject));
var IdentifierObject = (function (_super) {
__extends(IdentifierObject, _super);
function IdentifierObject(kind, pos, end) {
_super.call(this, pos, end);
}
return IdentifierObject;
}(TokenOrIdentifierObject));
IdentifierObject.prototype.kind = 69 /* Identifier */;
var SymbolObject = (function () {
function SymbolObject(flags, name) {
this.flags = flags;
@ -58937,6 +59062,8 @@ var ts;
function initializeServices() {
ts.objectAllocator = {
getNodeConstructor: function () { return NodeObject; },
getTokenConstructor: function () { return TokenObject; },
getIdentifierConstructor: function () { return IdentifierObject; },
getSourceFileConstructor: function () { return SourceFileObject; },
getSymbolConstructor: function () { return SymbolObject; },
getTypeConstructor: function () { return TypeObject; },
@ -59562,7 +59689,7 @@ var ts;
//
/// <reference path='services.ts' />
/* @internal */
var debugObjectHost = this;
var debugObjectHost = new Function("return this")();
// We need to use 'null' to interface with the managed side.
/* tslint:disable:no-null-keyword */
/* tslint:disable:no-in-operator */
@ -59701,7 +59828,7 @@ var ts;
return this.shimHost.getCurrentDirectory();
};
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
return this.shimHost.getDirectories(path);
return JSON.parse(this.shimHost.getDirectories(path));
};
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

View File

@ -30,6 +30,7 @@
},
"devDependencies": {
"@types/browserify": "latest",
"@types/convert-source-map": "latest",
"@types/chai": "latest",
"@types/del": "latest",
"@types/glob": "latest",
@ -50,6 +51,7 @@
"@types/through2": "latest",
"browserify": "latest",
"chai": "latest",
"convert-source-map": "latest",
"del": "latest",
"gulp": "latest",
"gulp-clone": "latest",
@ -68,9 +70,9 @@
"mocha": "latest",
"mocha-fivemat-progress-reporter": "latest",
"run-sequence": "latest",
"sorcery": "latest",
"through2": "latest",
"ts-node": "latest",
"tsd": "latest",
"tslint": "next",
"typescript": "next"
},

View File

@ -1,12 +0,0 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "5f480287834a2615274eea31574b713e64decf17"
}
}
}

View File

@ -19,4 +19,6 @@ declare module "into-stream" {
export function obj(content: any): NodeJS.ReadableStream
}
export = IntoStream;
}
}
declare module "sorcery";

View File

@ -3,8 +3,6 @@
/* @internal */
namespace ts {
export let bindTime = 0;
export const enum ModuleInstanceState {
NonInstantiated = 0,
Instantiated = 1,
@ -91,9 +89,9 @@ namespace ts {
const binder = createBinder();
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
const start = new Date().getTime();
const start = performance.mark();
binder(file, options);
bindTime += new Date().getTime() - start;
performance.measure("Bind", start);
}
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {

View File

@ -15,8 +15,6 @@ namespace ts {
return node.id;
}
export let checkTime = 0;
export function getSymbolId(symbol: Symbol): number {
if (!symbol.id) {
symbol.id = nextSymbolId;
@ -976,7 +974,7 @@ namespace ts {
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
if (!isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
}
}
@ -3160,6 +3158,9 @@ namespace ts {
if (declaration.kind === SyntaxKind.ExportAssignment) {
return links.type = checkExpression((<ExportAssignment>declaration).expression);
}
if (declaration.flags & NodeFlags.JavaScriptFile && declaration.kind === SyntaxKind.JSDocPropertyTag && (<JSDocPropertyTag>declaration).typeExpression) {
return links.type = getTypeFromTypeNode((<JSDocPropertyTag>declaration).typeExpression.type);
}
// Handle variable, parameter or property
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
return unknownType;
@ -13274,7 +13275,7 @@ namespace ts {
checkAsyncFunctionReturnType(<FunctionLikeDeclaration>node);
}
}
if (!(<FunctionDeclaration>node).body) {
if (noUnusedIdentifiers && !(<FunctionDeclaration>node).body) {
checkUnusedTypeParameters(node);
}
}
@ -14609,8 +14610,15 @@ namespace ts {
function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
if (node.typeParameters) {
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
const symbol = getSymbolOfNode(node);
const lastDeclaration = symbol && symbol.declarations && lastOrUndefined(symbol.declarations);
if (lastDeclaration !== node) {
return;
}
for (const typeParameter of node.typeParameters) {
if (!typeParameter.symbol.isReferenced) {
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
@ -16119,7 +16127,7 @@ namespace ts {
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
checkUnusedTypeParameters(node);
registerForUnusedIdentifiersCheck(node);
}
}
@ -17016,11 +17024,11 @@ namespace ts {
}
function checkSourceFile(node: SourceFile) {
const start = new Date().getTime();
const start = performance.mark();
checkSourceFileWorker(node);
checkTime += new Date().getTime() - start;
performance.measure("Check", start);
}
// Fully type check a source file and collect the relevant diagnostics.

View File

@ -27,6 +27,10 @@ namespace ts {
name: "diagnostics",
type: "boolean",
},
{
name: "extendedDiagnostics",
type: "boolean",
},
{
name: "emitBOM",
type: "boolean"
@ -135,12 +139,12 @@ namespace ts {
{
name: "noUnusedLocals",
type: "boolean",
description: Diagnostics.Report_Errors_on_Unused_Locals,
description: Diagnostics.Report_errors_on_unused_locals,
},
{
name: "noUnusedParameters",
type: "boolean",
description: Diagnostics.Report_Errors_on_Unused_Parameters
description: Diagnostics.Report_errors_on_unused_parameters,
},
{
name: "noLib",

View File

@ -1,4 +1,6 @@
/// <reference path="types.ts"/>
/// <reference path="performance.ts" />
/* @internal */
namespace ts {
@ -899,10 +901,19 @@ namespace ts {
return true;
}
/* @internal */
export function startsWith(str: string, prefix: string): boolean {
return str.lastIndexOf(prefix, 0) === 0;
}
/* @internal */
export function endsWith(str: string, suffix: string): boolean {
const expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
export function fileExtensionIs(path: string, extension: string): boolean {
const pathLen = path.length;
const extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
return path.length > extension.length && endsWith(path, extension);
}
export function fileExtensionIsAny(path: string, extensions: string[]): boolean {
@ -915,7 +926,6 @@ namespace ts {
return false;
}
// Reserved characters, forces escaping of any non-word (or digit), non-whitespace character.
// It may be inefficient (we could just match (/[-[\]{}()*+?.,\\^$|#\s]/g), but this is future
// proof.
@ -1271,6 +1281,8 @@ namespace ts {
export interface ObjectAllocator {
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
getTokenConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
getIdentifierConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
@ -1300,6 +1312,8 @@ namespace ts {
export let objectAllocator: ObjectAllocator = {
getNodeConstructor: () => <any>Node,
getTokenConstructor: () => <any>Node,
getIdentifierConstructor: () => <any>Node,
getSourceFileConstructor: () => <any>Node,
getSymbolConstructor: () => <any>Symbol,
getTypeConstructor: () => <any>Type,

View File

@ -2800,11 +2800,11 @@
"category": "Error",
"code": 6133
},
"Report Errors on Unused Locals.": {
"Report errors on unused locals.": {
"category": "Message",
"code": 6134
},
"Report Errors on Unused Parameters.": {
"Report errors on unused parameters.": {
"category": "Message",
"code": 6135
},

View File

@ -614,7 +614,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
const sourceMappingURL = sourceMap.getSourceMappingURL();
if (sourceMappingURL) {
write(`//# sourceMappingURL=${sourceMappingURL}`);
write(`//# ${"sourceMappingURL"}=${sourceMappingURL}`); // Sometimes tools can sometimes see this line as a source mapping url comment
}
writeEmittedFiles(writer.getText(), jsFilePath, sourceMapFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM, sourceFiles);
@ -2749,7 +2749,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
* if we should also export the value after its it changed
* - check if node is a source level declaration to emit it differently,
* i.e non-exported variable statement 'var x = 1' is hoisted so
* we we emit variable statement 'var' should be dropped.
* when we emit variable statement 'var' should be dropped.
*/
function isSourceFileLevelDeclarationInSystemJsModule(node: Node, isExported: boolean): boolean {
if (!node || !isCurrentFileSystemExternalModule()) {
@ -4571,14 +4571,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
function emitRestParameter(node: FunctionLikeDeclaration) {
if (languageVersion < ScriptTarget.ES6 && hasDeclaredRestParameter(node)) {
const restIndex = node.parameters.length - 1;
const restParam = node.parameters[restIndex];
const restParam = node.parameters[node.parameters.length - 1];
// A rest parameter cannot have a binding pattern, so let's just ignore it if it does.
if (isBindingPattern(restParam.name)) {
return;
}
const skipThisCount = node.parameters.length && (<Identifier>node.parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword ? 1 : 0;
const restIndex = node.parameters.length - 1 - skipThisCount;
const tempName = createTempVariable(TempFlags._i).text;
writeLine();
emitLeadingComments(restParam);
@ -4726,7 +4727,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
write("(");
if (node) {
const parameters = node.parameters;
const skipCount = node.parameters.length && (<Identifier>node.parameters[0].name).text === "this" ? 1 : 0;
const skipCount = node.parameters.length && (<Identifier>node.parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword ? 1 : 0;
const omitCount = languageVersion < ScriptTarget.ES6 && hasDeclaredRestParameter(node) ? 1 : 0;
emitList(parameters, skipCount, parameters.length - omitCount - skipCount, /*multiLine*/ false, /*trailingComma*/ false);
}
@ -5503,16 +5504,15 @@ const _super = (function (geti, seti) {
write("export ");
}
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
if (decoratedClassAlias !== undefined) {
write(`${decoratedClassAlias}`);
write(`let ${decoratedClassAlias}`);
}
else {
if (!isHoistedDeclarationInSystemModule) {
write("let ");
}
emitDeclarationName(node);
}
write(" = ");
}
else if (isES6ExportedDeclaration(node)) {
@ -5530,7 +5530,9 @@ const _super = (function (geti, seti) {
//
// We'll emit:
//
// (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp)
// let C_1 = class C{};
// C_1.a = 1;
// C_1.b = 2; // so forth and so on
//
// This keeps the expression as an expression, while ensuring that the static parts
// of it have been initialized by the time it is used.
@ -6155,10 +6157,11 @@ const _super = (function (geti, seti) {
if (valueDeclaration) {
const parameters = valueDeclaration.parameters;
const skipThisCount = parameters.length && (<Identifier>parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword ? 1 : 0;
const parameterCount = parameters.length;
if (parameterCount > 0) {
for (let i = 0; i < parameterCount; i++) {
if (i > 0) {
if (parameterCount > skipThisCount) {
for (let i = skipThisCount; i < parameterCount; i++) {
if (i > skipThisCount) {
write(", ");
}

View File

@ -2,15 +2,21 @@
/// <reference path="scanner.ts"/>
namespace ts {
/* @internal */ export let parseTime = 0;
let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let IdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node {
if (kind === SyntaxKind.SourceFile) {
return new (SourceFileConstructor || (SourceFileConstructor = objectAllocator.getSourceFileConstructor()))(kind, pos, end);
}
else if (kind === SyntaxKind.Identifier) {
return new (IdentifierConstructor || (IdentifierConstructor = objectAllocator.getIdentifierConstructor()))(kind, pos, end);
}
else if (kind < SyntaxKind.FirstNode) {
return new (TokenConstructor || (TokenConstructor = objectAllocator.getTokenConstructor()))(kind, pos, end);
}
else {
return new (NodeConstructor || (NodeConstructor = objectAllocator.getNodeConstructor()))(kind, pos, end);
}
@ -413,10 +419,10 @@ namespace ts {
}
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile {
const start = new Date().getTime();
const start = performance.mark();
const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
parseTime += new Date().getTime() - start;
performance.measure("Parse", start);
return result;
}
@ -466,6 +472,8 @@ namespace ts {
// capture constructors in 'initializeState' to avoid null checks
let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let IdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
let sourceFile: SourceFile;
@ -576,6 +584,8 @@ namespace ts {
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
NodeConstructor = objectAllocator.getNodeConstructor();
TokenConstructor = objectAllocator.getTokenConstructor();
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
sourceText = _sourceText;
@ -1018,13 +1028,15 @@ namespace ts {
}
// note: this function creates only node
function createNode(kind: SyntaxKind, pos?: number): Node {
function createNode(kind: SyntaxKind, pos?: number): Node | Token | Identifier {
nodeCount++;
if (!(pos >= 0)) {
pos = scanner.getStartPos();
}
return new NodeConstructor(kind, pos, pos);
return kind >= SyntaxKind.FirstNode ? new NodeConstructor(kind, pos, pos) :
kind === SyntaxKind.Identifier ? new IdentifierConstructor(kind, pos, pos) :
new TokenConstructor(kind, pos, pos);
}
function finishNode<T extends Node>(node: T, end?: number): T {
@ -5096,7 +5108,7 @@ namespace ts {
}
flags |= modifierToFlag(modifierKind);
modifiers.push(finishNode(createNode(modifierKind, modifierStart)));
modifiers.push(finishNode(<Modifier>createNode(modifierKind, modifierStart)));
}
if (modifiers) {
modifiers.flags = flags;
@ -5115,7 +5127,7 @@ namespace ts {
modifiers = <ModifiersArray>[];
modifiers.pos = modifierStart;
flags |= modifierToFlag(modifierKind);
modifiers.push(finishNode(createNode(modifierKind, modifierStart)));
modifiers.push(finishNode(<Modifier>createNode(modifierKind, modifierStart)));
modifiers.flags = flags;
modifiers.end = scanner.getStartPos();
}

109
src/compiler/performance.ts Normal file
View File

@ -0,0 +1,109 @@
/*@internal*/
namespace ts {
declare const performance: { now?(): number } | undefined;
/** Gets a timestamp with (at least) ms resolution */
export const timestamp = typeof performance !== "undefined" && performance.now ? performance.now : Date.now ? Date.now : () => +(new Date());
}
/*@internal*/
namespace ts.performance {
/** Performance measurements for the compiler. */
declare const onProfilerEvent: { (markName: string): void; profiler: boolean; };
let profilerEvent: (markName: string) => void;
let counters: Map<number>;
let measures: Map<number>;
/**
* Emit a performance event if ts-profiler is connected. This is primarily used
* to generate heap snapshots.
*
* @param eventName A name for the event.
*/
export function emit(eventName: string) {
if (profilerEvent) {
profilerEvent(eventName);
}
}
/**
* Increments a counter with the specified name.
*
* @param counterName The name of the counter.
*/
export function increment(counterName: string) {
if (counters) {
counters[counterName] = (getProperty(counters, counterName) || 0) + 1;
}
}
/**
* Gets the value of the counter with the specified name.
*
* @param counterName The name of the counter.
*/
export function getCount(counterName: string) {
return counters && getProperty(counters, counterName) || 0;
}
/**
* Marks the start of a performance measurement.
*/
export function mark() {
return measures ? timestamp() : 0;
}
/**
* Adds a performance measurement with the specified name.
*
* @param measureName The name of the performance measurement.
* @param marker The timestamp of the starting mark.
*/
export function measure(measureName: string, marker: number) {
if (measures) {
measures[measureName] = (getProperty(measures, measureName) || 0) + (timestamp() - marker);
}
}
/**
* Iterate over each measure, performing some action
*
* @param cb The action to perform for each measure
*/
export function forEachMeasure(cb: (measureName: string, duration: number) => void) {
return forEachKey(measures, key => cb(key, measures[key]));
}
/**
* Gets the total duration of all measurements with the supplied name.
*
* @param measureName The name of the measure whose durations should be accumulated.
*/
export function getDuration(measureName: string) {
return measures && getProperty(measures, measureName) || 0;
}
/** Enables (and resets) performance measurements for the compiler. */
export function enable() {
counters = { };
measures = {
"I/O Read": 0,
"I/O Write": 0,
"Program": 0,
"Parse": 0,
"Bind": 0,
"Check": 0,
"Emit": 0,
};
profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true
? onProfilerEvent
: undefined;
}
/** Disables (and clears) performance measurements for the compiler. */
export function disable() {
counters = undefined;
measures = undefined;
profilerEvent = undefined;
}
}

View File

@ -3,11 +3,6 @@
/// <reference path="core.ts" />
namespace ts {
/* @internal */ export let programTime = 0;
/* @internal */ export let emitTime = 0;
/* @internal */ export let ioReadTime = 0;
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export const version = "2.1.0";
@ -112,13 +107,7 @@ namespace ts {
}
function moduleHasNonRelativeName(moduleName: string): boolean {
if (isRootedDiskPath(moduleName)) {
return false;
}
const i = moduleName.lastIndexOf("./", 1);
const startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === CharacterCodes.dot);
return !startsWithDotSlashOrDotDotSlash;
return !(isRootedDiskPath(moduleName) || isExternalModuleNameRelative(moduleName));
}
interface ModuleResolutionState {
@ -871,9 +860,9 @@ namespace ts {
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
let text: string;
try {
const start = new Date().getTime();
const start = performance.mark();
text = sys.readFile(fileName, options.charset);
ioReadTime += new Date().getTime() - start;
performance.measure("I/O Read", start);
}
catch (e) {
if (onError) {
@ -940,7 +929,7 @@ namespace ts {
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
try {
const start = new Date().getTime();
const start = performance.mark();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) {
@ -950,7 +939,7 @@ namespace ts {
sys.writeFile(fileName, data, writeByteOrderMark);
}
ioWriteTime += new Date().getTime() - start;
performance.measure("I/O Write", start);
}
catch (e) {
if (onError) {
@ -997,6 +986,29 @@ namespace ts {
return sortAndDeduplicateDiagnostics(diagnostics);
}
export interface FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
}
export function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string {
let output = "";
for (const diagnostic of diagnostics) {
if (diagnostic.file) {
const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
const fileName = diagnostic.file.fileName;
const relativeFileName = convertToRelativePath(fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName));
output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `;
}
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }${ host.getNewLine() }`;
}
return output;
}
export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string {
if (typeof messageText === "string") {
return messageText;
@ -1104,7 +1116,7 @@ namespace ts {
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
const sourceFilesFoundSearchingNodeModules: Map<boolean> = {};
const start = new Date().getTime();
const start = performance.mark();
host = host || createCompilerHost(options);
@ -1203,7 +1215,7 @@ namespace ts {
verifyCompilerOptions();
programTime += new Date().getTime() - start;
performance.measure("Program", start);
return program;
@ -1446,14 +1458,14 @@ namespace ts {
// checked is to not pass the file to getEmitResolver.
const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile);
const start = new Date().getTime();
const start = performance.mark();
const emitResult = emitFiles(
emitResolver,
getEmitHost(writeFileCallback),
sourceFile);
emitTime += new Date().getTime() - start;
performance.measure("Emit", start);
return emitResult;
}

View File

@ -240,6 +240,8 @@ namespace ts {
return;
}
const start = performance.mark();
const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos);
// Convert the location to be one-based.
@ -279,6 +281,8 @@ namespace ts {
}
updateLastEncodedAndRecordedSpans();
performance.measure("Source Map", start);
}
function getStartPos(range: TextRange) {

View File

@ -6,9 +6,19 @@ namespace ts {
fileWatcher?: FileWatcher;
}
let reportDiagnostic = reportDiagnosticSimply;
const defaultFormatDiagnosticsHost: FormatDiagnosticsHost = {
getCurrentDirectory: () => sys.getCurrentDirectory(),
getNewLine: () => sys.newLine,
getCanonicalFileName: createGetCanonicalFileName(sys.useCaseSensitiveFileNames)
};
function reportDiagnostics(diagnostics: Diagnostic[], host: CompilerHost): void {
let reportDiagnosticWorker = reportDiagnosticSimply;
function reportDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost) {
reportDiagnosticWorker(diagnostic, host || defaultFormatDiagnosticsHost);
}
function reportDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): void {
for (const diagnostic of diagnostics) {
reportDiagnostic(diagnostic, host);
}
@ -101,23 +111,8 @@ namespace ts {
return <string>diagnostic.messageText;
}
function getRelativeFileName(fileName: string, host: CompilerHost): string {
return host ? convertToRelativePath(fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : fileName;
}
function reportDiagnosticSimply(diagnostic: Diagnostic, host: CompilerHost): void {
let output = "";
if (diagnostic.file) {
const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
const relativeFileName = getRelativeFileName(diagnostic.file.fileName, host);
output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `;
}
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
sys.write(output);
function reportDiagnosticSimply(diagnostic: Diagnostic, host: FormatDiagnosticsHost): void {
sys.write(ts.formatDiagnostics([diagnostic], host));
}
const redForegroundEscapeSequence = "\u001b[91m";
@ -137,7 +132,7 @@ namespace ts {
return formatStyle + text + resetEscapeSequence;
}
function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic, host: CompilerHost): void {
function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic, host: FormatDiagnosticsHost): void {
let output = "";
if (diagnostic.file) {
@ -145,7 +140,7 @@ namespace ts {
const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start);
const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length);
const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line;
const relativeFileName = getRelativeFileName(file.fileName, host);
const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName;
const hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
let gutterWidth = (lastLine + 1 + "").length;
@ -272,7 +267,7 @@ namespace ts {
if (commandLine.options.locale) {
if (!isJSONSupported()) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
@ -303,11 +298,11 @@ namespace ts {
if (commandLine.options.project) {
if (!isJSONSupported()) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.fileNames.length !== 0) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
@ -315,14 +310,14 @@ namespace ts {
if (!fileOrDirectory /* current directory "." */ || sys.directoryExists(fileOrDirectory)) {
configFileName = combinePaths(fileOrDirectory, "tsconfig.json");
if (!sys.fileExists(configFileName)) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
}
else {
configFileName = fileOrDirectory;
if (!sys.fileExists(configFileName)) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
}
@ -340,7 +335,7 @@ namespace ts {
if (isWatchSet(commandLine.options)) {
if (!sys.watchFile) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* host */ undefined);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (configFileName) {
@ -385,7 +380,8 @@ namespace ts {
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
return;
}
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), sys.getCurrentDirectory()), commandLine.options, configFileName);
const cwd = sys.getCurrentDirectory();
const configParseResult = parseJsonConfigFileContent(configObject, sys, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), commandLine.options, getNormalizedAbsolutePath(configFileName, cwd));
if (configParseResult.errors.length > 0) {
reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined);
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
@ -393,7 +389,7 @@ namespace ts {
}
if (isWatchSet(configParseResult.options)) {
if (!sys.watchFile) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* host */ undefined);
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
@ -432,7 +428,7 @@ namespace ts {
}
if (compilerOptions.pretty) {
reportDiagnostic = reportDiagnosticWithColorAndContext;
reportDiagnosticWorker = reportDiagnosticWithColorAndContext;
}
// reset the cache of existing files
@ -554,12 +550,8 @@ namespace ts {
}
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
ioReadTime = 0;
ioWriteTime = 0;
programTime = 0;
bindTime = 0;
checkTime = 0;
emitTime = 0;
const hasDiagnostics = compilerOptions.diagnostics || compilerOptions.extendedDiagnostics;
if (hasDiagnostics) performance.enable();
const program = createProgram(fileNames, compilerOptions, compilerHost);
const exitStatus = compileProgram();
@ -570,7 +562,7 @@ namespace ts {
});
}
if (compilerOptions.diagnostics) {
if (hasDiagnostics) {
const memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
reportCountStatistic("Files", program.getSourceFiles().length);
reportCountStatistic("Lines", countLines(program));
@ -583,17 +575,28 @@ namespace ts {
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
}
// Individual component times.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
reportTimeStatistic("I/O read", ioReadTime);
reportTimeStatistic("I/O write", ioWriteTime);
reportTimeStatistic("Parse time", programTime);
reportTimeStatistic("Bind time", bindTime);
reportTimeStatistic("Check time", checkTime);
reportTimeStatistic("Emit time", emitTime);
const programTime = performance.getDuration("Program");
const bindTime = performance.getDuration("Bind");
const checkTime = performance.getDuration("Check");
const emitTime = performance.getDuration("Emit");
if (compilerOptions.extendedDiagnostics) {
performance.forEachMeasure((name, duration) => reportTimeStatistic(`${name} time`, duration));
}
else {
// Individual component times.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
reportTimeStatistic("I/O read", performance.getDuration("I/O Read"));
reportTimeStatistic("I/O write", performance.getDuration("I/O Write"));
reportTimeStatistic("Parse time", programTime);
reportTimeStatistic("Bind time", bindTime);
reportTimeStatistic("Check time", checkTime);
reportTimeStatistic("Emit time", emitTime);
}
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
performance.disable();
}
return { program, exitStatus };
@ -657,7 +660,7 @@ namespace ts {
// Build up the list of examples.
const padding = makePadding(marginLength);
output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine;
output += padding + "tsc --out file.js file.ts" + sys.newLine;
output += padding + "tsc --outFile file.js file.ts" + sys.newLine;
output += padding + "tsc @args.txt" + sys.newLine;
output += sys.newLine;
@ -757,7 +760,7 @@ namespace ts {
const currentDirectory = sys.getCurrentDirectory();
const file = normalizePath(combinePaths(currentDirectory, "tsconfig.json"));
if (sys.fileExists(file)) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined);
}
else {
const compilerOptions = extend(options, defaultInitCompilerOptions);
@ -777,7 +780,7 @@ namespace ts {
}
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* compilerHost */ undefined);
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined);
}
return;

View File

@ -12,6 +12,7 @@
},
"files": [
"core.ts",
"performance.ts",
"sys.ts",
"types.ts",
"scanner.ts",

View File

@ -472,6 +472,10 @@ namespace ts {
flags: NodeFlags;
}
export interface Token extends Node {
__tokenTag: any;
}
// @kind(SyntaxKind.AbstractKeyword)
// @kind(SyntaxKind.AsyncKeyword)
// @kind(SyntaxKind.ConstKeyword)
@ -482,7 +486,7 @@ namespace ts {
// @kind(SyntaxKind.PrivateKeyword)
// @kind(SyntaxKind.ProtectedKeyword)
// @kind(SyntaxKind.StaticKeyword)
export interface Modifier extends Node { }
export interface Modifier extends Token { }
// @kind(SyntaxKind.Identifier)
export interface Identifier extends PrimaryExpression {
@ -2535,6 +2539,7 @@ namespace ts {
declaration?: boolean;
declarationDir?: string;
/* @internal */ diagnostics?: boolean;
/* @internal */ extendedDiagnostics?: boolean;
disableSizeLimit?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
@ -2908,7 +2913,6 @@ namespace ts {
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
getDefaultLibLocation?(): string;
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];

View File

@ -1218,7 +1218,7 @@ namespace ts {
export function isExternalModuleNameRelative(moduleName: string): boolean {
// TypeScript 1.0 spec (April 2014): 11.2.1
// An external module name is "relative" if the first term is "." or "..".
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\";
return /^\.\.?($|[\\/])/.test(moduleName);
}
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
@ -3113,13 +3113,4 @@ namespace ts {
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
return node.flags & NodeFlags.ParameterPropertyModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
}
export function startsWith(str: string, prefix: string): boolean {
return str.lastIndexOf(prefix, 0) === 0;
}
export function endsWith(str: string, suffix: string): boolean {
const expectedPos = str.length - suffix.length;
return str.indexOf(suffix, expectedPos) === expectedPos;
}
}

View File

@ -50,7 +50,9 @@ class CompilerBaselineRunner extends RunnerBase {
}
private makeUnitName(name: string, root: string) {
return ts.isRootedDiskPath(name) ? name : ts.combinePaths(root, name);
const path = ts.toPath(name, root, (fileName) => Harness.Compiler.getCanonicalFileName(fileName));
const pathStart = ts.toPath(Harness.IO.getCurrentDirectory(), "", (fileName) => Harness.Compiler.getCanonicalFileName(fileName));
return path.replace(pathStart, "/");
};
public checkTestCodeOutput(fileName: string) {

View File

@ -1377,31 +1377,27 @@ namespace Harness {
writeByteOrderMark: boolean;
}
function stringEndsWith(str: string, end: string) {
return str.substr(str.length - end.length) === end;
}
export function isTS(fileName: string) {
return stringEndsWith(fileName, ".ts");
return ts.endsWith(fileName, ".ts");
}
export function isTSX(fileName: string) {
return stringEndsWith(fileName, ".tsx");
return ts.endsWith(fileName, ".tsx");
}
export function isDTS(fileName: string) {
return stringEndsWith(fileName, ".d.ts");
return ts.endsWith(fileName, ".d.ts");
}
export function isJS(fileName: string) {
return stringEndsWith(fileName, ".js");
return ts.endsWith(fileName, ".js");
}
export function isJSX(fileName: string) {
return stringEndsWith(fileName, ".jsx");
return ts.endsWith(fileName, ".jsx");
}
export function isJSMap(fileName: string) {
return stringEndsWith(fileName, ".js.map") || stringEndsWith(fileName, ".jsx.map");
return ts.endsWith(fileName, ".js.map") || ts.endsWith(fileName, ".jsx.map");
}
/** Contains the code and errors of a compilation and some helper methods to check its status. */

View File

@ -328,7 +328,7 @@ class ProjectRunner extends RunnerBase {
if (Harness.Compiler.isJS(fileName)) {
// Make sure if there is URl we have it cleaned up
const indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
const indexOfSourceMapUrl = data.lastIndexOf(`//# ${"sourceMappingURL"}=`); // This line can be seen as a sourceMappingURL comment
if (indexOfSourceMapUrl !== -1) {
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
}

View File

@ -14,6 +14,7 @@
},
"files": [
"../compiler/core.ts",
"../compiler/performance.ts",
"../compiler/sys.ts",
"../compiler/types.ts",
"../compiler/scanner.ts",

4
src/lib/es5.d.ts vendored
View File

@ -513,8 +513,8 @@ interface NumberConstructor {
/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */
declare const Number: NumberConstructor;
interface TemplateStringsArray extends Array<string> {
readonly raw: string[];
interface TemplateStringsArray extends ReadonlyArray<string> {
readonly raw: ReadonlyArray<string>
}
interface Math {

View File

@ -514,16 +514,6 @@ namespace ts {
return str === str.toLowerCase();
}
function startsWith(string: string, search: string) {
for (let i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
}
return true;
}
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(string: string, value: string): number {
for (let i = 0, n = string.length - value.length; i <= n; i++) {

View File

@ -94,7 +94,7 @@ namespace ts {
* change range cannot be determined. However, in that case, incremental parsing will
* not happen and the entire document will be re - parsed.
*/
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined;
/** Releases all resources held by this script snapshot */
dispose?(): void;
@ -180,9 +180,10 @@ namespace ts {
];
let jsDocCompletionEntries: CompletionEntry[];
function createNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags, parent?: Node): NodeObject {
const node = new NodeObject(kind, pos, end);
node.flags = flags;
function createNode(kind: SyntaxKind, pos: number, end: number, parent?: Node): NodeObject | TokenObject | IdentifierObject {
const node = kind >= SyntaxKind.FirstNode ? new NodeObject(kind, pos, end) :
kind === SyntaxKind.Identifier ? new IdentifierObject(kind, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
return node;
}
@ -197,11 +198,11 @@ namespace ts {
private _children: Node[];
constructor(kind: SyntaxKind, pos: number, end: number) {
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = NodeFlags.None;
this.parent = undefined;
this.kind = kind;
}
public getSourceFile(): SourceFile {
@ -246,7 +247,7 @@ namespace ts {
const token = useJSDocScanner ? scanner.scanJSDocToken() : scanner.scan();
const textPos = scanner.getTextPos();
if (textPos <= end) {
nodes.push(createNode(token, pos, textPos, 0, this));
nodes.push(createNode(token, pos, textPos, this));
}
pos = textPos;
}
@ -254,7 +255,7 @@ namespace ts {
}
private createSyntaxList(nodes: NodeArray<Node>): Node {
const list = createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, 0, this);
const list = <NodeObject>createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, this);
list._children = [];
let pos = nodes.pos;
@ -345,6 +346,95 @@ namespace ts {
}
}
class TokenOrIdentifierObject implements Token {
public kind: SyntaxKind;
public pos: number;
public end: number;
public flags: NodeFlags;
public parent: Node;
public jsDocComments: JSDocComment[];
public __tokenTag: any;
constructor(pos: number, end: number) {
// Set properties in same order as NodeObject
this.pos = pos;
this.end = end;
this.flags = NodeFlags.None;
this.parent = undefined;
}
public getSourceFile(): SourceFile {
return getSourceFileOfNode(this);
}
public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number {
return getTokenPosOfNode(this, sourceFile, includeJsDocComment);
}
public getFullStart(): number {
return this.pos;
}
public getEnd(): number {
return this.end;
}
public getWidth(sourceFile?: SourceFile): number {
return this.getEnd() - this.getStart(sourceFile);
}
public getFullWidth(): number {
return this.end - this.pos;
}
public getLeadingTriviaWidth(sourceFile?: SourceFile): number {
return this.getStart(sourceFile) - this.pos;
}
public getFullText(sourceFile?: SourceFile): string {
return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end);
}
public getText(sourceFile?: SourceFile): string {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
}
public getChildCount(sourceFile?: SourceFile): number {
return 0;
}
public getChildAt(index: number, sourceFile?: SourceFile): Node {
return undefined;
}
public getChildren(sourceFile?: SourceFile): Node[] {
return emptyArray;
}
public getFirstToken(sourceFile?: SourceFile): Node {
return undefined;
}
public getLastToken(sourceFile?: SourceFile): Node {
return undefined;
}
}
class TokenObject extends TokenOrIdentifierObject {
public kind: SyntaxKind;
constructor(kind: SyntaxKind, pos: number, end: number) {
super(pos, end);
this.kind = kind;
}
}
class IdentifierObject extends TokenOrIdentifierObject {
constructor(kind: SyntaxKind, pos: number, end: number) {
super(pos, end);
}
}
IdentifierObject.prototype.kind = SyntaxKind.Identifier;
class SymbolObject implements Symbol {
flags: SymbolFlags;
name: string;
@ -3259,14 +3349,14 @@ namespace ts {
let isJsDocTagName = false;
let start = new Date().getTime();
let start = timestamp();
const currentToken = getTokenAtPosition(sourceFile, position);
log("getCompletionData: Get current token: " + (new Date().getTime() - start));
log("getCompletionData: Get current token: " + (timestamp() - start));
start = new Date().getTime();
start = timestamp();
// Completion not allowed inside comments, bail out if this is the case
const insideComment = isInsideComment(sourceFile, currentToken, position);
log("getCompletionData: Is inside comment: " + (new Date().getTime() - start));
log("getCompletionData: Is inside comment: " + (timestamp() - start));
if (insideComment) {
// The current position is next to the '@' sign, when no tag name being provided yet.
@ -3309,9 +3399,9 @@ namespace ts {
}
}
start = new Date().getTime();
start = timestamp();
const previousToken = findPrecedingToken(position, sourceFile);
log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start));
log("getCompletionData: Get previous token 1: " + (timestamp() - start));
// The decision to provide completion depends on the contextToken, which is determined through the previousToken.
// Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file
@ -3320,9 +3410,9 @@ namespace ts {
// Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
// Skip this partial identifier and adjust the contextToken to the token that precedes it.
if (contextToken && position <= contextToken.end && isWord(contextToken.kind)) {
const start = new Date().getTime();
const start = timestamp();
contextToken = findPrecedingToken(contextToken.getFullStart(), sourceFile);
log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start));
log("getCompletionData: Get previous token 2: " + (timestamp() - start));
}
// Find the node where completion is requested on.
@ -3369,7 +3459,7 @@ namespace ts {
}
}
const semanticStart = new Date().getTime();
const semanticStart = timestamp();
let isMemberCompletion: boolean;
let isNewIdentifierLocation: boolean;
let symbols: Symbol[] = [];
@ -3407,7 +3497,7 @@ namespace ts {
}
}
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName };
@ -3551,12 +3641,12 @@ namespace ts {
}
function isCompletionListBlocker(contextToken: Node): boolean {
const start = new Date().getTime();
const start = timestamp();
const result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) ||
isSolelyIdentifierDefinitionLocation(contextToken) ||
isDotOfNumericLiteral(contextToken) ||
isInJsxText(contextToken);
log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start));
log("getCompletionsAtPosition: isCompletionListBlocker: " + (timestamp() - start));
return result;
}
@ -4206,10 +4296,11 @@ namespace ts {
kindModifiers: getSymbolModifiers(symbol),
sortText: "0",
};
}
function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[], location: Node, performCharacterChecks: boolean): Map<string> {
const start = new Date().getTime();
const start = timestamp();
const uniqueNames: Map<string> = {};
if (symbols) {
for (const symbol of symbols) {
@ -4224,7 +4315,7 @@ namespace ts {
}
}
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start));
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start));
return uniqueNames;
}
@ -4234,22 +4325,58 @@ namespace ts {
return undefined;
}
const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile);
if (argumentInfo) {
// Get string literal completions from specialized signatures of the target
return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo);
if (node.parent.kind === SyntaxKind.PropertyAssignment && node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression) {
// Get quoted name of properties of the object literal expression
// i.e. interface ConfigFiles {
// 'jspm:dev': string
// }
// let files: ConfigFiles = {
// '/*completion position*/'
// }
//
// function foo(c: ConfigFiles) {}
// foo({
// '/*completion position*/'
// });
return getStringLiteralCompletionEntriesFromPropertyAssignment(<ObjectLiteralElement>node.parent);
}
else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) {
// Get all names of properties on the expression
// i.e. interface A {
// 'prop1': string
// }
// let a: A;
// a['/*completion position*/']
return getStringLiteralCompletionEntriesFromElementAccess(node.parent);
}
else {
// Otherwise, get the completions from the contextual type if one exists
const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile);
if (argumentInfo) {
// Get string literal completions from specialized signatures of the target
// i.e. declare function f(a: 'A');
// f("/*completion position*/")
return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node);
}
// Get completion for string literal from string literal type
// i.e. var x: "hi" | "hello" = "/*completion position*/"
return getStringLiteralCompletionEntriesFromContextualType(<StringLiteral>node);
}
}
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) {
function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement) {
const typeChecker = program.getTypeChecker();
const type = typeChecker.getContextualType((<ObjectLiteralExpression>element.parent));
const entries: CompletionEntry[] = [];
if (type) {
getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false);
if (entries.length) {
return { isMemberCompletion: true, isNewIdentifierLocation: true, entries };
}
}
}
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, location: Node) {
const typeChecker = program.getTypeChecker();
const candidates: Signature[] = [];
const entries: CompletionEntry[] = [];
@ -7645,14 +7772,14 @@ namespace ts {
}
function getIndentationAtPosition(fileName: string, position: number, editorOptions: EditorOptions) {
let start = new Date().getTime();
let start = timestamp();
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start));
log("getIndentationAtPosition: getCurrentSourceFile: " + (timestamp() - start));
start = new Date().getTime();
start = timestamp();
const result = formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions);
log("getIndentationAtPosition: computeIndentation : " + (new Date().getTime() - start));
log("getIndentationAtPosition: computeIndentation : " + (timestamp() - start));
return result;
}
@ -8694,6 +8821,8 @@ namespace ts {
function initializeServices() {
objectAllocator = {
getNodeConstructor: () => NodeObject,
getTokenConstructor: () => TokenObject,
getIdentifierConstructor: () => IdentifierObject,
getSourceFileConstructor: () => SourceFileObject,
getSymbolConstructor: () => SymbolObject,
getTypeConstructor: () => TypeObject,

View File

@ -423,7 +423,7 @@ namespace ts {
}
public isCancellationRequested(): boolean {
const time = Date.now();
const time = timestamp();
const duration = Math.abs(time - this.lastCancellationCheckTime);
if (duration > 10) {
// Check no more than once every 10 ms.
@ -498,13 +498,13 @@ namespace ts {
let start: number;
if (logPerformance) {
logger.log(actionDescription);
start = Date.now();
start = timestamp();
}
const result = action();
if (logPerformance) {
const end = Date.now();
const end = timestamp();
logger.log(`${actionDescription} completed in ${end - start} msec`);
if (typeof result === "string") {
let str = result;

View File

@ -13,6 +13,7 @@
},
"files": [
"../compiler/core.ts",
"../compiler/performance.ts",
"../compiler/sys.ts",
"../compiler/types.ts",
"../compiler/scanner.ts",

View File

@ -0,0 +1,28 @@
//// [decoratedClassExportsCommonJS1.ts]
declare var Something: any;
@Something({ v: () => Testing123 })
export class Testing123 {
static prop0: string;
static prop1 = Testing123.prop0;
}
//// [decoratedClassExportsCommonJS1.js]
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let Testing123_1 = class Testing123 {
};
let Testing123 = Testing123_1;
Testing123.prop1 = Testing123.prop0;
Testing123 = Testing123_1 = __decorate([
Something({ v: () => Testing123 }),
__metadata('design:paramtypes', [])
], Testing123);
exports.Testing123 = Testing123;

View File

@ -0,0 +1,21 @@
=== tests/cases/conformance/decorators/class/decoratedClassExportsCommonJS1.ts ===
declare var Something: any;
>Something : Symbol(Something, Decl(decoratedClassExportsCommonJS1.ts, 0, 11))
@Something({ v: () => Testing123 })
>Something : Symbol(Something, Decl(decoratedClassExportsCommonJS1.ts, 0, 11))
>v : Symbol(v, Decl(decoratedClassExportsCommonJS1.ts, 1, 12))
>Testing123 : Symbol(Testing123, Decl(decoratedClassExportsCommonJS1.ts, 0, 27))
export class Testing123 {
>Testing123 : Symbol(Testing123, Decl(decoratedClassExportsCommonJS1.ts, 0, 27))
static prop0: string;
>prop0 : Symbol(Testing123.prop0, Decl(decoratedClassExportsCommonJS1.ts, 2, 25))
static prop1 = Testing123.prop0;
>prop1 : Symbol(Testing123.prop1, Decl(decoratedClassExportsCommonJS1.ts, 3, 25))
>Testing123.prop0 : Symbol(Testing123.prop0, Decl(decoratedClassExportsCommonJS1.ts, 2, 25))
>Testing123 : Symbol(Testing123, Decl(decoratedClassExportsCommonJS1.ts, 0, 27))
>prop0 : Symbol(Testing123.prop0, Decl(decoratedClassExportsCommonJS1.ts, 2, 25))
}

View File

@ -0,0 +1,24 @@
=== tests/cases/conformance/decorators/class/decoratedClassExportsCommonJS1.ts ===
declare var Something: any;
>Something : any
@Something({ v: () => Testing123 })
>Something({ v: () => Testing123 }) : any
>Something : any
>{ v: () => Testing123 } : { v: () => typeof Testing123; }
>v : () => typeof Testing123
>() => Testing123 : () => typeof Testing123
>Testing123 : typeof Testing123
export class Testing123 {
>Testing123 : Testing123
static prop0: string;
>prop0 : string
static prop1 = Testing123.prop0;
>prop1 : string
>Testing123.prop0 : string
>Testing123 : typeof Testing123
>prop0 : string
}

View File

@ -0,0 +1,26 @@
//// [a.ts]
declare function forwardRef(x: any): any;
declare var Something: any;
@Something({ v: () => Testing123 })
export class Testing123 { }
//// [a.js]
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let Testing123_1 = class Testing123 {
};
let Testing123 = Testing123_1;
Testing123 = Testing123_1 = __decorate([
Something({ v: () => Testing123 }),
__metadata('design:paramtypes', [])
], Testing123);
exports.Testing123 = Testing123;

View File

@ -0,0 +1,17 @@
=== tests/cases/conformance/decorators/class/a.ts ===
declare function forwardRef(x: any): any;
>forwardRef : Symbol(forwardRef, Decl(a.ts, 0, 0))
>x : Symbol(x, Decl(a.ts, 1, 28))
declare var Something: any;
>Something : Symbol(Something, Decl(a.ts, 2, 11))
@Something({ v: () => Testing123 })
>Something : Symbol(Something, Decl(a.ts, 2, 11))
>v : Symbol(v, Decl(a.ts, 3, 12))
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))
export class Testing123 { }
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))

View File

@ -0,0 +1,20 @@
=== tests/cases/conformance/decorators/class/a.ts ===
declare function forwardRef(x: any): any;
>forwardRef : (x: any) => any
>x : any
declare var Something: any;
>Something : any
@Something({ v: () => Testing123 })
>Something({ v: () => Testing123 }) : any
>Something : any
>{ v: () => Testing123 } : { v: () => typeof Testing123; }
>v : () => typeof Testing123
>() => Testing123 : () => typeof Testing123
>Testing123 : typeof Testing123
export class Testing123 { }
>Testing123 : Testing123

View File

@ -0,0 +1,39 @@
//// [a.ts]
declare function forwardRef(x: any): any;
declare var Something: any;
@Something({ v: () => Testing123 })
export class Testing123 {
static prop0: string;
static prop1 = Testing123.prop0;
}
//// [a.js]
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var Testing123;
return {
setters:[],
execute: function() {
let Testing123_1 = class Testing123 {
};
let Testing123 = Testing123_1;
Testing123.prop1 = Testing123.prop0;
Testing123 = Testing123_1 = __decorate([
Something({ v: () => Testing123 }),
__metadata('design:paramtypes', [])
], Testing123);
exports_1("Testing123", Testing123);
}
}
});

View File

@ -0,0 +1,26 @@
=== tests/cases/conformance/decorators/class/a.ts ===
declare function forwardRef(x: any): any;
>forwardRef : Symbol(forwardRef, Decl(a.ts, 0, 0))
>x : Symbol(x, Decl(a.ts, 1, 28))
declare var Something: any;
>Something : Symbol(Something, Decl(a.ts, 2, 11))
@Something({ v: () => Testing123 })
>Something : Symbol(Something, Decl(a.ts, 2, 11))
>v : Symbol(v, Decl(a.ts, 3, 12))
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))
export class Testing123 {
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))
static prop0: string;
>prop0 : Symbol(Testing123.prop0, Decl(a.ts, 4, 25))
static prop1 = Testing123.prop0;
>prop1 : Symbol(Testing123.prop1, Decl(a.ts, 5, 25))
>Testing123.prop0 : Symbol(Testing123.prop0, Decl(a.ts, 4, 25))
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))
>prop0 : Symbol(Testing123.prop0, Decl(a.ts, 4, 25))
}

View File

@ -0,0 +1,29 @@
=== tests/cases/conformance/decorators/class/a.ts ===
declare function forwardRef(x: any): any;
>forwardRef : (x: any) => any
>x : any
declare var Something: any;
>Something : any
@Something({ v: () => Testing123 })
>Something({ v: () => Testing123 }) : any
>Something : any
>{ v: () => Testing123 } : { v: () => typeof Testing123; }
>v : () => typeof Testing123
>() => Testing123 : () => typeof Testing123
>Testing123 : typeof Testing123
export class Testing123 {
>Testing123 : Testing123
static prop0: string;
>prop0 : string
static prop1 = Testing123.prop0;
>prop1 : string
>Testing123.prop0 : string
>Testing123 : typeof Testing123
>prop0 : string
}

View File

@ -0,0 +1,35 @@
//// [a.ts]
declare function forwardRef(x: any): any;
declare var Something: any;
@Something({ v: () => Testing123 })
export class Testing123 { }
//// [a.js]
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var Testing123;
return {
setters:[],
execute: function() {
let Testing123_1 = class Testing123 {
};
let Testing123 = Testing123_1;
Testing123 = Testing123_1 = __decorate([
Something({ v: () => Testing123 }),
__metadata('design:paramtypes', [])
], Testing123);
exports_1("Testing123", Testing123);
}
}
});

View File

@ -0,0 +1,17 @@
=== tests/cases/conformance/decorators/class/a.ts ===
declare function forwardRef(x: any): any;
>forwardRef : Symbol(forwardRef, Decl(a.ts, 0, 0))
>x : Symbol(x, Decl(a.ts, 1, 28))
declare var Something: any;
>Something : Symbol(Something, Decl(a.ts, 2, 11))
@Something({ v: () => Testing123 })
>Something : Symbol(Something, Decl(a.ts, 2, 11))
>v : Symbol(v, Decl(a.ts, 3, 12))
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))
export class Testing123 { }
>Testing123 : Symbol(Testing123, Decl(a.ts, 2, 27))

View File

@ -0,0 +1,20 @@
=== tests/cases/conformance/decorators/class/a.ts ===
declare function forwardRef(x: any): any;
>forwardRef : (x: any) => any
>x : any
declare var Something: any;
>Something : any
@Something({ v: () => Testing123 })
>Something({ v: () => Testing123 }) : any
>Something : any
>{ v: () => Testing123 } : { v: () => typeof Testing123; }
>v : () => typeof Testing123
>() => Testing123 : () => typeof Testing123
>Testing123 : typeof Testing123
export class Testing123 { }
>Testing123 : Testing123

View File

@ -14,7 +14,7 @@ class A {
class B {
constructor(...args: number[]) {}
@MyMethodDecorator
method(...args: string[]) {}
method(this: this, ...args: string[]) {}
}

View File

@ -37,8 +37,9 @@ class B {
@MyMethodDecorator
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
method(...args: string[]) {}
method(this: this, ...args: string[]) {}
>method : Symbol(B.method, Decl(emitDecoratorMetadata_restArgs.ts, 13, 37))
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 15, 11))
>this : Symbol(this, Decl(emitDecoratorMetadata_restArgs.ts, 15, 11))
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 15, 22))
}

View File

@ -37,8 +37,9 @@ class B {
@MyMethodDecorator
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
method(...args: string[]) {}
>method : (...args: string[]) => void
method(this: this, ...args: string[]) {}
>method : (this: this, ...args: string[]) => void
>this : this
>args : string[]
}

View File

@ -0,0 +1,18 @@
//// [emitSkipsThisWithRestParameter.ts]
function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any {
return function(this: any, ...args: any[]) {
return fn.apply(this, [ this ].concat(args));
};
}
//// [emitSkipsThisWithRestParameter.js]
function rebase(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
return fn.apply(this, [this].concat(args));
};
}

View File

@ -0,0 +1,25 @@
=== tests/cases/compiler/emitSkipsThisWithRestParameter.ts ===
function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any {
>rebase : Symbol(rebase, Decl(emitSkipsThisWithRestParameter.ts, 0, 0))
>fn : Symbol(fn, Decl(emitSkipsThisWithRestParameter.ts, 0, 16))
>base : Symbol(base, Decl(emitSkipsThisWithRestParameter.ts, 0, 21))
>args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 0, 31))
>args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 0, 58))
return function(this: any, ...args: any[]) {
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
>args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 1, 30))
return fn.apply(this, [ this ].concat(args));
>fn.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(emitSkipsThisWithRestParameter.ts, 0, 16))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
>[ this ].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>this : Symbol(this, Decl(emitSkipsThisWithRestParameter.ts, 1, 20))
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --))
>args : Symbol(args, Decl(emitSkipsThisWithRestParameter.ts, 1, 30))
};
}

View File

@ -0,0 +1,29 @@
=== tests/cases/compiler/emitSkipsThisWithRestParameter.ts ===
function rebase(fn: (base: any, ...args: any[]) => any): (...args: any[]) => any {
>rebase : (fn: (base: any, ...args: any[]) => any) => (...args: any[]) => any
>fn : (base: any, ...args: any[]) => any
>base : any
>args : any[]
>args : any[]
return function(this: any, ...args: any[]) {
>function(this: any, ...args: any[]) { return fn.apply(this, [ this ].concat(args)); } : (this: any, ...args: any[]) => any
>this : any
>args : any[]
return fn.apply(this, [ this ].concat(args));
>fn.apply(this, [ this ].concat(args)) : any
>fn.apply : (this: Function, thisArg: any, argArray?: any) => any
>fn : (base: any, ...args: any[]) => any
>apply : (this: Function, thisArg: any, argArray?: any) => any
>this : any
>[ this ].concat(args) : any[]
>[ this ].concat : (...items: any[]) => any[]
>[ this ] : any[]
>this : any
>concat : (...items: any[]) => any[]
>args : any[]
};
}

View File

@ -0,0 +1,9 @@
=== tests/cases/compiler/test.d.ts ===
declare var S: typeof A; // no error
>S : Symbol(S, Decl(test.d.ts, 1, 11))
>A : Symbol(A, Decl(test.d.ts, 2, 13))
declare const A: number;
>A : Symbol(A, Decl(test.d.ts, 2, 13))

View File

@ -0,0 +1,9 @@
=== tests/cases/compiler/test.d.ts ===
declare var S: typeof A; // no error
>S : number
>A : number
declare const A: number;
>A : number

View File

@ -0,0 +1,42 @@
//// [tests/cases/compiler/relativeModuleWithoutSlash.ts] ////
//// [a.ts]
export default { a: 0 };
//// [index.ts]
export default { aIndex: 0 };
//// [test.ts]
import a from ".";
import aIndex from "./";
a.a;
aIndex.a; //aIndex.aIndex; See GH#9690
//// [test.ts]
import a from "..";
import aIndex from "../";
a.a;
aIndex.a; //aIndex.aIndex;
//// [a.js]
"use strict";
exports.__esModule = true;
exports["default"] = { a: 0 };
//// [index.js]
"use strict";
exports.__esModule = true;
exports["default"] = { aIndex: 0 };
//// [test.js]
"use strict";
var _1 = require(".");
var _2 = require("./");
_1["default"].a;
_2["default"].a; //aIndex.aIndex; See GH#9690
//// [test.js]
"use strict";
var __1 = require("..");
var _1 = require("../");
__1["default"].a;
_1["default"].a; //aIndex.aIndex;

View File

@ -0,0 +1,43 @@
=== /a.ts ===
export default { a: 0 };
>a : Symbol(a, Decl(a.ts, 1, 16))
=== /a/index.ts ===
export default { aIndex: 0 };
>aIndex : Symbol(aIndex, Decl(index.ts, 0, 16))
=== /a/test.ts ===
import a from ".";
>a : Symbol(a, Decl(test.ts, 0, 6))
import aIndex from "./";
>aIndex : Symbol(aIndex, Decl(test.ts, 1, 6))
a.a;
>a.a : Symbol(a, Decl(a.ts, 1, 16))
>a : Symbol(a, Decl(test.ts, 0, 6))
>a : Symbol(a, Decl(a.ts, 1, 16))
aIndex.a; //aIndex.aIndex; See GH#9690
>aIndex.a : Symbol(a, Decl(a.ts, 1, 16))
>aIndex : Symbol(aIndex, Decl(test.ts, 1, 6))
>a : Symbol(a, Decl(a.ts, 1, 16))
=== /a/b/test.ts ===
import a from "..";
>a : Symbol(a, Decl(test.ts, 0, 6))
import aIndex from "../";
>aIndex : Symbol(aIndex, Decl(test.ts, 1, 6))
a.a;
>a.a : Symbol(a, Decl(a.ts, 1, 16))
>a : Symbol(a, Decl(test.ts, 0, 6))
>a : Symbol(a, Decl(a.ts, 1, 16))
aIndex.a; //aIndex.aIndex;
>aIndex.a : Symbol(a, Decl(a.ts, 1, 16))
>aIndex : Symbol(aIndex, Decl(test.ts, 1, 6))
>a : Symbol(a, Decl(a.ts, 1, 16))

View File

@ -0,0 +1,26 @@
[
"======== Resolving module '.' from '/a/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a'.",
"File '/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a.ts', result '/a.ts'",
"======== Module name '.' was successfully resolved to '/a.ts'. ========",
"======== Resolving module './' from '/a/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a'.",
"File '/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a.ts', result '/a.ts'",
"======== Module name './' was successfully resolved to '/a.ts'. ========",
"======== Resolving module '..' from '/a/b/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a'.",
"File '/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a.ts', result '/a.ts'",
"======== Module name '..' was successfully resolved to '/a.ts'. ========",
"======== Resolving module '../' from '/a/b/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a'.",
"File '/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a.ts', result '/a.ts'",
"======== Module name '../' was successfully resolved to '/a.ts'. ========"
]

View File

@ -0,0 +1,47 @@
=== /a.ts ===
export default { a: 0 };
>{ a: 0 } : { a: number; }
>a : number
>0 : number
=== /a/index.ts ===
export default { aIndex: 0 };
>{ aIndex: 0 } : { aIndex: number; }
>aIndex : number
>0 : number
=== /a/test.ts ===
import a from ".";
>a : { a: number; }
import aIndex from "./";
>aIndex : { a: number; }
a.a;
>a.a : number
>a : { a: number; }
>a : number
aIndex.a; //aIndex.aIndex; See GH#9690
>aIndex.a : number
>aIndex : { a: number; }
>a : number
=== /a/b/test.ts ===
import a from "..";
>a : { a: number; }
import aIndex from "../";
>aIndex : { a: number; }
a.a;
>a.a : number
>a : { a: number; }
>a : number
aIndex.a; //aIndex.aIndex;
>aIndex.a : number
>aIndex : { a: number; }
>a : number

View File

@ -13,60 +13,60 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
noParams ``;
// Generic tag with parameter which does not use type parameter
function noGenericParams<T>(n: string[]) { }
function noGenericParams<T>(n: TemplateStringsArray) { }
noGenericParams ``;
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a<T, U>(n: T, m: number) { }
someGenerics1a `${3}`;
function someGenerics1b<T, U>(n: string[], m: U) { }
function someGenerics1b<T, U>(n: TemplateStringsArray, m: U) { }
someGenerics1b `${3}`;
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
function someGenerics2a<T>(strs: TemplateStringsArray, n: (x: T) => void) { }
someGenerics2a `${(n: string) => n}`;
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
function someGenerics2b<T, U>(strs: TemplateStringsArray, n: (x: T, y: U) => void) { }
someGenerics2b `${ (n: string, x: number) => n }`;
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(strs: string[], producer: () => T) { }
function someGenerics3<T>(strs: TemplateStringsArray, producer: () => T) { }
someGenerics3 `${() => ''}`;
someGenerics3 `${() => undefined}`;
someGenerics3 `${() => 3}`;
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics4<T, U>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics4 `${4}${ () => null }`;
someGenerics4 `${''}${ () => 3 }`;
someGenerics4 `${ null }${ null }`;
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics5<U, T>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics5 `${ 4 } ${ () => null }`;
someGenerics5 `${ '' }${ () => 3 }`;
someGenerics5 `${null}${null}`;
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
function someGenerics6<A>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
function someGenerics7<A, B, C>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
// Generic tag with argument of generic function type
function someGenerics8<T>(strs: string[], n: T): T { return n; }
function someGenerics8<T>(strs: TemplateStringsArray, n: T): T { return n; }
var x = someGenerics8 `${ someGenerics7 }`;
x `${null}${null}${null}`;
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
function someGenerics9<T>(strs: TemplateStringsArray, a: T, b: T, c: T): T {
return null;
}
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;

View File

@ -6,60 +6,60 @@ function noParams<T>(n: T) { }
noParams ``;
// Generic tag with parameter which does not use type parameter
function noGenericParams<T>(n: string[]) { }
function noGenericParams<T>(n: TemplateStringsArray) { }
noGenericParams ``;
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a<T, U>(n: T, m: number) { }
someGenerics1a `${3}`;
function someGenerics1b<T, U>(n: string[], m: U) { }
function someGenerics1b<T, U>(n: TemplateStringsArray, m: U) { }
someGenerics1b `${3}`;
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
function someGenerics2a<T>(strs: TemplateStringsArray, n: (x: T) => void) { }
someGenerics2a `${(n: string) => n}`;
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
function someGenerics2b<T, U>(strs: TemplateStringsArray, n: (x: T, y: U) => void) { }
someGenerics2b `${ (n: string, x: number) => n }`;
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(strs: string[], producer: () => T) { }
function someGenerics3<T>(strs: TemplateStringsArray, producer: () => T) { }
someGenerics3 `${() => ''}`;
someGenerics3 `${() => undefined}`;
someGenerics3 `${() => 3}`;
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics4<T, U>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics4 `${4}${ () => null }`;
someGenerics4 `${''}${ () => 3 }`;
someGenerics4 `${ null }${ null }`;
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics5<U, T>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics5 `${ 4 } ${ () => null }`;
someGenerics5 `${ '' }${ () => 3 }`;
someGenerics5 `${null}${null}`;
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
function someGenerics6<A>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
function someGenerics7<A, B, C>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
// Generic tag with argument of generic function type
function someGenerics8<T>(strs: string[], n: T): T { return n; }
function someGenerics8<T>(strs: TemplateStringsArray, n: T): T { return n; }
var x = someGenerics8 `${ someGenerics7 }`;
x `${null}${null}${null}`;
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
function someGenerics9<T>(strs: TemplateStringsArray, a: T, b: T, c: T): T {
return null;
}
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;

View File

@ -12,60 +12,60 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
noParams ``;
// Generic tag with parameter which does not use type parameter
function noGenericParams<T>(n: string[]) { }
function noGenericParams<T>(n: TemplateStringsArray) { }
noGenericParams ``;
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a<T, U>(n: T, m: number) { }
someGenerics1a `${3}`;
function someGenerics1b<T, U>(n: string[], m: U) { }
function someGenerics1b<T, U>(n: TemplateStringsArray, m: U) { }
someGenerics1b `${3}`;
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
function someGenerics2a<T>(strs: TemplateStringsArray, n: (x: T) => void) { }
someGenerics2a `${(n: string) => n}`;
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
function someGenerics2b<T, U>(strs: TemplateStringsArray, n: (x: T, y: U) => void) { }
someGenerics2b `${ (n: string, x: number) => n }`;
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(strs: string[], producer: () => T) { }
function someGenerics3<T>(strs: TemplateStringsArray, producer: () => T) { }
someGenerics3 `${() => ''}`;
someGenerics3 `${() => undefined}`;
someGenerics3 `${() => 3}`;
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics4<T, U>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics4 `${4}${ () => null }`;
someGenerics4 `${''}${ () => 3 }`;
someGenerics4 `${ null }${ null }`;
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics5<U, T>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics5 `${ 4 } ${ () => null }`;
someGenerics5 `${ '' }${ () => 3 }`;
someGenerics5 `${null}${null}`;
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
function someGenerics6<A>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
function someGenerics7<A, B, C>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
// Generic tag with argument of generic function type
function someGenerics8<T>(strs: string[], n: T): T { return n; }
function someGenerics8<T>(strs: TemplateStringsArray, n: T): T { return n; }
var x = someGenerics8 `${ someGenerics7 }`;
x `${null}${null}${null}`;
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
function someGenerics9<T>(strs: TemplateStringsArray, a: T, b: T, c: T): T {
return null;
}
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;

View File

@ -5,60 +5,60 @@ function noParams<T>(n: T) { }
noParams ``;
// Generic tag with parameter which does not use type parameter
function noGenericParams<T>(n: string[]) { }
function noGenericParams<T>(n: TemplateStringsArray) { }
noGenericParams ``;
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a<T, U>(n: T, m: number) { }
someGenerics1a `${3}`;
function someGenerics1b<T, U>(n: string[], m: U) { }
function someGenerics1b<T, U>(n: TemplateStringsArray, m: U) { }
someGenerics1b `${3}`;
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
function someGenerics2a<T>(strs: TemplateStringsArray, n: (x: T) => void) { }
someGenerics2a `${(n: string) => n}`;
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
function someGenerics2b<T, U>(strs: TemplateStringsArray, n: (x: T, y: U) => void) { }
someGenerics2b `${ (n: string, x: number) => n }`;
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(strs: string[], producer: () => T) { }
function someGenerics3<T>(strs: TemplateStringsArray, producer: () => T) { }
someGenerics3 `${() => ''}`;
someGenerics3 `${() => undefined}`;
someGenerics3 `${() => 3}`;
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics4<T, U>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics4 `${4}${ () => null }`;
someGenerics4 `${''}${ () => 3 }`;
someGenerics4 `${ null }${ null }`;
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
function someGenerics5<U, T>(strs: TemplateStringsArray, n: T, f: (x: U) => void) { }
someGenerics5 `${ 4 } ${ () => null }`;
someGenerics5 `${ '' }${ () => 3 }`;
someGenerics5 `${null}${null}`;
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
function someGenerics6<A>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
function someGenerics7<A, B, C>(strs: TemplateStringsArray, a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
// Generic tag with argument of generic function type
function someGenerics8<T>(strs: string[], n: T): T { return n; }
function someGenerics8<T>(strs: TemplateStringsArray, n: T): T { return n; }
var x = someGenerics8 `${ someGenerics7 }`;
x `${null}${null}${null}`;
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
function someGenerics9<T>(strs: TemplateStringsArray, a: T, b: T, c: T): T {
return null;
}
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;

View File

@ -8,7 +8,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (6 errors) ====
interface I {
(stringParts: string[], ...rest: boolean[]): I;
(stringParts: TemplateStringsArray, ...rest: boolean[]): I;
g: I;
h: I;
member: I;

View File

@ -1,6 +1,6 @@
//// [taggedTemplateStringsWithIncompatibleTypedTags.ts]
interface I {
(stringParts: string[], ...rest: boolean[]): I;
(stringParts: TemplateStringsArray, ...rest: boolean[]): I;
g: I;
h: I;
member: I;

View File

@ -8,7 +8,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts (6 errors) ====
interface I {
(stringParts: string[], ...rest: boolean[]): I;
(stringParts: TemplateStringsArray, ...rest: boolean[]): I;
g: I;
h: I;
member: I;

View File

@ -1,6 +1,6 @@
//// [taggedTemplateStringsWithIncompatibleTypedTagsES6.ts]
interface I {
(stringParts: string[], ...rest: boolean[]): I;
(stringParts: TemplateStringsArray, ...rest: boolean[]): I;
g: I;
h: I;
member: I;

View File

@ -1,6 +1,6 @@
//// [taggedTemplateStringsWithManyCallAndMemberExpressions.ts]
interface I {
(strs: string[], ...subs: number[]): I;
(strs: TemplateStringsArray, ...subs: number[]): I;
member: {
new (s: string): {
new (n: number): {

View File

@ -2,13 +2,14 @@
interface I {
>I : Symbol(I, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 0, 0))
(strs: string[], ...subs: number[]): I;
(strs: TemplateStringsArray, ...subs: number[]): I;
>strs : Symbol(strs, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 5))
>subs : Symbol(subs, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 20))
>TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.d.ts, --, --))
>subs : Symbol(subs, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 32))
>I : Symbol(I, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 0, 0))
member: {
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 43))
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 55))
new (s: string): {
>s : Symbol(s, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 3, 13))
@ -27,8 +28,8 @@ var f: I;
var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
>x : Symbol(x, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 12, 3))
>f `abc${ 0 }def`.member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 43))
>f `abc${ 0 }def`.member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 55))
>f : Symbol(f, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 10, 3))
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 43))
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressions.ts, 1, 55))

View File

@ -2,8 +2,9 @@
interface I {
>I : I
(strs: string[], ...subs: number[]): I;
>strs : string[]
(strs: TemplateStringsArray, ...subs: number[]): I;
>strs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>subs : number[]
>I : I

View File

@ -1,6 +1,6 @@
//// [taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts]
interface I {
(strs: string[], ...subs: number[]): I;
(strs: TemplateStringsArray, ...subs: number[]): I;
member: {
new (s: string): {
new (n: number): {

View File

@ -2,13 +2,14 @@
interface I {
>I : Symbol(I, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 0, 0))
(strs: string[], ...subs: number[]): I;
(strs: TemplateStringsArray, ...subs: number[]): I;
>strs : Symbol(strs, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 5))
>subs : Symbol(subs, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 20))
>TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.es5.d.ts, --, --))
>subs : Symbol(subs, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 32))
>I : Symbol(I, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 0, 0))
member: {
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 43))
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 55))
new (s: string): {
>s : Symbol(s, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 3, 13))
@ -27,8 +28,8 @@ var f: I;
var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
>x : Symbol(x, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 12, 3))
>f `abc${ 0 }def`.member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 43))
>f `abc${ 0 }def`.member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 55))
>f : Symbol(f, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 10, 3))
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 43))
>member : Symbol(I.member, Decl(taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts, 1, 55))

View File

@ -2,8 +2,9 @@
interface I {
>I : I
(strs: string[], ...subs: number[]): I;
>strs : string[]
(strs: TemplateStringsArray, ...subs: number[]): I;
>strs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>subs : number[]
>I : I

View File

@ -1,25 +1,39 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(9,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
Property 'raw' is missing in type 'undefined[]'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(10,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(11,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(13,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (4 errors) ====
function foo(strs: string[]): number;
function foo(strs: string[], x: number): string;
function foo(strs: string[], x: number, y: number): boolean;
function foo(strs: string[], x: number, y: string): {};
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (8 errors) ====
function foo(strs: TemplateStringsArray): number;
function foo(strs: TemplateStringsArray, x: number): string;
function foo(strs: TemplateStringsArray, x: number, y: number): boolean;
function foo(strs: TemplateStringsArray, x: number, y: string): {};
function foo(...stuff: any[]): any {
return undefined;
}
var a = foo([]); // number
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
!!! error TS2345: Property 'raw' is missing in type 'undefined[]'.
var b = foo([], 1); // string
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var c = foo([], 1, 2); // boolean
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var d = foo([], 1, true); // boolean (with error)
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var e = foo([], 1, "2"); // {}
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var f = foo([], 1, 2, 3); // any (with error)
~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View File

@ -1,8 +1,8 @@
//// [taggedTemplateStringsWithOverloadResolution1.ts]
function foo(strs: string[]): number;
function foo(strs: string[], x: number): string;
function foo(strs: string[], x: number, y: number): boolean;
function foo(strs: string[], x: number, y: string): {};
function foo(strs: TemplateStringsArray): number;
function foo(strs: TemplateStringsArray, x: number): string;
function foo(strs: TemplateStringsArray, x: number, y: number): boolean;
function foo(strs: TemplateStringsArray, x: number, y: string): {};
function foo(...stuff: any[]): any {
return undefined;
}

View File

@ -1,25 +1,39 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(9,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
Property 'raw' is missing in type 'undefined[]'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(10,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(11,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(12,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(13,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts (4 errors) ====
function foo(strs: string[]): number;
function foo(strs: string[], x: number): string;
function foo(strs: string[], x: number, y: number): boolean;
function foo(strs: string[], x: number, y: string): {};
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts (8 errors) ====
function foo(strs: TemplateStringsArray): number;
function foo(strs: TemplateStringsArray, x: number): string;
function foo(strs: TemplateStringsArray, x: number, y: number): boolean;
function foo(strs: TemplateStringsArray, x: number, y: string): {};
function foo(...stuff: any[]): any {
return undefined;
}
var a = foo([]); // number
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
!!! error TS2345: Property 'raw' is missing in type 'undefined[]'.
var b = foo([], 1); // string
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var c = foo([], 1, 2); // boolean
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var d = foo([], 1, true); // boolean (with error)
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var e = foo([], 1, "2"); // {}
~~
!!! error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'.
var f = foo([], 1, 2, 3); // any (with error)
~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View File

@ -1,8 +1,8 @@
//// [taggedTemplateStringsWithOverloadResolution1_ES6.ts]
function foo(strs: string[]): number;
function foo(strs: string[], x: number): string;
function foo(strs: string[], x: number, y: number): boolean;
function foo(strs: string[], x: number, y: string): {};
function foo(strs: TemplateStringsArray): number;
function foo(strs: TemplateStringsArray, x: number): string;
function foo(strs: TemplateStringsArray, x: number, y: number): boolean;
function foo(strs: TemplateStringsArray, x: number, y: string): {};
function foo(...stuff: any[]): any {
return undefined;
}

View File

@ -6,8 +6,8 @@ function foo1(...stuff: any[]): any {
return undefined;
}
var a = foo1 `${1}`; // string
var b = foo1([], 1); // number
var a = foo1 `${1}`;
var b = foo1([], 1);
function foo2(strs: string[], x: number): number;
function foo2(strs: TemplateStringsArray, x: number): string;
@ -15,8 +15,8 @@ function foo2(...stuff: any[]): any {
return undefined;
}
var c = foo2 `${1}`; // number
var d = foo2([], 1); // number
var c = foo2 `${1}`;
var d = foo2([], 1);
//// [taggedTemplateStringsWithOverloadResolution2.js]
function foo1() {
@ -26,8 +26,8 @@ function foo1() {
}
return undefined;
}
var a = (_a = ["", ""], _a.raw = ["", ""], foo1(_a, 1)); // string
var b = foo1([], 1); // number
var a = (_a = ["", ""], _a.raw = ["", ""], foo1(_a, 1));
var b = foo1([], 1);
function foo2() {
var stuff = [];
for (var _i = 0; _i < arguments.length; _i++) {
@ -35,6 +35,6 @@ function foo2() {
}
return undefined;
}
var c = (_b = ["", ""], _b.raw = ["", ""], foo2(_b, 1)); // number
var d = foo2([], 1); // number
var c = (_b = ["", ""], _b.raw = ["", ""], foo2(_b, 1));
var d = foo2([], 1);
var _a, _b;

View File

@ -19,11 +19,11 @@ function foo1(...stuff: any[]): any {
>undefined : Symbol(undefined)
}
var a = foo1 `${1}`; // string
var a = foo1 `${1}`;
>a : Symbol(a, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 7, 3))
>foo1 : Symbol(foo1, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 0, 0), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 1, 61), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 2, 49))
var b = foo1([], 1); // number
var b = foo1([], 1);
>b : Symbol(b, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 8, 3))
>foo1 : Symbol(foo1, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 0, 0), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 1, 61), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 2, 49))
@ -46,11 +46,11 @@ function foo2(...stuff: any[]): any {
>undefined : Symbol(undefined)
}
var c = foo2 `${1}`; // number
var c = foo2 `${1}`;
>c : Symbol(c, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 16, 3))
>foo2 : Symbol(foo2, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 8, 20), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 10, 49), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 11, 61))
var d = foo2([], 1); // number
var d = foo2([], 1);
>d : Symbol(d, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 17, 3))
>foo2 : Symbol(foo2, Decl(taggedTemplateStringsWithOverloadResolution2.ts, 8, 20), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 10, 49), Decl(taggedTemplateStringsWithOverloadResolution2.ts, 11, 61))

View File

@ -19,14 +19,14 @@ function foo1(...stuff: any[]): any {
>undefined : undefined
}
var a = foo1 `${1}`; // string
var a = foo1 `${1}`;
>a : string
>foo1 `${1}` : string
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
>`${1}` : string
>1 : number
var b = foo1([], 1); // number
var b = foo1([], 1);
>b : number
>foo1([], 1) : number
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
@ -52,14 +52,14 @@ function foo2(...stuff: any[]): any {
>undefined : undefined
}
var c = foo2 `${1}`; // number
>c : number
>foo2 `${1}` : number
var c = foo2 `${1}`;
>c : string
>foo2 `${1}` : string
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
>`${1}` : string
>1 : number
var d = foo2([], 1); // number
var d = foo2([], 1);
>d : number
>foo2([], 1) : number
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }

View File

@ -5,8 +5,8 @@ function foo1(...stuff: any[]): any {
return undefined;
}
var a = foo1 `${1}`; // string
var b = foo1([], 1); // number
var a = foo1 `${1}`;
var b = foo1([], 1);
function foo2(strs: string[], x: number): number;
function foo2(strs: TemplateStringsArray, x: number): string;
@ -14,17 +14,17 @@ function foo2(...stuff: any[]): any {
return undefined;
}
var c = foo2 `${1}`; // number
var d = foo2([], 1); // number
var c = foo2 `${1}`;
var d = foo2([], 1);
//// [taggedTemplateStringsWithOverloadResolution2_ES6.js]
function foo1(...stuff) {
return undefined;
}
var a = foo1 `${1}`; // string
var b = foo1([], 1); // number
var a = foo1 `${1}`;
var b = foo1([], 1);
function foo2(...stuff) {
return undefined;
}
var c = foo2 `${1}`; // number
var d = foo2([], 1); // number
var c = foo2 `${1}`;
var d = foo2([], 1);

View File

@ -18,11 +18,11 @@ function foo1(...stuff: any[]): any {
>undefined : Symbol(undefined)
}
var a = foo1 `${1}`; // string
var a = foo1 `${1}`;
>a : Symbol(a, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 6, 3))
>foo1 : Symbol(foo1, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 0, 0), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 0, 61), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 1, 49))
var b = foo1([], 1); // number
var b = foo1([], 1);
>b : Symbol(b, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 7, 3))
>foo1 : Symbol(foo1, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 0, 0), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 0, 61), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 1, 49))
@ -45,11 +45,11 @@ function foo2(...stuff: any[]): any {
>undefined : Symbol(undefined)
}
var c = foo2 `${1}`; // number
var c = foo2 `${1}`;
>c : Symbol(c, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 15, 3))
>foo2 : Symbol(foo2, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 7, 20), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 9, 49), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 10, 61))
var d = foo2([], 1); // number
var d = foo2([], 1);
>d : Symbol(d, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 16, 3))
>foo2 : Symbol(foo2, Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 7, 20), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 9, 49), Decl(taggedTemplateStringsWithOverloadResolution2_ES6.ts, 10, 61))

View File

@ -18,14 +18,14 @@ function foo1(...stuff: any[]): any {
>undefined : undefined
}
var a = foo1 `${1}`; // string
var a = foo1 `${1}`;
>a : string
>foo1 `${1}` : string
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
>`${1}` : string
>1 : number
var b = foo1([], 1); // number
var b = foo1([], 1);
>b : number
>foo1([], 1) : number
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
@ -51,14 +51,14 @@ function foo2(...stuff: any[]): any {
>undefined : undefined
}
var c = foo2 `${1}`; // number
>c : number
>foo2 `${1}` : number
var c = foo2 `${1}`;
>c : string
>foo2 `${1}` : string
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
>`${1}` : string
>1 : number
var d = foo2([], 1); // number
var d = foo2([], 1);
>d : number
>foo2([], 1) : number
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }

View File

@ -1,6 +1,6 @@
//// [taggedTemplateStringsWithTypedTags.ts]
interface I {
(stringParts: string[], ...rest: number[]): I;
(stringParts: TemplateStringsArray, ...rest: number[]): I;
g: I;
h: I;
member: I;

View File

@ -2,13 +2,14 @@
interface I {
>I : Symbol(I, Decl(taggedTemplateStringsWithTypedTags.ts, 0, 0))
(stringParts: string[], ...rest: number[]): I;
(stringParts: TemplateStringsArray, ...rest: number[]): I;
>stringParts : Symbol(stringParts, Decl(taggedTemplateStringsWithTypedTags.ts, 1, 5))
>rest : Symbol(rest, Decl(taggedTemplateStringsWithTypedTags.ts, 1, 27))
>TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.d.ts, --, --))
>rest : Symbol(rest, Decl(taggedTemplateStringsWithTypedTags.ts, 1, 39))
>I : Symbol(I, Decl(taggedTemplateStringsWithTypedTags.ts, 0, 0))
g: I;
>g : Symbol(I.g, Decl(taggedTemplateStringsWithTypedTags.ts, 1, 50))
>g : Symbol(I.g, Decl(taggedTemplateStringsWithTypedTags.ts, 1, 62))
>I : Symbol(I, Decl(taggedTemplateStringsWithTypedTags.ts, 0, 0))
h: I;

View File

@ -2,8 +2,9 @@
interface I {
>I : I
(stringParts: string[], ...rest: number[]): I;
>stringParts : string[]
(stringParts: TemplateStringsArray, ...rest: number[]): I;
>stringParts : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>rest : number[]
>I : I

View File

@ -1,6 +1,6 @@
//// [taggedTemplateStringsWithTypedTagsES6.ts]
interface I {
(stringParts: string[], ...rest: number[]): I;
(stringParts: TemplateStringsArray, ...rest: number[]): I;
g: I;
h: I;
member: I;

View File

@ -2,13 +2,14 @@
interface I {
>I : Symbol(I, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 0, 0))
(stringParts: string[], ...rest: number[]): I;
(stringParts: TemplateStringsArray, ...rest: number[]): I;
>stringParts : Symbol(stringParts, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 1, 5))
>rest : Symbol(rest, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 1, 27))
>TemplateStringsArray : Symbol(TemplateStringsArray, Decl(lib.es5.d.ts, --, --))
>rest : Symbol(rest, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 1, 39))
>I : Symbol(I, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 0, 0))
g: I;
>g : Symbol(I.g, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 1, 50))
>g : Symbol(I.g, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 1, 62))
>I : Symbol(I, Decl(taggedTemplateStringsWithTypedTagsES6.ts, 0, 0))
h: I;

View File

@ -2,8 +2,9 @@
interface I {
>I : I
(stringParts: string[], ...rest: number[]): I;
>stringParts : string[]
(stringParts: TemplateStringsArray, ...rest: number[]): I;
>stringParts : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>rest : number[]
>I : I

View File

@ -0,0 +1,20 @@
tests/cases/compiler/b.d.ts(2,20): error TS2305: Module '"tests/cases/compiler/a".ns' has no exported member 'IFoo'.
==== tests/cases/compiler/a.d.ts (0 errors) ====
export = ns;
export as namespace ns;
declare namespace ns {
export var x: number;
export interface IFoo { }
}
==== tests/cases/compiler/b.d.ts (1 errors) ====
declare namespace ns.something {
export var p: ns.IFoo;
~~~~
!!! error TS2305: Module '"tests/cases/compiler/a".ns' has no exported member 'IFoo'.
}

View File

@ -0,0 +1,16 @@
//// [tests/cases/compiler/unusedTypeParameters6.ts] ////
//// [a.ts]
class C<T> { }
//// [b.ts]
interface C<T> { a: T; }
//// [a.js]
var C = (function () {
function C() {
}
return C;
}());
//// [b.js]

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/a.ts ===
class C<T> { }
>C : Symbol(C, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
>T : Symbol(T, Decl(a.ts, 1, 8), Decl(b.ts, 0, 12))
=== tests/cases/compiler/b.ts ===
interface C<T> { a: T; }
>C : Symbol(C, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
>T : Symbol(T, Decl(a.ts, 1, 8), Decl(b.ts, 0, 12))
>a : Symbol(C.a, Decl(b.ts, 0, 16))
>T : Symbol(T, Decl(a.ts, 1, 8), Decl(b.ts, 0, 12))

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/a.ts ===
class C<T> { }
>C : C<T>
>T : T
=== tests/cases/compiler/b.ts ===
interface C<T> { a: T; }
>C : C<T>
>T : T
>a : T
>T : T

View File

@ -0,0 +1,16 @@
//// [tests/cases/compiler/unusedTypeParameters7.ts] ////
//// [a.ts]
class C<T> { a: T; }
//// [b.ts]
interface C<T> { }
//// [a.js]
var C = (function () {
function C() {
}
return C;
}());
//// [b.js]

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/a.ts ===
class C<T> { a: T; }
>C : Symbol(C, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
>T : Symbol(T, Decl(a.ts, 1, 8), Decl(b.ts, 0, 12))
>a : Symbol(C.a, Decl(a.ts, 1, 12))
>T : Symbol(T, Decl(a.ts, 1, 8), Decl(b.ts, 0, 12))
=== tests/cases/compiler/b.ts ===
interface C<T> { }
>C : Symbol(C, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0))
>T : Symbol(T, Decl(a.ts, 1, 8), Decl(b.ts, 0, 12))

View File

@ -0,0 +1,13 @@
=== tests/cases/compiler/a.ts ===
class C<T> { a: T; }
>C : C<T>
>T : T
>a : T
>T : T
=== tests/cases/compiler/b.ts ===
interface C<T> { }
>C : C<T>
>T : T

View File

@ -0,0 +1,11 @@
tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but never used.
==== tests/cases/compiler/a.ts (0 errors) ====
class C<T> { }
==== tests/cases/compiler/b.ts (1 errors) ====
interface C<T> { }
~
!!! error TS6133: 'T' is declared but never used.

View File

@ -0,0 +1,16 @@
//// [tests/cases/compiler/unusedTypeParameters8.ts] ////
//// [a.ts]
class C<T> { }
//// [b.ts]
interface C<T> { }
//// [a.js]
var C = (function () {
function C() {
}
return C;
}());
//// [b.js]

Some files were not shown because too many files have changed in this diff Show More