Skip to content

Commit 8d47511

Browse files
committed
Merge branch 'master' into noEmitExtraVars
2 parents ae7f1be + 0971212 commit 8d47511

File tree

687 files changed

+3546
-1965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

687 files changed

+3546
-1965
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9421,8 +9421,8 @@ namespace ts {
94219421
let container = getSuperContainer(node, /*stopOnFunctions*/ true);
94229422
let needToCaptureLexicalThis = false;
94239423

9424+
// adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
94249425
if (!isCallExpression) {
9425-
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
94269426
while (container && container.kind === SyntaxKind.ArrowFunction) {
94279427
container = getSuperContainer(container, /*stopOnFunctions*/ true);
94289428
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
@@ -14439,6 +14439,7 @@ namespace ts {
1443914439
// constructors of derived classes must contain at least one super call somewhere in their function body.
1444014440
const containingClassDecl = <ClassDeclaration>node.parent;
1444114441
if (getClassExtendsHeritageClauseElement(containingClassDecl)) {
14442+
captureLexicalThis(node.parent, containingClassDecl);
1444214443
const classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
1444314444
const superCall = getSuperCallInConstructor(node);
1444414445
if (superCall) {
@@ -17713,9 +17714,11 @@ namespace ts {
1771317714
}
1771417715

1771517716
function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
17716-
if (node.parent.kind !== SyntaxKind.SourceFile && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.ModuleDeclaration) {
17717-
return grammarErrorOnFirstToken(node, errorMessage);
17717+
const isInAppropriateContext = node.parent.kind === SyntaxKind.SourceFile || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.ModuleDeclaration;
17718+
if (!isInAppropriateContext) {
17719+
grammarErrorOnFirstToken(node, errorMessage);
1771817720
}
17721+
return !isInAppropriateContext;
1771917722
}
1772017723

1772117724
function checkExportSpecifier(node: ExportSpecifier) {
@@ -17756,7 +17759,7 @@ namespace ts {
1775617759
checkExpressionCached(node.expression);
1775717760
}
1775817761

17759-
checkExternalModuleExports(<SourceFile | ModuleDeclaration>container);
17762+
checkExternalModuleExports(container);
1776017763

1776117764
if (node.isExportEquals && !isInAmbientContext(node)) {
1776217765
if (modulekind === ModuleKind.ES6) {

src/compiler/transformers/es6.ts

Lines changed: 234 additions & 54 deletions
Large diffs are not rendered by default.

src/compiler/utilities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,11 @@ namespace ts {
982982
}
983983

984984
/**
985-
* Given an super call\property node returns a closest node where either
986-
* - super call\property is legal in the node and not legal in the parent node the node.
985+
* Given an super call/property node, returns the closest node where
986+
* - a super call/property access is legal in the node and not legal in the parent node the node.
987987
* i.e. super call is legal in constructor but not legal in the class body.
988-
* - node is arrow function (so caller might need to call getSuperContainer in case it needs to climb higher)
989-
* - super call\property is definitely illegal in the node (but might be legal in some subnode)
988+
* - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher)
989+
* - a super call/property is definitely illegal in the container (but might be legal in some subnode)
990990
* i.e. super property access is illegal in function declaration but can be legal in the statement list
991991
*/
992992
export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,4 +2045,22 @@ namespace ts.projectSystem {
20452045
assert.equal(snap.getLength(), expectedLength, "Incorrect snapshot size");
20462046
}
20472047
});
2048+
2049+
describe("Language service", () => {
2050+
it("should work correctly on case-sensitive file systems", () => {
2051+
const lib = {
2052+
path: "/a/Lib/lib.d.ts",
2053+
content: "let x: number"
2054+
};
2055+
const f = {
2056+
path: "/a/b/app.ts",
2057+
content: "let x = 1;"
2058+
};
2059+
const host = createServerHost([lib, f], { executingFilePath: "/a/Lib/tsc.js", useCaseSensitiveFileNames: true });
2060+
const projectService = createProjectService(host);
2061+
projectService.openClientFile(f.path);
2062+
projectService.checkNumberOfProjects({ inferredProjects: 1 });
2063+
projectService.inferredProjects[0].getLanguageService().getProgram();
2064+
});
2065+
});
20482066
}

src/server/editorServices.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,14 @@ namespace ts.server {
10011001
}
10021002

10031003
getScriptInfoForNormalizedPath(fileName: NormalizedPath) {
1004-
return this.filenameToScriptInfo.get(normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName));
1004+
return this.getScriptInfoForPath(normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName));
10051005
}
10061006

1007+
getScriptInfoForPath(fileName: Path) {
1008+
return this.filenameToScriptInfo.get(fileName);
1009+
}
1010+
1011+
10071012
setHostConfiguration(args: protocol.ConfigureRequestArguments) {
10081013
if (args.file) {
10091014
const info = this.getScriptInfoForNormalizedPath(toNormalizedPath(args.file));

src/server/project.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,13 @@ namespace ts.server {
215215
}
216216

217217
getScriptInfos() {
218-
return map(this.program.getSourceFiles(), sourceFile => this.getScriptInfoLSHost(sourceFile.path));
218+
return map(this.program.getSourceFiles(), sourceFile => {
219+
const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.path);
220+
if (!scriptInfo) {
221+
Debug.assert(false, `scriptInfo for a file '${sourceFile.fileName}' is missing.`);
222+
}
223+
return scriptInfo;
224+
});
219225
}
220226

221227
getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean) {

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ namespace ts {
947947

948948
let lastTypesRootVersion = 0;
949949

950-
const useCaseSensitivefileNames = false;
950+
const useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames();
951951
const cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
952952

953953
const currentDirectory = host.getCurrentDirectory();

tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var A;
3838
var Point3d = (function (_super) {
3939
__extends(Point3d, _super);
4040
function Point3d() {
41-
_super.apply(this, arguments);
41+
return _super.apply(this, arguments) || this;
4242
}
4343
return Point3d;
4444
}(Point));

tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var A;
4141
var Point3d = (function (_super) {
4242
__extends(Point3d, _super);
4343
function Point3d() {
44-
_super.apply(this, arguments);
44+
return _super.apply(this, arguments) || this;
4545
}
4646
return Point3d;
4747
}(Point));

tests/baselines/reference/abstractClassInLocalScope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var __extends = (this && this.__extends) || function (d, b) {
2222
var B = (function (_super) {
2323
__extends(B, _super);
2424
function B() {
25-
_super.apply(this, arguments);
25+
return _super.apply(this, arguments) || this;
2626
}
2727
return B;
2828
}(A));

0 commit comments

Comments
 (0)