Merge branch 'master' into ownJsonParsing

This commit is contained in:
Sheetal Nandi
2016-11-23 13:29:10 -08:00
12 changed files with 212 additions and 12 deletions

View File

@@ -1677,16 +1677,10 @@ namespace ts {
function createJsxFactoryExpressionFromEntityName(jsxFactory: EntityName, parent: JsxOpeningLikeElement): Expression {
if (isQualifiedName(jsxFactory)) {
return createPropertyAccess(
createJsxFactoryExpressionFromEntityName(
jsxFactory.left,
parent
),
setEmitFlags(
getMutableClone(jsxFactory.right),
EmitFlags.NoSourceMap
)
);
const left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
const right = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
right.text = jsxFactory.right.text;
return createPropertyAccess(left, right);
}
else {
return createReactNamespace(jsxFactory.text, parent);

View File

@@ -578,6 +578,35 @@ namespace ts.projectSystem {
checkWatchedDirectories(host, ["/a/b/c", "/a/b", "/a"]);
});
it("can handle tsconfig file name with difference casing", () => {
const f1 = {
path: "/a/b/app.ts",
content: "let x = 1"
};
const config = {
path: "/a/b/tsconfig.json",
content: JSON.stringify({
include: []
})
};
const host = createServerHost([f1, config], { useCaseSensitiveFileNames: false });
const service = createProjectService(host);
service.openExternalProject(<protocol.ExternalProject>{
projectFileName: "/a/b/project.csproj",
rootFiles: toExternalFiles([f1.path, combinePaths(getDirectoryPath(config.path).toUpperCase(), getBaseFileName(config.path))]),
options: {}
});
service.checkNumberOfProjects({ configuredProjects: 1 });
checkProjectActualFiles(service.configuredProjects[0], []);
service.openClientFile(f1.path);
service.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
checkProjectActualFiles(service.configuredProjects[0], []);
checkProjectActualFiles(service.inferredProjects[0], [f1.path]);
})
it("create configured project without file list", () => {
const configFile: FileOrFolder = {
path: "/a/b/tsconfig.json",

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

@@ -176,6 +176,18 @@ interface ObjectConstructor {
*/
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze<T>(a: T[]): ReadonlyArray<T>;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze<T extends Function>(f: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.

View File

@@ -257,7 +257,7 @@ namespace ts.server {
private changedFiles: ScriptInfo[];
private toCanonicalFileName: (f: string) => string;
readonly toCanonicalFileName: (f: string) => string;
public lastDeletedFile: ScriptInfo;
@@ -777,7 +777,13 @@ namespace ts.server {
}
private findConfiguredProjectByProjectName(configFileName: NormalizedPath) {
return findProjectByName(configFileName, this.configuredProjects);
// make sure that casing of config file name is consistent
configFileName = asNormalizedPath(this.toCanonicalFileName(configFileName));
for (const proj of this.configuredProjects) {
if (proj.canonicalConfigFilePath === configFileName) {
return proj;
}
}
}
private findExternalProjectByProjectName(projectFileName: string) {

View File

@@ -817,6 +817,7 @@ namespace ts.server {
private directoryWatcher: FileWatcher;
private directoriesWatchedForWildcards: Map<FileWatcher>;
private typeRootsWatchers: FileWatcher[];
readonly canonicalConfigFilePath: NormalizedPath;
/** Used for configured projects which may have multiple open roots */
openRefCount = 0;
@@ -830,6 +831,7 @@ namespace ts.server {
languageServiceEnabled: boolean,
public compileOnSaveEnabled: boolean) {
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName));
}
getConfigFilePath() {

View File

@@ -0,0 +1,27 @@
//// [index.tsx]
import "./jsx";
var skate: any;
const React = { createElement: skate.h };
class Component {
renderCallback() {
return <div>test</div>;
}
};
//// [index.js]
"use strict";
require("./jsx");
var skate;
var React = { createElement: skate.h };
var Component = (function () {
function Component() {
}
Component.prototype.renderCallback = function () {
return skate.h("div", null, "test");
};
return Component;
}());
;

View File

@@ -0,0 +1,23 @@
=== tests/cases/compiler/index.tsx ===
import "./jsx";
var skate: any;
>skate : Symbol(skate, Decl(index.tsx, 3, 3))
const React = { createElement: skate.h };
>React : Symbol(React, Decl(index.tsx, 4, 5))
>createElement : Symbol(createElement, Decl(index.tsx, 4, 15))
>skate : Symbol(skate, Decl(index.tsx, 3, 3))
class Component {
>Component : Symbol(Component, Decl(index.tsx, 4, 41))
renderCallback() {
>renderCallback : Symbol(Component.renderCallback, Decl(index.tsx, 6, 17))
return <div>test</div>;
>div : Symbol(unknown)
>div : Symbol(unknown)
}
};

View File

@@ -0,0 +1,27 @@
=== tests/cases/compiler/index.tsx ===
import "./jsx";
var skate: any;
>skate : any
const React = { createElement: skate.h };
>React : { createElement: any; }
>{ createElement: skate.h } : { createElement: any; }
>createElement : any
>skate.h : any
>skate : any
>h : any
class Component {
>Component : Component
renderCallback() {
>renderCallback : () => any
return <div>test</div>;
><div>test</div> : any
>div : any
>div : any
}
};

View File

@@ -0,0 +1,22 @@
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.
==== tests/cases/compiler/objectFreeze.ts (2 errors) ====
const f = Object.freeze(function foo(a: number, b: string) { return false; });
f(1, "") === false;
class C { constructor(a: number) { } }
const c = Object.freeze(C);
new c(1);
const a = Object.freeze([1, 2, 3]);
a[0] = a[2].toString();
~~~~
!!! error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
const o = Object.freeze({ a: 1, b: "string" });
o.b = o.a.toString();
~
!!! error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.

View File

@@ -0,0 +1,29 @@
//// [objectFreeze.ts]
const f = Object.freeze(function foo(a: number, b: string) { return false; });
f(1, "") === false;
class C { constructor(a: number) { } }
const c = Object.freeze(C);
new c(1);
const a = Object.freeze([1, 2, 3]);
a[0] = a[2].toString();
const o = Object.freeze({ a: 1, b: "string" });
o.b = o.a.toString();
//// [objectFreeze.js]
var f = Object.freeze(function foo(a, b) { return false; });
f(1, "") === false;
var C = (function () {
function C(a) {
}
return C;
}());
var c = Object.freeze(C);
new c(1);
var a = Object.freeze([1, 2, 3]);
a[0] = a[2].toString();
var o = Object.freeze({ a: 1, b: "string" });
o.b = o.a.toString();

View File

@@ -0,0 +1,17 @@
//@module: commonjs
//@target: es5
//@jsx: react
//@jsxFactory: skate.h
//@noEmit: false
// @filename: index.tsx
import "./jsx";
var skate: any;
const React = { createElement: skate.h };
class Component {
renderCallback() {
return <div>test</div>;
}
};

View File

@@ -0,0 +1,12 @@
const f = Object.freeze(function foo(a: number, b: string) { return false; });
f(1, "") === false;
class C { constructor(a: number) { } }
const c = Object.freeze(C);
new c(1);
const a = Object.freeze([1, 2, 3]);
a[0] = a[2].toString();
const o = Object.freeze({ a: 1, b: "string" });
o.b = o.a.toString();