Merge pull request #3 from Microsoft/master

fetch latest code
This commit is contained in:
York Yao committed 2016-01-24 12:13:52 +08:00
commit 18094ebb54
391 files changed
+28411 -15551

No files matched your search

+42
View File
@@ -1,3 +1,45 @@
# Instructions for Logging Issues
## 1. Read the FAQ
Please [read the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) before logging new issues, even if you think you have found a bug.
Issues that ask questions answered in the FAQ will be closed without elaboration.
## 2. Search for Duplicates
[Search the existing issues](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue) before logging a new one.
## 3. Do you have a question?
The issue tracker is for **issues**, in other words, bugs and suggestions.
If you have a *question*, please use [http://stackoverflow.com/questions/tagged/typescript](Stack Overflow), [https://gitter.im/Microsoft/TypeScript](Gitter), your favorite search engine, or other resources.
Due to increased traffic, we can no longer answer questions in the issue tracker.
## 4. Did you find a bug?
When logging a bug, please be sure to include the following:
* What version of TypeScript you're using (run `tsc --v`)
* If at all possible, an *isolated* way to reproduce the behavior
* The behavior you expect to see, and the actual behavior
You can try out the nightly build of TypeScript (`npm install typescript@next`) to see if the bug has already been fixed.
## 5. Do you have a suggestion?
We also accept suggestions in the issue tracker.
Be sure to [check the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) and [search](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue) first.
In general, things we find useful when reviewing suggestins are:
* A description of the problem you're trying to solve
* An overview of the suggested solution
* Examples of how the suggestion would work in various places
* Code examples showing e.g. "this would be an error, this wouldn't"
* Code examples showing the generated JavaScript (if applicable)
* If relevant, precedent in other languages can be useful for establishing context and expected behavior
# Instructions for Contributing Code
## Contributing bug fixes
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved ("Milestone == Community") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
+7 -4
View File
@@ -163,13 +163,15 @@ var harnessSources = harnessCoreSources.concat([
}));
var librarySourceMap = [
{ target: "lib.core.d.ts", sources: ["core.d.ts"] },
{ target: "lib.core.d.ts", sources: ["header.d.ts", "core.d.ts"] },
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
{ target: "lib.es6.d.ts", sources: ["es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
{ target: "lib.d.ts", sources: ["header.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.core.es6.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts"]},
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
{ target: "lib.core.es7.d.ts", sources: ["header.d.ts", "core.d.ts", "es6.d.ts", "es7.d.ts"]},
{ target: "lib.es7.d.ts", sources: ["header.d.ts", "es6.d.ts", "es7.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
];
var libraryTargets = librarySourceMap.map(function (f) {
@@ -893,6 +895,7 @@ function getLinterOptions() {
function lintFileContents(options, path, contents) {
var ll = new Linter(path, contents, options);
console.log("Linting '" + path + "'.")
return ll.lint();
}
-1
View File
@@ -14,7 +14,6 @@ and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
+8 -9
View File
@@ -14,7 +14,6 @@ and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
@@ -5121,15 +5120,15 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
/**
+32 -14
View File
@@ -14,7 +14,6 @@ and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
@@ -5296,7 +5295,7 @@ interface Console {
select(element: Element): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(): void;
trace(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
}
@@ -5555,9 +5554,9 @@ interface DataTransferItemList {
length: number;
add(data: File): DataTransferItem;
clear(): void;
item(index: number): File;
item(index: number): DataTransferItem;
remove(index: number): void;
[index: number]: File;
[index: number]: DataTransferItem;
}
declare var DataTransferItemList: {
@@ -6610,6 +6609,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* @param content The text and HTML tags to write.
*/
writeln(...content: string[]): void;
createElement(tagName: "picture"): HTMLPictureElement;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -7022,6 +7023,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
matches(selector: string): boolean;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -7811,6 +7813,7 @@ interface HTMLCanvasElement extends HTMLElement {
* @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
*/
toDataURL(type?: string, ...args: any[]): string;
toBlob(): Blob;
}
declare var HTMLCanvasElement: {
@@ -10965,7 +10968,7 @@ interface IDBDatabase extends EventTarget {
objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
version: string;
version: number;
close(): void;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
@@ -11681,7 +11684,7 @@ declare var MediaQueryList: {
interface MediaSource extends EventTarget {
activeSourceBuffers: SourceBufferList;
duration: number;
readyState: number;
readyState: string;
sourceBuffers: SourceBufferList;
addSourceBuffer(type: string): SourceBuffer;
endOfStream(error?: number): void;
@@ -14410,17 +14413,16 @@ declare var Storage: {
}
interface StorageEvent extends Event {
key: string;
newValue: any;
oldValue: any;
storageArea: Storage;
url: string;
initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void;
key?: string;
oldValue?: string;
newValue?: string;
storageArea?: Storage;
}
declare var StorageEvent: {
prototype: StorageEvent;
new(): StorageEvent;
new (type: string, eventInitDict?: StorageEventInit): StorageEvent;
}
interface StyleMedia {
@@ -16018,7 +16020,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
msMatchMedia(mediaQuery: string): MediaQueryList;
msRequestAnimationFrame(callback: FrameRequestCallback): number;
msWriteProfilerMark(profilerMarkName: string): void;
open(url?: string, target?: string, features?: string, replace?: boolean): any;
open(url?: string, target?: string, features?: string, replace?: boolean): Window;
postMessage(message: any, targetOrigin: string, ports?: any): void;
print(): void;
prompt(message?: string, _default?: string): string;
@@ -16620,6 +16622,14 @@ interface XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface StorageEventInit extends EventInit {
key?: string;
oldValue?: string;
newValue?: string;
url: string;
storageArea?: Storage;
}
interface IDBObjectStoreParameters {
keyPath?: string | string[];
autoIncrement?: boolean;
@@ -16674,6 +16684,14 @@ declare var HTMLTemplateElement: {
new(): HTMLTemplateElement;
}
interface HTMLPictureElement extends HTMLElement {
}
declare var HTMLPictureElement: {
prototype: HTMLPictureElement;
new(): HTMLPictureElement;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@@ -16870,7 +16888,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void;
declare function msMatchMedia(mediaQuery: string): MediaQueryList;
declare function msRequestAnimationFrame(callback: FrameRequestCallback): number;
declare function msWriteProfilerMark(profilerMarkName: string): void;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): any;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window;
declare function postMessage(message: any, targetOrigin: string, ports?: any): void;
declare function print(): void;
declare function prompt(message?: string, _default?: string): string;
+32 -13
View File
@@ -1472,7 +1472,7 @@ interface Console {
select(element: Element): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(): void;
trace(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
}
@@ -1731,9 +1731,9 @@ interface DataTransferItemList {
length: number;
add(data: File): DataTransferItem;
clear(): void;
item(index: number): File;
item(index: number): DataTransferItem;
remove(index: number): void;
[index: number]: File;
[index: number]: DataTransferItem;
}
declare var DataTransferItemList: {
@@ -2786,6 +2786,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* @param content The text and HTML tags to write.
*/
writeln(...content: string[]): void;
createElement(tagName: "picture"): HTMLPictureElement;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -3198,6 +3200,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
matches(selector: string): boolean;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -3987,6 +3990,7 @@ interface HTMLCanvasElement extends HTMLElement {
* @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
*/
toDataURL(type?: string, ...args: any[]): string;
toBlob(): Blob;
}
declare var HTMLCanvasElement: {
@@ -7141,7 +7145,7 @@ interface IDBDatabase extends EventTarget {
objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
version: string;
version: number;
close(): void;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
@@ -7857,7 +7861,7 @@ declare var MediaQueryList: {
interface MediaSource extends EventTarget {
activeSourceBuffers: SourceBufferList;
duration: number;
readyState: number;
readyState: string;
sourceBuffers: SourceBufferList;
addSourceBuffer(type: string): SourceBuffer;
endOfStream(error?: number): void;
@@ -10586,17 +10590,16 @@ declare var Storage: {
}
interface StorageEvent extends Event {
key: string;
newValue: any;
oldValue: any;
storageArea: Storage;
url: string;
initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void;
key?: string;
oldValue?: string;
newValue?: string;
storageArea?: Storage;
}
declare var StorageEvent: {
prototype: StorageEvent;
new(): StorageEvent;
new (type: string, eventInitDict?: StorageEventInit): StorageEvent;
}
interface StyleMedia {
@@ -12194,7 +12197,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
msMatchMedia(mediaQuery: string): MediaQueryList;
msRequestAnimationFrame(callback: FrameRequestCallback): number;
msWriteProfilerMark(profilerMarkName: string): void;
open(url?: string, target?: string, features?: string, replace?: boolean): any;
open(url?: string, target?: string, features?: string, replace?: boolean): Window;
postMessage(message: any, targetOrigin: string, ports?: any): void;
print(): void;
prompt(message?: string, _default?: string): string;
@@ -12796,6 +12799,14 @@ interface XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface StorageEventInit extends EventInit {
key?: string;
oldValue?: string;
newValue?: string;
url: string;
storageArea?: Storage;
}
interface IDBObjectStoreParameters {
keyPath?: string | string[];
autoIncrement?: boolean;
@@ -12850,6 +12861,14 @@ declare var HTMLTemplateElement: {
new(): HTMLTemplateElement;
}
interface HTMLPictureElement extends HTMLElement {
}
declare var HTMLPictureElement: {
prototype: HTMLPictureElement;
new(): HTMLPictureElement;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@@ -13046,7 +13065,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void;
declare function msMatchMedia(mediaQuery: string): MediaQueryList;
declare function msRequestAnimationFrame(callback: FrameRequestCallback): number;
declare function msWriteProfilerMark(profilerMarkName: string): void;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): any;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window;
declare function postMessage(message: any, targetOrigin: string, ports?: any): void;
declare function print(): void;
declare function prompt(message?: string, _default?: string): string;
+41 -23
View File
@@ -13,6 +13,7 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare type PropertyKey = string | number | symbol;
interface Symbol {
@@ -1296,15 +1297,15 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
/**
@@ -1346,8 +1347,6 @@ interface PromiseConstructor {
}
declare var Promise: PromiseConstructor;
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
@@ -6629,7 +6628,7 @@ interface Console {
select(element: Element): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(): void;
trace(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
}
@@ -6888,9 +6887,9 @@ interface DataTransferItemList {
length: number;
add(data: File): DataTransferItem;
clear(): void;
item(index: number): File;
item(index: number): DataTransferItem;
remove(index: number): void;
[index: number]: File;
[index: number]: DataTransferItem;
}
declare var DataTransferItemList: {
@@ -7943,6 +7942,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* @param content The text and HTML tags to write.
*/
writeln(...content: string[]): void;
createElement(tagName: "picture"): HTMLPictureElement;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -8355,6 +8356,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
matches(selector: string): boolean;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -9144,6 +9146,7 @@ interface HTMLCanvasElement extends HTMLElement {
* @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
*/
toDataURL(type?: string, ...args: any[]): string;
toBlob(): Blob;
}
declare var HTMLCanvasElement: {
@@ -12298,7 +12301,7 @@ interface IDBDatabase extends EventTarget {
objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
version: string;
version: number;
close(): void;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
@@ -13014,7 +13017,7 @@ declare var MediaQueryList: {
interface MediaSource extends EventTarget {
activeSourceBuffers: SourceBufferList;
duration: number;
readyState: number;
readyState: string;
sourceBuffers: SourceBufferList;
addSourceBuffer(type: string): SourceBuffer;
endOfStream(error?: number): void;
@@ -15743,17 +15746,16 @@ declare var Storage: {
}
interface StorageEvent extends Event {
key: string;
newValue: any;
oldValue: any;
storageArea: Storage;
url: string;
initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void;
key?: string;
oldValue?: string;
newValue?: string;
storageArea?: Storage;
}
declare var StorageEvent: {
prototype: StorageEvent;
new(): StorageEvent;
new (type: string, eventInitDict?: StorageEventInit): StorageEvent;
}
interface StyleMedia {
@@ -17351,7 +17353,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
msMatchMedia(mediaQuery: string): MediaQueryList;
msRequestAnimationFrame(callback: FrameRequestCallback): number;
msWriteProfilerMark(profilerMarkName: string): void;
open(url?: string, target?: string, features?: string, replace?: boolean): any;
open(url?: string, target?: string, features?: string, replace?: boolean): Window;
postMessage(message: any, targetOrigin: string, ports?: any): void;
print(): void;
prompt(message?: string, _default?: string): string;
@@ -17953,6 +17955,14 @@ interface XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface StorageEventInit extends EventInit {
key?: string;
oldValue?: string;
newValue?: string;
url: string;
storageArea?: Storage;
}
interface IDBObjectStoreParameters {
keyPath?: string | string[];
autoIncrement?: boolean;
@@ -18007,6 +18017,14 @@ declare var HTMLTemplateElement: {
new(): HTMLTemplateElement;
}
interface HTMLPictureElement extends HTMLElement {
}
declare var HTMLPictureElement: {
prototype: HTMLPictureElement;
new(): HTMLPictureElement;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@@ -18203,7 +18221,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void;
declare function msMatchMedia(mediaQuery: string): MediaQueryList;
declare function msRequestAnimationFrame(callback: FrameRequestCallback): number;
declare function msWriteProfilerMark(profilerMarkName: string): void;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): any;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window;
declare function postMessage(message: any, targetOrigin: string, ports?: any): void;
declare function print(): void;
declare function prompt(message?: string, _default?: string): string;
+2 -2
View File
@@ -286,7 +286,7 @@ interface Console {
select(element: any): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(): void;
trace(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
}
@@ -526,7 +526,7 @@ interface IDBDatabase extends EventTarget {
objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
version: string;
version: number;
close(): void;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
+3048 -2636
View File
File diff suppressed because it is too large. Load diff
+4087 -3504
View File
File diff suppressed because it is too large. Load diff
+169 -149
View File
@@ -167,161 +167,162 @@ declare namespace ts {
SymbolKeyword = 131,
TypeKeyword = 132,
FromKeyword = 133,
OfKeyword = 134,
QualifiedName = 135,
ComputedPropertyName = 136,
TypeParameter = 137,
Parameter = 138,
Decorator = 139,
PropertySignature = 140,
PropertyDeclaration = 141,
MethodSignature = 142,
MethodDeclaration = 143,
Constructor = 144,
GetAccessor = 145,
SetAccessor = 146,
CallSignature = 147,
ConstructSignature = 148,
IndexSignature = 149,
TypePredicate = 150,
TypeReference = 151,
FunctionType = 152,
ConstructorType = 153,
TypeQuery = 154,
TypeLiteral = 155,
ArrayType = 156,
TupleType = 157,
UnionType = 158,
IntersectionType = 159,
ParenthesizedType = 160,
ThisType = 161,
StringLiteralType = 162,
ObjectBindingPattern = 163,
ArrayBindingPattern = 164,
BindingElement = 165,
ArrayLiteralExpression = 166,
ObjectLiteralExpression = 167,
PropertyAccessExpression = 168,
ElementAccessExpression = 169,
CallExpression = 170,
NewExpression = 171,
TaggedTemplateExpression = 172,
TypeAssertionExpression = 173,
ParenthesizedExpression = 174,
FunctionExpression = 175,
ArrowFunction = 176,
DeleteExpression = 177,
TypeOfExpression = 178,
VoidExpression = 179,
AwaitExpression = 180,
PrefixUnaryExpression = 181,
PostfixUnaryExpression = 182,
BinaryExpression = 183,
ConditionalExpression = 184,
TemplateExpression = 185,
YieldExpression = 186,
SpreadElementExpression = 187,
ClassExpression = 188,
OmittedExpression = 189,
ExpressionWithTypeArguments = 190,
AsExpression = 191,
TemplateSpan = 192,
SemicolonClassElement = 193,
Block = 194,
VariableStatement = 195,
EmptyStatement = 196,
ExpressionStatement = 197,
IfStatement = 198,
DoStatement = 199,
WhileStatement = 200,
ForStatement = 201,
ForInStatement = 202,
ForOfStatement = 203,
ContinueStatement = 204,
BreakStatement = 205,
ReturnStatement = 206,
WithStatement = 207,
SwitchStatement = 208,
LabeledStatement = 209,
ThrowStatement = 210,
TryStatement = 211,
DebuggerStatement = 212,
VariableDeclaration = 213,
VariableDeclarationList = 214,
FunctionDeclaration = 215,
ClassDeclaration = 216,
InterfaceDeclaration = 217,
TypeAliasDeclaration = 218,
EnumDeclaration = 219,
ModuleDeclaration = 220,
ModuleBlock = 221,
CaseBlock = 222,
ImportEqualsDeclaration = 223,
ImportDeclaration = 224,
ImportClause = 225,
NamespaceImport = 226,
NamedImports = 227,
ImportSpecifier = 228,
ExportAssignment = 229,
ExportDeclaration = 230,
NamedExports = 231,
ExportSpecifier = 232,
MissingDeclaration = 233,
ExternalModuleReference = 234,
JsxElement = 235,
JsxSelfClosingElement = 236,
JsxOpeningElement = 237,
JsxText = 238,
JsxClosingElement = 239,
JsxAttribute = 240,
JsxSpreadAttribute = 241,
JsxExpression = 242,
CaseClause = 243,
DefaultClause = 244,
HeritageClause = 245,
CatchClause = 246,
PropertyAssignment = 247,
ShorthandPropertyAssignment = 248,
EnumMember = 249,
SourceFile = 250,
JSDocTypeExpression = 251,
JSDocAllType = 252,
JSDocUnknownType = 253,
JSDocArrayType = 254,
JSDocUnionType = 255,
JSDocTupleType = 256,
JSDocNullableType = 257,
JSDocNonNullableType = 258,
JSDocRecordType = 259,
JSDocRecordMember = 260,
JSDocTypeReference = 261,
JSDocOptionalType = 262,
JSDocFunctionType = 263,
JSDocVariadicType = 264,
JSDocConstructorType = 265,
JSDocThisType = 266,
JSDocComment = 267,
JSDocTag = 268,
JSDocParameterTag = 269,
JSDocReturnTag = 270,
JSDocTypeTag = 271,
JSDocTemplateTag = 272,
SyntaxList = 273,
Count = 274,
GlobalKeyword = 134,
OfKeyword = 135,
QualifiedName = 136,
ComputedPropertyName = 137,
TypeParameter = 138,
Parameter = 139,
Decorator = 140,
PropertySignature = 141,
PropertyDeclaration = 142,
MethodSignature = 143,
MethodDeclaration = 144,
Constructor = 145,
GetAccessor = 146,
SetAccessor = 147,
CallSignature = 148,
ConstructSignature = 149,
IndexSignature = 150,
TypePredicate = 151,
TypeReference = 152,
FunctionType = 153,
ConstructorType = 154,
TypeQuery = 155,
TypeLiteral = 156,
ArrayType = 157,
TupleType = 158,
UnionType = 159,
IntersectionType = 160,
ParenthesizedType = 161,
ThisType = 162,
StringLiteralType = 163,
ObjectBindingPattern = 164,
ArrayBindingPattern = 165,
BindingElement = 166,
ArrayLiteralExpression = 167,
ObjectLiteralExpression = 168,
PropertyAccessExpression = 169,
ElementAccessExpression = 170,
CallExpression = 171,
NewExpression = 172,
TaggedTemplateExpression = 173,
TypeAssertionExpression = 174,
ParenthesizedExpression = 175,
FunctionExpression = 176,
ArrowFunction = 177,
DeleteExpression = 178,
TypeOfExpression = 179,
VoidExpression = 180,
AwaitExpression = 181,
PrefixUnaryExpression = 182,
PostfixUnaryExpression = 183,
BinaryExpression = 184,
ConditionalExpression = 185,
TemplateExpression = 186,
YieldExpression = 187,
SpreadElementExpression = 188,
ClassExpression = 189,
OmittedExpression = 190,
ExpressionWithTypeArguments = 191,
AsExpression = 192,
TemplateSpan = 193,
SemicolonClassElement = 194,
Block = 195,
VariableStatement = 196,
EmptyStatement = 197,
ExpressionStatement = 198,
IfStatement = 199,
DoStatement = 200,
WhileStatement = 201,
ForStatement = 202,
ForInStatement = 203,
ForOfStatement = 204,
ContinueStatement = 205,
BreakStatement = 206,
ReturnStatement = 207,
WithStatement = 208,
SwitchStatement = 209,
LabeledStatement = 210,
ThrowStatement = 211,
TryStatement = 212,
DebuggerStatement = 213,
VariableDeclaration = 214,
VariableDeclarationList = 215,
FunctionDeclaration = 216,
ClassDeclaration = 217,
InterfaceDeclaration = 218,
TypeAliasDeclaration = 219,
EnumDeclaration = 220,
ModuleDeclaration = 221,
ModuleBlock = 222,
CaseBlock = 223,
ImportEqualsDeclaration = 224,
ImportDeclaration = 225,
ImportClause = 226,
NamespaceImport = 227,
NamedImports = 228,
ImportSpecifier = 229,
ExportAssignment = 230,
ExportDeclaration = 231,
NamedExports = 232,
ExportSpecifier = 233,
MissingDeclaration = 234,
ExternalModuleReference = 235,
JsxElement = 236,
JsxSelfClosingElement = 237,
JsxOpeningElement = 238,
JsxText = 239,
JsxClosingElement = 240,
JsxAttribute = 241,
JsxSpreadAttribute = 242,
JsxExpression = 243,
CaseClause = 244,
DefaultClause = 245,
HeritageClause = 246,
CatchClause = 247,
PropertyAssignment = 248,
ShorthandPropertyAssignment = 249,
EnumMember = 250,
SourceFile = 251,
JSDocTypeExpression = 252,
JSDocAllType = 253,
JSDocUnknownType = 254,
JSDocArrayType = 255,
JSDocUnionType = 256,
JSDocTupleType = 257,
JSDocNullableType = 258,
JSDocNonNullableType = 259,
JSDocRecordType = 260,
JSDocRecordMember = 261,
JSDocTypeReference = 262,
JSDocOptionalType = 263,
JSDocFunctionType = 264,
JSDocVariadicType = 265,
JSDocConstructorType = 266,
JSDocThisType = 267,
JSDocComment = 268,
JSDocTag = 269,
JSDocParameterTag = 270,
JSDocReturnTag = 271,
JSDocTypeTag = 272,
JSDocTemplateTag = 273,
SyntaxList = 274,
Count = 275,
FirstAssignment = 56,
LastAssignment = 68,
FirstReservedWord = 70,
LastReservedWord = 105,
FirstKeyword = 70,
LastKeyword = 134,
LastKeyword = 135,
FirstFutureReservedWord = 106,
LastFutureReservedWord = 114,
FirstTypeNode = 150,
LastTypeNode = 162,
FirstTypeNode = 151,
LastTypeNode = 163,
FirstPunctuation = 15,
LastPunctuation = 68,
FirstToken = 0,
LastToken = 134,
LastToken = 135,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -330,7 +331,7 @@ declare namespace ts {
LastTemplateToken = 14,
FirstBinaryOperator = 25,
LastBinaryOperator = 68,
FirstNode = 135,
FirstNode = 136,
}
enum NodeFlags {
None = 0,
@@ -354,10 +355,16 @@ declare namespace ts {
ContainsThis = 262144,
HasImplicitReturn = 524288,
HasExplicitReturn = 1048576,
GlobalAugmentation = 2097152,
HasClassExtends = 4194304,
HasDecorators = 8388608,
HasParamDecorators = 16777216,
HasAsyncFunctions = 33554432,
Modifier = 1022,
AccessibilityModifier = 56,
BlockScoped = 24576,
ReachabilityCheckFlags = 1572864,
EmitHelperFlags = 62914560,
}
enum JsxFlags {
None = 0,
@@ -1141,6 +1148,7 @@ declare namespace ts {
getSymbolAtLocation(node: Node): Symbol;
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol;
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
getTypeAtLocation(node: Node): Type;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
@@ -1154,6 +1162,7 @@ declare namespace ts {
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
isUndefinedSymbol(symbol: Symbol): boolean;
isArgumentsSymbol(symbol: Symbol): boolean;
isUnknownSymbol(symbol: Symbol): boolean;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
@@ -1543,6 +1552,8 @@ declare namespace ts {
}
}
declare namespace ts {
type FileWatcherCallback = (path: string, removed?: boolean) => void;
type DirectoryWatcherCallback = (path: string) => void;
interface System {
args: string[];
newLine: string;
@@ -1550,8 +1561,8 @@ declare namespace ts {
write(s: string): void;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher;
watchFile?(path: Path, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
@@ -1565,6 +1576,10 @@ declare namespace ts {
interface FileWatcher {
close(): void;
}
interface DirectoryWatcher extends FileWatcher {
directoryPath: Path;
referenceCount: number;
}
var sys: System;
}
declare namespace ts {
@@ -2237,6 +2252,9 @@ declare namespace ts {
static jsxOpenTagName: string;
static jsxCloseTagName: string;
static jsxSelfClosingTagName: string;
static jsxAttribute: string;
static jsxText: string;
static jsxAttributeStringLiteralValue: string;
}
enum ClassificationType {
comment = 1,
@@ -2260,6 +2278,9 @@ declare namespace ts {
jsxOpenTagName = 19,
jsxCloseTagName = 20,
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
}
interface DisplayPartsSymbolWriter extends SymbolWriter {
displayParts(): SymbolDisplayPart[];
@@ -2283,7 +2304,6 @@ declare namespace ts {
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string;
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo;
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
+4698 -3926
View File
File diff suppressed because it is too large. Load diff
+169 -149
View File
@@ -167,161 +167,162 @@ declare namespace ts {
SymbolKeyword = 131,
TypeKeyword = 132,
FromKeyword = 133,
OfKeyword = 134,
QualifiedName = 135,
ComputedPropertyName = 136,
TypeParameter = 137,
Parameter = 138,
Decorator = 139,
PropertySignature = 140,
PropertyDeclaration = 141,
MethodSignature = 142,
MethodDeclaration = 143,
Constructor = 144,
GetAccessor = 145,
SetAccessor = 146,
CallSignature = 147,
ConstructSignature = 148,
IndexSignature = 149,
TypePredicate = 150,
TypeReference = 151,
FunctionType = 152,
ConstructorType = 153,
TypeQuery = 154,
TypeLiteral = 155,
ArrayType = 156,
TupleType = 157,
UnionType = 158,
IntersectionType = 159,
ParenthesizedType = 160,
ThisType = 161,
StringLiteralType = 162,
ObjectBindingPattern = 163,
ArrayBindingPattern = 164,
BindingElement = 165,
ArrayLiteralExpression = 166,
ObjectLiteralExpression = 167,
PropertyAccessExpression = 168,
ElementAccessExpression = 169,
CallExpression = 170,
NewExpression = 171,
TaggedTemplateExpression = 172,
TypeAssertionExpression = 173,
ParenthesizedExpression = 174,
FunctionExpression = 175,
ArrowFunction = 176,
DeleteExpression = 177,
TypeOfExpression = 178,
VoidExpression = 179,
AwaitExpression = 180,
PrefixUnaryExpression = 181,
PostfixUnaryExpression = 182,
BinaryExpression = 183,
ConditionalExpression = 184,
TemplateExpression = 185,
YieldExpression = 186,
SpreadElementExpression = 187,
ClassExpression = 188,
OmittedExpression = 189,
ExpressionWithTypeArguments = 190,
AsExpression = 191,
TemplateSpan = 192,
SemicolonClassElement = 193,
Block = 194,
VariableStatement = 195,
EmptyStatement = 196,
ExpressionStatement = 197,
IfStatement = 198,
DoStatement = 199,
WhileStatement = 200,
ForStatement = 201,
ForInStatement = 202,
ForOfStatement = 203,
ContinueStatement = 204,
BreakStatement = 205,
ReturnStatement = 206,
WithStatement = 207,
SwitchStatement = 208,
LabeledStatement = 209,
ThrowStatement = 210,
TryStatement = 211,
DebuggerStatement = 212,
VariableDeclaration = 213,
VariableDeclarationList = 214,
FunctionDeclaration = 215,
ClassDeclaration = 216,
InterfaceDeclaration = 217,
TypeAliasDeclaration = 218,
EnumDeclaration = 219,
ModuleDeclaration = 220,
ModuleBlock = 221,
CaseBlock = 222,
ImportEqualsDeclaration = 223,
ImportDeclaration = 224,
ImportClause = 225,
NamespaceImport = 226,
NamedImports = 227,
ImportSpecifier = 228,
ExportAssignment = 229,
ExportDeclaration = 230,
NamedExports = 231,
ExportSpecifier = 232,
MissingDeclaration = 233,
ExternalModuleReference = 234,
JsxElement = 235,
JsxSelfClosingElement = 236,
JsxOpeningElement = 237,
JsxText = 238,
JsxClosingElement = 239,
JsxAttribute = 240,
JsxSpreadAttribute = 241,
JsxExpression = 242,
CaseClause = 243,
DefaultClause = 244,
HeritageClause = 245,
CatchClause = 246,
PropertyAssignment = 247,
ShorthandPropertyAssignment = 248,
EnumMember = 249,
SourceFile = 250,
JSDocTypeExpression = 251,
JSDocAllType = 252,
JSDocUnknownType = 253,
JSDocArrayType = 254,
JSDocUnionType = 255,
JSDocTupleType = 256,
JSDocNullableType = 257,
JSDocNonNullableType = 258,
JSDocRecordType = 259,
JSDocRecordMember = 260,
JSDocTypeReference = 261,
JSDocOptionalType = 262,
JSDocFunctionType = 263,
JSDocVariadicType = 264,
JSDocConstructorType = 265,
JSDocThisType = 266,
JSDocComment = 267,
JSDocTag = 268,
JSDocParameterTag = 269,
JSDocReturnTag = 270,
JSDocTypeTag = 271,
JSDocTemplateTag = 272,
SyntaxList = 273,
Count = 274,
GlobalKeyword = 134,
OfKeyword = 135,
QualifiedName = 136,
ComputedPropertyName = 137,
TypeParameter = 138,
Parameter = 139,
Decorator = 140,
PropertySignature = 141,
PropertyDeclaration = 142,
MethodSignature = 143,
MethodDeclaration = 144,
Constructor = 145,
GetAccessor = 146,
SetAccessor = 147,
CallSignature = 148,
ConstructSignature = 149,
IndexSignature = 150,
TypePredicate = 151,
TypeReference = 152,
FunctionType = 153,
ConstructorType = 154,
TypeQuery = 155,
TypeLiteral = 156,
ArrayType = 157,
TupleType = 158,
UnionType = 159,
IntersectionType = 160,
ParenthesizedType = 161,
ThisType = 162,
StringLiteralType = 163,
ObjectBindingPattern = 164,
ArrayBindingPattern = 165,
BindingElement = 166,
ArrayLiteralExpression = 167,
ObjectLiteralExpression = 168,
PropertyAccessExpression = 169,
ElementAccessExpression = 170,
CallExpression = 171,
NewExpression = 172,
TaggedTemplateExpression = 173,
TypeAssertionExpression = 174,
ParenthesizedExpression = 175,
FunctionExpression = 176,
ArrowFunction = 177,
DeleteExpression = 178,
TypeOfExpression = 179,
VoidExpression = 180,
AwaitExpression = 181,
PrefixUnaryExpression = 182,
PostfixUnaryExpression = 183,
BinaryExpression = 184,
ConditionalExpression = 185,
TemplateExpression = 186,
YieldExpression = 187,
SpreadElementExpression = 188,
ClassExpression = 189,
OmittedExpression = 190,
ExpressionWithTypeArguments = 191,
AsExpression = 192,
TemplateSpan = 193,
SemicolonClassElement = 194,
Block = 195,
VariableStatement = 196,
EmptyStatement = 197,
ExpressionStatement = 198,
IfStatement = 199,
DoStatement = 200,
WhileStatement = 201,
ForStatement = 202,
ForInStatement = 203,
ForOfStatement = 204,
ContinueStatement = 205,
BreakStatement = 206,
ReturnStatement = 207,
WithStatement = 208,
SwitchStatement = 209,
LabeledStatement = 210,
ThrowStatement = 211,
TryStatement = 212,
DebuggerStatement = 213,
VariableDeclaration = 214,
VariableDeclarationList = 215,
FunctionDeclaration = 216,
ClassDeclaration = 217,
InterfaceDeclaration = 218,
TypeAliasDeclaration = 219,
EnumDeclaration = 220,
ModuleDeclaration = 221,
ModuleBlock = 222,
CaseBlock = 223,
ImportEqualsDeclaration = 224,
ImportDeclaration = 225,
ImportClause = 226,
NamespaceImport = 227,
NamedImports = 228,
ImportSpecifier = 229,
ExportAssignment = 230,
ExportDeclaration = 231,
NamedExports = 232,
ExportSpecifier = 233,
MissingDeclaration = 234,
ExternalModuleReference = 235,
JsxElement = 236,
JsxSelfClosingElement = 237,
JsxOpeningElement = 238,
JsxText = 239,
JsxClosingElement = 240,
JsxAttribute = 241,
JsxSpreadAttribute = 242,
JsxExpression = 243,
CaseClause = 244,
DefaultClause = 245,
HeritageClause = 246,
CatchClause = 247,
PropertyAssignment = 248,
ShorthandPropertyAssignment = 249,
EnumMember = 250,
SourceFile = 251,
JSDocTypeExpression = 252,
JSDocAllType = 253,
JSDocUnknownType = 254,
JSDocArrayType = 255,
JSDocUnionType = 256,
JSDocTupleType = 257,
JSDocNullableType = 258,
JSDocNonNullableType = 259,
JSDocRecordType = 260,
JSDocRecordMember = 261,
JSDocTypeReference = 262,
JSDocOptionalType = 263,
JSDocFunctionType = 264,
JSDocVariadicType = 265,
JSDocConstructorType = 266,
JSDocThisType = 267,
JSDocComment = 268,
JSDocTag = 269,
JSDocParameterTag = 270,
JSDocReturnTag = 271,
JSDocTypeTag = 272,
JSDocTemplateTag = 273,
SyntaxList = 274,
Count = 275,
FirstAssignment = 56,
LastAssignment = 68,
FirstReservedWord = 70,
LastReservedWord = 105,
FirstKeyword = 70,
LastKeyword = 134,
LastKeyword = 135,
FirstFutureReservedWord = 106,
LastFutureReservedWord = 114,
FirstTypeNode = 150,
LastTypeNode = 162,
FirstTypeNode = 151,
LastTypeNode = 163,
FirstPunctuation = 15,
LastPunctuation = 68,
FirstToken = 0,
LastToken = 134,
LastToken = 135,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -330,7 +331,7 @@ declare namespace ts {
LastTemplateToken = 14,
FirstBinaryOperator = 25,
LastBinaryOperator = 68,
FirstNode = 135,
FirstNode = 136,
}
enum NodeFlags {
None = 0,
@@ -354,10 +355,16 @@ declare namespace ts {
ContainsThis = 262144,
HasImplicitReturn = 524288,
HasExplicitReturn = 1048576,
GlobalAugmentation = 2097152,
HasClassExtends = 4194304,
HasDecorators = 8388608,
HasParamDecorators = 16777216,
HasAsyncFunctions = 33554432,
Modifier = 1022,
AccessibilityModifier = 56,
BlockScoped = 24576,
ReachabilityCheckFlags = 1572864,
EmitHelperFlags = 62914560,
}
enum JsxFlags {
None = 0,
@@ -1141,6 +1148,7 @@ declare namespace ts {
getSymbolAtLocation(node: Node): Symbol;
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol;
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
getTypeAtLocation(node: Node): Type;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
@@ -1154,6 +1162,7 @@ declare namespace ts {
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
isUndefinedSymbol(symbol: Symbol): boolean;
isArgumentsSymbol(symbol: Symbol): boolean;
isUnknownSymbol(symbol: Symbol): boolean;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
@@ -1543,6 +1552,8 @@ declare namespace ts {
}
}
declare namespace ts {
type FileWatcherCallback = (path: string, removed?: boolean) => void;
type DirectoryWatcherCallback = (path: string) => void;
interface System {
args: string[];
newLine: string;
@@ -1550,8 +1561,8 @@ declare namespace ts {
write(s: string): void;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher;
watchFile?(path: Path, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
@@ -1565,6 +1576,10 @@ declare namespace ts {
interface FileWatcher {
close(): void;
}
interface DirectoryWatcher extends FileWatcher {
directoryPath: Path;
referenceCount: number;
}
var sys: System;
}
declare namespace ts {
@@ -2237,6 +2252,9 @@ declare namespace ts {
static jsxOpenTagName: string;
static jsxCloseTagName: string;
static jsxSelfClosingTagName: string;
static jsxAttribute: string;
static jsxText: string;
static jsxAttributeStringLiteralValue: string;
}
enum ClassificationType {
comment = 1,
@@ -2260,6 +2278,9 @@ declare namespace ts {
jsxOpenTagName = 19,
jsxCloseTagName = 20,
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
}
interface DisplayPartsSymbolWriter extends SymbolWriter {
displayParts(): SymbolDisplayPart[];
@@ -2283,7 +2304,6 @@ declare namespace ts {
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string;
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo;
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
+4698 -3926
View File
File diff suppressed because it is too large. Load diff
+114 -13
View File
@@ -117,6 +117,12 @@ namespace ts {
let labelIndexMap: Map<number>;
let implicitLabels: number[];
// state used for emit helpers
let hasClassExtends: boolean;
let hasAsyncFunctions: boolean;
let hasDecorators: boolean;
let hasParameterDecorators: boolean;
// If this file is an external module, then it is automatically in strict-mode according to
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
@@ -131,6 +137,7 @@ namespace ts {
options = opts;
inStrictMode = !!file.externalModuleIndicator;
classifiableNames = {};
Symbol = objectAllocator.getSymbolConstructor();
if (!file.locals) {
@@ -150,6 +157,10 @@ namespace ts {
labelStack = undefined;
labelIndexMap = undefined;
implicitLabels = undefined;
hasClassExtends = false;
hasAsyncFunctions = false;
hasDecorators = false;
hasParameterDecorators = false;
}
return bindSourceFile;
@@ -191,8 +202,8 @@ namespace ts {
// unless it is a well known Symbol.
function getDeclarationName(node: Declaration): string {
if (node.name) {
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
return `"${(<LiteralExpression>node.name).text}"`;
if (isAmbientModule(node)) {
return isGlobalScopeAugmentation(<ModuleDeclaration>node) ? "__global" : `"${(<LiteralExpression>node.name).text}"`;
}
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
const nameExpression = (<ComputedPropertyName>node.name).expression;
@@ -240,6 +251,15 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ClassDeclaration:
return node.flags & NodeFlags.Default ? "default" : undefined;
case SyntaxKind.JSDocFunctionType:
return isJSDocConstructSignature(node) ? "__new" : "__call";
case SyntaxKind.Parameter:
// Parameters with names are handled at the top of this function. Parameters
// without names can only come from JSDocFunctionTypes.
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType);
let functionType = <JSDocFunctionType>node.parent;
let index = indexOf(functionType.parameters, node);
return "p" + index;
}
}
@@ -348,7 +368,12 @@ namespace ts {
// 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol,
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
if (hasExportModifier || container.flags & NodeFlags.ExportContext) {
// NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
// and this case is specially handled. Module augmentations should only be merged with original module definition
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
if (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) {
const exportKind =
(symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
(symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
@@ -405,7 +430,6 @@ namespace ts {
addToContainerChain(container);
}
else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
blockScopeContainer = node;
blockScopeContainer.locals = undefined;
@@ -423,6 +447,9 @@ namespace ts {
// reset all reachability check related flags on node (for incremental scenarios)
flags &= ~NodeFlags.ReachabilityCheckFlags;
// reset all emit helper flags on node (for incremental scenarios)
flags &= ~NodeFlags.EmitHelperFlags;
if (kind === SyntaxKind.InterfaceDeclaration) {
seenThisKeyword = false;
}
@@ -440,6 +467,10 @@ namespace ts {
labelStack = labelIndexMap = implicitLabels = undefined;
}
if (isInJavaScriptFile(node) && node.jsDocComment) {
bind(node.jsDocComment);
}
bindReachableStatement(node);
if (currentReachabilityState === Reachability.Reachable && isFunctionLikeKind(kind) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
@@ -453,6 +484,21 @@ namespace ts {
flags = seenThisKeyword ? flags | NodeFlags.ContainsThis : flags & ~NodeFlags.ContainsThis;
}
if (kind === SyntaxKind.SourceFile) {
if (hasClassExtends) {
flags |= NodeFlags.HasClassExtends;
}
if (hasDecorators) {
flags |= NodeFlags.HasDecorators;
}
if (hasParameterDecorators) {
flags |= NodeFlags.HasParamDecorators;
}
if (hasAsyncFunctions) {
flags |= NodeFlags.HasAsyncFunctions;
}
}
node.flags = flags;
if (saveState) {
@@ -688,8 +734,9 @@ namespace ts {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeLiteral:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TypeLiteral:
case SyntaxKind.JSDocRecordType:
return ContainerFlags.IsContainer;
case SyntaxKind.CallSignature:
@@ -775,6 +822,7 @@ namespace ts {
case SyntaxKind.TypeLiteral:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.JSDocRecordType:
// Interface/Object-types always have their children added to the 'members' of
// their container. They are only accessible through an instance of their
// container, and are never in scope otherwise (even inside the body of the
@@ -795,6 +843,7 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.JSDocFunctionType:
case SyntaxKind.TypeAliasDeclaration:
// All the children of these container types are never visible through another
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
@@ -843,7 +892,10 @@ namespace ts {
function bindModuleDeclaration(node: ModuleDeclaration) {
setExportContextFlag(node);
if (node.name.kind === SyntaxKind.StringLiteral) {
if (isAmbientModule(node)) {
if (node.flags & NodeFlags.Export) {
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
}
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
}
else {
@@ -873,7 +925,7 @@ namespace ts {
}
}
function bindFunctionOrConstructorType(node: SignatureDeclaration) {
function bindFunctionOrConstructorType(node: SignatureDeclaration): void {
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
// to the one we would get for: { <...>(...): T }
//
@@ -948,7 +1000,7 @@ namespace ts {
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
}
// fall through.
// fall through.
default:
if (!blockScopeContainer.locals) {
blockScopeContainer.locals = {};
@@ -1227,12 +1279,14 @@ namespace ts {
return bindVariableDeclarationOrBindingElement(<VariableDeclaration | BindingElement>node);
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.JSDocRecordMember:
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
case SyntaxKind.PropertyAssignment:
case SyntaxKind.ShorthandPropertyAssignment:
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
case SyntaxKind.EnumMember:
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
@@ -1246,8 +1300,7 @@ namespace ts {
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None),
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes);
case SyntaxKind.FunctionDeclaration:
checkStrictModeFunctionName(<FunctionDeclaration>node);
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Function, SymbolFlags.FunctionExcludes);
return bindFunctionDeclaration(<FunctionDeclaration>node);
case SyntaxKind.Constructor:
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Constructor, /*symbolExcludes:*/ SymbolFlags.None);
case SyntaxKind.GetAccessor:
@@ -1256,16 +1309,16 @@ namespace ts {
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.JSDocFunctionType:
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
case SyntaxKind.TypeLiteral:
case SyntaxKind.JSDocRecordType:
return bindAnonymousDeclaration(<TypeLiteralNode>node, SymbolFlags.TypeLiteral, "__type");
case SyntaxKind.ObjectLiteralExpression:
return bindObjectLiteralExpression(<ObjectLiteralExpression>node);
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
checkStrictModeFunctionName(<FunctionExpression>node);
const bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
return bindFunctionExpression(<FunctionExpression>node);
case SyntaxKind.CallExpression:
if (isInJavaScriptFile(node)) {
@@ -1415,6 +1468,15 @@ namespace ts {
}
function bindClassLikeDeclaration(node: ClassLikeDeclaration) {
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
if (getClassExtendsHeritageClauseElement(node) !== undefined) {
hasClassExtends = true;
}
if (nodeIsDecorated(node)) {
hasDecorators = true;
}
}
if (node.kind === SyntaxKind.ClassDeclaration) {
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
}
@@ -1484,6 +1546,13 @@ namespace ts {
}
function bindParameter(node: ParameterDeclaration) {
if (!isDeclarationFile(file) &&
!isInAmbientContext(node) &&
nodeIsDecorated(node)) {
hasDecorators = true;
hasParameterDecorators = true;
}
if (inStrictMode) {
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
@@ -1505,7 +1574,39 @@ namespace ts {
}
}
function bindFunctionDeclaration(node: FunctionDeclaration) {
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
if (isAsyncFunctionLike(node)) {
hasAsyncFunctions = true;
}
}
checkStrictModeFunctionName(<FunctionDeclaration>node);
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Function, SymbolFlags.FunctionExcludes);
}
function bindFunctionExpression(node: FunctionExpression) {
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
if (isAsyncFunctionLike(node)) {
hasAsyncFunctions = true;
}
}
checkStrictModeFunctionName(<FunctionExpression>node);
const bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
}
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
if (isAsyncFunctionLike(node)) {
hasAsyncFunctions = true;
}
if (nodeIsDecorated(node)) {
hasDecorators = true;
}
}
return hasDynamicName(node)
? bindAnonymousDeclaration(node, symbolFlags, "__computed")
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
+652 -339
View File
File diff suppressed because it is too large. Load diff
+9 -4
View File
@@ -493,8 +493,8 @@ namespace ts {
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}): ParsedCommandLine {
const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string): ParsedCommandLine {
const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName);
const options = extend(existingOptions, optionsFromJsonConfigFile);
return {
@@ -523,7 +523,7 @@ namespace ts {
for (const extension of supportedExtensions) {
const filesInDirWithExtension = host.readDirectory(basePath, extension, exclude);
for (const fileName of filesInDirWithExtension) {
// .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension,
// .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension,
// lets pick them when its turn comes up
if (extension === ".ts" && fileExtensionIs(fileName, ".d.ts")) {
continue;
@@ -547,10 +547,15 @@ namespace ts {
}
}
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { options: CompilerOptions, errors: Diagnostic[] } {
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } {
const options: CompilerOptions = {};
const errors: Diagnostic[] = [];
if (configFileName && getBaseFileName(configFileName) === "jsconfig.json") {
options.module = ModuleKind.CommonJS;
options.allowJs = true;
}
if (!jsonOptions) {
return { options, errors };
}
+12 -2
View File
@@ -616,7 +616,9 @@ namespace ts {
return path.substr(0, rootLength) + normalized.join(directorySeparator);
}
export function getDirectoryPath(path: string) {
export function getDirectoryPath(path: Path): Path;
export function getDirectoryPath(path: string): string;
export function getDirectoryPath(path: string): any {
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
}
@@ -716,7 +718,8 @@ namespace ts {
}
// Find the component that differs
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
let joinStartIndex: number;
for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) {
break;
}
@@ -874,4 +877,11 @@ namespace ts {
}
return copiedList;
}
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
return useCaseSensitivefileNames
? ((fileName) => fileName)
: ((fileName) => fileName.toLowerCase());
}
}
+34 -5
View File
@@ -54,6 +54,7 @@ namespace ts {
let writer = createAndSetNewTextWriterWithSymbolWriter();
let enclosingDeclaration: Node;
let resultHasExternalModuleIndicator: boolean;
let currentText: string;
let currentLineMap: number[];
let currentIdentifiers: Map<string>;
@@ -101,6 +102,7 @@ namespace ts {
});
}
resultHasExternalModuleIndicator = false;
if (!isBundledEmit || !isExternalModule(sourceFile)) {
noDeclare = false;
emitSourceFile(sourceFile);
@@ -139,6 +141,14 @@ namespace ts {
allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo);
moduleElementDeclarationEmitInfo = [];
}
if (!isBundledEmit && isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) {
// if file was external module with augmentations - this fact should be preserved in .d.ts as well.
// in case if we didn't write any external module specifiers in .d.ts we need to emit something
// that will force compiler to think that this file is an external module - 'export {}' is a reasonable choice here.
write("export {};");
writeLine();
}
});
return {
@@ -721,16 +731,25 @@ namespace ts {
writer.writeLine();
}
function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration) {
function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration) {
// emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations).
// the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered
// external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}'
// so compiler will treat them as external modules.
resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== SyntaxKind.ModuleDeclaration;
let moduleSpecifier: Node;
if (parent.kind === SyntaxKind.ImportEqualsDeclaration) {
const node = parent as ImportEqualsDeclaration;
moduleSpecifier = getExternalModuleImportEqualsDeclarationExpression(node);
}
else if (parent.kind === SyntaxKind.ModuleDeclaration) {
moduleSpecifier = (<ModuleDeclaration>parent).name;
}
else {
const node = parent as (ImportDeclaration | ExportDeclaration);
moduleSpecifier = node.moduleSpecifier;
}
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && isBundledEmit && (compilerOptions.out || compilerOptions.outFile)) {
const moduleName = getExternalModuleNameFromDeclaration(host, resolver, parent);
if (moduleName) {
@@ -784,13 +803,23 @@ namespace ts {
function writeModuleDeclaration(node: ModuleDeclaration) {
emitJsDocComments(node);
emitModuleElementDeclarationFlags(node);
if (node.flags & NodeFlags.Namespace) {
write("namespace ");
if (isGlobalScopeAugmentation(node)) {
write("global ");
}
else {
write("module ");
if (node.flags & NodeFlags.Namespace) {
write("namespace ");
}
else {
write("module ");
}
if (isExternalModuleAugmentation(node)) {
emitExternalModuleSpecifier(node);
}
else {
writeTextOfNode(currentText, node.name);
}
}
writeTextOfNode(currentText, node.name);
while (node.body.kind !== SyntaxKind.ModuleBlock) {
node = <ModuleDeclaration>node.body;
write(".");
+36 -8
View File
@@ -711,10 +711,6 @@
"category": "Error",
"code": 1227
},
"A type predicate is only allowed in return type position for functions and methods.": {
"category": "Error",
"code": 1228
},
"A type predicate cannot reference a rest parameter.": {
"category": "Error",
"code": 1229
@@ -1655,10 +1651,6 @@
"category": "Error",
"code": 2518
},
"A 'this'-based type predicate is only allowed within a class or interface's members, get accessors, or return type positions for functions and methods.": {
"category": "Error",
"code": 2519
},
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
"category": "Error",
"code": 2520
@@ -1775,6 +1767,42 @@
"category": "Error",
"code": 2661
},
"Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?": {
"category": "Error",
"code": 2662
},
"Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?": {
"category": "Error",
"code": 2663
},
"Invalid module name in augmentation, module '{0}' cannot be found.": {
"category": "Error",
"code": 2664
},
"Module augmentation cannot introduce new names in the top level scope.": {
"category": "Error",
"code": 2665
},
"Exports and export assignments are not permitted in module augmentations.": {
"category": "Error",
"code": 2666
},
"Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.": {
"category": "Error",
"code": 2667
},
"'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.": {
"category": "Error",
"code": 2668
},
"Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.": {
"category": "Error",
"code": 2669
},
"Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context.": {
"category": "Error",
"code": 2670
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
+17 -21
View File
@@ -319,17 +319,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
};`;
const awaiterHelper = `
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
return new Promise(function (resolve, reject) {
generator = generator.call(thisArg, _arguments);
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step("next", void 0);
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};`;
@@ -1250,7 +1245,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
// One object literal with all the attributes in them
write("{");
for (var i = 0; i < attrs.length; i++) {
for (let i = 0, n = attrs.length; i < n; i++) {
if (i > 0) {
write(", ");
}
@@ -1262,7 +1257,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Children
if (children) {
for (var i = 0; i < children.length; i++) {
for (let i = 0; i < children.length; i++) {
// Don't emit empty expressions
if (children[i].kind === SyntaxKind.JsxExpression && !((<JsxExpression>children[i]).expression)) {
continue;
@@ -1356,7 +1351,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitJsxElement(node: JsxElement) {
emitJsxOpeningOrSelfClosingElement(node.openingElement);
for (var i = 0, n = node.children.length; i < n; i++) {
for (let i = 0, n = node.children.length; i < n; i++) {
emit(node.children[i]);
}
@@ -2886,7 +2881,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
if ((<ForStatement | ForInStatement | ForOfStatement>node).initializer.kind === SyntaxKind.VariableDeclarationList) {
const initializer = (<ForStatement | ForInStatement | ForOfStatement>node).initializer;
if (initializer && initializer.kind === SyntaxKind.VariableDeclarationList) {
loopInitializer = <VariableDeclarationList>(<ForStatement | ForInStatement | ForOfStatement>node).initializer;
}
break;
@@ -5171,7 +5167,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
if (isClassExpressionWithStaticProperties) {
for (var property of staticProperties) {
for (const property of staticProperties) {
write(",");
writeLine();
emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true);
@@ -5718,7 +5714,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
const parameters = valueDeclaration.parameters;
const parameterCount = parameters.length;
if (parameterCount > 0) {
for (var i = 0; i < parameterCount; i++) {
for (let i = 0; i < parameterCount; i++) {
if (i > 0) {
write(", ");
}
@@ -7353,12 +7349,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (!compilerOptions.noEmitHelpers) {
// Only Emit __extends function when target ES5.
// For target ES6 and above, we can emit classDeclaration as is.
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) {
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
writeLines(extendsHelper);
extendsEmitted = true;
}
if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) {
if (!decorateEmitted && node.flags & NodeFlags.HasDecorators) {
writeLines(decorateHelper);
if (compilerOptions.emitDecoratorMetadata) {
writeLines(metadataHelper);
@@ -7366,12 +7362,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
decorateEmitted = true;
}
if (!paramEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitParam) {
if (!paramEmitted && node.flags & NodeFlags.HasParamDecorators) {
writeLines(paramHelper);
paramEmitted = true;
}
if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitAwaiter) {
if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) {
writeLines(awaiterHelper);
awaiterEmitted = true;
}
+189 -166
View File
@@ -611,44 +611,24 @@ namespace ts {
fixupParentReferences(sourceFile);
}
// If this is a javascript file, proactively see if we can get JSDoc comments for
// relevant nodes in the file. We'll use these to provide typing informaion if they're
// available.
if (isSourceFileJavaScript(sourceFile)) {
addJSDocComments();
}
return sourceFile;
}
function addJSDocComments() {
forEachChild(sourceFile, visit);
return;
function visit(node: Node) {
// Add additional cases as necessary depending on how we see JSDoc comments used
// in the wild.
switch (node.kind) {
case SyntaxKind.VariableStatement:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.Parameter:
addJSDocComment(node);
}
forEachChild(node, visit);
}
}
function addJSDocComment(node: Node) {
const comments = getLeadingCommentRangesOfNode(node, sourceFile);
if (comments) {
for (const comment of comments) {
const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos);
if (jsDocComment) {
node.jsDocComment = jsDocComment;
function addJSDocComment<T extends Node>(node: T): T {
if (contextFlags & ParserContextFlags.JavaScriptFile) {
const comments = getLeadingCommentRangesOfNode(node, sourceFile);
if (comments) {
for (const comment of comments) {
const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos);
if (jsDocComment) {
node.jsDocComment = jsDocComment;
}
}
}
}
return node;
}
export function fixupParentReferences(sourceFile: Node) {
@@ -896,17 +876,19 @@ namespace ts {
return result;
}
// Invokes the provided callback then unconditionally restores the parser to the state it
// was in immediately prior to invoking the callback. The result of invoking the callback
// is returned from this function.
/** Invokes the provided callback then unconditionally restores the parser to the state it
* was in immediately prior to invoking the callback. The result of invoking the callback
* is returned from this function.
*/
function lookAhead<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookAhead*/ true);
}
// Invokes the provided callback. If the callback returns something falsy, then it restores
// the parser to the state it was in immediately prior to invoking the callback. If the
// callback returns something truthy, then the parser state is not rolled back. The result
// of invoking the callback is returned from this function.
/** Invokes the provided callback. If the callback returns something falsy, then it restores
* the parser to the state it was in immediately prior to invoking the callback. If the
* callback returns something truthy, then the parser state is not rolled back. The result
* of invoking the callback is returned from this function.
*/
function tryParse<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookAhead*/ false);
}
@@ -1948,11 +1930,8 @@ namespace ts {
// TYPES
function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode {
function parseTypeReference(): TypeReferenceNode {
const typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
return parseTypePredicate(typeName as Identifier);
}
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference, typeName.pos);
node.typeName = typeName;
if (!scanner.hasPrecedingLineBreak() && token === SyntaxKind.LessThanToken) {
@@ -2068,7 +2047,8 @@ namespace ts {
// contexts. In addition, parameter initializers are semantically disallowed in
// overload signatures. So parameter initializers are transitively disallowed in
// ambient contexts.
return finishNode(node);
return addJSDocComment(finishNode(node));
}
function parseBindingElementInitializer(inParameter: boolean) {
@@ -2092,10 +2072,10 @@ namespace ts {
if (returnTokenRequired) {
parseExpected(returnToken);
signature.type = parseType();
signature.type = parseTypeOrTypePredicate();
}
else if (parseOptional(returnToken)) {
signature.type = parseType();
signature.type = parseTypeOrTypePredicate();
}
}
@@ -2411,7 +2391,7 @@ namespace ts {
case SyntaxKind.SymbolKeyword:
// If these are followed by a dot, then parse these out as a dotted type reference instead.
const node = tryParse(parseKeywordAndNoDot);
return node || parseTypeReferenceOrTypePredicate();
return node || parseTypeReference();
case SyntaxKind.StringLiteral:
return parseStringLiteralTypeNode();
case SyntaxKind.VoidKeyword:
@@ -2434,7 +2414,7 @@ namespace ts {
case SyntaxKind.OpenParenToken:
return parseParenthesizedType();
default:
return parseTypeReferenceOrTypePredicate();
return parseTypeReference();
}
}
@@ -2541,6 +2521,28 @@ namespace ts {
return false;
}
function parseTypeOrTypePredicate(): TypeNode {
const typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
const type = parseType();
if (typePredicateVariable) {
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typePredicateVariable.pos);
node.parameterName = typePredicateVariable;
node.type = type;
return finishNode(node);
}
else {
return type;
}
}
function parseTypePredicatePrefix() {
const id = parseIdentifier();
if (token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
nextToken();
return id;
}
}
function parseType(): TypeNode {
// The rules about 'yield' only apply to actual code/expression contexts. They don't
// apply to 'type' contexts. So we disable these parameters here before moving on.
@@ -4409,6 +4411,9 @@ namespace ts {
}
continue;
case SyntaxKind.GlobalKeyword:
return nextToken() === SyntaxKind.OpenBraceToken;
case SyntaxKind.ImportKeyword:
nextToken();
return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken ||
@@ -4473,6 +4478,7 @@ namespace ts {
case SyntaxKind.ModuleKeyword:
case SyntaxKind.NamespaceKeyword:
case SyntaxKind.TypeKeyword:
case SyntaxKind.GlobalKeyword:
// When these don't start a declaration, they're an identifier in an expression statement
return true;
@@ -4561,6 +4567,7 @@ namespace ts {
case SyntaxKind.PublicKeyword:
case SyntaxKind.AbstractKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.GlobalKeyword:
if (isStartOfDeclaration()) {
return parseDeclaration();
}
@@ -4588,6 +4595,7 @@ namespace ts {
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.EnumKeyword:
return parseEnumDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.GlobalKeyword:
case SyntaxKind.ModuleKeyword:
case SyntaxKind.NamespaceKeyword:
return parseModuleDeclaration(fullStart, decorators, modifiers);
@@ -4746,7 +4754,7 @@ namespace ts {
setModifiers(node, modifiers);
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false);
parseSemicolon();
return finishNode(node);
return addJSDocComment(finishNode(node));
}
function parseFunctionDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): FunctionDeclaration {
@@ -4760,7 +4768,7 @@ namespace ts {
const isAsync = !!(node.flags & NodeFlags.Async);
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected);
return finishNode(node);
return addJSDocComment(finishNode(node));
}
function parseConstructorDeclaration(pos: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ConstructorDeclaration {
@@ -5222,14 +5230,25 @@ namespace ts {
const node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.name = parseLiteralNode(/*internName*/ true);
if (token === SyntaxKind.GlobalKeyword) {
// parse 'global' as name of global scope augmentation
node.name = parseIdentifier();
node.flags |= NodeFlags.GlobalAugmentation;
}
else {
node.name = parseLiteralNode(/*internName*/ true);
}
node.body = parseModuleBlock();
return finishNode(node);
}
function parseModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
let flags = modifiers ? modifiers.flags : 0;
if (parseOptional(SyntaxKind.NamespaceKeyword)) {
if (token === SyntaxKind.GlobalKeyword) {
// global augmentation
return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers);
}
else if (parseOptional(SyntaxKind.NamespaceKeyword)) {
flags |= NodeFlags.Namespace;
}
else {
@@ -5586,23 +5605,19 @@ namespace ts {
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined);
const jsDocTypeExpression = parseJSDocTypeExpression(start, length);
scanner.setText(content, start, length);
token = scanner.scan();
const jsDocTypeExpression = parseJSDocTypeExpression();
const diagnostics = parseDiagnostics;
clearState();
return jsDocTypeExpression ? { jsDocTypeExpression, diagnostics } : undefined;
}
// Parses out a JSDoc type expression. The starting position should be right at the open
// curly in the type expression. Returns 'undefined' if it encounters any errors while parsing.
// Parses out a JSDoc type expression.
/* @internal */
export function parseJSDocTypeExpression(start: number, length: number): JSDocTypeExpression {
scanner.setText(sourceText, start, length);
// Prime the first token for us to start processing.
token = nextToken();
const result = <JSDocTypeExpression>createNode(SyntaxKind.JSDocTypeExpression);
export function parseJSDocTypeExpression(): JSDocTypeExpression {
const result = <JSDocTypeExpression>createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos());
parseExpected(SyntaxKind.OpenBraceToken);
result.type = parseJSDocTopLevelType();
@@ -5900,7 +5915,8 @@ namespace ts {
export function parseIsolatedJSDocComment(content: string, start: number, length: number) {
initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined);
const jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length);
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content };
const jsDocComment = parseJSDocCommentWorker(start, length);
const diagnostics = parseDiagnostics;
clearState();
@@ -5908,12 +5924,19 @@ namespace ts {
}
export function parseJSDocComment(parent: Node, start: number, length: number): JSDocComment {
const saveToken = token;
const saveParseDiagnosticsLength = parseDiagnostics.length;
const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
const comment = parseJSDocCommentWorker(start, length);
if (comment) {
fixupParentReferences(comment);
comment.parent = parent;
}
token = saveToken;
parseDiagnostics.length = saveParseDiagnosticsLength;
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
return comment;
}
@@ -5928,69 +5951,69 @@ namespace ts {
Debug.assert(end <= content.length);
let tags: NodeArray<JSDocTag>;
let pos: number;
// NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I
// considered using an actual Scanner, but this would complicate things. The
// scanner would need to know it was in a Doc Comment. Otherwise, it would then
// produce comments *inside* the doc comment. In the end it was just easier to
// write a simple scanner rather than go that route.
if (length >= "/** */".length) {
if (content.charCodeAt(start) === CharacterCodes.slash &&
content.charCodeAt(start + 1) === CharacterCodes.asterisk &&
content.charCodeAt(start + 2) === CharacterCodes.asterisk &&
content.charCodeAt(start + 3) !== CharacterCodes.asterisk) {
let result: JSDocComment;
// Check for /** (JSDoc opening part)
if (content.charCodeAt(start) === CharacterCodes.slash &&
content.charCodeAt(start + 1) === CharacterCodes.asterisk &&
content.charCodeAt(start + 2) === CharacterCodes.asterisk &&
content.charCodeAt(start + 3) !== CharacterCodes.asterisk) {
// + 3 for leading /**, - 5 in total for /** */
scanner.scanRange(start + 3, length - 5, () => {
// Initially we can parse out a tag. We also have seen a starting asterisk.
// This is so that /** * @type */ doesn't parse.
let canParseTag = true;
let seenAsterisk = true;
for (pos = start + "/**".length; pos < end; ) {
const ch = content.charCodeAt(pos);
pos++;
nextJSDocToken();
while (token !== SyntaxKind.EndOfFileToken) {
switch (token) {
case SyntaxKind.AtToken:
if (canParseTag) {
parseTag();
}
// This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop
seenAsterisk = false;
break;
if (ch === CharacterCodes.at && canParseTag) {
parseTag();
case SyntaxKind.NewLineTrivia:
// After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet
canParseTag = true;
seenAsterisk = false;
break;
// Once we parse out a tag, we cannot keep parsing out tags on this line.
canParseTag = false;
continue;
}
case SyntaxKind.AsteriskToken:
if (seenAsterisk) {
// If we've already seen an asterisk, then we can no longer parse a tag on this line
canParseTag = false;
}
// Ignore the first asterisk on a line
seenAsterisk = true;
break;
if (isLineBreak(ch)) {
// After a line break, we can parse a tag, and we haven't seen as asterisk
// on the next line yet.
canParseTag = true;
seenAsterisk = false;
continue;
}
if (isWhiteSpace(ch)) {
// Whitespace doesn't affect any of our parsing.
continue;
}
// Ignore the first asterisk on a line.
if (ch === CharacterCodes.asterisk) {
if (seenAsterisk) {
// If we've already seen an asterisk, then we can no longer parse a tag
// on this line.
case SyntaxKind.Identifier:
// Anything else is doc comment text. We can't do anything with it. Because it
// wasn't a tag, we can no longer parse a tag on this line until we hit the next
// line break.
canParseTag = false;
}
seenAsterisk = true;
continue;
break;
case SyntaxKind.EndOfFileToken:
break;
}
// Anything else is doc comment text. We can't do anything with it. Because it
// wasn't a tag, we can no longer parse a tag on this line until we hit the next
// line break.
canParseTag = false;
nextJSDocToken();
}
}
result = createJSDocComment();
});
}
return createJSDocComment();
return result;
function createJSDocComment(): JSDocComment {
if (!tags) {
@@ -6003,17 +6026,18 @@ namespace ts {
}
function skipWhitespace(): void {
while (pos < end && isWhiteSpace(content.charCodeAt(pos))) {
pos++;
while (token === SyntaxKind.WhitespaceTrivia || token === SyntaxKind.NewLineTrivia) {
nextJSDocToken();
}
}
function parseTag(): void {
Debug.assert(content.charCodeAt(pos - 1) === CharacterCodes.at);
const atToken = createNode(SyntaxKind.AtToken, pos - 1);
atToken.end = pos;
Debug.assert(token === SyntaxKind.AtToken);
const atToken = createNode(SyntaxKind.AtToken, scanner.getTokenPos());
atToken.end = scanner.getTextPos();
nextJSDocToken();
const tagName = scanIdentifier();
const tagName = parseJSDocIdentifier();
if (!tagName) {
return;
}
@@ -6044,7 +6068,7 @@ namespace ts {
const result = <JSDocTag>createNode(SyntaxKind.JSDocTag, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result, pos);
return finishNode(result);
}
function addTag(tag: JSDocTag): void {
@@ -6060,14 +6084,11 @@ namespace ts {
}
function tryParseTypeExpression(): JSDocTypeExpression {
skipWhitespace();
if (content.charCodeAt(pos) !== CharacterCodes.openBrace) {
if (token !== SyntaxKind.OpenBraceToken) {
return undefined;
}
const typeExpression = parseJSDocTypeExpression(pos, end - pos);
pos = typeExpression.end;
const typeExpression = parseJSDocTypeExpression();
return typeExpression;
}
@@ -6077,18 +6098,25 @@ namespace ts {
skipWhitespace();
let name: Identifier;
let isBracketed: boolean;
if (content.charCodeAt(pos) === CharacterCodes.openBracket) {
pos++;
skipWhitespace();
name = scanIdentifier();
// Looking for something like '[foo]' or 'foo'
if (parseOptionalToken(SyntaxKind.OpenBracketToken)) {
name = parseJSDocIdentifier();
isBracketed = true;
// May have an optional default, e.g. '[foo = 42]'
if (parseOptionalToken(SyntaxKind.EqualsToken)) {
parseExpression();
}
parseExpected(SyntaxKind.CloseBracketToken);
}
else {
name = scanIdentifier();
else if (token === SyntaxKind.Identifier) {
name = parseJSDocIdentifier();
}
if (!name) {
parseErrorAtPosition(pos, 0, Diagnostics.Identifier_expected);
parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected);
return undefined;
}
let preName: Identifier, postName: Identifier;
@@ -6110,95 +6138,90 @@ namespace ts {
result.typeExpression = typeExpression;
result.postParameterName = postName;
result.isBracketed = isBracketed;
return finishNode(result, pos);
return finishNode(result);
}
function handleReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) {
parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
}
const result = <JSDocReturnTag>createNode(SyntaxKind.JSDocReturnTag, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result, pos);
return finishNode(result);
}
function handleTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) {
parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
}
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result, pos);
return finishNode(result);
}
function handleTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag {
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) {
parseErrorAtPosition(tagName.pos, pos - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
}
// Type parameter list looks like '@template T,U,V'
const typeParameters = <NodeArray<TypeParameterDeclaration>>[];
typeParameters.pos = pos;
typeParameters.pos = scanner.getStartPos();
while (true) {
skipWhitespace();
const startPos = pos;
const name = scanIdentifier();
const name = parseJSDocIdentifier();
if (!name) {
parseErrorAtPosition(startPos, 0, Diagnostics.Identifier_expected);
parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected);
return undefined;
}
const typeParameter = <TypeParameterDeclaration>createNode(SyntaxKind.TypeParameter, name.pos);
typeParameter.name = name;
finishNode(typeParameter, pos);
finishNode(typeParameter);
typeParameters.push(typeParameter);
skipWhitespace();
if (content.charCodeAt(pos) !== CharacterCodes.comma) {
if (token === SyntaxKind.CommaToken) {
nextJSDocToken();
}
else {
break;
}
pos++;
}
typeParameters.end = pos;
const result = <JSDocTemplateTag>createNode(SyntaxKind.JSDocTemplateTag, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = typeParameters;
return finishNode(result, pos);
finishNode(result);
typeParameters.end = result.end;
return result;
}
function scanIdentifier(): Identifier {
const startPos = pos;
for (; pos < end; pos++) {
const ch = content.charCodeAt(pos);
if (pos === startPos && isIdentifierStart(ch, ScriptTarget.Latest)) {
continue;
}
else if (pos > startPos && isIdentifierPart(ch, ScriptTarget.Latest)) {
continue;
}
function nextJSDocToken(): SyntaxKind {
return token = scanner.scanJSDocToken();
}
break;
}
if (startPos === pos) {
function parseJSDocIdentifier(): Identifier {
if (token !== SyntaxKind.Identifier) {
parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
return undefined;
}
const result = <Identifier>createNode(SyntaxKind.Identifier, startPos);
result.text = content.substring(startPos, pos);
return finishNode(result, pos);
const pos = scanner.getTokenPos();
const end = scanner.getTextPos();
const result = <Identifier>createNode(SyntaxKind.Identifier, pos);
result.text = content.substring(pos, end);
finishNode(result, end);
nextJSDocToken();
return result;
}
}
}
+95 -46
View File
@@ -361,7 +361,24 @@ namespace ts {
const currentDirectory = host.getCurrentDirectory();
const resolveModuleNamesWorker = host.resolveModuleNames
? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile))
: ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule));
: ((moduleNames: string[], containingFile: string) => {
const resolvedModuleNames: ResolvedModule[] = [];
// resolveModuleName does not store any results between calls.
// lookup is a local cache to avoid resolving the same module name several times
const lookup: Map<ResolvedModule> = {};
for (const moduleName of moduleNames) {
let resolvedName: ResolvedModule;
if (hasProperty(lookup, moduleName)) {
resolvedName = lookup[moduleName];
}
else {
resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule;
lookup[moduleName] = resolvedName;
}
resolvedModuleNames.push(resolvedName);
}
return resolvedModuleNames;
});
const filesByName = createFileMap<SourceFile>();
// stores 'filename -> file association' ignoring case
@@ -498,15 +515,19 @@ namespace ts {
return false;
}
// check imports
// check imports and module augmentations
collectExternalModuleReferences(newSourceFile);
if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
// imports has changed
return false;
}
if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
// moduleAugmentations has changed
return false;
}
if (resolveModuleNamesWorker) {
const moduleNames = map(newSourceFile.imports, name => name.text);
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory));
// ensure that module resolution results are still correct
for (let i = 0; i < moduleNames.length; i++) {
@@ -895,65 +916,85 @@ namespace ts {
return a.text === b.text;
}
function getTextOfLiteral(literal: LiteralExpression): string {
return literal.text;
}
function collectExternalModuleReferences(file: SourceFile): void {
if (file.imports) {
return;
}
const isJavaScriptFile = isSourceFileJavaScript(file);
const isExternalModuleFile = isExternalModule(file);
let imports: LiteralExpression[];
let moduleAugmentations: LiteralExpression[];
for (const node of file.statements) {
collect(node, /*allowRelativeModuleNames*/ true, /*collectOnlyRequireCalls*/ false);
collectModuleReferences(node, /*inAmbientModule*/ false);
if (isJavaScriptFile) {
collectRequireCalls(node);
}
}
file.imports = imports || emptyArray;
file.moduleAugmentations = moduleAugmentations || emptyArray;
return;
function collect(node: Node, allowRelativeModuleNames: boolean, collectOnlyRequireCalls: boolean): void {
if (!collectOnlyRequireCalls) {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportDeclaration:
let moduleNameExpr = getExternalModuleName(node);
if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) {
break;
}
if (!(<LiteralExpression>moduleNameExpr).text) {
break;
}
if (allowRelativeModuleNames || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) {
(imports || (imports = [])).push(<LiteralExpression>moduleNameExpr);
}
function collectModuleReferences(node: Node, inAmbientModule: boolean): void {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportDeclaration:
let moduleNameExpr = getExternalModuleName(node);
if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) {
break;
case SyntaxKind.ModuleDeclaration:
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
// TypeScript 1.0 spec (April 2014): 12.1.6
}
if (!(<LiteralExpression>moduleNameExpr).text) {
break;
}
// TypeScript 1.0 spec (April 2014): 12.1.6
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules
// only through top - level external module names. Relative external module names are not permitted.
if (!inAmbientModule || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) {
(imports || (imports = [])).push(<LiteralExpression>moduleNameExpr);
}
break;
case SyntaxKind.ModuleDeclaration:
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
// This will happen in two cases:
// - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope
// - if current file is not external module then module augmentation is an ambient module declaration with non-relative module name
// immediately nested in top level ambient module declaration .
if (isExternalModuleFile || (inAmbientModule && !isExternalModuleNameRelative(moduleName.text))) {
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
}
else if (!inAmbientModule) {
// An AmbientExternalModuleDeclaration declares an external module.
// This type of declaration is permitted only in the global module.
// The StringLiteral must specify a top - level external module name.
// Relative external module names are not permitted
forEachChild((<ModuleDeclaration>node).body, node => {
// TypeScript 1.0 spec (April 2014): 12.1.6
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
// only through top - level external module names. Relative external module names are not permitted.
collect(node, /*allowRelativeModuleNames*/ false, collectOnlyRequireCalls);
});
}
break;
}
}
if (isJavaScriptFile) {
if (isRequireCall(node)) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
else {
forEachChild(node, node => collect(node, allowRelativeModuleNames, /*collectOnlyRequireCalls*/ true));
}
// NOTE: body of ambient module is always a module block
for (const statement of (<ModuleBlock>(<ModuleDeclaration>node).body).statements) {
collectModuleReferences(statement, /*inAmbientModule*/ true);
}
}
}
}
}
function collectRequireCalls(node: Node): void {
if (isRequireCall(node)) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
else {
forEachChild(node, collectRequireCalls);
}
}
}
@@ -1083,14 +1124,22 @@ namespace ts {
function processImportedModules(file: SourceFile, basePath: string) {
collectExternalModuleReferences(file);
if (file.imports.length) {
if (file.imports.length || file.moduleAugmentations.length) {
file.resolvedModules = {};
const moduleNames = map(file.imports, name => name.text);
const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
for (let i = 0; i < file.imports.length; i++) {
for (let i = 0; i < moduleNames.length; i++) {
const resolution = resolutions[i];
setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {
// add file to program only if:
// - resolution was successfull
// - noResolve is falsy
// - module name come from the list fo imports
const shouldAddFile = resolution &&
!options.noResolve &&
i < file.imports.length;
if (shouldAddFile) {
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
if (importedFile && resolution.isExternalLibraryImport) {
@@ -1168,7 +1217,7 @@ namespace ts {
if (sourceFiles) {
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
for (var sourceFile of sourceFiles) {
for (const sourceFile of sourceFiles) {
if (!isDeclarationFile(sourceFile)) {
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
+89
View File
@@ -29,6 +29,7 @@ namespace ts {
scanJsxIdentifier(): SyntaxKind;
reScanJsxToken(): SyntaxKind;
scanJsxToken(): SyntaxKind;
scanJSDocToken(): SyntaxKind;
scan(): SyntaxKind;
// Sets the text for the scanner to scan. An optional subrange starting point and length
// can be provided to have the scanner only scan a portion of the text.
@@ -42,6 +43,10 @@ namespace ts {
// is returned from this function.
lookAhead<T>(callback: () => T): T;
// Invokes the callback with the scanner set to scan the specified range. When the callback
// returns, the scanner is restored to the state it was in before scanRange was called.
scanRange<T>(start: number, length: number, callback: () => T): T;
// Invokes the provided callback. If the callback returns something falsy, then it restores
// the scanner to the state it was in immediately prior to invoking the callback. If the
// callback returns something truthy, then the scanner state is not rolled back. The result
@@ -94,6 +99,7 @@ namespace ts {
"protected": SyntaxKind.ProtectedKeyword,
"public": SyntaxKind.PublicKeyword,
"require": SyntaxKind.RequireKeyword,
"global": SyntaxKind.GlobalKeyword,
"return": SyntaxKind.ReturnKeyword,
"set": SyntaxKind.SetKeyword,
"static": SyntaxKind.StaticKeyword,
@@ -749,6 +755,7 @@ namespace ts {
scanJsxIdentifier,
reScanJsxToken,
scanJsxToken,
scanJSDocToken,
scan,
setText,
setScriptTarget,
@@ -757,6 +764,7 @@ namespace ts {
setTextPos,
tryScan,
lookAhead,
scanRange,
};
function error(message: DiagnosticMessage, length?: number): void {
@@ -1664,6 +1672,60 @@ namespace ts {
return token;
}
function scanJSDocToken(): SyntaxKind {
if (pos >= end) {
return token = SyntaxKind.EndOfFileToken;
}
startPos = pos;
// Eat leading whitespace
let ch = text.charCodeAt(pos);
while (pos < end) {
ch = text.charCodeAt(pos);
if (isWhiteSpace(ch)) {
pos++;
}
else {
break;
}
}
tokenPos = pos;
switch (ch) {
case CharacterCodes.at:
return pos += 1, token = SyntaxKind.AtToken;
case CharacterCodes.lineFeed:
case CharacterCodes.carriageReturn:
return pos += 1, token = SyntaxKind.NewLineTrivia;
case CharacterCodes.asterisk:
return pos += 1, token = SyntaxKind.AsteriskToken;
case CharacterCodes.openBrace:
return pos += 1, token = SyntaxKind.OpenBraceToken;
case CharacterCodes.closeBrace:
return pos += 1, token = SyntaxKind.CloseBraceToken;
case CharacterCodes.openBracket:
return pos += 1, token = SyntaxKind.OpenBracketToken;
case CharacterCodes.closeBracket:
return pos += 1, token = SyntaxKind.CloseBracketToken;
case CharacterCodes.equals:
return pos += 1, token = SyntaxKind.EqualsToken;
case CharacterCodes.comma:
return pos += 1, token = SyntaxKind.CommaToken;
}
if (isIdentifierStart(ch, ScriptTarget.Latest)) {
pos++;
while (isIdentifierPart(text.charCodeAt(pos), ScriptTarget.Latest) && pos < end) {
pos++;
}
return token = SyntaxKind.Identifier;
}
else {
return pos += 1, token = SyntaxKind.Unknown;
}
}
function speculationHelper<T>(callback: () => T, isLookahead: boolean): T {
const savePos = pos;
const saveStartPos = startPos;
@@ -1686,6 +1748,33 @@ namespace ts {
return result;
}
function scanRange<T>(start: number, length: number, callback: () => T): T {
const saveEnd = end;
const savePos = pos;
const saveStartPos = startPos;
const saveTokenPos = tokenPos;
const saveToken = token;
const savePrecedingLineBreak = precedingLineBreak;
const saveTokenValue = tokenValue;
const saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
const saveTokenIsUnterminated = tokenIsUnterminated;
setText(text, start, length);
const result = callback();
end = saveEnd;
pos = savePos;
startPos = saveStartPos;
tokenPos = saveTokenPos;
token = saveToken;
precedingLineBreak = savePrecedingLineBreak;
tokenValue = saveTokenValue;
hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape;
tokenIsUnterminated = saveTokenIsUnterminated;
return result;
}
function lookAhead<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookahead*/ true);
}
+127 -23
View File
@@ -1,6 +1,9 @@
/// <reference path="core.ts"/>
namespace ts {
export type FileWatcherCallback = (path: string, removed?: boolean) => void;
export type DirectoryWatcherCallback = (path: string) => void;
export interface System {
args: string[];
newLine: string;
@@ -8,8 +11,8 @@ namespace ts {
write(s: string): void;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher;
watchFile?(path: Path, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
@@ -22,15 +25,20 @@ namespace ts {
}
interface WatchedFile {
fileName: string;
callback: (fileName: string, removed?: boolean) => void;
mtime: Date;
filePath: Path;
callback: FileWatcherCallback;
mtime?: Date;
}
export interface FileWatcher {
close(): void;
}
export interface DirectoryWatcher extends FileWatcher {
directoryPath: Path;
referenceCount: number;
}
declare var require: any;
declare var module: any;
declare var process: any;
@@ -62,8 +70,8 @@ namespace ts {
readFile(path: string): string;
writeFile(path: string, contents: string): void;
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
watchDirectory?(path: string, callback: (path: string) => void, recursive?: boolean): FileWatcher;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
};
export var sys: System = (function () {
@@ -221,7 +229,7 @@ namespace ts {
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
function createWatchedFileSet(interval = 2500, chunkSize = 30) {
function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) {
let watchedFiles: WatchedFile[] = [];
let nextFileToCheck = 0;
let watchTimer: any;
@@ -236,13 +244,13 @@ namespace ts {
return;
}
_fs.stat(watchedFile.fileName, (err: any, stats: any) => {
_fs.stat(watchedFile.filePath, (err: any, stats: any) => {
if (err) {
watchedFile.callback(watchedFile.fileName);
watchedFile.callback(watchedFile.filePath);
}
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
watchedFile.mtime = getModifiedTime(watchedFile.fileName);
watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0);
watchedFile.mtime = getModifiedTime(watchedFile.filePath);
watchedFile.callback(watchedFile.filePath, watchedFile.mtime.getTime() === 0);
}
});
}
@@ -270,11 +278,11 @@ namespace ts {
}, interval);
}
function addFile(fileName: string, callback: (fileName: string, removed?: boolean) => void): WatchedFile {
function addFile(filePath: Path, callback: FileWatcherCallback): WatchedFile {
const file: WatchedFile = {
fileName,
filePath,
callback,
mtime: getModifiedTime(fileName)
mtime: getModifiedTime(filePath)
};
watchedFiles.push(file);
@@ -297,6 +305,90 @@ namespace ts {
};
}
function createWatchedFileSet() {
const dirWatchers = createFileMap<DirectoryWatcher>();
// One file can have multiple watchers
const fileWatcherCallbacks = createFileMap<FileWatcherCallback[]>();
return { addFile, removeFile };
function reduceDirWatcherRefCountForFile(filePath: Path) {
const dirPath = getDirectoryPath(filePath);
if (dirWatchers.contains(dirPath)) {
const watcher = dirWatchers.get(dirPath);
watcher.referenceCount -= 1;
if (watcher.referenceCount <= 0) {
watcher.close();
dirWatchers.remove(dirPath);
}
}
}
function addDirWatcher(dirPath: Path): void {
if (dirWatchers.contains(dirPath)) {
const watcher = dirWatchers.get(dirPath);
watcher.referenceCount += 1;
return;
}
const watcher: DirectoryWatcher = _fs.watch(
dirPath,
{ persistent: true },
(eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath)
);
watcher.referenceCount = 1;
dirWatchers.set(dirPath, watcher);
return;
}
function addFileWatcherCallback(filePath: Path, callback: FileWatcherCallback): void {
if (fileWatcherCallbacks.contains(filePath)) {
fileWatcherCallbacks.get(filePath).push(callback);
}
else {
fileWatcherCallbacks.set(filePath, [callback]);
}
}
function addFile(filePath: Path, callback: FileWatcherCallback): WatchedFile {
addFileWatcherCallback(filePath, callback);
addDirWatcher(getDirectoryPath(filePath));
return { filePath, callback };
}
function removeFile(watchedFile: WatchedFile) {
removeFileWatcherCallback(watchedFile.filePath, watchedFile.callback);
reduceDirWatcherRefCountForFile(watchedFile.filePath);
}
function removeFileWatcherCallback(filePath: Path, callback: FileWatcherCallback) {
if (fileWatcherCallbacks.contains(filePath)) {
const newCallbacks = copyListRemovingItem(callback, fileWatcherCallbacks.get(filePath));
if (newCallbacks.length === 0) {
fileWatcherCallbacks.remove(filePath);
}
else {
fileWatcherCallbacks.set(filePath, newCallbacks);
}
}
}
/**
* @param watcherPath is the path from which the watcher is triggered.
*/
function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: Path) {
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
const filePath = typeof relativeFileName !== "string"
? undefined
: toPath(relativeFileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) {
for (const fileCallback of fileWatcherCallbacks.get(filePath)) {
fileCallback(filePath);
}
}
}
}
// REVIEW: for now this implementation uses polling.
// The advantage of polling is that it works reliably
// on all os and with network mounted files.
@@ -310,8 +402,13 @@ namespace ts {
// changes for large reference sets? If so, do we want
// to increase the chunk size or decrease the interval
// time dynamically to match the large reference set?
const pollingWatchedFileSet = createPollingWatchedFileSet();
const watchedFileSet = createWatchedFileSet();
function isNode4OrLater(): boolean {
return parseInt(process.version.charAt(1)) >= 4;
}
const platform: string = _os.platform();
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
@@ -365,7 +462,7 @@ namespace ts {
}
function getCanonicalPath(path: string): string {
return useCaseSensitiveFileNames ? path.toLowerCase() : path;
return useCaseSensitiveFileNames ? path : path.toLowerCase();
}
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
@@ -405,29 +502,38 @@ namespace ts {
},
readFile,
writeFile,
watchFile: (fileName, callback) => {
watchFile: (filePath, callback) => {
// Node 4.0 stablized the `fs.watch` function on Windows which avoids polling
// and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
// if the current node.js version is newer than 4, use `fs.watch` instead.
const watchedFile = watchedFileSet.addFile(fileName, callback);
const watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet;
const watchedFile = watchSet.addFile(filePath, callback);
return {
close: () => watchedFileSet.removeFile(watchedFile)
close: () => watchSet.removeFile(watchedFile)
};
},
watchDirectory: (path, callback, recursive) => {
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
let options: any;
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
options = { persistent: true };
}
return _fs.watch(
path,
{ persistent: true, recursive: !!recursive },
options,
(eventName: string, relativeFileName: string) => {
// In watchDirectory we only care about adding and removing files (when event name is
// "rename"); changes made within files are handled by corresponding fileWatchers (when
// event name is "change")
if (eventName === "rename") {
// When deleting a file, the passed baseFileName is null
callback(!relativeFileName ? relativeFileName : normalizePath(ts.combinePaths(path, relativeFileName)));
callback(!relativeFileName ? relativeFileName : normalizePath(combinePaths(path, relativeFileName)));
};
}
);
@@ -511,5 +617,3 @@ namespace ts {
}
})();
}
+5 -3
View File
@@ -334,12 +334,13 @@ namespace ts {
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (configFileName) {
configFileWatcher = sys.watchFile(configFileName, configFileChanged);
const configFilePath = toPath(configFileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
configFileWatcher = sys.watchFile(configFilePath, configFileChanged);
}
if (sys.watchDirectory && configFileName) {
const directory = ts.getDirectoryPath(configFileName);
directoryWatcher = sys.watchDirectory(
// When the configFileName is just "tsconfig.json", the watched directory should be
// When the configFileName is just "tsconfig.json", the watched directory should be
// the current direcotry; if there is a given "project" parameter, then the configFileName
// is an absolute file name.
directory == "" ? "." : directory,
@@ -442,7 +443,8 @@ namespace ts {
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
if (sourceFile && compilerOptions.watch) {
// Attach a file watcher
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
const filePath = toPath(sourceFile.fileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
sourceFile.fileWatcher = sys.watchFile(filePath, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
}
return sourceFile;
}
+18 -11
View File
@@ -170,6 +170,7 @@ namespace ts {
SymbolKeyword,
TypeKeyword,
FromKeyword,
GlobalKeyword,
OfKeyword, // LastKeyword and LastToken
// Parse tree nodes
@@ -311,11 +312,11 @@ namespace ts {
// Top-level nodes
SourceFile,
// JSDoc nodes.
// JSDoc nodes
JSDocTypeExpression,
// The * type.
// The * type
JSDocAllType,
// The ? type.
// The ? type
JSDocUnknownType,
JSDocArrayType,
JSDocUnionType,
@@ -389,11 +390,18 @@ namespace ts {
ContainsThis = 1 << 18, // Interface contains references to "this"
HasImplicitReturn = 1 << 19, // If function implicitly returns on one of codepaths (initialized by binding)
HasExplicitReturn = 1 << 20, // If function has explicit reachable return on one of codepaths (initialized by binding)
GlobalAugmentation = 1 << 21, // Set if module declaration is an augmentation for the global scope
HasClassExtends = 1 << 22, // If the file has a non-ambient class with an extends clause in ES5 or lower (initialized by binding)
HasDecorators = 1 << 23, // If the file has decorators (initialized by binding)
HasParamDecorators = 1 << 24, // If the file has parameter decorators (initialized by binding)
HasAsyncFunctions = 1 << 25, // If the file has async functions (initialized by binding)
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
AccessibilityModifier = Public | Private | Protected,
BlockScoped = Let | Const,
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
EmitHelperFlags = HasClassExtends | HasDecorators | HasParamDecorators | HasAsyncFunctions,
}
/* @internal */
@@ -996,7 +1004,7 @@ namespace ts {
}
// @kind(SyntaxKind.CallExpression)
export interface CallExpression extends LeftHandSideExpression {
export interface CallExpression extends LeftHandSideExpression, Declaration {
expression: LeftHandSideExpression;
typeArguments?: NodeArray<TypeNode>;
arguments: NodeArray<Expression>;
@@ -1475,6 +1483,8 @@ namespace ts {
type: JSDocType;
}
export type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
// @kind(SyntaxKind.JSDocRecordMember)
export interface JSDocRecordMember extends PropertySignature {
name: Identifier | LiteralExpression;
@@ -1577,6 +1587,7 @@ namespace ts {
// Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
/* @internal */ resolvedModules: Map<ResolvedModule>;
/* @internal */ imports: LiteralExpression[];
/* @internal */ moduleAugmentations: LiteralExpression[];
}
export interface ScriptReferenceHost {
@@ -1725,6 +1736,7 @@ namespace ts {
getSymbolAtLocation(node: Node): Symbol;
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol;
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
getTypeAtLocation(node: Node): Type;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
@@ -1910,7 +1922,7 @@ namespace ts {
isOptionalParameter(node: ParameterDeclaration): boolean;
moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean;
isArgumentsLocalBinding(node: Identifier): boolean;
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile;
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile;
}
export const enum SymbolFlags {
@@ -2043,11 +2055,6 @@ namespace ts {
TypeChecked = 0x00000001, // Node has been type checked
LexicalThis = 0x00000002, // Lexical 'this' reference
CaptureThis = 0x00000004, // Lexical 'this' used in body
EmitExtends = 0x00000008, // Emit __extends
EmitDecorate = 0x00000010, // Emit __decorate
EmitParam = 0x00000020, // Emit __param helper for decorators
EmitAwaiter = 0x00000040, // Emit __awaiter
EmitGenerator = 0x00000080, // Emit __generator
SuperInstance = 0x00000100, // Instance 'super' reference
SuperStatic = 0x00000200, // Static 'super' reference
ContextChecked = 0x00000400, // Contextual types have been assigned
+94 -60
View File
@@ -251,6 +251,31 @@ namespace ts {
isCatchClauseVariableDeclaration(declaration);
}
export function isAmbientModule(node: Node): boolean {
return node && node.kind === SyntaxKind.ModuleDeclaration &&
((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(<ModuleDeclaration>node));
}
export function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean {
return !!(module.flags & NodeFlags.GlobalAugmentation);
}
export function isExternalModuleAugmentation(node: Node): boolean {
// external module augmentation is a ambient module declaration that is either:
// - defined in the top level scope and source file is an external module
// - defined inside ambient module declaration located in the top level scope and source file not an external module
if (!node || !isAmbientModule(node)) {
return false;
}
switch (node.parent.kind) {
case SyntaxKind.SourceFile:
return isExternalModule(<SourceFile>node.parent);
case SyntaxKind.ModuleBlock:
return isAmbientModule(node.parent.parent) && !isExternalModule(<SourceFile>node.parent.parent.parent);
}
return false;
}
// Gets the nearest enclosing block scope container that has the provided node
// as a descendant, that is not the provided node.
export function getEnclosingBlockScopeContainer(node: Node): Node {
@@ -343,6 +368,7 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.TypeAliasDeclaration:
errorNode = (<Declaration>node).name;
break;
}
@@ -776,10 +802,10 @@ namespace ts {
}
/**
* Given an super call\property node returns a closest node where either
* - super call\property is legal in the node and not legal in the parent node the node.
* Given an super call\property node returns a closest node where either
* - super call\property is legal in the node and not legal in the parent node the node.
* i.e. super call is legal in constructor but not legal in the class body.
* - node is arrow function (so caller might need to call getSuperContainer in case if he needs to climb higher)
* - node is arrow function (so caller might need to call getSuperContainer in case it needs to climb higher)
* - super call\property is definitely illegal in the node (but might be legal in some subnode)
* i.e. super property access is illegal in function declaration but can be legal in the statement list
*/
@@ -859,54 +885,28 @@ namespace ts {
// property declarations are valid if their parent is a class declaration.
return node.parent.kind === SyntaxKind.ClassDeclaration;
case SyntaxKind.Parameter:
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
return (<FunctionLikeDeclaration>node.parent).body && node.parent.parent.kind === SyntaxKind.ClassDeclaration;
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MethodDeclaration:
// if this method has a body and its parent is a class declaration, this is a valid target.
return (<FunctionLikeDeclaration>node).body && node.parent.kind === SyntaxKind.ClassDeclaration;
return (<FunctionLikeDeclaration>node).body !== undefined
&& node.parent.kind === SyntaxKind.ClassDeclaration;
case SyntaxKind.Parameter:
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
return (<FunctionLikeDeclaration>node.parent).body !== undefined
&& (node.parent.kind === SyntaxKind.Constructor
|| node.parent.kind === SyntaxKind.MethodDeclaration
|| node.parent.kind === SyntaxKind.SetAccessor)
&& node.parent.parent.kind === SyntaxKind.ClassDeclaration;
}
return false;
}
export function nodeIsDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
if (node.decorators) {
return true;
}
return false;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.Parameter:
if (node.decorators) {
return true;
}
return false;
case SyntaxKind.GetAccessor:
if ((<FunctionLikeDeclaration>node).body && node.decorators) {
return true;
}
return false;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.SetAccessor:
if ((<FunctionLikeDeclaration>node).body && node.decorators) {
return true;
}
return false;
}
return false;
return node.decorators !== undefined
&& nodeCanBeDecorated(node);
}
export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression {
@@ -1054,7 +1054,7 @@ namespace ts {
/**
* Returns true if the node is a CallExpression to the identifier 'require' with
* exactly one string literal argument.
* exactly one argument.
* This function does not test if the node is in a JavaScript file or not.
*/
export function isRequireCall(expression: Node): expression is CallExpression {
@@ -1062,8 +1062,7 @@ namespace ts {
return expression.kind === SyntaxKind.CallExpression &&
(<CallExpression>expression).expression.kind === SyntaxKind.Identifier &&
(<Identifier>(<CallExpression>expression).expression).text === "require" &&
(<CallExpression>expression).arguments.length === 1 &&
(<CallExpression>expression).arguments[0].kind === SyntaxKind.StringLiteral;
(<CallExpression>expression).arguments.length === 1;
}
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
@@ -1115,6 +1114,9 @@ namespace ts {
if (node.kind === SyntaxKind.ExportDeclaration) {
return (<ExportDeclaration>node).moduleSpecifier;
}
if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
return (<ModuleDeclaration>node).name;
}
}
export function hasQuestionToken(node: Node) {
@@ -1140,26 +1142,56 @@ namespace ts {
(<JSDocFunctionType>node).parameters[0].type.kind === SyntaxKind.JSDocConstructorType;
}
function getJSDocTag(node: Node, kind: SyntaxKind): JSDocTag {
if (node && node.jsDocComment) {
for (const tag of node.jsDocComment.tags) {
if (tag.kind === kind) {
return tag;
}
function getJSDocTag(node: Node, kind: SyntaxKind, checkParentVariableStatement: boolean): JSDocTag {
if (!node) {
return undefined;
}
const jsDocComment = getJSDocComment(node, checkParentVariableStatement);
if (!jsDocComment) {
return undefined;
}
for (const tag of jsDocComment.tags) {
if (tag.kind === kind) {
return tag;
}
}
}
function getJSDocComment(node: Node, checkParentVariableStatement: boolean): JSDocComment {
if (node.jsDocComment) {
return node.jsDocComment;
}
// Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement.
// /**
// * @param {number} name
// * @returns {number}
// */
// var x = function(name) { return name.length; }
if (checkParentVariableStatement) {
const isInitializerOfVariableDeclarationInStatement =
node.parent.kind === SyntaxKind.VariableDeclaration &&
(<VariableDeclaration>node.parent).initializer === node &&
node.parent.parent.parent.kind === SyntaxKind.VariableStatement;
const variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined;
return variableStatementNode && variableStatementNode.jsDocComment;
}
return undefined;
}
export function getJSDocTypeTag(node: Node): JSDocTypeTag {
return <JSDocTypeTag>getJSDocTag(node, SyntaxKind.JSDocTypeTag);
return <JSDocTypeTag>getJSDocTag(node, SyntaxKind.JSDocTypeTag, /*checkParentVariableStatement*/ false);
}
export function getJSDocReturnTag(node: Node): JSDocReturnTag {
return <JSDocReturnTag>getJSDocTag(node, SyntaxKind.JSDocReturnTag);
return <JSDocReturnTag>getJSDocTag(node, SyntaxKind.JSDocReturnTag, /*checkParentVariableStatement*/ true);
}
export function getJSDocTemplateTag(node: Node): JSDocTemplateTag {
return <JSDocTemplateTag>getJSDocTag(node, SyntaxKind.JSDocTemplateTag);
return <JSDocTemplateTag>getJSDocTag(node, SyntaxKind.JSDocTemplateTag, /*checkParentVariableStatement*/ false);
}
export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag {
@@ -1168,19 +1200,21 @@ namespace ts {
// annotation.
const parameterName = (<Identifier>parameter.name).text;
const docComment = parameter.parent.jsDocComment;
if (docComment) {
return <JSDocParameterTag>forEach(docComment.tags, t => {
if (t.kind === SyntaxKind.JSDocParameterTag) {
const parameterTag = <JSDocParameterTag>t;
const jsDocComment = getJSDocComment(parameter.parent, /*checkParentVariableStatement*/ true);
if (jsDocComment) {
for (const tag of jsDocComment.tags) {
if (tag.kind === SyntaxKind.JSDocParameterTag) {
const parameterTag = <JSDocParameterTag>tag;
const name = parameterTag.preParameterName || parameterTag.postParameterName;
if (name.text === parameterName) {
return t;
return parameterTag;
}
}
});
}
}
}
return undefined;
}
export function hasRestParameter(s: SignatureDeclaration): boolean {
+25
View File
@@ -572,6 +572,31 @@ namespace FourSlash {
}
}
public verifyCompletionListStartsWithItemsInOrder(items: string[]): void {
if (items.length === 0) {
return;
}
const entries = this.getCompletionListAtCaret().entries;
assert.isTrue(items.length <= entries.length, `Amount of expected items in completion list [ ${items.length} ] is greater than actual number of items in list [ ${entries.length} ]`);
for (let i = 0; i < items.length; i++) {
assert.equal(entries[i].name, items[i], `Unexpected item in completion list`);
}
}
public noItemsWithSameNameButDifferentKind(): void {
const completions = this.getCompletionListAtCaret();
const uniqueItems: ts.Map<string> = {};
for (const item of completions.entries) {
if (!ts.hasProperty(uniqueItems, item.name)) {
uniqueItems[item.name] = item.kind;
}
else {
assert.equal(item.kind, uniqueItems[item.name], `Items should have the same kind, got ${item.kind} and ${uniqueItems[item.name]}`);
}
}
}
public verifyMemberListIsEmpty(negative: boolean) {
const members = this.getMemberListAtCaret();
if ((!members || members.entries.length === 0) && negative) {
-2
View File
@@ -1,5 +1,3 @@
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
+32 -13
View File
@@ -1255,7 +1255,7 @@ interface Console {
select(element: Element): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(): void;
trace(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
}
@@ -1514,9 +1514,9 @@ interface DataTransferItemList {
length: number;
add(data: File): DataTransferItem;
clear(): void;
item(index: number): File;
item(index: number): DataTransferItem;
remove(index: number): void;
[index: number]: File;
[index: number]: DataTransferItem;
}
declare var DataTransferItemList: {
@@ -2569,6 +2569,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* @param content The text and HTML tags to write.
*/
writeln(...content: string[]): void;
createElement(tagName: "picture"): HTMLPictureElement;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -2981,6 +2983,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
matches(selector: string): boolean;
getElementsByTagName(tagname: "picture"): NodeListOf<HTMLPictureElement>;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@@ -3770,6 +3773,7 @@ interface HTMLCanvasElement extends HTMLElement {
* @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
*/
toDataURL(type?: string, ...args: any[]): string;
toBlob(): Blob;
}
declare var HTMLCanvasElement: {
@@ -6924,7 +6928,7 @@ interface IDBDatabase extends EventTarget {
objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
version: string;
version: number;
close(): void;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
@@ -7640,7 +7644,7 @@ declare var MediaQueryList: {
interface MediaSource extends EventTarget {
activeSourceBuffers: SourceBufferList;
duration: number;
readyState: number;
readyState: string;
sourceBuffers: SourceBufferList;
addSourceBuffer(type: string): SourceBuffer;
endOfStream(error?: number): void;
@@ -10369,17 +10373,16 @@ declare var Storage: {
}
interface StorageEvent extends Event {
key: string;
newValue: any;
oldValue: any;
storageArea: Storage;
url: string;
initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void;
key?: string;
oldValue?: string;
newValue?: string;
storageArea?: Storage;
}
declare var StorageEvent: {
prototype: StorageEvent;
new(): StorageEvent;
new (type: string, eventInitDict?: StorageEventInit): StorageEvent;
}
interface StyleMedia {
@@ -11977,7 +11980,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
msMatchMedia(mediaQuery: string): MediaQueryList;
msRequestAnimationFrame(callback: FrameRequestCallback): number;
msWriteProfilerMark(profilerMarkName: string): void;
open(url?: string, target?: string, features?: string, replace?: boolean): any;
open(url?: string, target?: string, features?: string, replace?: boolean): Window;
postMessage(message: any, targetOrigin: string, ports?: any): void;
print(): void;
prompt(message?: string, _default?: string): string;
@@ -12579,6 +12582,14 @@ interface XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface StorageEventInit extends EventInit {
key?: string;
oldValue?: string;
newValue?: string;
url: string;
storageArea?: Storage;
}
interface IDBObjectStoreParameters {
keyPath?: string | string[];
autoIncrement?: boolean;
@@ -12633,6 +12644,14 @@ declare var HTMLTemplateElement: {
new(): HTMLTemplateElement;
}
interface HTMLPictureElement extends HTMLElement {
}
declare var HTMLPictureElement: {
prototype: HTMLPictureElement;
new(): HTMLPictureElement;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@@ -12829,7 +12848,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void;
declare function msMatchMedia(mediaQuery: string): MediaQueryList;
declare function msRequestAnimationFrame(callback: FrameRequestCallback): number;
declare function msWriteProfilerMark(profilerMarkName: string): void;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): any;
declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window;
declare function postMessage(message: any, targetOrigin: string, ports?: any): void;
declare function print(): void;
declare function prompt(message?: string, _default?: string): string;
+89
View File
@@ -0,0 +1,89 @@
interface Array<T> {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: T, fromIndex?: number): boolean;
}
interface Int8Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint8Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint8ClampedArray {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Int16Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint16Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Int32Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Uint32Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Float32Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
interface Float64Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
+1
View File
@@ -0,0 +1 @@
/// <reference no-default-lib="true"/>
+2 -2
View File
@@ -69,7 +69,7 @@ interface Console {
select(element: any): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(): void;
trace(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
}
@@ -309,7 +309,7 @@ interface IDBDatabase extends EventTarget {
objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
version: string;
version: number;
close(): void;
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
+30 -20
View File
@@ -120,7 +120,7 @@ namespace ts.server {
if (!resolution) {
const existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName);
if (moduleResolutionIsValid(existingResolution)) {
// ok, it is safe to use existing module resolution results
// ok, it is safe to use existing module resolution results
resolution = existingResolution;
}
else {
@@ -145,8 +145,8 @@ namespace ts.server {
}
if (resolution.resolvedModule) {
// TODO: consider checking failedLookupLocations
// TODO: use lastCheckTime to track expiration for module name resolution
// TODO: consider checking failedLookupLocations
// TODO: use lastCheckTime to track expiration for module name resolution
return true;
}
@@ -483,7 +483,7 @@ namespace ts.server {
openFileRootsConfigured: ScriptInfo[] = [];
// a path to directory watcher map that detects added tsconfig files
directoryWatchersForTsconfig: ts.Map<FileWatcher> = {};
// count of how many projects are using the directory watcher. If the
// count of how many projects are using the directory watcher. If the
// number becomes 0 for a watcher, then we should close it.
directoryWatchersRefCount: ts.Map<number> = {};
hostConfiguration: HostConfiguration;
@@ -564,11 +564,11 @@ namespace ts.server {
// We check if the project file list has changed. If so, we update the project.
if (!arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) {
// For configured projects, the change is made outside the tsconfig file, and
// it is not likely to affect the project for other files opened by the client. We can
// it is not likely to affect the project for other files opened by the client. We can
// just update the current project.
this.updateConfiguredProject(project);
// Call updateProjectStructure to clean up inferred projects we may have
// Call updateProjectStructure to clean up inferred projects we may have
// created for the new files
this.updateProjectStructure();
}
@@ -792,8 +792,8 @@ namespace ts.server {
* @param info The file that has been closed or newly configured
*/
closeOpenFile(info: ScriptInfo) {
// Closing file should trigger re-reading the file content from disk. This is
// because the user may chose to discard the buffer content before saving
// Closing file should trigger re-reading the file content from disk. This is
// because the user may chose to discard the buffer content before saving
// to the disk, and the server's version of the file can be out of sync.
info.svc.reloadFromFile(info.fileName);
@@ -891,8 +891,8 @@ namespace ts.server {
}
/**
* This function is to update the project structure for every projects.
* It is called on the premise that all the configured projects are
* This function is to update the project structure for every projects.
* It is called on the premise that all the configured projects are
* up to date.
*/
updateProjectStructure() {
@@ -946,7 +946,7 @@ namespace ts.server {
if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) {
// If the root file has already been added into a configured project,
// meaning the original inferred project is gone already.
// meaning the original inferred project is gone already.
if (!rootedProject.isConfiguredProject()) {
this.removeProject(rootedProject);
}
@@ -1002,7 +1002,9 @@ namespace ts.server {
info.setFormatOptions(this.getFormatCodeOptions());
this.filenameToScriptInfo[fileName] = info;
if (!info.isOpen) {
info.fileWatcher = this.host.watchFile(fileName, _ => { this.watchedFileChanged(fileName); });
info.fileWatcher = this.host.watchFile(
toPath(fileName, fileName, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
_ => { this.watchedFileChanged(fileName); });
}
}
}
@@ -1024,10 +1026,16 @@ namespace ts.server {
// the newly opened file.
findConfigFile(searchPath: string): string {
while (true) {
const fileName = ts.combinePaths(searchPath, "tsconfig.json");
if (this.host.fileExists(fileName)) {
return fileName;
const tsconfigFileName = ts.combinePaths(searchPath, "tsconfig.json");
if (this.host.fileExists(tsconfigFileName)) {
return tsconfigFileName;
}
const jsconfigFileName = ts.combinePaths(searchPath, "jsconfig.json");
if (this.host.fileExists(jsconfigFileName)) {
return jsconfigFileName;
}
const parentPath = ts.getDirectoryPath(searchPath);
if (parentPath === searchPath) {
break;
@@ -1051,9 +1059,9 @@ namespace ts.server {
}
/**
* This function tries to search for a tsconfig.json for the given file. If we found it,
* This function tries to search for a tsconfig.json for the given file. If we found it,
* we first detect if there is already a configured project created for it: if so, we re-read
* the tsconfig file content and update the project; otherwise we create a new one.
* the tsconfig file content and update the project; otherwise we create a new one.
*/
openOrUpdateConfiguredProjectForFile(fileName: string) {
const searchPath = ts.normalizePath(getDirectoryPath(fileName));
@@ -1178,7 +1186,7 @@ namespace ts.server {
return { succeeded: false, error: rawConfig.error };
}
else {
const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath);
const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, /*existingOptions*/ {}, configFilename);
Debug.assert(!!parsedCommandLine.fileNames);
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
@@ -1215,7 +1223,9 @@ namespace ts.server {
}
}
project.finishGraph();
project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project));
project.projectFileWatcher = this.host.watchFile(
toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
_ => this.watchedProjectConfigFileChanged(project));
this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename));
project.directoryWatcher = this.host.watchDirectory(
ts.getDirectoryPath(configFilename),
@@ -1255,7 +1265,7 @@ namespace ts.server {
info = this.openFile(fileName, /*openedByClient*/ false);
}
else {
// if the root file was opened by client, it would belong to either
// if the root file was opened by client, it would belong to either
// openFileRoots or openFileReferenced.
if (info.isOpen) {
if (this.openFileRoots.indexOf(info) >= 0) {
+3 -1
View File
@@ -792,7 +792,9 @@ namespace ts.server {
}
private closeClientFile(fileName: string) {
if (!fileName) { return; }
if (!fileName) {
return;
}
const file = ts.normalizePath(fileName);
this.projectService.closeClientFile(file);
}
+1 -1
View File
@@ -387,7 +387,7 @@ namespace ts.NavigationBar {
function getModuleName(moduleDeclaration: ModuleDeclaration): string {
// We want to maintain quotation marks.
if (moduleDeclaration.name.kind === SyntaxKind.StringLiteral) {
if (isAmbientModule(moduleDeclaration)) {
return getTextOfNode(moduleDeclaration.name);
}
+63 -21
View File
@@ -811,6 +811,7 @@ namespace ts {
public nameTable: Map<string>;
public resolvedModules: Map<ResolvedModule>;
public imports: LiteralExpression[];
public moduleAugmentations: LiteralExpression[];
private namedDeclarations: Map<Declaration[]>;
constructor(kind: SyntaxKind, pos: number, end: number) {
@@ -2018,13 +2019,6 @@ namespace ts {
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true);
}
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
return useCaseSensitivefileNames
? ((fileName) => fileName)
: ((fileName) => fileName.toLowerCase());
}
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry {
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
// for those settings.
@@ -5517,10 +5511,8 @@ namespace ts {
};
}
function isImportOrExportSpecifierImportSymbol(symbol: Symbol) {
return (symbol.flags & SymbolFlags.Alias) && forEach(symbol.declarations, declaration => {
return declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ExportSpecifier;
});
function isImportSpecifierSymbol(symbol: Symbol) {
return (symbol.flags & SymbolFlags.Alias) && !!getDeclarationOfKind(symbol, SyntaxKind.ImportSpecifier);
}
function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string {
@@ -5964,8 +5956,17 @@ namespace ts {
let result = [symbol];
// If the symbol is an alias, add what it alaises to the list
if (isImportOrExportSpecifierImportSymbol(symbol)) {
result.push(typeChecker.getAliasedSymbol(symbol));
if (isImportSpecifierSymbol(symbol)) {
result.push(typeChecker.getAliasedSymbol(symbol));
}
// For export specifiers, the exported name can be refering to a local symbol, e.g.:
// import {a} from "mod";
// export {a as somethingElse}
// We want the *local* declaration of 'a' as declared in the import,
// *not* as declared within "mod" (or farther)
if (location.parent.kind === SyntaxKind.ExportSpecifier) {
result.push(typeChecker.getExportSpecifierLocalTargetSymbol(<ExportSpecifier>location.parent));
}
// If the location is in a context sensitive location (i.e. in an object literal) try
@@ -6011,15 +6012,43 @@ namespace ts {
// Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result);
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {});
}
});
return result;
}
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[]): void {
if (symbol && symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
/**
* Find symbol of the given property-name and add the symbol to the given result array
* @param symbol a symbol to start searching for the given propertyName
* @param propertyName a name of property to serach for
* @param result an array of symbol of found property symbols
* @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol.
* The value of previousIterationSymbol is undefined when the function is first called.
*/
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[],
previousIterationSymbolsCache: SymbolTable): void {
if (!symbol) {
return;
}
// If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited
// This is particularly important for the following cases, so that we do not infinitely visit the same symbol.
// For example:
// interface C extends C {
// /*findRef*/propName: string;
// }
// The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName,
// the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined,
// the function will add any found symbol of the property-name, then its sub-routine will call
// getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already
// visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol.
if (hasProperty(previousIterationSymbolsCache, symbol.name)) {
return;
}
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
forEach(symbol.getDeclarations(), declaration => {
if (declaration.kind === SyntaxKind.ClassDeclaration) {
getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(<ClassDeclaration>declaration));
@@ -6042,7 +6071,8 @@ namespace ts {
}
// Visit the typeReference as well to see if it directly or indirectly use that property
getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result);
previousIterationSymbolsCache[symbol.name] = symbol;
getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache);
}
}
}
@@ -6055,13 +6085,24 @@ namespace ts {
// If the reference symbol is an alias, check if what it is aliasing is one of the search
// symbols.
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
if (isImportSpecifierSymbol(referenceSymbol)) {
const aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
return aliasedSymbol;
}
}
// For export specifiers, it can be a local symbol, e.g.
// import {a} from "mod";
// export {a as somethingElse}
// We want the local target of the export (i.e. the import symbol) and not the final target (i.e. "mod".a)
if (referenceLocation.parent.kind === SyntaxKind.ExportSpecifier) {
const aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(<ExportSpecifier>referenceLocation.parent);
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
return aliasedSymbol;
}
}
// If the reference location is in an object literal, try to get the contextual type for the
// object literal, lookup the property symbol in the contextual type, and use this symbol to
// compare to our searchSymbol
@@ -6083,7 +6124,7 @@ namespace ts {
// see if any is in the list
if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
const result: Symbol[] = [];
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result);
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {});
return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
}
@@ -6256,7 +6297,7 @@ namespace ts {
return SemanticMeaning.Value | SemanticMeaning.Type;
case SyntaxKind.ModuleDeclaration:
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
if (isAmbientModule(<ModuleDeclaration>node)) {
return SemanticMeaning.Namespace | SemanticMeaning.Value;
}
else if (getModuleInstanceState(node) === ModuleInstanceState.Instantiated) {
@@ -6787,7 +6828,8 @@ namespace ts {
function classifyDisabledMergeCode(text: string, start: number, end: number) {
// Classify the line that the ======= marker is on as a comment. Then just lex
// all further tokens and add them to the result.
for (var i = start; i < end; i++) {
let i: number;
for (i = start; i < end; i++) {
if (isLineBreak(text.charCodeAt(i))) {
break;
}
+2 -1
View File
@@ -946,7 +946,8 @@ namespace ts {
};
}
const configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName)));
const normalizedFileName = normalizeSlashes(fileName);
const configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName);
return {
options: configFile.options,
@@ -1,5 +1,5 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2304: Cannot find name 'foo'.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'?
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ====
@@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): err
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~
!!! error TS2304: Cannot find name 'foo'.
!!! error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'?
}
}
@@ -0,0 +1,13 @@
tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts(5,17): error TS2662: Cannot find name 'foo'. Did you mean the static member 'C.foo'?
==== tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts (1 errors) ====
class C {
static foo: string;
bar() {
let k = foo;
~~~
!!! error TS2662: Cannot find name 'foo'. Did you mean the static member 'C.foo'?
}
}
@@ -0,0 +1,18 @@
//// [accessInstanceMemberFromStaticMethod01.ts]
class C {
static foo: string;
bar() {
let k = foo;
}
}
//// [accessInstanceMemberFromStaticMethod01.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
var k = foo;
};
return C;
}());
@@ -0,0 +1,13 @@
tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts(5,17): error TS2304: Cannot find name 'foo'.
==== tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts (1 errors) ====
class C {
foo: string;
static bar() {
let k = foo;
~~~
!!! error TS2304: Cannot find name 'foo'.
}
}
@@ -0,0 +1,18 @@
//// [accessStaticMemberFromInstanceMethod01.ts]
class C {
foo: string;
static bar() {
let k = foo;
}
}
//// [accessStaticMemberFromInstanceMethod01.js]
var C = (function () {
function C() {
}
C.bar = function () {
var k = foo;
};
return C;
}());
@@ -1,5 +1,4 @@
tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
Property 'someClass' is missing in type 'Number'.
tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'.
@@ -9,7 +8,6 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes
x = 1; // Should be error
~
!!! error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
!!! error TS2322: Property 'someClass' is missing in type 'Number'.
var y = 1;
y = moduleA; // should be error
~
@@ -1,4 +1,4 @@
tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2664: Invalid module name in augmentation, module 'ext' cannot be found.
tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): error TS2307: Cannot find module 'ext'.
@@ -9,7 +9,7 @@ tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): err
declare module "ext" {
~~~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
!!! error TS2664: Invalid module name in augmentation, module 'ext' cannot be found.
export class C { }
}
@@ -1,9 +1,12 @@
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,5): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (1 errors) ====
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (2 errors) ====
module M {
export declare module "M" { }
~~~~~~
!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
}
@@ -1,7 +1,10 @@
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2664: Invalid module name in augmentation, module 'M' cannot be found.
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (1 errors) ====
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (2 errors) ====
export declare module "M" { }
~~~~~~
!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
!!! error TS2664: Invalid module name in augmentation, module 'M' cannot be found.
@@ -1,5 +1,4 @@
tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type 'number' is not assignable to type 'IArguments'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts (1 errors) ====
@@ -8,5 +7,4 @@ tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS
arguments = 10; /// This shouldnt be of type number and result in error.
~~~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'IArguments'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
}
@@ -26,10 +26,13 @@ tests/cases/compiler/arrayAssignmentTest1.ts(70,1): error TS2322: Type 'C3[]' is
Property 'C2M1' is missing in type 'C3'.
tests/cases/compiler/arrayAssignmentTest1.ts(75,1): error TS2322: Type 'C2[]' is not assignable to type 'C3[]'.
Type 'C2' is not assignable to type 'C3'.
Property 'CM3M1' is missing in type 'C2'.
tests/cases/compiler/arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is not assignable to type 'C3[]'.
Type 'C1' is not assignable to type 'C3'.
Property 'CM3M1' is missing in type 'C1'.
tests/cases/compiler/arrayAssignmentTest1.ts(77,1): error TS2322: Type 'I1[]' is not assignable to type 'C3[]'.
Type 'I1' is not assignable to type 'C3'.
Property 'CM3M1' is missing in type 'I1'.
tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'.
Property 'push' is missing in type '() => C1'.
tests/cases/compiler/arrayAssignmentTest1.ts(80,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'.
@@ -159,14 +162,17 @@ tests/cases/compiler/arrayAssignmentTest1.ts(85,1): error TS2322: Type 'I1' is n
~~~~~~
!!! error TS2322: Type 'C2[]' is not assignable to type 'C3[]'.
!!! error TS2322: Type 'C2' is not assignable to type 'C3'.
!!! error TS2322: Property 'CM3M1' is missing in type 'C2'.
arr_c3 = arr_c1_2; // should be an error - is
~~~~~~
!!! error TS2322: Type 'C1[]' is not assignable to type 'C3[]'.
!!! error TS2322: Type 'C1' is not assignable to type 'C3'.
!!! error TS2322: Property 'CM3M1' is missing in type 'C1'.
arr_c3 = arr_i1_2; // should be an error - is
~~~~~~
!!! error TS2322: Type 'I1[]' is not assignable to type 'C3[]'.
!!! error TS2322: Type 'I1' is not assignable to type 'C3'.
!!! error TS2322: Property 'CM3M1' is missing in type 'I1'.
arr_any = f1; // should be an error - is
~~~~~~~
@@ -18,7 +18,6 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
Types of parameters 'items' and 'items' are incompatible.
Type 'number | string' is not assignable to type 'Number'.
Type 'string' is not assignable to type 'Number'.
Property 'toFixed' is missing in type 'String'.
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ====
@@ -82,5 +81,4 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
!!! error TS2322: Type 'number | string' is not assignable to type 'Number'.
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
!!! error TS2322: Property 'toFixed' is missing in type 'String'.
@@ -4,7 +4,6 @@ tests/cases/compiler/arraySigChecking.ts(18,5): error TS2322: Type 'void[]' is n
tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
Type 'number[]' is not assignable to type 'number[][]'.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/arraySigChecking.ts (3 errors) ====
@@ -39,7 +38,6 @@ tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]'
!!! error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
!!! error TS2322: Type 'number[]' is not assignable to type 'number[][]'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
function isEmpty(l: { length: number }) {
return l.length === 0;
@@ -1,5 +1,4 @@
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'.
Property 'isArray' is missing in type 'Number'.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: '=' expected.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'.
@@ -16,7 +15,6 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(
var xs3: typeof Array<number>;
~~~
!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'.
!!! error TS2322: Property 'isArray' is missing in type 'Number'.
~
!!! error TS1005: '=' expected.
~
@@ -3,9 +3,7 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: st
tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: number]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'String'.
tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'.
Index signature is missing in type 'Boolean'.
==== tests/cases/compiler/assignmentCompat1.ts (4 errors) ====
@@ -25,11 +23,9 @@ tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is
y = "foo"; // Error
~
!!! error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'String'.
z = "foo"; // OK, string has numeric indexer
z = false; // Error
~
!!! error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
@@ -8,6 +8,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (2 errors) ====
@@ -76,6 +80,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var b10: <T extends Derived>(...x: T[]) => T;
@@ -8,6 +8,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
Types of parameters 'x' and 'x' are incompatible.
Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
@@ -15,6 +19,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(78,9): error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
Types of parameters 'x' and 'x' are incompatible.
Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(81,9): error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
Types of parameters 'x' and 'x' are incompatible.
Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
@@ -22,6 +27,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(82,9): error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
Types of parameters 'x' and 'x' are incompatible.
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts (6 errors) ====
@@ -90,6 +96,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var b10: new <T extends Derived>(...x: T[]) => T;
@@ -124,6 +134,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
var b17: new <T>(x: (a: T) => T) => any[];
a17 = b17; // error
@@ -137,6 +148,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
}
module WithGenericSignaturesInBaseType {
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability16.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'any[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability16.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability16.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability17.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: any[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'any[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability17.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability17.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: any[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'any[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'any[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability18.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability18.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability18.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability19.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: number[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'number[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability19.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability19.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: number[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'number[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability20.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'string[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability20.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability20.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability21.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'string[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability21.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability21.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'string[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'string[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability22.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'boolean[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability22.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability22.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability23.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: boolean[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'boolean[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability23.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability23.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: boolean[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'boolean[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'boolean[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability29.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'any[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability29.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability29.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability30.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability30.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability30.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability31.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'string[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability31.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability31.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.
@@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability32.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'boolean[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability32.ts (1 errors) ====
@@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability32.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.
@@ -1,9 +1,7 @@
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Applicable'.
Property 'apply' is missing in type 'String'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Applicable'.
Property 'apply' is missing in type 'string[]'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Applicable'.
Property 'apply' is missing in type 'Number'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Applicable'.
Property 'apply' is missing in type '{}'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Applicable'.
@@ -26,7 +24,6 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi
x = '';
~
!!! error TS2322: Type 'string' is not assignable to type 'Applicable'.
!!! error TS2322: Property 'apply' is missing in type 'String'.
x = [''];
~
!!! error TS2322: Type 'string[]' is not assignable to type 'Applicable'.
@@ -34,7 +31,6 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi
x = 4;
~
!!! error TS2322: Type 'number' is not assignable to type 'Applicable'.
!!! error TS2322: Property 'apply' is missing in type 'Number'.
x = {};
~
!!! error TS2322: Type '{}' is not assignable to type 'Applicable'.
@@ -1,9 +1,7 @@
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Callable'.
Property 'call' is missing in type 'String'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Callable'.
Property 'call' is missing in type 'string[]'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Callable'.
Property 'call' is missing in type 'Number'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Callable'.
Property 'call' is missing in type '{}'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'.
@@ -26,7 +24,6 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio
x = '';
~
!!! error TS2322: Type 'string' is not assignable to type 'Callable'.
!!! error TS2322: Property 'call' is missing in type 'String'.
x = [''];
~
!!! error TS2322: Type 'string[]' is not assignable to type 'Callable'.
@@ -34,7 +31,6 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio
x = 4;
~
!!! error TS2322: Type 'number' is not assignable to type 'Callable'.
!!! error TS2322: Property 'call' is missing in type 'Number'.
x = {};
~
!!! error TS2322: Type '{}' is not assignable to type 'Callable'.
@@ -40,17 +40,12 @@ module M {
}
//// [asyncAwaitIsolatedModules_es6.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
return new Promise(function (resolve, reject) {
generator = generator.call(thisArg, _arguments);
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step("next", void 0);
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};
function f0() {
+6 -11
View File
@@ -40,17 +40,12 @@ module M {
}
//// [asyncAwait_es6.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
return new Promise(function (resolve, reject) {
generator = generator.call(thisArg, _arguments);
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step("next", void 0);
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};
function f0() {
@@ -0,0 +1,47 @@
//// [tests/cases/compiler/asyncFunctionsAcrossFiles.ts] ////
//// [a.ts]
import { b } from './b';
export const a = {
f: async () => {
await b.f();
}
};
//// [b.ts]
import { a } from './a';
export const b = {
f: async () => {
await a.f();
}
};
//// [b.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};
import { a } from './a';
export const b = {
f: () => __awaiter(this, void 0, Promise, function* () {
yield a.f();
})
};
//// [a.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};
import { b } from './b';
export const a = {
f: () => __awaiter(this, void 0, Promise, function* () {
yield b.f();
})
};
@@ -0,0 +1,32 @@
=== tests/cases/compiler/a.ts ===
import { b } from './b';
>b : Symbol(b, Decl(a.ts, 0, 8))
export const a = {
>a : Symbol(a, Decl(a.ts, 1, 12))
f: async () => {
>f : Symbol(f, Decl(a.ts, 1, 18))
await b.f();
>b.f : Symbol(f, Decl(b.ts, 1, 18))
>b : Symbol(b, Decl(a.ts, 0, 8))
>f : Symbol(f, Decl(b.ts, 1, 18))
}
};
=== tests/cases/compiler/b.ts ===
import { a } from './a';
>a : Symbol(a, Decl(b.ts, 0, 8))
export const b = {
>b : Symbol(b, Decl(b.ts, 1, 12))
f: async () => {
>f : Symbol(f, Decl(b.ts, 1, 18))
await a.f();
>a.f : Symbol(f, Decl(a.ts, 1, 18))
>a : Symbol(a, Decl(b.ts, 0, 8))
>f : Symbol(f, Decl(a.ts, 1, 18))
}
};
@@ -0,0 +1,40 @@
=== tests/cases/compiler/a.ts ===
import { b } from './b';
>b : { f: () => Promise<void>; }
export const a = {
>a : { f: () => Promise<void>; }
>{ f: async () => { await b.f(); }} : { f: () => Promise<void>; }
f: async () => {
>f : () => Promise<void>
>async () => { await b.f(); } : () => Promise<void>
await b.f();
>await b.f() : void
>b.f() : Promise<void>
>b.f : () => Promise<void>
>b : { f: () => Promise<void>; }
>f : () => Promise<void>
}
};
=== tests/cases/compiler/b.ts ===
import { a } from './a';
>a : { f: () => Promise<void>; }
export const b = {
>b : { f: () => Promise<void>; }
>{ f: async () => { await a.f(); }} : { f: () => Promise<void>; }
f: async () => {
>f : () => Promise<void>
>async () => { await a.f(); } : () => Promise<void>
await a.f();
>await a.f() : void
>a.f() : Promise<void>
>a.f : () => Promise<void>
>a : { f: () => Promise<void>; }
>f : () => Promise<void>
}
};
@@ -16,17 +16,12 @@ class Task extends Promise {
exports.Task = Task;
//// [test.js]
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
return new Promise(function (resolve, reject) {
generator = generator.call(thisArg, _arguments);
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step("next", void 0);
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};
var task_1 = require("./task");
+6 -11
View File
@@ -6,17 +6,12 @@ async function f() {}
function g() { }
//// [a.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
return new Promise(function (resolve, reject) {
generator = generator.call(thisArg, _arguments);
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step("next", void 0);
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new P(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.call(thisArg, _arguments)).next());
});
};
function f() {
@@ -1,11 +1,5 @@
tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type 'number' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => number' is not assignable to type '() => boolean'.
Type 'number' is not assignable to type 'boolean'.
tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type 'string' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => string' is not assignable to type '() => boolean'.
Type 'string' is not assignable to type 'boolean'.
tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => Object' is not assignable to type '() => boolean'.
@@ -17,15 +11,9 @@ tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not a
b = 1; // Error
~
!!! error TS2322: Type 'number' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => number' is not assignable to type '() => boolean'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
b = "a"; // Error
~
!!! error TS2322: Type 'string' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => string' is not assignable to type '() => boolean'.
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
b = {}; // Error
~
!!! error TS2322: Type '{}' is not assignable to type 'Boolean'.
@@ -0,0 +1,35 @@
//// [capturedLetConstInLoop11.ts]
for (;;) {
let x = 1;
() => x;
}
function foo() {
for (;;) {
const a = 0;
switch(a) {
case 0: return () => a;
}
}
}
//// [capturedLetConstInLoop11.js]
var _loop_1 = function() {
var x = 1;
(function () { return x; });
};
for (;;) {
_loop_1();
}
function foo() {
var _loop_2 = function() {
var a = 0;
switch (a) {
case 0: return { value: function () { return a; } };
}
};
for (;;) {
var state_2 = _loop_2();
if (typeof state_2 === "object") return state_2.value
}
}
@@ -0,0 +1,24 @@
=== tests/cases/compiler/capturedLetConstInLoop11.ts ===
for (;;) {
let x = 1;
>x : Symbol(x, Decl(capturedLetConstInLoop11.ts, 1, 7))
() => x;
>x : Symbol(x, Decl(capturedLetConstInLoop11.ts, 1, 7))
}
function foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop11.ts, 3, 1))
for (;;) {
const a = 0;
>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13))
switch(a) {
>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13))
case 0: return () => a;
>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13))
}
}
}
@@ -0,0 +1,29 @@
=== tests/cases/compiler/capturedLetConstInLoop11.ts ===
for (;;) {
let x = 1;
>x : number
>1 : number
() => x;
>() => x : () => number
>x : number
}
function foo() {
>foo : () => () => number
for (;;) {
const a = 0;
>a : number
>0 : number
switch(a) {
>a : number
case 0: return () => a;
>0 : number
>() => a : () => number
>a : number
}
}
}
@@ -0,0 +1,28 @@
//// [capturedLetConstInLoop11_ES6.ts]
for (;;) {
let x = 1;
() => x;
}
function foo() {
for (;;) {
const a = 0;
switch(a) {
case 0: return () => a;
}
}
}
//// [capturedLetConstInLoop11_ES6.js]
for (;;) {
let x = 1;
(() => x);
}
function foo() {
for (;;) {
const a = 0;
switch (a) {
case 0: return () => a;
}
}
}
@@ -0,0 +1,24 @@
=== tests/cases/compiler/capturedLetConstInLoop11_ES6.ts ===
for (;;) {
let x = 1;
>x : Symbol(x, Decl(capturedLetConstInLoop11_ES6.ts, 1, 7))
() => x;
>x : Symbol(x, Decl(capturedLetConstInLoop11_ES6.ts, 1, 7))
}
function foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop11_ES6.ts, 3, 1))
for (;;) {
const a = 0;
>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13))
switch(a) {
>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13))
case 0: return () => a;
>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13))
}
}
}
@@ -0,0 +1,29 @@
=== tests/cases/compiler/capturedLetConstInLoop11_ES6.ts ===
for (;;) {
let x = 1;
>x : number
>1 : number
() => x;
>() => x : () => number
>x : number
}
function foo() {
>foo : () => () => number
for (;;) {
const a = 0;
>a : number
>0 : number
switch(a) {
>a : number
case 0: return () => a;
>0 : number
>() => a : () => number
>a : number
}
}
}
@@ -0,0 +1,71 @@
//// [tests/cases/compiler/classExtendsAcrossFiles.ts] ////
//// [a.ts]
import { b } from './b';
export const a = {
f: () => {
class A { }
class B extends A { }
b.f();
}
};
//// [b.ts]
import { a } from './a';
export const b = {
f: () => {
class A { }
class B extends A { }
a.f();
}
};
//// [b.js]
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var a_1 = require('./a');
exports.b = {
f: function () {
var A = (function () {
function A() {
}
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
}(A));
a_1.a.f();
}
};
//// [a.js]
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var b_1 = require('./b');
exports.a = {
f: function () {
var A = (function () {
function A() {
}
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
return B;
}(A));
b_1.b.f();
}
};
@@ -0,0 +1,46 @@
=== tests/cases/compiler/a.ts ===
import { b } from './b';
>b : Symbol(b, Decl(a.ts, 0, 8))
export const a = {
>a : Symbol(a, Decl(a.ts, 1, 12))
f: () => {
>f : Symbol(f, Decl(a.ts, 1, 18))
class A { }
>A : Symbol(A, Decl(a.ts, 2, 14))
class B extends A { }
>B : Symbol(B, Decl(a.ts, 3, 19))
>A : Symbol(A, Decl(a.ts, 2, 14))
b.f();
>b.f : Symbol(f, Decl(b.ts, 1, 18))
>b : Symbol(b, Decl(a.ts, 0, 8))
>f : Symbol(f, Decl(b.ts, 1, 18))
}
};
=== tests/cases/compiler/b.ts ===
import { a } from './a';
>a : Symbol(a, Decl(b.ts, 0, 8))
export const b = {
>b : Symbol(b, Decl(b.ts, 1, 12))
f: () => {
>f : Symbol(f, Decl(b.ts, 1, 18))
class A { }
>A : Symbol(A, Decl(b.ts, 2, 14))
class B extends A { }
>B : Symbol(B, Decl(b.ts, 3, 19))
>A : Symbol(A, Decl(b.ts, 2, 14))
a.f();
>a.f : Symbol(f, Decl(a.ts, 1, 18))
>a : Symbol(a, Decl(b.ts, 0, 8))
>f : Symbol(f, Decl(a.ts, 1, 18))
}
};
@@ -0,0 +1,52 @@
=== tests/cases/compiler/a.ts ===
import { b } from './b';
>b : { f: () => void; }
export const a = {
>a : { f: () => void; }
>{ f: () => { class A { } class B extends A { } b.f(); }} : { f: () => void; }
f: () => {
>f : () => void
>() => { class A { } class B extends A { } b.f(); } : () => void
class A { }
>A : A
class B extends A { }
>B : B
>A : A
b.f();
>b.f() : void
>b.f : () => void
>b : { f: () => void; }
>f : () => void
}
};
=== tests/cases/compiler/b.ts ===
import { a } from './a';
>a : { f: () => void; }
export const b = {
>b : { f: () => void; }
>{ f: () => { class A { } class B extends A { } a.f(); }} : { f: () => void; }
f: () => {
>f : () => void
>() => { class A { } class B extends A { } a.f(); } : () => void
class A { }
>A : A
class B extends A { }
>B : B
>A : A
a.f();
>a.f() : void
>a.f : () => void
>a : { f: () => void; }
>f : () => void
}
};
@@ -2,7 +2,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(8,1): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(11,1): error TS2322: Type 'string' is not assignable to type 'E'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(14,1): error TS2322: Type 'string' is not assignable to type '{ a: string; }'.
Property 'a' is missing in type 'String'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(17,1): error TS2322: Type 'string' is not assignable to type 'void'.
@@ -29,7 +28,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
x4 += '';
~~
!!! error TS2322: Type 'string' is not assignable to type '{ a: string; }'.
!!! error TS2322: Property 'a' is missing in type 'String'.
var x5: void;
x5 += '';
@@ -1,5 +1,4 @@
tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type 'number' is not assignable to type 'X'.
Property 'foo' is missing in type 'Number'.
tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
@@ -9,7 +8,6 @@ tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Retur
return 1;
~
!!! error TS2322: Type 'number' is not assignable to type 'X'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
~
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
}
@@ -1,5 +1,4 @@
tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type 'number' is not assignable to type 'D'.
Property 'x' is missing in type 'Number'.
tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F<T>'.
Types of property 'x' are incompatible.
@@ -22,7 +21,6 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl
return 1; // error
~
!!! error TS2322: Type 'number' is not assignable to type 'D'.
!!! error TS2322: Property 'x' is missing in type 'Number'.
~
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
}
@@ -1,7 +1,6 @@
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
Type 'number' is not assignable to type '{ id: number; }'.
Property 'id' is missing in type 'Number'.
==== tests/cases/compiler/contextualTyping21.ts (1 errors) ====
@@ -9,5 +8,4 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: num
~~~
!!! error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'.
!!! error TS2322: Property 'id' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'.
@@ -1,6 +1,7 @@
tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }'.
Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/contextualTyping33.ts (1 errors) ====
@@ -8,4 +9,5 @@ tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
!!! error TS2345: Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
@@ -2,7 +2,6 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
Index signatures are incompatible.
Type 'Date | number' is not assignable to type 'Date'.
Type 'number' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfArrayLiterals1.ts (1 errors) ====
@@ -16,7 +15,6 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'Date | number' is not assignable to type 'Date'.
!!! error TS2322: Type 'number' is not assignable to type 'Date'.
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
var r2 = x3[1];
r2.getDate();
@@ -2,7 +2,6 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS
Type '(b: number) => void' is not assignable to type '(a: A) => void'.
Types of parameters 'b' and 'a' are incompatible.
Type 'number' is not assignable to type 'A'.
Property 'foo' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ====
@@ -22,5 +21,4 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS
!!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void'.
!!! error TS2322: Types of parameters 'b' and 'a' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'A'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
@@ -1,6 +1,5 @@
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(16,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
Type 'string' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'String'.
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
Type 'string' is not assignable to type 'Date'.
@@ -25,7 +24,6 @@ tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32):
~
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
!!! error TS2345: Type 'string' is not assignable to type 'Date'.
!!! error TS2345: Property 'toDateString' is missing in type 'String'.
var r6 = _.forEach<number>(c2, (x) => { return x.toFixed() });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
@@ -0,0 +1,15 @@
tests/cases/compiler/declarationEmit_UnknownImport.ts(2,1): error TS2304: Cannot find name 'SomeNonExistingName'.
tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS2503: Cannot find namespace 'SomeNonExistingName'.
tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'.
==== tests/cases/compiler/declarationEmit_UnknownImport.ts (3 errors) ====
import Foo = SomeNonExistingName
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'SomeNonExistingName'.
~~~~~~~~~~~~~~~~~~~
!!! error TS2503: Cannot find namespace 'SomeNonExistingName'.
~~~~~~~~~~~~~~~~~~~
!!! error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'.
export {Foo}
@@ -0,0 +1,7 @@
//// [declarationEmit_UnknownImport.ts]
import Foo = SomeNonExistingName
export {Foo}
//// [declarationEmit_UnknownImport.js]
"use strict";
@@ -0,0 +1,21 @@
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,1): error TS2304: Cannot find name 'From'.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS1005: '=' expected.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS2503: Cannot find namespace 'From'.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS4000: Import declaration 'Foo' is using private name 'From'.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,17): error TS1005: ';' expected.
==== tests/cases/compiler/declarationEmit_UnknownImport2.ts (5 errors) ====
import Foo From './Foo'; // Syntax error
~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'From'.
~~~~
!!! error TS1005: '=' expected.
~~~~
!!! error TS2503: Cannot find namespace 'From'.
~~~~
!!! error TS4000: Import declaration 'Foo' is using private name 'From'.
~~~~~~~
!!! error TS1005: ';' expected.
export default Foo
@@ -0,0 +1,8 @@
//// [declarationEmit_UnknownImport2.ts]
import Foo From './Foo'; // Syntax error
export default Foo
//// [declarationEmit_UnknownImport2.js]
"use strict";
'./Foo'; // Syntax error
@@ -5,7 +5,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss
Types of property '1' are incompatible.
Type 'number' is not assignable to type 'boolean'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'.
Property 'toFixed' is missing in type 'String'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'.
Property '0' is missing in type 'number[]'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'.
@@ -43,7 +42,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss
var [b3 = "string", b4, b5] = bar(); // Error
~~
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
!!! error TS2322: Property 'toFixed' is missing in type 'String'.
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.
Loaded 100 of 391 files, more files were not shown because too many files have changed in this diff. Show more