Skip to content

[Transforms] merging "master" on 06/15/2016 #9218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jun 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4d3cff1
Add upper limit for the program size, fix readDirectory for the symli…
zhengbli Mar 11, 2016
b155fa8
Add comments
zhengbli Mar 12, 2016
a3aa000
CR feedback / Change upper limit / Add disableSizeLimit compiler option
zhengbli Mar 14, 2016
a6a466c
online and offline CR feedback
zhengbli Mar 15, 2016
d4eb3b8
Don't count current opened client file if it's TS file
zhengbli Mar 15, 2016
a839d93
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 17, 2016
225e3b4
Speed up file searching
zhengbli Mar 17, 2016
c8e0b00
Make language service optional for a project
zhengbli Mar 17, 2016
d7e1d34
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 18, 2016
cb46f16
Fix failed tests
zhengbli Mar 18, 2016
74e3d7b
Fix project updateing issue after editing config file
zhengbli Mar 18, 2016
1b76294
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 24, 2016
5c9ce9e
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 28, 2016
94d44ad
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Jun 9, 2016
d387050
Fix merging issues and multiple project scenario
zhengbli Jun 9, 2016
4383f1a
Refactoring
zhengbli Jun 9, 2016
e41b10b
add test and spit commandLineParser changes to another PR
zhengbli Jun 10, 2016
1e7790d
Fix #8523
zhengbli Jun 10, 2016
85ac67f
check the declaration and use order if both are not in module file
zhengbli Jun 10, 2016
e86f183
Fix #9098: report missing function impelementation errors for merged …
mhegazy Jun 11, 2016
5a90c67
Added tests.
DanielRosenwasser Jun 14, 2016
0a1c4c6
Accepted baselines.
DanielRosenwasser Jun 14, 2016
c9bab05
Check tuple types when getting the type node's type.
DanielRosenwasser Jun 14, 2016
82b385f
Accepted baselines.
DanielRosenwasser Jun 14, 2016
784a765
Fix #9173: clear out lib and types before creating a program in trans…
mhegazy Jun 15, 2016
38c89af
Merge pull request #9174 from Microsoft/Fix9173
mhegazy Jun 15, 2016
14c2bcf
Added tests.
DanielRosenwasser Jun 15, 2016
f786c5c
Accepted baselines.
DanielRosenwasser Jun 15, 2016
52a96ac
Always check type assertion types.
DanielRosenwasser Jun 15, 2016
74a784c
Accepted baselines.
DanielRosenwasser Jun 15, 2016
8a025fc
Use helper functions to simplify range tests
Jun 15, 2016
6366a6d
Remove String, Number, and Boolean from TypeFlags.Falsy
ahejlsberg Jun 15, 2016
28b241e
Add regression test
ahejlsberg Jun 15, 2016
c9e5bcb
Accept new baselines
ahejlsberg Jun 15, 2016
dd0411a
Allow property declarations in .js files
Jun 15, 2016
9b6472a
Remove old test
Jun 15, 2016
e2376a7
Merge pull request #9185 from Microsoft/simplify_range_tests
Jun 15, 2016
a3a0c98
Merge pull request #9188 from Microsoft/relaxLogicalAnd
ahejlsberg Jun 15, 2016
97be083
Merge pull request #9100 from Microsoft/Fix9098
mhegazy Jun 15, 2016
a1e0504
Merge pull request #9189 from Microsoft/js_property_declaration
Jun 15, 2016
9a2cf11
Merge pull request #9170 from Microsoft/emptyTupleAssertions
DanielRosenwasser Jun 15, 2016
8c38cbf
Merge pull request #9073 from zhengbli/i8523
zhengbli Jun 15, 2016
7bb739f
Merge pull request #9083 from zhengbli/i6853
zhengbli Jun 15, 2016
3354436
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Jun 15, 2016
550d912
Refactor code to make if statements cheaper
zhengbli Jun 15, 2016
95ae809
Merge pull request #7486 from zhengbli/fixLargeProjectTry2
zhengbli Jun 16, 2016
62eb4cd
Merge branch 'master' into transforms_mergemaster_0615
Jun 16, 2016
8ef30c8
Fix test failure from mergining with master
Jun 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,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;
}
Expand Down Expand Up @@ -11529,7 +11530,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)) {
Expand Down Expand Up @@ -13564,9 +13568,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) {
Expand Down Expand Up @@ -13599,7 +13600,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);
}

Expand Down Expand Up @@ -13633,8 +13634,8 @@ namespace ts {
}

// Abstract methods can't have an implementation -- in particular, they don't need one.
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
!hasModifier(lastSeenNonAmbientDeclaration, ModifierFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) {
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
!(getModifierFlags(lastSeenNonAmbientDeclaration) & ModifierFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) {
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
}

Expand Down
10 changes: 8 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ namespace ts {
},
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
},
{
name: "disableProjectSizeLimit",
type: "boolean"
},
{
name: "strictNullChecks",
type: "boolean",
Expand Down Expand Up @@ -771,8 +775,10 @@ namespace ts {
}
}

filesSeen[fileName] = true;
fileNames.push(fileName);
if (!filesSeen[fileName]) {
filesSeen[fileName] = true;
fileNames.push(fileName);
}
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2925,10 +2925,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
Expand Down
15 changes: 13 additions & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,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;
Expand Down
15 changes: 13 additions & 2 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,7 +83,7 @@ namespace ts {
getEnvironmentVariable?(name: string): string;
};

export var sys: System = (function () {
export var sys: System = (function() {

function getWScriptSystem(): System {

Expand Down Expand Up @@ -509,7 +510,7 @@ namespace ts {
}
);
},
resolvePath: function (path: string): string {
resolvePath: function(path: string): string {
return _path.resolve(path);
},
fileExists,
Expand Down Expand Up @@ -549,6 +550,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);
},
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,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 */
Expand Down Expand Up @@ -2632,6 +2633,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[];
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,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.
Expand Down
113 changes: 82 additions & 31 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,78 @@ namespace FourSlash {
}
}

public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
public verifyReferencesCountIs(count: number, localFilesOnly = true) {
const references = this.getReferencesAtCaret();
let referencesCount = 0;

if (localFilesOnly) {
const localFiles = this.testData.files.map<string>(file => file.fileName);
// Count only the references in local files. Filter the ones in lib and other files.
ts.forEach(references, entry => {
if (localFiles.some((fileName) => fileName === entry.fileName)) {
referencesCount++;
}
});
}
else {
referencesCount = references && references.length || 0;
}

if (referencesCount !== count) {
const condition = localFilesOnly ? "excluding libs" : "including libs";
this.raiseError("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount);
}
}

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) {
Expand All @@ -752,29 +817,7 @@ namespace FourSlash {

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;

if (localFilesOnly) {
const localFiles = this.testData.files.map<string>(file => file.fileName);
// Count only the references in local files. Filter the ones in lib and other files.
ts.forEach(references, entry => {
if (localFiles.some((fileName) => fileName === entry.fileName)) {
referencesCount++;
}
});
}
else {
referencesCount = references && references.length || 0;
}

if (referencesCount !== count) {
const condition = localFilesOnly ? "excluding libs" : "including libs";
this.raiseError("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount);
}
}

private getMemberListAtCaret() {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading