Merge branch 'master' into JSLS

Conflicts:
	src/services/services.ts
This commit is contained in:
Cyrus Najmabadi
2015-04-02 14:22:16 -07:00
74 changed files with 15996 additions and 8321 deletions
+3 -1
View File
@@ -111,6 +111,7 @@ var definitionsRoots = [
"compiler/parser.d.ts",
"compiler/checker.d.ts",
"compiler/program.d.ts",
"compiler/commandLineParser.d.ts",
"services/services.d.ts",
];
@@ -143,7 +144,8 @@ var harnessSources = [
"services/colorization.ts",
"services/documentRegistry.ts",
"services/preProcessFile.ts",
"services/patternMatcher.ts"
"services/patternMatcher.ts",
"versionCache.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
+158 -8
View File
@@ -14223,7 +14223,11 @@ declare function importScripts(...urls: string[]): void;
/// Windows Script Host APIS
/////////////////////////////
declare var ActiveXObject: { new (s: string): any; };
interface ActiveXObject {
new (s: string): any;
}
declare var ActiveXObject: ActiveXObject;
interface ITextWriter {
Write(s: string): void;
@@ -14231,11 +14235,157 @@ interface ITextWriter {
Close(): void;
}
declare var WScript: {
Echo(s: any): void;
StdErr: ITextWriter;
StdOut: ITextWriter;
Arguments: { length: number; Item(n: number): string; };
ScriptFullName: string;
Quit(exitCode?: number): number;
interface TextStreamBase {
/**
* The column number of the current character position in an input stream.
*/
Column: number;
/**
* The current line number in an input stream.
*/
Line: number;
/**
* Closes a text stream.
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
*/
Close(): void;
}
interface TextStreamWriter extends TextStreamBase {
/**
* Sends a string to an output stream.
*/
Write(s: string): void;
/**
* Sends a specified number of blank lines (newline characters) to an output stream.
*/
WriteBlankLines(intLines: number): void;
/**
* Sends a string followed by a newline character to an output stream.
*/
WriteLine(s: string): void;
}
interface TextStreamReader extends TextStreamBase {
/**
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
* Does not return until the ENTER key is pressed.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
Read(characters: number): string;
/**
* Returns all characters from an input stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadAll(): string;
/**
* Returns an entire line from an input stream.
* Although this method extracts the newline character, it does not add it to the returned string.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadLine(): string;
/**
* Skips a specified number of characters when reading from an input text stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
*/
Skip(characters: number): void;
/**
* Skips the next line when reading from an input text stream.
* Can only be used on a stream in reading mode, not writing or appending mode.
*/
SkipLine(): void;
/**
* Indicates whether the stream pointer position is at the end of a line.
*/
AtEndOfLine: boolean;
/**
* Indicates whether the stream pointer position is at the end of a stream.
*/
AtEndOfStream: boolean;
}
declare var WScript: {
/**
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
*/
Echo(s: any): void;
/**
* Exposes the write-only error output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdErr: TextStreamWriter;
/**
* Exposes the write-only output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdOut: TextStreamWriter;
Arguments: { length: number; Item(n: number): string; };
/**
* The full path of the currently running script.
*/
ScriptFullName: string;
/**
* Forces the script to stop immediately, with an optional exit code.
*/
Quit(exitCode?: number): number;
/**
* The Windows Script Host build version number.
*/
BuildVersion: number;
/**
* Fully qualified path of the host executable.
*/
FullName: string;
/**
* Gets/sets the script mode - interactive(true) or batch(false).
*/
Interactive: boolean;
/**
* The name of the host executable (WScript.exe or CScript.exe).
*/
Name: string;
/**
* Path of the directory containing the host executable.
*/
Path: string;
/**
* The filename of the currently running script.
*/
ScriptName: string;
/**
* Exposes the read-only input stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdIn: TextStreamReader;
/**
* Windows Script Host version
*/
Version: string;
/**
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
*/
ConnectObject(objEventSource: any, strPrefix: string): void;
/**
* Creates a COM object.
* @param strProgiID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
CreateObject(strProgID: string, strPrefix?: string): any;
/**
* Disconnects a COM object from its event sources.
*/
DisconnectObject(obj: any): void;
/**
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
* @param strProgID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
/**
* Suspends script execution for a specified length of time, then continues execution.
* @param intTime Interval (in milliseconds) to suspend script execution.
*/
Sleep(intTime: number): void;
};
+158 -8
View File
@@ -17205,7 +17205,11 @@ declare function importScripts(...urls: string[]): void;
/// Windows Script Host APIS
/////////////////////////////
declare var ActiveXObject: { new (s: string): any; };
interface ActiveXObject {
new (s: string): any;
}
declare var ActiveXObject: ActiveXObject;
interface ITextWriter {
Write(s: string): void;
@@ -17213,11 +17217,157 @@ interface ITextWriter {
Close(): void;
}
declare var WScript: {
Echo(s: any): void;
StdErr: ITextWriter;
StdOut: ITextWriter;
Arguments: { length: number; Item(n: number): string; };
ScriptFullName: string;
Quit(exitCode?: number): number;
interface TextStreamBase {
/**
* The column number of the current character position in an input stream.
*/
Column: number;
/**
* The current line number in an input stream.
*/
Line: number;
/**
* Closes a text stream.
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
*/
Close(): void;
}
interface TextStreamWriter extends TextStreamBase {
/**
* Sends a string to an output stream.
*/
Write(s: string): void;
/**
* Sends a specified number of blank lines (newline characters) to an output stream.
*/
WriteBlankLines(intLines: number): void;
/**
* Sends a string followed by a newline character to an output stream.
*/
WriteLine(s: string): void;
}
interface TextStreamReader extends TextStreamBase {
/**
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
* Does not return until the ENTER key is pressed.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
Read(characters: number): string;
/**
* Returns all characters from an input stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadAll(): string;
/**
* Returns an entire line from an input stream.
* Although this method extracts the newline character, it does not add it to the returned string.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadLine(): string;
/**
* Skips a specified number of characters when reading from an input text stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
*/
Skip(characters: number): void;
/**
* Skips the next line when reading from an input text stream.
* Can only be used on a stream in reading mode, not writing or appending mode.
*/
SkipLine(): void;
/**
* Indicates whether the stream pointer position is at the end of a line.
*/
AtEndOfLine: boolean;
/**
* Indicates whether the stream pointer position is at the end of a stream.
*/
AtEndOfStream: boolean;
}
declare var WScript: {
/**
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
*/
Echo(s: any): void;
/**
* Exposes the write-only error output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdErr: TextStreamWriter;
/**
* Exposes the write-only output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdOut: TextStreamWriter;
Arguments: { length: number; Item(n: number): string; };
/**
* The full path of the currently running script.
*/
ScriptFullName: string;
/**
* Forces the script to stop immediately, with an optional exit code.
*/
Quit(exitCode?: number): number;
/**
* The Windows Script Host build version number.
*/
BuildVersion: number;
/**
* Fully qualified path of the host executable.
*/
FullName: string;
/**
* Gets/sets the script mode - interactive(true) or batch(false).
*/
Interactive: boolean;
/**
* The name of the host executable (WScript.exe or CScript.exe).
*/
Name: string;
/**
* Path of the directory containing the host executable.
*/
Path: string;
/**
* The filename of the currently running script.
*/
ScriptName: string;
/**
* Exposes the read-only input stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdIn: TextStreamReader;
/**
* Windows Script Host version
*/
Version: string;
/**
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
*/
ConnectObject(objEventSource: any, strPrefix: string): void;
/**
* Creates a COM object.
* @param strProgiID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
CreateObject(strProgID: string, strPrefix?: string): any;
/**
* Disconnects a COM object from its event sources.
*/
DisconnectObject(obj: any): void;
/**
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
* @param strProgID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
/**
* Suspends script execution for a specified length of time, then continues execution.
* @param intTime Interval (in milliseconds) to suspend script execution.
*/
Sleep(intTime: number): void;
};
+158 -8
View File
@@ -20,7 +20,11 @@ and limitations under the License.
/// Windows Script Host APIS
/////////////////////////////
declare var ActiveXObject: { new (s: string): any; };
interface ActiveXObject {
new (s: string): any;
}
declare var ActiveXObject: ActiveXObject;
interface ITextWriter {
Write(s: string): void;
@@ -28,11 +32,157 @@ interface ITextWriter {
Close(): void;
}
declare var WScript: {
Echo(s: any): void;
StdErr: ITextWriter;
StdOut: ITextWriter;
Arguments: { length: number; Item(n: number): string; };
ScriptFullName: string;
Quit(exitCode?: number): number;
interface TextStreamBase {
/**
* The column number of the current character position in an input stream.
*/
Column: number;
/**
* The current line number in an input stream.
*/
Line: number;
/**
* Closes a text stream.
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
*/
Close(): void;
}
interface TextStreamWriter extends TextStreamBase {
/**
* Sends a string to an output stream.
*/
Write(s: string): void;
/**
* Sends a specified number of blank lines (newline characters) to an output stream.
*/
WriteBlankLines(intLines: number): void;
/**
* Sends a string followed by a newline character to an output stream.
*/
WriteLine(s: string): void;
}
interface TextStreamReader extends TextStreamBase {
/**
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
* Does not return until the ENTER key is pressed.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
Read(characters: number): string;
/**
* Returns all characters from an input stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadAll(): string;
/**
* Returns an entire line from an input stream.
* Although this method extracts the newline character, it does not add it to the returned string.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadLine(): string;
/**
* Skips a specified number of characters when reading from an input text stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
*/
Skip(characters: number): void;
/**
* Skips the next line when reading from an input text stream.
* Can only be used on a stream in reading mode, not writing or appending mode.
*/
SkipLine(): void;
/**
* Indicates whether the stream pointer position is at the end of a line.
*/
AtEndOfLine: boolean;
/**
* Indicates whether the stream pointer position is at the end of a stream.
*/
AtEndOfStream: boolean;
}
declare var WScript: {
/**
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
*/
Echo(s: any): void;
/**
* Exposes the write-only error output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdErr: TextStreamWriter;
/**
* Exposes the write-only output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdOut: TextStreamWriter;
Arguments: { length: number; Item(n: number): string; };
/**
* The full path of the currently running script.
*/
ScriptFullName: string;
/**
* Forces the script to stop immediately, with an optional exit code.
*/
Quit(exitCode?: number): number;
/**
* The Windows Script Host build version number.
*/
BuildVersion: number;
/**
* Fully qualified path of the host executable.
*/
FullName: string;
/**
* Gets/sets the script mode - interactive(true) or batch(false).
*/
Interactive: boolean;
/**
* The name of the host executable (WScript.exe or CScript.exe).
*/
Name: string;
/**
* Path of the directory containing the host executable.
*/
Path: string;
/**
* The filename of the currently running script.
*/
ScriptName: string;
/**
* Exposes the read-only input stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdIn: TextStreamReader;
/**
* Windows Script Host version
*/
Version: string;
/**
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
*/
ConnectObject(objEventSource: any, strPrefix: string): void;
/**
* Creates a COM object.
* @param strProgiID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
CreateObject(strProgID: string, strPrefix?: string): any;
/**
* Disconnects a COM object from its event sources.
*/
DisconnectObject(obj: any): void;
/**
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
* @param strProgID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
/**
* Suspends script execution for a specified length of time, then continues execution.
* @param intTime Interval (in milliseconds) to suspend script execution.
*/
Sleep(intTime: number): void;
};
+8084 -3044
View File
File diff suppressed because one or more lines are too long
+1949 -1593
View File
File diff suppressed because it is too large Load Diff
+86 -58
View File
@@ -196,59 +196,62 @@ declare module "typescript" {
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
ClassExpression = 174,
OmittedExpression = 175,
TemplateSpan = 176,
HeritageClauseElement = 177,
SemicolonClassElement = 178,
Block = 179,
VariableStatement = 180,
EmptyStatement = 181,
ExpressionStatement = 182,
IfStatement = 183,
DoStatement = 184,
WhileStatement = 185,
ForStatement = 186,
ForInStatement = 187,
ForOfStatement = 188,
ContinueStatement = 189,
BreakStatement = 190,
ReturnStatement = 191,
WithStatement = 192,
SwitchStatement = 193,
LabeledStatement = 194,
ThrowStatement = 195,
TryStatement = 196,
DebuggerStatement = 197,
VariableDeclaration = 198,
VariableDeclarationList = 199,
FunctionDeclaration = 200,
ClassDeclaration = 201,
InterfaceDeclaration = 202,
TypeAliasDeclaration = 203,
EnumDeclaration = 204,
ModuleDeclaration = 205,
ModuleBlock = 206,
CaseBlock = 207,
ImportEqualsDeclaration = 208,
ImportDeclaration = 209,
ImportClause = 210,
NamespaceImport = 211,
NamedImports = 212,
ImportSpecifier = 213,
ExportAssignment = 214,
ExportDeclaration = 215,
NamedExports = 216,
ExportSpecifier = 217,
MissingDeclaration = 218,
ExternalModuleReference = 219,
CaseClause = 220,
DefaultClause = 221,
HeritageClause = 222,
CatchClause = 223,
PropertyAssignment = 224,
ShorthandPropertyAssignment = 225,
EnumMember = 226,
SourceFile = 227,
SyntaxList = 228,
Count = 229,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
@@ -432,6 +435,9 @@ declare module "typescript" {
interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
body?: Block;
}
interface SemicolonClassElement extends ClassElement {
_semicolonClassElementBrand: any;
}
interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
_accessorDeclarationBrand: any;
body: Block;
@@ -570,6 +576,10 @@ declare module "typescript" {
typeArguments?: NodeArray<TypeNode>;
arguments: NodeArray<Expression>;
}
interface HeritageClauseElement extends Node {
expression: LeftHandSideExpression;
typeArguments?: NodeArray<TypeNode>;
}
interface NewExpression extends CallExpression, PrimaryExpression {
}
interface TaggedTemplateExpression extends MemberExpression {
@@ -664,12 +674,16 @@ declare module "typescript" {
interface ModuleElement extends Node {
_moduleElementBrand: any;
}
interface ClassDeclaration extends Declaration, ModuleElement {
interface ClassLikeDeclaration extends Declaration {
name?: Identifier;
typeParameters?: NodeArray<TypeParameterDeclaration>;
heritageClauses?: NodeArray<HeritageClause>;
members: NodeArray<ClassElement>;
}
interface ClassDeclaration extends ClassLikeDeclaration, Statement {
}
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
}
interface ClassElement extends Declaration {
_classElementBrand: any;
}
@@ -681,7 +695,7 @@ declare module "typescript" {
}
interface HeritageClause extends Node {
token: SyntaxKind;
types?: NodeArray<TypeReferenceNode>;
types?: NodeArray<HeritageClauseElement>;
}
interface TypeAliasDeclaration extends Declaration, ModuleElement {
name: Identifier;
@@ -923,7 +937,7 @@ declare module "typescript" {
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
@@ -1179,7 +1193,6 @@ declare module "typescript" {
interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
codepage?: number;
declaration?: boolean;
diagnostics?: boolean;
emitBOM?: boolean;
@@ -1193,7 +1206,6 @@ declare module "typescript" {
noErrorTruncation?: boolean;
noImplicitAny?: boolean;
noLib?: boolean;
noLibCheck?: boolean;
noResolve?: boolean;
out?: string;
outDir?: string;
@@ -1206,6 +1218,7 @@ declare module "typescript" {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1454,6 +1467,20 @@ declare module "typescript" {
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -1947,6 +1974,7 @@ declare module "typescript" {
isCancellationRequested(): boolean;
throwIfCancellationRequested(): void;
}
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string;
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
+2006 -1647
View File
File diff suppressed because it is too large Load Diff
+86 -58
View File
@@ -196,59 +196,62 @@ declare module ts {
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
ClassExpression = 174,
OmittedExpression = 175,
TemplateSpan = 176,
HeritageClauseElement = 177,
SemicolonClassElement = 178,
Block = 179,
VariableStatement = 180,
EmptyStatement = 181,
ExpressionStatement = 182,
IfStatement = 183,
DoStatement = 184,
WhileStatement = 185,
ForStatement = 186,
ForInStatement = 187,
ForOfStatement = 188,
ContinueStatement = 189,
BreakStatement = 190,
ReturnStatement = 191,
WithStatement = 192,
SwitchStatement = 193,
LabeledStatement = 194,
ThrowStatement = 195,
TryStatement = 196,
DebuggerStatement = 197,
VariableDeclaration = 198,
VariableDeclarationList = 199,
FunctionDeclaration = 200,
ClassDeclaration = 201,
InterfaceDeclaration = 202,
TypeAliasDeclaration = 203,
EnumDeclaration = 204,
ModuleDeclaration = 205,
ModuleBlock = 206,
CaseBlock = 207,
ImportEqualsDeclaration = 208,
ImportDeclaration = 209,
ImportClause = 210,
NamespaceImport = 211,
NamedImports = 212,
ImportSpecifier = 213,
ExportAssignment = 214,
ExportDeclaration = 215,
NamedExports = 216,
ExportSpecifier = 217,
MissingDeclaration = 218,
ExternalModuleReference = 219,
CaseClause = 220,
DefaultClause = 221,
HeritageClause = 222,
CatchClause = 223,
PropertyAssignment = 224,
ShorthandPropertyAssignment = 225,
EnumMember = 226,
SourceFile = 227,
SyntaxList = 228,
Count = 229,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
@@ -432,6 +435,9 @@ declare module ts {
interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
body?: Block;
}
interface SemicolonClassElement extends ClassElement {
_semicolonClassElementBrand: any;
}
interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
_accessorDeclarationBrand: any;
body: Block;
@@ -570,6 +576,10 @@ declare module ts {
typeArguments?: NodeArray<TypeNode>;
arguments: NodeArray<Expression>;
}
interface HeritageClauseElement extends Node {
expression: LeftHandSideExpression;
typeArguments?: NodeArray<TypeNode>;
}
interface NewExpression extends CallExpression, PrimaryExpression {
}
interface TaggedTemplateExpression extends MemberExpression {
@@ -664,12 +674,16 @@ declare module ts {
interface ModuleElement extends Node {
_moduleElementBrand: any;
}
interface ClassDeclaration extends Declaration, ModuleElement {
interface ClassLikeDeclaration extends Declaration {
name?: Identifier;
typeParameters?: NodeArray<TypeParameterDeclaration>;
heritageClauses?: NodeArray<HeritageClause>;
members: NodeArray<ClassElement>;
}
interface ClassDeclaration extends ClassLikeDeclaration, Statement {
}
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
}
interface ClassElement extends Declaration {
_classElementBrand: any;
}
@@ -681,7 +695,7 @@ declare module ts {
}
interface HeritageClause extends Node {
token: SyntaxKind;
types?: NodeArray<TypeReferenceNode>;
types?: NodeArray<HeritageClauseElement>;
}
interface TypeAliasDeclaration extends Declaration, ModuleElement {
name: Identifier;
@@ -923,7 +937,7 @@ declare module ts {
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
@@ -1179,7 +1193,6 @@ declare module ts {
interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
codepage?: number;
declaration?: boolean;
diagnostics?: boolean;
emitBOM?: boolean;
@@ -1193,7 +1206,6 @@ declare module ts {
noErrorTruncation?: boolean;
noImplicitAny?: boolean;
noLib?: boolean;
noLibCheck?: boolean;
noResolve?: boolean;
out?: string;
outDir?: string;
@@ -1206,6 +1218,7 @@ declare module ts {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1454,6 +1467,20 @@ declare module ts {
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module ts {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module ts {
/** The version of the language service API */
let servicesVersion: string;
@@ -1947,6 +1974,7 @@ declare module ts {
isCancellationRequested(): boolean;
throwIfCancellationRequested(): void;
}
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string;
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
+2006 -1647
View File
File diff suppressed because it is too large Load Diff
+17 -6
View File
@@ -221,9 +221,9 @@ declare module ts {
function isClassElement(n: Node): boolean;
function isDeclarationName(name: Node): boolean;
function isAliasSymbolDeclaration(node: Node): boolean;
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration): HeritageClauseElement;
function getClassImplementsHeritageClauseElements(node: ClassDeclaration): NodeArray<HeritageClauseElement>;
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<HeritageClauseElement>;
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
function getAncestor(node: Node, kind: SyntaxKind): Node;
@@ -307,7 +307,7 @@ declare module ts {
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string;
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void;
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number;
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration;
function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration;
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
firstAccessor: AccessorDeclaration;
@@ -318,11 +318,22 @@ declare module ts {
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void;
function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void;
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void;
function isSupportedHeritageClauseElement(node: HeritageClauseElement): boolean;
function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean;
function getLocalSymbolForExportDefault(symbol: Symbol): Symbol;
}
declare module ts {
var optionDeclarations: CommandLineOption[];
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module ts {
+17 -6
View File
@@ -221,9 +221,9 @@ declare module "typescript" {
function isClassElement(n: Node): boolean;
function isDeclarationName(name: Node): boolean;
function isAliasSymbolDeclaration(node: Node): boolean;
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration): HeritageClauseElement;
function getClassImplementsHeritageClauseElements(node: ClassDeclaration): NodeArray<HeritageClauseElement>;
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<HeritageClauseElement>;
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
function getAncestor(node: Node, kind: SyntaxKind): Node;
@@ -307,7 +307,7 @@ declare module "typescript" {
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string;
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void;
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number;
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration;
function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration;
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
firstAccessor: AccessorDeclaration;
@@ -318,11 +318,22 @@ declare module "typescript" {
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void;
function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void;
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void;
function isSupportedHeritageClauseElement(node: HeritageClauseElement): boolean;
function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean;
function getLocalSymbolForExportDefault(symbol: Symbol): Symbol;
}
declare module "typescript" {
var optionDeclarations: CommandLineOption[];
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module "typescript" {
+11 -6
View File
@@ -388,23 +388,28 @@ module ts {
bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true);
}
function bindBlockScopedVariableDeclaration(node: Declaration) {
function bindBlockScopedDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
switch (blockScopeContainer.kind) {
case SyntaxKind.ModuleDeclaration:
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
declareModuleMember(node, symbolKind, symbolExcludes);
break;
case SyntaxKind.SourceFile:
if (isExternalModule(<SourceFile>container)) {
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
declareModuleMember(node, symbolKind, symbolExcludes);
break;
}
// fall through.
default:
if (!blockScopeContainer.locals) {
blockScopeContainer.locals = {};
}
declareSymbol(blockScopeContainer.locals, undefined, node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes);
}
bindChildren(node, SymbolFlags.BlockScopedVariable, /*isBlockScopeContainer*/ false);
bindChildren(node, symbolKind, /*isBlockScopeContainer*/ false);
}
function bindBlockScopedVariableDeclaration(node: Declaration) {
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
}
function getDestructuringParameterName(node: Declaration) {
@@ -493,7 +498,7 @@ module ts {
bindCatchVariableDeclaration(<CatchClause>node);
break;
case SyntaxKind.ClassDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes, /*isBlockScopeContainer*/ false);
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
break;
case SyntaxKind.InterfaceDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false);
+22 -13
View File
@@ -74,7 +74,7 @@ module ts {
isImplementationOfOverload,
getAliasedSymbol: resolveAlias,
getEmitResolver,
getExportsOfExternalModule,
getExportsOfModule: getExportsOfModuleAsArray,
};
let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -349,6 +349,14 @@ module ts {
}
result = undefined;
}
else if (location.kind === SyntaxKind.SourceFile) {
result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & SymbolFlags.ModuleMember);
let localSymbol = getLocalSymbolForExportDefault(result);
if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) {
break loop;
}
result = undefined;
}
break;
case SyntaxKind.EnumDeclaration:
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) {
@@ -890,6 +898,10 @@ module ts {
return moduleSymbol.exports["export="];
}
function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] {
return symbolsToArray(getExportsOfModule(moduleSymbol));
}
function getExportsOfSymbol(symbol: Symbol): SymbolTable {
return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols;
}
@@ -1109,7 +1121,7 @@ module ts {
// Check if symbol is any of the alias
return forEachValue(symbols, symbolFromSymbolTable => {
if (symbolFromSymbolTable.flags & SymbolFlags.Alias) {
if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=") {
if (!useOnlyExternalAliasing || // We can use any type of alias to get the name
// Is this external alias, then use it to name
ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) {
@@ -1950,6 +1962,10 @@ module ts {
case SyntaxKind.SourceFile:
return true;
// Export assignements do not create name bindings outside the module
case SyntaxKind.ExportAssignment:
return false;
default:
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
}
@@ -3020,17 +3036,6 @@ module ts {
return result;
}
function getExportsOfExternalModule(node: ImportDeclaration): Symbol[] {
if (!node.moduleSpecifier) {
return emptyArray;
}
let module = resolveExternalModuleName(node, node.moduleSpecifier);
if (!module) {
return emptyArray;
}
return symbolsToArray(getExportsOfModule(module));
}
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
let links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
@@ -9755,6 +9760,10 @@ module ts {
grammarErrorOnNode(node, Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
}
if (!node.name && !(node.flags & NodeFlags.Default)) {
grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkGrammarClassDeclarationHeritageClauses(node);
checkDecorators(node);
if (node.name) {
+13 -1
View File
@@ -4,6 +4,7 @@
/// <reference path="scanner.ts"/>
module ts {
/* @internal */
export var optionDeclarations: CommandLineOption[] = [
{
name: "charset",
@@ -157,7 +158,8 @@ module ts {
description: Diagnostics.Watch_input_files,
}
];
/* @internal */
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
var options: CompilerOptions = {};
var fileNames: string[] = [];
@@ -267,6 +269,10 @@ module ts {
}
}
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
export function readConfigFile(fileName: string): any {
try {
var text = sys.readFile(fileName);
@@ -276,6 +282,12 @@ module ts {
}
}
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine {
var errors: Diagnostic[] = [];
@@ -167,6 +167,7 @@ module ts {
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1210, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
+4
View File
@@ -659,6 +659,10 @@
"category": "Error",
"code": 1209
},
"A class declaration without the 'default' modifier must have a name": {
"category": "Error",
"code": 1210
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
+1
View File
@@ -262,6 +262,7 @@ module ts {
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
generateNameForFunctionOrClassDeclaration(<Declaration>node);
break;
case SyntaxKind.ModuleDeclaration:
+1 -1
View File
@@ -4764,7 +4764,7 @@ module ts {
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.ClassKeyword);
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
node.name = parseOptionalIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause:*/ true);
+2 -2
View File
@@ -933,7 +933,7 @@ module ts {
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
// In rest of the cases, module specifier is string literal corresponding to module
// ImportClause information is shown at its declaration below.
export interface ImportDeclaration extends Statement, ModuleElement {
export interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -1146,7 +1146,7 @@ module ts {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
+11 -7
View File
@@ -145,7 +145,7 @@ module ts {
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
}
export function nodeIsPresent(node: Node) {
return !nodeIsMissing(node);
}
@@ -296,7 +296,7 @@ module ts {
errorNode = (<Declaration>node).name;
break;
}
if (errorNode === undefined) {
// If we don't have a better node, then just set the error on the first token of
// construct.
@@ -642,7 +642,7 @@ module ts {
return false;
}
export function childIsDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
@@ -754,7 +754,7 @@ module ts {
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
let moduleState = getModuleInstanceState(node)
return moduleState === ModuleInstanceState.Instantiated ||
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
}
export function isExternalModuleImportEqualsDeclaration(node: Node) {
@@ -1170,7 +1170,7 @@ module ts {
export function createTextSpanFromBounds(start: number, end: number) {
return createTextSpan(start, end - start);
}
export function textChangeRangeNewSpan(range: TextChangeRange) {
return createTextSpan(range.span.start, range.newLength);
}
@@ -1444,13 +1444,13 @@ module ts {
return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0));
}
}
function get16BitUnicodeEscapeSequence(charCode: number): string {
let hexCharCode = charCode.toString(16).toUpperCase();
let paddedHexCode = ("0000" + hexCharCode).slice(-4);
return "\\u" + paddedHexCode;
}
let nonAsciiCharacters = /[^\u0000-\u007F]/g;
export function escapeNonAsciiCharacters(s: string): string {
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
@@ -1799,4 +1799,8 @@ module ts {
return (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) ||
(node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node);
}
export function getLocalSymbolForExportDefault(symbol: Symbol) {
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
}
}
+4
View File
@@ -1466,6 +1466,10 @@ module ts.server {
return accum;
}
getLength(): number {
return this.root.charCount();
}
every(f: (ll: LineLeaf, s: number, len: number) => boolean, rangeStart: number, rangeEnd?: number) {
if (!rangeEnd) {
rangeEnd = this.root.charCount();
+3 -3
View File
@@ -418,10 +418,10 @@ module ts.NavigationBar {
}
function createFunctionItem(node: FunctionDeclaration) {
if ((node.name || node.flags & NodeFlags.Default) && node.body && node.body.kind === SyntaxKind.Block) {
if (node.body && node.body.kind === SyntaxKind.Block) {
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
return getNavigationBarItem((!node.name && node.flags & NodeFlags.Default) ? "default": node.name.text ,
return getNavigationBarItem(!node.name ? "default": node.name.text ,
ts.ScriptElementKind.functionElement,
getNodeModifiers(node),
[getNodeSpan(node)],
@@ -470,7 +470,7 @@ module ts.NavigationBar {
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
}
var nodeName = !node.name && (node.flags & NodeFlags.Default) ? "default" : node.name.text;
var nodeName = !node.name ? "default" : node.name.text;
return getNavigationBarItem(
nodeName,
+144 -121
View File
@@ -730,7 +730,7 @@ module ts {
public statements: NodeArray<Statement>;
public endOfFileToken: Node;
public amdDependencies: {name: string; path: string}[];
public amdDependencies: { name: string; path: string }[];
public amdModuleName: string;
public referencedFiles: FileReference[];
@@ -769,126 +769,131 @@ module ts {
public getNamedDeclarations() {
if (!this.namedDeclarations) {
let sourceFile = this;
let namedDeclarations: Declaration[] = [];
forEachChild(sourceFile, function visit(node: Node): void {
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
let functionDeclaration = <FunctionLikeDeclaration>node;
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
let lastDeclaration = namedDeclarations.length > 0 ?
namedDeclarations[namedDeclarations.length - 1] :
undefined;
// Check whether this declaration belongs to an "overload group".
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
// Overwrite the last declaration if it was an overload
// and this one is an implementation.
if (functionDeclaration.body && !(<FunctionLikeDeclaration>lastDeclaration).body) {
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
}
}
else {
namedDeclarations.push(functionDeclaration);
}
forEachChild(node, visit);
}
break;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportSpecifier:
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportClause:
case SyntaxKind.NamespaceImport:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.TypeLiteral:
if ((<Declaration>node).name) {
namedDeclarations.push(<Declaration>node);
}
// fall through
case SyntaxKind.Constructor:
case SyntaxKind.VariableStatement:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ModuleBlock:
forEachChild(node, visit);
break;
case SyntaxKind.Block:
if (isFunctionBlock(node)) {
forEachChild(node, visit);
}
break;
case SyntaxKind.Parameter:
// Only consider properties defined as constructor parameters
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
break;
}
// fall through
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
if (isBindingPattern((<VariableDeclaration>node).name)) {
forEachChild((<VariableDeclaration>node).name, visit);
break;
}
case SyntaxKind.EnumMember:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
namedDeclarations.push(<Declaration>node);
break;
case SyntaxKind.ExportDeclaration:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if ((<ExportDeclaration>node).exportClause) {
forEach((<ExportDeclaration>node).exportClause.elements, visit);
}
break;
case SyntaxKind.ImportDeclaration:
let importClause = (<ImportDeclaration>node).importClause;
if (importClause) {
// Handle default import case e.g.:
// import d from "mod";
if (importClause.name) {
namedDeclarations.push(importClause);
}
// Handle named bindings in imports e.g.:
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
namedDeclarations.push(<NamespaceImport>importClause.namedBindings);
}
else {
forEach((<NamedImports>importClause.namedBindings).elements, visit);
}
}
}
break;
}
});
this.namedDeclarations = namedDeclarations;
this.namedDeclarations = this.computeNamedDeclarations();
}
return this.namedDeclarations;
}
private computeNamedDeclarations() {
let namedDeclarations: Declaration[] = [];
forEachChild(this, visit);
return namedDeclarations;
function visit(node: Node): void {
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
let functionDeclaration = <FunctionLikeDeclaration>node;
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
let lastDeclaration = namedDeclarations.length > 0 ?
namedDeclarations[namedDeclarations.length - 1] :
undefined;
// Check whether this declaration belongs to an "overload group".
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
// Overwrite the last declaration if it was an overload
// and this one is an implementation.
if (functionDeclaration.body && !(<FunctionLikeDeclaration>lastDeclaration).body) {
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
}
}
else {
namedDeclarations.push(functionDeclaration);
}
forEachChild(node, visit);
}
break;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportSpecifier:
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportClause:
case SyntaxKind.NamespaceImport:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.TypeLiteral:
if ((<Declaration>node).name) {
namedDeclarations.push(<Declaration>node);
}
// fall through
case SyntaxKind.Constructor:
case SyntaxKind.VariableStatement:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ModuleBlock:
forEachChild(node, visit);
break;
case SyntaxKind.Block:
if (isFunctionBlock(node)) {
forEachChild(node, visit);
}
break;
case SyntaxKind.Parameter:
// Only consider properties defined as constructor parameters
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
break;
}
// fall through
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
if (isBindingPattern((<VariableDeclaration>node).name)) {
forEachChild((<VariableDeclaration>node).name, visit);
break;
}
case SyntaxKind.EnumMember:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
namedDeclarations.push(<Declaration>node);
break;
case SyntaxKind.ExportDeclaration:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if ((<ExportDeclaration>node).exportClause) {
forEach((<ExportDeclaration>node).exportClause.elements, visit);
}
break;
case SyntaxKind.ImportDeclaration:
let importClause = (<ImportDeclaration>node).importClause;
if (importClause) {
// Handle default import case e.g.:
// import d from "mod";
if (importClause.name) {
namedDeclarations.push(importClause);
}
// Handle named bindings in imports e.g.:
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
namedDeclarations.push(<NamespaceImport>importClause.namedBindings);
}
else {
forEach((<NamedImports>importClause.namedBindings).elements, visit);
}
}
}
break;
}
}
}
}
//
@@ -2623,6 +2628,14 @@ module ts {
function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string {
let displayName = symbol.getName();
if (displayName) {
// If this is the default export, get the name of the declaration if it exists
if (displayName === "default") {
let localSymbol = getLocalSymbolForExportDefault(symbol);
if (localSymbol && localSymbol.name) {
displayName = symbol.valueDeclaration.localSymbol.name;
}
}
let firstCharCode = displayName.charCodeAt(0);
// First check of the displayName is not external module; if it is an external module, it is not valid entry
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
@@ -2786,7 +2799,8 @@ module ts {
if (symbol && symbol.flags & SymbolFlags.HasExports) {
// Extract module or enum members
forEachValue(symbol.exports, symbol => {
let exportedSymbols = typeInfoResolver.getExportsOfModule(symbol);
forEach(exportedSymbols, symbol => {
if (typeInfoResolver.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
symbols.push(symbol);
}
@@ -2831,8 +2845,17 @@ module ts {
if (showCompletionsInImportsClause(contextToken)) {
let importDeclaration = <ImportDeclaration>getAncestor(contextToken, SyntaxKind.ImportDeclaration);
Debug.assert(importDeclaration !== undefined);
let exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration);
symbols = filterModuleExports(exports, importDeclaration);
let exports: Symbol[];
if (importDeclaration.moduleSpecifier) {
let moduleSpecifierSymbol = typeInfoResolver.getSymbolAtLocation(importDeclaration.moduleSpecifier);
if (moduleSpecifierSymbol) {
exports = typeInfoResolver.getExportsOfModule(moduleSpecifierSymbol);
}
}
//let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration);
symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray;
}
}
else {
@@ -2872,7 +2895,7 @@ module ts {
previousToken.getStart() :
position;
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile);
let scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
/// TODO filter meaning based on the current context
let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
+16 -2
View File
@@ -760,7 +760,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -902,7 +902,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -1504,6 +1504,20 @@ declare module "typescript" {
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -2307,9 +2307,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@@ -2818,10 +2817,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@@ -4838,6 +4837,27 @@ declare module "typescript" {
>CompilerHost : CompilerHost
>Program : Program
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
>readConfigFile : (fileName: string) => any
>fileName : string
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
>json : any
>basePath : string
>ParsedCommandLine : ParsedCommandLine
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
+16 -2
View File
@@ -791,7 +791,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -933,7 +933,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -1535,6 +1535,20 @@ declare module "typescript" {
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -2453,9 +2453,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@@ -2964,10 +2963,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@@ -4984,6 +4983,27 @@ declare module "typescript" {
>CompilerHost : CompilerHost
>Program : Program
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
>readConfigFile : (fileName: string) => any
>fileName : string
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
>json : any
>basePath : string
>ParsedCommandLine : ParsedCommandLine
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -2453,9 +2453,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@@ -2964,10 +2963,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@@ -4984,6 +4983,27 @@ declare module "typescript" {
>CompilerHost : CompilerHost
>Program : Program
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
>readConfigFile : (fileName: string) => any
>fileName : string
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
>json : any
>basePath : string
>ParsedCommandLine : ParsedCommandLine
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -792,7 +792,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -934,7 +934,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -1536,6 +1536,20 @@ declare module "typescript" {
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -2403,9 +2403,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@@ -2914,10 +2913,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@@ -4934,6 +4933,27 @@ declare module "typescript" {
>CompilerHost : CompilerHost
>Program : Program
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
>readConfigFile : (fileName: string) => any
>fileName : string
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
>json : any
>basePath : string
>ParsedCommandLine : ParsedCommandLine
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
+16 -2
View File
@@ -829,7 +829,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -971,7 +971,7 @@ declare module "typescript" {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
getAliasedSymbol(symbol: Symbol): Symbol;
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -1573,6 +1573,20 @@ declare module "typescript" {
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -2576,9 +2576,8 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
>ImportDeclaration : ImportDeclaration
>Statement : Statement
>ModuleElement : ModuleElement
importClause?: ImportClause;
@@ -3087,10 +3086,10 @@ declare module "typescript" {
>Symbol : Symbol
>Symbol : Symbol
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
>getExportsOfExternalModule : (node: ImportDeclaration) => Symbol[]
>node : ImportDeclaration
>ImportDeclaration : ImportDeclaration
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
>getExportsOfModule : (moduleSymbol: Symbol) => Symbol[]
>moduleSymbol : Symbol
>Symbol : Symbol
>Symbol : Symbol
}
interface SymbolDisplayBuilder {
@@ -5107,6 +5106,27 @@ declare module "typescript" {
>CompilerHost : CompilerHost
>Program : Program
}
declare module "typescript" {
/**
* Read tsconfig.json file
* @param fileName The path to the config file
*/
function readConfigFile(fileName: string): any;
>readConfigFile : (fileName: string) => any
>fileName : string
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
>parseConfigFile : (json: any, basePath?: string) => ParsedCommandLine
>json : any
>basePath : string
>ParsedCommandLine : ParsedCommandLine
}
declare module "typescript" {
/** The version of the language service API */
let servicesVersion: string;
@@ -0,0 +1,9 @@
tests/cases/compiler/anonymousClassExpression1.ts(2,19): error TS9003: 'class' expressions are not currently supported.
==== tests/cases/compiler/anonymousClassExpression1.ts (1 errors) ====
function f() {
return typeof class {} === "function";
~~~~~
!!! error TS9003: 'class' expressions are not currently supported.
}
@@ -0,0 +1,13 @@
//// [anonymousClassExpression1.ts]
function f() {
return typeof class {} === "function";
}
//// [anonymousClassExpression1.js]
function f() {
return typeof (function () {
function default_1() {
}
return default_1;
})() === "function";
}
@@ -0,0 +1,13 @@
tests/cases/compiler/classDeclarationBlockScoping1.ts(5,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
==== tests/cases/compiler/classDeclarationBlockScoping1.ts (1 errors) ====
class C {
}
{
class C {
~
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
}
}
@@ -0,0 +1,22 @@
//// [classDeclarationBlockScoping1.ts]
class C {
}
{
class C {
}
}
//// [classDeclarationBlockScoping1.js]
var C = (function () {
function C() {
}
return C;
})();
{
var C = (function () {
function C() {
}
return C;
})();
}
@@ -0,0 +1,18 @@
tests/cases/compiler/classDeclarationBlockScoping2.ts(2,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
tests/cases/compiler/classDeclarationBlockScoping2.ts(5,15): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
==== tests/cases/compiler/classDeclarationBlockScoping2.ts (2 errors) ====
function f() {
class C {}
~
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
var c1 = C;
{
class C {}
~
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
var c2 = C;
}
return C === c1;
}
@@ -0,0 +1,29 @@
//// [classDeclarationBlockScoping2.ts]
function f() {
class C {}
var c1 = C;
{
class C {}
var c2 = C;
}
return C === c1;
}
//// [classDeclarationBlockScoping2.js]
function f() {
var C = (function () {
function C() {
}
return C;
})();
var c1 = C;
{
var C = (function () {
function C() {
}
return C;
})();
var c2 = C;
}
return C === c1;
}
@@ -1,4 +1,4 @@
tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames2.ts(3,7): error TS1003: Identifier expected.
tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames2.ts(3,7): error TS1005: '{' expected.
==== tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames2.ts (1 errors) ====
@@ -6,4 +6,4 @@ tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsName
class void {}
~~~~
!!! error TS1003: Identifier expected.
!!! error TS1005: '{' expected.
@@ -5,9 +5,9 @@ class void {}
//// [classWithPredefinedTypesAsNames2.js]
// classes cannot use predefined types as names
var = (function () {
function () {
var default_1 = (function () {
function default_1() {
}
return ;
return default_1;
})();
void {};
@@ -42,23 +42,23 @@ module m2 {
}
var m2: {
>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; }
>m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; }
(): m2.connectExport;
>m2 : unknown
>connectExport : export=.connectExport
>connectExport : m2.connectExport
test1: m2.connectModule;
>test1 : export=.connectModule
>test1 : m2.connectModule
>m2 : unknown
>connectModule : export=.connectModule
>connectModule : m2.connectModule
test2(): m2.connectModule;
>test2 : () => export=.connectModule
>test2 : () => m2.connectModule
>m2 : unknown
>connectModule : export=.connectModule
>connectModule : m2.connectModule
};
export = m2;
>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; }
>m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; }
@@ -7,7 +7,7 @@ declare module "express" {
function express(): express.ExpressServer;
>express : typeof express
>express : unknown
>ExpressServer : export=.ExpressServer
>ExpressServer : express.ExpressServer
module express {
>express : typeof express
@@ -27,24 +27,24 @@ module m2 {
}
var m2: {
>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; }
>m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; }
(): m2.connectExport;
>m2 : unknown
>connectExport : export=.connectExport
>connectExport : m2.connectExport
test1: m2.connectModule;
>test1 : export=.connectModule
>test1 : m2.connectModule
>m2 : unknown
>connectModule : export=.connectModule
>connectModule : m2.connectModule
test2(): m2.connectModule;
>test2 : () => export=.connectModule
>test2 : () => m2.connectModule
>m2 : unknown
>connectModule : export=.connectModule
>connectModule : m2.connectModule
};
export = m2;
>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; }
>m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; }
@@ -28,24 +28,24 @@ module m2 {
var x = 10, m2: {
>x : number
>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; }
>m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; }
(): m2.connectExport;
>m2 : unknown
>connectExport : export=.connectExport
>connectExport : m2.connectExport
test1: m2.connectModule;
>test1 : export=.connectModule
>test1 : m2.connectModule
>m2 : unknown
>connectModule : export=.connectModule
>connectModule : m2.connectModule
test2(): m2.connectModule;
>test2 : () => export=.connectModule
>test2 : () => m2.connectModule
>m2 : unknown
>connectModule : export=.connectModule
>connectModule : m2.connectModule
};
export = m2;
>m2 : { (): export=.connectExport; test1: export=.connectModule; test2(): export=.connectModule; }
>m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; }
@@ -0,0 +1,35 @@
//// [es5ExportDefaultClassDeclaration3.ts]
var before: C = new C();
export default class C {
method(): C {
return new C();
}
}
var after: C = new C();
var t: typeof C = C;
//// [es5ExportDefaultClassDeclaration3.js]
var before = new C();
var C = (function () {
function C() {
}
C.prototype.method = function () {
return new C();
};
return C;
})();
exports.default = C;
var after = new C();
var t = C;
//// [es5ExportDefaultClassDeclaration3.d.ts]
export default class C {
method(): C;
}
@@ -0,0 +1,33 @@
=== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts ===
var before: C = new C();
>before : C
>C : C
>new C() : C
>C : typeof C
export default class C {
>C : C
method(): C {
>method : () => C
>C : C
return new C();
>new C() : C
>C : typeof C
}
}
var after: C = new C();
>after : C
>C : C
>new C() : C
>C : typeof C
var t: typeof C = C;
>t : typeof C
>C : typeof C
>C : typeof C
@@ -0,0 +1,21 @@
//// [es5ExportDefaultFunctionDeclaration3.ts]
var before: typeof func = func();
export default function func(): typeof func {
return func;
}
var after: typeof func = func();
//// [es5ExportDefaultFunctionDeclaration3.js]
var before = func();
function func() {
return func;
}
exports.default = func;
var after = func();
//// [es5ExportDefaultFunctionDeclaration3.d.ts]
export default function func(): typeof func;
@@ -0,0 +1,22 @@
=== tests/cases/compiler/es5ExportDefaultFunctionDeclaration3.ts ===
var before: typeof func = func();
>before : () => typeof func
>func : () => typeof func
>func() : () => typeof func
>func : () => typeof func
export default function func(): typeof func {
>func : () => typeof func
>func : () => typeof func
return func;
>func : () => typeof func
}
var after: typeof func = func();
>after : () => typeof func
>func : () => typeof func
>func() : () => typeof func
>func : () => typeof func
@@ -0,0 +1,37 @@
//// [es5ExportEqualsDts.ts]
class A {
foo() {
var aVal: A.B;
return aVal;
}
}
module A {
export interface B { }
}
export = A
//// [es5ExportEqualsDts.js]
var A = (function () {
function A() {
}
A.prototype.foo = function () {
var aVal;
return aVal;
};
return A;
})();
module.exports = A;
//// [es5ExportEqualsDts.d.ts]
declare class A {
foo(): A.B;
}
declare module A {
interface B {
}
}
export = A;
@@ -0,0 +1,28 @@
=== tests/cases/compiler/es5ExportEqualsDts.ts ===
class A {
>A : A
foo() {
>foo : () => A.B
var aVal: A.B;
>aVal : A.B
>A : unknown
>B : A.B
return aVal;
>aVal : A.B
}
}
module A {
>A : typeof A
export interface B { }
>B : B
}
export = A
>A : A
@@ -22,9 +22,9 @@ class Foo {
>Foo : Foo
x: Foo.Bar;
>x : export=.Bar
>x : Foo.Bar
>Foo : unknown
>Bar : export=.Bar
>Bar : Foo.Bar
}
module Foo {
>Foo : typeof Foo
@@ -12,7 +12,7 @@ interface server {
(): server.Server;
>server : unknown
>Server : export=.Server
>Server : server.Server
startTime: Date;
>startTime : Date
@@ -8,9 +8,13 @@ tests/cases/compiler/externModule.ts(18,6): error TS2390: Constructor implementa
tests/cases/compiler/externModule.ts(20,13): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/externModule.ts(26,13): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/externModule.ts(28,13): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/externModule.ts(32,11): error TS2304: Cannot find name 'XDate'.
tests/cases/compiler/externModule.ts(34,7): error TS2304: Cannot find name 'XDate'.
tests/cases/compiler/externModule.ts(36,7): error TS2304: Cannot find name 'XDate'.
tests/cases/compiler/externModule.ts(37,3): error TS2304: Cannot find name 'XDate'.
==== tests/cases/compiler/externModule.ts (10 errors) ====
==== tests/cases/compiler/externModule.ts (14 errors) ====
declare module {
~~~~~~~
!!! error TS2304: Cannot find name 'declare'.
@@ -63,10 +67,18 @@ tests/cases/compiler/externModule.ts(28,13): error TS2391: Function implementati
}
var d=new XDate();
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
d.getDay();
d=new XDate(1978,2);
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
d.getXDate();
var n=XDate.parse("3/2/2004");
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
n=XDate.UTC(1964,2,1);
~~~~~
!!! error TS2304: Cannot find name 'XDate'.
@@ -1,4 +1,4 @@
tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPredefinedTypesAsName2.ts(3,7): error TS1003: Identifier expected.
tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPredefinedTypesAsName2.ts(3,7): error TS1005: '{' expected.
==== tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPredefinedTypesAsName2.ts (1 errors) ====
@@ -6,4 +6,4 @@ tests/cases/conformance/types/specifyingTypes/predefinedTypes/objectTypesWithPre
class void {} // parse error unlike the others
~~~~
!!! error TS1003: Identifier expected.
!!! error TS1005: '{' expected.
@@ -5,9 +5,9 @@ class void {} // parse error unlike the others
//// [objectTypesWithPredefinedTypesAsName2.js]
// it is an error to use a predefined type as a type name
var = (function () {
function () {
var default_1 = (function () {
function default_1() {
}
return ;
return default_1;
})();
void {}; // parse error unlike the others
@@ -1,6 +1,6 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(1,5): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(3,5): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(3,10): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts(3,10): error TS1005: '{' expected.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInvalidIdentifiersInVariableStatements1.ts (3 errors) ====
@@ -12,6 +12,6 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/VariableLists/parserInv
~~~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1003: Identifier expected.
!!! error TS1005: '{' expected.
var bar;
@@ -9,10 +9,10 @@ var bar;
var ;
var foo;
var ;
var = (function () {
function () {
var default_1 = (function () {
function default_1() {
}
return ;
return default_1;
})();
;
var bar;
@@ -12,9 +12,9 @@ interface Foo<T> {
>T : T
}
var Foo: new () => Foo.A<Foo<string>>;
>Foo : new () => export=.A<Foo<string>>
>Foo : new () => Foo.A<Foo<string>>
>Foo : unknown
>A : export=.A<T>
>A : Foo.A<T>
>Foo : Foo<T>
export = Foo;
@@ -0,0 +1,3 @@
function f() {
return typeof class {} === "function";
}
@@ -0,0 +1,7 @@
class C {
}
{
class C {
}
}
@@ -0,0 +1,9 @@
function f() {
class C {}
var c1 = C;
{
class C {}
var c2 = C;
}
return C === c1;
}
@@ -0,0 +1,16 @@
// @target: es5
// @module: commonjs
// @declaration: true
var before: C = new C();
export default class C {
method(): C {
return new C();
}
}
var after: C = new C();
var t: typeof C = C;
@@ -0,0 +1,11 @@
// @target: es5
// @module: commonjs
// @declaration: true
var before: typeof func = func();
export default function func(): typeof func {
return func;
}
var after: typeof func = func();
@@ -0,0 +1,16 @@
// @target: es5
// @module: commonjs
// @declaration: true
class A {
foo() {
var aVal: A.B;
return aVal;
}
}
module A {
export interface B { }
}
export = A
@@ -0,0 +1,39 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x = c./**/
goTo.marker();
verify.completionListContains("C1");
verify.completionListContains("Inner");
verify.completionListContains("bVar");
verify.completionListContains("cVar");
verify.not.completionListContains("__export");
@@ -0,0 +1,39 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x = c.Inner./**/
goTo.marker();
verify.completionListContains("varVar");
verify.completionListContains("letVar");
verify.completionListContains("constVar");
verify.not.completionListContains("__export");
@@ -0,0 +1,40 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x: c./**/
goTo.marker();
verify.completionListContains("I1");
verify.completionListContains("I2");
verify.completionListContains("I1_OR_I2");
verify.completionListContains("C1");
verify.not.completionListContains("__export");
@@ -0,0 +1,37 @@
///<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "A";
////export * from "B"
// @Filename: D.ts
////import * as c from "C";
////var x: c.Inner./**/
goTo.marker();
verify.completionListContains("I3");
verify.not.completionListContains("__export");
@@ -0,0 +1,12 @@
/// <reference path='./fourslash.ts'/>
////export default class C {
//// method() { /*1*/ }
////}
//// /*2*/
goTo.marker('1');
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
goTo.marker('2');
verify.completionListContains("C", "class C", /*documentation*/ undefined, "class");
@@ -0,0 +1,12 @@
/// <reference path='./fourslash.ts'/>
////export default function func() {
//// /*1*/
////}
//// /*2*/
goTo.marker('1');
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");
goTo.marker('2');
verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function");
@@ -8,5 +8,5 @@ edit.insertLine("module A");
edit.insert("export class ");
// should not crash
verify.getScriptLexicalStructureListCount(1);
verify.getScriptLexicalStructureListCount(2);
@@ -8,4 +8,4 @@
// The class is unnamed, so its method is not included either.
verify.getScriptLexicalStructureListCount(0);
verify.getScriptLexicalStructureListCount(2);
+279
View File
@@ -0,0 +1,279 @@
/// <reference path="..\..\..\src\harness\harness.ts" />
/// <reference path="..\..\..\src\server\editorServices.ts" />
module ts {
function editFlat(position: number, deletedLength: number, newText: string, source: string) {
return source.substring(0, position) + newText + source.substring(position + deletedLength, source.length);
}
function lineColToPosition(lineIndex: server.LineIndex, line: number, col: number) {
var lineInfo = lineIndex.lineNumberToInfo(line);
return (lineInfo.offset + col - 1);
}
function validateEdit(lineIndex: server.LineIndex, sourceText: string, position: number, deleteLength: number, insertString: string): void {
let checkText = editFlat(position, deleteLength, insertString, sourceText);
let snapshot = lineIndex.edit(position, deleteLength, insertString);
let editedText = snapshot.getText(0, snapshot.getLength());
assert.equal(editedText, checkText);
}
describe('VersionCache TS code', () => {
var testContent = `/// <reference path="z.ts" />
var x = 10;
var y = { zebra: 12, giraffe: "ell" };
z.a;
class Point {
x: number;
}
k=y;
var p:Point=new Point();
var q:Point=<Point>p;`
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
function validateEditAtLineCharIndex(line: number, char: number, deleteLength: number, insertString: string): void {
let position = lineColToPosition(lineIndex, line, char);
validateEdit(lineIndex, testContent, position, deleteLength, insertString);
}
it('change 9 1 0 1 {"y"}', () => {
validateEditAtLineCharIndex(9, 1, 0, "y");
});
it('change 9 2 0 1 {"."}', () => {
validateEditAtLineCharIndex(9, 2, 0, ".");
});
it('change 9 3 0 1 {"\\n"}', () => {
validateEditAtLineCharIndex(9, 3, 0, "\n");
});
it('change 10 1 0 10 {"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n"}', () => {
validateEditAtLineCharIndex(10, 1, 0, "\n\n\n\n\n\n\n\n\n\n");
});
it('change 19 1 1 0', () => {
validateEditAtLineCharIndex(19, 1, 1, "");
});
it('change 18 1 1 0', () => {
validateEditAtLineCharIndex(18, 1, 1, "");
});
});
describe('VersionCache simple text', () => {
let testContent = `in this story:
the lazy brown fox
jumped over the cow
that ate the grass
that was purple at the tips
and grew 1cm per day`;
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
function validateEditAtPosition(position: number, deleteLength: number, insertString: string): void {
validateEdit(lineIndex, testContent, position, deleteLength, insertString);
}
it('Insert at end of file', () => {
validateEditAtPosition(testContent.length, 0, "hmmmm...\r\n");
});
it('Unusual line endings merge', () => {
validateEditAtPosition(lines[0].length - 1, lines[1].length, "");
});
it('Delete whole line and nothing but line (last line)', () => {
validateEditAtPosition(lineMap[lineMap.length - 2], lines[lines.length - 1].length, "");
});
it('Delete whole line and nothing but line (first line)', () => {
validateEditAtPosition(0, lines[0].length, "");
});
it('Delete whole line (first line) and insert with no line breaks', () => {
validateEditAtPosition(0, lines[0].length, "moo, moo, moo! ");
});
it('Delete whole line (first line) and insert with multiple line breaks', () => {
validateEditAtPosition(0, lines[0].length, "moo, \r\nmoo, \r\nmoo! ");
});
it('Delete multiple lines and nothing but lines (first and second lines)', () => {
validateEditAtPosition(0, lines[0].length + lines[1].length, "");
});
it('Delete multiple lines and nothing but lines (second and third lines)', () => {
validateEditAtPosition(lines[0].length, lines[1].length + lines[2].length, "");
});
it('Insert multiple line breaks', () => {
validateEditAtPosition(21, 1, "cr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr...\r\ncr");
});
it('Insert multiple line breaks', () => {
validateEditAtPosition(21, 1, "cr...\r\ncr...\r\ncr");
});
it('Insert multiple line breaks with leading \\n', () => {
validateEditAtPosition(21, 1, "\ncr...\r\ncr...\r\ncr");
});
it('Single line no line breaks deleted or inserted, delete 1 char', () => {
validateEditAtPosition(21, 1, "");
});
it('Single line no line breaks deleted or inserted, insert 1 char', () => {
validateEditAtPosition(21, 0, "b");
});
it('Single line no line breaks deleted or inserted, delete 1, insert 2 chars', () => {
validateEditAtPosition(21, 1, "cr");
});
it('Delete across line break (just the line break)', () => {
validateEditAtPosition(21, 22, "");
});
it('Delete across line break', () => {
validateEditAtPosition(21, 32, "");
});
it('Delete across multiple line breaks and insert no line breaks', () => {
validateEditAtPosition(21, 42, "");
});
it('Delete across multiple line breaks and insert text', () => {
validateEditAtPosition(21, 42, "slithery ");
});
});
describe('VersionCache stress test', () => {
const iterationCount = 20;
//const interationCount = 20000; // uncomment for testing
// Use scanner.ts, decent size, does not change frequentlly
let testFileName = "src/compiler/scanner.ts";
let testContent = Harness.IO.readFile(testFileName);
let totalChars = testContent.length;
assert.isTrue(totalChars > 0, "Failed to read test file.");
let {lines, lineMap} = server.LineIndex.linesFromText(testContent);
assert.isTrue(lines.length > 0, "Failed to initialize test text. Expected text to have at least one line");
let lineIndex = new server.LineIndex();
lineIndex.load(lines);
let rsa: number[] = [];
let la: number[] = [];
let las: number[] = [];
let elas: number[] = [];
let ersa: number[] = [];
let ela: number[] = [];
let etotalChars = totalChars;
for (let j = 0; j < 100000; j++) {
rsa[j] = Math.floor(Math.random() * totalChars);
la[j] = Math.floor(Math.random() * (totalChars - rsa[j]));
if (la[j] > 4) {
las[j] = 4;
}
else {
las[j] = la[j];
}
if (j < 4000) {
ersa[j] = Math.floor(Math.random() * etotalChars);
ela[j] = Math.floor(Math.random() * (etotalChars - ersa[j]));
if (ela[j] > 4) {
elas[j] = 4;
}
else {
elas[j] = ela[j];
}
etotalChars += (las[j] - elas[j]);
}
}
it("Range (average length 1/4 file size)", () => {
for (let i = 0; i < iterationCount; i++) {
let s2 = lineIndex.getText(rsa[i], la[i]);
let s1 = testContent.substring(rsa[i], rsa[i] + la[i]);
assert.equal(s1, s2);
}
});
it("Range (average length 4 chars)", () => {
for (let j = 0; j < iterationCount; j++) {
let s2 = lineIndex.getText(rsa[j], las[j]);
let s1 = testContent.substring(rsa[j], rsa[j] + las[j]);
assert.equal(s1, s2);
}
});
it("Edit (average length 4)", () => {
for (let i = 0; i < iterationCount; i++) {
let insertString = testContent.substring(rsa[100000 - i], rsa[100000 - i] + las[100000 - i]);
let snapshot = lineIndex.edit(rsa[i], las[i], insertString);
let checkText = editFlat(rsa[i], las[i], insertString, testContent);
let snapText = snapshot.getText(0, checkText.length);
assert.equal(checkText, snapText);
}
});
it("Edit ScriptVersionCache ", () => {
let svc = server.ScriptVersionCache.fromString(testContent);
let checkText = testContent;
for (let i = 0; i < iterationCount; i++) {
let insertString = testContent.substring(rsa[i], rsa[i] + las[i]);
svc.edit(ersa[i], elas[i], insertString);
checkText = editFlat(ersa[i], elas[i], insertString, checkText);
if (0 == (i % 4)) {
let snap = svc.getSnapshot();
let snapText = snap.getText(0, checkText.length);
assert.equal(checkText, snapText);
}
}
});
it("Edit (average length 1/4th file size)", () => {
for (let i = 0; i < iterationCount; i++) {
let insertString = testContent.substring(rsa[100000 - i], rsa[100000 - i] + la[100000 - i]);
let snapshot = lineIndex.edit(rsa[i], la[i], insertString);
let checkText = editFlat(rsa[i], la[i], insertString, testContent);
let snapText = snapshot.getText(0, checkText.length);
assert.equal(checkText, snapText);
}
});
it("Line/offset from pos", () => {
for (let i = 0; i < iterationCount; i++) {
let lp = lineIndex.charOffsetToLineNumberAndPos(rsa[i]);
let lac = ts.computeLineAndCharacterOfPosition(lineMap, rsa[i]);
assert.equal(lac.line + 1, lp.line, "Line number mismatch " + (lac.line + 1) + " " + lp.line + " " + i);
assert.equal(lac.character, (lp.offset), "Charachter offset mismatch " + lac.character + " " + lp.offset + " " + i);
}
});
it("Start pos from line", () => {
for (let i = 0; i < iterationCount; i++) {
for (let j = 0, llen = lines.length; j < llen; j++) {
let lineInfo = lineIndex.lineNumberToInfo(j + 1);
let lineIndexOffset = lineInfo.offset;
let lineMapOffset = lineMap[j];
assert.equal(lineIndexOffset, lineMapOffset);
}
}
});
});
}