Skip to content

Commit 6419de9

Browse files
committed
Merge branch 'master' into ownJsonParsing
2 parents 005123f + 72cee3e commit 6419de9

12 files changed

+212
-12
lines changed

src/compiler/factory.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -1677,16 +1677,10 @@ namespace ts {
16771677

16781678
function createJsxFactoryExpressionFromEntityName(jsxFactory: EntityName, parent: JsxOpeningLikeElement): Expression {
16791679
if (isQualifiedName(jsxFactory)) {
1680-
return createPropertyAccess(
1681-
createJsxFactoryExpressionFromEntityName(
1682-
jsxFactory.left,
1683-
parent
1684-
),
1685-
setEmitFlags(
1686-
getMutableClone(jsxFactory.right),
1687-
EmitFlags.NoSourceMap
1688-
)
1689-
);
1680+
const left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
1681+
const right = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
1682+
right.text = jsxFactory.right.text;
1683+
return createPropertyAccess(left, right);
16901684
}
16911685
else {
16921686
return createReactNamespace(jsxFactory.text, parent);

src/harness/unittests/tsserverProjectSystem.ts

+29
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,35 @@ namespace ts.projectSystem {
578578
checkWatchedDirectories(host, ["/a/b/c", "/a/b", "/a"]);
579579
});
580580

581+
it("can handle tsconfig file name with difference casing", () => {
582+
const f1 = {
583+
path: "/a/b/app.ts",
584+
content: "let x = 1"
585+
};
586+
const config = {
587+
path: "/a/b/tsconfig.json",
588+
content: JSON.stringify({
589+
include: []
590+
})
591+
};
592+
593+
const host = createServerHost([f1, config], { useCaseSensitiveFileNames: false });
594+
const service = createProjectService(host);
595+
service.openExternalProject(<protocol.ExternalProject>{
596+
projectFileName: "/a/b/project.csproj",
597+
rootFiles: toExternalFiles([f1.path, combinePaths(getDirectoryPath(config.path).toUpperCase(), getBaseFileName(config.path))]),
598+
options: {}
599+
});
600+
service.checkNumberOfProjects({ configuredProjects: 1 });
601+
checkProjectActualFiles(service.configuredProjects[0], []);
602+
603+
service.openClientFile(f1.path);
604+
service.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
605+
606+
checkProjectActualFiles(service.configuredProjects[0], []);
607+
checkProjectActualFiles(service.inferredProjects[0], [f1.path]);
608+
})
609+
581610
it("create configured project without file list", () => {
582611
const configFile: FileOrFolder = {
583612
path: "/a/b/tsconfig.json",

src/lib/es5.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ interface ObjectConstructor {
176176
*/
177177
seal<T>(o: T): T;
178178

179+
/**
180+
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
181+
* @param o Object on which to lock the attributes.
182+
*/
183+
freeze<T>(a: T[]): ReadonlyArray<T>;
184+
185+
/**
186+
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
187+
* @param o Object on which to lock the attributes.
188+
*/
189+
freeze<T extends Function>(f: T): T;
190+
179191
/**
180192
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
181193
* @param o Object on which to lock the attributes.

src/server/editorServices.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ namespace ts.server {
257257

258258
private changedFiles: ScriptInfo[];
259259

260-
private toCanonicalFileName: (f: string) => string;
260+
readonly toCanonicalFileName: (f: string) => string;
261261

262262
public lastDeletedFile: ScriptInfo;
263263

@@ -777,7 +777,13 @@ namespace ts.server {
777777
}
778778

779779
private findConfiguredProjectByProjectName(configFileName: NormalizedPath) {
780-
return findProjectByName(configFileName, this.configuredProjects);
780+
// make sure that casing of config file name is consistent
781+
configFileName = asNormalizedPath(this.toCanonicalFileName(configFileName));
782+
for (const proj of this.configuredProjects) {
783+
if (proj.canonicalConfigFilePath === configFileName) {
784+
return proj;
785+
}
786+
}
781787
}
782788

783789
private findExternalProjectByProjectName(projectFileName: string) {

src/server/project.ts

+2
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ namespace ts.server {
817817
private directoryWatcher: FileWatcher;
818818
private directoriesWatchedForWildcards: Map<FileWatcher>;
819819
private typeRootsWatchers: FileWatcher[];
820+
readonly canonicalConfigFilePath: NormalizedPath;
820821

821822
/** Used for configured projects which may have multiple open roots */
822823
openRefCount = 0;
@@ -830,6 +831,7 @@ namespace ts.server {
830831
languageServiceEnabled: boolean,
831832
public compileOnSaveEnabled: boolean) {
832833
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
834+
this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName));
833835
}
834836

835837
getConfigFilePath() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [index.tsx]
2+
3+
import "./jsx";
4+
5+
var skate: any;
6+
const React = { createElement: skate.h };
7+
8+
class Component {
9+
renderCallback() {
10+
return <div>test</div>;
11+
}
12+
};
13+
14+
//// [index.js]
15+
"use strict";
16+
require("./jsx");
17+
var skate;
18+
var React = { createElement: skate.h };
19+
var Component = (function () {
20+
function Component() {
21+
}
22+
Component.prototype.renderCallback = function () {
23+
return skate.h("div", null, "test");
24+
};
25+
return Component;
26+
}());
27+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/index.tsx ===
2+
3+
import "./jsx";
4+
5+
var skate: any;
6+
>skate : Symbol(skate, Decl(index.tsx, 3, 3))
7+
8+
const React = { createElement: skate.h };
9+
>React : Symbol(React, Decl(index.tsx, 4, 5))
10+
>createElement : Symbol(createElement, Decl(index.tsx, 4, 15))
11+
>skate : Symbol(skate, Decl(index.tsx, 3, 3))
12+
13+
class Component {
14+
>Component : Symbol(Component, Decl(index.tsx, 4, 41))
15+
16+
renderCallback() {
17+
>renderCallback : Symbol(Component.renderCallback, Decl(index.tsx, 6, 17))
18+
19+
return <div>test</div>;
20+
>div : Symbol(unknown)
21+
>div : Symbol(unknown)
22+
}
23+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
=== tests/cases/compiler/index.tsx ===
2+
3+
import "./jsx";
4+
5+
var skate: any;
6+
>skate : any
7+
8+
const React = { createElement: skate.h };
9+
>React : { createElement: any; }
10+
>{ createElement: skate.h } : { createElement: any; }
11+
>createElement : any
12+
>skate.h : any
13+
>skate : any
14+
>h : any
15+
16+
class Component {
17+
>Component : Component
18+
19+
renderCallback() {
20+
>renderCallback : () => any
21+
22+
return <div>test</div>;
23+
><div>test</div> : any
24+
>div : any
25+
>div : any
26+
}
27+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
2+
tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.
3+
4+
5+
==== tests/cases/compiler/objectFreeze.ts (2 errors) ====
6+
const f = Object.freeze(function foo(a: number, b: string) { return false; });
7+
f(1, "") === false;
8+
9+
class C { constructor(a: number) { } }
10+
const c = Object.freeze(C);
11+
new c(1);
12+
13+
const a = Object.freeze([1, 2, 3]);
14+
a[0] = a[2].toString();
15+
~~~~
16+
!!! error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
17+
18+
const o = Object.freeze({ a: 1, b: "string" });
19+
o.b = o.a.toString();
20+
~
21+
!!! error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.
22+
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//// [objectFreeze.ts]
2+
const f = Object.freeze(function foo(a: number, b: string) { return false; });
3+
f(1, "") === false;
4+
5+
class C { constructor(a: number) { } }
6+
const c = Object.freeze(C);
7+
new c(1);
8+
9+
const a = Object.freeze([1, 2, 3]);
10+
a[0] = a[2].toString();
11+
12+
const o = Object.freeze({ a: 1, b: "string" });
13+
o.b = o.a.toString();
14+
15+
16+
//// [objectFreeze.js]
17+
var f = Object.freeze(function foo(a, b) { return false; });
18+
f(1, "") === false;
19+
var C = (function () {
20+
function C(a) {
21+
}
22+
return C;
23+
}());
24+
var c = Object.freeze(C);
25+
new c(1);
26+
var a = Object.freeze([1, 2, 3]);
27+
a[0] = a[2].toString();
28+
var o = Object.freeze({ a: 1, b: "string" });
29+
o.b = o.a.toString();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@module: commonjs
2+
//@target: es5
3+
//@jsx: react
4+
//@jsxFactory: skate.h
5+
//@noEmit: false
6+
7+
// @filename: index.tsx
8+
import "./jsx";
9+
10+
var skate: any;
11+
const React = { createElement: skate.h };
12+
13+
class Component {
14+
renderCallback() {
15+
return <div>test</div>;
16+
}
17+
};

tests/cases/compiler/objectFreeze.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const f = Object.freeze(function foo(a: number, b: string) { return false; });
2+
f(1, "") === false;
3+
4+
class C { constructor(a: number) { } }
5+
const c = Object.freeze(C);
6+
new c(1);
7+
8+
const a = Object.freeze([1, 2, 3]);
9+
a[0] = a[2].toString();
10+
11+
const o = Object.freeze({ a: 1, b: "string" });
12+
o.b = o.a.toString();

0 commit comments

Comments
 (0)