mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-29 00:06:17 -05:00
Merge branch 'master' into ownJsonParsing
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
12
src/lib/es5.d.ts
vendored
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
27
tests/baselines/reference/jsxFactoryQualifiedNameWithEs5.js
Normal file
27
tests/baselines/reference/jsxFactoryQualifiedNameWithEs5.js
Normal 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;
|
||||
}());
|
||||
;
|
||||
@@ -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)
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
22
tests/baselines/reference/objectFreeze.errors.txt
Normal file
22
tests/baselines/reference/objectFreeze.errors.txt
Normal 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.
|
||||
|
||||
29
tests/baselines/reference/objectFreeze.js
Normal file
29
tests/baselines/reference/objectFreeze.js
Normal 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();
|
||||
17
tests/cases/compiler/jsxFactoryQualifiedNameWithEs5.ts
Normal file
17
tests/cases/compiler/jsxFactoryQualifiedNameWithEs5.ts
Normal 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>;
|
||||
}
|
||||
};
|
||||
12
tests/cases/compiler/objectFreeze.ts
Normal file
12
tests/cases/compiler/objectFreeze.ts
Normal 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();
|
||||
Reference in New Issue
Block a user