merge with origin/master

This commit is contained in:
Vladimir Matveev 2016-06-27 10:29:57 -07:00
commit 15f825b6b3
621 changed files with 23151 additions and 6860 deletions

21
.vscode/tasks.json vendored
View File

@ -7,7 +7,7 @@
// ${cwd}: the current working directory of the spawned process
{
"version": "0.1.0",
"command": "jake",
"command": "gulp",
"isShellCommand": true,
"showOutput": "silent",
"tasks": [
@ -18,25 +18,6 @@
"problemMatcher": [
"$tsc"
]
},
{
"taskName": "lint-server",
"args": [],
"problemMatcher": {
"owner": "typescript",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(warning|error)\\s+([^(]+)\\s+\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(.*)$",
"severity": 1,
"file": 2,
"location": 3,
"message": 4
},
"watchedTaskBeginsRegExp": "^\\*\\*\\*Lint failure\\*\\*\\*$",
"watchedTaskEndsRegExp": "^\\*\\*\\* Total \\d+ failures\\.$"
},
"showOutput": "always",
"isWatching": true
}
]
}

View File

@ -40,6 +40,10 @@ In general, things we find useful when reviewing suggestions are:
# Instructions for Contributing Code
## Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## 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.

1047
Gulpfile.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -307,7 +307,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
file(outFile, prereqs, function() {
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
var options = "--noImplicitAny --noEmitOnError --pretty";
var options = "--noImplicitAny --noEmitOnError --types --pretty";
opts = opts || {};
// Keep comments when specifically requested
// or when in debug mode.
@ -1018,7 +1018,8 @@ var tslintRules = [
"booleanTriviaRule",
"typeOperatorSpacingRule",
"noInOperatorRule",
"noIncrementDecrementRule"
"noIncrementDecrementRule",
"objectLiteralSurroundingSpaceRule",
];
var tslintRulesFiles = tslintRules.map(function(p) {
return path.join(tslintRuleDir, p + ".ts");
@ -1069,7 +1070,8 @@ var lintTargets = compilerSources
.concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f) }))
.concat(serverCoreSources)
.concat(tslintRulesFiles)
.concat(servicesSources);
.concat(servicesSources)
.concat(["Gulpfile.ts"]);
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");

View File

@ -56,29 +56,29 @@ Change to the TypeScript directory:
cd TypeScript
```
Install Jake tools and dev dependencies:
Install Gulp tools and dev dependencies:
```
npm install -g jake
npm install -g gulp
npm install
```
Use one of the following to build and test:
```
jake local # Build the compiler into built/local
jake clean # Delete the built compiler
jake LKG # Replace the last known good with the built one.
gulp local # Build the compiler into built/local
gulp clean # Delete the built compiler
gulp LKG # Replace the last known good with the built one.
# Bootstrapping step to be executed when the built compiler reaches a stable state.
jake tests # Build the test infrastructure using the built compiler.
jake runtests # Run tests using the built compiler and test infrastructure.
gulp tests # Build the test infrastructure using the built compiler.
gulp runtests # Run tests using the built compiler and test infrastructure.
# You can override the host or specify a test for this command.
# Use host=<hostName> or tests=<testPath>.
jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional
gulp runtests-browser # Runs the tests using the built run.js file. Syntax is gulp runtests. Optional
parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests.
jake lint # Runs tslint on the TypeScript source.
jake -T # List the above commands.
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
gulp lint # Runs tslint on the TypeScript source.
gulp help # List the above commands.
```

852
lib/lib.d.ts vendored

File diff suppressed because it is too large Load Diff

802
lib/lib.dom.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -19,59 +19,149 @@ and limitations under the License.
*/
interface Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): Promise<TResult>;
/**
* Creates a new Promise with the same internal state of this Promise.
* @returns A Promise.
*/
then(): Promise<T>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
catch(onrejected?: (reason: any) => void): Promise<T>;
catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected: (reason: any) => T | PromiseLike<T>): Promise<T>;
}
interface PromiseConstructor {
/**
* A reference to the prototype.
/**
* A reference to the prototype.
*/
readonly prototype: Promise<any>;
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
reject(reason: any): Promise<never>;
/**
* Creates a new rejected promise for the provided reason.

52
lib/lib.es5.d.ts vendored
View File

@ -1271,13 +1271,33 @@ declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | P
interface PromiseLike<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
/**
* Creates a new Promise with the same internal state of this Promise.
* @returns A Promise.
*/
then(): PromiseLike<T>;
}
interface ArrayLike<T> {
@ -1540,7 +1560,7 @@ interface Int8Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -1813,7 +1833,7 @@ interface Uint8Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2087,7 +2107,7 @@ interface Uint8ClampedArray {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2360,7 +2380,7 @@ interface Int16Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2634,7 +2654,7 @@ interface Uint16Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2907,7 +2927,7 @@ interface Int32Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -3180,7 +3200,7 @@ interface Uint32Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -3453,7 +3473,7 @@ interface Float32Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -3727,7 +3747,7 @@ interface Float64Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.

972
lib/lib.es6.d.ts vendored

File diff suppressed because it is too large Load Diff

223
lib/lib.webworker.d.ts vendored
View File

@ -19,6 +19,10 @@ and limitations under the License.
/// IE Worker APIs
/////////////////////////////
interface Algorithm {
name: string;
}
interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
@ -34,6 +38,10 @@ interface IDBObjectStoreParameters {
keyPath?: IDBKeyPath;
}
interface KeyAlgorithm {
name?: string;
}
interface EventListener {
(evt: Event): void;
}
@ -123,6 +131,18 @@ declare var Coordinates: {
new(): Coordinates;
}
interface CryptoKey {
readonly algorithm: KeyAlgorithm;
readonly extractable: boolean;
readonly type: string;
readonly usages: string[];
}
declare var CryptoKey: {
prototype: CryptoKey;
new(): CryptoKey;
}
interface DOMError {
readonly name: string;
toString(): string;
@ -339,7 +359,7 @@ interface IDBDatabase extends EventTarget {
readonly name: string;
readonly objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
version: number;
onversionchange: (ev: IDBVersionChangeEvent) => any;
close(): void;
@ -442,7 +462,7 @@ declare var IDBOpenDBRequest: {
interface IDBRequest extends EventTarget {
readonly error: DOMError;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onsuccess: (ev: Event) => any;
readonly readyState: string;
readonly result: any;
@ -464,7 +484,7 @@ interface IDBTransaction extends EventTarget {
readonly mode: string;
onabort: (ev: Event) => any;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
abort(): void;
objectStore(name: string): IDBObjectStore;
readonly READ_ONLY: string;
@ -532,7 +552,7 @@ declare var MSApp: MSApp;
interface MSAppAsyncOperation extends EventTarget {
readonly error: DOMError;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
readonly readyState: number;
readonly result: any;
start(): void;
@ -681,7 +701,7 @@ interface WebSocket extends EventTarget {
readonly bufferedAmount: number;
readonly extensions: string;
onclose: (ev: CloseEvent) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onmessage: (ev: MessageEvent) => any;
onopen: (ev: Event) => any;
readonly protocol: string;
@ -724,7 +744,6 @@ declare var Worker: {
}
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
msCaching: string;
onreadystatechange: (ev: ProgressEvent) => any;
readonly readyState: number;
readonly response: any;
@ -736,6 +755,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
timeout: number;
readonly upload: XMLHttpRequestUpload;
withCredentials: boolean;
msCaching?: string;
abort(): void;
getAllResponseHeaders(): string;
getResponseHeader(header: string): string | null;
@ -782,14 +802,14 @@ declare var XMLHttpRequestUpload: {
}
interface AbstractWorker {
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface MSBaseReader {
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
onloadend: (ev: ProgressEvent) => any;
onloadstart: (ev: Event) => any;
@ -835,7 +855,7 @@ interface WindowConsole {
interface XMLHttpRequestEventTarget {
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
onloadend: (ev: ProgressEvent) => any;
onloadstart: (ev: Event) => any;
@ -865,7 +885,7 @@ declare var FileReaderSync: {
interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole {
readonly location: WorkerLocation;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
readonly self: WorkerGlobalScope;
close(): void;
msWriteProfilerMark(profilerMarkName: string): void;
@ -921,8 +941,11 @@ interface WorkerUtils extends Object, WindowBase64 {
clearInterval(handle: number): void;
clearTimeout(handle: number): void;
importScripts(...urls: string[]): void;
setImmediate(handler: (...args: any[]) => void): number;
setImmediate(handler: any, ...args: any[]): number;
setInterval(handler: (...args: any[]) => void, timeout: number): number;
setInterval(handler: any, timeout?: any, ...args: any[]): number;
setTimeout(handler: (...args: any[]) => void, timeout: number): number;
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}
@ -958,6 +981,177 @@ interface ProgressEventInit extends EventInit {
interface IDBArrayKey extends Array<IDBValidKey> {
}
interface RsaKeyGenParams extends Algorithm {
modulusLength: number;
publicExponent: Uint8Array;
}
interface RsaHashedKeyGenParams extends RsaKeyGenParams {
hash: AlgorithmIdentifier;
}
interface RsaKeyAlgorithm extends KeyAlgorithm {
modulusLength: number;
publicExponent: Uint8Array;
}
interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm {
hash: AlgorithmIdentifier;
}
interface RsaHashedImportParams {
hash: AlgorithmIdentifier;
}
interface RsaPssParams {
saltLength: number;
}
interface RsaOaepParams extends Algorithm {
label?: BufferSource;
}
interface EcdsaParams extends Algorithm {
hash: AlgorithmIdentifier;
}
interface EcKeyGenParams extends Algorithm {
typedCurve: string;
}
interface EcKeyAlgorithm extends KeyAlgorithm {
typedCurve: string;
}
interface EcKeyImportParams {
namedCurve: string;
}
interface EcdhKeyDeriveParams extends Algorithm {
public: CryptoKey;
}
interface AesCtrParams extends Algorithm {
counter: BufferSource;
length: number;
}
interface AesKeyAlgorithm extends KeyAlgorithm {
length: number;
}
interface AesKeyGenParams extends Algorithm {
length: number;
}
interface AesDerivedKeyParams extends Algorithm {
length: number;
}
interface AesCbcParams extends Algorithm {
iv: BufferSource;
}
interface AesCmacParams extends Algorithm {
length: number;
}
interface AesGcmParams extends Algorithm {
iv: BufferSource;
additionalData?: BufferSource;
tagLength?: number;
}
interface AesCfbParams extends Algorithm {
iv: BufferSource;
}
interface HmacImportParams extends Algorithm {
hash?: AlgorithmIdentifier;
length?: number;
}
interface HmacKeyAlgorithm extends KeyAlgorithm {
hash: AlgorithmIdentifier;
length: number;
}
interface HmacKeyGenParams extends Algorithm {
hash: AlgorithmIdentifier;
length?: number;
}
interface DhKeyGenParams extends Algorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface DhKeyAlgorithm extends KeyAlgorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface DhKeyDeriveParams extends Algorithm {
public: CryptoKey;
}
interface DhImportKeyParams extends Algorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface ConcatParams extends Algorithm {
hash?: AlgorithmIdentifier;
algorithmId: Uint8Array;
partyUInfo: Uint8Array;
partyVInfo: Uint8Array;
publicInfo?: Uint8Array;
privateInfo?: Uint8Array;
}
interface HkdfCtrParams extends Algorithm {
hash: AlgorithmIdentifier;
label: BufferSource;
context: BufferSource;
}
interface Pbkdf2Params extends Algorithm {
salt: BufferSource;
iterations: number;
hash: AlgorithmIdentifier;
}
interface RsaOtherPrimesInfo {
r: string;
d: string;
t: string;
}
interface JsonWebKey {
kty: string;
use?: string;
key_ops?: string[];
alg?: string;
kid?: string;
x5u?: string;
x5c?: string;
x5t?: string;
ext?: boolean;
crv?: string;
x?: string;
y?: string;
d?: string;
n?: string;
e?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
oth?: RsaOtherPrimesInfo[];
k?: string;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@ -991,7 +1185,7 @@ interface FunctionStringCallback {
(data: string): void;
}
declare var location: WorkerLocation;
declare var onerror: (ev: Event) => any;
declare var onerror: (ev: ErrorEvent) => any;
declare var self: WorkerGlobalScope;
declare function close(): void;
declare function msWriteProfilerMark(profilerMarkName: string): void;
@ -1006,8 +1200,11 @@ declare function clearImmediate(handle: number): void;
declare function clearInterval(handle: number): void;
declare function clearTimeout(handle: number): void;
declare function importScripts(...urls: string[]): void;
declare function setImmediate(handler: (...args: any[]) => void): number;
declare function setImmediate(handler: any, ...args: any[]): number;
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;
declare function setInterval(handler: any, timeout?: any, ...args: any[]): number;
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number;
declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number;
declare function atob(encodedString: string): string;
declare function btoa(rawString: string): string;
@ -1017,5 +1214,7 @@ declare var console: Console;
declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
type AlgorithmIdentifier = string | Algorithm;
type IDBKeyPath = string;
type IDBValidKey = number | string | Date | IDBArrayKey;
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;

1392
lib/tsc.js

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -704,7 +704,6 @@ declare namespace ts {
}
interface PropertyAccessExpression extends MemberExpression, Declaration {
expression: LeftHandSideExpression;
dotToken: Node;
name: Identifier;
}
type IdentifierOrPropertyAccess = Identifier | PropertyAccessExpression;
@ -835,6 +834,7 @@ declare namespace ts {
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
possiblyExhaustive?: boolean;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
@ -910,7 +910,7 @@ declare namespace ts {
type ModuleBody = ModuleBlock | ModuleDeclaration;
interface ModuleDeclaration extends DeclarationStatement {
name: Identifier | LiteralExpression;
body: ModuleBlock | ModuleDeclaration;
body?: ModuleBlock | ModuleDeclaration;
}
interface ModuleBlock extends Node, Statement {
statements: NodeArray<Statement>;
@ -1066,8 +1066,9 @@ declare namespace ts {
Assignment = 16,
TrueCondition = 32,
FalseCondition = 64,
Referenced = 128,
Shared = 256,
SwitchClause = 128,
Referenced = 256,
Shared = 512,
Label = 12,
Condition = 96,
}
@ -1089,6 +1090,12 @@ declare namespace ts {
expression: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNode {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface AmdDependency {
path: string;
name: string;
@ -1132,7 +1139,9 @@ declare namespace ts {
getCurrentDirectory(): string;
}
interface ParseConfigHost {
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
useCaseSensitiveFileNames: boolean;
readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[];
fileExists(path: string): boolean;
}
interface WriteFileCallback {
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void;
@ -1504,6 +1513,7 @@ declare namespace ts {
resolvedJsxType?: Type;
hasSuperCall?: boolean;
superCall?: ExpressionStatement;
switchTypes?: Type[];
}
const enum TypeFlags {
Any = 1,
@ -1535,7 +1545,7 @@ declare namespace ts {
ObjectLiteralPatternWithComputedProperties = 67108864,
Never = 134217728,
Nullable = 96,
Falsy = 126,
Falsy = 112,
Intrinsic = 150995071,
Primitive = 16777726,
StringLike = 258,
@ -1772,8 +1782,9 @@ declare namespace ts {
suppressOutputPathCheck?: boolean;
target?: ScriptTarget;
traceResolution?: boolean;
disableSizeLimit?: boolean;
types?: string[];
typesRoot?: string;
typeRoots?: string[];
typesSearchPaths?: string[];
version?: boolean;
watch?: boolean;
@ -1843,6 +1854,15 @@ declare namespace ts {
fileNames: string[];
raw?: any;
errors: Diagnostic[];
wildcardDirectories?: Map<WatchDirectoryFlags>;
}
const enum WatchDirectoryFlags {
None = 0,
Recursive = 1,
}
interface ExpandResult {
fileNames: string[];
wildcardDirectories: Map<WatchDirectoryFlags>;
}
interface CommandLineOptionBase {
name: string;
@ -2027,6 +2047,7 @@ declare namespace ts {
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
@ -2068,8 +2089,10 @@ declare namespace ts {
function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U;
function contains<T>(array: T[], value: T, areEqual?: (a: T, b: T) => boolean): boolean;
function indexOf<T>(array: T[], value: T): number;
function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number;
function countWhere<T>(array: T[], predicate: (x: T) => boolean): number;
function filter<T>(array: T[], f: (x: T) => boolean): T[];
function filterMutate<T>(array: T[], f: (x: T) => boolean): void;
function map<T, U>(array: T[], f: (x: T) => U): U[];
function concatenate<T>(array1: T[], array2: T[]): T[];
function deduplicate<T>(array: T[], areEqual?: (a: T, b: T) => boolean): T[];
@ -2104,6 +2127,8 @@ declare namespace ts {
function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain;
function compareValues<T>(a: T, b: T): Comparison;
function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison;
function compareStringsCaseInsensitive(a: string, b: string): Comparison;
function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison;
function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
@ -2121,16 +2146,45 @@ declare namespace ts {
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string;
function getBaseFileName(path: string): string;
function combinePaths(path1: string, path2: string): string;
function removeTrailingDirectorySeparator(path: string): string;
function ensureTrailingDirectorySeparator(path: string): string;
function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison;
function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean;
function fileExtensionIs(path: string, extension: string): boolean;
function fileExtensionIsAny(path: string, extensions: string[]): boolean;
function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string;
interface FileSystemEntries {
files: string[];
directories: string[];
}
interface FileMatcherPatterns {
includeFilePattern: string;
includeDirectoryPattern: string;
excludePattern: string;
basePaths: string[];
}
function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns;
function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[];
function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind;
function getScriptKindFromFileName(fileName: string): ScriptKind;
const supportedTypeScriptExtensions: string[];
const supportedJavascriptExtensions: string[];
function getSupportedExtensions(options?: CompilerOptions): string[];
function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions): boolean;
const enum ExtensionPriority {
TypeScriptFiles = 0,
DeclarationAndJavaScriptFiles = 2,
Limit = 5,
Highest = 0,
Lowest = 2,
}
function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority;
function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority;
function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority;
function removeFileExtension(path: string): string;
function tryRemoveExtension(path: string, extension: string): string;
function isJsxOrTsxExtension(ext: string): boolean;
function changeExtension<T extends string | Path>(path: T, newExtension: string): T;
interface ObjectAllocator {
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
@ -2167,6 +2221,7 @@ declare namespace ts {
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@ -2177,7 +2232,7 @@ declare namespace ts {
getExecutingFilePath(): string;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
getModifiedTime?(path: string): Date;
createHash?(data: string): string;
getMemoryUsage?(): number;
@ -3053,7 +3108,7 @@ declare namespace ts {
key: string;
message: string;
};
A_parameter_property_may_not_be_a_binding_pattern: {
A_parameter_property_may_not_be_declared_using_a_binding_pattern: {
code: number;
category: DiagnosticCategory;
key: string;
@ -3149,12 +3204,6 @@ declare namespace ts {
key: string;
message: string;
};
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Decorators_are_not_valid_here: {
code: number;
category: DiagnosticCategory;
@ -3479,6 +3528,12 @@ declare namespace ts {
key: string;
message: string;
};
A_parameter_property_cannot_be_declared_using_a_rest_parameter: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Duplicate_identifier_0: {
code: number;
category: DiagnosticCategory;
@ -5099,6 +5154,18 @@ declare namespace ts {
key: string;
message: string;
};
Cannot_find_type_definition_file_for_0: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Cannot_extend_an_interface_0_Did_you_mean_implements: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Import_declaration_0_is_using_private_name_1: {
code: number;
category: DiagnosticCategory;
@ -5537,6 +5604,18 @@ declare namespace ts {
key: string;
message: string;
};
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
Cannot_read_file_0_Colon_1: {
code: number;
category: DiagnosticCategory;
@ -6575,12 +6654,6 @@ declare namespace ts {
key: string;
message: string;
};
property_declarations_can_only_be_used_in_a_ts_file: {
code: number;
category: DiagnosticCategory;
key: string;
message: string;
};
enum_declarations_can_only_be_used_in_a_ts_file: {
code: number;
category: DiagnosticCategory;
@ -6742,7 +6815,7 @@ declare namespace ts {
function getOptionNameMap(): OptionNameMap;
function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic;
function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]): number | string;
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[];
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] | undefined;
function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
function readConfigFile(fileName: string, readFile: (path: string) => string): {
config?: any;
@ -6818,6 +6891,7 @@ declare namespace ts {
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function isAmbientModule(node: Node): boolean;
function isShorthandAmbientModule(node: Node): boolean;
function isBlockScopedContainerTopLevel(node: Node): boolean;
function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean;
function isExternalModuleAugmentation(node: Node): boolean;
@ -6880,6 +6954,7 @@ declare namespace ts {
function isInJavaScriptFile(node: Node): boolean;
function isRequireCall(expression: Node, checkArgumentIsStringLiteral: boolean): expression is CallExpression;
function isSingleOrDoubleQuote(charCode: number): boolean;
function isDeclarationOfFunctionExpression(s: Symbol): boolean;
function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind;
function getExternalModuleName(node: Node): Expression;
function hasQuestionToken(node: Node): boolean;
@ -6994,6 +7069,7 @@ declare namespace ts {
function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean;
function getLocalSymbolForExportDefault(symbol: Symbol): Symbol;
function hasJavaScriptFileExtension(fileName: string): boolean;
function hasTypeScriptFileExtension(fileName: string): boolean;
const stringify: (value: any) => string;
function convertToBase64(input: string): string;
function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string;
@ -7105,7 +7181,7 @@ declare namespace ts {
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
declare namespace ts.BreakpointResolver {
@ -7118,8 +7194,7 @@ declare namespace ts.NavigateTo {
function getNavigateToItems(program: Program, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[];
}
declare namespace ts.NavigationBar {
function getNavigationBarItems(sourceFile: SourceFile, compilerOptions: CompilerOptions): ts.NavigationBarItem[];
function getJsNavigationBarItems(sourceFile: SourceFile, compilerOptions: CompilerOptions): NavigationBarItem[];
function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[];
}
declare namespace ts {
enum PatternMatchKind {
@ -7229,7 +7304,7 @@ declare namespace ts.JsTyping {
directoryExists: (path: string) => boolean;
fileExists: (fileName: string) => boolean;
readFile: (path: string, encoding?: string) => string;
readDirectory: (path: string, extension?: string, exclude?: string[], depth?: number) => string[];
readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[];
}
function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map<string>, typingOptions: TypingOptions, compilerOptions: CompilerOptions): {
cachedTypingPaths: string[];
@ -7716,6 +7791,7 @@ declare namespace ts {
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
getDirectories?(directoryName: string): string[];
}
interface LanguageService {
cleanupSemanticCache(): void;
@ -7799,6 +7875,7 @@ declare namespace ts {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
interface DocumentHighlights {
fileName: string;
@ -8216,7 +8293,7 @@ declare namespace ts.server {
private reload(fileName, tempFileName, reqSeq?);
private saveToTmp(fileName, tempFileName);
private closeClientFile(fileName);
private decorateNavigationBarItem(project, fileName, items);
private decorateNavigationBarItem(project, fileName, items, lineIndex);
private getNavigationBarItems(fileName);
private getNavigateToItems(searchValue, fileName, maxResultCount?);
private getBraceMatching(line, offset, fileName);
@ -8246,6 +8323,7 @@ declare namespace ts.server {
endGroup(): void;
msg(s: string, type?: string): void;
}
const maxProgramSizeForNonTsFiles: number;
class ScriptInfo {
private host;
fileName: string;
@ -8304,27 +8382,34 @@ declare namespace ts.server {
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
getDirectories(path: string): string[];
lineToTextSpan(filename: string, line: number): ts.TextSpan;
lineOffsetToPosition(filename: string, line: number, offset: number): number;
positionToLineOffset(filename: string, position: number): ILineInfo;
positionToLineOffset(filename: string, position: number, lineIndex?: LineIndex): ILineInfo;
getLineIndex(filename: string): LineIndex;
}
interface ProjectOptions {
files?: string[];
wildcardDirectories?: ts.Map<ts.WatchDirectoryFlags>;
compilerOptions?: ts.CompilerOptions;
}
class Project {
projectService: ProjectService;
projectOptions?: ProjectOptions;
languageServiceDiabled: boolean;
compilerService: CompilerService;
projectFilename: string;
projectFileWatcher: FileWatcher;
directoryWatcher: FileWatcher;
directoriesWatchedForWildcards: Map<FileWatcher>;
directoriesWatchedForTsconfig: string[];
program: ts.Program;
filenameToSourceFile: ts.Map<ts.SourceFile>;
updateGraphSeq: number;
openRefCount: number;
constructor(projectService: ProjectService, projectOptions?: ProjectOptions);
constructor(projectService: ProjectService, projectOptions?: ProjectOptions, languageServiceDiabled?: boolean);
enableLanguageService(): void;
disableLanguageService(): void;
addOpenRef(): void;
deleteOpenRef(): number;
openReferencedFile(filename: string): ScriptInfo;
@ -8415,13 +8500,14 @@ declare namespace ts.server {
projectOptions?: ProjectOptions;
errors?: Diagnostic[];
};
private exceedTotalNonTsFileSizeLimit(fileNames);
openConfigFile(configFilename: string, clientFileName?: string): {
success: boolean;
project?: Project;
errors?: Diagnostic[];
};
updateConfiguredProject(project: Project): Diagnostic[];
createProject(projectFilename: string, projectOptions?: ProjectOptions): Project;
createProject(projectFilename: string, projectOptions?: ProjectOptions, languageServiceDisabled?: boolean): Project;
}
class CompilerService {
project: Project;
@ -8592,7 +8678,9 @@ declare namespace ts {
directoryExists(directoryName: string): boolean;
}
interface CoreServicesShimHost extends Logger, ModuleResolutionHost {
readDirectory(rootDir: string, extension: string, exclude?: string, depth?: number): string;
readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string;
useCaseSensitiveFileNames?(): boolean;
getCurrentDirectory(): string;
trace(s: string): void;
}
interface IFileReference {
@ -8685,10 +8773,12 @@ declare namespace ts {
private shimHost;
directoryExists: (directoryName: string) => boolean;
realpath: (path: string) => string;
useCaseSensitiveFileNames: boolean;
constructor(shimHost: CoreServicesShimHost);
readDirectory(rootDir: string, extension: string, exclude: string[], depth?: number): string[];
readDirectory(rootDir: string, extensions: string[], exclude: string[], include: string[], depth?: number): string[];
fileExists(fileName: string): boolean;
readFile(fileName: string): string;
private readDirectoryFallback(rootDir, extension, exclude);
}
function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): {
message: string;

File diff suppressed because it is too large Load Diff

53
lib/typescript.d.ts vendored
View File

@ -713,7 +713,6 @@ declare namespace ts {
}
interface PropertyAccessExpression extends MemberExpression, Declaration {
expression: LeftHandSideExpression;
dotToken: Node;
name: Identifier;
}
type IdentifierOrPropertyAccess = Identifier | PropertyAccessExpression;
@ -844,6 +843,7 @@ declare namespace ts {
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
possiblyExhaustive?: boolean;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
@ -919,7 +919,7 @@ declare namespace ts {
type ModuleBody = ModuleBlock | ModuleDeclaration;
interface ModuleDeclaration extends DeclarationStatement {
name: Identifier | LiteralExpression;
body: ModuleBlock | ModuleDeclaration;
body?: ModuleBlock | ModuleDeclaration;
}
interface ModuleBlock extends Node, Statement {
statements: NodeArray<Statement>;
@ -1075,8 +1075,9 @@ declare namespace ts {
Assignment = 16,
TrueCondition = 32,
FalseCondition = 64,
Referenced = 128,
Shared = 256,
SwitchClause = 128,
Referenced = 256,
Shared = 512,
Label = 12,
Condition = 96,
}
@ -1098,6 +1099,12 @@ declare namespace ts {
expression: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNode {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface AmdDependency {
path: string;
name: string;
@ -1132,7 +1139,13 @@ declare namespace ts {
getCurrentDirectory(): string;
}
interface ParseConfigHost {
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
useCaseSensitiveFileNames: boolean;
readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[];
/**
* Gets a value indicating whether the specified path exists and is a file.
* @param path The path to test.
*/
fileExists(path: string): boolean;
}
interface WriteFileCallback {
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void;
@ -1412,7 +1425,6 @@ declare namespace ts {
ThisType = 33554432,
ObjectLiteralPatternWithComputedProperties = 67108864,
Never = 134217728,
Falsy = 126,
StringLike = 258,
NumberLike = 132,
ObjectType = 80896,
@ -1574,7 +1586,10 @@ declare namespace ts {
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
traceResolution?: boolean;
disableSizeLimit?: boolean;
types?: string[];
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];
typesSearchPaths?: string[];
[option: string]: CompilerOptionsValue | undefined;
}
@ -1638,6 +1653,15 @@ declare namespace ts {
fileNames: string[];
raw?: any;
errors: Diagnostic[];
wildcardDirectories?: Map<WatchDirectoryFlags>;
}
enum WatchDirectoryFlags {
None = 0,
Recursive = 1,
}
interface ExpandResult {
fileNames: string[];
wildcardDirectories: Map<WatchDirectoryFlags>;
}
interface ModuleResolutionHost {
fileExists(fileName: string): boolean;
@ -1672,6 +1696,7 @@ declare namespace ts {
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
@ -1707,6 +1732,7 @@ declare namespace ts {
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@ -1717,7 +1743,7 @@ declare namespace ts {
getExecutingFilePath(): string;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
getModifiedTime?(path: string): Date;
createHash?(data: string): string;
getMemoryUsage?(): number;
@ -1821,6 +1847,7 @@ declare namespace ts {
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
}
declare namespace ts {
/** The version of the TypeScript compiler release */
const version: string;
function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
@ -1836,7 +1863,15 @@ declare namespace ts {
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
/**
* Given a set of options and a set of root files, returns the set of type directive names
* that should be included for this program automatically.
* This list could either come from the config file,
* or from enumerating the types root + initial secondary types lookup location.
* More type directives might appear in the program later as a result of loading actual source files;
* this list is only the set of defaults that are implicitly included.
*/
function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
declare namespace ts {
@ -1978,6 +2013,7 @@ declare namespace ts {
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
getDirectories?(directoryName: string): string[];
}
interface LanguageService {
cleanupSemanticCache(): void;
@ -2068,6 +2104,7 @@ declare namespace ts {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
interface DocumentHighlights {
fileName: string;

File diff suppressed because it is too large Load Diff

View File

@ -713,7 +713,6 @@ declare namespace ts {
}
interface PropertyAccessExpression extends MemberExpression, Declaration {
expression: LeftHandSideExpression;
dotToken: Node;
name: Identifier;
}
type IdentifierOrPropertyAccess = Identifier | PropertyAccessExpression;
@ -844,6 +843,7 @@ declare namespace ts {
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
possiblyExhaustive?: boolean;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
@ -919,7 +919,7 @@ declare namespace ts {
type ModuleBody = ModuleBlock | ModuleDeclaration;
interface ModuleDeclaration extends DeclarationStatement {
name: Identifier | LiteralExpression;
body: ModuleBlock | ModuleDeclaration;
body?: ModuleBlock | ModuleDeclaration;
}
interface ModuleBlock extends Node, Statement {
statements: NodeArray<Statement>;
@ -1075,8 +1075,9 @@ declare namespace ts {
Assignment = 16,
TrueCondition = 32,
FalseCondition = 64,
Referenced = 128,
Shared = 256,
SwitchClause = 128,
Referenced = 256,
Shared = 512,
Label = 12,
Condition = 96,
}
@ -1098,6 +1099,12 @@ declare namespace ts {
expression: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNode {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface AmdDependency {
path: string;
name: string;
@ -1132,7 +1139,13 @@ declare namespace ts {
getCurrentDirectory(): string;
}
interface ParseConfigHost {
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
useCaseSensitiveFileNames: boolean;
readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[];
/**
* Gets a value indicating whether the specified path exists and is a file.
* @param path The path to test.
*/
fileExists(path: string): boolean;
}
interface WriteFileCallback {
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void;
@ -1412,7 +1425,6 @@ declare namespace ts {
ThisType = 33554432,
ObjectLiteralPatternWithComputedProperties = 67108864,
Never = 134217728,
Falsy = 126,
StringLike = 258,
NumberLike = 132,
ObjectType = 80896,
@ -1574,7 +1586,10 @@ declare namespace ts {
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
traceResolution?: boolean;
disableSizeLimit?: boolean;
types?: string[];
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];
typesSearchPaths?: string[];
[option: string]: CompilerOptionsValue | undefined;
}
@ -1638,6 +1653,15 @@ declare namespace ts {
fileNames: string[];
raw?: any;
errors: Diagnostic[];
wildcardDirectories?: Map<WatchDirectoryFlags>;
}
enum WatchDirectoryFlags {
None = 0,
Recursive = 1,
}
interface ExpandResult {
fileNames: string[];
wildcardDirectories: Map<WatchDirectoryFlags>;
}
interface ModuleResolutionHost {
fileExists(fileName: string): boolean;
@ -1672,6 +1696,7 @@ declare namespace ts {
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
@ -1707,6 +1732,7 @@ declare namespace ts {
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@ -1717,7 +1743,7 @@ declare namespace ts {
getExecutingFilePath(): string;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
getModifiedTime?(path: string): Date;
createHash?(data: string): string;
getMemoryUsage?(): number;
@ -1821,6 +1847,7 @@ declare namespace ts {
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
}
declare namespace ts {
/** The version of the TypeScript compiler release */
const version: string;
function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
@ -1836,7 +1863,15 @@ declare namespace ts {
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
/**
* Given a set of options and a set of root files, returns the set of type directive names
* that should be included for this program automatically.
* This list could either come from the config file,
* or from enumerating the types root + initial secondary types lookup location.
* More type directives might appear in the program later as a result of loading actual source files;
* this list is only the set of defaults that are implicitly included.
*/
function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
declare namespace ts {
@ -1978,6 +2013,7 @@ declare namespace ts {
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
getDirectories?(directoryName: string): string[];
}
interface LanguageService {
cleanupSemanticCache(): void;
@ -2068,6 +2104,7 @@ declare namespace ts {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
interface DocumentHighlights {
fileName: string;

File diff suppressed because it is too large Load Diff

View File

@ -29,15 +29,48 @@
"node": ">=0.8.0"
},
"devDependencies": {
"jake": "latest",
"mocha": "latest",
"chai": "latest",
"@types/browserify": "latest",
"@types/del": "latest",
"@types/glob": "latest",
"@types/gulp": "latest",
"@types/gulp-concat": "latest",
"@types/gulp-help": "latest",
"@types/gulp-newer": "latest",
"@types/gulp-sourcemaps": "latest",
"@types/gulp-typescript": "latest",
"@types/merge2": "latest",
"@types/minimatch": "latest",
"@types/minimist": "latest",
"@types/mkdirp": "latest",
"@types/node": "latest",
"@types/q": "latest",
"@types/run-sequence": "latest",
"@types/through2": "latest",
"browserify": "latest",
"chai": "latest",
"del": "latest",
"gulp": "latest",
"gulp-clone": "latest",
"gulp-concat": "latest",
"gulp-help": "latest",
"gulp-insert": "latest",
"gulp-newer": "latest",
"gulp-sourcemaps": "latest",
"gulp-typescript": "latest",
"into-stream": "latest",
"istanbul": "latest",
"jake": "latest",
"merge2": "latest",
"minimist": "latest",
"mkdirp": "latest",
"mocha": "latest",
"mocha-fivemat-progress-reporter": "latest",
"run-sequence": "latest",
"through2": "latest",
"ts-node": "latest",
"tsd": "latest",
"tslint": "next",
"typescript": "next",
"tsd": "latest"
"typescript": "next"
},
"scripts": {
"pretest": "jake tests",
@ -47,6 +80,7 @@
"build:tests": "jake tests",
"start": "node lib/tsc",
"clean": "jake clean",
"gulp": "gulp",
"jake": "jake",
"lint": "jake lint",
"setup-hooks": "node scripts/link-hooks.js"

View File

@ -245,6 +245,13 @@ function runTests(taskConfigsFolder, run, options, cb) {
}
}
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
if (process.env.path !== undefined) {
process.env.path = nodeModulesPathPrefix + process.env.path;
} else if (process.env.PATH !== undefined) {
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
}
function spawnProcess(cmd, options) {
var shell = process.platform === "win32" ? "cmd" : "/bin/sh";
var prefix = process.platform === "win32" ? "/c" : "-c";

View File

@ -0,0 +1,42 @@
import * as Lint from "tslint/lib/lint";
import * as ts from "typescript";
export class Rule extends Lint.Rules.AbstractRule {
public static LEADING_FAILURE_STRING = "No leading whitespace found on single-line object literal.";
public static TRAILING_FAILURE_STRING = "No trailing whitespace found on single-line object literal.";
public static LEADING_EXCESS_FAILURE_STRING = "Excess leading whitespace found on single-line object literal.";
public static TRAILING_EXCESS_FAILURE_STRING = "Excess trailing whitespace found on single-line object literal.";
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new ObjectLiteralSpaceWalker(sourceFile, this.getOptions()));
}
}
class ObjectLiteralSpaceWalker extends Lint.RuleWalker {
public visitNode(node: ts.Node) {
if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) {
const literal = node as ts.ObjectLiteralExpression;
const text = literal.getText();
if (text.match(/^{[^\n]+}$/g)) {
if (text.charAt(1) !== " ") {
const failure = this.createFailure(node.pos, node.getWidth(), Rule.LEADING_FAILURE_STRING);
this.addFailure(failure);
}
if (text.charAt(2) === " ") {
const failure = this.createFailure(node.pos + 2, 1, Rule.LEADING_EXCESS_FAILURE_STRING);
this.addFailure(failure);
}
if (text.charAt(text.length - 2) !== " ") {
const failure = this.createFailure(node.pos, node.getWidth(), Rule.TRAILING_FAILURE_STRING);
this.addFailure(failure);
}
if (text.charAt(text.length - 3) === " ") {
const failure = this.createFailure(node.pos + node.getWidth() - 3, 1, Rule.TRAILING_EXCESS_FAILURE_STRING);
this.addFailure(failure);
}
}
}
super.visitNode(node);
}
}

22
scripts/types/ambient.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
declare module "gulp-clone" {
function Clone(): NodeJS.ReadWriteStream;
namespace Clone {
export function sink() : NodeJS.ReadWriteStream & {tap: () => NodeJS.ReadWriteStream};
}
export = Clone;
}
declare module "gulp-insert" {
export function append(text: string | Buffer): NodeJS.ReadWriteStream;
export function prepend(text: string | Buffer): NodeJS.ReadWriteStream;
export function wrap(text: string | Buffer, tail: string | Buffer): NodeJS.ReadWriteStream;
export function transform(cb: (contents: string, file: {path: string}) => string): NodeJS.ReadWriteStream; // file is a vinyl file
}
declare module "into-stream" {
function IntoStream(content: string | Buffer | (string | Buffer)[]): NodeJS.ReadableStream;
namespace IntoStream {
export function obj(content: any): NodeJS.ReadableStream
}
export = IntoStream;
}

View File

@ -1125,7 +1125,7 @@ namespace ts {
return getExternalModuleMember(<ImportDeclaration>node.parent.parent.parent, node);
}
function getTargetOfGlobalModuleExportDeclaration(node: NamespaceExportDeclaration): Symbol {
function getTargetOfNamespaceExportDeclaration(node: NamespaceExportDeclaration): Symbol {
return resolveExternalModuleSymbol(node.parent.symbol);
}
@ -1154,7 +1154,7 @@ namespace ts {
case SyntaxKind.ExportAssignment:
return getTargetOfExportAssignment(<ExportAssignment>node);
case SyntaxKind.NamespaceExportDeclaration:
return getTargetOfGlobalModuleExportDeclaration(<NamespaceExportDeclaration>node);
return getTargetOfNamespaceExportDeclaration(<NamespaceExportDeclaration>node);
}
}
@ -1265,9 +1265,13 @@ namespace ts {
const right = name.kind === SyntaxKind.QualifiedName ? (<QualifiedName>name).right : (<PropertyAccessExpression>name).name;
const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors);
if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) {
if (!namespace || nodeIsMissing(right)) {
return undefined;
}
else if (namespace === unknownSymbol) {
return namespace;
}
symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning);
if (!symbol) {
if (!ignoreErrors) {
@ -2473,16 +2477,13 @@ namespace ts {
}
}
function buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
function buildDisplayForParametersAndDelimiters(thisParameter: Symbol | undefined, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
writePunctuation(writer, SyntaxKind.OpenParenToken);
if (thisType) {
writeKeyword(writer, SyntaxKind.ThisKeyword);
writePunctuation(writer, SyntaxKind.ColonToken);
writeSpace(writer);
buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack);
if (thisParameter) {
buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack);
}
for (let i = 0; i < parameters.length; i++) {
if (i > 0 || thisType) {
if (i > 0 || thisParameter) {
writePunctuation(writer, SyntaxKind.CommaToken);
writeSpace(writer);
}
@ -2538,7 +2539,7 @@ namespace ts {
buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack);
}
buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack);
buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack);
buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack);
}
@ -2794,6 +2795,10 @@ namespace ts {
return type && (type.flags & TypeFlags.Any) !== 0;
}
function isTypeNever(type: Type) {
return type && (type.flags & TypeFlags.Never) !== 0;
}
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
// assigned by contextual typing.
function getTypeForBindingElementParent(node: VariableLikeDeclaration) {
@ -2977,12 +2982,14 @@ namespace ts {
if (func.kind === SyntaxKind.SetAccessor && !hasDynamicName(func)) {
const getter = <AccessorDeclaration>getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor);
if (getter) {
const signature = getSignatureFromDeclaration(getter);
const getterSignature = getSignatureFromDeclaration(getter);
const thisParameter = getAccessorThisParameter(func as AccessorDeclaration);
if (thisParameter && declaration === thisParameter) {
return signature.thisType;
// Use the type from the *getter*
Debug.assert(!thisParameter.type);
return getTypeOfSymbol(getterSignature.thisParameter);
}
return getReturnTypeOfSignature(signature);
return getReturnTypeOfSignature(getterSignature);
}
}
// Use contextual parameter type if one is available
@ -3147,23 +3154,29 @@ namespace ts {
if (declaration.kind === SyntaxKind.ExportAssignment) {
return links.type = checkExpression((<ExportAssignment>declaration).expression);
}
// Handle module.exports = expr
if (declaration.kind === SyntaxKind.BinaryExpression) {
return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
}
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
// Declarations only exist for property access expressions for certain
// special assignment kinds
if (declaration.parent.kind === SyntaxKind.BinaryExpression) {
// Handle exports.p = expr or this.p = expr or className.prototype.method = expr
return links.type = checkExpressionCached((<BinaryExpression>declaration.parent).right);
}
}
// Handle variable, parameter or property
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
return unknownType;
}
let type = getWidenedTypeForVariableLikeDeclaration(<VariableLikeDeclaration>declaration, /*reportErrors*/ true);
let type: Type = undefined;
// Handle module.exports = expr or this.p = expr
if (declaration.kind === SyntaxKind.BinaryExpression) {
type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
}
else if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
// Declarations only exist for property access expressions for certain
// special assignment kinds
if (declaration.parent.kind === SyntaxKind.BinaryExpression) {
// Handle exports.p = expr or className.prototype.method = expr
type = checkExpressionCached((<BinaryExpression>declaration.parent).right);
}
}
if (type === undefined) {
type = getWidenedTypeForVariableLikeDeclaration(<VariableLikeDeclaration>declaration, /*reportErrors*/ true);
}
if (!popTypeResolution()) {
if ((<VariableLikeDeclaration>symbol.valueDeclaration).type) {
// Variable has type annotation that circularly references the variable itself
@ -3198,14 +3211,13 @@ namespace ts {
return undefined;
}
function getAnnotatedAccessorThisType(accessor: AccessorDeclaration): Type {
if (accessor) {
const parameter = getAccessorThisParameter(accessor);
if (parameter && parameter.type) {
return getTypeFromTypeNode(accessor.parameters[0].type);
}
}
return undefined;
function getAnnotatedAccessorThisParameter(accessor: AccessorDeclaration): Symbol | undefined {
const parameter = getAccessorThisParameter(accessor);
return parameter && parameter.symbol;
}
function getThisTypeOfDeclaration(declaration: SignatureDeclaration): Type | undefined {
return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
}
function getTypeOfAccessors(symbol: Symbol): Type {
@ -3888,13 +3900,13 @@ namespace ts {
resolveObjectTypeMembers(type, source, typeParameters, typeArguments);
}
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisType: Type, parameters: Symbol[],
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisParameter: Symbol | undefined, parameters: Symbol[],
resolvedReturnType: Type, typePredicate: TypePredicate, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature {
const sig = new Signature(checker);
sig.declaration = declaration;
sig.typeParameters = typeParameters;
sig.parameters = parameters;
sig.thisType = thisType;
sig.thisParameter = thisParameter;
sig.resolvedReturnType = resolvedReturnType;
sig.typePredicate = typePredicate;
sig.minArgumentCount = minArgumentCount;
@ -3904,7 +3916,7 @@ namespace ts {
}
function cloneSignature(sig: Signature): Signature {
return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType,
return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, sig.resolvedReturnType,
sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
@ -4002,8 +4014,9 @@ namespace ts {
// Union the result types when more than one signature matches
if (unionSignatures.length > 1) {
s = cloneSignature(signature);
if (forEach(unionSignatures, sig => sig.thisType)) {
s.thisType = getUnionType(map(unionSignatures, sig => sig.thisType || anyType));
if (forEach(unionSignatures, sig => sig.thisParameter)) {
const thisType = getUnionType(map(unionSignatures, sig => getTypeOfSymbol(sig.thisParameter) || anyType));
s.thisParameter = createTransientSymbol(signature.thisParameter, thisType);
}
// Clear resolved return type we possibly got from cloneSignature
s.resolvedReturnType = undefined;
@ -4224,6 +4237,7 @@ namespace ts {
let props: Symbol[];
// Flags we want to propagate to the result if they exist in all source symbols
let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None;
let isReadonly = false;
for (const current of types) {
const type = getApparentType(current);
if (type !== unknownType) {
@ -4236,6 +4250,9 @@ namespace ts {
else if (!contains(props, prop)) {
props.push(prop);
}
if (isReadonlySymbol(prop)) {
isReadonly = true;
}
}
else if (containingType.flags & TypeFlags.Union) {
// A union type requires the property to be present in all constituent types
@ -4265,6 +4282,7 @@ namespace ts {
name);
result.containingType = containingType;
result.declarations = declarations;
result.isReadonly = isReadonly;
result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes);
return result;
}
@ -4397,7 +4415,7 @@ namespace ts {
return result;
}
function isOptionalParameter(node: ParameterDeclaration) {
function isJSDocOptionalParameter(node: ParameterDeclaration) {
if (node.flags & NodeFlags.JavaScriptFile) {
if (node.type && node.type.kind === SyntaxKind.JSDocOptionalType) {
return true;
@ -4414,8 +4432,10 @@ namespace ts {
}
}
}
}
if (hasQuestionToken(node)) {
function isOptionalParameter(node: ParameterDeclaration) {
if (hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
return true;
}
@ -4454,7 +4474,7 @@ namespace ts {
const parameters: Symbol[] = [];
let hasStringLiterals = false;
let minArgumentCount = -1;
let thisType: Type = undefined;
let thisParameter: Symbol = undefined;
let hasThisParameter: boolean;
const isJSConstructSignature = isJSDocConstructSignature(declaration);
@ -4472,7 +4492,7 @@ namespace ts {
}
if (i === 0 && paramSymbol.name === "this") {
hasThisParameter = true;
thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType;
thisParameter = param.symbol;
}
else {
parameters.push(paramSymbol);
@ -4482,7 +4502,7 @@ namespace ts {
hasStringLiterals = true;
}
if (param.initializer || param.questionToken || param.dotDotDotToken) {
if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
if (minArgumentCount < 0) {
minArgumentCount = i - (hasThisParameter ? 1 : 0);
}
@ -4496,10 +4516,12 @@ namespace ts {
// If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation
if ((declaration.kind === SyntaxKind.GetAccessor || declaration.kind === SyntaxKind.SetAccessor) &&
!hasDynamicName(declaration) &&
(!hasThisParameter || thisType === unknownType)) {
(!hasThisParameter || !thisParameter)) {
const otherKind = declaration.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
const setter = <AccessorDeclaration>getDeclarationOfKind(declaration.symbol, otherKind);
thisType = getAnnotatedAccessorThisType(setter);
const other = <AccessorDeclaration>getDeclarationOfKind(declaration.symbol, otherKind);
if (other) {
thisParameter = getAnnotatedAccessorThisParameter(other);
}
}
if (minArgumentCount < 0) {
@ -4520,7 +4542,7 @@ namespace ts {
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
undefined;
links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
}
return links.resolvedSignature;
}
@ -4602,6 +4624,12 @@ namespace ts {
return anyType;
}
function getThisTypeOfSignature(signature: Signature): Type | undefined {
if (signature.thisParameter) {
return getTypeOfSymbol(signature.thisParameter);
}
}
function getReturnTypeOfSignature(signature: Signature): Type {
if (!signature.resolvedReturnType) {
if (!pushTypeResolution(signature, TypeSystemPropertyName.ResolvedReturnType)) {
@ -5453,7 +5481,7 @@ namespace ts {
freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper);
}
const result = createSignature(signature.declaration, freshTypeParameters,
signature.thisType && instantiateType(signature.thisType, mapper),
signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper),
instantiateList(signature.parameters, mapper, instantiateSymbol),
instantiateType(signature.resolvedReturnType, mapper),
freshTypePredicate,
@ -5725,17 +5753,22 @@ namespace ts {
target = getErasedSignature(target);
let result = Ternary.True;
if (source.thisType && target.thisType && source.thisType !== voidType) {
// void sources are assignable to anything.
const related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false)
|| compareTypes(target.thisType, source.thisType, reportErrors);
if (!related) {
if (reportErrors) {
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
const sourceThisType = getThisTypeOfSignature(source);
if (sourceThisType && sourceThisType !== voidType) {
const targetThisType = getThisTypeOfSignature(target);
if (targetThisType) {
// void sources are assignable to anything.
const related = compareTypes(sourceThisType, targetThisType, /*reportErrors*/ false)
|| compareTypes(targetThisType, sourceThisType, reportErrors);
if (!related) {
if (reportErrors) {
errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible);
}
return Ternary.False;
}
return Ternary.False;
result &= related;
}
result &= related;
}
const sourceMax = getNumNonRestParameters(source);
@ -6750,13 +6783,21 @@ namespace ts {
source = getErasedSignature(source);
target = getErasedSignature(target);
let result = Ternary.True;
if (!ignoreThisTypes && source.thisType && target.thisType) {
const related = compareTypes(source.thisType, target.thisType);
if (!related) {
return Ternary.False;
if (!ignoreThisTypes) {
const sourceThisType = getThisTypeOfSignature(source);
if (sourceThisType) {
const targetThisType = getThisTypeOfSignature(target);
if (targetThisType) {
const related = compareTypes(sourceThisType, targetThisType);
if (!related) {
return Ternary.False;
}
result &= related;
}
}
result &= related;
}
const targetLen = target.parameters.length;
for (let i = 0; i < targetLen; i++) {
const s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]);
@ -8278,8 +8319,21 @@ namespace ts {
return container === declarationContainer;
}
function updateReferencesForInterfaceHeritiageClauseTargets(node: InterfaceDeclaration): void {
const extendedTypeNode = getClassExtendsHeritageClauseElement(node);
if (extendedTypeNode) {
const t = getTypeFromTypeNode(extendedTypeNode);
if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) {
t.symbol.hasReference = true;
}
}
}
function checkIdentifier(node: Identifier): Type {
const symbol = getResolvedSymbol(node);
if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) {
symbol.hasReference = true;
}
// As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects.
// Although in down-level emit of arrow function, we emit it using function expression which means that
@ -8582,9 +8636,10 @@ namespace ts {
if (type) {
return type;
}
const signature = getSignatureFromDeclaration(container);
if (signature.thisType) {
return signature.thisType;
const thisType = getThisTypeOfDeclaration(container);
if (thisType) {
return thisType;
}
}
if (isClassLike(container.parent)) {
@ -8825,7 +8880,7 @@ namespace ts {
if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) {
const contextualSignature = getContextualSignature(func);
if (contextualSignature) {
return contextualSignature.thisType;
return getThisTypeOfSignature(contextualSignature);
}
}
@ -9624,8 +9679,9 @@ namespace ts {
/**
* Returns true iff React would emit this tag name as a string rather than an identifier or qualified name
*/
function isJsxIntrinsicIdentifier(tagName: Identifier | QualifiedName) {
if (tagName.kind === SyntaxKind.QualifiedName) {
function isJsxIntrinsicIdentifier(tagName: JsxTagNameExpression) {
// TODO (yuisu): comment
if (tagName.kind === SyntaxKind.PropertyAccessExpression || tagName.kind === SyntaxKind.ThisKeyword) {
return false;
}
else {
@ -9821,6 +9877,29 @@ namespace ts {
}));
}
// If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type
if (elemType.flags & TypeFlags.String) {
return anyType;
}
else if (elemType.flags & TypeFlags.StringLiteral) {
// If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type
const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
if (intrinsicElementsType !== unknownType) {
const stringLiteralTypeName = (<StringLiteralType>elemType).text;
const intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName);
if (intrinsicProp) {
return getTypeOfSymbol(intrinsicProp);
}
const indexSignatureType = getIndexTypeOfType(intrinsicElementsType, IndexKind.String);
if (indexSignatureType) {
return indexSignatureType;
}
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements);
}
// If we need to report an error, we already done so here. So just return any to prevent any more error downstream
return anyType;
}
// Get the element instance type (the result of newing or invoking this tag)
const elemInstanceType = getJsxElementInstanceType(node, elemType);
@ -10169,6 +10248,10 @@ namespace ts {
return unknownType;
}
if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) {
prop.hasReference = true;
}
getNodeLinks(node).resolvedSymbol = prop;
if (prop.parent && prop.parent.flags & SymbolFlags.Class) {
@ -10625,10 +10708,11 @@ namespace ts {
context.failedTypeParameterIndex = undefined;
}
if (signature.thisType) {
const thisType = getThisTypeOfSignature(signature);
if (thisType) {
const thisArgumentNode = getThisArgumentOfCall(node);
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
inferTypes(context, thisArgumentType, signature.thisType);
inferTypes(context, thisArgumentType, thisType);
}
// We perform two passes over the arguments. In the first pass we infer from all arguments, but use
@ -10704,8 +10788,8 @@ namespace ts {
}
function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map<RelationComparisonResult>, excludeArgument: boolean[], reportErrors: boolean) {
if (signature.thisType && signature.thisType !== voidType && node.kind !== SyntaxKind.NewExpression) {
const thisType = getThisTypeOfSignature(signature);
if (thisType && thisType !== voidType && node.kind !== SyntaxKind.NewExpression) {
// If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType
// If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible.
// If the expression is a new expression, then the check is skipped.
@ -10713,7 +10797,7 @@ namespace ts {
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
const errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) {
if (!checkTypeRelatedTo(thisArgumentType, getThisTypeOfSignature(signature), relation, errorNode, headMessage)) {
return false;
}
}
@ -11432,7 +11516,7 @@ namespace ts {
if (getReturnTypeOfSignature(signature) !== voidType) {
error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
}
if (signature.thisType === voidType) {
if (getThisTypeOfSignature(signature) === voidType) {
error(node, Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
}
return signature;
@ -11779,6 +11863,16 @@ namespace ts {
return emptyObjectType;
}
function createPromiseReturnType(func: FunctionLikeDeclaration, promisedType: Type) {
const promiseType = createPromiseType(promisedType);
if (promiseType === emptyObjectType) {
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
return unknownType;
}
return promiseType;
}
function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type {
const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
if (!func.body) {
@ -11814,19 +11908,12 @@ namespace ts {
else {
types = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
if (!types) {
return neverType;
// For an async function, the return type will not be never, but rather a Promise for never.
return isAsync ? createPromiseReturnType(func, neverType) : neverType;
}
if (types.length === 0) {
if (isAsync) {
// For an async function, the return type will not be void, but rather a Promise for void.
const promiseType = createPromiseType(voidType);
if (promiseType === emptyObjectType) {
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
return unknownType;
}
return promiseType;
}
return voidType;
// For an async function, the return type will not be void, but rather a Promise for void.
return isAsync ? createPromiseReturnType(func, voidType) : voidType;
}
}
// When yield/return statements are contextually typed we allow the return type to be a union type.
@ -11840,7 +11927,7 @@ namespace ts {
else {
error(func, Diagnostics.No_best_common_type_exists_among_return_expressions);
// Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience
return getUnionType(types);
return isAsync ? createPromiseReturnType(func, getUnionType(types)) : getUnionType(types);
}
}
@ -11853,21 +11940,10 @@ namespace ts {
}
const widenedType = getWidenedType(type);
if (isAsync) {
// From within an async function you can return either a non-promise value or a promise. Any
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
// return type of the body is awaited type of the body, wrapped in a native Promise<T> type.
const promiseType = createPromiseType(widenedType);
if (promiseType === emptyObjectType) {
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
return unknownType;
}
return promiseType;
}
else {
return widenedType;
}
// From within an async function you can return either a non-promise value or a promise. Any
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
// return type of the body is awaited type of the body, wrapped in a native Promise<T> type.
return isAsync ? createPromiseReturnType(func, widenedType) : widenedType;
}
function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] {
@ -12118,6 +12194,8 @@ namespace ts {
}
}
}
checkUnusedIdentifiers(node);
checkUnusedTypeParameters(node);
}
}
@ -12135,7 +12213,9 @@ namespace ts {
// Variables declared with 'const'
// Get accessors without matching set accessors
// Enum members
return symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
// Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation)
return symbol.isReadonly ||
symbol.flags & SymbolFlags.Property && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Readonly) !== 0 ||
symbol.flags & SymbolFlags.Variable && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 ||
symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) ||
(symbol.flags & SymbolFlags.EnumMember) !== 0;
@ -13188,6 +13268,9 @@ namespace ts {
checkAsyncFunctionReturnType(<FunctionLikeDeclaration>node);
}
}
if (!(<FunctionDeclaration>node).body) {
checkUnusedTypeParameters(node);
}
}
}
@ -13340,6 +13423,8 @@ namespace ts {
checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node);
checkSourceElement(node.body);
checkUnusedIdentifiers(node);
checkUnusedTypeParameters(node);
const symbol = getSymbolOfNode(node);
const firstDeclaration = getDeclarationOfKind(symbol, node.kind);
@ -13478,7 +13563,7 @@ namespace ts {
// TypeScript 1.0 spec (April 2014): 4.5
// If both accessors include type annotations, the specified types must be identical.
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, Diagnostics.get_and_set_accessor_must_have_the_same_type);
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorThisType, Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
}
}
getTypeOfAccessors(getSymbolOfNode(node));
@ -13532,13 +13617,18 @@ namespace ts {
function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) {
checkGrammarTypeArguments(node, node.typeArguments);
const type = getTypeFromTypeReference(node);
if (type !== unknownType && node.typeArguments) {
// Do type argument local checks only if referenced type is successfully resolved
forEach(node.typeArguments, checkSourceElement);
if (produceDiagnostics) {
const symbol = getNodeLinks(node).resolvedSymbol;
const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
if (type !== unknownType) {
if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) {
type.symbol.hasReference = true;
}
if (node.typeArguments) {
// Do type argument local checks only if referenced type is successfully resolved
forEach(node.typeArguments, checkSourceElement);
if (produceDiagnostics) {
const symbol = getNodeLinks(node).resolvedSymbol;
const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (<TypeReference>type).target.localTypeParameters;
checkTypeArgumentConstraints(typeParameters, node.typeArguments);
}
}
}
}
@ -13896,7 +13986,7 @@ namespace ts {
function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage) {
type = getWidenedType(type);
if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
if (location) {
if (!message) {
message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member;
@ -13927,12 +14017,15 @@ namespace ts {
// }
//
if (promise.flags & TypeFlags.Any) {
if (isTypeAny(promise)) {
return undefined;
}
if ((promise.flags & TypeFlags.Reference) && (<GenericType>promise).target === tryGetGlobalPromiseType()) {
return (<GenericType>promise).typeArguments[0];
if (promise.flags & TypeFlags.Reference) {
if ((<GenericType>promise).target === tryGetGlobalPromiseType()
|| (<GenericType>promise).target === getGlobalPromiseLikeType()) {
return (<GenericType>promise).typeArguments[0];
}
}
const globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType();
@ -13941,17 +14034,17 @@ namespace ts {
}
const thenFunction = getTypeOfPropertyOfType(promise, "then");
if (thenFunction && (thenFunction.flags & TypeFlags.Any)) {
if (!thenFunction || isTypeAny(thenFunction)) {
return undefined;
}
const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray;
const thenSignatures = getSignaturesOfType(thenFunction, SignatureKind.Call);
if (thenSignatures.length === 0) {
return undefined;
}
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
if (onfulfilledParameterType.flags & TypeFlags.Any) {
if (isTypeAny(onfulfilledParameterType)) {
return undefined;
}
@ -13960,12 +14053,11 @@ namespace ts {
return undefined;
}
const valueParameterType = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature));
return valueParameterType;
return getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature));
}
function getTypeOfFirstParameterOfSignature(signature: Signature) {
return getTypeAtPosition(signature, 0);
return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType;
}
/**
@ -14379,6 +14471,8 @@ namespace ts {
}
checkSourceElement(node.body);
checkUnusedIdentifiers(node);
checkUnusedTypeParameters(node);
if (!node.asteriskToken) {
const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type));
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType);
@ -14400,12 +14494,83 @@ namespace ts {
}
}
function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block | CatchClause): void {
if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) {
for (const key in node.locals) {
if (hasProperty(node.locals, key)) {
const local = node.locals[key];
if (!local.hasReference && local.valueDeclaration) {
if (local.valueDeclaration.kind !== SyntaxKind.Parameter && compilerOptions.noUnusedLocals) {
error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
}
else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) {
if (local.valueDeclaration.flags === 0) {
error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
}
}
}
}
}
}
}
function checkUnusedClassLocals(node: ClassDeclaration): void {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
if (node.members) {
for (const member of node.members) {
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
if (isPrivateNode(member) && !member.symbol.hasReference) {
error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name);
}
}
else if (member.kind === SyntaxKind.Constructor) {
for (const parameter of (<ConstructorDeclaration>member).parameters) {
if (isPrivateNode(parameter) && !parameter.symbol.hasReference) {
error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name);
}
}
}
}
}
}
}
function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
if (node.typeParameters) {
for (const typeParameter of node.typeParameters) {
if (!typeParameter.symbol.hasReference) {
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
}
}
}
}
}
function isPrivateNode(node: Node): boolean {
return (node.flags & NodeFlags.Private) !== 0;
}
function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
for (const key in node.locals) {
if (hasProperty(node.locals, key)) {
const local = node.locals[key];
if (!local.hasReference && !local.exportSymbol) {
forEach(local.declarations, d => error(d.name, Diagnostics._0_is_declared_but_never_used, local.name));
}
}
}
}
}
function checkBlock(node: Block) {
// Grammar checking for SyntaxKind.Block
if (node.kind === SyntaxKind.Block) {
checkGrammarStatementInAmbientContext(node);
}
forEach(node.statements, checkSourceElement);
checkUnusedIdentifiers(node);
}
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
@ -14910,6 +15075,7 @@ namespace ts {
}
checkSourceElement(node.statement);
checkUnusedIdentifiers(node);
}
function checkForInStatement(node: ForInStatement) {
@ -14957,6 +15123,7 @@ namespace ts {
}
checkSourceElement(node.statement);
checkUnusedIdentifiers(node);
}
function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void {
@ -15396,6 +15563,7 @@ namespace ts {
}
checkBlock(catchClause.block);
checkUnusedIdentifiers(catchClause);
}
if (node.finallyBlock) {
@ -15557,6 +15725,8 @@ namespace ts {
}
checkClassLikeDeclaration(node);
forEach(node.members, checkSourceElement);
checkUnusedClassLocals(node);
checkUnusedTypeParameters(node);
}
function checkClassLikeDeclaration(node: ClassLikeDeclaration) {
@ -15866,6 +16036,8 @@ namespace ts {
if (produceDiagnostics) {
checkTypeForDuplicateIndexSignatures(node);
updateReferencesForInterfaceHeritiageClauseTargets(node);
checkUnusedTypeParameters(node);
}
}
@ -16262,6 +16434,7 @@ namespace ts {
if (node.body) {
checkSourceElement(node.body);
checkUnusedModuleLocals(node);
}
}
@ -16442,6 +16615,9 @@ namespace ts {
if (target.flags & SymbolFlags.Type) {
checkTypeNameIsReserved(node.name, Diagnostics.Import_name_cannot_be_0);
}
if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) {
target.hasReference = true;
}
}
}
else {
@ -16784,6 +16960,9 @@ namespace ts {
deferredNodes = [];
forEach(node.statements, checkSourceElement);
if (isExternalModule(node)) {
checkUnusedModuleLocals(node);
}
checkDeferredNodes();
deferredNodes = undefined;
@ -17156,6 +17335,15 @@ namespace ts {
return getSymbolOfEntityNameOrPropertyAccessExpression(<EntityName | PropertyAccessExpression>node);
case SyntaxKind.ThisKeyword:
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
if (isFunctionLike(container)) {
const sig = getSignatureFromDeclaration(container);
if (sig.thisParameter) {
return sig.thisParameter;
}
}
// fallthrough
case SyntaxKind.SuperKeyword:
const type = isExpression(node) ? checkExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
return type.symbol;
@ -17426,7 +17614,10 @@ namespace ts {
const parentSymbol = getParentOfSymbol(symbol);
if (parentSymbol) {
if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) {
return <SourceFile>parentSymbol.valueDeclaration;
// If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined.
if (parentSymbol.valueDeclaration === getSourceFileOfNode(node)) {
return <SourceFile>parentSymbol.valueDeclaration;
}
}
for (let n = node.parent; n; n = n.parent) {
if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) {
@ -18204,7 +18395,10 @@ namespace ts {
return grammarErrorOnNode(lastDeclare, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.ParameterPropertyModifier) && isBindingPattern((<ParameterDeclaration>node).name)) {
return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern);
return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
}
else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.ParameterPropertyModifier) && (<ParameterDeclaration>node).dotDotDotToken) {
return grammarErrorOnNode(node, Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
}
if (flags & NodeFlags.Async) {
return checkGrammarAsyncModifier(node, lastAsync);
@ -18685,7 +18879,7 @@ namespace ts {
return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === SyntaxKind.GetAccessor ? 0 : 1);
}
function getAccessorThisParameter(accessor: AccessorDeclaration) {
function getAccessorThisParameter(accessor: AccessorDeclaration): ParameterDeclaration {
if (accessor.parameters.length === (accessor.kind === SyntaxKind.GetAccessor ? 1 : 2) &&
accessor.parameters[0].name.kind === SyntaxKind.Identifier &&
(<Identifier>accessor.parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword) {

View File

@ -132,6 +132,16 @@ namespace ts {
type: "boolean",
description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
},
{
name: "noUnusedLocals",
type: "boolean",
description: Diagnostics.Report_Errors_on_Unused_Locals,
},
{
name: "noUnusedParameters",
type: "boolean",
description: Diagnostics.Report_Errors_on_Unused_Parameters
},
{
name: "noLib",
type: "boolean",

View File

@ -571,7 +571,7 @@
"category": "Error",
"code": 1186
},
"A parameter property may not be a binding pattern.": {
"A parameter property may not be declared using a binding pattern.": {
"category": "Error",
"code": 1187
},
@ -851,6 +851,10 @@
"category": "Error",
"code": 1316
},
"A parameter property cannot be declared using a rest parameter.": {
"category": "Error",
"code": 1317
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
@ -2788,6 +2792,18 @@
"category": "Message",
"code": 6132
},
"'{0}' is declared but never used.": {
"category": "Error",
"code": 6133
},
"Report Errors on Unused Locals.": {
"category": "Message",
"code": 6134
},
"Report Errors on Unused Parameters.": {
"category": "Message",
"code": 6135
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",

View File

@ -753,6 +753,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
return generateNameForExportDefault();
case SyntaxKind.ClassExpression:
return generateNameForClassExpression();
default:
Debug.fail();
}
}
@ -1217,7 +1219,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
function jsxEmitReact(node: JsxElement | JsxSelfClosingElement) {
/// Emit a tag name, which is either '"div"' for lower-cased names, or
/// 'Div' for upper-cased or dotted names
function emitTagName(name: Identifier | QualifiedName) {
function emitTagName(name: LeftHandSideExpression) {
if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((<Identifier>name).text)) {
write('"');
emit(name);
@ -1671,6 +1673,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
return false;
}
function getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node: Identifier) {
if (languageVersion >= ScriptTarget.ES6) {
let parent = node.parent;
if (parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>parent).expression === node) {
parent = parent.parent;
while (parent && parent.kind !== SyntaxKind.PropertyDeclaration) {
parent = parent.parent;
}
return parent && parent.kind === SyntaxKind.PropertyDeclaration && (parent.flags & NodeFlags.Static) !== 0 &&
parent.parent.kind === SyntaxKind.ClassExpression ? parent.parent : undefined;
}
}
return undefined;
}
function emitIdentifier(node: Identifier) {
if (convertedLoopState) {
if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) {
@ -1685,6 +1702,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
write(node.text);
}
else if (isExpressionIdentifier(node)) {
const classExpression = getClassExpressionInPropertyAccessInStaticPropertyDeclaration(node);
if (classExpression) {
const declaration = resolver.getReferencedValueDeclaration(node);
if (declaration === classExpression) {
write(getGeneratedNameForNode(declaration.name));
return;
}
}
emitExpressionIdentifier(node);
}
else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) {
@ -5084,13 +5109,13 @@ const _super = (function (geti, seti) {
}
}
function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: Identifier, isExpression?: boolean) {
function emitPropertyDeclaration(node: ClassLikeDeclaration, property: PropertyDeclaration, receiver?: string, isExpression?: boolean) {
writeLine();
emitLeadingComments(property);
emitStart(property);
emitStart(property.name);
if (receiver) {
emit(receiver);
write(receiver);
}
else {
if (property.flags & NodeFlags.Static) {
@ -5509,13 +5534,16 @@ const _super = (function (geti, seti) {
// of it have been initialized by the time it is used.
const staticProperties = getInitializedProperties(node, /*isStatic*/ true);
const isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression;
let tempVariable: Identifier;
let generatedName: string;
if (isClassExpressionWithStaticProperties) {
tempVariable = createAndRecordTempVariable(TempFlags.Auto);
generatedName = getGeneratedNameForNode(node.name);
const synthesizedNode = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
synthesizedNode.text = generatedName;
recordTempDeclaration(synthesizedNode);
write("(");
increaseIndent();
emit(tempVariable);
emit(synthesizedNode);
write(" = ");
}
@ -5569,11 +5597,11 @@ const _super = (function (geti, seti) {
for (const property of staticProperties) {
write(",");
writeLine();
emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true);
emitPropertyDeclaration(node, property, /*receiver*/ generatedName, /*isExpression*/ true);
}
write(",");
writeLine();
emit(tempVariable);
write(generatedName);
decreaseIndent();
write(")");
}

View File

@ -1179,6 +1179,7 @@ namespace ts {
return token === SyntaxKind.OpenBracketToken
|| token === SyntaxKind.OpenBraceToken
|| token === SyntaxKind.AsteriskToken
|| token === SyntaxKind.DotDotDotToken
|| isLiteralPropertyName();
}
@ -3576,7 +3577,7 @@ namespace ts {
return finishNode(node);
}
function tagNamesAreEquivalent(lhs: EntityName, rhs: EntityName): boolean {
function tagNamesAreEquivalent(lhs: JsxTagNameExpression, rhs: JsxTagNameExpression): boolean {
if (lhs.kind !== rhs.kind) {
return false;
}
@ -3585,8 +3586,15 @@ namespace ts {
return (<Identifier>lhs).text === (<Identifier>rhs).text;
}
return (<QualifiedName>lhs).right.text === (<QualifiedName>rhs).right.text &&
tagNamesAreEquivalent((<QualifiedName>lhs).left, (<QualifiedName>rhs).left);
if (lhs.kind === SyntaxKind.ThisKeyword) {
return true;
}
// If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only
// take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression
// it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element
return (<PropertyAccessExpression>lhs).name.text === (<PropertyAccessExpression>rhs).name.text &&
tagNamesAreEquivalent((<PropertyAccessExpression>lhs).expression as JsxTagNameExpression, (<PropertyAccessExpression>rhs).expression as JsxTagNameExpression);
}
@ -3654,7 +3662,7 @@ namespace ts {
Debug.fail("Unknown JSX child kind " + token);
}
function parseJsxChildren(openingTagName: EntityName): NodeArray<JsxChild> {
function parseJsxChildren(openingTagName: LeftHandSideExpression): NodeArray<JsxChild> {
const result = <NodeArray<JsxChild>>[];
result.pos = scanner.getStartPos();
const saveParsingContext = parsingContext;
@ -3717,17 +3725,22 @@ namespace ts {
return finishNode(node);
}
function parseJsxElementName(): EntityName {
function parseJsxElementName(): JsxTagNameExpression {
scanJsxIdentifier();
let elementName: EntityName = parseIdentifierName();
// JsxElement can have name in the form of
// propertyAccessExpression
// primaryExpression in the form of an identifier and "this" keyword
// We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword
// We only want to consider "this" as a primaryExpression
let expression: JsxTagNameExpression = token === SyntaxKind.ThisKeyword ?
parseTokenNode<PrimaryExpression>() : parseIdentifierName();
while (parseOptional(SyntaxKind.DotToken)) {
scanJsxIdentifier();
const node: QualifiedName = <QualifiedName>createNode(SyntaxKind.QualifiedName, elementName.pos); // !!!
node.left = elementName;
node.right = parseIdentifierName();
elementName = finishNode(node);
const propertyAccess: PropertyAccessExpression = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
propertyAccess.expression = expression;
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
expression = finishNode(propertyAccess);
}
return elementName;
return expression;
}
function parseJsxExpression(inExpressionContext: boolean): JsxExpression {
@ -4699,7 +4712,7 @@ namespace ts {
case SyntaxKind.EqualsToken:
return parseExportAssignment(fullStart, decorators, modifiers);
case SyntaxKind.AsKeyword:
return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers);
return parseNamespaceExportDeclaration(fullStart, decorators, modifiers);
default:
return parseExportDeclaration(fullStart, decorators, modifiers);
}
@ -5378,7 +5391,7 @@ namespace ts {
return nextToken() === SyntaxKind.SlashToken;
}
function parseGlobalModuleExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): NamespaceExportDeclaration {
function parseNamespaceExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): NamespaceExportDeclaration {
const exportDeclaration = <NamespaceExportDeclaration>createNode(SyntaxKind.NamespaceExportDeclaration, fullStart);
exportDeclaration.decorators = decorators;
exportDeclaration.modifiers = modifiers;

View File

@ -3,22 +3,26 @@
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"out": "../../built/local/tsc.js",
"sourceMap": true
"outFile": "../../built/local/tsc.js",
"sourceMap": true,
"declaration": true,
"stripInternal": true
},
"files": [
"types.ts",
"core.ts",
"sys.ts",
"diagnosticInformationMap.generated.ts",
"types.ts",
"scanner.ts",
"parser.ts",
"utilities.ts",
"binder.ts",
"checker.ts",
"sourcemap.ts",
"declarationEmitter.ts",
"emitter.ts",
"program.ts",
"commandLineParser.ts",
"tsc.ts"
"tsc.ts",
"diagnosticInformationMap.generated.ts"
]
}

View File

@ -1042,11 +1042,13 @@ namespace ts {
closingElement: JsxClosingElement;
}
export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression;
/// The opening element of a <Tag>...</Tag> JsxElement
// @kind(SyntaxKind.JsxOpeningElement)
export interface JsxOpeningElement extends Expression {
_openingElementBrand?: any;
tagName: EntityName;
tagName: JsxTagNameExpression;
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
}
@ -1073,7 +1075,7 @@ namespace ts {
// @kind(SyntaxKind.JsxClosingElement)
export interface JsxClosingElement extends Node {
tagName: EntityName;
tagName: JsxTagNameExpression;
}
// @kind(SyntaxKind.JsxExpression)
@ -1875,7 +1877,7 @@ namespace ts {
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
}
@ -2121,11 +2123,13 @@ namespace ts {
members?: SymbolTable; // Class, interface or literal instance members
exports?: SymbolTable; // Module exports
globalExports?: SymbolTable; // Conditional global UMD exports
/* @internal */ isReadonly?: boolean; // readonly? (set only for intersections and unions)
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
/* @internal */ parent?: Symbol; // Parent symbol
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
/* @internal */ hasReference?: boolean; // True if the symbol is referenced elsewhere
}
/* @internal */
@ -2395,7 +2399,8 @@ namespace ts {
declaration: SignatureDeclaration; // Originating declaration
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
parameters: Symbol[]; // Parameters
thisType?: Type; // type of this-type
/* @internal */
thisParameter?: Symbol; // symbol of this-type parameter
/* @internal */
resolvedReturnType: Type; // Resolved return type
/* @internal */
@ -2555,6 +2560,8 @@ namespace ts {
noImplicitAny?: boolean;
noImplicitReturns?: boolean;
noImplicitThis?: boolean;
noUnusedLocals?: boolean;
noUnusedParameters?: boolean;
noImplicitUseStrict?: boolean;
noLib?: boolean;
noResolve?: boolean;

View File

@ -1702,7 +1702,7 @@ namespace ts {
node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier;
}
export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) {
export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration) {
const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
}

View File

@ -310,6 +310,7 @@ namespace FourSlash {
}
this.formatCodeSettings = {
baseIndentSize: 0,
indentSize: 4,
tabSize: 4,
newLineCharacter: Harness.IO.newLine(),
@ -730,29 +731,6 @@ namespace FourSlash {
}
}
public verifyReferencesCountIs(count: number, localFilesOnly = true) {
const references = this.getReferencesAtCaret();
let referencesCount = 0;
if (localFilesOnly) {
const localFiles = this.testData.files.map<string>(file => file.fileName);
// Count only the references in local files. Filter the ones in lib and other files.
ts.forEach(references, entry => {
if (localFiles.some((fileName) => fileName === entry.fileName)) {
referencesCount++;
}
});
}
else {
referencesCount = references && references.length || 0;
}
if (referencesCount !== count) {
const condition = localFilesOnly ? "excluding libs" : "including libs";
this.raiseError("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount);
}
}
public verifyReferencesAre(expectedReferences: Range[]) {
const actualReferences = this.getReferencesAtCaret() || [];
@ -760,7 +738,7 @@ namespace FourSlash {
// Find the unaccounted-for reference.
for (const actual of actualReferences) {
if (!ts.forEach(expectedReferences, r => r.start === actual.textSpan.start)) {
this.raiseError(`A reference ${actual} is unaccounted for.`);
this.raiseError(`A reference ${stringify(actual)} is unaccounted for.`);
}
}
// Probably will never reach here.
@ -769,7 +747,7 @@ namespace FourSlash {
for (const reference of expectedReferences) {
const {fileName, start, end} = reference;
if (reference.marker) {
if (reference.marker && reference.marker.data) {
const {isWriteAccess, isDefinition} = reference.marker.data;
this.verifyReferencesWorker(actualReferences, fileName, start, end, isWriteAccess, isDefinition);
}
@ -793,12 +771,8 @@ namespace FourSlash {
}
}
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
const references = this.getReferencesAtCaret();
if (!references || references.length === 0) {
this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.");
}
this.verifyReferencesWorker(references, fileName, start, end, isWriteAccess, isDefinition);
public verifyRangesWithSameTextReferenceEachOther() {
ts.forEachValue(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges));
}
private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
@ -817,7 +791,6 @@ namespace FourSlash {
const missingItem = { fileName, start, end, isWriteAccess, isDefinition };
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
private getMemberListAtCaret() {
@ -907,13 +880,13 @@ namespace FourSlash {
assert.equal(getDisplayPartsJson(actualQuickInfo.documentation), getDisplayPartsJson(documentation), this.messageAtLastKnownMarker("QuickInfo documentation"));
}
public verifyRenameLocations(findInStrings: boolean, findInComments: boolean) {
public verifyRenameLocations(findInStrings: boolean, findInComments: boolean, ranges?: Range[]) {
const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
if (renameInfo.canRename) {
let references = this.languageService.findRenameLocations(
this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments);
let ranges = this.getRanges();
ranges = ranges || this.getRanges();
if (!references) {
if (ranges.length !== 0) {
@ -1541,19 +1514,32 @@ namespace FourSlash {
}
private updateMarkersForEdit(fileName: string, minChar: number, limChar: number, text: string) {
for (let i = 0; i < this.testData.markers.length; i++) {
const marker = this.testData.markers[i];
for (const marker of this.testData.markers) {
if (marker.fileName === fileName) {
if (marker.position > minChar) {
if (marker.position < limChar) {
// Marker is inside the edit - mark it as invalidated (?)
marker.position = -1;
}
else {
// Move marker back/forward by the appropriate amount
marker.position += (minChar - limChar) + text.length;
}
marker.position = updatePosition(marker.position);
}
}
for (const range of this.testData.ranges) {
if (range.fileName === fileName) {
range.start = updatePosition(range.start);
range.end = updatePosition(range.end);
}
}
function updatePosition(position: number) {
if (position > minChar) {
if (position < limChar) {
// Inside the edit - mark it as invalidated (?)
return -1;
}
else {
// Move marker back/forward by the appropriate amount
return position + (minChar - limChar) + text.length;
}
}
else {
return position;
}
}
}
@ -1648,8 +1634,20 @@ namespace FourSlash {
}
public getRanges(): Range[] {
// Return a copy of the list
return this.testData.ranges.slice(0);
return this.testData.ranges;
}
public rangesByText(): ts.Map<Range[]> {
const result: ts.Map<Range[]> = {};
for (const range of this.getRanges()) {
const text = this.rangeText(range);
(ts.getProperty(result, text) || (result[text] = [])).push(range);
}
return result;
}
private rangeText({fileName, start, end}: Range, more = false): string {
return this.getFileContent(fileName).slice(start, end);
}
public verifyCaretAtMarker(markerName = "") {
@ -1662,24 +1660,23 @@ namespace FourSlash {
}
}
private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle): number {
private getIndentation(fileName: string, position: number, indentStyle: ts.IndentStyle, baseIndentSize: number): number {
const formatOptions = ts.clone(this.formatCodeSettings);
formatOptions.indentStyle = indentStyle;
formatOptions.baseIndentSize = baseIndentSize;
return this.languageService.getIndentationAtPosition(fileName, position, formatOptions);
}
public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) {
const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle);
public verifyIndentationAtCurrentPosition(numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) {
const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle, baseIndentSize);
const lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
if (actual !== numberOfSpaces) {
this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
}
}
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart) {
const actual = this.getIndentation(fileName, position, indentStyle);
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) {
const actual = this.getIndentation(fileName, position, indentStyle, baseIndentSize);
const lineCol = this.getLineColStringAtPosition(position);
if (actual !== numberOfSpaces) {
this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
@ -1895,7 +1892,7 @@ namespace FourSlash {
});
}
public verifyBraceCompletionAtPostion(negative: boolean, openingBrace: string) {
public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) {
const openBraceMap: ts.Map<ts.CharacterCodes> = {
"(": ts.CharacterCodes.openParen,
@ -1915,7 +1912,7 @@ namespace FourSlash {
const position = this.currentCaretPosition;
const validBraceCompletion = this.languageService.isValidBraceCompletionAtPostion(this.activeFile.fileName, position, charCode);
const validBraceCompletion = this.languageService.isValidBraceCompletionAtPosition(this.activeFile.fileName, position, charCode);
if (!negative && !validBraceCompletion) {
this.raiseError(`${position} is not a valid brace completion position for ${openingBrace}`);
@ -2772,6 +2769,10 @@ namespace FourSlashInterface {
return this.state.getRanges();
}
public rangesByText(): ts.Map<FourSlash.Range[]> {
return this.state.rangesByText();
}
public markerByName(s: string): FourSlash.Marker {
return this.state.getMarkerByName(s);
}
@ -2919,8 +2920,8 @@ namespace FourSlashInterface {
this.state.verifyDefinitionsName(this.negative, name, containerName);
}
public isValidBraceCompletionAtPostion(openingBrace: string) {
this.state.verifyBraceCompletionAtPostion(this.negative, openingBrace);
public isValidBraceCompletionAtPosition(openingBrace: string) {
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
}
}
@ -2937,8 +2938,8 @@ namespace FourSlashInterface {
this.state.verifyIndentationAtCurrentPosition(numberOfSpaces);
}
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = ts.IndentStyle.Smart) {
this.state.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle);
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = ts.IndentStyle.Smart, baseIndentSize = 0) {
this.state.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle, baseIndentSize);
}
public textAtCaretIs(text: string) {
@ -2970,10 +2971,6 @@ namespace FourSlashInterface {
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
}
public referencesCountIs(count: number) {
this.state.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAre(ranges: FourSlash.Range[]) {
this.state.verifyReferencesAre(ranges);
}
@ -2986,6 +2983,10 @@ namespace FourSlashInterface {
this.state.verifyRangesReferenceEachOther(ranges);
}
public rangesWithSameTextReferenceEachOther() {
this.state.verifyRangesWithSameTextReferenceEachOther();
}
public currentParameterHelpArgumentNameIs(name: string) {
this.state.verifyCurrentParameterHelpName(name);
}
@ -3128,8 +3129,8 @@ namespace FourSlashInterface {
this.state.verifyRenameInfoFailed(message);
}
public renameLocations(findInStrings: boolean, findInComments: boolean) {
this.state.verifyRenameLocations(findInStrings, findInComments);
public renameLocations(findInStrings: boolean, findInComments: boolean, ranges?: FourSlash.Range[]) {
this.state.verifyRenameLocations(findInStrings, findInComments, ranges);
}
public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { start: number; length: number; },

View File

@ -450,8 +450,8 @@ namespace Harness.LanguageService {
getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion {
return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position));
}
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace));
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
}
getEmitOutput(fileName: string): ts.EmitOutput {
return unwrapJSONCallResult(this.shim.getEmitOutput(fileName));

View File

@ -224,12 +224,7 @@ namespace Playback {
recordLog.directoriesRead.push(logEntry);
return result;
},
(path, extension, exclude) => findResultByPath(wrapper,
replayLog.directoriesRead.filter(
d => {
return d.extension === extension;
}
), path));
(path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead, path));
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
(path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),

View File

@ -3,59 +3,149 @@
*/
interface Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): Promise<TResult>;
/**
* Creates a new Promise with the same internal state of this Promise.
* @returns A Promise.
*/
then(): Promise<T>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
catch(onrejected?: (reason: any) => void): Promise<T>;
catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected: (reason: any) => T | PromiseLike<T>): Promise<T>;
}
interface PromiseConstructor {
/**
* A reference to the prototype.
/**
* A reference to the prototype.
*/
readonly prototype: Promise<any>;
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
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]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
reject(reason: any): Promise<never>;
/**
* Creates a new rejected promise for the provided reason.

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

@ -1255,13 +1255,33 @@ declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | P
interface PromiseLike<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
/**
* Creates a new Promise with the same internal state of this Promise.
* @returns A Promise.
*/
then(): PromiseLike<T>;
}
interface ArrayLike<T> {
@ -1524,7 +1544,7 @@ interface Int8Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -1797,7 +1817,7 @@ interface Uint8Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2071,7 +2091,7 @@ interface Uint8ClampedArray {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2344,7 +2364,7 @@ interface Int16Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2618,7 +2638,7 @@ interface Uint16Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -2891,7 +2911,7 @@ interface Int32Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -3164,7 +3184,7 @@ interface Uint32Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -3437,7 +3457,7 @@ interface Float32Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
@ -3711,7 +3731,7 @@ interface Float64Array {
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.

View File

@ -588,7 +588,7 @@ namespace ts.server {
throw new Error("Not Implemented Yet.");
}
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
throw new Error("Not Implemented Yet.");
}

View File

@ -544,6 +544,7 @@ namespace ts.server {
if (!this.logger.isVerbose()) {
return;
}
this.logger.startGroup();
let counter = 0;

View File

@ -543,6 +543,9 @@ declare namespace ts.server.protocol {
/** Number of spaces to indent during formatting. Default value is 4. */
indentSize?: number;
/** Number of additional spaces to indent during formatting to preserve base indentation (ex. script block indentation). Default value is 0. */
baseIndentSize?: number;
/** The new line character to be used. Default value is the OS line delimiter. */
newLineCharacter?: string;
@ -1051,7 +1054,6 @@ declare namespace ts.server.protocol {
* Arguments of a signature help request.
*/
export interface SignatureHelpRequestArgs extends FileLocationRequestArgs {
}
/**
@ -1070,6 +1072,43 @@ declare namespace ts.server.protocol {
body?: SignatureHelpItems;
}
/**
* Synchronous request for semantic diagnostics of one file.
*/
export interface SemanticDiagnosticsSyncRequest extends FileRequest {
arguments: SemanticDiagnosticsSyncRequestArgs;
}
export interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs {
includeLinePosition?: boolean;
}
/**
* Response object for synchronous sematic diagnostics request.
*/
export interface SemanticDiagnosticsSyncResponse extends Response {
body?: Diagnostic[] | DiagnosticWithLinePosition[];
}
/**
* Synchronous request for syntactic diagnostics of one file.
*/
export interface SyntacticDiagnosticsSyncRequest extends FileRequest {
arguments: SyntacticDiagnosticsSyncRequestArgs;
}
export interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs {
includeLinePosition?: boolean;
}
/**
* Response object for synchronous syntactic diagnostics request.
*/
export interface SyntacticDiagnosticsSyncResponse extends Response {
body?: Diagnostic[] | DiagnosticWithLinePosition[];
}
/**
* Arguments for GeterrForProject request.
*/

View File

@ -21,16 +21,16 @@ namespace ts.server {
return spaceCache[n];
}
export function generateIndentString(n: number, editorOptions: EditorOptions): string {
if (editorOptions.ConvertTabsToSpaces) {
export function generateIndentString(n: number, editorOptions: EditorSettings): string {
if (editorOptions.convertTabsToSpaces) {
return generateSpaces(n);
}
else {
let result = "";
for (let i = 0; i < Math.floor(n / editorOptions.TabSize); i++) {
for (let i = 0; i < Math.floor(n / editorOptions.tabSize); i++) {
result += "\t";
}
for (let i = 0; i < n % editorOptions.TabSize; i++) {
for (let i = 0; i < n % editorOptions.tabSize; i++) {
result += " ";
}
return result;
@ -119,7 +119,8 @@ namespace ts.server {
export const FormatRangeFull = "formatRange-full";
export const Geterr = "geterr";
export const GeterrForProject = "geterrForProject";
export const SemanticDiagnosticsFull = "semanticDiagnostics-full";
export const SemanticDiagnosticsSync = "semanticDiagnosticsSync";
export const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
export const NavBar = "navbar";
export const NavBarFull = "navbar-full";
export const Navto = "navto";
@ -154,7 +155,6 @@ namespace ts.server {
export const TodoComments = "todoComments";
export const Indentation = "indentation";
export const DocCommentTemplate = "docCommentTemplate";
export const SyntacticDiagnosticsFull = "syntacticDiagnostics-full";
export const CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full";
export const NameOrDottedNameSpan = "nameOrDottedNameSpan";
export const BreakpointStatement = "breakpointStatement";
@ -162,6 +162,7 @@ namespace ts.server {
namespace Errors {
export const NoProject = new Error("No Project.");
export const ProjectLanguageServiceDisabled = new Error("The project's language service is disabled.");
}
export interface ServerHost extends ts.System {
@ -380,10 +381,10 @@ namespace ts.server {
private getCompilerOptionsDiagnostics(args: protocol.ProjectRequestArgs) {
const project = this.getProject(args.projectFileName);
return this.convertDiagnostics(project.languageService.getCompilerOptionsDiagnostics(), /*scriptInfo*/ undefined);
return this.convertToDiagnosticsWithLinePosition(project.languageService.getCompilerOptionsDiagnostics(), /*scriptInfo*/ undefined);
}
private convertDiagnostics(diagnostics: Diagnostic[], scriptInfo: ScriptInfo) {
private convertToDiagnosticsWithLinePosition(diagnostics: Diagnostic[], scriptInfo: ScriptInfo) {
return diagnostics.map(d => <protocol.DiagnosticWithLinePosition>{
message: flattenDiagnosticMessageText(d.messageText, this.host.newLine),
start: d.start,
@ -395,19 +396,13 @@ namespace ts.server {
});
}
private getDiagnosticsWorker(args: protocol.FileRequestArgs, selector: (project: Project, file: string) => Diagnostic[]) {
private getDiagnosticsWorker(args: protocol.FileRequestArgs, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) {
const { project, file } = this.getFileAndProject(args);
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
const diagnostics = selector(project, file);
return this.convertDiagnostics(diagnostics, scriptInfo);
}
private getSyntacticDiagnostics(args: protocol.FileRequestArgs): protocol.DiagnosticWithLinePosition[] {
return this.getDiagnosticsWorker(args, (project, file) => project.languageService.getSyntacticDiagnostics(file));
}
private getSemanticDiagnostics(args: protocol.FileRequestArgs): protocol.DiagnosticWithLinePosition[] {
return this.getDiagnosticsWorker(args, (project, file) => project.languageService.getSemanticDiagnostics(file));
return includeLinePosition
? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo)
: diagnostics.map(d => formatDiag(file, project, d));
}
private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.FileSpan[] | DefinitionInfo[] {
@ -480,11 +475,18 @@ namespace ts.server {
});
}
private getSyntacticDiagnosticsSync(args: protocol.SyntacticDiagnosticsSyncRequestArgs): protocol.Diagnostic[] | protocol.DiagnosticWithLinePosition[] {
return this.getDiagnosticsWorker(args, (project, file) => project.languageService.getSyntacticDiagnostics(file), args.includeLinePosition);
}
private getSemanticDiagnosticsSync(args: protocol.SemanticDiagnosticsSyncRequestArgs): protocol.Diagnostic[] | protocol.DiagnosticWithLinePosition[] {
return this.getDiagnosticsWorker(args, (project, file) => project.languageService.getSemanticDiagnostics(file), args.includeLinePosition);
}
private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): protocol.DocumentHighlightsItem[] | DocumentHighlights[] {
const { file, project } = this.getFileAndProject(args);
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
const position = this.getPosition(args, scriptInfo);
const documentHighlights = project.languageService.getDocumentHighlights(file, position, args.filesToSearch);
if (!documentHighlights) {
@ -797,7 +799,7 @@ namespace ts.server {
private isValidBraceCompletion(args: protocol.BraceCompletionRequestArgs) {
const { file, project } = this.getFileAndProject(args);
const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file));
return project.languageService.isValidBraceCompletionAtPostion(file, position, args.openingBrace.charCodeAt(0));
return project.languageService.isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0));
}
private getQuickInfoWorker(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.QuickInfoResponseBody | QuickInfo {
@ -881,15 +883,7 @@ namespace ts.server {
if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) {
const lineText = lineInfo.leaf.text;
if (lineText.search("\\S") < 0) {
// TODO: get these options from host
const editorOptions: ts.EditorOptions = {
IndentSize: formatOptions.indentSize,
TabSize: formatOptions.tabSize,
NewLineCharacter: formatOptions.newLineCharacter,
ConvertTabsToSpaces: formatOptions.convertTabsToSpaces,
IndentStyle: ts.IndentStyle.Smart,
};
const preferredIndent = project.languageService.getIndentationAtPosition(file, position, editorOptions);
const preferredIndent = project.languageService.getIndentationAtPosition(file, position, formatOptions);
let hasIndent = 0;
let i: number, len: number;
for (i = 0, len = lineText.length; i < len; i++) {
@ -897,7 +891,7 @@ namespace ts.server {
hasIndent++;
}
else if (lineText.charAt(i) == "\t") {
hasIndent += editorOptions.TabSize;
hasIndent += formatOptions.tabSize;
}
else {
break;
@ -908,7 +902,7 @@ namespace ts.server {
const firstNoWhiteSpacePosition = lineInfo.offset + i;
edits.push({
span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition),
newText: generateIndentString(preferredIndent, editorOptions)
newText: generateIndentString(preferredIndent, formatOptions)
});
}
}
@ -1376,12 +1370,6 @@ namespace ts.server {
[CommandNames.SignatureHelpFull]: (request: protocol.SignatureHelpRequest) => {
return this.requiredResponse(this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.SemanticDiagnosticsFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getSemanticDiagnostics(request.arguments));
},
[CommandNames.SyntacticDiagnosticsFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getSyntacticDiagnostics(request.arguments));
},
[CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.ProjectRequest) => {
return this.requiredResponse(this.getCompilerOptionsDiagnostics(request.arguments));
},
@ -1392,6 +1380,12 @@ namespace ts.server {
this.cleanup();
return this.requiredResponse(true);
},
[CommandNames.SemanticDiagnosticsSync]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getSemanticDiagnosticsSync(request.arguments));
},
[CommandNames.SyntacticDiagnosticsSync]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getSyntacticDiagnosticsSync(request.arguments));
},
[CommandNames.Geterr]: (request: protocol.Request) => {
const geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
return { response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false };

View File

@ -4,13 +4,16 @@
"removeComments": true,
"preserveConstEnums": true,
"out": "../../built/local/tsserver.js",
"sourceMap": true
"sourceMap": true,
"stripInternal": true
},
"files": [
"../services/shims.ts",
"../services/utilities.ts",
"node.d.ts",
"editorServices.ts",
"protocol.d.ts",
"server.ts",
"session.ts"
"session.ts",
"server.ts"
]
}

View File

@ -133,7 +133,7 @@ namespace ts.server {
getFormattingEditsForDocument: (): any => throwLanguageServiceIsDisabledError(),
getFormattingEditsAfterKeystroke: (): any => throwLanguageServiceIsDisabledError(),
getDocCommentTemplateAtPosition: (): any => throwLanguageServiceIsDisabledError(),
isValidBraceCompletionAtPostion: (): any => throwLanguageServiceIsDisabledError(),
isValidBraceCompletionAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getEmitOutput: (): any => throwLanguageServiceIsDisabledError(),
getProgram: (): any => throwLanguageServiceIsDisabledError(),
getNonBoundSourceFile: (): any => throwLanguageServiceIsDisabledError(),

View File

@ -394,7 +394,10 @@ namespace ts.formatting {
const startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
const column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
if (startLine !== parentStartLine || startPos === column) {
return column;
// Use the base indent size if it is greater than
// the indentation of the inherited predecessor.
const baseIndentSize = SmartIndenter.getBaseIndentation(options);
return baseIndentSize > column ? baseIndentSize : column;
}
}

View File

@ -10,7 +10,7 @@ namespace ts.formatting {
export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number {
if (position > sourceFile.text.length) {
return 0; // past EOF
return getBaseIndentation(options); // past EOF
}
// no indentation when the indent style is set to none,
@ -21,7 +21,7 @@ namespace ts.formatting {
const precedingToken = findPrecedingToken(position, sourceFile);
if (!precedingToken) {
return 0;
return getBaseIndentation(options);
}
// no indentation in string \regex\template literals
@ -96,8 +96,8 @@ namespace ts.formatting {
}
if (!current) {
// no parent was found - return 0 to be indented on the level of SourceFile
return 0;
// no parent was found - return the base indentation of the SourceFile
return getBaseIndentation(options);
}
return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options);
@ -108,6 +108,10 @@ namespace ts.formatting {
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
}
export function getBaseIndentation(options: EditorSettings) {
return options.baseIndentSize || 0;
}
function getIndentationForNodeWorker(
current: Node,
currentStart: LineAndCharacter,
@ -162,7 +166,7 @@ namespace ts.formatting {
parent = current.parent;
}
return indentationDelta;
return indentationDelta + getBaseIndentation(options);
}

View File

@ -795,7 +795,7 @@ namespace ts {
declaration: SignatureDeclaration;
typeParameters: TypeParameter[];
parameters: Symbol[];
thisType: Type;
thisParameter: Symbol;
resolvedReturnType: Type;
minArgumentCount: number;
hasRestParameter: boolean;
@ -1163,7 +1163,7 @@ namespace ts {
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getEmitOutput(fileName: string): EmitOutput;
@ -1261,6 +1261,7 @@ namespace ts {
/* @deprecated - consider using EditorSettings instead */
export interface EditorOptions {
BaseIndentSize?: number;
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
@ -1269,6 +1270,7 @@ namespace ts {
}
export interface EditorSettings {
baseIndentSize?: number;
indentSize: number;
tabSize: number;
newLineCharacter: string;
@ -5904,17 +5906,32 @@ namespace ts {
return undefined;
}
if (node.kind !== SyntaxKind.Identifier &&
// TODO (drosen): This should be enabled in a later release - currently breaks rename.
// node.kind !== SyntaxKind.ThisKeyword &&
// node.kind !== SyntaxKind.SuperKeyword &&
node.kind !== SyntaxKind.StringLiteral &&
!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) {
return undefined;
switch (node.kind) {
case SyntaxKind.NumericLiteral:
if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) {
break;
}
// Fallthrough
case SyntaxKind.Identifier:
case SyntaxKind.ThisKeyword:
// case SyntaxKind.SuperKeyword: TODO:GH#9268
case SyntaxKind.StringLiteral:
return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments);
}
return undefined;
}
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral);
return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments);
function isThis(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ThisKeyword:
// case SyntaxKind.ThisType: TODO: GH#9267
return true;
case SyntaxKind.Identifier:
// 'this' as a parameter
return (node as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword && node.parent.kind === SyntaxKind.Parameter;
default:
return false;
}
}
function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] {
@ -5934,7 +5951,7 @@ namespace ts {
}
}
if (node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.ThisType) {
if (isThis(node)) {
return getReferencesForThisKeyword(node, sourceFiles);
}
@ -6469,7 +6486,7 @@ namespace ts {
cancellationToken.throwIfCancellationRequested();
const node = getTouchingWord(sourceFile, position);
if (!node || (node.kind !== SyntaxKind.ThisKeyword && node.kind !== SyntaxKind.ThisType)) {
if (!node || !isThis(node)) {
return;
}
@ -7858,7 +7875,7 @@ namespace ts {
return { newText: result, caretOffset: preamble.length };
}
function isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean {
function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
// '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too
// expensive to do during typing scenarios
@ -8101,11 +8118,11 @@ namespace ts {
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true);
// Can only rename an identifier.
if (node) {
if (node.kind === SyntaxKind.Identifier ||
node.kind === SyntaxKind.StringLiteral ||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) {
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
isThis(node)) {
const symbol = typeChecker.getSymbolAtLocation(node);
// Only allow a symbol to be renamed if it actually has at least one declaration.
@ -8226,7 +8243,7 @@ namespace ts {
getFormattingEditsForDocument,
getFormattingEditsAfterKeystroke,
getDocCommentTemplateAtPosition,
isValidBraceCompletionAtPostion,
isValidBraceCompletionAtPosition,
getEmitOutput,
getNonBoundSourceFile,
getProgram

View File

@ -228,7 +228,7 @@ namespace ts {
* at the current position.
* E.g. we don't want brace completion inside string-literals, comments, etc.
*/
isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string;
getEmitOutput(fileName: string): string;
}
@ -758,10 +758,10 @@ namespace ts {
);
}
public isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string {
public isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string {
return this.forwardJSONCall(
`isValidBraceCompletionAtPostion('${fileName}', ${position}, ${openingBrace})`,
() => this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace)
`isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`,
() => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace)
);
}

View File

@ -357,8 +357,8 @@ namespace ts.SignatureHelp {
}
function getArgumentIndex(argumentsList: Node, node: Node) {
// The list we got back can include commas. In the presence of errors it may
// also just have nodes without commas. For example "Foo(a b c)" will have 3
// The list we got back can include commas. In the presence of errors it may
// also just have nodes without commas. For example "Foo(a b c)" will have 3
// args without commas. We want to find what index we're at. So we count
// forward until we hit ourselves, only incrementing the index if it isn't a
// comma.
@ -390,8 +390,8 @@ namespace ts.SignatureHelp {
// 'a' '<comma>'. So, in the case where the last child is a comma, we increase the
// arg count by one to compensate.
//
// Note: this subtlety only applies to the last comma. If you had "Foo(a,," then
// we'll have: 'a' '<comma>' '<missing>'
// Note: this subtlety only applies to the last comma. If you had "Foo(a,," then
// we'll have: 'a' '<comma>' '<missing>'
// That will give us 2 non-commas. We then add one for the last comma, givin us an
// arg count of 3.
const listChildren = argumentsList.getChildren();
@ -563,7 +563,7 @@ namespace ts.SignatureHelp {
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
const parameterParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation));
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation));
addRange(suffixDisplayParts, parameterParts);
}
else {

View File

@ -1,10 +1,13 @@
{
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"removeComments": false,
"preserveConstEnums": true,
"out": "../../built/local/typescriptServices.js",
"sourceMap": true
"outFile": "../../built/local/typescriptServices.js",
"sourceMap": true,
"stripInternal": true,
"noResolve": false,
"declaration": true
},
"files": [
"../compiler/core.ts",
@ -15,11 +18,12 @@
"../compiler/utilities.ts",
"../compiler/binder.ts",
"../compiler/checker.ts",
"../compiler/sourcemap.ts",
"../compiler/declarationEmitter.ts",
"../compiler/emitter.ts",
"../compiler/program.ts",
"../compiler/declarationEmitter.ts",
"../compiler/diagnosticInformationMap.generated.ts",
"../compiler/commandLineParser.ts",
"../compiler/diagnosticInformationMap.generated.ts",
"breakpoints.ts",
"navigateTo.ts",
"navigationBar.ts",

View File

@ -1,10 +1,15 @@
//// [classExpressionWithStaticPropertiesES61.ts]
var v = class C { static a = 1; static b = 2 };
var v = class C {
static a = 1;
static b = 2;
static c = C.a + 3;
};
//// [classExpressionWithStaticPropertiesES61.js]
var v = (_a = class C {
var v = (C_1 = class C {
},
_a.a = 1,
_a.b = 2,
_a);
var _a;
C_1.a = 1,
C_1.b = 2,
C_1.c = C_1.a + 3,
C_1);
var C_1;

View File

@ -1,7 +1,18 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts ===
var v = class C { static a = 1; static b = 2 };
var v = class C {
>v : Symbol(v, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 3))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7))
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 31))
static a = 1;
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
static b = 2;
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES61.ts, 1, 17))
static c = C.a + 3;
>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES61.ts, 2, 17))
>C.a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 7))
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES61.ts, 0, 17))
};

View File

@ -1,10 +1,23 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES61.ts ===
var v = class C { static a = 1; static b = 2 };
var v = class C {
>v : typeof C
>class C { static a = 1; static b = 2 } : typeof C
>class C { static a = 1; static b = 2; static c = C.a + 3;} : typeof C
>C : typeof C
static a = 1;
>a : number
>1 : number
static b = 2;
>b : number
>2 : number
static c = C.a + 3;
>c : number
>C.a + 3 : number
>C.a : number
>C : typeof C
>a : number
>3 : number
};

View File

@ -1,9 +1,20 @@
//// [classExpressionWithStaticPropertiesES62.ts]
var v = class C { static a = 1; static b };
var v = class C {
static a = 1;
static b
static c = {
x: "hi"
}
static d = C.c.x + " world";
};
//// [classExpressionWithStaticPropertiesES62.js]
var v = (_a = class C {
var v = (C_1 = class C {
},
_a.a = 1,
_a);
var _a;
C_1.a = 1,
C_1.c = {
x: "hi"
},
C_1.d = C_1.c.x + " world",
C_1);
var C_1;

View File

@ -1,7 +1,26 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts ===
var v = class C { static a = 1; static b };
var v = class C {
>v : Symbol(v, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 3))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7))
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17))
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 31))
static a = 1;
>a : Symbol(C.a, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 17))
static b
>b : Symbol(C.b, Decl(classExpressionWithStaticPropertiesES62.ts, 1, 17))
static c = {
>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12))
x: "hi"
>x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16))
}
static d = C.c.x + " world";
>d : Symbol(C.d, Decl(classExpressionWithStaticPropertiesES62.ts, 5, 5))
>C.c.x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16))
>C.c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES62.ts, 0, 7))
>c : Symbol(C.c, Decl(classExpressionWithStaticPropertiesES62.ts, 2, 12))
>x : Symbol(x, Decl(classExpressionWithStaticPropertiesES62.ts, 3, 16))
};

View File

@ -1,9 +1,32 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES62.ts ===
var v = class C { static a = 1; static b };
var v = class C {
>v : typeof C
>class C { static a = 1; static b } : typeof C
>class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; } : typeof C
>C : typeof C
static a = 1;
>a : number
>1 : number
static b
>b : any
static c = {
>c : { x: string; }
>{ x: "hi" } : { x: string; }
x: "hi"
>x : string
>"hi" : string
}
static d = C.c.x + " world";
>d : string
>C.c.x + " world" : string
>C.c.x : string
>C.c : { x: string; }
>C : typeof C
>c : { x: string; }
>x : string
>" world" : string
};

View File

@ -0,0 +1,23 @@
//// [classExpressionWithStaticPropertiesES63.ts]
declare var console: any;
const arr: {y(): number}[] = [];
for (let i = 0; i < 3; i++) {
arr.push(class C {
static x = i;
static y = () => C.x * 2;
});
}
arr.forEach(C => console.log(C.y()));
//// [classExpressionWithStaticPropertiesES63.js]
const arr = [];
for (let i = 0; i < 3; i++) {
arr.push((C_1 = class C {
},
C_1.x = i,
C_1.y = () => C_1.x * 2,
C_1));
}
arr.forEach(C => console.log(C.y()));
var C_1;

View File

@ -0,0 +1,42 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts ===
declare var console: any;
>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11))
const arr: {y(): number}[] = [];
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))
for (let i = 0; i < 3; i++) {
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
arr.push(class C {
>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13))
static x = i;
>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
>i : Symbol(i, Decl(classExpressionWithStaticPropertiesES63.ts, 3, 8))
static y = () => C.x * 2;
>y : Symbol(C.y, Decl(classExpressionWithStaticPropertiesES63.ts, 5, 21))
>C.x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 13))
>x : Symbol(C.x, Decl(classExpressionWithStaticPropertiesES63.ts, 4, 22))
});
}
arr.forEach(C => console.log(C.y()));
>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5))
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12))
>console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11))
>C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))
>C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12))
>y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12))

View File

@ -0,0 +1,58 @@
=== tests/cases/compiler/classExpressionWithStaticPropertiesES63.ts ===
declare var console: any;
>console : any
const arr: {y(): number}[] = [];
>arr : { y(): number; }[]
>y : () => number
>[] : undefined[]
for (let i = 0; i < 3; i++) {
>i : number
>0 : number
>i < 3 : boolean
>i : number
>3 : number
>i++ : number
>i : number
arr.push(class C {
>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number
>arr.push : (...items: { y(): number; }[]) => number
>arr : { y(): number; }[]
>push : (...items: { y(): number; }[]) => number
>class C { static x = i; static y = () => C.x * 2; } : typeof C
>C : typeof C
static x = i;
>x : number
>i : number
static y = () => C.x * 2;
>y : () => number
>() => C.x * 2 : () => number
>C.x * 2 : number
>C.x : number
>C : typeof C
>x : number
>2 : number
});
}
arr.forEach(C => console.log(C.y()));
>arr.forEach(C => console.log(C.y())) : void
>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
>arr : { y(): number; }[]
>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
>C => console.log(C.y()) : (C: { y(): number; }) => any
>C : { y(): number; }
>console.log(C.y()) : any
>console.log : any
>console : any
>log : any
>C.y() : number
>C.y : () => number
>C : { y(): number; }
>y : () => number

View File

@ -1,9 +0,0 @@
=== tests/cases/compiler/file1.ts ===
c;
>c : Symbol(c, Decl(file2.ts, 0, 5))
=== tests/cases/compiler/file2.ts ===
const c = 0;
>c : Symbol(c, Decl(file2.ts, 0, 5))

View File

@ -1,10 +0,0 @@
=== tests/cases/compiler/file1.ts ===
c;
>c : number
=== tests/cases/compiler/file2.ts ===
const c = 0;
>c : number
>0 : number

View File

@ -1,13 +1,13 @@
tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(2,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(8,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(14,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(2,17): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(8,17): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(14,17): error TS1187: A parameter property may not be declared using a binding pattern.
==== tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts (3 errors) ====
class C1 {
constructor(public [x, y, z]: string[]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
}
}
@ -15,7 +15,7 @@ tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(14,17):
class C2 {
constructor(public [x, y, z]: TupleType1) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
}
}
@ -23,6 +23,6 @@ tests/cases/compiler/declarationEmitDestructuringParameterProperties.ts(14,17):
class C3 {
constructor(public { x, y, z }: ObjType1) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
}
}

View File

@ -46,8 +46,9 @@ var MyClass = (function () {
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [Object])
__metadata('design:paramtypes', [(typeof (_a = typeof db_1.default !== 'undefined' && db_1.default.db) === 'function' && _a) || Object])
], MyClass);
return MyClass;
var _a;
}());
exports.MyClass = MyClass;

View File

@ -1,5 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(14,17): error TS1047: A rest parameter cannot be optional.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
@ -10,12 +12,12 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
Type 'number | string' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,24): error TS1005: ',' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,17): error TS1317: A parameter property cannot be declared using a rest parameter.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,22): error TS2304: Cannot find name 'E1'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,28): error TS2304: Cannot find name 'E'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (10 errors) ====
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (12 errors) ====
// If the parameter is a rest parameter, the parameter type is any[]
// A type annotation for a rest parameter must denote an array type.
@ -34,7 +36,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
~~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
function a3(...b?) { } // Error, can't be optional
~
!!! error TS1047: A rest parameter cannot be optional.
function a4(...b = [1,2,3]) { } // Error, can't have initializer
~
!!! error TS1048: A rest parameter cannot have an initializer.
function a5([a, b, [[c]]]) { }
function a6([a, b, c, ...x]: number[]) { }
@ -63,9 +69,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
var temp = [1, 2, 3];
class C {
constructor(public ...temp) { } // Error, rest parameter can't have accessibilityModifier
~~~
!!! error TS1005: ',' expected.
constructor(public ...temp) { } // Error, rest parameter can't have properties
~~~~~~~~~~~~~~
!!! error TS1317: A parameter property cannot be declared using a rest parameter.
}
// Rest parameter with generic

View File

@ -27,7 +27,7 @@ a6([1, 2, "string"]); // Error, parameter type is number[]
var temp = [1, 2, 3];
class C {
constructor(public ...temp) { } // Error, rest parameter can't have accessibilityModifier
constructor(public ...temp) { } // Error, rest parameter can't have properties
}
// Rest parameter with generic
@ -83,12 +83,13 @@ a5([1, 2]); // Error, parameter type is [any, any, [[any]]]
a6([1, 2, "string"]); // Error, parameter type is number[]
var temp = [1, 2, 3];
var C = (function () {
function C(public) {
function C() {
var temp = [];
for (var _i = 1; _i < arguments.length; _i++) {
temp[_i - 1] = arguments[_i];
for (var _i = 0; _i < arguments.length; _i++) {
temp[_i - 0] = arguments[_i];
}
} // Error, rest parameter can't have accessibilityModifier
this.temp = temp;
} // Error, rest parameter can't have properties
return C;
}());
// Rest parameter with generic

View File

@ -1,6 +1,6 @@
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(9,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(16,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2,17): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(9,17): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(16,17): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'.
@ -17,7 +17,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2
class C1 {
constructor(public [x, y, z]: string[]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
}
}
@ -26,7 +26,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2
class C2 {
constructor(public [x, y, z]: TupleType1) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
}
}
@ -35,7 +35,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2
class C3 {
constructor(public { x, y, z }: ObjType1) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
}
}

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2,36): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2,36): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'.
@ -14,7 +14,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2
class C1 {
constructor(private k: number, private [a, b, c]: [number, string, boolean]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
~
!!! error TS2339: Property 'b' does not exist on type 'C1'.

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(2,31): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(2,31): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
@ -11,7 +11,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(1
class C1<T, U, V> {
constructor(private k: T, private [a, b, c]: [T,U,V]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
~
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(3,31): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(3,31): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
@ -15,7 +15,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(2
class C1<T, U, V> {
constructor(private k: T, protected [a, b, c]: [T,U,V]) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
~
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.

View File

@ -1,4 +1,4 @@
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,17): error TS1187: A parameter property may not be a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,17): error TS1187: A parameter property may not be declared using a binding pattern.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature.
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature.
@ -20,7 +20,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1
class C1 {
constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1187: A parameter property may not be a binding pattern.
!!! error TS1187: A parameter property may not be declared using a binding pattern.
~~
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature.
~~

View File

@ -30,7 +30,7 @@ function weird(this: Example, a = this.getNumber()) {
>Example : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
>a : Symbol(a, Decl(inferParameterWithMethodCallInitializer.ts, 11, 29))
>this.getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
>this : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
>this : Symbol(this, Decl(inferParameterWithMethodCallInitializer.ts, 11, 15))
>getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
return a;
@ -45,7 +45,7 @@ class Weird {
>Example : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
>a : Symbol(a, Decl(inferParameterWithMethodCallInitializer.ts, 15, 30))
>this.getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
>this : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
>this : Symbol(this, Decl(inferParameterWithMethodCallInitializer.ts, 15, 16))
>getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
return a;

View File

@ -37,14 +37,14 @@ export class BrokenClass {
>reject : Symbol(reject, Decl(file1.ts, 13, 34))
this.doStuff(order.id)
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>this.doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>this : Symbol(BrokenClass, Decl(file1.ts, 1, 39))
>doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>order : Symbol(order, Decl(file1.ts, 12, 25))
.then((items) => {
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>items : Symbol(items, Decl(file1.ts, 15, 17))
order.items = items;
@ -60,17 +60,17 @@ export class BrokenClass {
};
return Promise.all(result.map(populateItems))
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>result : Symbol(result, Decl(file1.ts, 10, 7))
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7))
.then((orders: Array<MyModule.MyModel>) => {
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>orders : Symbol(orders, Decl(file1.ts, 23, 13))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))

View File

@ -46,7 +46,7 @@ export class BrokenClass {
this.doStuff(order.id)
>this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }) : Promise<void>
>this.doStuff(order.id) .then : { <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>this.doStuff(order.id) .then : { <TResult1, TResult2>(onfulfilled: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<void>; }
>this.doStuff(order.id) : Promise<void>
>this.doStuff : (id: number) => Promise<void>
>this : this
@ -56,7 +56,7 @@ export class BrokenClass {
>id : any
.then((items) => {
>then : { <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>then : { <TResult1, TResult2>(onfulfilled: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: void) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<void>; }
>(items) => { order.items = items; resolve(order); } : (items: void) => void
>items : void
@ -78,11 +78,11 @@ export class BrokenClass {
return Promise.all(result.map(populateItems))
>Promise.all(result.map(populateItems)) .then((orders: Array<MyModule.MyModel>) => { resolve(orders); }) : Promise<void>
>Promise.all(result.map(populateItems)) .then : { <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>Promise.all(result.map(populateItems)) .then : { <TResult1, TResult2>(onfulfilled: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}[]>; }
>Promise.all(result.map(populateItems)) : Promise<{}[]>
>Promise.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]>; <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]>; <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]>; <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]>; <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]>; <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]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>Promise.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]>; <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]>; <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]>; <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]>; <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]>; <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]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>Promise : PromiseConstructor
>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]>; <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]>; <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]>; <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]>; <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]>; <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]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>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]>; <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]>; <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]>; <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]>; <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]>; <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]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>result.map(populateItems) : Promise<{}>[]
>result.map : <U>(callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any) => U[]
>result : MyModule.MyModel[]
@ -90,7 +90,7 @@ export class BrokenClass {
>populateItems : (order: any) => Promise<{}>
.then((orders: Array<MyModule.MyModel>) => {
>then : { <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>then : { <TResult1, TResult2>(onfulfilled: (value: {}[]) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}[]) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}[]>; }
>(orders: Array<MyModule.MyModel>) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void
>orders : MyModule.MyModel[]
>Array : T[]

View File

@ -0,0 +1,44 @@
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(21,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(23,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(25,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
==== tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts (5 errors) ====
interface Base {
readonly value: number;
}
interface Identical {
readonly value: number;
}
interface Mutable {
value: number;
}
interface DifferentType {
readonly value: string;
}
interface DifferentName {
readonly other: number;
}
let base: Base;
base.value = 12 // error, lhs can't be a readonly property
~~~~~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
let identical: Base & Identical;
identical.value = 12; // error, lhs can't be a readonly property
~~~~~~~~~~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
let mutable: Base & Mutable;
mutable.value = 12; // error, lhs can't be a readonly property
~~~~~~~~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
let differentType: Base & DifferentType;
differentType.value = 12; // error, lhs can't be a readonly property
~~~~~~~~~~~~~~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
let differentName: Base & DifferentName;
differentName.value = 12; // error, property 'value' doesn't exist
~~~~~~~~~~~~~~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.

View File

@ -0,0 +1,39 @@
//// [intersectionTypeReadonly.ts]
interface Base {
readonly value: number;
}
interface Identical {
readonly value: number;
}
interface Mutable {
value: number;
}
interface DifferentType {
readonly value: string;
}
interface DifferentName {
readonly other: number;
}
let base: Base;
base.value = 12 // error, lhs can't be a readonly property
let identical: Base & Identical;
identical.value = 12; // error, lhs can't be a readonly property
let mutable: Base & Mutable;
mutable.value = 12; // error, lhs can't be a readonly property
let differentType: Base & DifferentType;
differentType.value = 12; // error, lhs can't be a readonly property
let differentName: Base & DifferentName;
differentName.value = 12; // error, property 'value' doesn't exist
//// [intersectionTypeReadonly.js]
var base;
base.value = 12; // error, lhs can't be a readonly property
var identical;
identical.value = 12; // error, lhs can't be a readonly property
var mutable;
mutable.value = 12; // error, lhs can't be a readonly property
var differentType;
differentType.value = 12; // error, lhs can't be a readonly property
var differentName;
differentName.value = 12; // error, property 'value' doesn't exist

View File

@ -0,0 +1,17 @@
=== tests/cases/compiler/foo.js ===
export class StackOverflowTest {
>StackOverflowTest : Symbol(StackOverflowTest, Decl(foo.js, 0, 0))
constructor () {
this.testStackOverflow = this.testStackOverflow.bind(this)
>this.testStackOverflow : Symbol(StackOverflowTest.testStackOverflow, Decl(foo.js, 2, 18))
>this : Symbol(StackOverflowTest, Decl(foo.js, 0, 0))
>testStackOverflow : Symbol(StackOverflowTest.testStackOverflow, Decl(foo.js, 2, 18))
>this.testStackOverflow : Symbol(StackOverflowTest.testStackOverflow, Decl(foo.js, 2, 18))
>this : Symbol(StackOverflowTest, Decl(foo.js, 0, 0))
>testStackOverflow : Symbol(StackOverflowTest.testStackOverflow, Decl(foo.js, 2, 18))
>this : Symbol(StackOverflowTest, Decl(foo.js, 0, 0))
}
}

View File

@ -0,0 +1,21 @@
=== tests/cases/compiler/foo.js ===
export class StackOverflowTest {
>StackOverflowTest : StackOverflowTest
constructor () {
this.testStackOverflow = this.testStackOverflow.bind(this)
>this.testStackOverflow = this.testStackOverflow.bind(this) : any
>this.testStackOverflow : any
>this : this
>testStackOverflow : any
>this.testStackOverflow.bind(this) : any
>this.testStackOverflow.bind : any
>this.testStackOverflow : any
>this : this
>testStackOverflow : any
>bind : any
>this : this
}
}

View File

@ -1,9 +0,0 @@
=== tests/cases/compiler/file1.ts ===
l;
>l : Symbol(l, Decl(file2.ts, 0, 5))
=== tests/cases/compiler/file2.ts ===
const l = 0;
>l : Symbol(l, Decl(file2.ts, 0, 5))

View File

@ -1,10 +0,0 @@
=== tests/cases/compiler/file1.ts ===
l;
>l : number
=== tests/cases/compiler/file2.ts ===
const l = 0;
>l : number
>0 : number

View File

@ -121,9 +121,9 @@ declare var console: any;
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11))
out().then(() => {
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 45, 37))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
console.log("Yea!");
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11))

View File

@ -148,10 +148,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>() => { console.log("Yea!");} : () => void
console.log("Yea!");

View File

@ -121,9 +121,9 @@ declare var console: any;
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11))
out().then(() => {
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 45, 37))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
console.log("Yea!");
>console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11))

View File

@ -148,10 +148,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>() => { console.log("Yea!");} : () => void
console.log("Yea!");

View File

@ -121,9 +121,9 @@ declare var console: any;
>console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11))
out().then(() => {
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>out : Symbol(out, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 45, 37))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
console.log("Yea!");
>console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11))

View File

@ -148,10 +148,10 @@ declare var console: any;
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>() => { console.log("Yea!");} : () => void
console.log("Yea!");

View File

@ -1,10 +1,10 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts(3,23): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts(3,16): error TS1317: A parameter property cannot be declared using a rest parameter.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509668.ts (1 errors) ====
class Foo3 {
// Doesn't work, but should
constructor (public ...args: string[]) { }
~~~
!!! error TS1005: ',' expected.
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1317: A parameter property cannot be declared using a rest parameter.
}

View File

@ -7,11 +7,12 @@ class Foo3 {
//// [parser509668.js]
var Foo3 = (function () {
// Doesn't work, but should
function Foo3(public) {
function Foo3() {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
this.args = args;
}
return Foo3;
}());

View File

@ -0,0 +1,14 @@
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
==== main.ts (1 errors) ====
import * as ng from "angular2/core";
~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'angular2/core'.
declare function foo(...args: any[]);
@foo
export class MyClass1 {
constructor(private _elementRef: ng.ElementRef){}
}

View File

@ -0,0 +1,13 @@
{
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule",
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.d.ts",
"main.ts"
],
"emittedFiles": [
"main.js"
]
}

View File

@ -0,0 +1,24 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
define(["require", "exports", "angular2/core"], function (require, exports, ng) {
"use strict";
var MyClass1 = (function () {
function MyClass1(_elementRef) {
this._elementRef = _elementRef;
}
MyClass1 = __decorate([
foo,
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
], MyClass1);
return MyClass1;
var _a;
}());
exports.MyClass1 = MyClass1;
});

View File

@ -0,0 +1,14 @@
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
==== main.ts (1 errors) ====
import * as ng from "angular2/core";
~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'angular2/core'.
declare function foo(...args: any[]);
@foo
export class MyClass1 {
constructor(private _elementRef: ng.ElementRef){}
}

View File

@ -0,0 +1,13 @@
{
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModule",
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.d.ts",
"main.ts"
],
"emittedFiles": [
"main.js"
]
}

View File

@ -0,0 +1,23 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var ng = require("angular2/core");
var MyClass1 = (function () {
function MyClass1(_elementRef) {
this._elementRef = _elementRef;
}
MyClass1 = __decorate([
foo,
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
], MyClass1);
return MyClass1;
var _a;
}());
exports.MyClass1 = MyClass1;

View File

@ -0,0 +1,14 @@
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
==== main.ts (1 errors) ====
import * as ng from "angular2/core";
~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'angular2/core'.
declare function foo(...args: any[]);
@foo
export class MyClass1 {
constructor(private _elementRef: ng.ElementRef){}
}

View File

@ -0,0 +1,13 @@
{
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve",
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.d.ts",
"main.ts"
],
"emittedFiles": [
"main.js"
]
}

View File

@ -0,0 +1,24 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
define(["require", "exports", "angular2/core"], function (require, exports, ng) {
"use strict";
var MyClass1 = (function () {
function MyClass1(_elementRef) {
this._elementRef = _elementRef;
}
MyClass1 = __decorate([
foo,
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
], MyClass1);
return MyClass1;
var _a;
}());
exports.MyClass1 = MyClass1;
});

View File

@ -0,0 +1,14 @@
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
==== main.ts (1 errors) ====
import * as ng from "angular2/core";
~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'angular2/core'.
declare function foo(...args: any[]);
@foo
export class MyClass1 {
constructor(private _elementRef: ng.ElementRef){}
}

View File

@ -0,0 +1,13 @@
{
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataCommonJSIsolatedModuleNoResolve",
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.d.ts",
"main.ts"
],
"emittedFiles": [
"main.js"
]
}

View File

@ -0,0 +1,23 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var ng = require("angular2/core");
var MyClass1 = (function () {
function MyClass1(_elementRef) {
this._elementRef = _elementRef;
}
MyClass1 = __decorate([
foo,
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
], MyClass1);
return MyClass1;
var _a;
}());
exports.MyClass1 = MyClass1;

View File

@ -0,0 +1,14 @@
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
==== main.ts (1 errors) ====
import * as ng from "angular2/core";
~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'angular2/core'.
declare function foo(...args: any[]);
@foo
export class MyClass1 {
constructor(private _elementRef: ng.ElementRef){}
}

View File

@ -0,0 +1,13 @@
{
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS",
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.d.ts",
"main.ts"
],
"emittedFiles": [
"main.js"
]
}

View File

@ -0,0 +1,24 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
define(["require", "exports", "angular2/core"], function (require, exports, ng) {
"use strict";
var MyClass1 = (function () {
function MyClass1(_elementRef) {
this._elementRef = _elementRef;
}
MyClass1 = __decorate([
foo,
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
], MyClass1);
return MyClass1;
var _a;
}());
exports.MyClass1 = MyClass1;
});

Some files were not shown because too many files have changed in this diff Show More