Skip to content

Commit a652517

Browse files
committed
Merge branch 'master' into configuration-inheritance
2 parents 23c1c49 + 670f0c9 commit a652517

File tree

4 files changed

+189
-188
lines changed

4 files changed

+189
-188
lines changed

Gulpfile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
710710
const originalMap = file.sourceMap;
711711
const prebundledContent = file.contents.toString();
712712
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
713-
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
713+
originalMap.sources = originalMap.sources.map(s => path.resolve("src", s));
714714
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
715715
originalMap.file = "built/local/_stream_0.js";
716716

src/compiler/performance.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace ts {
33
declare const performance: { now?(): number } | undefined;
44
/** Gets a timestamp with (at least) ms resolution */
5-
export const timestamp = typeof performance !== "undefined" && performance.now ? performance.now : Date.now ? Date.now : () => +(new Date());
5+
export const timestamp = typeof performance !== "undefined" && performance.now ? () => performance.now() : Date.now ? Date.now : () => +(new Date());
66
}
77

88
/*@internal*/
@@ -106,4 +106,4 @@ namespace ts.performance {
106106
measures = undefined;
107107
profilerEvent = undefined;
108108
}
109-
}
109+
}
+185-185
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,185 @@
1-
/// <reference path="..\harness.ts" />
2-
/// <reference path="..\..\compiler\commandLineParser.ts" />
3-
4-
namespace ts {
5-
describe("parseConfigFileTextToJson", () => {
6-
function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic }) {
7-
const parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
8-
assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject));
9-
}
10-
11-
function assertParseError(jsonText: string) {
12-
const parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
13-
assert.isTrue(undefined === parsed.config);
14-
assert.isTrue(undefined !== parsed.error);
15-
}
16-
17-
function assertParseErrorWithExcludesKeyword(jsonText: string) {
18-
const parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
19-
const parsedCommand = ts.parseJsonConfigFileContent(parsed.config, ts.sys, "tests/cases/unittests");
20-
assert.isTrue(parsedCommand.errors && parsedCommand.errors.length === 1 &&
21-
parsedCommand.errors[0].code === ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude.code);
22-
}
23-
24-
function assertParseFileList(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedFileList: string[]) {
25-
const json = JSON.parse(jsonText);
26-
const host: ParseConfigHost = new Utils.MockParseConfigHost(basePath, true, allFileList);
27-
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
28-
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
29-
}
30-
31-
it("returns empty config for file with only whitespaces", () => {
32-
assertParseResult("", { config : {} });
33-
assertParseResult(" ", { config : {} });
34-
});
35-
36-
it("returns empty config for file with comments only", () => {
37-
assertParseResult("// Comment", { config: {} });
38-
assertParseResult("/* Comment*/", { config: {} });
39-
});
40-
41-
it("returns empty config when config is empty object", () => {
42-
assertParseResult("{}", { config: {} });
43-
});
44-
45-
it("returns config object without comments", () => {
46-
assertParseResult(
47-
`{ // Excluded files
48-
"exclude": [
49-
// Exclude d.ts
50-
"file.d.ts"
51-
]
52-
}`, { config: { exclude: ["file.d.ts"] } });
53-
54-
assertParseResult(
55-
`{
56-
/* Excluded
57-
Files
58-
*/
59-
"exclude": [
60-
/* multiline comments can be in the middle of a line */"file.d.ts"
61-
]
62-
}`, { config: { exclude: ["file.d.ts"] } });
63-
});
64-
65-
it("keeps string content untouched", () => {
66-
assertParseResult(
67-
`{
68-
"exclude": [
69-
"xx//file.d.ts"
70-
]
71-
}`, { config: { exclude: ["xx//file.d.ts"] } });
72-
assertParseResult(
73-
`{
74-
"exclude": [
75-
"xx/*file.d.ts*/"
76-
]
77-
}`, { config: { exclude: ["xx/*file.d.ts*/"] } });
78-
});
79-
80-
it("handles escaped characters in strings correctly", () => {
81-
assertParseResult(
82-
`{
83-
"exclude": [
84-
"xx\\"//files"
85-
]
86-
}`, { config: { exclude: ["xx\"//files"] } });
87-
88-
assertParseResult(
89-
`{
90-
"exclude": [
91-
"xx\\\\" // end of line comment
92-
]
93-
}`, { config: { exclude: ["xx\\"] } });
94-
});
95-
96-
it("returns object with error when json is invalid", () => {
97-
assertParseError("invalid");
98-
});
99-
100-
it("returns object when users correctly specify library", () => {
101-
assertParseResult(
102-
`{
103-
"compilerOptions": {
104-
"lib": ["es5"]
105-
}
106-
}`, {
107-
config: { compilerOptions: { lib: ["es5"] } }
108-
});
109-
110-
assertParseResult(
111-
`{
112-
"compilerOptions": {
113-
"lib": ["es5", "es6"]
114-
}
115-
}`, {
116-
config: { compilerOptions: { lib: ["es5", "es6"] } }
117-
});
118-
});
119-
120-
it("returns error when tsconfig have excludes", () => {
121-
assertParseErrorWithExcludesKeyword(
122-
`{
123-
"compilerOptions": {
124-
"lib": ["es5"]
125-
},
126-
"excludes": [
127-
"foge.ts"
128-
]
129-
}`);
130-
});
131-
132-
it("ignore dotted files and folders", () => {
133-
assertParseFileList(
134-
`{}`,
135-
"tsconfig.json",
136-
"/apath",
137-
["/apath/test.ts", "/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"],
138-
["/apath/test.ts"]
139-
);
140-
});
141-
142-
it("allow dotted files and folders when explicitly requested", () => {
143-
assertParseFileList(
144-
`{
145-
"files": ["/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"]
146-
}`,
147-
"tsconfig.json",
148-
"/apath",
149-
["/apath/test.ts", "/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"],
150-
["/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"]
151-
);
152-
});
153-
154-
it("always exclude outDir", () => {
155-
const tsconfigWithoutExclude =
156-
`{
157-
"compilerOptions": {
158-
"outDir": "bin"
159-
}
160-
}`;
161-
const tsconfigWithExclude =
162-
`{
163-
"compilerOptions": {
164-
"outDir": "bin"
165-
},
166-
"exclude": [ "obj" ]
167-
}`;
168-
const rootDir = "/";
169-
const allFiles = ["/bin/a.ts", "/b.ts"];
170-
const expectedFiles = ["/b.ts"];
171-
assertParseFileList(tsconfigWithoutExclude, "tsconfig.json", rootDir, allFiles, expectedFiles);
172-
assertParseFileList(tsconfigWithExclude, "tsconfig.json", rootDir, allFiles, expectedFiles);
173-
});
174-
175-
it("implicitly exclude common package folders", () => {
176-
assertParseFileList(
177-
`{}`,
178-
"tsconfig.json",
179-
"/",
180-
["/node_modules/a.ts", "/bower_components/b.ts", "/jspm_packages/c.ts", "/d.ts", "/folder/e.ts"],
181-
["/d.ts", "/folder/e.ts"]
182-
);
183-
});
184-
});
185-
}
1+
/// <reference path="..\harness.ts" />
2+
/// <reference path="..\..\compiler\commandLineParser.ts" />
3+
4+
namespace ts {
5+
describe("parseConfigFileTextToJson", () => {
6+
function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic }) {
7+
const parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
8+
assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject));
9+
}
10+
11+
function assertParseError(jsonText: string) {
12+
const parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
13+
assert.isTrue(undefined === parsed.config);
14+
assert.isTrue(undefined !== parsed.error);
15+
}
16+
17+
function assertParseErrorWithExcludesKeyword(jsonText: string) {
18+
const parsed = ts.parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
19+
const parsedCommand = ts.parseJsonConfigFileContent(parsed.config, ts.sys, "tests/cases/unittests");
20+
assert.isTrue(parsedCommand.errors && parsedCommand.errors.length === 1 &&
21+
parsedCommand.errors[0].code === ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude.code);
22+
}
23+
24+
function assertParseFileList(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedFileList: string[]) {
25+
const json = JSON.parse(jsonText);
26+
const host: ParseConfigHost = new Utils.MockParseConfigHost(basePath, true, allFileList);
27+
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
28+
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
29+
}
30+
31+
it("returns empty config for file with only whitespaces", () => {
32+
assertParseResult("", { config : {} });
33+
assertParseResult(" ", { config : {} });
34+
});
35+
36+
it("returns empty config for file with comments only", () => {
37+
assertParseResult("// Comment", { config: {} });
38+
assertParseResult("/* Comment*/", { config: {} });
39+
});
40+
41+
it("returns empty config when config is empty object", () => {
42+
assertParseResult("{}", { config: {} });
43+
});
44+
45+
it("returns config object without comments", () => {
46+
assertParseResult(
47+
`{ // Excluded files
48+
"exclude": [
49+
// Exclude d.ts
50+
"file.d.ts"
51+
]
52+
}`, { config: { exclude: ["file.d.ts"] } });
53+
54+
assertParseResult(
55+
`{
56+
/* Excluded
57+
Files
58+
*/
59+
"exclude": [
60+
/* multiline comments can be in the middle of a line */"file.d.ts"
61+
]
62+
}`, { config: { exclude: ["file.d.ts"] } });
63+
});
64+
65+
it("keeps string content untouched", () => {
66+
assertParseResult(
67+
`{
68+
"exclude": [
69+
"xx//file.d.ts"
70+
]
71+
}`, { config: { exclude: ["xx//file.d.ts"] } });
72+
assertParseResult(
73+
`{
74+
"exclude": [
75+
"xx/*file.d.ts*/"
76+
]
77+
}`, { config: { exclude: ["xx/*file.d.ts*/"] } });
78+
});
79+
80+
it("handles escaped characters in strings correctly", () => {
81+
assertParseResult(
82+
`{
83+
"exclude": [
84+
"xx\\"//files"
85+
]
86+
}`, { config: { exclude: ["xx\"//files"] } });
87+
88+
assertParseResult(
89+
`{
90+
"exclude": [
91+
"xx\\\\" // end of line comment
92+
]
93+
}`, { config: { exclude: ["xx\\"] } });
94+
});
95+
96+
it("returns object with error when json is invalid", () => {
97+
assertParseError("invalid");
98+
});
99+
100+
it("returns object when users correctly specify library", () => {
101+
assertParseResult(
102+
`{
103+
"compilerOptions": {
104+
"lib": ["es5"]
105+
}
106+
}`, {
107+
config: { compilerOptions: { lib: ["es5"] } }
108+
});
109+
110+
assertParseResult(
111+
`{
112+
"compilerOptions": {
113+
"lib": ["es5", "es6"]
114+
}
115+
}`, {
116+
config: { compilerOptions: { lib: ["es5", "es6"] } }
117+
});
118+
});
119+
120+
it("returns error when tsconfig have excludes", () => {
121+
assertParseErrorWithExcludesKeyword(
122+
`{
123+
"compilerOptions": {
124+
"lib": ["es5"]
125+
},
126+
"excludes": [
127+
"foge.ts"
128+
]
129+
}`);
130+
});
131+
132+
it("ignore dotted files and folders", () => {
133+
assertParseFileList(
134+
`{}`,
135+
"tsconfig.json",
136+
"/apath",
137+
["/apath/test.ts", "/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"],
138+
["/apath/test.ts"]
139+
);
140+
});
141+
142+
it("allow dotted files and folders when explicitly requested", () => {
143+
assertParseFileList(
144+
`{
145+
"files": ["/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"]
146+
}`,
147+
"tsconfig.json",
148+
"/apath",
149+
["/apath/test.ts", "/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"],
150+
["/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"]
151+
);
152+
});
153+
154+
it("always exclude outDir", () => {
155+
const tsconfigWithoutExclude =
156+
`{
157+
"compilerOptions": {
158+
"outDir": "bin"
159+
}
160+
}`;
161+
const tsconfigWithExclude =
162+
`{
163+
"compilerOptions": {
164+
"outDir": "bin"
165+
},
166+
"exclude": [ "obj" ]
167+
}`;
168+
const rootDir = "/";
169+
const allFiles = ["/bin/a.ts", "/b.ts"];
170+
const expectedFiles = ["/b.ts"];
171+
assertParseFileList(tsconfigWithoutExclude, "tsconfig.json", rootDir, allFiles, expectedFiles);
172+
assertParseFileList(tsconfigWithExclude, "tsconfig.json", rootDir, allFiles, expectedFiles);
173+
});
174+
175+
it("implicitly exclude common package folders", () => {
176+
assertParseFileList(
177+
`{}`,
178+
"tsconfig.json",
179+
"/",
180+
["/node_modules/a.ts", "/bower_components/b.ts", "/jspm_packages/c.ts", "/d.ts", "/folder/e.ts"],
181+
["/d.ts", "/folder/e.ts"]
182+
);
183+
});
184+
});
185+
}

0 commit comments

Comments
 (0)