Merge branch 'master' into Fix9173-2

This commit is contained in:
Mohamed Hegazy
2016-06-17 15:21:43 -07:00
197 changed files with 2068 additions and 1306 deletions
+7 -6
View File
@@ -562,7 +562,8 @@ namespace ts {
const declarationFile = getSourceFileOfNode(declaration);
const useFile = getSourceFileOfNode(usage);
if (declarationFile !== useFile) {
if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) {
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
(!compilerOptions.outFile && !compilerOptions.out)) {
// nodes are in different files and order cannot be determines
return true;
}
@@ -11524,7 +11525,10 @@ namespace ts {
function checkAssertion(node: AssertionExpression) {
const exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression));
checkSourceElement(node.type);
const targetType = getTypeFromTypeNode(node.type);
if (produceDiagnostics && targetType !== unknownType) {
const widenedType = getWidenedType(exprType);
if (!isTypeComparableTo(targetType, widenedType)) {
@@ -13559,9 +13563,6 @@ namespace ts {
}
}
// when checking exported function declarations across modules check only duplicate implementations
// names and consistency of modifiers are verified when we check local symbol
const isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module;
let duplicateFunctionDeclaration = false;
let multipleConstructorImplementation = false;
for (const current of declarations) {
@@ -13594,7 +13595,7 @@ namespace ts {
duplicateFunctionDeclaration = true;
}
}
else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
reportImplementationExpectedError(previousDeclaration);
}
@@ -13628,7 +13629,7 @@ namespace ts {
}
// Abstract methods can't have an implementation -- in particular, they don't need one.
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
!(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) {
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
}
+8 -2
View File
@@ -412,6 +412,10 @@ namespace ts {
},
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
},
{
name: "disableProjectSizeLimit",
type: "boolean"
},
{
name: "strictNullChecks",
type: "boolean",
@@ -761,8 +765,10 @@ namespace ts {
}
}
filesSeen[fileName] = true;
fileNames.push(fileName);
if (!filesSeen[fileName]) {
filesSeen[fileName] = true;
fileNames.push(fileName);
}
}
}
}
-4
View File
@@ -2921,10 +2921,6 @@
"category": "Error",
"code": 8012
},
"'property declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8014
},
"'enum declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8015
+8 -7
View File
@@ -2076,7 +2076,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
function createPropertyAccessExpression(expression: Expression, name: Identifier): PropertyAccessExpression {
const result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
result.expression = parenthesizeForAccess(expression);
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
result.name = name;
return result;
}
@@ -2223,11 +2222,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// Returns 'true' if the code was actually indented, false otherwise.
// If the code is not indented, an optional valueToWriteWhenNotIndenting will be
// emitted instead.
function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean {
function indentIfOnDifferentLines(parent: Node, node1: TextRange, node2: TextRange, valueToWriteWhenNotIndenting?: string): boolean {
const realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
// Always use a newline for synthesized code if the synthesizer desires it.
const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2);
const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2 as Node);
if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) {
increaseIndent();
@@ -2257,7 +2256,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
emit(node.expression);
const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken);
const dotRangeStart = nodeIsSynthesized(node.expression) ? -1 : node.expression.end;
const dotRangeEnd = nodeIsSynthesized(node.expression) ? -1 : skipTrivia(currentText, node.expression.end) + 1;
const dotToken = <TextRange>{ pos: dotRangeStart, end: dotRangeEnd };
const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, dotToken);
// 1 .toString is a valid property access, emit a space after the literal
// Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal
@@ -2283,7 +2285,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
write(".");
}
const indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name);
const indentedAfterDot = indentIfOnDifferentLines(node, dotToken, node.name);
emit(node.name);
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
}
@@ -2780,7 +2782,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
const identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false);
synthesizedLHS.expression = identifier;
(<PropertyAccessExpression>synthesizedLHS).dotToken = leftHandSideExpression.dotToken;
(<PropertyAccessExpression>synthesizedLHS).name = leftHandSideExpression.name;
write(", ");
}
@@ -3758,7 +3759,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
getLineOfLocalPositionFromLineMap(currentLineMap, node2.end);
}
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
function nodeEndIsOnSameLineAsNodeStart(node1: TextRange, node2: TextRange) {
return getLineOfLocalPositionFromLineMap(currentLineMap, node1.end) ===
getLineOfLocalPositionFromLineMap(currentLineMap, skipTrivia(currentText, node2.pos));
}
+1 -3
View File
@@ -137,7 +137,6 @@ namespace ts {
return visitNodes(cbNodes, (<ObjectLiteralExpression>node).properties);
case SyntaxKind.PropertyAccessExpression:
return visitNode(cbNode, (<PropertyAccessExpression>node).expression) ||
visitNode(cbNode, (<PropertyAccessExpression>node).dotToken) ||
visitNode(cbNode, (<PropertyAccessExpression>node).name);
case SyntaxKind.ElementAccessExpression:
return visitNode(cbNode, (<ElementAccessExpression>node).expression) ||
@@ -3571,7 +3570,7 @@ namespace ts {
// If it wasn't then just try to parse out a '.' and report an error.
const node = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
node.expression = expression;
node.dotToken = parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
return finishNode(node);
}
@@ -3807,7 +3806,6 @@ namespace ts {
if (dotToken) {
const propertyAccess = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
propertyAccess.expression = expression;
propertyAccess.dotToken = dotToken;
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
expression = finishNode(propertyAccess);
continue;
+13 -2
View File
@@ -1601,8 +1601,19 @@ namespace ts {
}
break;
case SyntaxKind.PropertyDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
return true;
const propertyDeclaration = <PropertyDeclaration>node;
if (propertyDeclaration.modifiers) {
for (const modifier of propertyDeclaration.modifiers) {
if (modifier.kind !== SyntaxKind.StaticKeyword) {
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics._0_can_only_be_used_in_a_ts_file, tokenToString(modifier.kind)));
return true;
}
}
}
if (checkTypeAnnotation((<PropertyDeclaration>node).type)) {
return true;
}
break;
case SyntaxKind.EnumDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
return true;
+13 -2
View File
@@ -15,6 +15,7 @@ namespace ts {
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@@ -79,7 +80,7 @@ namespace ts {
realpath(path: string): string;
};
export var sys: System = (function () {
export var sys: System = (function() {
function getWScriptSystem(): System {
@@ -503,7 +504,7 @@ namespace ts {
}
);
},
resolvePath: function (path: string): string {
resolvePath: function(path: string): string {
return _path.resolve(path);
},
fileExists,
@@ -540,6 +541,16 @@ namespace ts {
}
return process.memoryUsage().heapUsed;
},
getFileSize(path) {
try {
const stat = _fs.statSync(path);
if (stat.isFile()) {
return stat.size;
}
}
catch (e) { }
return 0;
},
exit(exitCode?: number): void {
process.exit(exitCode);
},
+3 -2
View File
@@ -980,7 +980,6 @@ namespace ts {
// @kind(SyntaxKind.PropertyAccessExpression)
export interface PropertyAccessExpression extends MemberExpression, Declaration {
expression: LeftHandSideExpression;
dotToken: Node;
name: Identifier;
}
@@ -2224,7 +2223,8 @@ namespace ts {
/* @internal */
Nullable = Undefined | Null,
Falsy = String | Number | Boolean | Void | Undefined | Null,
/* @internal */
Falsy = Void | Undefined | Null, // TODO: Add false, 0, and ""
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null | Never,
/* @internal */
@@ -2561,6 +2561,7 @@ namespace ts {
/* @internal */ suppressOutputPathCheck?: boolean;
target?: ScriptTarget;
traceResolution?: boolean;
disableSizeLimit?: boolean;
types?: string[];
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];
+4
View File
@@ -2714,6 +2714,10 @@ namespace ts {
return forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
}
export function hasTypeScriptFileExtension(fileName: string) {
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
}
/**
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
* representing the UTF-8 encoding of the character, and return the expanded char code list.
+83 -32
View File
@@ -730,30 +730,6 @@ namespace FourSlash {
}
}
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
const references = this.getReferencesAtCaret();
if (!references || references.length === 0) {
this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.");
}
for (let i = 0; i < references.length; i++) {
const reference = references[i];
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
}
if (typeof isDefinition !== "undefined" && reference.isDefinition !== isDefinition) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isDefinition value does not match, actual: ${reference.isDefinition}, expected: ${isDefinition}.`);
}
return;
}
}
const missingItem = { fileName, start, end, isWriteAccess, isDefinition };
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
public verifyReferencesCountIs(count: number, localFilesOnly = true) {
const references = this.getReferencesAtCaret();
let referencesCount = 0;
@@ -777,6 +753,73 @@ namespace FourSlash {
}
}
public verifyReferencesAre(expectedReferences: Range[]) {
const actualReferences = this.getReferencesAtCaret() || [];
if (actualReferences.length > expectedReferences.length) {
// Find the unaccounted-for reference.
for (const actual of actualReferences) {
if (!ts.forEach(expectedReferences, r => r.start === actual.textSpan.start)) {
this.raiseError(`A reference ${actual} is unaccounted for.`);
}
}
// Probably will never reach here.
this.raiseError(`There are ${actualReferences.length} references but only ${expectedReferences.length} were expected.`);
}
for (const reference of expectedReferences) {
const {fileName, start, end} = reference;
if (reference.marker) {
const {isWriteAccess, isDefinition} = reference.marker.data;
this.verifyReferencesWorker(actualReferences, fileName, start, end, isWriteAccess, isDefinition);
}
else {
this.verifyReferencesWorker(actualReferences, fileName, start, end);
}
}
}
public verifyReferencesOf({fileName, start}: Range, references: Range[]) {
this.openFile(fileName);
this.goToPosition(start);
this.verifyReferencesAre(references);
}
public verifyRangesReferenceEachOther(ranges?: Range[]) {
ranges = ranges || this.getRanges();
assert(ranges.length);
for (const range of ranges) {
this.verifyReferencesOf(range, ranges);
}
}
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
const references = this.getReferencesAtCaret();
if (!references || references.length === 0) {
this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.");
}
this.verifyReferencesWorker(references, fileName, start, end, isWriteAccess, isDefinition);
}
private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
for (let i = 0; i < references.length; i++) {
const reference = references[i];
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
}
if (typeof isDefinition !== "undefined" && reference.isDefinition !== isDefinition) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isDefinition value does not match, actual: ${reference.isDefinition}, expected: ${isDefinition}.`);
}
return;
}
}
const missingItem = { fileName, start, end, isWriteAccess, isDefinition };
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
private getMemberListAtCaret() {
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
}
@@ -2836,14 +2879,6 @@ namespace FourSlashInterface {
this.state.verifyMemberListIsEmpty(this.negative);
}
public referencesCountIs(count: number) {
this.state.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean, isDefinition?: boolean) {
this.state.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess, isDefinition);
}
public signatureHelpPresent() {
this.state.verifySignatureHelpPresent(!this.negative);
}
@@ -2935,6 +2970,22 @@ namespace FourSlashInterface {
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
}
public referencesCountIs(count: number) {
this.state.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAre(ranges: FourSlash.Range[]) {
this.state.verifyReferencesAre(ranges);
}
public referencesOf(start: FourSlash.Range, references: FourSlash.Range[]) {
this.state.verifyReferencesOf(start, references);
}
public rangesReferenceEachOther(ranges?: FourSlash.Range[]) {
this.state.verifyRangesReferenceEachOther(ranges);
}
public currentParameterHelpArgumentNameIs(name: string) {
this.state.verifyCurrentParameterHelpName(name);
}
+158 -7
View File
@@ -27,6 +27,8 @@ namespace ts.server {
});
}
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
export class ScriptInfo {
svc: ScriptVersionCache;
children: ScriptInfo[] = []; // files referenced by this file
@@ -385,12 +387,29 @@ namespace ts.server {
/** Used for configured projects which may have multiple open roots */
openRefCount = 0;
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
constructor(
public projectService: ProjectService,
public projectOptions?: ProjectOptions,
public languageServiceDiabled = false) {
if (projectOptions && projectOptions.files) {
// If files are listed explicitly, allow all extensions
projectOptions.compilerOptions.allowNonTsExtensions = true;
}
this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions);
if (!languageServiceDiabled) {
this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions);
}
}
enableLanguageService() {
// if the language service was disabled, we should re-initiate the compiler service
if (this.languageServiceDiabled) {
this.compilerService = new CompilerService(this, this.projectOptions && this.projectOptions.compilerOptions);
}
this.languageServiceDiabled = false;
}
disableLanguageService() {
this.languageServiceDiabled = true;
}
addOpenRef() {
@@ -407,19 +426,45 @@ namespace ts.server {
}
getRootFiles() {
if (this.languageServiceDiabled) {
// When the languageService was disabled, only return file list if it is a configured project
return this.projectOptions ? this.projectOptions.files : undefined;
}
return this.compilerService.host.roots.map(info => info.fileName);
}
getFileNames() {
if (this.languageServiceDiabled) {
if (!this.projectOptions) {
return undefined;
}
const fileNames: string[] = [];
if (this.projectOptions && this.projectOptions.compilerOptions) {
fileNames.push(getDefaultLibFilePath(this.projectOptions.compilerOptions));
}
ts.addRange(fileNames, this.projectOptions.files);
return fileNames;
}
const sourceFiles = this.program.getSourceFiles();
return sourceFiles.map(sourceFile => sourceFile.fileName);
}
getSourceFile(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return undefined;
}
return this.filenameToSourceFile[info.fileName];
}
getSourceFileFromName(filename: string, requireOpen?: boolean) {
if (this.languageServiceDiabled) {
return undefined;
}
const info = this.projectService.getScriptInfo(filename);
if (info) {
if ((!requireOpen) || info.isOpen) {
@@ -429,15 +474,27 @@ namespace ts.server {
}
isRoot(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return undefined;
}
return this.compilerService.host.roots.some(root => root === info);
}
removeReferencedFile(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return;
}
this.compilerService.host.removeReferencedFile(info);
this.updateGraph();
}
updateFileMap() {
if (this.languageServiceDiabled) {
return;
}
this.filenameToSourceFile = {};
const sourceFiles = this.program.getSourceFiles();
for (let i = 0, len = sourceFiles.length; i < len; i++) {
@@ -447,11 +504,19 @@ namespace ts.server {
}
finishGraph() {
if (this.languageServiceDiabled) {
return;
}
this.updateGraph();
this.compilerService.languageService.getNavigateToItems(".*");
}
updateGraph() {
if (this.languageServiceDiabled) {
return;
}
this.program = this.compilerService.languageService.getProgram();
this.updateFileMap();
}
@@ -462,15 +527,32 @@ namespace ts.server {
// add a root file to project
addRoot(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return;
}
this.compilerService.host.addRoot(info);
}
// remove a root file from project
removeRoot(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return;
}
this.compilerService.host.removeRoot(info);
}
filesToString() {
if (this.languageServiceDiabled) {
if (this.projectOptions) {
let strBuilder = "";
ts.forEach(this.projectOptions.files,
file => { strBuilder += file + "\n"; });
return strBuilder;
}
}
let strBuilder = "";
ts.forEachValue(this.filenameToSourceFile,
sourceFile => { strBuilder += sourceFile.fileName + "\n"; });
@@ -481,7 +563,9 @@ namespace ts.server {
this.projectOptions = projectOptions;
if (projectOptions.compilerOptions) {
projectOptions.compilerOptions.allowNonTsExtensions = true;
this.compilerService.setCompilerOptions(projectOptions.compilerOptions);
if (!this.languageServiceDiabled) {
this.compilerService.setCompilerOptions(projectOptions.compilerOptions);
}
}
}
}
@@ -807,6 +891,7 @@ namespace ts.server {
else {
this.findReferencingProjects(info);
if (info.defaultProject) {
info.defaultProject.addOpenRef();
this.openFilesReferenced.push(info);
}
else {
@@ -1260,7 +1345,24 @@ namespace ts.server {
return { succeeded: true, projectOptions };
}
}
}
private exceedTotalNonTsFileSizeLimit(fileNames: string[]) {
let totalNonTsFileSize = 0;
if (!this.host.getFileSize) {
return false;
}
for (const fileName of fileNames) {
if (hasTypeScriptFileExtension(fileName)) {
continue;
}
totalNonTsFileSize += this.host.getFileSize(fileName);
if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) {
return true;
}
}
return false;
}
openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors?: Diagnostic[] } {
@@ -1269,6 +1371,19 @@ namespace ts.server {
return { success: false, errors };
}
else {
if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) {
if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) {
const project = this.createProject(configFilename, projectOptions, /*languageServiceDisabled*/ true);
// for configured projects with languageService disabled, we only watch its config file,
// do not care about the directory changes in the folder.
project.projectFileWatcher = this.host.watchFile(
toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
_ => this.watchedProjectConfigFileChanged(project));
return { success: true, project };
}
}
const project = this.createProject(configFilename, projectOptions);
let errors: Diagnostic[];
for (const rootFilename of projectOptions.files) {
@@ -1292,7 +1407,7 @@ namespace ts.server {
}
}
updateConfiguredProject(project: Project) {
updateConfiguredProject(project: Project): Diagnostic[] {
if (!this.host.fileExists(project.projectFilename)) {
this.log("Config file deleted");
this.removeProject(project);
@@ -1303,7 +1418,43 @@ namespace ts.server {
return errors;
}
else {
const oldFileNames = project.compilerService.host.roots.map(info => info.fileName);
if (projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit && this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) {
project.setProjectOptions(projectOptions);
if (project.languageServiceDiabled) {
return;
}
project.disableLanguageService();
if (project.directoryWatcher) {
project.directoryWatcher.close();
project.directoryWatcher = undefined;
}
return;
}
if (project.languageServiceDiabled) {
project.setProjectOptions(projectOptions);
project.enableLanguageService();
project.directoryWatcher = this.host.watchDirectory(
ts.getDirectoryPath(project.projectFilename),
path => this.directoryWatchedForSourceFilesChanged(project, path),
/*recursive*/ true
);
for (const rootFilename of projectOptions.files) {
if (this.host.fileExists(rootFilename)) {
const info = this.openFile(rootFilename, /*openedByClient*/ false);
project.addRoot(info);
}
}
project.finishGraph();
return;
}
// if the project is too large, the root files might not have been all loaded if the total
// program size reached the upper limit. In that case project.projectOptions.files should
// be more precise. However this would only happen for configured project.
const oldFileNames = project.projectOptions ? project.projectOptions.files : project.compilerService.host.roots.map(info => info.fileName);
const newFileNames = ts.filter(projectOptions.files, f => this.host.fileExists(f));
const fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0);
const fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0);
@@ -1346,8 +1497,8 @@ namespace ts.server {
}
}
createProject(projectFilename: string, projectOptions?: ProjectOptions) {
const project = new Project(this, projectOptions);
createProject(projectFilename: string, projectOptions?: ProjectOptions, languageServiceDisabled?: boolean) {
const project = new Project(this, projectOptions, languageServiceDisabled);
project.projectFilename = projectFilename;
return project;
}
+4
View File
@@ -123,6 +123,10 @@ declare namespace ts.server.protocol {
* The list of normalized file name in the project, including 'lib.d.ts'
*/
fileNames?: string[];
/**
* Indicates if the project has a active language service instance
*/
languageServiceDisabled?: boolean;
}
/**
+37 -28
View File
@@ -313,7 +313,7 @@ namespace ts.server {
private getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -335,7 +335,7 @@ namespace ts.server {
private getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -358,7 +358,7 @@ namespace ts.server {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -388,7 +388,7 @@ namespace ts.server {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -423,15 +423,18 @@ namespace ts.server {
private getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (!project) {
throw Errors.NoProject;
}
const projectInfo: protocol.ProjectInfo = {
configFileName: project.projectFilename
configFileName: project.projectFilename,
languageServiceDisabled: project.languageServiceDiabled
};
if (needFileNameList) {
projectInfo.fileNames = project.getFileNames();
}
return projectInfo;
}
@@ -439,11 +442,12 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const info = this.projectService.getScriptInfo(file);
const projects = this.projectService.findReferencingProjects(info);
if (!projects.length) {
const projectsWithLanguageServiceEnabeld = ts.filter(projects, p => !p.languageServiceDiabled);
if (projectsWithLanguageServiceEnabeld.length === 0) {
throw Errors.NoProject;
}
const defaultProject = projects[0];
const defaultProject = projectsWithLanguageServiceEnabeld[0];
// The rename info should be the same for every project
const defaultProjectCompilerService = defaultProject.compilerService;
const position = defaultProjectCompilerService.host.lineOffsetToPosition(file, line, offset);
@@ -460,7 +464,7 @@ namespace ts.server {
}
const fileSpans = combineProjectOutput(
projects,
projectsWithLanguageServiceEnabeld,
(project: Project) => {
const compilerService = project.compilerService;
const renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments);
@@ -521,11 +525,12 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const info = this.projectService.getScriptInfo(file);
const projects = this.projectService.findReferencingProjects(info);
if (!projects.length) {
const projectsWithLanguageServiceEnabeld = ts.filter(projects, p => !p.languageServiceDiabled);
if (projectsWithLanguageServiceEnabeld.length === 0) {
throw Errors.NoProject;
}
const defaultProject = projects[0];
const defaultProject = projectsWithLanguageServiceEnabeld[0];
const position = defaultProject.compilerService.host.lineOffsetToPosition(file, line, offset);
const nameInfo = defaultProject.compilerService.languageService.getQuickInfoAtPosition(file, position);
if (!nameInfo) {
@@ -537,7 +542,7 @@ namespace ts.server {
const nameColStart = defaultProject.compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
const nameText = defaultProject.compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
const refs = combineProjectOutput<protocol.ReferencesResponseItem>(
projects,
projectsWithLanguageServiceEnabeld,
(project: Project) => {
const compilerService = project.compilerService;
const references = compilerService.languageService.getReferencesAtPosition(file, position);
@@ -596,7 +601,7 @@ namespace ts.server {
private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -622,7 +627,7 @@ namespace ts.server {
private getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -650,7 +655,7 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -728,7 +733,7 @@ namespace ts.server {
}
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -752,7 +757,7 @@ namespace ts.server {
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -771,7 +776,7 @@ namespace ts.server {
private getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -801,7 +806,7 @@ namespace ts.server {
const checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (project) {
if (project && !project.languageServiceDiabled) {
accum.push({ fileName, project });
}
return accum;
@@ -815,7 +820,7 @@ namespace ts.server {
private change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (project) {
if (project && !project.languageServiceDiabled) {
const compilerService = project.compilerService;
const start = compilerService.host.lineOffsetToPosition(file, line, offset);
const end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
@@ -831,7 +836,7 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const tmpfile = ts.normalizePath(tempFileName);
const project = this.projectService.getProjectForFile(file);
if (project) {
if (project && !project.languageServiceDiabled) {
this.changeSeq++;
// make sure no changes happen before this one is finished
project.compilerService.host.reloadScript(file, tmpfile, () => {
@@ -845,7 +850,7 @@ namespace ts.server {
const tmpfile = ts.normalizePath(tempFileName);
const project = this.projectService.getProjectForFile(file);
if (project) {
if (project && !project.languageServiceDiabled) {
project.compilerService.host.saveTo(file, tmpfile);
}
}
@@ -881,7 +886,7 @@ namespace ts.server {
private getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -898,13 +903,13 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const info = this.projectService.getScriptInfo(file);
const projects = this.projectService.findReferencingProjects(info);
const defaultProject = projects[0];
if (!defaultProject) {
const projectsWithLanguageServiceEnabeld = ts.filter(projects, p => !p.languageServiceDiabled);
if (projectsWithLanguageServiceEnabeld.length === 0) {
throw Errors.NoProject;
}
const allNavToItems = combineProjectOutput(
projects,
projectsWithLanguageServiceEnabeld,
(project: Project) => {
const compilerService = project.compilerService;
const navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount);
@@ -956,7 +961,7 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@@ -975,7 +980,11 @@ namespace ts.server {
}
getDiagnosticsForProject(delay: number, fileName: string) {
const { fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
const { fileNames, languageServiceDisabled } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
if (languageServiceDisabled) {
return;
}
// No need to analyze lib.d.ts
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);
+3 -1
View File
@@ -1,4 +1,5 @@
/// <reference path="..\compiler\program.ts"/>
/// <reference path="..\compiler\commandLineParser.ts"/>
/// <reference path='breakpoints.ts' />
/// <reference path='outliningElementsCollector.ts' />
@@ -2990,7 +2991,8 @@ namespace ts {
oldSettings.moduleResolution !== newSettings.moduleResolution ||
oldSettings.noResolve !== newSettings.noResolve ||
oldSettings.jsx !== newSettings.jsx ||
oldSettings.allowJs !== newSettings.allowJs);
oldSettings.allowJs !== newSettings.allowJs ||
oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit);
// Now create a new compiler
const compilerHost: CompilerHost = {
@@ -0,0 +1,11 @@
tests/cases/compiler/file1.ts(2,1): error TS2448: Block-scoped variable 'c' used before its declaration.
==== tests/cases/compiler/file1.ts (1 errors) ====
c;
~
!!! error TS2448: Block-scoped variable 'c' used before its declaration.
==== tests/cases/compiler/file2.ts (0 errors) ====
const c = 0;
@@ -1,8 +1,11 @@
tests/cases/compiler/defaultValueInFunctionTypes.ts(1,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/compiler/defaultValueInFunctionTypes.ts(2,11): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
==== tests/cases/compiler/defaultValueInFunctionTypes.ts (1 errors) ====
==== tests/cases/compiler/defaultValueInFunctionTypes.ts (2 errors) ====
var x: (a: number = 1) => number;
~~~~~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
var y = <(a : string = "") => any>(undefined)
var y = <(a : string = "") => any>(undefined)
~~~~~~~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
@@ -0,0 +1,11 @@
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions01.ts(2,11): error TS2300: Duplicate identifier 'a'.
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions01.ts(2,22): error TS2300: Duplicate identifier 'a'.
==== tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions01.ts (2 errors) ====
let x = <{a: number; a: number}>{};
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
@@ -0,0 +1,12 @@
//// [duplicatePropertiesInTypeAssertions01.ts]
let x = <{a: number; a: number}>{};
//// [duplicatePropertiesInTypeAssertions01.js]
var x = {};
//// [duplicatePropertiesInTypeAssertions01.d.ts]
declare let x: {
a: number;
};
@@ -0,0 +1,11 @@
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions02.ts(2,16): error TS2300: Duplicate identifier 'a'.
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions02.ts(2,27): error TS2300: Duplicate identifier 'a'.
==== tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions02.ts (2 errors) ====
let x = {} as {a: number; a: number};
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
@@ -0,0 +1,12 @@
//// [duplicatePropertiesInTypeAssertions02.ts]
let x = {} as {a: number; a: number};
//// [duplicatePropertiesInTypeAssertions02.js]
var x = {};
//// [duplicatePropertiesInTypeAssertions02.d.ts]
declare let x: {
a: number;
};
@@ -0,0 +1,9 @@
tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts(2,10): error TS1122: A tuple type element list cannot be empty.
==== tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts (1 errors) ====
let x = <[]>[];
~~
!!! error TS1122: A tuple type element list cannot be empty.
let y = x[0];
@@ -0,0 +1,13 @@
//// [emptyTuplesTypeAssertion01.ts]
let x = <[]>[];
let y = x[0];
//// [emptyTuplesTypeAssertion01.js]
var x = [];
var y = x[0];
//// [emptyTuplesTypeAssertion01.d.ts]
declare let x: [];
declare let y: never;
@@ -0,0 +1,9 @@
tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts(2,15): error TS1122: A tuple type element list cannot be empty.
==== tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts (1 errors) ====
let x = [] as [];
~~
!!! error TS1122: A tuple type element list cannot be empty.
let y = x[0];
@@ -0,0 +1,13 @@
//// [emptyTuplesTypeAssertion02.ts]
let x = [] as [];
let y = x[0];
//// [emptyTuplesTypeAssertion02.js]
var x = [];
var y = x[0];
//// [emptyTuplesTypeAssertion02.d.ts]
declare let x: [];
declare let y: never;
@@ -1,10 +1,13 @@
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used before its declaration.
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
==== tests/cases/compiler/a.ts (0 errors) ====
==== tests/cases/compiler/a.ts (1 errors) ====
let b = 30;
a = 10;
~
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
==== tests/cases/compiler/b.js (0 errors) ====
let a = 10;
b = 30;
@@ -1,9 +0,0 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
tests/cases/compiler/a.js(1,11): error TS8014: 'property declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
==== tests/cases/compiler/a.js (1 errors) ====
class C { v }
~
!!! error TS8014: 'property declarations' can only be used in a .ts file.
@@ -0,0 +1,11 @@
tests/cases/compiler/file1.ts(2,1): error TS2448: Block-scoped variable 'l' used before its declaration.
==== tests/cases/compiler/file1.ts (1 errors) ====
l;
~
!!! error TS2448: Block-scoped variable 'l' used before its declaration.
==== tests/cases/compiler/file2.ts (0 errors) ====
const l = 0;
@@ -86,8 +86,8 @@ const a8 = a && z;
>z : string | number | undefined
const s1 = s && a;
>s1 : number[] | string
>s && a : number[] | string
>s1 : number[]
>s && a : number[]
>s : string
>a : number[]
@@ -98,32 +98,32 @@ const s2 = s && s;
>s : string
const s3 = s && x;
>s3 : number | string
>s && x : number | string
>s3 : number
>s && x : number
>s : string
>x : number
const s4 = s && b;
>s4 : boolean | string
>s && b : boolean | string
>s4 : boolean
>s && b : boolean
>s : string
>b : boolean
const s5 = s && v;
>s5 : void | string
>s && v : void | string
>s5 : void
>s && v : void
>s : string
>v : void
const s6 = s && u;
>s6 : string | undefined
>s && u : string | undefined
>s6 : undefined
>s && u : undefined
>s : string
>u : undefined
const s7 = s && n;
>s7 : string | null
>s && n : string | null
>s7 : null
>s && n : null
>s : string
>n : null
@@ -134,14 +134,14 @@ const s8 = s && z;
>z : string | number | undefined
const x1 = x && a;
>x1 : number[] | number
>x && a : number[] | number
>x1 : number[]
>x && a : number[]
>x : number
>a : number[]
const x2 = x && s;
>x2 : string | number
>x && s : string | number
>x2 : string
>x && s : string
>x : number
>s : string
@@ -152,26 +152,26 @@ const x3 = x && x;
>x : number
const x4 = x && b;
>x4 : boolean | number
>x && b : boolean | number
>x4 : boolean
>x && b : boolean
>x : number
>b : boolean
const x5 = x && v;
>x5 : void | number
>x && v : void | number
>x5 : void
>x && v : void
>x : number
>v : void
const x6 = x && u;
>x6 : number | undefined
>x && u : number | undefined
>x6 : undefined
>x && u : undefined
>x : number
>u : undefined
const x7 = x && n;
>x7 : number | null
>x && n : number | null
>x7 : null
>x && n : null
>x : number
>n : null
@@ -182,20 +182,20 @@ const x8 = x && z;
>z : string | number | undefined
const b1 = b && a;
>b1 : number[] | boolean
>b && a : number[] | boolean
>b1 : number[]
>b && a : number[]
>b : boolean
>a : number[]
const b2 = b && s;
>b2 : string | boolean
>b && s : string | boolean
>b2 : string
>b && s : string
>b : boolean
>s : string
const b3 = b && x;
>b3 : number | boolean
>b && x : number | boolean
>b3 : number
>b && x : number
>b : boolean
>x : number
@@ -206,26 +206,26 @@ const b4 = b && b;
>b : boolean
const b5 = b && v;
>b5 : void | boolean
>b && v : void | boolean
>b5 : void
>b && v : void
>b : boolean
>v : void
const b6 = b && u;
>b6 : boolean | undefined
>b && u : boolean | undefined
>b6 : undefined
>b && u : undefined
>b : boolean
>u : undefined
const b7 = b && n;
>b7 : boolean | null
>b && n : boolean | null
>b7 : null
>b && n : null
>b : boolean
>n : null
const b8 = b && z;
>b8 : string | number | boolean | undefined
>b && z : string | number | boolean | undefined
>b8 : string | number | undefined
>b && z : string | number | undefined
>b : boolean
>z : string | number | undefined
@@ -374,44 +374,44 @@ const n8 = n && z;
>z : string | number | undefined
const z1 = z && a;
>z1 : number[] | string | number | undefined
>z && a : number[] | string | number | undefined
>z1 : number[] | undefined
>z && a : number[] | undefined
>z : string | number | undefined
>a : number[]
const z2 = z && s;
>z2 : string | number | undefined
>z && s : string | number | undefined
>z2 : string | undefined
>z && s : string | undefined
>z : string | number | undefined
>s : string
const z3 = z && x;
>z3 : number | string | undefined
>z && x : number | string | undefined
>z3 : number | undefined
>z && x : number | undefined
>z : string | number | undefined
>x : number
const z4 = z && b;
>z4 : boolean | string | number | undefined
>z && b : boolean | string | number | undefined
>z4 : boolean | undefined
>z && b : boolean | undefined
>z : string | number | undefined
>b : boolean
const z5 = z && v;
>z5 : void | string | number
>z && v : void | string | number
>z5 : void
>z && v : void
>z : string | number | undefined
>v : void
const z6 = z && u;
>z6 : string | number | undefined
>z && u : string | number | undefined
>z6 : undefined
>z && u : undefined
>z : string | number | undefined
>u : undefined
const z7 = z && n;
>z7 : string | number | null | undefined
>z && n : string | number | null | undefined
>z7 : null | undefined
>z && n : null | undefined
>z : string | number | undefined
>n : null
@@ -0,0 +1,140 @@
tests/cases/compiler/missingFunctionImplementation.ts(3,3): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(8,3): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(16,3): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(22,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(28,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(33,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(41,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(48,10): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(49,10): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(49,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(52,19): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(57,10): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(60,19): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(60,19): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(65,19): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(73,19): error TS2393: Duplicate function implementation.
tests/cases/compiler/missingFunctionImplementation.ts(74,19): error TS2393: Duplicate function implementation.
tests/cases/compiler/missingFunctionImplementation.ts(75,19): error TS2393: Duplicate function implementation.
tests/cases/compiler/missingFunctionImplementation.ts(78,19): error TS2393: Duplicate function implementation.
==== tests/cases/compiler/missingFunctionImplementation.ts (19 errors) ====
export class C1 {
m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// merged with a namespace
export class C2 {
m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
export namespace C2 { }
// merged with a namespace, multiple overloads
class C3 {
m(a, b);
m(a);
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C3 { }
// static methods, multiple overloads
class C4 {
static m(a): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// static methods, multiple overloads
class C5 {
static m(a): void;
static m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// merged with namespace, static methods
class C6 {
static m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C6 {
}
// merged with namespace, static methods, multiple overloads
class C7 {
static m(a): void;
static m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C7 {
}
// merged with namespace, static methods, duplicate declarations
class C8 {
static m(a): void;
~
!!! error TS2300: Duplicate identifier 'm'.
static m(a, b): void;
~
!!! error TS2300: Duplicate identifier 'm'.
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C8 {
export function m(a?, b?): void { }
~
!!! error TS2300: Duplicate identifier 'm'.
}
// merged with namespace, static methods, duplicate declarations
class C9 {
static m(a): void { }
~
!!! error TS2300: Duplicate identifier 'm'.
}
namespace C9 {
export function m(a): void;
~
!!! error TS2300: Duplicate identifier 'm'.
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// merged namespaces
namespace N10 {
export function m(a): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace N10 {
export function m(a): void { }
}
// merged namespaces, duplicate defintions
namespace N12 {
export function m(a): void;
~
!!! error TS2393: Duplicate function implementation.
export function m(): void;
~
!!! error TS2393: Duplicate function implementation.
export function m(a?): void { }
~
!!! error TS2393: Duplicate function implementation.
}
namespace N12 {
export function m(a): void { }
~
!!! error TS2393: Duplicate function implementation.
}
@@ -0,0 +1,168 @@
//// [missingFunctionImplementation.ts]
export class C1 {
m(): void;
}
// merged with a namespace
export class C2 {
m(): void;
}
export namespace C2 { }
// merged with a namespace, multiple overloads
class C3 {
m(a, b);
m(a);
}
namespace C3 { }
// static methods, multiple overloads
class C4 {
static m(a): void;
}
// static methods, multiple overloads
class C5 {
static m(a): void;
static m(): void;
}
// merged with namespace, static methods
class C6 {
static m(): void;
}
namespace C6 {
}
// merged with namespace, static methods, multiple overloads
class C7 {
static m(a): void;
static m(): void;
}
namespace C7 {
}
// merged with namespace, static methods, duplicate declarations
class C8 {
static m(a): void;
static m(a, b): void;
}
namespace C8 {
export function m(a?, b?): void { }
}
// merged with namespace, static methods, duplicate declarations
class C9 {
static m(a): void { }
}
namespace C9 {
export function m(a): void;
}
// merged namespaces
namespace N10 {
export function m(a): void;
}
namespace N10 {
export function m(a): void { }
}
// merged namespaces, duplicate defintions
namespace N12 {
export function m(a): void;
export function m(): void;
export function m(a?): void { }
}
namespace N12 {
export function m(a): void { }
}
//// [missingFunctionImplementation.js]
"use strict";
var C1 = (function () {
function C1() {
}
return C1;
}());
exports.C1 = C1;
// merged with a namespace
var C2 = (function () {
function C2() {
}
return C2;
}());
exports.C2 = C2;
// merged with a namespace, multiple overloads
var C3 = (function () {
function C3() {
}
return C3;
}());
// static methods, multiple overloads
var C4 = (function () {
function C4() {
}
return C4;
}());
// static methods, multiple overloads
var C5 = (function () {
function C5() {
}
return C5;
}());
// merged with namespace, static methods
var C6 = (function () {
function C6() {
}
return C6;
}());
// merged with namespace, static methods, multiple overloads
var C7 = (function () {
function C7() {
}
return C7;
}());
// merged with namespace, static methods, duplicate declarations
var C8 = (function () {
function C8() {
}
return C8;
}());
var C8;
(function (C8) {
function m(a, b) { }
C8.m = m;
})(C8 || (C8 = {}));
// merged with namespace, static methods, duplicate declarations
var C9 = (function () {
function C9() {
}
C9.m = function (a) { };
return C9;
}());
var C9;
(function (C9) {
})(C9 || (C9 = {}));
// merged namespaces
var N10;
(function (N10) {
})(N10 || (N10 = {}));
var N10;
(function (N10) {
function m(a) { }
N10.m = m;
})(N10 || (N10 = {}));
// merged namespaces, duplicate defintions
var N12;
(function (N12) {
function m(a) { }
N12.m = m;
})(N12 || (N12 = {}));
var N12;
(function (N12) {
function m(a) { }
N12.m = m;
})(N12 || (N12 = {}));
@@ -0,0 +1,16 @@
tests/cases/compiler/missingFunctionImplementation2_a.ts(3,19): error TS2384: Overload signatures must all be ambient or non-ambient.
tests/cases/compiler/missingFunctionImplementation2_b.ts(1,17): error TS2391: Function implementation is missing or not immediately following the declaration.
==== tests/cases/compiler/missingFunctionImplementation2_a.ts (1 errors) ====
export {};
declare module "./missingFunctionImplementation2_b.ts" {
export function f(a, b): void;
~
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
}
==== tests/cases/compiler/missingFunctionImplementation2_b.ts (1 errors) ====
export function f(a?, b?);
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/missingFunctionImplementation2.ts] ////
//// [missingFunctionImplementation2_a.ts]
export {};
declare module "./missingFunctionImplementation2_b.ts" {
export function f(a, b): void;
}
//// [missingFunctionImplementation2_b.ts]
export function f(a?, b?);
//// [missingFunctionImplementation2_a.js]
"use strict";
//// [missingFunctionImplementation2_b.js]
"use strict";
@@ -0,0 +1,26 @@
//// [strictNullLogicalAndOr.ts]
// Repro from #9113
let sinOrCos = Math.random() < .5;
let choice = sinOrCos && Math.sin || Math.cos;
choice(Math.PI);
function sq(n?: number): number {
const r = n !== undefined && n*n || 0;
return r;
}
sq(3);
//// [strictNullLogicalAndOr.js]
// Repro from #9113
var sinOrCos = Math.random() < .5;
var choice = sinOrCos && Math.sin || Math.cos;
choice(Math.PI);
function sq(n) {
var r = n !== undefined && n * n || 0;
return r;
}
sq(3);
@@ -0,0 +1,44 @@
=== tests/cases/compiler/strictNullLogicalAndOr.ts ===
// Repro from #9113
let sinOrCos = Math.random() < .5;
>sinOrCos : Symbol(sinOrCos, Decl(strictNullLogicalAndOr.ts, 3, 3))
>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.d.ts, --, --))
let choice = sinOrCos && Math.sin || Math.cos;
>choice : Symbol(choice, Decl(strictNullLogicalAndOr.ts, 4, 3))
>sinOrCos : Symbol(sinOrCos, Decl(strictNullLogicalAndOr.ts, 3, 3))
>Math.sin : Symbol(Math.sin, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>sin : Symbol(Math.sin, Decl(lib.d.ts, --, --))
>Math.cos : Symbol(Math.cos, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>cos : Symbol(Math.cos, Decl(lib.d.ts, --, --))
choice(Math.PI);
>choice : Symbol(choice, Decl(strictNullLogicalAndOr.ts, 4, 3))
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
function sq(n?: number): number {
>sq : Symbol(sq, Decl(strictNullLogicalAndOr.ts, 6, 16))
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
const r = n !== undefined && n*n || 0;
>r : Symbol(r, Decl(strictNullLogicalAndOr.ts, 9, 7))
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
>undefined : Symbol(undefined)
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
return r;
>r : Symbol(r, Decl(strictNullLogicalAndOr.ts, 9, 7))
}
sq(3);
>sq : Symbol(sq, Decl(strictNullLogicalAndOr.ts, 6, 16))
@@ -0,0 +1,57 @@
=== tests/cases/compiler/strictNullLogicalAndOr.ts ===
// Repro from #9113
let sinOrCos = Math.random() < .5;
>sinOrCos : boolean
>Math.random() < .5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>.5 : number
let choice = sinOrCos && Math.sin || Math.cos;
>choice : (x: number) => number
>sinOrCos && Math.sin || Math.cos : (x: number) => number
>sinOrCos && Math.sin : (x: number) => number
>sinOrCos : boolean
>Math.sin : (x: number) => number
>Math : Math
>sin : (x: number) => number
>Math.cos : (x: number) => number
>Math : Math
>cos : (x: number) => number
choice(Math.PI);
>choice(Math.PI) : number
>choice : (x: number) => number
>Math.PI : number
>Math : Math
>PI : number
function sq(n?: number): number {
>sq : (n?: number | undefined) => number
>n : number | undefined
const r = n !== undefined && n*n || 0;
>r : number
>n !== undefined && n*n || 0 : number
>n !== undefined && n*n : number
>n !== undefined : boolean
>n : number | undefined
>undefined : undefined
>n*n : number
>n : number
>n : number
>0 : number
return r;
>r : number
}
sq(3);
>sq(3) : number
>sq : (n?: number | undefined) => number
>3 : number
@@ -0,0 +1,2 @@
export const x = 0;
//# sourceMappingURL=file.js.map
@@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map
@@ -0,0 +1,7 @@
file.ts(1,3): error TS1005: ';' expected.
==== file.ts (1 errors) ====
a b
~
!!! error TS1005: ';' expected.
@@ -0,0 +1,4 @@
"use strict";
a;
b;
//# sourceMappingURL=file.js.map
@@ -0,0 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
var x = 0;
});
//# sourceMappingURL=file.js.map
@@ -0,0 +1,4 @@
"use strict";
/// <reference path="file2.ts" />
var x = 0;
//# sourceMappingURL=file.js.map
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map
@@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map
@@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map
@@ -0,0 +1,5 @@
define(["require", "exports", "SomeOtherName"], function (require, exports, SomeName_1) {
"use strict";
use(SomeName_1.foo);
});
//# sourceMappingURL=file.js.map
@@ -0,0 +1,15 @@
System.register(["SomeOtherName"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var SomeName_1;
return {
setters:[
function (SomeName_1_1) {
SomeName_1 = SomeName_1_1;
}],
execute: function() {
use(SomeName_1.foo);
}
}
});
//# sourceMappingURL=file.js.map
@@ -0,0 +1,13 @@
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports", "SomeOtherName"], factory);
}
})(function (require, exports) {
"use strict";
var SomeName_1 = require("SomeOtherName");
use(SomeName_1.foo);
});
//# sourceMappingURL=file.js.map
@@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map
@@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map
@@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map
@@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map
@@ -0,0 +1,12 @@
System.register("NamedModule", [], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var x;
return {
setters:[],
execute: function() {
var x = 1;
}
}
});
//# sourceMappingURL=file.js.map
@@ -0,0 +1,3 @@
"use strict";
var a = 10;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
var a = 10;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
var x;
//# sourceMappingURL=b.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,2 @@
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map
@@ -0,0 +1,3 @@
"use strict";
x;
//# sourceMappingURL=input.js.map

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