Skip to content

Commit abd7db7

Browse files
Merge branch 'master' into fixDeFaultOfFindAllRefsToMaster
Conflicts: src/compiler/checker.ts src/compiler/types.ts
2 parents 6a7ce44 + 644ea82 commit abd7db7

File tree

1,033 files changed

+29388
-20383
lines changed

Some content is hidden

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

1,033 files changed

+29388
-20383
lines changed

CONTRIBUTING.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,75 @@ Your pull request should:
3131
## Running the Tests
3232
To run all tests, invoke the runtests target using jake:
3333

34-
`jake runtests`
34+
```Shell
35+
jake runtests
36+
```
3537

3638
This run will all tests; to run only a specific subset of tests, use:
3739

38-
`jake runtests tests=<regex>`
40+
```Shell
41+
jake runtests tests=<regex>
42+
```
3943

4044
e.g. to run all compiler baseline tests:
4145

42-
`jake runtests tests=compiler`
46+
```Shell
47+
jake runtests tests=compiler
48+
```
4349

44-
or to run specifc test:tests\cases\compiler\2dArrays.ts
50+
or to run specifc test: `tests\cases\compiler\2dArrays.ts`
4551

46-
`jake runtests tests=2dArrays`
52+
```Shell
53+
jake runtests tests=2dArrays
54+
```
4755

4856
## Adding a Test
49-
To add a new testcase, simply place a .ts file in tests\cases\compiler containing code that exemplifies the bugfix or change you are making.
57+
To add a new testcase, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
5058

51-
These files support metadata tags in the format // @name: value . The supported names and values are:
59+
These files support metadata tags in the format `// @metaDataName: value`. The supported names and values are:
5260

53-
* comments, sourcemap, noimplicitany, declaration: true or false (corresponds to the compiler command-line options of the same name)
54-
* target: ES3 or ES5 (same as compiler)
55-
* out, outDir: path (same as compiler)
56-
* module: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
61+
* `comments`, `sourcemap`, `noimplicitany`, `declaration`: true or false (corresponds to the compiler command-line options of the same name)
62+
* `target`: ES3 or ES5 (same as compiler)
63+
* `out`, outDir: path (same as compiler)
64+
* `module`: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
65+
* `fileName`: path
66+
* These tags delimit sections of a file to be used as separate compilation units. They are useful for tests relating to modules. See below for examples.
5767

58-
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in tests\cases\conformance in an appropriately-named subfolder.
68+
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
5969
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
6070

71+
### Tests for multiple files
72+
73+
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
74+
75+
```TypeScript
76+
// @fileName: file1.ts
77+
export function f() {
78+
}
79+
80+
// @fileName: file2.ts
81+
import { f as g } from "file1";
82+
83+
var x = g();
84+
```
85+
86+
One can also write a project test, but it is slightly more involved.
87+
6188
## Managing the Baselines
62-
Compiler testcases generate baselines that track the emitted .js, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
89+
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
6390

6491
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
6592

66-
`jake diff`
93+
```Shell
94+
jake diff
95+
```
6796

6897
After verifying that the changes in the baselines are correct, run
6998

70-
`jake baseline-accept`
99+
```Shell
100+
jake baseline-accept
101+
```
71102

72-
to establish the new baselines as the desired behavior. This will change the files in tests\baselines\reference, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
103+
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
73104

74105
**Note** that baseline-accept should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.

Jakefile.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ var serverSources = [
105105
return path.join(serverDirectory, f);
106106
});
107107

108+
var languageServiceLibrarySources = [
109+
"editorServices.ts",
110+
"protocol.d.ts",
111+
"session.ts"
112+
].map(function (f) {
113+
return path.join(serverDirectory, f);
114+
}).concat(servicesSources);
115+
108116
var harnessSources = [
109117
"harness.ts",
110118
"sourceMapRecorder.ts",
@@ -129,7 +137,8 @@ var harnessSources = [
129137
"services/preProcessFile.ts",
130138
"services/patternMatcher.ts",
131139
"versionCache.ts",
132-
"convertToBase64.ts"
140+
"convertToBase64.ts",
141+
"transpile.ts"
133142
].map(function (f) {
134143
return path.join(unittestsDirectory, f);
135144
})).concat([
@@ -148,7 +157,7 @@ var librarySourceMap = [
148157
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
149158
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
150159
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
151-
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"]},
160+
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
152161
];
153162

154163
var libraryTargets = librarySourceMap.map(function (f) {
@@ -360,14 +369,28 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
360369
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
361370
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
362371
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
363-
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"');
372+
definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
364373
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
365374
});
366375

367376

368377
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
369378
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
370379

380+
var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
381+
compileFile(
382+
lsslFile,
383+
languageServiceLibrarySources,
384+
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
385+
/*prefixes*/ [copyright],
386+
/*useBuiltCompiler*/ true,
387+
/*noOutFile*/ false,
388+
/*generateDeclarations*/ true);
389+
390+
// Local target to build the language service server library
391+
desc("Builds language service server library");
392+
task("lssl", [lsslFile]);
393+
371394
// Local target to build the compiler and services
372395
desc("Builds the full compiler and services");
373396
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
@@ -504,9 +527,9 @@ function cleanTestDirs() {
504527
}
505528

506529
// used to pass data from jake command line directly to run.js
507-
function writeTestConfigFile(tests, testConfigFile) {
530+
function writeTestConfigFile(tests, light, testConfigFile) {
508531
console.log('Running test(s): ' + tests);
509-
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}';
532+
var testConfigContents = JSON.stringify({ test: [tests], light: light });
510533
fs.writeFileSync('test.config', testConfigContents);
511534
}
512535

@@ -522,13 +545,14 @@ task("runtests", ["tests", builtLocalDirectory], function() {
522545
cleanTestDirs();
523546
host = "mocha"
524547
tests = process.env.test || process.env.tests || process.env.t;
548+
var light = process.env.light || false;
525549
var testConfigFile = 'test.config';
526550
if(fs.existsSync(testConfigFile)) {
527551
fs.unlinkSync(testConfigFile);
528552
}
529553

530-
if(tests) {
531-
writeTestConfigFile(tests, testConfigFile);
554+
if(tests || light) {
555+
writeTestConfigFile(tests, light, testConfigFile);
532556
}
533557

534558
if (tests && tests.toLocaleLowerCase() === "rwc") {
@@ -571,12 +595,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
571595
port = process.env.port || process.env.p || '8888';
572596
browser = process.env.browser || process.env.b || "IE";
573597
tests = process.env.test || process.env.tests || process.env.t;
598+
var light = process.env.light || false;
574599
var testConfigFile = 'test.config';
575600
if(fs.existsSync(testConfigFile)) {
576601
fs.unlinkSync(testConfigFile);
577602
}
578-
if(tests) {
579-
writeTestConfigFile(tests, testConfigFile);
603+
if(tests || light) {
604+
writeTestConfigFile(tests, light, testConfigFile);
580605
}
581606

582607
tests = tests ? tests : '';

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript)
66

77
# TypeScript
8-
9-
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8+
9+
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1010

1111
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang).
1212

@@ -31,7 +31,7 @@ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob
3131

3232
## Building
3333

34-
In order to build the TypeScript compiler, ensure that you have [Git](http://git-scm.com/downloads) and [Node.js](http://nodejs.org/) installed. Note that you need to have autocrlf off as we track whitespace changes (`git config --global core.autocrlf false`).
34+
In order to build the TypeScript compiler, ensure that you have [Git](http://git-scm.com/downloads) and [Node.js](http://nodejs.org/) installed.
3535

3636
Clone a copy of the repo:
3737

bin/lib.core.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ interface ArrayConstructor {
11651165
(arrayLength?: number): any[];
11661166
<T>(arrayLength: number): T[];
11671167
<T>(...items: T[]): T[];
1168-
isArray(arg: any): boolean;
1168+
isArray(arg: any): arg is Array<any>;
11691169
prototype: Array<any>;
11701170
}
11711171

bin/lib.core.es6.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ interface ArrayConstructor {
11651165
(arrayLength?: number): any[];
11661166
<T>(arrayLength: number): T[];
11671167
<T>(...items: T[]): T[];
1168-
isArray(arg: any): boolean;
1168+
isArray(arg: any): arg is Array<any>;
11691169
prototype: Array<any>;
11701170
}
11711171

bin/lib.d.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ interface ArrayConstructor {
11651165
(arrayLength?: number): any[];
11661166
<T>(arrayLength: number): T[];
11671167
<T>(...items: T[]): T[];
1168-
isArray(arg: any): boolean;
1168+
isArray(arg: any): arg is Array<any>;
11691169
prototype: Array<any>;
11701170
}
11711171

@@ -3531,6 +3531,11 @@ declare module Intl {
35313531
currency?: string;
35323532
currencyDisplay?: string;
35333533
useGrouping?: boolean;
3534+
minimumintegerDigits?: number;
3535+
minimumFractionDigits?: number;
3536+
maximumFractionDigits?: number;
3537+
minimumSignificantDigits?: number;
3538+
maximumSignificantDigits?: number;
35343539
}
35353540

35363541
interface ResolvedNumberFormatOptions {
@@ -3593,7 +3598,7 @@ declare module Intl {
35933598
}
35943599

35953600
interface DateTimeFormat {
3596-
format(date: number): string;
3601+
format(date?: Date | number): string;
35973602
resolvedOptions(): ResolvedDateTimeFormatOptions;
35983603
}
35993604
var DateTimeFormat: {
@@ -11335,10 +11340,10 @@ declare var MediaQueryList: {
1133511340
interface MediaSource extends EventTarget {
1133611341
activeSourceBuffers: SourceBufferList;
1133711342
duration: number;
11338-
readyState: string;
11343+
readyState: number;
1133911344
sourceBuffers: SourceBufferList;
1134011345
addSourceBuffer(type: string): SourceBuffer;
11341-
endOfStream(error?: string): void;
11346+
endOfStream(error?: number): void;
1134211347
removeSourceBuffer(sourceBuffer: SourceBuffer): void;
1134311348
}
1134411349

@@ -12067,7 +12072,7 @@ declare var PopStateEvent: {
1206712072

1206812073
interface Position {
1206912074
coords: Coordinates;
12070-
timestamp: Date;
12075+
timestamp: number;
1207112076
}
1207212077

1207312078
declare var Position: {
@@ -14748,9 +14753,17 @@ interface WebGLRenderingContext {
1474814753
stencilMaskSeparate(face: number, mask: number): void;
1474914754
stencilOp(fail: number, zfail: number, zpass: number): void;
1475014755
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
14756+
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void;
14757+
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void;
14758+
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void;
14759+
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void;
1475114760
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void;
1475214761
texParameterf(target: number, pname: number, param: number): void;
1475314762
texParameteri(target: number, pname: number, param: number): void;
14763+
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void;
14764+
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void;
14765+
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void;
14766+
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void;
1475414767
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void;
1475514768
uniform1f(location: WebGLUniformLocation, x: number): void;
1475614769
uniform1fv(location: WebGLUniformLocation, v: any): void;
@@ -15990,10 +16003,11 @@ interface DocumentEvent {
1599016003
createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent;
1599116004
createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent;
1599216005
createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent;
16006+
createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent;
1599316007
createEvent(eventInterface:"CloseEvent"): CloseEvent;
1599416008
createEvent(eventInterface:"CommandEvent"): CommandEvent;
1599516009
createEvent(eventInterface:"CompositionEvent"): CompositionEvent;
15996-
createEvent(eventInterface: "CustomEvent"): CustomEvent;
16010+
createEvent(eventInterface:"CustomEvent"): CustomEvent;
1599716011
createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent;
1599816012
createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent;
1599916013
createEvent(eventInterface:"DragEvent"): DragEvent;
@@ -16016,8 +16030,6 @@ interface DocumentEvent {
1601616030
createEvent(eventInterface:"MouseEvent"): MouseEvent;
1601716031
createEvent(eventInterface:"MouseEvents"): MouseEvent;
1601816032
createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent;
16019-
createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent;
16020-
createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent;
1602116033
createEvent(eventInterface:"MutationEvent"): MutationEvent;
1602216034
createEvent(eventInterface:"MutationEvents"): MutationEvent;
1602316035
createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent;
@@ -16630,6 +16642,7 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) =>
1663016642
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
1663116643
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
1663216644
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
16645+
1663316646
/////////////////////////////
1663416647
/// WorkerGlobalScope APIs
1663516648
/////////////////////////////

0 commit comments

Comments
 (0)