Merge branch 'master' into jsSigHelp

Conflicts:
	src/services/outliningElementsCollector.ts
	src/services/services.ts
This commit is contained in:
Cyrus Najmabadi
2015-04-14 14:22:48 -07:00
2954 changed files with 133069 additions and 110783 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ Your pull request should:
* Tests should include reasonable permutations of the target fix/change
* Include baseline changes with your change
* All changed code must have 100% code coverage
* Follow the code conventions descriped in [Coding guidlines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidlines)
* Follow the code conventions descriped in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
## Running the Tests
+15 -61
View File
@@ -105,24 +105,6 @@ var serverSources = [
return path.join(serverDirectory, f);
});
var definitionsRoots = [
"compiler/types.d.ts",
"compiler/scanner.d.ts",
"compiler/parser.d.ts",
"compiler/checker.d.ts",
"compiler/program.d.ts",
"compiler/commandLineParser.d.ts",
"services/services.d.ts",
];
var internalDefinitionsRoots = [
"compiler/core.d.ts",
"compiler/sys.d.ts",
"compiler/utilities.d.ts",
"compiler/commandLineParser.d.ts",
"services/utilities.d.ts",
];
var harnessSources = [
"harness.ts",
"sourceMapRecorder.ts",
@@ -354,60 +336,32 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
/*prefixes*/ [copyright],
/*useBuiltCompiler*/ true,
/*noOutFile*/ false,
/*generateDeclarations*/ false,
/*generateDeclarations*/ true,
/*outDir*/ undefined,
/*preserveConstEnums*/ true,
/*keepComments*/ false,
/*keepComments*/ true,
/*noResolve*/ false,
/*stripInternal*/ false,
/*stripInternal*/ true,
/*callback*/ function () {
jake.cpR(servicesFile, nodePackageFile, {silent: true});
prependFile(copyright, standaloneDefinitionsFile);
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"');
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
});
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
var internalNodeDefinitionsFile = path.join(builtLocalDirectory, "typescript_internal.d.ts");
var internalStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices_internal.d.ts");
var tempDirPath = path.join(builtLocalDirectory, "temptempdir");
compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
/*prefixes*/ undefined,
/*useBuiltCompiler*/ true,
/*noOutFile*/ true,
/*generateDeclarations*/ true,
/*outDir*/ tempDirPath,
/*preserveConstEnums*/ true,
/*keepComments*/ true,
/*noResolve*/ true,
/*stripInternal*/ true,
/*callback*/ function () {
function makeDefinitionFiles(definitionsRoots, standaloneDefinitionsFile, nodeDefinitionsFile) {
// Create the standalone definition file
concatenateFiles(standaloneDefinitionsFile, definitionsRoots.map(function (f) {
return path.join(tempDirPath, f);
}));
prependFile(copyright, standaloneDefinitionsFile);
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"');
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
}
// Create the public definition files
makeDefinitionFiles(definitionsRoots, standaloneDefinitionsFile, nodeDefinitionsFile);
// Create the internal definition files
makeDefinitionFiles(internalDefinitionsRoots, internalStandaloneDefinitionsFile, internalNodeDefinitionsFile);
// Delete the temp dir
jake.rmRf(tempDirPath, {silent: true});
});
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
@@ -469,7 +423,7 @@ task("generate-spec", [specMd])
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
desc("Makes a new LKG out of the built js files");
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, internalNodeDefinitionsFile, internalStandaloneDefinitionsFile].concat(libraryTargets);
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile].concat(libraryTargets);
var missingFiles = expectedFiles.filter(function (f) {
return !fs.existsSync(f);
});
+2 -2
View File
@@ -838,7 +838,7 @@ interface RegExp {
*/
test(string: string): boolean;
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
source: string;
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
@@ -1183,4 +1183,4 @@ interface TypedPropertyDescriptor<T> {
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
+39 -32
View File
@@ -838,7 +838,7 @@ interface RegExp {
*/
test(string: string): boolean;
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
source: string;
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
@@ -1183,7 +1183,7 @@ interface TypedPropertyDescriptor<T> {
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
declare type PropertyKey = string | number | symbol;
interface Symbol {
@@ -1236,26 +1236,21 @@ interface SymbolConstructor {
*/
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
* for-of statement.
*/
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
* abstract operation.
*/
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
toStringTag: symbol;
@@ -1297,7 +1292,7 @@ interface ObjectConstructor {
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
@@ -1784,8 +1779,6 @@ interface Math {
}
interface RegExp {
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
* that search.
@@ -1817,6 +1810,20 @@ interface RegExp {
*/
split(string: string, limit?: number): string[];
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
@@ -4699,27 +4706,27 @@ interface ProxyHandler<T> {
interface ProxyConstructor {
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T>(target: T, handeler: ProxyHandler<T>): T
new <T>(target: T, handler: ProxyHandler<T>): T
}
declare var Proxy: ProxyConstructor;
declare var Reflect: {
apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
construct(target: Function, argumentsList: ArrayLike<any>): any;
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
deleteProperty(target: any, propertyKey: PropertyKey): boolean;
enumerate(target: any): IterableIterator<any>;
get(target: any, propertyKey: PropertyKey, receiver?: any): any;
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
getPrototypeOf(target: any): any;
has(target: any, propertyKey: string): boolean;
has(target: any, propertyKey: symbol): boolean;
isExtensible(target: any): boolean;
ownKeys(target: any): Array<PropertyKey>;
preventExtensions(target: any): boolean;
set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
setPrototypeOf(target: any, proto: any): boolean;
};
declare module Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): IterableIterator<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: string): boolean;
function has(target: any, propertyKey: symbol): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}
/**
* Represents the completion of an asynchronous operation
+2 -2
View File
@@ -838,7 +838,7 @@ interface RegExp {
*/
test(string: string): boolean;
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
source: string;
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
@@ -1183,7 +1183,7 @@ interface TypedPropertyDescriptor<T> {
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
/////////////////////////////
/// IE10 ECMAScript Extensions
+39 -32
View File
@@ -838,7 +838,7 @@ interface RegExp {
*/
test(string: string): boolean;
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
source: string;
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
@@ -1183,7 +1183,7 @@ interface TypedPropertyDescriptor<T> {
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
declare type PropertyKey = string | number | symbol;
interface Symbol {
@@ -1236,26 +1236,21 @@ interface SymbolConstructor {
*/
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
* for-of statement.
*/
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
* abstract operation.
*/
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
toStringTag: symbol;
@@ -1297,7 +1292,7 @@ interface ObjectConstructor {
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
@@ -1784,8 +1779,6 @@ interface Math {
}
interface RegExp {
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
* that search.
@@ -1817,6 +1810,20 @@ interface RegExp {
*/
split(string: string, limit?: number): string[];
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
@@ -4699,27 +4706,27 @@ interface ProxyHandler<T> {
interface ProxyConstructor {
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T>(target: T, handeler: ProxyHandler<T>): T
new <T>(target: T, handler: ProxyHandler<T>): T
}
declare var Proxy: ProxyConstructor;
declare var Reflect: {
apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
construct(target: Function, argumentsList: ArrayLike<any>): any;
defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
deleteProperty(target: any, propertyKey: PropertyKey): boolean;
enumerate(target: any): IterableIterator<any>;
get(target: any, propertyKey: PropertyKey, receiver?: any): any;
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
getPrototypeOf(target: any): any;
has(target: any, propertyKey: string): boolean;
has(target: any, propertyKey: symbol): boolean;
isExtensible(target: any): boolean;
ownKeys(target: any): Array<PropertyKey>;
preventExtensions(target: any): boolean;
set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
setPrototypeOf(target: any, proto: any): boolean;
};
declare module Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): IterableIterator<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: string): boolean;
function has(target: any, propertyKey: symbol): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}
/**
* Represents the completion of an asynchronous operation
+2430 -6593
View File
File diff suppressed because one or more lines are too long
+1942 -1294
View File
File diff suppressed because it is too large Load Diff
+103 -350
View File
@@ -295,34 +295,12 @@ declare module "typescript" {
AccessibilityModifier = 112,
BlockScoped = 12288,
}
const enum ParserContextFlags {
StrictMode = 1,
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
Failed = 2,
FailedAndReported = 3,
}
interface Node extends TextRange {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
symbol?: Symbol;
locals?: SymbolTable;
nextContainer?: Node;
localSymbol?: Symbol;
}
interface NodeArray<T> extends Array<T>, TextRange {
hasTrailingComma?: boolean;
@@ -723,7 +701,7 @@ declare module "typescript" {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -751,14 +729,14 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression?: Expression;
type?: TypeNode;
expression: Expression;
}
interface FileReference extends TextRange {
fileName: string;
}
interface CommentRange extends TextRange {
hasTrailingNewLine?: boolean;
kind: SyntaxKind;
}
interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
@@ -772,9 +750,7 @@ declare module "typescript" {
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node;
languageVersion: ScriptTarget;
identifiers: Map<string>;
}
interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
@@ -785,6 +761,9 @@ declare module "typescript" {
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
}
interface Program extends ScriptReferenceHost {
/**
* Get a list of files in the program
*/
getSourceFiles(): SourceFile[];
/**
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
@@ -801,15 +780,23 @@ declare module "typescript" {
getGlobalDiagnostics(): Diagnostic[];
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
/**
* Gets a type checker that can be used to semantically analyze source fils in the program.
*/
getTypeChecker(): TypeChecker;
getCommonSourceDirectory(): string;
}
interface SourceMapSpan {
/** Line number in the .js file. */
emittedLine: number;
/** Column number in the .js file. */
emittedColumn: number;
/** Line number in the .ts file. */
sourceLine: number;
/** Column number in the .ts file. */
sourceColumn: number;
/** Optional name (index into names array) associated with this span. */
nameIndex?: number;
/** .ts file (index into sources array) associated with this span */
sourceIndex: number;
}
interface SourceMapData {
@@ -823,6 +810,7 @@ declare module "typescript" {
sourceMapMappings: string;
sourceMapDecodedMappings: SourceMapSpan[];
}
/** Return code used by getEmitOutput function to indicate status of the function */
enum ExitStatus {
Success = 0,
DiagnosticsPresent_OutputsSkipped = 1,
@@ -831,7 +819,6 @@ declare module "typescript" {
interface EmitResult {
emitSkipped: boolean;
diagnostics: Diagnostic[];
sourceMaps: SourceMapData[];
}
interface TypeCheckerHost {
getCompilerOptions(): CompilerOptions;
@@ -865,7 +852,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;
@@ -908,40 +895,6 @@ declare module "typescript" {
WriteTypeParametersOrArguments = 1,
UseOnlyExternalAliasing = 2,
}
const enum SymbolAccessibility {
Accessible = 0,
NotAccessible = 1,
CannotBeNamed = 2,
}
type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
interface SymbolVisibilityResult {
accessibility: SymbolAccessibility;
aliasesToMakeVisible?: AnyImportSyntax[];
errorSymbolName?: string;
errorNode?: Node;
}
interface SymbolAccessiblityResult extends SymbolVisibilityResult {
errorModuleName?: string;
}
interface EmitResolver {
hasGlobalName(name: string): boolean;
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
isValueAliasDeclaration(node: Node): boolean;
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
getNodeCheckFlags(node: Node): NodeCheckFlags;
isDeclarationVisible(node: Declaration): boolean;
collectLinkedAliases(node: Identifier): Node[];
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
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 | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
BlockScopedVariable = 2,
@@ -1011,57 +964,14 @@ declare module "typescript" {
interface Symbol {
flags: SymbolFlags;
name: string;
id?: number;
mergeId?: number;
declarations?: Declaration[];
parent?: Symbol;
members?: SymbolTable;
exports?: SymbolTable;
exportSymbol?: Symbol;
valueDeclaration?: Declaration;
constEnumOnlyModule?: boolean;
}
interface SymbolLinks {
target?: Symbol;
type?: Type;
declaredType?: Type;
mapper?: TypeMapper;
referenced?: boolean;
unionType?: UnionType;
resolvedExports?: SymbolTable;
exportsChecked?: boolean;
}
interface TransientSymbol extends Symbol, SymbolLinks {
}
interface SymbolTable {
[index: string]: Symbol;
}
const enum NodeCheckFlags {
TypeChecked = 1,
LexicalThis = 2,
CaptureThis = 4,
EmitExtends = 8,
SuperInstance = 16,
SuperStatic = 32,
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;
resolvedSignature?: Signature;
resolvedSymbol?: Symbol;
flags?: NodeCheckFlags;
enumMemberValue?: number;
isIllegalTypeReferenceInConstraint?: boolean;
isVisible?: boolean;
generatedName?: string;
generatedNames?: Map<string>;
assignmentChecks?: Map<boolean>;
hasReportedStatementInAmbientContext?: boolean;
importOnRightSide?: Symbol;
}
const enum TypeFlags {
Any = 1,
String = 2,
@@ -1079,26 +989,16 @@ declare module "typescript" {
Tuple = 8192,
Union = 16384,
Anonymous = 32768,
FromSignature = 65536,
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
RequiresWidening = 786432,
}
interface Type {
flags: TypeFlags;
id: number;
symbol?: Symbol;
}
interface IntrinsicType extends Type {
intrinsicName: string;
}
interface StringLiteralType extends Type {
text: string;
}
@@ -1118,7 +1018,6 @@ declare module "typescript" {
typeArguments: Type[];
}
interface GenericType extends InterfaceType, TypeReference {
instantiations: Map<TypeReference>;
}
interface TupleType extends ObjectType {
elementTypes: Type[];
@@ -1126,20 +1025,9 @@ declare module "typescript" {
}
interface UnionType extends Type {
types: Type[];
resolvedProperties: SymbolTable;
}
interface ResolvedType extends ObjectType, UnionType {
members: SymbolTable;
properties: Symbol[];
callSignatures: Signature[];
constructSignatures: Signature[];
stringIndexType: Type;
numberIndexType: Type;
}
interface TypeParameter extends Type {
constraint: Type;
target?: TypeParameter;
mapper?: TypeMapper;
}
const enum SignatureKind {
Call = 0,
@@ -1149,28 +1037,22 @@ declare module "typescript" {
declaration: SignatureDeclaration;
typeParameters: TypeParameter[];
parameters: Symbol[];
resolvedReturnType: Type;
minArgumentCount: number;
hasRestParameter: boolean;
hasStringLiterals: boolean;
target?: Signature;
mapper?: TypeMapper;
unionSignatures?: Signature[];
erasedSignatureCache?: Signature;
isolatedSignatureType?: ObjectType;
}
const enum IndexKind {
String = 0,
Number = 1,
}
interface TypeMapper {
(t: Type): Type;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
code: number;
}
/**
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
* It is built from the bottom up, leaving the head to be the "main" diagnostic.
* While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage,
* the difference is that messages are all preformatted in DMC.
*/
interface DiagnosticMessageChain {
messageText: string;
category: DiagnosticCategory;
@@ -1219,6 +1101,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1241,142 +1124,6 @@ declare module "typescript" {
fileNames: string[];
errors: Diagnostic[];
}
interface CommandLineOption {
name: string;
type: string | Map<number>;
isFilePath?: boolean;
shortName?: string;
description?: DiagnosticMessage;
paramType?: DiagnosticMessage;
error?: DiagnosticMessage;
experimental?: boolean;
}
const enum CharacterCodes {
nullCharacter = 0,
maxAsciiCharacter = 127,
lineFeed = 10,
carriageReturn = 13,
lineSeparator = 8232,
paragraphSeparator = 8233,
nextLine = 133,
space = 32,
nonBreakingSpace = 160,
enQuad = 8192,
emQuad = 8193,
enSpace = 8194,
emSpace = 8195,
threePerEmSpace = 8196,
fourPerEmSpace = 8197,
sixPerEmSpace = 8198,
figureSpace = 8199,
punctuationSpace = 8200,
thinSpace = 8201,
hairSpace = 8202,
zeroWidthSpace = 8203,
narrowNoBreakSpace = 8239,
ideographicSpace = 12288,
mathematicalSpace = 8287,
ogham = 5760,
_ = 95,
$ = 36,
_0 = 48,
_1 = 49,
_2 = 50,
_3 = 51,
_4 = 52,
_5 = 53,
_6 = 54,
_7 = 55,
_8 = 56,
_9 = 57,
a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
ampersand = 38,
asterisk = 42,
at = 64,
backslash = 92,
backtick = 96,
bar = 124,
caret = 94,
closeBrace = 125,
closeBracket = 93,
closeParen = 41,
colon = 58,
comma = 44,
dot = 46,
doubleQuote = 34,
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
openBracket = 91,
openParen = 40,
percent = 37,
plus = 43,
question = 63,
semicolon = 59,
singleQuote = 39,
slash = 47,
tilde = 126,
backspace = 8,
formFeed = 12,
byteOrderMark = 65279,
tab = 9,
verticalTab = 11,
}
interface CancellationToken {
isCancellationRequested(): boolean;
}
@@ -1400,49 +1147,39 @@ declare module "typescript" {
}
}
declare module "typescript" {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
interface System {
args: string[];
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string) => void): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
createDirectory(path: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
readDirectory(path: string, extension?: string): string[];
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
getTextPos(): number;
getTokenPos(): number;
getTokenText(): string;
getTokenValue(): string;
hasExtendedUnicodeEscape(): boolean;
hasPrecedingLineBreak(): boolean;
isIdentifier(): boolean;
isReservedWord(): boolean;
isUnterminated(): boolean;
reScanGreaterToken(): SyntaxKind;
reScanSlashToken(): SyntaxKind;
reScanTemplateToken(): SyntaxKind;
scan(): SyntaxKind;
setText(text: string): void;
setTextPos(textPos: number): void;
lookAhead<T>(callback: () => T): T;
tryScan<T>(callback: () => T): T;
interface FileWatcher {
close(): void;
}
var sys: System;
}
declare module "typescript" {
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
character: number;
};
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
function isWhiteSpace(ch: number): boolean;
function isLineBreak(ch: number): boolean;
function isOctalDigit(ch: number): boolean;
function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number;
function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner;
}
declare module "typescript" {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
@@ -1455,12 +1192,9 @@ declare module "typescript" {
function isLeftHandSideExpression(expr: Expression): boolean;
function isAssignmentOperator(token: SyntaxKind): boolean;
}
declare module "typescript" {
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
}
declare module "typescript" {
/** The version of the TypeScript compiler release */
let version: string;
const version: string;
function findConfigFile(searchPath: string): string;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
@@ -1468,6 +1202,7 @@ declare module "typescript" {
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
@@ -1589,8 +1324,10 @@ declare module "typescript" {
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
/** @deprecated */
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
@@ -1641,6 +1378,20 @@ declare module "typescript" {
fileName: string;
isWriteAccess: boolean;
}
interface DocumentHighlights {
fileName: string;
highlightSpans: HighlightSpan[];
}
module HighlightSpanKind {
const none: string;
const definition: string;
const reference: string;
const writtenReference: string;
}
interface HighlightSpan {
textSpan: TextSpan;
kind: string;
}
interface NavigateToItem {
name: string;
kind: string;
@@ -1765,6 +1516,7 @@ declare module "typescript" {
name: string;
kind: string;
kindModifiers: string;
sortText: string;
}
interface CompletionEntryDetails {
name: string;
@@ -1905,43 +1657,44 @@ declare module "typescript" {
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
}
class ScriptElementKind {
static unknown: string;
static keyword: string;
static scriptElement: string;
static moduleElement: string;
static classElement: string;
static interfaceElement: string;
static typeElement: string;
static enumElement: string;
static variableElement: string;
static localVariableElement: string;
static functionElement: string;
static localFunctionElement: string;
static memberFunctionElement: string;
static memberGetAccessorElement: string;
static memberSetAccessorElement: string;
static memberVariableElement: string;
static constructorImplementationElement: string;
static callSignatureElement: string;
static indexSignatureElement: string;
static constructSignatureElement: string;
static parameterElement: string;
static typeParameterElement: string;
static primitiveType: string;
static label: string;
static alias: string;
static constElement: string;
static letElement: string;
module ScriptElementKind {
const unknown: string;
const warning: string;
const keyword: string;
const scriptElement: string;
const moduleElement: string;
const classElement: string;
const interfaceElement: string;
const typeElement: string;
const enumElement: string;
const variableElement: string;
const localVariableElement: string;
const functionElement: string;
const localFunctionElement: string;
const memberFunctionElement: string;
const memberGetAccessorElement: string;
const memberSetAccessorElement: string;
const memberVariableElement: string;
const constructorImplementationElement: string;
const callSignatureElement: string;
const indexSignatureElement: string;
const constructSignatureElement: string;
const parameterElement: string;
const typeParameterElement: string;
const primitiveType: string;
const label: string;
const alias: string;
const constElement: string;
const letElement: string;
}
class ScriptElementKindModifier {
static none: string;
static publicMemberModifier: string;
static privateMemberModifier: string;
static protectedMemberModifier: string;
static exportedModifier: string;
static ambientModifier: string;
static staticModifier: string;
module ScriptElementKindModifier {
const none: string;
const publicMemberModifier: string;
const privateMemberModifier: string;
const protectedMemberModifier: string;
const exportedModifier: string;
const ambientModifier: string;
const staticModifier: string;
}
class ClassificationTypeNames {
static comment: string;
+12874 -6843
View File
File diff suppressed because one or more lines are too long
+103 -350
View File
@@ -295,34 +295,12 @@ declare module ts {
AccessibilityModifier = 112,
BlockScoped = 12288,
}
const enum ParserContextFlags {
StrictMode = 1,
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
Failed = 2,
FailedAndReported = 3,
}
interface Node extends TextRange {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
symbol?: Symbol;
locals?: SymbolTable;
nextContainer?: Node;
localSymbol?: Symbol;
}
interface NodeArray<T> extends Array<T>, TextRange {
hasTrailingComma?: boolean;
@@ -723,7 +701,7 @@ declare module ts {
interface ExternalModuleReference extends Node {
expression?: Expression;
}
interface ImportDeclaration extends Statement, ModuleElement {
interface ImportDeclaration extends ModuleElement {
importClause?: ImportClause;
moduleSpecifier: Expression;
}
@@ -751,14 +729,14 @@ declare module ts {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression?: Expression;
type?: TypeNode;
expression: Expression;
}
interface FileReference extends TextRange {
fileName: string;
}
interface CommentRange extends TextRange {
hasTrailingNewLine?: boolean;
kind: SyntaxKind;
}
interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
@@ -772,9 +750,7 @@ declare module ts {
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
externalModuleIndicator: Node;
languageVersion: ScriptTarget;
identifiers: Map<string>;
}
interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
@@ -785,6 +761,9 @@ declare module ts {
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
}
interface Program extends ScriptReferenceHost {
/**
* Get a list of files in the program
*/
getSourceFiles(): SourceFile[];
/**
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
@@ -801,15 +780,23 @@ declare module ts {
getGlobalDiagnostics(): Diagnostic[];
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
/**
* Gets a type checker that can be used to semantically analyze source fils in the program.
*/
getTypeChecker(): TypeChecker;
getCommonSourceDirectory(): string;
}
interface SourceMapSpan {
/** Line number in the .js file. */
emittedLine: number;
/** Column number in the .js file. */
emittedColumn: number;
/** Line number in the .ts file. */
sourceLine: number;
/** Column number in the .ts file. */
sourceColumn: number;
/** Optional name (index into names array) associated with this span. */
nameIndex?: number;
/** .ts file (index into sources array) associated with this span */
sourceIndex: number;
}
interface SourceMapData {
@@ -823,6 +810,7 @@ declare module ts {
sourceMapMappings: string;
sourceMapDecodedMappings: SourceMapSpan[];
}
/** Return code used by getEmitOutput function to indicate status of the function */
enum ExitStatus {
Success = 0,
DiagnosticsPresent_OutputsSkipped = 1,
@@ -831,7 +819,6 @@ declare module ts {
interface EmitResult {
emitSkipped: boolean;
diagnostics: Diagnostic[];
sourceMaps: SourceMapData[];
}
interface TypeCheckerHost {
getCompilerOptions(): CompilerOptions;
@@ -865,7 +852,7 @@ declare 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[];
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -908,40 +895,6 @@ declare module ts {
WriteTypeParametersOrArguments = 1,
UseOnlyExternalAliasing = 2,
}
const enum SymbolAccessibility {
Accessible = 0,
NotAccessible = 1,
CannotBeNamed = 2,
}
type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
interface SymbolVisibilityResult {
accessibility: SymbolAccessibility;
aliasesToMakeVisible?: AnyImportSyntax[];
errorSymbolName?: string;
errorNode?: Node;
}
interface SymbolAccessiblityResult extends SymbolVisibilityResult {
errorModuleName?: string;
}
interface EmitResolver {
hasGlobalName(name: string): boolean;
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
isValueAliasDeclaration(node: Node): boolean;
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
getNodeCheckFlags(node: Node): NodeCheckFlags;
isDeclarationVisible(node: Declaration): boolean;
collectLinkedAliases(node: Identifier): Node[];
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
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 | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
}
const enum SymbolFlags {
FunctionScopedVariable = 1,
BlockScopedVariable = 2,
@@ -1011,57 +964,14 @@ declare module ts {
interface Symbol {
flags: SymbolFlags;
name: string;
id?: number;
mergeId?: number;
declarations?: Declaration[];
parent?: Symbol;
members?: SymbolTable;
exports?: SymbolTable;
exportSymbol?: Symbol;
valueDeclaration?: Declaration;
constEnumOnlyModule?: boolean;
}
interface SymbolLinks {
target?: Symbol;
type?: Type;
declaredType?: Type;
mapper?: TypeMapper;
referenced?: boolean;
unionType?: UnionType;
resolvedExports?: SymbolTable;
exportsChecked?: boolean;
}
interface TransientSymbol extends Symbol, SymbolLinks {
}
interface SymbolTable {
[index: string]: Symbol;
}
const enum NodeCheckFlags {
TypeChecked = 1,
LexicalThis = 2,
CaptureThis = 4,
EmitExtends = 8,
SuperInstance = 16,
SuperStatic = 32,
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;
resolvedSignature?: Signature;
resolvedSymbol?: Symbol;
flags?: NodeCheckFlags;
enumMemberValue?: number;
isIllegalTypeReferenceInConstraint?: boolean;
isVisible?: boolean;
generatedName?: string;
generatedNames?: Map<string>;
assignmentChecks?: Map<boolean>;
hasReportedStatementInAmbientContext?: boolean;
importOnRightSide?: Symbol;
}
const enum TypeFlags {
Any = 1,
String = 2,
@@ -1079,26 +989,16 @@ declare module ts {
Tuple = 8192,
Union = 16384,
Anonymous = 32768,
FromSignature = 65536,
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
RequiresWidening = 786432,
}
interface Type {
flags: TypeFlags;
id: number;
symbol?: Symbol;
}
interface IntrinsicType extends Type {
intrinsicName: string;
}
interface StringLiteralType extends Type {
text: string;
}
@@ -1118,7 +1018,6 @@ declare module ts {
typeArguments: Type[];
}
interface GenericType extends InterfaceType, TypeReference {
instantiations: Map<TypeReference>;
}
interface TupleType extends ObjectType {
elementTypes: Type[];
@@ -1126,20 +1025,9 @@ declare module ts {
}
interface UnionType extends Type {
types: Type[];
resolvedProperties: SymbolTable;
}
interface ResolvedType extends ObjectType, UnionType {
members: SymbolTable;
properties: Symbol[];
callSignatures: Signature[];
constructSignatures: Signature[];
stringIndexType: Type;
numberIndexType: Type;
}
interface TypeParameter extends Type {
constraint: Type;
target?: TypeParameter;
mapper?: TypeMapper;
}
const enum SignatureKind {
Call = 0,
@@ -1149,28 +1037,22 @@ declare module ts {
declaration: SignatureDeclaration;
typeParameters: TypeParameter[];
parameters: Symbol[];
resolvedReturnType: Type;
minArgumentCount: number;
hasRestParameter: boolean;
hasStringLiterals: boolean;
target?: Signature;
mapper?: TypeMapper;
unionSignatures?: Signature[];
erasedSignatureCache?: Signature;
isolatedSignatureType?: ObjectType;
}
const enum IndexKind {
String = 0,
Number = 1,
}
interface TypeMapper {
(t: Type): Type;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
code: number;
}
/**
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
* It is built from the bottom up, leaving the head to be the "main" diagnostic.
* While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage,
* the difference is that messages are all preformatted in DMC.
*/
interface DiagnosticMessageChain {
messageText: string;
category: DiagnosticCategory;
@@ -1219,6 +1101,7 @@ declare module ts {
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1241,142 +1124,6 @@ declare module ts {
fileNames: string[];
errors: Diagnostic[];
}
interface CommandLineOption {
name: string;
type: string | Map<number>;
isFilePath?: boolean;
shortName?: string;
description?: DiagnosticMessage;
paramType?: DiagnosticMessage;
error?: DiagnosticMessage;
experimental?: boolean;
}
const enum CharacterCodes {
nullCharacter = 0,
maxAsciiCharacter = 127,
lineFeed = 10,
carriageReturn = 13,
lineSeparator = 8232,
paragraphSeparator = 8233,
nextLine = 133,
space = 32,
nonBreakingSpace = 160,
enQuad = 8192,
emQuad = 8193,
enSpace = 8194,
emSpace = 8195,
threePerEmSpace = 8196,
fourPerEmSpace = 8197,
sixPerEmSpace = 8198,
figureSpace = 8199,
punctuationSpace = 8200,
thinSpace = 8201,
hairSpace = 8202,
zeroWidthSpace = 8203,
narrowNoBreakSpace = 8239,
ideographicSpace = 12288,
mathematicalSpace = 8287,
ogham = 5760,
_ = 95,
$ = 36,
_0 = 48,
_1 = 49,
_2 = 50,
_3 = 51,
_4 = 52,
_5 = 53,
_6 = 54,
_7 = 55,
_8 = 56,
_9 = 57,
a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
ampersand = 38,
asterisk = 42,
at = 64,
backslash = 92,
backtick = 96,
bar = 124,
caret = 94,
closeBrace = 125,
closeBracket = 93,
closeParen = 41,
colon = 58,
comma = 44,
dot = 46,
doubleQuote = 34,
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
openBracket = 91,
openParen = 40,
percent = 37,
plus = 43,
question = 63,
semicolon = 59,
singleQuote = 39,
slash = 47,
tilde = 126,
backspace = 8,
formFeed = 12,
byteOrderMark = 65279,
tab = 9,
verticalTab = 11,
}
interface CancellationToken {
isCancellationRequested(): boolean;
}
@@ -1400,49 +1147,39 @@ declare module ts {
}
}
declare module ts {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
interface System {
args: string[];
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string) => void): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
createDirectory(path: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
readDirectory(path: string, extension?: string): string[];
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
getTextPos(): number;
getTokenPos(): number;
getTokenText(): string;
getTokenValue(): string;
hasExtendedUnicodeEscape(): boolean;
hasPrecedingLineBreak(): boolean;
isIdentifier(): boolean;
isReservedWord(): boolean;
isUnterminated(): boolean;
reScanGreaterToken(): SyntaxKind;
reScanSlashToken(): SyntaxKind;
reScanTemplateToken(): SyntaxKind;
scan(): SyntaxKind;
setText(text: string): void;
setTextPos(textPos: number): void;
lookAhead<T>(callback: () => T): T;
tryScan<T>(callback: () => T): T;
interface FileWatcher {
close(): void;
}
var sys: System;
}
declare module ts {
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
character: number;
};
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
function isWhiteSpace(ch: number): boolean;
function isLineBreak(ch: number): boolean;
function isOctalDigit(ch: number): boolean;
function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number;
function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner;
}
declare module ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
@@ -1455,12 +1192,9 @@ declare module ts {
function isLeftHandSideExpression(expr: Expression): boolean;
function isAssignmentOperator(token: SyntaxKind): boolean;
}
declare module ts {
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
}
declare module ts {
/** The version of the TypeScript compiler release */
let version: string;
const version: string;
function findConfigFile(searchPath: string): string;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
@@ -1468,6 +1202,7 @@ declare module ts {
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module ts {
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
/**
* Read tsconfig.json file
* @param fileName The path to the config file
@@ -1589,8 +1324,10 @@ declare module ts {
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
/** @deprecated */
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
@@ -1641,6 +1378,20 @@ declare module ts {
fileName: string;
isWriteAccess: boolean;
}
interface DocumentHighlights {
fileName: string;
highlightSpans: HighlightSpan[];
}
module HighlightSpanKind {
const none: string;
const definition: string;
const reference: string;
const writtenReference: string;
}
interface HighlightSpan {
textSpan: TextSpan;
kind: string;
}
interface NavigateToItem {
name: string;
kind: string;
@@ -1765,6 +1516,7 @@ declare module ts {
name: string;
kind: string;
kindModifiers: string;
sortText: string;
}
interface CompletionEntryDetails {
name: string;
@@ -1905,43 +1657,44 @@ declare module ts {
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
}
class ScriptElementKind {
static unknown: string;
static keyword: string;
static scriptElement: string;
static moduleElement: string;
static classElement: string;
static interfaceElement: string;
static typeElement: string;
static enumElement: string;
static variableElement: string;
static localVariableElement: string;
static functionElement: string;
static localFunctionElement: string;
static memberFunctionElement: string;
static memberGetAccessorElement: string;
static memberSetAccessorElement: string;
static memberVariableElement: string;
static constructorImplementationElement: string;
static callSignatureElement: string;
static indexSignatureElement: string;
static constructSignatureElement: string;
static parameterElement: string;
static typeParameterElement: string;
static primitiveType: string;
static label: string;
static alias: string;
static constElement: string;
static letElement: string;
module ScriptElementKind {
const unknown: string;
const warning: string;
const keyword: string;
const scriptElement: string;
const moduleElement: string;
const classElement: string;
const interfaceElement: string;
const typeElement: string;
const enumElement: string;
const variableElement: string;
const localVariableElement: string;
const functionElement: string;
const localFunctionElement: string;
const memberFunctionElement: string;
const memberGetAccessorElement: string;
const memberSetAccessorElement: string;
const memberVariableElement: string;
const constructorImplementationElement: string;
const callSignatureElement: string;
const indexSignatureElement: string;
const constructSignatureElement: string;
const parameterElement: string;
const typeParameterElement: string;
const primitiveType: string;
const label: string;
const alias: string;
const constElement: string;
const letElement: string;
}
class ScriptElementKindModifier {
static none: string;
static publicMemberModifier: string;
static privateMemberModifier: string;
static protectedMemberModifier: string;
static exportedModifier: string;
static ambientModifier: string;
static staticModifier: string;
module ScriptElementKindModifier {
const none: string;
const publicMemberModifier: string;
const privateMemberModifier: string;
const protectedMemberModifier: string;
const exportedModifier: string;
const ambientModifier: string;
const staticModifier: string;
}
class ClassificationTypeNames {
static comment: string;
+12874 -6843
View File
File diff suppressed because one or more lines are too long
-399
View File
@@ -1,399 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
declare module ts {
const enum Ternary {
False = 0,
Maybe = 1,
True = -1,
}
const enum Comparison {
LessThan = -1,
EqualTo = 0,
GreaterThan = 1,
}
interface StringSet extends Map<any> {
}
function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U;
function contains<T>(array: T[], value: T): boolean;
function indexOf<T>(array: T[], value: T): number;
function countWhere<T>(array: T[], predicate: (x: T) => boolean): number;
function filter<T>(array: T[], f: (x: T) => boolean): T[];
function map<T, U>(array: T[], f: (x: T) => U): U[];
function concatenate<T>(array1: T[], array2: T[]): T[];
function deduplicate<T>(array: T[]): T[];
function sum(array: any[], prop: string): number;
function addRange<T>(to: T[], from: T[]): void;
/**
* Returns the last element of an array if non-empty, undefined otherwise.
*/
function lastOrUndefined<T>(array: T[]): T;
function binarySearch(array: number[], value: number): number;
function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function hasProperty<T>(map: Map<T>, key: string): boolean;
function getProperty<T>(map: Map<T>, key: string): T;
function isEmpty<T>(map: Map<T>): boolean;
function clone<T>(object: T): T;
function extend<T>(first: Map<T>, second: Map<T>): Map<T>;
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
function lookUp<T>(map: Map<T>, key: string): T;
function copyMap<T>(source: Map<T>, target: Map<T>): void;
/**
* Creates a map from the elements of an array.
*
* @param array the array of input elements.
* @param makeKey a function that produces a key for a given element.
*
* This function makes no effort to avoid collisions; if any two elements produce
* the same key with the given 'makeKey' function, then the element with the higher
* index in the array will be the one associated with the produced key.
*/
function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T>;
let localizedDiagnosticMessages: Map<string>;
function getLocaleSpecificMessage(message: string): string;
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain;
function compareValues<T>(a: T, b: T): Comparison;
function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison;
function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
function normalizeSlashes(path: string): string;
function getRootLength(path: string): number;
let directorySeparator: string;
function normalizePath(path: string): string;
function getDirectoryPath(path: string): string;
function isUrl(path: string): boolean;
function isRootedDiskPath(path: string): boolean;
function getNormalizedPathComponents(path: string, currentDirectory: string): string[];
function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string;
function getNormalizedPathFromPathComponents(pathComponents: string[]): string;
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string;
function getBaseFileName(path: string): string;
function combinePaths(path1: string, path2: string): string;
function fileExtensionIs(path: string, extension: string): boolean;
function removeFileExtension(path: string): string;
function getDefaultLibFileName(options: CompilerOptions): string;
interface ObjectAllocator {
getNodeConstructor(kind: SyntaxKind): new () => Node;
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
}
let objectAllocator: ObjectAllocator;
const enum AssertionLevel {
None = 0,
Normal = 1,
Aggressive = 2,
VeryAggressive = 3,
}
module Debug {
function shouldAssert(level: AssertionLevel): boolean;
function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void;
function fail(message?: string): void;
}
}
declare module ts {
interface System {
args: string[];
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(fileName: string, encoding?: string): string;
writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
createDirectory(directoryName: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
readDirectory(path: string, extension?: string): string[];
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
interface FileWatcher {
close(): void;
}
var sys: System;
}
declare module ts {
interface ReferencePathMatchResult {
fileReference?: FileReference;
diagnosticMessage?: DiagnosticMessage;
isNoDefaultLib?: boolean;
}
interface SynthesizedNode extends Node {
leadingCommentRanges?: CommentRange[];
trailingCommentRanges?: CommentRange[];
startsOnNewLine: boolean;
}
function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration;
interface StringSymbolWriter extends SymbolWriter {
string(): string;
}
interface EmitHost extends ScriptReferenceHost {
getSourceFiles(): SourceFile[];
getCommonSourceDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
writeFile: WriteFileCallback;
}
function getSingleLineStringWriter(): StringSymbolWriter;
function releaseStringWriter(writer: StringSymbolWriter): void;
function getFullWidth(node: Node): number;
function containsParseError(node: Node): boolean;
function getSourceFileOfNode(node: Node): SourceFile;
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
function nodePosToString(node: Node): string;
function getStartPosOfNode(node: Node): number;
function nodeIsMissing(node: Node): boolean;
function nodeIsPresent(node: Node): boolean;
function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number;
function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string;
function getTextOfNodeFromSourceText(sourceText: string, node: Node): string;
function getTextOfNode(node: Node): string;
function escapeIdentifier(identifier: string): string;
function unescapeIdentifier(identifier: string): string;
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function getEnclosingBlockScopeContainer(node: Node): Node;
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
function declarationNameToString(name: DeclarationName): string;
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic;
function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan;
function isExternalModule(file: SourceFile): boolean;
function isDeclarationFile(file: SourceFile): boolean;
function isConstEnumDeclaration(node: Node): boolean;
function getCombinedNodeFlags(node: Node): NodeFlags;
function isConst(node: Node): boolean;
function isLet(node: Node): boolean;
function isPrologueDirective(node: Node): boolean;
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
let fullTripleSlashReferencePathRegEx: RegExp;
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
function isFunctionLike(node: Node): boolean;
function isFunctionBlock(node: Node): boolean;
function isObjectLiteralMethod(node: Node): boolean;
function getContainingFunction(node: Node): FunctionLikeDeclaration;
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
function getInvokedExpression(node: CallLikeExpression): Expression;
function nodeCanBeDecorated(node: Node): boolean;
function nodeIsDecorated(node: Node): boolean;
function childIsDecorated(node: Node): boolean;
function nodeOrChildIsDecorated(node: Node): boolean;
function isExpression(node: Node): boolean;
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression;
function isInternalModuleImportEqualsDeclaration(node: Node): boolean;
function getExternalModuleName(node: Node): Expression;
function hasDotDotDotToken(node: Node): boolean;
function hasQuestionToken(node: Node): boolean;
function hasRestParameters(s: SignatureDeclaration): boolean;
function isLiteralKind(kind: SyntaxKind): boolean;
function isTextualLiteralKind(kind: SyntaxKind): boolean;
function isTemplateLiteralKind(kind: SyntaxKind): boolean;
function isBindingPattern(node: Node): boolean;
function isInAmbientContext(node: Node): boolean;
function isDeclaration(node: Node): boolean;
function isStatement(n: Node): boolean;
function isClassElement(n: Node): boolean;
function isDeclarationName(name: Node): boolean;
function isAliasSymbolDeclaration(node: Node): boolean;
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;
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
function isKeyword(token: SyntaxKind): boolean;
function isTrivia(token: SyntaxKind): boolean;
/**
* A declaration has a dynamic name if both of the following are true:
* 1. The declaration has a computed property name
* 2. The computed name is *not* expressed as Symbol.<name>, where name
* is a property of the Symbol constructor that denotes a built in
* Symbol.
*/
function hasDynamicName(declaration: Declaration): boolean;
/**
* Checks if the expression is of the form:
* Symbol.name
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
function isWellKnownSymbolSyntactically(node: Expression): boolean;
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
function getPropertyNameForKnownSymbolName(symbolName: string): string;
/**
* Includes the word "Symbol" with unicode escapes
*/
function isESSymbolIdentifier(node: Node): boolean;
function isModifier(token: SyntaxKind): boolean;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
function createTextSpan(start: number, length: number): TextSpan;
function createTextSpanFromBounds(start: number, end: number): TextSpan;
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
let unchangedTextChangeRange: TextChangeRange;
/**
* Called to merge all the changes that occurred across several versions of a script snapshot
* into a single change. i.e. if a user keeps making successive edits to a script we will
* have a text change from V1 to V2, V2 to V3, ..., Vn.
*
* This function will then merge those changes into a single change range valid between V1 and
* Vn.
*/
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function nodeStartsNewLexicalEnvironment(n: Node): boolean;
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
* Note that this doesn't actually wrap the input in double quotes.
*/
function escapeString(s: string): string;
function escapeNonAsciiCharacters(s: string): string;
interface EmitTextWriter {
write(s: string): void;
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
getText(): string;
rawWrite(s: string): void;
writeLiteral(s: string): void;
getTextPos(): number;
getLine(): number;
getColumn(): number;
getIndent(): number;
}
function getIndentString(level: number): string;
function getIndentSize(): number;
function createTextWriter(newLine: String): EmitTextWriter;
function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string;
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: ClassLikeDeclaration): ConstructorDeclaration;
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
};
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 {
/**
* 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 {
interface ListItemInfo {
listItemIndex: number;
list: Node;
}
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean;
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean;
function findListItemInfo(node: Node): ListItemInfo;
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean;
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
function findContainingList(node: Node): Node;
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node;
/** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */
function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean): Node;
/** Returns a token if position is in [start-of-leading-trivia, end) */
function getTokenAtPosition(sourceFile: SourceFile, position: number): Node;
/**
* The token on the left of the position is the token that strictly includes the position
* or sits to the left of the cursor if it is on a boundary. For example
*
* fo|o -> will return foo
* foo <comment> |bar -> will return foo
*
*/
function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node;
function findNextToken(previousToken: Node, parent: Node): Node;
function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node;
function getNodeModifiers(node: Node): string;
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
function isToken(n: Node): boolean;
function isWord(kind: SyntaxKind): boolean;
function isComment(kind: SyntaxKind): boolean;
function isPunctuation(kind: SyntaxKind): boolean;
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
function isAccessibilityModifier(kind: SyntaxKind): boolean;
function compareDataObjects(dst: any, src: any): boolean;
}
declare module ts {
function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean;
function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart;
function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart;
function spacePart(): SymbolDisplayPart;
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
function textOrKeywordPart(text: string): SymbolDisplayPart;
function textPart(text: string): SymbolDisplayPart;
function lineBreakPart(): SymbolDisplayPart;
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];
function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[];
function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
}
-399
View File
@@ -1,399 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
declare module "typescript" {
const enum Ternary {
False = 0,
Maybe = 1,
True = -1,
}
const enum Comparison {
LessThan = -1,
EqualTo = 0,
GreaterThan = 1,
}
interface StringSet extends Map<any> {
}
function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U;
function contains<T>(array: T[], value: T): boolean;
function indexOf<T>(array: T[], value: T): number;
function countWhere<T>(array: T[], predicate: (x: T) => boolean): number;
function filter<T>(array: T[], f: (x: T) => boolean): T[];
function map<T, U>(array: T[], f: (x: T) => U): U[];
function concatenate<T>(array1: T[], array2: T[]): T[];
function deduplicate<T>(array: T[]): T[];
function sum(array: any[], prop: string): number;
function addRange<T>(to: T[], from: T[]): void;
/**
* Returns the last element of an array if non-empty, undefined otherwise.
*/
function lastOrUndefined<T>(array: T[]): T;
function binarySearch(array: number[], value: number): number;
function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function hasProperty<T>(map: Map<T>, key: string): boolean;
function getProperty<T>(map: Map<T>, key: string): T;
function isEmpty<T>(map: Map<T>): boolean;
function clone<T>(object: T): T;
function extend<T>(first: Map<T>, second: Map<T>): Map<T>;
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
function lookUp<T>(map: Map<T>, key: string): T;
function copyMap<T>(source: Map<T>, target: Map<T>): void;
/**
* Creates a map from the elements of an array.
*
* @param array the array of input elements.
* @param makeKey a function that produces a key for a given element.
*
* This function makes no effort to avoid collisions; if any two elements produce
* the same key with the given 'makeKey' function, then the element with the higher
* index in the array will be the one associated with the produced key.
*/
function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T>;
let localizedDiagnosticMessages: Map<string>;
function getLocaleSpecificMessage(message: string): string;
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain;
function compareValues<T>(a: T, b: T): Comparison;
function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison;
function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
function normalizeSlashes(path: string): string;
function getRootLength(path: string): number;
let directorySeparator: string;
function normalizePath(path: string): string;
function getDirectoryPath(path: string): string;
function isUrl(path: string): boolean;
function isRootedDiskPath(path: string): boolean;
function getNormalizedPathComponents(path: string, currentDirectory: string): string[];
function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string;
function getNormalizedPathFromPathComponents(pathComponents: string[]): string;
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string;
function getBaseFileName(path: string): string;
function combinePaths(path1: string, path2: string): string;
function fileExtensionIs(path: string, extension: string): boolean;
function removeFileExtension(path: string): string;
function getDefaultLibFileName(options: CompilerOptions): string;
interface ObjectAllocator {
getNodeConstructor(kind: SyntaxKind): new () => Node;
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
}
let objectAllocator: ObjectAllocator;
const enum AssertionLevel {
None = 0,
Normal = 1,
Aggressive = 2,
VeryAggressive = 3,
}
module Debug {
function shouldAssert(level: AssertionLevel): boolean;
function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void;
function fail(message?: string): void;
}
}
declare module "typescript" {
interface System {
args: string[];
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(fileName: string, encoding?: string): string;
writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(fileName: string, callback: (fileName: string) => void): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
createDirectory(directoryName: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
readDirectory(path: string, extension?: string): string[];
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
interface FileWatcher {
close(): void;
}
var sys: System;
}
declare module "typescript" {
interface ReferencePathMatchResult {
fileReference?: FileReference;
diagnosticMessage?: DiagnosticMessage;
isNoDefaultLib?: boolean;
}
interface SynthesizedNode extends Node {
leadingCommentRanges?: CommentRange[];
trailingCommentRanges?: CommentRange[];
startsOnNewLine: boolean;
}
function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration;
interface StringSymbolWriter extends SymbolWriter {
string(): string;
}
interface EmitHost extends ScriptReferenceHost {
getSourceFiles(): SourceFile[];
getCommonSourceDirectory(): string;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
writeFile: WriteFileCallback;
}
function getSingleLineStringWriter(): StringSymbolWriter;
function releaseStringWriter(writer: StringSymbolWriter): void;
function getFullWidth(node: Node): number;
function containsParseError(node: Node): boolean;
function getSourceFileOfNode(node: Node): SourceFile;
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
function nodePosToString(node: Node): string;
function getStartPosOfNode(node: Node): number;
function nodeIsMissing(node: Node): boolean;
function nodeIsPresent(node: Node): boolean;
function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number;
function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string;
function getTextOfNodeFromSourceText(sourceText: string, node: Node): string;
function getTextOfNode(node: Node): string;
function escapeIdentifier(identifier: string): string;
function unescapeIdentifier(identifier: string): string;
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function getEnclosingBlockScopeContainer(node: Node): Node;
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
function declarationNameToString(name: DeclarationName): string;
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic;
function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan;
function isExternalModule(file: SourceFile): boolean;
function isDeclarationFile(file: SourceFile): boolean;
function isConstEnumDeclaration(node: Node): boolean;
function getCombinedNodeFlags(node: Node): NodeFlags;
function isConst(node: Node): boolean;
function isLet(node: Node): boolean;
function isPrologueDirective(node: Node): boolean;
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
let fullTripleSlashReferencePathRegEx: RegExp;
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
function isFunctionLike(node: Node): boolean;
function isFunctionBlock(node: Node): boolean;
function isObjectLiteralMethod(node: Node): boolean;
function getContainingFunction(node: Node): FunctionLikeDeclaration;
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
function getInvokedExpression(node: CallLikeExpression): Expression;
function nodeCanBeDecorated(node: Node): boolean;
function nodeIsDecorated(node: Node): boolean;
function childIsDecorated(node: Node): boolean;
function nodeOrChildIsDecorated(node: Node): boolean;
function isExpression(node: Node): boolean;
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression;
function isInternalModuleImportEqualsDeclaration(node: Node): boolean;
function getExternalModuleName(node: Node): Expression;
function hasDotDotDotToken(node: Node): boolean;
function hasQuestionToken(node: Node): boolean;
function hasRestParameters(s: SignatureDeclaration): boolean;
function isLiteralKind(kind: SyntaxKind): boolean;
function isTextualLiteralKind(kind: SyntaxKind): boolean;
function isTemplateLiteralKind(kind: SyntaxKind): boolean;
function isBindingPattern(node: Node): boolean;
function isInAmbientContext(node: Node): boolean;
function isDeclaration(node: Node): boolean;
function isStatement(n: Node): boolean;
function isClassElement(n: Node): boolean;
function isDeclarationName(name: Node): boolean;
function isAliasSymbolDeclaration(node: Node): boolean;
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;
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
function isKeyword(token: SyntaxKind): boolean;
function isTrivia(token: SyntaxKind): boolean;
/**
* A declaration has a dynamic name if both of the following are true:
* 1. The declaration has a computed property name
* 2. The computed name is *not* expressed as Symbol.<name>, where name
* is a property of the Symbol constructor that denotes a built in
* Symbol.
*/
function hasDynamicName(declaration: Declaration): boolean;
/**
* Checks if the expression is of the form:
* Symbol.name
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
function isWellKnownSymbolSyntactically(node: Expression): boolean;
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
function getPropertyNameForKnownSymbolName(symbolName: string): string;
/**
* Includes the word "Symbol" with unicode escapes
*/
function isESSymbolIdentifier(node: Node): boolean;
function isModifier(token: SyntaxKind): boolean;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
function createTextSpan(start: number, length: number): TextSpan;
function createTextSpanFromBounds(start: number, end: number): TextSpan;
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
let unchangedTextChangeRange: TextChangeRange;
/**
* Called to merge all the changes that occurred across several versions of a script snapshot
* into a single change. i.e. if a user keeps making successive edits to a script we will
* have a text change from V1 to V2, V2 to V3, ..., Vn.
*
* This function will then merge those changes into a single change range valid between V1 and
* Vn.
*/
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function nodeStartsNewLexicalEnvironment(n: Node): boolean;
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
* Note that this doesn't actually wrap the input in double quotes.
*/
function escapeString(s: string): string;
function escapeNonAsciiCharacters(s: string): string;
interface EmitTextWriter {
write(s: string): void;
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
getText(): string;
rawWrite(s: string): void;
writeLiteral(s: string): void;
getTextPos(): number;
getLine(): number;
getColumn(): number;
getIndent(): number;
}
function getIndentString(level: number): string;
function getIndentSize(): number;
function createTextWriter(newLine: String): EmitTextWriter;
function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string;
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: ClassLikeDeclaration): ConstructorDeclaration;
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
};
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" {
/**
* 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" {
interface ListItemInfo {
listItemIndex: number;
list: Node;
}
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean;
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean;
function findListItemInfo(node: Node): ListItemInfo;
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean;
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
function findContainingList(node: Node): Node;
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node;
/** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */
function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean): Node;
/** Returns a token if position is in [start-of-leading-trivia, end) */
function getTokenAtPosition(sourceFile: SourceFile, position: number): Node;
/**
* The token on the left of the position is the token that strictly includes the position
* or sits to the left of the cursor if it is on a boundary. For example
*
* fo|o -> will return foo
* foo <comment> |bar -> will return foo
*
*/
function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node;
function findNextToken(previousToken: Node, parent: Node): Node;
function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node;
function getNodeModifiers(node: Node): string;
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
function isToken(n: Node): boolean;
function isWord(kind: SyntaxKind): boolean;
function isComment(kind: SyntaxKind): boolean;
function isPunctuation(kind: SyntaxKind): boolean;
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
function isAccessibilityModifier(kind: SyntaxKind): boolean;
function compareDataObjects(dst: any, src: any): boolean;
}
declare module "typescript" {
function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean;
function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart;
function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart;
function spacePart(): SymbolDisplayPart;
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
function textOrKeywordPart(text: string): SymbolDisplayPart;
function textPart(text: string): SymbolDisplayPart;
function lineBreakPart(): SymbolDisplayPart;
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];
function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[];
function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[];
}
+1
View File
@@ -54,6 +54,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
var result =
'// <auto-generated />\r\n' +
'/// <reference path="types.ts" />\r\n' +
'/* @internal */\r\n' +
'module ts {\r\n' +
' export var Diagnostics = {\r\n';
var names = Utilities.getObjectKeys(messageTable);
+3 -2
View File
@@ -1,7 +1,8 @@
/// <reference path="parser.ts"/>
/* @internal */
module ts {
/* @internal */ export let bindTime = 0;
export let bindTime = 0;
export const enum ModuleInstanceState {
NonInstantiated = 0,
@@ -539,7 +540,7 @@ module ts {
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
break;
case SyntaxKind.ExportAssignment:
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
// An export default clause with an identifier exports all meanings of that identifier
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
}
+295 -108
View File
@@ -1,19 +1,18 @@
/// <reference path="binder.ts"/>
/* @internal */
module ts {
let nextSymbolId = 1;
let nextNodeId = 1;
let nextMergeId = 1;
// @internal
export function getNodeId(node: Node): number {
if (!node.id) node.id = nextNodeId++;
return node.id;
}
/* @internal */ export let checkTime = 0;
export let checkTime = 0;
/* @internal */
export function getSymbolId(symbol: Symbol): number {
if (!symbol.id) {
symbol.id = nextSymbolId++;
@@ -682,7 +681,7 @@ module ts {
}
function getTargetOfExportAssignment(node: ExportAssignment): Symbol {
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
return resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
}
function getTargetOfAliasDeclaration(node: Declaration): Symbol {
@@ -748,7 +747,7 @@ module ts {
if (!links.referenced) {
links.referenced = true;
let node = getDeclarationOfAliasSymbol(symbol);
if (node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression) {
if (node.kind === SyntaxKind.ExportAssignment) {
// export default <symbol>
checkExpressionCached((<ExportAssignment>node).expression);
}
@@ -2078,15 +2077,20 @@ module ts {
}
}
else {
// For an array binding element the specified or inferred type of the parent must be an array-like type
if (!isArrayLikeType(parentType)) {
error(pattern, Diagnostics.Type_0_is_not_an_array_type, typeToString(parentType));
return unknownType;
}
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
let elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false);
if (!declaration.dotDotDotToken) {
if (elementType.flags & TypeFlags.Any) {
return elementType;
}
// Use specific property type when parent is a tuple or numeric index type when parent is an array
let propName = "" + indexOf(pattern.elements, declaration);
type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) : getIndexTypeOfType(parentType, IndexKind.Number);
type = isTupleLikeType(parentType)
? getTypeOfPropertyOfType(parentType, propName)
: elementType;
if (!type) {
if (isTupleType(parentType)) {
error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), (<TupleType>parentType).elementTypes.length, pattern.elements.length);
@@ -2099,7 +2103,7 @@ module ts {
}
else {
// Rest element has an array type with the same element type as the parent type
type = createArrayType(getIndexTypeOfType(parentType, IndexKind.Number));
type = createArrayType(elementType);
}
}
return type;
@@ -2188,7 +2192,34 @@ module ts {
hasSpreadElement = true;
}
});
return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes);
if (!elementTypes.length) {
return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType;
}
else if (hasSpreadElement) {
let unionOfElements = getUnionType(elementTypes);
if (languageVersion >= ScriptTarget.ES6) {
// If the user has something like:
//
// function fun(...[a, ...b]) { }
//
// Normally, in ES6, the implied type of an array binding pattern with a rest element is
// an iterable. However, there is a requirement in our type system that all rest
// parameters be array types. To satisfy this, we have an exception to the rule that
// says the type of an array binding pattern with a rest element is an array type
// if it is *itself* in a rest parameter. It will still be compatible with a spreaded
// iterable argument, but within the function it will be an array.
let parent = pattern.parent;
let isRestParameter = parent.kind === SyntaxKind.Parameter &&
pattern === (<ParameterDeclaration>parent).name &&
(<ParameterDeclaration>parent).dotDotDotToken !== undefined;
return isRestParameter ? createArrayType(unionOfElements) : createIterableType(unionOfElements);
}
return createArrayType(unionOfElements);
}
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -2255,16 +2286,7 @@ module ts {
}
// Handle export default expressions
if (declaration.kind === SyntaxKind.ExportAssignment) {
var exportAssignment = <ExportAssignment>declaration;
if (exportAssignment.expression) {
return links.type = checkExpression(exportAssignment.expression);
}
else if (exportAssignment.type) {
return links.type = getTypeFromTypeNodeOrHeritageClauseElement(exportAssignment.type);
}
else {
return links.type = anyType;
}
return links.type = checkExpression((<ExportAssignment>declaration).expression);
}
// Handle variable, parameter or property
links.type = resolvingType;
@@ -3461,6 +3483,10 @@ module ts {
return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
}
function createIterableType(elementType: Type): Type {
return globalIterableType !== emptyObjectType ? createTypeReference(<GenericType>globalIterableType, [elementType]) : emptyObjectType;
}
function createArrayType(elementType: Type): Type {
// globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if
// user code augments the Array type with call or construct signatures that have an array type as the return type.
@@ -5546,7 +5572,7 @@ module ts {
needToCaptureLexicalThis = false;
while (container && container.kind === SyntaxKind.ArrowFunction) {
container = getSuperContainer(container, /*includeFunctions*/ true);
needToCaptureLexicalThis = true;
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
}
// topmost container must be something that is directly nested in the class declaration
@@ -5968,12 +5994,14 @@ module ts {
}
function checkSpreadElementExpression(node: SpreadElementExpression, contextualMapper?: TypeMapper): Type {
let type = checkExpressionCached(node.expression, contextualMapper);
if (!isArrayLikeType(type)) {
error(node.expression, Diagnostics.Type_0_is_not_an_array_type, typeToString(type));
return unknownType;
}
return type;
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
// You can tell that we are contextually typing because of the contextualMapper parameter.
// While it is true that a spread element can have a contextual type, it does not do anything
// with this type. It is neither affected by it, nor does it propagate it to its operand.
// So the fact that contextualMapper is passed is not important, because the operand of a spread
// element is not contextually typed.
let arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type {
@@ -5981,18 +6009,13 @@ module ts {
if (!elements.length) {
return createArrayType(undefinedType);
}
let hasSpreadElement: boolean = false;
let hasSpreadElement = false;
let elementTypes: Type[] = [];
forEach(elements, e => {
for (let e of elements) {
let type = checkExpression(e, contextualMapper);
if (e.kind === SyntaxKind.SpreadElementExpression) {
elementTypes.push(getIndexTypeOfType(type, IndexKind.Number) || anyType);
hasSpreadElement = true;
}
else {
elementTypes.push(type);
}
});
elementTypes.push(type);
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
}
if (!hasSpreadElement) {
let contextualType = getContextualType(node);
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || isAssignmentTarget(node)) {
@@ -6615,7 +6638,7 @@ module ts {
for (let i = 0; i < args.length; i++) {
let arg = args[i];
if (arg.kind !== SyntaxKind.OmittedExpression) {
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
let paramType = getTypeAtPosition(signature, i);
let argType: Type;
if (i === 0 && args[i].parent.kind === SyntaxKind.TaggedTemplateExpression) {
argType = globalTemplateStringsArrayType;
@@ -6638,7 +6661,7 @@ module ts {
// No need to check for omitted args and template expressions, their exlusion value is always undefined
if (excludeArgument[i] === false) {
let arg = args[i];
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
let paramType = getTypeAtPosition(signature, i);
inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType);
}
}
@@ -6671,7 +6694,7 @@ module ts {
let arg = args[i];
if (arg.kind !== SyntaxKind.OmittedExpression) {
// Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter)
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
let paramType = getTypeAtPosition(signature, i);
// A tagged template expression provides a special first argument, and string literals get string literal types
// unless we're reporting errors
let argType = i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression ? globalTemplateStringsArrayType :
@@ -7145,14 +7168,9 @@ module ts {
}
function getTypeAtPosition(signature: Signature, pos: number): Type {
if (pos >= 0) {
return signature.hasRestParameter ?
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType;
}
return signature.hasRestParameter ?
getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]) :
anyArrayType;
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType;
}
function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) {
@@ -7266,7 +7284,7 @@ module ts {
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
// Grammar checking
let hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
let hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node);
if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) {
checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
}
@@ -7312,7 +7330,7 @@ module ts {
function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) {
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
if (node.type) {
if (node.type && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
@@ -7588,11 +7606,10 @@ module ts {
}
function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
// TODOO(andersh): Allow iterable source type in ES6
if (!isArrayLikeType(sourceType)) {
error(node, Diagnostics.Type_0_is_not_an_array_type, typeToString(sourceType));
return sourceType;
}
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false);
let elements = node.elements;
for (let i = 0; i < elements.length; i++) {
let e = elements[i];
@@ -7600,8 +7617,9 @@ module ts {
if (e.kind !== SyntaxKind.SpreadElementExpression) {
let propName = "" + i;
let type = sourceType.flags & TypeFlags.Any ? sourceType :
isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) :
getIndexTypeOfType(sourceType, IndexKind.Number);
isTupleLikeType(sourceType)
? getTypeOfPropertyOfType(sourceType, propName)
: elementType;
if (type) {
checkDestructuringAssignment(e, type, contextualMapper);
}
@@ -7616,7 +7634,7 @@ module ts {
}
else {
if (i === elements.length - 1) {
checkReferenceAssignment((<SpreadElementExpression>e).expression, sourceType, contextualMapper);
checkReferenceAssignment((<SpreadElementExpression>e).expression, createArrayType(elementType), contextualMapper);
}
else {
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
@@ -7926,6 +7944,7 @@ module ts {
}
function checkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
checkGrammarIdentifierInStrictMode(node);
return checkExpressionOrQualifiedName(node, contextualMapper);
}
@@ -8041,6 +8060,8 @@ module ts {
// DECLARATION AND STATEMENT TYPE CHECKING
function checkTypeParameter(node: TypeParameterDeclaration) {
checkGrammarDeclarationNameInStrictMode(node);
// Grammar Checking
if (node.expression) {
grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected);
@@ -8309,10 +8330,13 @@ module ts {
}
function checkTypeReferenceNode(node: TypeReferenceNode) {
checkGrammarTypeReferenceInStrictMode(node.typeName);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkHeritageClauseElement(node: HeritageClauseElement) {
checkGrammarHeritageClauseElementInStrictMode(<PropertyAccessExpression>node.expression);
return checkTypeReferenceOrHeritageClauseElement(node);
}
@@ -8843,6 +8867,7 @@ module ts {
}
function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void {
checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSignatureDeclaration(node);
@@ -8878,7 +8903,7 @@ module ts {
}
checkSourceElement(node.body);
if (node.type && !isAccessor(node.kind)) {
if (node.type && !isAccessor(node.kind) && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
@@ -9126,6 +9151,7 @@ module ts {
// Check variable, parameter, or property declaration
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSourceElement(node.type);
// For a computed property, just check the initializer and exit
@@ -9373,29 +9399,44 @@ module ts {
function checkRightHandSideOfForOf(rhsExpression: Expression): Type {
let expressionType = getTypeOfExpression(rhsExpression);
return languageVersion >= ScriptTarget.ES6
? checkIteratedType(expressionType, rhsExpression)
: checkElementTypeOfArrayOrString(expressionType, rhsExpression);
return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true);
}
function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type {
if (languageVersion >= ScriptTarget.ES6) {
return checkIteratedType(inputType, errorNode) || anyType;
}
if (allowStringInput) {
return checkElementTypeOfArrayOrString(inputType, errorNode);
}
if (isArrayLikeType(inputType)) {
let indexType = getIndexTypeOfType(inputType, IndexKind.Number);
if (indexType) {
return indexType;
}
}
error(errorNode, Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
return unknownType;
}
/**
* When expressionForError is undefined, it means we should not report any errors.
* When errorNode is undefined, it means we should not report any errors.
*/
function checkIteratedType(iterable: Type, expressionForError: Expression): Type {
function checkIteratedType(iterable: Type, errorNode: Node): Type {
Debug.assert(languageVersion >= ScriptTarget.ES6);
let iteratedType = getIteratedType(iterable, expressionForError);
let iteratedType = getIteratedType(iterable, errorNode);
// Now even though we have extracted the iteratedType, we will have to validate that the type
// passed in is actually an Iterable.
if (expressionForError && iteratedType) {
let completeIterableType = globalIterableType !== emptyObjectType
? createTypeReference(<GenericType>globalIterableType, [iteratedType])
: emptyObjectType;
checkTypeAssignableTo(iterable, completeIterableType, expressionForError);
if (errorNode && iteratedType) {
checkTypeAssignableTo(iterable, createIterableType(iteratedType), errorNode);
}
return iteratedType;
function getIteratedType(iterable: Type, expressionForError: Expression) {
function getIteratedType(iterable: Type, errorNode: Node) {
// We want to treat type as an iterable, and get the type it is an iterable of. The iterable
// must have the following structure (annotated with the names of the variables below):
//
@@ -9426,6 +9467,12 @@ module ts {
return undefined;
}
// As an optimization, if the type is instantiated directly using the globalIterableType (Iterable<number>),
// then just grab its type argument.
if ((iterable.flags & TypeFlags.Reference) && (<GenericType>iterable).target === globalIterableType) {
return (<GenericType>iterable).typeArguments[0];
}
let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator"));
if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) {
return undefined;
@@ -9433,8 +9480,8 @@ module ts {
let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray;
if (iteratorFunctionSignatures.length === 0) {
if (expressionForError) {
error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
if (errorNode) {
error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
}
return undefined;
}
@@ -9451,8 +9498,8 @@ module ts {
let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray;
if (iteratorNextFunctionSignatures.length === 0) {
if (expressionForError) {
error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method);
if (errorNode) {
error(errorNode, Diagnostics.An_iterator_must_have_a_next_method);
}
return undefined;
}
@@ -9464,8 +9511,8 @@ module ts {
let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value");
if (!iteratorNextValue) {
if (expressionForError) {
error(expressionForError, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property);
if (errorNode) {
error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property);
}
return undefined;
}
@@ -9491,7 +9538,7 @@ module ts {
* 1. Some constituent is neither a string nor an array.
* 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable).
*/
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type {
Debug.assert(languageVersion < ScriptTarget.ES6);
// After we remove all types that are StringLike, we will know if there was a string constituent
@@ -9502,7 +9549,7 @@ module ts {
let reportedError = false;
if (hasStringConstituent) {
if (languageVersion < ScriptTarget.ES5) {
error(expressionForError, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
error(errorNode, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
reportedError = true;
}
@@ -9522,7 +9569,7 @@ module ts {
let diagnostic = hasStringConstituent
? Diagnostics.Type_0_is_not_an_array_type
: Diagnostics.Type_0_is_not_an_array_type_or_a_string_type;
error(expressionForError, diagnostic, typeToString(arrayType));
error(errorNode, diagnostic, typeToString(arrayType));
}
return hasStringConstituent ? stringType : unknownType;
}
@@ -9834,6 +9881,7 @@ module ts {
}
function checkClassDeclaration(node: ClassDeclaration) {
checkGrammarDeclarationNameInStrictMode(node);
// Grammar checking
if (node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.SourceFile) {
grammarErrorOnNode(node, Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
@@ -10060,7 +10108,7 @@ module ts {
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
// Grammar checking
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
@@ -10285,7 +10333,7 @@ module ts {
}
// Grammar checking
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
@@ -10355,7 +10403,7 @@ module ts {
function checkModuleDeclaration(node: ModuleDeclaration) {
if (produceDiagnostics) {
// Grammar checking
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -10459,7 +10507,7 @@ module ts {
}
function checkImportDeclaration(node: ImportDeclaration) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -10481,7 +10529,7 @@ module ts {
}
function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & NodeFlags.Export) {
@@ -10553,21 +10601,12 @@ module ts {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
}
if (node.expression) {
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
}
else {
checkExpressionCached(node.expression);
}
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
}
if (node.type) {
checkSourceElement(node.type);
if (!isInAmbientContext(node)) {
grammarErrorOnFirstToken(node.type, Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration);
}
else {
checkExpressionCached(node.expression);
}
checkExternalModuleExports(container);
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {
@@ -10821,6 +10860,8 @@ module ts {
checkGrammarSourceFile(node);
emitExtends = false;
emitDecorate = false;
emitParam = false;
potentialThisCollisions.length = 0;
forEach(node.statements, checkSourceElement);
@@ -11867,8 +11908,155 @@ module ts {
anyArrayType = createArrayType(anyType);
}
// GRAMMAR CHECKING
function isReservedwordInStrictMode(node: Identifier): boolean {
// Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word
return (node.parserContextFlags & ParserContextFlags.StrictMode) &&
(node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord);
}
function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
// if so, we would like to give more explicit invalid usage error.
if (getAncestor(identifier, SyntaxKind.ClassDeclaration) || getAncestor(identifier, SyntaxKind.ClassExpression)) {
return grammarErrorOnNode(identifier, message, arg0);
}
return false;
}
function checkGrammarImportDeclarationNameInStrictMode(node: ImportDeclaration): boolean {
// Check if the import declaration used strict-mode reserved word in its names bindings
if (node.importClause) {
let impotClause = node.importClause;
if (impotClause.namedBindings) {
let nameBindings = impotClause.namedBindings;
if (nameBindings.kind === SyntaxKind.NamespaceImport) {
let name = <Identifier>(<NamespaceImport>nameBindings).name;
if (name.originalKeywordKind) {
let nameText = declarationNameToString(name);
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
}
}
else if (nameBindings.kind === SyntaxKind.NamedImports) {
let reportError = false;
for (let element of (<NamedImports>nameBindings).elements) {
let name = element.name;
if (name.originalKeywordKind) {
let nameText = declarationNameToString(name);
reportError = reportError || grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
}
}
return reportError;
}
}
}
return false;
}
function checkGrammarDeclarationNameInStrictMode(node: Declaration): boolean {
let name = node.name;
if (name && name.kind === SyntaxKind.Identifier && isReservedwordInStrictMode(<Identifier>name)) {
let nameText = declarationNameToString(name);
switch (node.kind) {
case SyntaxKind.Parameter:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.TypeParameter:
case SyntaxKind.BindingElement:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
return checkGrammarIdentifierInStrictMode(<Identifier>name);
case SyntaxKind.ClassDeclaration:
// Report an error if the class declaration uses strict-mode reserved word.
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText);
case SyntaxKind.ModuleDeclaration:
// Report an error if the module declaration uses strict-mode reserved word.
// TODO(yuisu): fix this when having external module in strict mode
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
case SyntaxKind.ImportEqualsDeclaration:
// TODO(yuisu): fix this when having external module in strict mode
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
}
}
return false;
}
function checkGrammarTypeReferenceInStrictMode(typeName: Identifier | QualifiedName) {
// Check if the type reference is using strict mode keyword
// Example:
// class C {
// foo(x: public){} // Error.
// }
if (typeName.kind === SyntaxKind.Identifier) {
checkGrammarTypeNameInStrictMode(<Identifier>typeName);
}
// Report an error for each identifier in QualifiedName
// Example:
// foo (x: B.private.bar) // error at private
// foo (x: public.private.package) // error at public, private, and package
else if (typeName.kind === SyntaxKind.QualifiedName) {
// Walk from right to left and report a possible error at each Identifier in QualifiedName
// Example:
// x1: public.private.package // error at public and private
checkGrammarTypeNameInStrictMode((<QualifiedName>typeName).right);
checkGrammarTypeReferenceInStrictMode((<QualifiedName>typeName).left);
}
}
// This function will report an error for every identifier in property access expression
// whether it violates strict mode reserved words.
// Example:
// public // error at public
// public.private.package // error at public
// B.private.B // no error
function checkGrammarHeritageClauseElementInStrictMode(expression: Expression) {
// Example:
// class C extends public // error at public
if (expression && expression.kind === SyntaxKind.Identifier) {
return checkGrammarIdentifierInStrictMode(expression);
}
else if (expression && expression.kind === SyntaxKind.PropertyAccessExpression) {
// Walk from left to right in PropertyAccessExpression until we are at the left most expression
// in PropertyAccessExpression. According to grammar production of MemberExpression,
// the left component expression is a PrimaryExpression (i.e. Identifier) while the other
// component after dots can be IdentifierName.
checkGrammarHeritageClauseElementInStrictMode((<PropertyAccessExpression>expression).expression);
}
}
// The function takes an identifier itself or an expression which has SyntaxKind.Identifier.
function checkGrammarIdentifierInStrictMode(node: Expression | Identifier, nameText?: string): boolean {
if (node && node.kind === SyntaxKind.Identifier && isReservedwordInStrictMode(<Identifier>node)) {
if (!nameText) {
nameText = declarationNameToString(<Identifier>node);
}
// TODO (yuisu): Fix when module is a strict mode
let errorReport = reportStrictModeGrammarErrorInClassDeclaration(<Identifier>node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText)||
grammarErrorOnNode(node, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
return errorReport;
}
return false;
}
// The function takes an identifier when uses as a typeName in TypeReferenceNode
function checkGrammarTypeNameInStrictMode(node: Identifier): boolean {
if (node && node.kind === SyntaxKind.Identifier && isReservedwordInStrictMode(<Identifier>node)) {
let nameText = declarationNameToString(<Identifier>node);
// TODO (yuisu): Fix when module is a strict mode
let errorReport = reportStrictModeGrammarErrorInClassDeclaration(<Identifier>node, Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
grammarErrorOnNode(node, Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText);
return errorReport;
}
return false;
}
function checkGrammarDecorators(node: Node): boolean {
if (!node.decorators) {
return false;
@@ -12729,15 +12917,14 @@ module ts {
if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) {
let nameText = declarationNameToString(identifier);
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
// if so, we would like to give more explicit invalid usage error.
// This will be particularly helpful in the case of "arguments" as such case is very common mistake.
if (getAncestor(name, SyntaxKind.ClassDeclaration) || getAncestor(name, SyntaxKind.ClassExpression)) {
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
}
else {
// We check first if the name is inside class declaration or class expression; if so give explicit message
// otherwise report generic error message.
// reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise
let reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
if (!reportErrorInClassDeclaration){
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
return reportErrorInClassDeclaration;
}
}
}
-1
View File
@@ -164,7 +164,6 @@ module ts {
}
];
/* @internal */
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
var options: CompilerOptions = {};
var fileNames: string[] = [];
+4 -2
View File
@@ -1,7 +1,7 @@
/// <reference path="types.ts"/>
/* @internal */
module ts {
// Ternary values are defined such that
// x & y is False if either x or y is False.
// x & y is Maybe if either x or y is Maybe, but neither x or y is False.
@@ -434,7 +434,7 @@ module ts {
return path.replace(/\\/g, "/");
}
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/")
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
export function getRootLength(path: string): number {
if (path.charCodeAt(0) === CharacterCodes.slash) {
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
@@ -448,6 +448,8 @@ module ts {
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
return 2;
}
let idx = path.indexOf('://');
if (idx !== -1) return idx + 3
return 0;
}
+31 -10
View File
@@ -1,7 +1,7 @@
/// <reference path="checker.ts"/>
/* @internal */
module ts {
interface ModuleElementDeclarationEmitInfo {
node: Node;
outputPos: number;
@@ -442,20 +442,41 @@ module ts {
emitLines(node.statements);
}
// Return a temp variable name to be used in `export default` statements.
// The temp name will be of the form _default_counter.
// Note that export default is only allowed at most once in a module, so we
// do not need to keep track of created temp names.
function getExportDefaultTempVariableName(): string {
let baseName = "_default";
if (!hasProperty(currentSourceFile.identifiers, baseName)) {
return baseName;
}
let count = 0;
while (true) {
let name = baseName + "_" + (++count);
if (!hasProperty(currentSourceFile.identifiers, name)) {
return name;
}
}
}
function emitExportAssignment(node: ExportAssignment) {
write(node.isExportEquals ? "export = " : "export default ");
if (node.expression.kind === SyntaxKind.Identifier) {
write(node.isExportEquals ? "export = " : "export default ");
writeTextOfNode(currentSourceFile, node.expression);
}
else {
// Expression
let tempVarName = getExportDefaultTempVariableName();
write("declare var ");
write(tempVarName);
write(": ");
if (node.type) {
emitType(node.type);
}
else {
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
write(";");
writeLine();
write(node.isExportEquals ? "export = " : "export default ");
write(tempVarName);
}
write(";");
writeLine();
@@ -1540,7 +1561,7 @@ module ts {
}
}
// @internal
/* @internal */
export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) {
let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile);
// TODO(shkamat): Should we not write any declaration file if any of them can produce error,
@@ -1,5 +1,6 @@
// <auto-generated />
/// <reference path="types.ts" />
/* @internal */
module ts {
export var Diagnostics = {
Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." },
@@ -158,7 +159,6 @@ module ts {
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
@@ -169,6 +169,12 @@ module ts {
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." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." },
Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." },
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." },
@@ -344,8 +350,8 @@ module ts {
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." },
An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." },
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },
+31 -11
View File
@@ -623,10 +623,6 @@
"category": "Error",
"code": 1200
},
"A type annotation on an export statement is only allowed in an ambient external module declaration.": {
"category": "Error",
"code": 1201
},
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
"category": "Error",
"code": 1202
@@ -661,12 +657,36 @@
},
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1210
"code": 1210
},
"A class declaration without the 'default' modifier must have a name": {
"category": "Error",
"code": 1211
},
"Identifier expected. '{0}' is a reserved word in strict mode": {
"category": "Error",
"code": 1212
},
"Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1213
},
"Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode.": {
"category": "Error",
"code": 1214
},
"Type expected. '{0}' is a reserved word in strict mode": {
"category": "Error",
"code": 1215
},
"Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.": {
"category": "Error",
"code": 1216
},
"Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode.": {
"category": "Error",
"code": 1217
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
@@ -1367,11 +1387,11 @@
"category": "Error",
"code": 2487
},
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
"Type must have a '[Symbol.iterator]()' method that returns an iterator.": {
"category": "Error",
"code": 2488
},
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
"An iterator must have a 'next()' method.": {
"category": "Error",
"code": 2489
},
@@ -2023,19 +2043,19 @@
},
"'import ... =' can only be used in a .ts file.": {
"category": "Error",
"code": 8002
"code": 8002
},
"'export=' can only be used in a .ts file.": {
"category": "Error",
"code": 8003
"code": 8003
},
"'type parameter declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8004
"code": 8004
},
"'implements clauses' can only be used in a .ts file.": {
"category": "Error",
"code": 8005
"code": 8005
},
"'interface declarations' can only be used in a .ts file.": {
"category": "Error",
+192 -194
View File
@@ -1,6 +1,7 @@
/// <reference path="checker.ts"/>
/// <reference path="declarationEmitter.ts"/>
/* @internal */
module ts {
// represents one LexicalEnvironment frame to store unique generated names
interface ScopeFrame {
@@ -20,7 +21,6 @@ module ts {
_n = 0x20000000, // Use/preference flag for '_n'
}
// @internal
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult {
// emit output for the __extends helper function
@@ -1097,6 +1097,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
default:
return Comparison.LessThan;
}
case SyntaxKind.YieldExpression:
case SyntaxKind.ConditionalExpression:
return Comparison.LessThan;
default:
@@ -1136,8 +1137,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
if (!computedPropertyNamesToGeneratedNames) {
computedPropertyNamesToGeneratedNames = [];
}
let generatedName = computedPropertyNamesToGeneratedNames[node.id];
let generatedName = computedPropertyNamesToGeneratedNames[getNodeId(node)];
if (generatedName) {
// we have already generated a variable for this node, write that value instead.
write(generatedName);
@@ -1145,7 +1146,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
generatedName = createAndRecordTempVariable(TempFlags.Auto).text;
computedPropertyNamesToGeneratedNames[node.id] = generatedName;
computedPropertyNamesToGeneratedNames[getNodeId(node)] = generatedName;
write(generatedName);
write(" = ");
}
@@ -1305,6 +1306,17 @@ var __param = this.__param || function(index, decorator) { return function (targ
emit((<SpreadElementExpression>node).expression);
}
function emitYieldExpression(node: YieldExpression) {
write(tokenToString(SyntaxKind.YieldKeyword));
if (node.asteriskToken) {
write("*");
}
if (node.expression) {
write(" ");
emit(node.expression);
}
}
function needsParenthesisForPropertyAccessOrInvocation(node: Expression) {
switch (node.kind) {
case SyntaxKind.Identifier:
@@ -1381,211 +1393,163 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
}
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void {
let parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex);
return emit(parenthesizedObjectLiteral);
function emitObjectLiteralBody(node: ObjectLiteralExpression, numElements: number): void {
if (numElements === 0) {
write("{}");
return;
}
write("{");
if (numElements > 0) {
var properties = node.properties;
// If we are not doing a downlevel transformation for object literals,
// then try to preserve the original shape of the object literal.
// Otherwise just try to preserve the formatting.
if (numElements === properties.length) {
emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= ScriptTarget.ES5, /* spacesBetweenBraces */ true);
}
else {
let multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
if (!multiLine) {
write(" ");
}
else {
increaseIndent();
}
emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false);
if (!multiLine) {
write(" ");
}
else {
decreaseIndent();
}
}
}
write("}");
}
function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral: ObjectLiteralExpression, firstComputedPropertyIndex: number): ParenthesizedExpression {
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) {
let multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
let properties = node.properties;
write("(");
if (multiLine) {
increaseIndent();
}
// For computed properties, we need to create a unique handle to the object
// literal so we can modify it without risking internal assignments tainting the object.
let tempVar = createAndRecordTempVariable(TempFlags.Auto);
// Hold onto the initial non-computed properties in a new object literal,
// then create the rest through property accesses on the temp variable.
let initialObjectLiteral = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
initialObjectLiteral.properties = <NodeArray<ObjectLiteralElement>>originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex);
initialObjectLiteral.flags |= NodeFlags.MultiLine;
// Write out the first non-computed properties
// (or all properties if none of them are computed),
// then emit the rest through indexing on the temp variable.
emit(tempVar)
write(" = ");
emitObjectLiteralBody(node, firstComputedPropertyIndex);
// The comma expressions that will patch the object literal.
// This will end up being something like '_a = { ... }, _a.x = 10, _a.y = 20, _a'.
let propertyPatches = createBinaryExpression(tempVar, SyntaxKind.EqualsToken, initialObjectLiteral);
for (let i = firstComputedPropertyIndex, n = properties.length; i < n; i++) {
writeComma();
ts.forEach(originalObjectLiteral.properties, property => {
let patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property);
if (patchedProperty) {
// TODO(drosen): Preserve comments
//let leadingComments = getLeadingCommentRanges(currentSourceFile.text, property.pos);
//let trailingComments = getTrailingCommentRanges(currentSourceFile.text, property.end);
//addCommentsToSynthesizedNode(patchedProperty, leadingComments, trailingComments);
let property = properties[i];
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, patchedProperty);
emitStart(property)
if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) {
// TODO (drosen): Reconcile with 'emitMemberFunctions'.
let accessors = getAllAccessorDeclarations(node.properties, <AccessorDeclaration>property);
if (property !== accessors.firstAccessor) {
continue;
}
write("Object.defineProperty(");
emit(tempVar);
write(", ");
emitStart(node.name);
emitExpressionForPropertyName(property.name);
emitEnd(property.name);
write(", {");
increaseIndent();
if (accessors.getAccessor) {
writeLine()
emitLeadingComments(accessors.getAccessor);
write("get: ");
emitStart(accessors.getAccessor);
write("function ");
emitSignatureAndBody(accessors.getAccessor);
emitEnd(accessors.getAccessor);
emitTrailingComments(accessors.getAccessor);
write(",");
}
if (accessors.setAccessor) {
writeLine();
emitLeadingComments(accessors.setAccessor);
write("set: ");
emitStart(accessors.setAccessor);
write("function ");
emitSignatureAndBody(accessors.setAccessor);
emitEnd(accessors.setAccessor);
emitTrailingComments(accessors.setAccessor);
write(",");
}
writeLine();
write("enumerable: true,");
writeLine();
write("configurable: true");
decreaseIndent();
writeLine();
write("})");
emitEnd(property);
}
});
else {
emitLeadingComments(property);
emitStart(property.name);
emit(tempVar);
emitMemberAccessForPropertyName(property.name);
emitEnd(property.name);
// Finally, return the temp variable.
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, createIdentifier(tempVar.text, /*startsOnNewLine:*/ true));
write(" = ");
let result = createParenthesizedExpression(propertyPatches);
// TODO(drosen): Preserve comments
// let leadingComments = getLeadingCommentRanges(currentSourceFile.text, originalObjectLiteral.pos);
// let trailingComments = getTrailingCommentRanges(currentSourceFile.text, originalObjectLiteral.end);
//addCommentsToSynthesizedNode(result, leadingComments, trailingComments);
return result;
}
function addCommentsToSynthesizedNode(node: SynthesizedNode, leadingCommentRanges: CommentRange[], trailingCommentRanges: CommentRange[]): void {
node.leadingCommentRanges = leadingCommentRanges;
node.trailingCommentRanges = trailingCommentRanges;
}
// Returns 'undefined' if a property has already been accounted for
// (e.g. a 'get' accessor which has already been emitted along with its 'set' accessor).
function tryCreatePatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, tempVar: Identifier, property: ObjectLiteralElement): Expression {
let leftHandSide = createMemberAccessForPropertyName(tempVar, property.name);
let maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property);
return maybeRightHandSide && createBinaryExpression(leftHandSide, SyntaxKind.EqualsToken, maybeRightHandSide, /*startsOnNewLine:*/ true);
}
function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, property: ObjectLiteralElement) {
switch (property.kind) {
case SyntaxKind.PropertyAssignment:
return (<PropertyAssignment>property).initializer;
case SyntaxKind.ShorthandPropertyAssignment:
// TODO: (andersh) Technically it isn't correct to make an identifier here since getExpressionNamePrefix returns
// a string containing a dotted name. In general I'm not a fan of mini tree rewriters as this one, elsewhere we
// manage by just emitting strings (which is a lot more performant).
//let prefix = createIdentifier(resolver.getExpressionNamePrefix((<ShorthandPropertyAssignment>property).name));
//return createPropertyAccessExpression(prefix, (<ShorthandPropertyAssignment>property).name);
return createIdentifier(resolver.getExpressionNameSubstitution((<ShorthandPropertyAssignment>property).name, getGeneratedNameForNode));
case SyntaxKind.MethodDeclaration:
return createFunctionExpression((<MethodDeclaration>property).parameters, (<MethodDeclaration>property).body);
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
let { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(objectLiteral.properties, <AccessorDeclaration>property);
// Only emit the first accessor.
if (firstAccessor !== property) {
return undefined;
if (property.kind === SyntaxKind.PropertyAssignment) {
emit((<PropertyAssignment>property).initializer);
}
let propertyDescriptor = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
let descriptorProperties = <NodeArray<ObjectLiteralElement>>[];
if (getAccessor) {
let getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body));
descriptorProperties.push(getProperty);
else if (property.kind === SyntaxKind.ShorthandPropertyAssignment) {
emitExpressionIdentifier((<ShorthandPropertyAssignment>property).name);
}
if (setAccessor) {
let setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body));
descriptorProperties.push(setProperty);
else if (property.kind === SyntaxKind.MethodDeclaration) {
emitFunctionDeclaration(<MethodDeclaration>property);
}
else {
Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind);
}
}
let trueExpr = <PrimaryExpression>createSynthesizedNode(SyntaxKind.TrueKeyword);
let enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr);
descriptorProperties.push(enumerableTrue);
let configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr);
descriptorProperties.push(configurableTrue);
propertyDescriptor.properties = descriptorProperties;
let objectDotDefineProperty = createPropertyAccessExpression(createIdentifier("Object"), createIdentifier("defineProperty"));
return createCallExpression(objectDotDefineProperty, createNodeArray(propertyDescriptor));
default:
Debug.fail(`ObjectLiteralElement kind ${property.kind} not accounted for.`);
emitEnd(property);
}
}
function createParenthesizedExpression(expression: Expression) {
let result = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
result.expression = expression;
writeComma();
emit(tempVar);
return result;
}
function createNodeArray<T extends Node>(...elements: T[]): NodeArray<T> {
let result = <NodeArray<T>>elements;
result.pos = -1;
result.end = -1;
return result;
}
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression {
let result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine);
result.operatorToken = createSynthesizedNode(operator);
result.left = left;
result.right = right;
return result;
}
function createExpressionStatement(expression: Expression): ExpressionStatement {
let result = <ExpressionStatement>createSynthesizedNode(SyntaxKind.ExpressionStatement);
result.expression = expression;
return result;
}
function createMemberAccessForPropertyName(expression: LeftHandSideExpression, memberName: DeclarationName): PropertyAccessExpression | ElementAccessExpression {
if (memberName.kind === SyntaxKind.Identifier) {
return createPropertyAccessExpression(expression, <Identifier>memberName);
if (multiLine) {
decreaseIndent();
writeLine();
}
else if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) {
return createElementAccessExpression(expression, <LiteralExpression>memberName);
write(")");
function writeComma() {
if (multiLine) {
write(",");
writeLine();
}
else {
write(", ");
}
}
else if (memberName.kind === SyntaxKind.ComputedPropertyName) {
return createElementAccessExpression(expression, (<ComputedPropertyName>memberName).expression);
}
else {
Debug.fail(`Kind '${memberName.kind}' not accounted for.`);
}
}
function createPropertyAssignment(name: LiteralExpression | Identifier, initializer: Expression) {
let result = <PropertyAssignment>createSynthesizedNode(SyntaxKind.PropertyAssignment);
result.name = name;
result.initializer = initializer;
return result;
}
function createFunctionExpression(parameters: NodeArray<ParameterDeclaration>, body: Block): FunctionExpression {
let result = <FunctionExpression>createSynthesizedNode(SyntaxKind.FunctionExpression);
result.parameters = parameters;
result.body = body;
return result;
}
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
result.expression = expression;
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
result.name = name;
return result;
}
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
result.expression = expression;
result.argumentExpression = argumentExpression;
return result;
}
function createIdentifier(name: string, startsOnNewLine?: boolean) {
let result = <Identifier>createSynthesizedNode(SyntaxKind.Identifier, startsOnNewLine);
result.text = name;
return result;
}
function createCallExpression(invokedExpression: MemberExpression, arguments: NodeArray<Expression>) {
let result = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
result.expression = invokedExpression;
result.arguments = arguments;
return result;
}
function emitObjectLiteral(node: ObjectLiteralExpression): void {
@@ -1613,13 +1577,33 @@ var __param = this.__param || function(index, decorator) { return function (targ
// Ordinary case: either the object has no computed properties
// or we're compiling with an ES6+ target.
write("{");
emitObjectLiteralBody(node, properties.length);
}
if (properties.length) {
emitLinePreservingList(node, properties, /*allowTrailingComma:*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces:*/ true)
}
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression {
let result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine);
result.operatorToken = createSynthesizedNode(operator);
result.left = left;
result.right = right;
write("}");
return result;
}
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
result.expression = expression;
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
result.name = name;
return result;
}
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
result.expression = expression;
result.argumentExpression = argumentExpression;
return result;
}
function emitComputedPropertyName(node: ComputedPropertyName) {
@@ -1629,6 +1613,10 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
function emitMethod(node: MethodDeclaration) {
if (languageVersion >= ScriptTarget.ES6 && node.asteriskToken) {
write("*");
}
emit(node.name, /*allowGeneratedIdentifiers*/ false);
if (languageVersion < ScriptTarget.ES6) {
write(": function ");
@@ -2988,7 +2976,12 @@ var __param = this.__param || function(index, decorator) { return function (targ
write("default ");
}
}
write("function ");
write("function");
if (languageVersion >= ScriptTarget.ES6 && node.asteriskToken) {
write("*");
}
write(" ");
}
if (shouldEmitFunctionName(node)) {
@@ -3372,6 +3365,9 @@ var __param = this.__param || function(index, decorator) { return function (targ
else if (member.kind === SyntaxKind.SetAccessor) {
write("set ");
}
if ((<MethodDeclaration>member).asteriskToken) {
write("*");
}
emit((<MethodDeclaration>member).name);
emitSignatureAndBody(<MethodDeclaration>member);
emitEnd(member);
@@ -4950,6 +4946,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
return emitConditionalExpression(<ConditionalExpression>node);
case SyntaxKind.SpreadElementExpression:
return emitSpreadElementExpression(<SpreadElementExpression>node);
case SyntaxKind.YieldExpression:
return emitYieldExpression(<YieldExpression>node);
case SyntaxKind.OmittedExpression:
return;
case SyntaxKind.Block:
+42 -11
View File
@@ -299,8 +299,7 @@ module ts {
case SyntaxKind.ExportAssignment:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ExportAssignment>node).expression) ||
visitNode(cbNode, (<ExportAssignment>node).type);
visitNode(cbNode, (<ExportAssignment>node).expression);
case SyntaxKind.TemplateExpression:
return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);
case SyntaxKind.TemplateSpan:
@@ -1350,6 +1349,7 @@ module ts {
return speculationHelper(callback, /*isLookAhead:*/ false);
}
// Ignore strict mode flag because we will report an error in type checker instead.
function isIdentifier(): boolean {
if (token === SyntaxKind.Identifier) {
return true;
@@ -1361,7 +1361,7 @@ module ts {
return false;
}
return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord;
return token > SyntaxKind.LastReservedWord;
}
function parseExpected(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage): boolean {
@@ -1485,6 +1485,11 @@ module ts {
identifierCount++;
if (isIdentifier) {
let node = <Identifier>createNode(SyntaxKind.Identifier);
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
if (token !== SyntaxKind.Identifier) {
node.originalKeywordKind = token;
}
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
@@ -3221,6 +3226,16 @@ module ts {
}
}
// If encounter "([" or "({", this could be the start of a binding pattern.
// Examples:
// ([ x ]) => { }
// ({ x }) => { }
// ([ x ])
// ({ x })
if (second === SyntaxKind.OpenBracketToken || second === SyntaxKind.OpenBraceToken) {
return Tristate.Unknown;
}
// Simple case: "(..."
// This is an arrow function with a rest parameter.
if (second === SyntaxKind.DotDotDotToken) {
@@ -4590,6 +4605,18 @@ module ts {
return finishNode(node);
}
function isClassMemberModifier(idToken: SyntaxKind) {
switch (idToken) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.StaticKeyword:
return true;
default:
return false;
}
}
function isClassMemberStart(): boolean {
let idToken: SyntaxKind;
@@ -4600,6 +4627,16 @@ module ts {
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
while (isModifier(token)) {
idToken = token;
// If the idToken is a class modifier (protected, private, public, and static), it is
// certain that we are starting to parse class member. This allows better error recovery
// Example:
// public foo() ... // true
// public @dec blah ... // true; we will then report an error later
// export public ... // true; we will then report an error later
if (isClassMemberModifier(idToken)) {
return true;
}
nextToken();
}
@@ -5123,17 +5160,11 @@ module ts {
setModifiers(node, modifiers);
if (parseOptional(SyntaxKind.EqualsToken)) {
node.isExportEquals = true;
node.expression = parseAssignmentExpressionOrHigher();
}
else {
parseExpected(SyntaxKind.DefaultKeyword);
if (parseOptional(SyntaxKind.ColonToken)) {
node.type = parseType();
}
else {
node.expression = parseAssignmentExpressionOrHigher();
}
}
node.expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
return finishNode(node);
}
@@ -5299,7 +5330,7 @@ module ts {
break;
}
let range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() };
let range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() };
let comment = sourceText.substring(range.pos, range.end);
let referencePathMatchResult = getFileReferenceFromReferencePath(comment, range);
+1 -1
View File
@@ -8,7 +8,7 @@ module ts {
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export let version = "1.5.0";
export const version = "1.5.0";
export function findConfigFile(searchPath: string): string {
var fileName = "tsconfig.json";
+11 -2
View File
@@ -2,11 +2,12 @@
/// <reference path="diagnosticInformationMap.generated.ts"/>
module ts {
/* @internal */
export interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
/* @internal */
export interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
@@ -262,6 +263,7 @@ module ts {
return textToToken[s];
}
/* @internal */
export function computeLineStarts(text: string): number[] {
let result: number[] = new Array();
let pos = 0;
@@ -293,15 +295,18 @@ module ts {
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character);
}
/* @internal */
export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number {
Debug.assert(line >= 0 && line < lineStarts.length);
return lineStarts[line] + character;
}
/* @internal */
export function getLineStarts(sourceFile: SourceFile): number[] {
return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
}
/* @internal */
export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) {
let lineNumber = binarySearch(lineStarts, position);
if (lineNumber < 0) {
@@ -362,10 +367,12 @@ module ts {
return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
}
/* @internal */
export function isOctalDigit(ch: number): boolean {
return ch >= CharacterCodes._0 && ch <= CharacterCodes._7;
}
/* @internal */
export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number {
while (true) {
let ch = text.charCodeAt(pos);
@@ -523,6 +530,7 @@ module ts {
let nextChar = text.charCodeAt(pos + 1);
let hasTrailingNewLine = false;
if (nextChar === CharacterCodes.slash || nextChar === CharacterCodes.asterisk) {
let kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia;
let startPos = pos;
pos += 2;
if (nextChar === CharacterCodes.slash) {
@@ -548,7 +556,7 @@ module ts {
result = [];
}
result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine });
result.push({ pos: startPos, end: pos, hasTrailingNewLine, kind });
}
continue;
}
@@ -587,6 +595,7 @@ module ts {
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
}
/* @internal */
export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner {
let pos: number; // Current position (end position of text of current token)
let len: number; // Length of text
+5 -5
View File
@@ -6,17 +6,17 @@ module ts {
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(fileName: string, encoding?: string): string;
writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void;
watchFile? (fileName: string, callback: (fileName: string) => void): FileWatcher;
readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string) => void): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
directoryExists(path: string): boolean;
createDirectory(directoryName: string): void;
createDirectory(path: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
readDirectory(path: string, extension?: string): string[];
getMemoryUsage? (): number;
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
+97 -49
View File
@@ -320,6 +320,7 @@ module ts {
BlockScoped = Let | Const
}
/* @internal */
export const enum ParserContextFlags {
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
// checking if the node can be reused in incremental settings.
@@ -355,6 +356,7 @@ module ts {
HasAggregatedChildData = 1 << 7
}
/* @internal */
export const enum RelationComparisonResult {
Succeeded = 1, // Should be truthy
Failed = 2,
@@ -366,15 +368,15 @@ module ts {
flags: NodeFlags;
// Specific context the parser was in when this node was created. Normally undefined.
// Only set when the parser was in some interesting context (like async/yield).
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding)
symbol?: Symbol; // Symbol declared by node (initialized by binding)
locals?: SymbolTable; // Locals associated with node (initialized by binding)
nextContainer?: Node; // Next container in declaration order (initialized by binding)
localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
/* @internal */ parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding)
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
}
export interface NodeArray<T> extends Array<T>, TextRange {
@@ -386,7 +388,8 @@ module ts {
}
export interface Identifier extends PrimaryExpression {
text: string; // Text of identifier (with escapes converted to characters)
text: string; // Text of identifier (with escapes converted to characters)
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
}
export interface QualifiedName extends Node {
@@ -975,8 +978,7 @@ module ts {
export interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression?: Expression;
type?: TypeNode;
expression: Expression;
}
export interface FileReference extends TextRange {
@@ -985,6 +987,7 @@ module ts {
export interface CommentRange extends TextRange {
hasTrailingNewLine?: boolean;
kind: SyntaxKind;
}
// Source files are declarations when they are external modules.
@@ -1001,11 +1004,12 @@ module ts {
hasNoDefaultLib: boolean;
// The first node that causes this file to be an external module
externalModuleIndicator: Node;
languageVersion: ScriptTarget;
identifiers: Map<string>;
// The first node that causes this file to be an external module
/* @internal */ externalModuleIndicator: Node;
/* @internal */ identifiers: Map<string>;
/* @internal */ nodeCount: number;
/* @internal */ identifierCount: number;
/* @internal */ symbolCount: number;
@@ -1033,6 +1037,9 @@ module ts {
}
export interface Program extends ScriptReferenceHost {
/**
* Get a list of files in the program
*/
getSourceFiles(): SourceFile[];
/**
@@ -1052,10 +1059,12 @@ module ts {
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
// Gets a type checker that can be used to semantically analyze source fils in the program.
/**
* Gets a type checker that can be used to semantically analyze source fils in the program.
*/
getTypeChecker(): TypeChecker;
getCommonSourceDirectory(): string;
/* @internal */ getCommonSourceDirectory(): string;
// For testing purposes only. Should not be used by any other consumers (including the
// language service).
@@ -1068,12 +1077,18 @@ module ts {
}
export interface SourceMapSpan {
emittedLine: number; // Line number in the .js file
emittedColumn: number; // Column number in the .js file
sourceLine: number; // Line number in the .ts file
sourceColumn: number; // Column number in the .ts file
nameIndex?: number; // Optional name (index into names array) associated with this span
sourceIndex: number; // .ts file (index into sources array) associated with this span*/
/** Line number in the .js file. */
emittedLine: number;
/** Column number in the .js file. */
emittedColumn: number;
/** Line number in the .ts file. */
sourceLine: number;
/** Column number in the .ts file. */
sourceColumn: number;
/** Optional name (index into names array) associated with this span. */
nameIndex?: number;
/** .ts file (index into sources array) associated with this span */
sourceIndex: number;
}
export interface SourceMapData {
@@ -1088,7 +1103,7 @@ module ts {
sourceMapDecodedMappings: SourceMapSpan[]; // Raw source map spans that were encoded into the sourceMapMappings
}
// Return code used by getEmitOutput function to indicate status of the function
/** Return code used by getEmitOutput function to indicate status of the function */
export enum ExitStatus {
// Compiler ran successfully. Either this was a simple do-nothing compilation (for example,
// when -version or -help was provided, or this was a normal compilation, no diagnostics
@@ -1105,7 +1120,7 @@ module ts {
export interface EmitResult {
emitSkipped: boolean;
diagnostics: Diagnostic[];
sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
/* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
}
export interface TypeCheckerHost {
@@ -1124,8 +1139,6 @@ module ts {
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
getReturnTypeOfSignature(signature: Signature): Type;
// If 'predicate' is supplied, then only the first symbol in scope matching the predicate
// will be returned. Otherwise, all symbols in scope will be returned.
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolAtLocation(node: Node): Symbol;
getShorthandAssignmentValueSymbol(location: Node): Symbol;
@@ -1217,14 +1230,17 @@ module ts {
UseOnlyExternalAliasing = 0x00000002,
}
/* @internal */
export const enum SymbolAccessibility {
Accessible,
NotAccessible,
CannotBeNamed
}
/* @internal */
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
/* @internal */
export interface SymbolVisibilityResult {
accessibility: SymbolAccessibility;
aliasesToMakeVisible?: AnyImportSyntax[]; // aliases that need to have this symbol visible
@@ -1232,10 +1248,12 @@ module ts {
errorNode?: Node; // optional node that results in error
}
/* @internal */
export interface SymbolAccessiblityResult extends SymbolVisibilityResult {
errorModuleName?: string // If the symbol is not visible from module, module's name
}
/* @internal */
export interface EmitResolver {
hasGlobalName(name: string): boolean;
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
@@ -1340,19 +1358,20 @@ module ts {
}
export interface Symbol {
flags: SymbolFlags; // Symbol flags
name: string; // Name of symbol
id?: number; // Unique id (used to look up SymbolLinks)
mergeId?: number; // Merge id (used to look up merged symbol)
declarations?: Declaration[]; // Declarations associated with this symbol
parent?: Symbol; // Parent symbol
members?: SymbolTable; // Class, interface or literal instance members
exports?: SymbolTable; // Module exports
exportSymbol?: Symbol; // Exported symbol associated with this symbol
valueDeclaration?: Declaration // First value declaration of the symbol
constEnumOnlyModule?: boolean // True if module contains only const enums or other modules with only const enums
flags: SymbolFlags; // Symbol flags
name: string; // Name of symbol
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
declarations?: Declaration[]; // Declarations associated with this symbol
/* @internal */ parent?: Symbol; // Parent symbol
members?: SymbolTable; // Class, interface or literal instance members
exports?: SymbolTable; // Module exports
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
valueDeclaration?: Declaration; // First value declaration of the symbol
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
}
/* @internal */
export interface SymbolLinks {
target?: Symbol; // Resolved (non-alias) target of an alias
type?: Type; // Type of value symbol
@@ -1364,12 +1383,14 @@ module ts {
exportsChecked?: boolean; // True if exports of external module have been checked
}
/* @internal */
export interface TransientSymbol extends Symbol, SymbolLinks { }
export interface SymbolTable {
[index: string]: Symbol;
}
/* @internal */
export const enum NodeCheckFlags {
TypeChecked = 0x00000001, // Node has been type checked
LexicalThis = 0x00000002, // Lexical 'this' reference
@@ -1386,6 +1407,7 @@ module ts {
EmitParam = 0x00000400, // Emit __param helper for decorators
}
/* @internal */
export interface NodeLinks {
resolvedType?: Type; // Cached type of type node
resolvedSignature?: Signature; // Cached signature of signature node or call expression
@@ -1418,27 +1440,34 @@ module ts {
Tuple = 0x00002000, // Tuple
Union = 0x00004000, // Union
Anonymous = 0x00008000, // Anonymous
/* @internal */
FromSignature = 0x00010000, // Created for signature assignment check
ObjectLiteral = 0x00020000, // Originates in an object literal
/* @internal */
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
/* @internal */
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
/* @internal */
Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum,
StringLike = String | StringLiteral,
NumberLike = Number | Enum,
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
}
// Properties common to all types
export interface Type {
flags: TypeFlags; // Flags
id: number; // Unique ID
symbol?: Symbol; // Symbol associated with type (if any)
flags: TypeFlags; // Flags
/* @internal */ id: number; // Unique ID
symbol?: Symbol; // Symbol associated with type (if any)
}
/* @internal */
// Intrinsic types (TypeFlags.Intrinsic)
export interface IntrinsicType extends Type {
intrinsicName: string; // Name of intrinsic type
@@ -1471,6 +1500,7 @@ module ts {
// Generic class and interface types
export interface GenericType extends InterfaceType, TypeReference {
/* @internal */
instantiations: Map<TypeReference>; // Generic instantiation cache
}
@@ -1481,9 +1511,11 @@ module ts {
export interface UnionType extends Type {
types: Type[]; // Constituent types
/* @internal */
resolvedProperties: SymbolTable; // Cache of resolved properties
}
/* @internal */
// Resolved object or union type
export interface ResolvedType extends ObjectType, UnionType {
members: SymbolTable; // Properties by name
@@ -1497,7 +1529,9 @@ module ts {
// Type parameters (TypeFlags.TypeParameter)
export interface TypeParameter extends Type {
constraint: Type; // Constraint
/* @internal */
target?: TypeParameter; // Instantiation target
/* @internal */
mapper?: TypeMapper; // Instantiation mapper
}
@@ -1510,14 +1544,23 @@ module ts {
declaration: SignatureDeclaration; // Originating declaration
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
parameters: Symbol[]; // Parameters
/* @internal */
resolvedReturnType: Type; // Resolved return type
/* @internal */
minArgumentCount: number; // Number of non-optional parameters
/* @internal */
hasRestParameter: boolean; // True if last parameter is rest parameter
/* @internal */
hasStringLiterals: boolean; // True if specialized
/* @internal */
target?: Signature; // Instantiation target
/* @internal */
mapper?: TypeMapper; // Instantiation mapper
/* @internal */
unionSignatures?: Signature[]; // Underlying signatures of a union signature
/* @internal */
erasedSignatureCache?: Signature; // Erased version of signature (deferred)
/* @internal */
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
}
@@ -1526,11 +1569,12 @@ module ts {
Number,
}
/* @internal */
export interface TypeMapper {
(t: Type): Type;
}
// @internal
/* @internal */
export interface TypeInferences {
primary: Type[]; // Inferences made directly to a type parameter
secondary: Type[]; // Inferences made to a type parameter in a union type
@@ -1538,7 +1582,7 @@ module ts {
// If a type parameter is fixed, no more inferences can be made for the type parameter
}
// @internal
/* @internal */
export interface InferenceContext {
typeParameters: TypeParameter[]; // Type parameters for which inferences are made
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
@@ -1554,10 +1598,12 @@ module ts {
code: number;
}
// A linked list of formatted diagnostic messages to be used as part of a multiline message.
// It is built from the bottom up, leaving the head to be the "main" diagnostic.
// While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage,
// the difference is that messages are all preformatted in DMC.
/**
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
* It is built from the bottom up, leaving the head to be the "main" diagnostic.
* While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage,
* the difference is that messages are all preformatted in DMC.
*/
export interface DiagnosticMessageChain {
messageText: string;
category: DiagnosticCategory;
@@ -1641,6 +1687,7 @@ module ts {
errors: Diagnostic[];
}
/* @internal */
export interface CommandLineOption {
name: string;
type: string | Map<number>; // "string", "number", "boolean", or an object literal mapping named values to actual values
@@ -1652,6 +1699,7 @@ module ts {
experimental?: boolean;
}
/* @internal */
export const enum CharacterCodes {
nullCharacter = 0,
maxAsciiCharacter = 0x7F,
@@ -1813,7 +1861,7 @@ module ts {
newLength: number;
}
// @internal
/* @internal */
export interface DiagnosticCollection {
// Adds a diagnostic to this diagnostic collection.
add(diagnostic: Diagnostic): void;
+12 -1
View File
@@ -1,5 +1,6 @@
/// <reference path="binder.ts" />
/* @internal */
module ts {
export interface ReferencePathMatchResult {
fileReference?: FileReference
@@ -160,6 +161,14 @@ module ts {
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
}
export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
if (nodeIsMissing(node) || !node.decorators) {
return getTokenPosOfNode(node, sourceFile);
}
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
}
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
if (nodeIsMissing(node)) {
return "";
@@ -780,6 +789,8 @@ module ts {
return node === (<TemplateSpan>parent).expression;
case SyntaxKind.ComputedPropertyName:
return node === (<ComputedPropertyName>parent).expression;
case SyntaxKind.Decorator:
return true;
default:
if (isExpression(parent)) {
return true;
@@ -1368,7 +1379,7 @@ module ts {
return node;
}
// @internal
/* @internal */
export function createDiagnosticCollection(): DiagnosticCollection {
let nonFileDiagnostics: Diagnostic[] = [];
let fileDiagnostics: Map<Diagnostic[]> = {};
+3
View File
@@ -336,6 +336,9 @@ module Harness.LanguageService {
getOccurrencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
return unwrapJSONCallResult(this.shim.getOccurrencesAtPosition(fileName, position));
}
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): ts.DocumentHighlights[] {
return unwrapJSONCallResult(this.shim.getDocumentHighlights(fileName, position, JSON.stringify(filesToSearch)));
}
getNavigateToItems(searchValue: string): ts.NavigateToItem[] {
return unwrapJSONCallResult(this.shim.getNavigateToItems(searchValue));
}
+27 -74
View File
@@ -1,6 +1,5 @@
interface TypeWriterResult {
line: number;
column: number;
syntaxKind: number;
sourceText: string;
type: string;
@@ -29,89 +28,43 @@ class TypeWriterWalker {
}
private visitNode(node: ts.Node): void {
switch (node.kind) {
// Should always log expressions that are not tokens
// Also, always log the "this" keyword
// TODO: Ideally we should log all expressions, but to compare to the
// old typeWriter baselines, suppress tokens
case ts.SyntaxKind.ThisKeyword:
case ts.SyntaxKind.SuperKeyword:
case ts.SyntaxKind.ArrayLiteralExpression:
case ts.SyntaxKind.ObjectLiteralExpression:
case ts.SyntaxKind.ElementAccessExpression:
case ts.SyntaxKind.CallExpression:
case ts.SyntaxKind.NewExpression:
case ts.SyntaxKind.TypeAssertionExpression:
case ts.SyntaxKind.ParenthesizedExpression:
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.TypeOfExpression:
case ts.SyntaxKind.VoidExpression:
case ts.SyntaxKind.DeleteExpression:
case ts.SyntaxKind.PrefixUnaryExpression:
case ts.SyntaxKind.PostfixUnaryExpression:
case ts.SyntaxKind.BinaryExpression:
case ts.SyntaxKind.ConditionalExpression:
this.log(node, this.getTypeOfNode(node));
break;
case ts.SyntaxKind.PropertyAccessExpression:
for (var current = node; current.kind === ts.SyntaxKind.PropertyAccessExpression; current = current.parent) {
}
if (current.kind !== ts.SyntaxKind.HeritageClauseElement) {
this.log(node, this.getTypeOfNode(node));
}
break;
// Should not change expression status (maybe expressions)
// TODO: Again, ideally should log number and string literals too,
// but to be consistent with the old typeWriter, just log identifiers
case ts.SyntaxKind.Identifier:
var identifier = <ts.Identifier>node;
if (!this.isLabel(identifier)) {
var type = this.getTypeOfNode(identifier);
this.log(node, type);
}
break;
if (ts.isExpression(node) || node.kind === ts.SyntaxKind.Identifier) {
this.logTypeAndSymbol(node);
}
ts.forEachChild(node, child => this.visitNode(child));
}
private isLabel(identifier: ts.Identifier): boolean {
var parent = identifier.parent;
switch (parent.kind) {
case ts.SyntaxKind.ContinueStatement:
case ts.SyntaxKind.BreakStatement:
return (<ts.BreakOrContinueStatement>parent).label === identifier;
case ts.SyntaxKind.LabeledStatement:
return (<ts.LabeledStatement>parent).label === identifier;
}
return false;
}
private log(node: ts.Node, type: ts.Type): void {
private logTypeAndSymbol(node: ts.Node): void {
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
// If we got an unknown type, we temporarily want to fall back to just pretending the name
// (source text) of the node is the type. This is to align with the old typeWriter to make
// baseline comparisons easier. In the long term, we will want to just call typeToString
this.results.push({
line: lineAndCharacter.line,
// todo(cyrusn): Not sure why column is one-based for type-writer. But I'm preserving
// that behavior to prevent having a lot of baselines to fix up.
column: lineAndCharacter.character + 1,
syntaxKind: node.kind,
sourceText: sourceText,
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)
});
}
private getTypeOfNode(node: ts.Node): ts.Type {
var type = this.checker.getTypeAtLocation(node);
ts.Debug.assert(type !== undefined, "type doesn't exist");
return type;
var symbol = this.checker.getSymbolAtLocation(node);
var typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation);
if (symbol) {
var symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent);
if (symbol.declarations) {
for (let declaration of symbol.declarations) {
symbolString += ", ";
let declSourceFile = declaration.getSourceFile();
let declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })`
}
}
symbolString += ")";
typeString += ", " + symbolString;
}
this.results.push({
line: lineAndCharacter.line,
syntaxKind: node.kind,
sourceText: sourceText,
type: typeString
});
}
}
+1 -1
View File
@@ -823,7 +823,7 @@ interface RegExp {
*/
test(string: string): boolean;
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
source: string;
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
+19 -12
View File
@@ -50,26 +50,21 @@ interface SymbolConstructor {
*/
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
* for-of statement.
*/
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
* abstract operation.
*/
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
toStringTag: symbol;
@@ -111,7 +106,7 @@ interface ObjectConstructor {
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
@@ -598,8 +593,6 @@ interface Math {
}
interface RegExp {
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
* that search.
@@ -631,6 +624,20 @@ interface RegExp {
*/
split(string: string, limit?: number): string[];
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
+25 -1
View File
@@ -104,7 +104,7 @@ module ts.server {
var response: T = JSON.parse(responseBody);
}
catch (e) {
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error detailes: " + e.message);
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error details: " + e.message);
}
// verify the sequence numbers
@@ -446,6 +446,7 @@ module ts.server {
if (!response.body) {
return undefined;
}
var helpItems: protocol.SignatureHelpItems = response.body;
var span = helpItems.applicableSpan;
var start = this.lineOffsetToPosition(fileName, span.start);
@@ -465,6 +466,29 @@ module ts.server {
}
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
var args: protocol.FileLocationRequestArgs = {
file: fileName,
line: lineOffset.line,
offset: lineOffset.offset,
};
var request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
var response = this.processResponse<protocol.OccurrencesResponse>(request);
return response.body.map(entry => {
var fileName = entry.file;
var start = this.lineOffsetToPosition(fileName, entry.start);
var end = this.lineOffsetToPosition(fileName, entry.end);
return {
fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
isWriteAccess: entry.isWriteAccess,
};
});
}
getDocumentHighlights(fileName: string, position: number): DocumentHighlights[] {
throw new Error("Not Implemented Yet.");
}
+19
View File
@@ -165,6 +165,25 @@ declare module ts.server.protocol {
body?: FileSpan[];
}
/**
* Get occurrences request; value of command field is
* "occurrences". Return response giving spans that are relevant
* in the file at a given line and column.
*/
export interface OccurrencesRequest extends FileLocationRequest {
}
export interface OccurrencesResponseItem extends FileSpan {
/**
* True if the occurrence is a write location, false otherwise.
*/
isWriteAccess: boolean;
}
export interface OccurrencesResponse extends Response {
body?: OccurrencesResponseItem[];
}
/**
* Find references request; value of command field is
* "references". Return response giving the file locations that
+37 -1
View File
@@ -89,6 +89,7 @@ module ts.server {
export var Geterr = "geterr";
export var NavBar = "navbar";
export var Navto = "navto";
export var Occurrences = "occurrences";
export var Open = "open";
export var Quickinfo = "quickinfo";
export var References = "references";
@@ -284,6 +285,36 @@ module ts.server {
}));
}
getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[] {
fileName = ts.normalizePath(fileName);
let project = this.projectService.getProjectForFile(fileName);
if (!project) {
throw Errors.NoProject;
}
let { compilerService } = project;
let position = compilerService.host.lineOffsetToPosition(fileName, line, offset);
let occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, position);
if (!occurrences) {
return undefined;
}
return occurrences.map(occurrence => {
let { fileName, isWriteAccess, textSpan } = occurrence;
let start = compilerService.host.positionToLineOffset(fileName, textSpan.start);
let end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan));
return {
start,
end,
file: fileName,
isWriteAccess
}
});
}
getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
@@ -378,7 +409,7 @@ module ts.server {
var nameSpan = nameInfo.textSpan;
var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
var bakedRefs: protocol.ReferencesResponseItem[] = references.map((ref) => {
var bakedRefs: protocol.ReferencesResponseItem[] = references.map(ref => {
var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start);
var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
@@ -884,6 +915,11 @@ module ts.server {
response = this.getNavigationBarItems(navBarArgs.file);
break;
}
case CommandNames.Occurrences: {
var { line, offset, file: fileName } = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getOccurrences(line, offset, fileName);
break;
}
default: {
this.projectService.log("Unrecognized JSON command: " + message);
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
+1 -4
View File
@@ -3,6 +3,7 @@
/// <reference path='services.ts' />
/* @internal */
module ts.BreakpointResolver {
/**
* Get the breakpoint span in given sourceFile
@@ -173,10 +174,6 @@ module ts.BreakpointResolver {
return textSpan(node, (<ThrowStatement>node).expression);
case SyntaxKind.ExportAssignment:
if (!(<ExportAssignment>node).expression) {
return undefined;
}
// span on export = id
return textSpan(node, (<ExportAssignment>node).expression);
+20 -7
View File
@@ -3,6 +3,7 @@
///<reference path='rulesProvider.ts' />
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export interface TextRangeWithKind extends TextRange {
@@ -328,8 +329,13 @@ module ts.formatting {
if (formattingScanner.isOnToken()) {
let startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
let undecoratedStartLine = startLine;
if (enclosingNode.decorators) {
undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line;
}
let delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta);
}
formattingScanner.close();
@@ -500,7 +506,7 @@ module ts.formatting {
}
}
function processNode(node: Node, contextNode: Node, nodeStartLine: number, indentation: number, delta: number) {
function processNode(node: Node, contextNode: Node, nodeStartLine: number, undecoratedNodeStartLine: number, indentation: number, delta: number) {
if (!rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) {
return;
}
@@ -526,7 +532,7 @@ module ts.formatting {
forEachChild(
node,
child => {
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, /*isListElement*/ false)
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false)
},
(nodes: NodeArray<Node>) => {
processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation);
@@ -547,11 +553,17 @@ module ts.formatting {
parent: Node,
parentDynamicIndentation: DynamicIndentation,
parentStartLine: number,
undecoratedParentStartLine: number,
isListItem: boolean): number {
let childStartPos = child.getStart(sourceFile);
let childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
let childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line;
let undecoratedChildStartLine = childStartLine;
if (child.decorators) {
undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(child, sourceFile)).line;
}
// if child is a list item - try to get its indentation
let childIndentationAmount = Constants.Unknown;
@@ -594,9 +606,10 @@ module ts.formatting {
return inheritedIndentation;
}
let childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine);
let effectiveParentStartLine = child.kind === SyntaxKind.Decorator ? childStartLine : undecoratedParentStartLine;
let childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
processNode(child, childContextNode, childStart.line, childIndentation.indentation, childIndentation.delta);
processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta);
childContextNode = node;
@@ -640,7 +653,7 @@ module ts.formatting {
let inheritedIndentation = Constants.Unknown;
for (let child of nodes) {
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, /*isListElement*/ true)
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true)
}
if (listEndToken !== SyntaxKind.Unknown) {
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/// <reference path="references.ts"/>
/* @internal */
module ts.formatting {
export class FormattingContext {
public currentTokenSpan: TextRangeWithKind;
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/// <reference path="references.ts"/>
/* @internal */
module ts.formatting {
export const enum FormattingRequestKind {
FormatDocument,
@@ -1,6 +1,7 @@
/// <reference path="formatting.ts"/>
/// <reference path="..\..\compiler\scanner.ts"/>
/* @internal */
module ts.formatting {
let scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);
-15
View File
@@ -1,18 +1,3 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='..\services.ts' />
///<reference path='formattingContext.ts' />
///<reference path='formattingRequestKind.ts' />
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export class Rule {
constructor(
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export const enum RuleAction {
Ignore = 0x00000001,
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export class RuleDescriptor {
constructor(public LeftTokenRange: Shared.TokenRange, public RightTokenRange: Shared.TokenRange) {
+2 -15
View File
@@ -1,20 +1,7 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export const enum RuleFlags {
None,
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export class RuleOperation {
public Context: RuleOperationContext;
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export class RuleOperationContext {
+29 -16
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export class Rules {
public getRuleName(rule: Rule) {
@@ -208,6 +194,11 @@ module ts.formatting {
public SpaceAfterAnonymousFunctionKeyword: Rule;
public NoSpaceAfterAnonymousFunctionKeyword: Rule;
// Insert space after @ in decorator
public SpaceBeforeAt: Rule;
public NoSpaceAfterAt: Rule;
public SpaceAfterDecorator: Rule;
constructor() {
///
/// Common Rules
@@ -344,6 +335,11 @@ module ts.formatting {
// Remove spaces in empty interface literals. e.g.: x: {}
this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), RuleAction.Delete));
// decorators
this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -381,7 +377,10 @@ module ts.formatting {
this.NoSpaceBetweenCloseParenAndAngularBracket,
this.NoSpaceAfterOpenAngularBracket,
this.NoSpaceBeforeCloseAngularBracket,
this.NoSpaceAfterCloseAngularBracket
this.NoSpaceAfterCloseAngularBracket,
this.SpaceBeforeAt,
this.NoSpaceAfterAt,
this.SpaceAfterDecorator,
];
// These rules are lower in priority than user-configurable rules.
@@ -649,6 +648,20 @@ module ts.formatting {
return context.TokensAreOnSameLine();
}
static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean {
return context.TokensAreOnSameLine() &&
context.contextNode.decorators &&
Rules.NodeIsInDecoratorContext(context.currentTokenParent) &&
!Rules.NodeIsInDecoratorContext(context.nextTokenParent);
}
static NodeIsInDecoratorContext(node: Node): boolean {
while (isExpression(node)) {
node = node.parent;
}
return node.kind === SyntaxKind.Decorator;
}
static IsStartOfVariableDeclarationList(context: FormattingContext): boolean {
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export class RulesMap {
public map: RulesBucket[];
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/// <reference path="references.ts"/>
/* @internal */
module ts.formatting {
export class RulesProvider {
private globalRules: Rules;
+1
View File
@@ -1,5 +1,6 @@
///<reference path='..\services.ts' />
/* @internal */
module ts.formatting {
export module SmartIndenter {
+1 -15
View File
@@ -1,20 +1,6 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
/* @internal */
module ts.formatting {
export module Shared {
export interface ITokenAccess {
+1
View File
@@ -1,3 +1,4 @@
/* @internal */
module ts.NavigateTo {
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
+1
View File
@@ -1,5 +1,6 @@
/// <reference path='services.ts' />
/* @internal */
module ts.NavigationBar {
export function getNavigationBarItems(sourceFile: SourceFile): ts.NavigationBarItem[] {
// If the source file has any child items, then it included in the tree
+67 -17
View File
@@ -1,18 +1,4 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/* @internal */
module ts {
export module OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
@@ -31,17 +17,81 @@ module ts {
}
}
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
if (commentSpan) {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
}
function addOutliningForLeadingCommentsForNode(n: Node) {
let comments = ts.getLeadingCommentRangesOfNode(n, sourceFile);
if (comments) {
let firstSingleLineCommentStart = -1;
let lastSingleLineCommentEnd = -1;
let isFirstSingleLineComment = true;
let singleLineCommentCount = 0;
for (let currentComment of comments) {
// For single line comments, combine consecutive ones (2 or more) into
// a single span from the start of the first till the end of the last
if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) {
if (isFirstSingleLineComment) {
firstSingleLineCommentStart = currentComment.pos;
}
isFirstSingleLineComment = false;
lastSingleLineCommentEnd = currentComment.end;
singleLineCommentCount++;
}
else if (currentComment.kind === SyntaxKind.MultiLineCommentTrivia) {
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
addOutliningSpanComments(currentComment, /*autoCollapse*/ false);
singleLineCommentCount = 0;
lastSingleLineCommentEnd = -1;
isFirstSingleLineComment = true;
}
}
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
}
}
function combineAndAddMultipleSingleLineComments(count: number, start: number, end: number) {
// Only outline spans of two or more consecutive single line comments
if (count > 1) {
let multipleSingleLineComments = {
pos: start,
end: end,
kind: SyntaxKind.SingleLineCommentTrivia
}
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
}
}
function autoCollapse(node: Node) {
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
}
let depth = 0;
let maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
}
if (isDeclaration(n)) {
addOutliningForLeadingCommentsForNode(n);
}
switch (n.kind) {
case SyntaxKind.Block:
if (!isFunctionBlock(n)) {
@@ -94,7 +144,7 @@ module ts {
});
break;
}
// Fallthrough.
// Fallthrough.
case SyntaxKind.ModuleBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
+1
View File
@@ -1,3 +1,4 @@
/* @internal */
module ts {
// Note(cyrusn): this enum is ordered from strongest match type to weakest match type.
export enum PatternMatchKind {
+680 -567
View File
File diff suppressed because it is too large Load Diff
+22 -1
View File
@@ -15,8 +15,10 @@
/// <reference path='services.ts' />
/* @internal */
var debugObjectHost = (<any>this);
/* @internal */
module ts {
export interface ScriptSnapshotShim {
/** Gets a portion of the script snapshot specified by [start, end). */
@@ -135,11 +137,21 @@ module ts {
findReferences(fileName: string, position: number): string;
/**
* @deprecated
* Returns a JSON-encoded value of the type:
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
*/
getOccurrencesAtPosition(fileName: string, position: number): string;
/**
* Returns a JSON-encoded value of the type:
* { fileName: string; highlights: { start: number; length: number, isDefinition: boolean }[] }[]
*
* @param fileToSearch A JSON encoded string[] containing the file names that should be
* considered when searching.
*/
getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string;
/**
* Returns a JSON-encoded value of the type:
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
@@ -331,7 +343,6 @@ module ts {
}
}
/* @internal */
export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; } []{
return diagnostics.map(d => realizeDiagnostic(d, newLine));
}
@@ -590,6 +601,14 @@ module ts {
});
}
public getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string {
return this.forwardJSONCall(
"getDocumentHighlights('" + fileName + "', " + position + ")",
() => {
return this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
});
}
/// COMPLETION LISTS
/**
@@ -844,8 +863,10 @@ module ts {
/// TODO: this is used by VS, clean this up on both sides of the interface
/* @internal */
module TypeScript.Services {
export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
}
/* @internal */
let toolsVersion = "1.4";
+1 -1
View File
@@ -1,5 +1,5 @@
///<reference path='services.ts' />
/* @internal */
module ts.SignatureHelp {
// A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression
+2
View File
@@ -1,4 +1,5 @@
// These utilities are common to multiple language service features.
/* @internal */
module ts {
export interface ListItemInfo {
listItemIndex: number;
@@ -500,6 +501,7 @@ module ts {
}
// Display-part writer helpers
/* @internal */
module ts {
export function isFirstDeclarationOfSymbolParameter(symbol: Symbol) {
return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;
+18 -18
View File
@@ -1,40 +1,40 @@
=== tests/cases/compiler/2dArrays.ts ===
class Cell {
>Cell : Cell
>Cell : Cell, Symbol(Cell, Decl(2dArrays.ts, 0, 0))
}
class Ship {
>Ship : Ship
>Ship : Ship, Symbol(Ship, Decl(2dArrays.ts, 1, 1))
isSunk: boolean;
>isSunk : boolean
>isSunk : boolean, Symbol(isSunk, Decl(2dArrays.ts, 3, 12))
}
class Board {
>Board : Board
>Board : Board, Symbol(Board, Decl(2dArrays.ts, 5, 1))
ships: Ship[];
>ships : Ship[]
>Ship : Ship
>ships : Ship[], Symbol(ships, Decl(2dArrays.ts, 7, 13))
>Ship : Ship, Symbol(Ship, Decl(2dArrays.ts, 1, 1))
cells: Cell[];
>cells : Cell[]
>Cell : Cell
>cells : Cell[], Symbol(cells, Decl(2dArrays.ts, 8, 18))
>Cell : Cell, Symbol(Cell, Decl(2dArrays.ts, 0, 0))
private allShipsSunk() {
>allShipsSunk : () => boolean
>allShipsSunk : () => boolean, Symbol(allShipsSunk, Decl(2dArrays.ts, 9, 18))
return this.ships.every(function (val) { return val.isSunk; });
>this.ships.every(function (val) { return val.isSunk; }) : boolean
>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean
>this.ships : Ship[]
>this : Board
>ships : Ship[]
>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean
>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean, Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
>this.ships : Ship[], Symbol(ships, Decl(2dArrays.ts, 7, 13))
>this : Board, Symbol(Board, Decl(2dArrays.ts, 5, 1))
>ships : Ship[], Symbol(ships, Decl(2dArrays.ts, 7, 13))
>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean, Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
>function (val) { return val.isSunk; } : (val: Ship) => boolean
>val : Ship
>val.isSunk : boolean
>val : Ship
>isSunk : boolean
>val : Ship, Symbol(val, Decl(2dArrays.ts, 12, 42))
>val.isSunk : boolean, Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
>val : Ship, Symbol(val, Decl(2dArrays.ts, 12, 42))
>isSunk : boolean, Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
}
}
@@ -7,152 +7,162 @@
*/
declare var process: any;
>process : any
>process : any, Symbol(process, Decl(APISample_compile.ts, 7, 11))
declare var console: any;
>console : any
>console : any, Symbol(console, Decl(APISample_compile.ts, 8, 11))
declare var os: any;
>os : any
>os : any, Symbol(os, Decl(APISample_compile.ts, 9, 11))
import ts = require("typescript");
>ts : typeof ts
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
>compile : (fileNames: string[], options: ts.CompilerOptions) => void
>fileNames : string[]
>options : ts.CompilerOptions
>ts : unknown
>CompilerOptions : ts.CompilerOptions
>compile : (fileNames: string[], options: ts.CompilerOptions) => void, Symbol(compile, Decl(APISample_compile.ts, 11, 34))
>fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44))
>ts : any, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5))
var program = ts.createProgram(fileNames, options);
>program : ts.Program
>program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7))
>ts.createProgram(fileNames, options) : ts.Program
>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program
>ts : typeof ts
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program
>fileNames : string[]
>options : ts.CompilerOptions
>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1201, 113))
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1201, 113))
>fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44))
var emitResult = program.emit();
>emitResult : ts.EmitResult
>emitResult : ts.EmitResult, Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
>program.emit() : ts.EmitResult
>program.emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult
>program : ts.Program
>emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult
>program.emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult, Symbol(ts.Program.emit, Decl(typescript.d.ts, 767, 39))
>program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7))
>emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult, Symbol(ts.Program.emit, Decl(typescript.d.ts, 767, 39))
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
>allDiagnostics : ts.Diagnostic[]
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_compile.ts, 17, 7))
>ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics) : ts.Diagnostic[]
>ts.getPreEmitDiagnostics(program).concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>ts.getPreEmitDiagnostics(program).concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>ts.getPreEmitDiagnostics(program) : ts.Diagnostic[]
>ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[]
>ts : typeof ts
>getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[]
>program : ts.Program
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>emitResult.diagnostics : ts.Diagnostic[]
>emitResult : ts.EmitResult
>diagnostics : ts.Diagnostic[]
>ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1199, 98))
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1199, 98))
>program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7))
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>emitResult.diagnostics : ts.Diagnostic[], Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29))
>emitResult : ts.EmitResult, Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
>diagnostics : ts.Diagnostic[], Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29))
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach(diagnostic => { var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); }) : void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics : ts.Diagnostic[]
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_compile.ts, 17, 7))
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>diagnostic => { var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } : (diagnostic: ts.Diagnostic) => void
>diagnostic : ts.Diagnostic
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>line : number
>character : number
>line : number, Symbol(line, Decl(APISample_compile.ts, 20, 13))
>character : number, Symbol(character, Decl(APISample_compile.ts, 20, 19))
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.start : number
>diagnostic : ts.Diagnostic
>start : number
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
>diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
>message : string
>message : string, Symbol(message, Decl(APISample_compile.ts, 21, 11))
>ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') : string
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>ts : typeof ts
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>diagnostic.messageText : string | ts.DiagnosticMessageChain
>diagnostic : ts.Diagnostic
>messageText : string | ts.DiagnosticMessageChain
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
>diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
>'\n' : string
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
>console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_compile.ts, 8, 11))
>log : any
>diagnostic.file.fileName : string
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string
>diagnostic.file.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>line + 1 : number
>line : number
>line : number, Symbol(line, Decl(APISample_compile.ts, 20, 13))
>1 : number
>character + 1 : number
>character : number
>message : string
>character : number, Symbol(character, Decl(APISample_compile.ts, 20, 19))
>1 : number
>message : string, Symbol(message, Decl(APISample_compile.ts, 21, 11))
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
>exitCode : number
>exitCode : number, Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
>emitResult.emitSkipped ? 1 : 0 : number
>emitResult.emitSkipped : boolean
>emitResult : ts.EmitResult
>emitSkipped : boolean
>emitResult.emitSkipped : boolean, Symbol(ts.EmitResult.emitSkipped, Decl(typescript.d.ts, 819, 26))
>emitResult : ts.EmitResult, Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
>emitSkipped : boolean, Symbol(ts.EmitResult.emitSkipped, Decl(typescript.d.ts, 819, 26))
>1 : number
>0 : number
console.log(`Process exiting with code '${exitCode}'.`);
>console.log(`Process exiting with code '${exitCode}'.`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_compile.ts, 8, 11))
>log : any
>exitCode : number
>`Process exiting with code '${exitCode}'.` : string
>exitCode : number, Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
process.exit(exitCode);
>process.exit(exitCode) : any
>process.exit : any
>process : any
>process : any, Symbol(process, Decl(APISample_compile.ts, 7, 11))
>exit : any
>exitCode : number
>exitCode : number, Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
}
compile(process.argv.slice(2), {
>compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS}) : void
>compile : (fileNames: string[], options: ts.CompilerOptions) => void
>compile : (fileNames: string[], options: ts.CompilerOptions) => void, Symbol(compile, Decl(APISample_compile.ts, 11, 34))
>process.argv.slice(2) : any
>process.argv.slice : any
>process.argv : any
>process : any
>process : any, Symbol(process, Decl(APISample_compile.ts, 7, 11))
>argv : any
>slice : any
>2 : number
>{ noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS} : { [x: string]: boolean | ts.ScriptTarget | ts.ModuleKind; noEmitOnError: boolean; noImplicitAny: boolean; target: ts.ScriptTarget; module: ts.ModuleKind; }
noEmitOnError: true, noImplicitAny: true,
>noEmitOnError : boolean
>noImplicitAny : boolean
>noEmitOnError : boolean, Symbol(noEmitOnError, Decl(APISample_compile.ts, 30, 32))
>true : boolean
>noImplicitAny : boolean, Symbol(noImplicitAny, Decl(APISample_compile.ts, 31, 24))
>true : boolean
target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS
>target : ts.ScriptTarget
>ts.ScriptTarget.ES5 : ts.ScriptTarget
>ts.ScriptTarget : typeof ts.ScriptTarget
>ts : typeof ts
>ScriptTarget : typeof ts.ScriptTarget
>ES5 : ts.ScriptTarget
>module : ts.ModuleKind
>ts.ModuleKind.CommonJS : ts.ModuleKind
>ts.ModuleKind : typeof ts.ModuleKind
>ts : typeof ts
>ModuleKind : typeof ts.ModuleKind
>CommonJS : ts.ModuleKind
>target : ts.ScriptTarget, Symbol(target, Decl(APISample_compile.ts, 31, 45))
>ts.ScriptTarget.ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16))
>ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16))
>module : ts.ModuleKind, Symbol(module, Decl(APISample_compile.ts, 32, 32))
>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
});
+180 -171
View File
@@ -7,297 +7,306 @@
*/
declare var process: any;
>process : any
>process : any, Symbol(process, Decl(APISample_linter.ts, 7, 11))
declare var console: any;
>console : any
>console : any, Symbol(console, Decl(APISample_linter.ts, 8, 11))
declare var readFileSync: any;
>readFileSync : any
>readFileSync : any, Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11))
import * as ts from "typescript";
>ts : typeof ts
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
export function delint(sourceFile: ts.SourceFile) {
>delint : (sourceFile: ts.SourceFile) => void
>sourceFile : ts.SourceFile
>ts : unknown
>SourceFile : ts.SourceFile
>delint : (sourceFile: ts.SourceFile) => void, Symbol(delint, Decl(APISample_linter.ts, 11, 33))
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SourceFile : ts.SourceFile, Symbol(ts.SourceFile, Decl(typescript.d.ts, 740, 5), Decl(typescript.d.ts, 1261, 5))
delintNode(sourceFile);
>delintNode(sourceFile) : void
>delintNode : (node: ts.Node) => void
>sourceFile : ts.SourceFile
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
function delintNode(node: ts.Node) {
>delintNode : (node: ts.Node) => void
>node : ts.Node
>ts : unknown
>Node : ts.Node
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1221, 32))
switch (node.kind) {
>node.kind : ts.SyntaxKind
>node : ts.Node
>kind : ts.SyntaxKind
>node.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
case ts.SyntaxKind.ForStatement:
>ts.SyntaxKind.ForStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>ForStatement : ts.SyntaxKind
>ts.SyntaxKind.ForStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForStatement, Decl(typescript.d.ts, 209, 29))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ForStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForStatement, Decl(typescript.d.ts, 209, 29))
case ts.SyntaxKind.ForInStatement:
>ts.SyntaxKind.ForInStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>ForInStatement : ts.SyntaxKind
>ts.SyntaxKind.ForInStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForInStatement, Decl(typescript.d.ts, 210, 27))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ForInStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForInStatement, Decl(typescript.d.ts, 210, 27))
case ts.SyntaxKind.WhileStatement:
>ts.SyntaxKind.WhileStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>WhileStatement : ts.SyntaxKind
>ts.SyntaxKind.WhileStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.WhileStatement, Decl(typescript.d.ts, 208, 26))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>WhileStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.WhileStatement, Decl(typescript.d.ts, 208, 26))
case ts.SyntaxKind.DoStatement:
>ts.SyntaxKind.DoStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>DoStatement : ts.SyntaxKind
>ts.SyntaxKind.DoStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.DoStatement, Decl(typescript.d.ts, 207, 26))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>DoStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.DoStatement, Decl(typescript.d.ts, 207, 26))
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
>(<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block : boolean
>(<ts.IterationStatement>node).statement.kind : ts.SyntaxKind
>(<ts.IterationStatement>node).statement : ts.Statement
>(<ts.IterationStatement>node).statement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>(<ts.IterationStatement>node).statement : ts.Statement, Symbol(ts.IterationStatement.statement, Decl(typescript.d.ts, 589, 52))
>(<ts.IterationStatement>node) : ts.IterationStatement
><ts.IterationStatement>node : ts.IterationStatement
>ts : unknown
>IterationStatement : ts.IterationStatement
>node : ts.Node
>statement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.Block : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>Block : ts.SyntaxKind
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>IterationStatement : ts.IterationStatement, Symbol(ts.IterationStatement, Decl(typescript.d.ts, 588, 5))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>statement : ts.Statement, Symbol(ts.IterationStatement.statement, Decl(typescript.d.ts, 589, 52))
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
report(node, "A looping statement's contents should be wrapped in a block body.");
>report(node, "A looping statement's contents should be wrapped in a block body.") : void
>report : (node: ts.Node, message: string) => void
>node : ts.Node
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>"A looping statement's contents should be wrapped in a block body." : string
}
break;
case ts.SyntaxKind.IfStatement:
>ts.SyntaxKind.IfStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>IfStatement : ts.SyntaxKind
>ts.SyntaxKind.IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
let ifStatement = (<ts.IfStatement>node);
>ifStatement : ts.IfStatement
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>(<ts.IfStatement>node) : ts.IfStatement
><ts.IfStatement>node : ts.IfStatement
>ts : unknown
>IfStatement : ts.IfStatement
>node : ts.Node
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>IfStatement : ts.IfStatement, Symbol(ts.IfStatement, Decl(typescript.d.ts, 583, 5))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
>ifStatement.thenStatement.kind !== ts.SyntaxKind.Block : boolean
>ifStatement.thenStatement.kind : ts.SyntaxKind
>ifStatement.thenStatement : ts.Statement
>ifStatement : ts.IfStatement
>thenStatement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.Block : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>Block : ts.SyntaxKind
>ifStatement.thenStatement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ifStatement.thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
>report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.") : void
>report : (node: ts.Node, message: string) => void
>ifStatement.thenStatement : ts.Statement
>ifStatement : ts.IfStatement
>thenStatement : ts.Statement
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
>ifStatement.thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
>"An if statement's contents should be wrapped in a block body." : string
}
if (ifStatement.elseStatement &&
>ifStatement.elseStatement && ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement : boolean
>ifStatement.elseStatement && ifStatement.elseStatement.kind !== ts.SyntaxKind.Block : boolean
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
>ifStatement.elseStatement.kind !== ts.SyntaxKind.Block : boolean
>ifStatement.elseStatement.kind : ts.SyntaxKind
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.Block : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>Block : ts.SyntaxKind
>ifStatement.elseStatement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
>ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement : boolean
>ifStatement.elseStatement.kind : ts.SyntaxKind
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>kind : ts.SyntaxKind
>ts.SyntaxKind.IfStatement : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>IfStatement : ts.SyntaxKind
>ifStatement.elseStatement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>ts.SyntaxKind.IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
>report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.") : void
>report : (node: ts.Node, message: string) => void
>ifStatement.elseStatement : ts.Statement
>ifStatement : ts.IfStatement
>elseStatement : ts.Statement
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
>"An else statement's contents should be wrapped in a block body." : string
}
break;
case ts.SyntaxKind.BinaryExpression:
>ts.SyntaxKind.BinaryExpression : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>BinaryExpression : ts.SyntaxKind
>ts.SyntaxKind.BinaryExpression : ts.SyntaxKind, Symbol(ts.SyntaxKind.BinaryExpression, Decl(typescript.d.ts, 192, 37))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>BinaryExpression : ts.SyntaxKind, Symbol(ts.SyntaxKind.BinaryExpression, Decl(typescript.d.ts, 192, 37))
let op = (<ts.BinaryExpression>node).operatorToken.kind;
>op : ts.SyntaxKind
>(<ts.BinaryExpression>node).operatorToken.kind : ts.SyntaxKind
>(<ts.BinaryExpression>node).operatorToken : ts.Node
>op : ts.SyntaxKind, Symbol(op, Decl(APISample_linter.ts, 40, 19))
>(<ts.BinaryExpression>node).operatorToken.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
>(<ts.BinaryExpression>node).operatorToken : ts.Node, Symbol(ts.BinaryExpression.operatorToken, Decl(typescript.d.ts, 497, 25))
>(<ts.BinaryExpression>node) : ts.BinaryExpression
><ts.BinaryExpression>node : ts.BinaryExpression
>ts : unknown
>BinaryExpression : ts.BinaryExpression
>node : ts.Node
>operatorToken : ts.Node
>kind : ts.SyntaxKind
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>BinaryExpression : ts.BinaryExpression, Symbol(ts.BinaryExpression, Decl(typescript.d.ts, 495, 5))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>operatorToken : ts.Node, Symbol(ts.BinaryExpression.operatorToken, Decl(typescript.d.ts, 497, 25))
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
>op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken : boolean
>op === ts.SyntaxKind.EqualsEqualsToken : boolean
>op : ts.SyntaxKind
>ts.SyntaxKind.EqualsEqualsToken : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>EqualsEqualsToken : ts.SyntaxKind
>op : ts.SyntaxKind, Symbol(op, Decl(APISample_linter.ts, 40, 19))
>ts.SyntaxKind.EqualsEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.EqualsEqualsToken, Decl(typescript.d.ts, 51, 36))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>EqualsEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.EqualsEqualsToken, Decl(typescript.d.ts, 51, 36))
>op == ts.SyntaxKind.ExclamationEqualsToken : boolean
>op : ts.SyntaxKind
>ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind
>ts.SyntaxKind : typeof ts.SyntaxKind
>ts : typeof ts
>SyntaxKind : typeof ts.SyntaxKind
>ExclamationEqualsToken : ts.SyntaxKind
>op : ts.SyntaxKind, Symbol(op, Decl(APISample_linter.ts, 40, 19))
>ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.ExclamationEqualsToken, Decl(typescript.d.ts, 52, 31))
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
>ExclamationEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.ExclamationEqualsToken, Decl(typescript.d.ts, 52, 31))
report(node, "Use '===' and '!=='.")
>report(node, "Use '===' and '!=='.") : void
>report : (node: ts.Node, message: string) => void
>node : ts.Node
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>"Use '===' and '!=='." : string
}
break;
}
ts.forEachChild(node, delintNode);
>ts.forEachChild(node, delintNode) : void
>ts.forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T
>ts : typeof ts
>forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T
>node : ts.Node
>delintNode : (node: ts.Node) => void
>ts.forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1186, 48))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1186, 48))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
}
function report(node: ts.Node, message: string) {
>report : (node: ts.Node, message: string) => void
>node : ts.Node
>ts : unknown
>Node : ts.Node
>message : string
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 50, 20))
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1221, 32))
>message : string, Symbol(message, Decl(APISample_linter.ts, 50, 34))
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
>line : number
>character : number
>line : number, Symbol(line, Decl(APISample_linter.ts, 51, 13))
>character : number, Symbol(character, Decl(APISample_linter.ts, 51, 19))
>sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>sourceFile : ts.SourceFile
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
>node.getStart() : number
>node.getStart : (sourceFile?: ts.SourceFile) => number
>node : ts.Node
>getStart : (sourceFile?: ts.SourceFile) => number
>node.getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 53))
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 50, 20))
>getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 53))
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
>console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_linter.ts, 8, 11))
>log : any
>sourceFile.fileName : string
>sourceFile : ts.SourceFile
>fileName : string
>`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}` : string
>sourceFile.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
>fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>line + 1 : number
>line : number
>line : number, Symbol(line, Decl(APISample_linter.ts, 51, 13))
>1 : number
>character + 1 : number
>character : number
>message : string
>character : number, Symbol(character, Decl(APISample_linter.ts, 51, 19))
>1 : number
>message : string, Symbol(message, Decl(APISample_linter.ts, 50, 34))
}
}
const fileNames = process.argv.slice(2);
>fileNames : any
>fileNames : any, Symbol(fileNames, Decl(APISample_linter.ts, 56, 5))
>process.argv.slice(2) : any
>process.argv.slice : any
>process.argv : any
>process : any
>process : any, Symbol(process, Decl(APISample_linter.ts, 7, 11))
>argv : any
>slice : any
>2 : number
fileNames.forEach(fileName => {
>fileNames.forEach(fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);}) : any
>fileNames.forEach : any
>fileNames : any
>fileNames : any, Symbol(fileNames, Decl(APISample_linter.ts, 56, 5))
>forEach : any
>fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);} : (fileName: any) => void
>fileName : any
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
// Parse a file
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
>sourceFile : ts.SourceFile
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7))
>ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true) : ts.SourceFile
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>ts : typeof ts
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
>fileName : any
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1190, 62))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1190, 62))
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
>readFileSync(fileName).toString() : any
>readFileSync(fileName).toString : any
>readFileSync(fileName) : any
>readFileSync : any
>fileName : any
>readFileSync : any, Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11))
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
>toString : any
>ts.ScriptTarget.ES6 : ts.ScriptTarget
>ts.ScriptTarget : typeof ts.ScriptTarget
>ts : typeof ts
>ScriptTarget : typeof ts.ScriptTarget
>ES6 : ts.ScriptTarget
>ts.ScriptTarget.ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16))
>ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
>ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
>ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16))
>true : boolean
// delint it
delint(sourceFile);
>delint(sourceFile) : void
>delint : (sourceFile: ts.SourceFile) => void
>sourceFile : ts.SourceFile
>delint : (sourceFile: ts.SourceFile) => void, Symbol(delint, Decl(APISample_linter.ts, 11, 33))
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7))
});
@@ -7,37 +7,38 @@
*/
declare var console: any;
>console : any
>console : any, Symbol(console, Decl(APISample_transform.ts, 7, 11))
import * as ts from "typescript";
>ts : typeof ts
>ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6))
const source = "let x: string = 'string'";
>source : string
>source : string, Symbol(source, Decl(APISample_transform.ts, 11, 5))
>"let x: string = 'string'" : string
let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
>result : string
>result : string, Symbol(result, Decl(APISample_transform.ts, 13, 3))
>ts.transpile(source, { module: ts.ModuleKind.CommonJS }) : string
>ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string
>ts : typeof ts
>transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string
>source : string
>ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1728, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6))
>transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1728, 5))
>source : string, Symbol(source, Decl(APISample_transform.ts, 11, 5))
>{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; }
>module : ts.ModuleKind
>ts.ModuleKind.CommonJS : ts.ModuleKind
>ts.ModuleKind : typeof ts.ModuleKind
>ts : typeof ts
>ModuleKind : typeof ts.ModuleKind
>CommonJS : ts.ModuleKind
>module : ts.ModuleKind, Symbol(module, Decl(APISample_transform.ts, 13, 35))
>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6))
>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
console.log(JSON.stringify(result));
>console.log(JSON.stringify(result)) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_transform.ts, 7, 11))
>log : any
>JSON.stringify(result) : string
>JSON.stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }
>JSON : JSON
>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }
>result : string
>JSON.stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }, Symbol(JSON.stringify, Decl(lib.d.ts, 964, 70), Decl(lib.d.ts, 969, 34), Decl(lib.d.ts, 975, 78), Decl(lib.d.ts, 981, 51), Decl(lib.d.ts, 988, 90))
>JSON : JSON, Symbol(JSON, Decl(lib.d.ts, 955, 42), Decl(lib.d.ts, 1000, 11))
>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }, Symbol(JSON.stringify, Decl(lib.d.ts, 964, 70), Decl(lib.d.ts, 969, 34), Decl(lib.d.ts, 975, 78), Decl(lib.d.ts, 981, 51), Decl(lib.d.ts, 988, 90))
>result : string, Symbol(result, Decl(APISample_transform.ts, 13, 3))
+198 -183
View File
@@ -7,197 +7,200 @@
*/
declare var process: any;
>process : any
>process : any, Symbol(process, Decl(APISample_watcher.ts, 7, 11))
declare var console: any;
>console : any
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
declare var fs: any;
>fs : any
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
declare var path: any;
>path : any
>path : any, Symbol(path, Decl(APISample_watcher.ts, 10, 11))
import * as ts from "typescript";
>ts : typeof ts
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void
>rootFileNames : string[]
>options : ts.CompilerOptions
>ts : unknown
>CompilerOptions : ts.CompilerOptions
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void, Symbol(watch, Decl(APISample_watcher.ts, 12, 33))
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 14, 39))
>ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5))
const files: ts.Map<{ version: number }> = {};
>files : ts.Map<{ version: number; }>
>ts : unknown
>Map : ts.Map<T>
>version : number
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>Map : ts.Map<T>, Symbol(ts.Map, Decl(typescript.d.ts, 15, 29))
>version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>{} : { [x: string]: undefined; }
// initialize the list of files
rootFileNames.forEach(fileName => {
>rootFileNames.forEach(fileName => { files[fileName] = { version: 0 }; }) : void
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>rootFileNames : string[]
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>fileName => { files[fileName] = { version: 0 }; } : (fileName: string) => void
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 18, 26))
files[fileName] = { version: 0 };
>files[fileName] = { version: 0 } : { version: number; }
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 18, 26))
>{ version: 0 } : { version: number; }
>version : number
>version : number, Symbol(version, Decl(APISample_watcher.ts, 19, 27))
>0 : number
});
// Create the language service host to allow the LS to communicate with the host
const servicesHost: ts.LanguageServiceHost = {
>servicesHost : ts.LanguageServiceHost
>ts : unknown
>LanguageServiceHost : ts.LanguageServiceHost
>servicesHost : ts.LanguageServiceHost, Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9))
>ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>LanguageServiceHost : ts.LanguageServiceHost, Symbol(ts.LanguageServiceHost, Decl(typescript.d.ts, 1294, 5))
>{ getScriptFileNames: () => rootFileNames, getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(), getScriptSnapshot: (fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); }, getCurrentDirectory: () => process.cwd(), getCompilationSettings: () => options, getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), } : { getScriptFileNames: () => string[]; getScriptVersion: (fileName: string) => string; getScriptSnapshot: (fileName: string) => ts.IScriptSnapshot; getCurrentDirectory: () => any; getCompilationSettings: () => ts.CompilerOptions; getDefaultLibFileName: (options: ts.CompilerOptions) => string; }
getScriptFileNames: () => rootFileNames,
>getScriptFileNames : () => string[]
>getScriptFileNames : () => string[], Symbol(getScriptFileNames, Decl(APISample_watcher.ts, 23, 50))
>() => rootFileNames : () => string[]
>rootFileNames : string[]
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
>getScriptVersion : (fileName: string) => string
>getScriptVersion : (fileName: string) => string, Symbol(getScriptVersion, Decl(APISample_watcher.ts, 24, 48))
>(fileName) => files[fileName] && files[fileName].version.toString() : (fileName: string) => string
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
>files[fileName] && files[fileName].version.toString() : string
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
>files[fileName].version.toString() : string
>files[fileName].version.toString : (radix?: number) => string
>files[fileName].version : number
>files[fileName].version.toString : (radix?: number) => string, Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>files[fileName].version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>version : number
>toString : (radix?: number) => string
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
>version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>toString : (radix?: number) => string, Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
getScriptSnapshot: (fileName) => {
>getScriptSnapshot : (fileName: string) => ts.IScriptSnapshot
>getScriptSnapshot : (fileName: string) => ts.IScriptSnapshot, Symbol(getScriptSnapshot, Decl(APISample_watcher.ts, 25, 94))
>(fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); } : (fileName: string) => ts.IScriptSnapshot
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
if (!fs.existsSync(fileName)) {
>!fs.existsSync(fileName) : boolean
>fs.existsSync(fileName) : any
>fs.existsSync : any
>fs : any
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>existsSync : any
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
return undefined;
>undefined : undefined
>undefined : undefined, Symbol(undefined)
}
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
>ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : ts.IScriptSnapshot
>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot
>ts : typeof ts
>ScriptSnapshot : typeof ts.ScriptSnapshot
>fromString : (text: string) => ts.IScriptSnapshot
>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1287, 27))
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1286, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1286, 5))
>fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1287, 27))
>fs.readFileSync(fileName).toString() : any
>fs.readFileSync(fileName).toString : any
>fs.readFileSync(fileName) : any
>fs.readFileSync : any
>fs : any
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>readFileSync : any
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
>toString : any
},
getCurrentDirectory: () => process.cwd(),
>getCurrentDirectory : () => any
>getCurrentDirectory : () => any, Symbol(getCurrentDirectory, Decl(APISample_watcher.ts, 32, 10))
>() => process.cwd() : () => any
>process.cwd() : any
>process.cwd : any
>process : any
>process : any, Symbol(process, Decl(APISample_watcher.ts, 7, 11))
>cwd : any
getCompilationSettings: () => options,
>getCompilationSettings : () => ts.CompilerOptions
>getCompilationSettings : () => ts.CompilerOptions, Symbol(getCompilationSettings, Decl(APISample_watcher.ts, 33, 49))
>() => options : () => ts.CompilerOptions
>options : ts.CompilerOptions
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 14, 39))
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
>getDefaultLibFileName : (options: ts.CompilerOptions) => string
>getDefaultLibFileName : (options: ts.CompilerOptions) => string, Symbol(getDefaultLibFileName, Decl(APISample_watcher.ts, 34, 46))
>(options) => ts.getDefaultLibFilePath(options) : (options: ts.CompilerOptions) => string
>options : ts.CompilerOptions
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32))
>ts.getDefaultLibFilePath(options) : string
>ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string
>ts : typeof ts
>getDefaultLibFilePath : (options: ts.CompilerOptions) => string
>options : ts.CompilerOptions
>ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1736, 44))
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1736, 44))
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32))
};
// Create the language service files
const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry())
>services : ts.LanguageService
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>ts.createLanguageService(servicesHost, ts.createDocumentRegistry()) : ts.LanguageService
>ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService
>ts : typeof ts
>createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService
>servicesHost : ts.LanguageServiceHost
>ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1734, 97))
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1734, 97))
>servicesHost : ts.LanguageServiceHost, Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9))
>ts.createDocumentRegistry() : ts.DocumentRegistry
>ts.createDocumentRegistry : () => ts.DocumentRegistry
>ts : typeof ts
>createDocumentRegistry : () => ts.DocumentRegistry
>ts.createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1732, 193))
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1732, 193))
// Now let's watch the files
rootFileNames.forEach(fileName => {
>rootFileNames.forEach(fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); }) : void
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>rootFileNames : string[]
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); } : (fileName: string) => void
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
// First time around, emit all files
emitFile(fileName);
>emitFile(fileName) : void
>emitFile : (fileName: string) => void
>fileName : string
>emitFile : (fileName: string) => void, Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
// Add a watch on the file to handle next change
fs.watchFile(fileName,
>fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }) : any
>fs.watchFile : any
>fs : any
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>watchFile : any
>fileName : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
{ persistent: true, interval: 250 },
>{ persistent: true, interval: 250 } : { persistent: boolean; interval: number; }
>persistent : boolean
>interval : number
>persistent : boolean, Symbol(persistent, Decl(APISample_watcher.ts, 48, 13))
>true : boolean
>interval : number, Symbol(interval, Decl(APISample_watcher.ts, 48, 31))
>250 : number
(curr, prev) => {
>(curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); } : (curr: any, prev: any) => void
>curr : any
>prev : any
>curr : any, Symbol(curr, Decl(APISample_watcher.ts, 49, 13))
>prev : any, Symbol(prev, Decl(APISample_watcher.ts, 49, 18))
// Check timestamp
if (+curr.mtime <= +prev.mtime) {
>+curr.mtime <= +prev.mtime : boolean
>+curr.mtime : number
>curr.mtime : any
>curr : any
>curr : any, Symbol(curr, Decl(APISample_watcher.ts, 49, 13))
>mtime : any
>+prev.mtime : number
>prev.mtime : any
>prev : any
>prev : any, Symbol(prev, Decl(APISample_watcher.ts, 49, 18))
>mtime : any
return;
@@ -206,175 +209,183 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
// Update the version to signal a change in the file
files[fileName].version++;
>files[fileName].version++ : number
>files[fileName].version : number
>files[fileName].version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
>files[fileName] : { version: number; }
>files : ts.Map<{ version: number; }>
>fileName : string
>version : number
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
>version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
// write the changes to disk
emitFile(fileName);
>emitFile(fileName) : void
>emitFile : (fileName: string) => void
>fileName : string
>emitFile : (fileName: string) => void, Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
});
});
function emitFile(fileName: string) {
>emitFile : (fileName: string) => void
>fileName : string
>emitFile : (fileName: string) => void, Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
let output = services.getEmitOutput(fileName);
>output : ts.EmitOutput
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
>services.getEmitOutput(fileName) : ts.EmitOutput
>services.getEmitOutput : (fileName: string) => ts.EmitOutput
>services : ts.LanguageService
>getEmitOutput : (fileName: string) => ts.EmitOutput
>fileName : string
>services.getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1338, 132))
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1338, 132))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
if (!output.emitSkipped) {
>!output.emitSkipped : boolean
>output.emitSkipped : boolean
>output : ts.EmitOutput
>emitSkipped : boolean
>output.emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1541, 34))
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
>emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1541, 34))
console.log(`Emitting ${fileName}`);
>console.log(`Emitting ${fileName}`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>log : any
>fileName : string
>`Emitting ${fileName}` : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
}
else {
console.log(`Emitting ${fileName} failed`);
>console.log(`Emitting ${fileName} failed`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>log : any
>fileName : string
>`Emitting ${fileName} failed` : string
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
logErrors(fileName);
>logErrors(fileName) : void
>logErrors : (fileName: string) => void
>fileName : string
>logErrors : (fileName: string) => void, Symbol(logErrors, Decl(APISample_watcher.ts, 77, 5))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
}
output.outputFiles.forEach(o => {
>output.outputFiles.forEach(o => { fs.writeFileSync(o.name, o.text, "utf8"); }) : void
>output.outputFiles.forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void
>output.outputFiles : ts.OutputFile[]
>output : ts.EmitOutput
>outputFiles : ts.OutputFile[]
>forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void
>output.outputFiles.forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>output.outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1540, 26))
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
>outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1540, 26))
>forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>o => { fs.writeFileSync(o.name, o.text, "utf8"); } : (o: ts.OutputFile) => void
>o : ts.OutputFile
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
fs.writeFileSync(o.name, o.text, "utf8");
>fs.writeFileSync(o.name, o.text, "utf8") : any
>fs.writeFileSync : any
>fs : any
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>writeFileSync : any
>o.name : string
>o : ts.OutputFile
>name : string
>o.text : string
>o : ts.OutputFile
>text : string
>o.name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1549, 26))
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
>name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1549, 26))
>o.text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1551, 36))
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
>text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1551, 36))
>"utf8" : string
});
}
function logErrors(fileName: string) {
>logErrors : (fileName: string) => void
>fileName : string
>logErrors : (fileName: string) => void, Symbol(logErrors, Decl(APISample_watcher.ts, 77, 5))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
let allDiagnostics = services.getCompilerOptionsDiagnostics()
>allDiagnostics : ts.Diagnostic[]
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_watcher.ts, 80, 11))
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat(services.getSemanticDiagnostics(fileName)) : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics() .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>services.getCompilerOptionsDiagnostics() .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getCompilerOptionsDiagnostics() : ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[]
>services : ts.LanguageService
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[]
>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1312, 63))
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1312, 63))
.concat(services.getSyntacticDiagnostics(fileName))
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getSyntacticDiagnostics(fileName) : ts.Diagnostic[]
>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[]
>services : ts.LanguageService
>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[]
>fileName : string
>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1310, 37))
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1310, 37))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
.concat(services.getSemanticDiagnostics(fileName));
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
>services.getSemanticDiagnostics(fileName) : ts.Diagnostic[]
>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[]
>services : ts.LanguageService
>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[]
>fileName : string
>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1311, 64))
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1311, 64))
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach(diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { console.log(` Error: ${message}`); } }) : void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics : ts.Diagnostic[]
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_watcher.ts, 80, 11))
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
>diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { console.log(` Error: ${message}`); } } : (diagnostic: ts.Diagnostic) => void
>diagnostic : ts.Diagnostic
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
>message : string
>message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15))
>ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") : string
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>ts : typeof ts
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string
>diagnostic.messageText : string | ts.DiagnosticMessageChain
>diagnostic : ts.Diagnostic
>messageText : string | ts.DiagnosticMessageChain
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
>diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
>"\n" : string
if (diagnostic.file) {
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>line : number
>character : number
>line : number, Symbol(line, Decl(APISample_watcher.ts, 87, 21))
>character : number, Symbol(character, Decl(APISample_watcher.ts, 87, 27))
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.start : number
>diagnostic : ts.Diagnostic
>start : number
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
>diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
>console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>log : any
>diagnostic.file.fileName : string
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string
>diagnostic.file.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
>fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
>line + 1 : number
>line : number
>line : number, Symbol(line, Decl(APISample_watcher.ts, 87, 21))
>1 : number
>character + 1 : number
>character : number
>message : string
>character : number, Symbol(character, Decl(APISample_watcher.ts, 87, 27))
>1 : number
>message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15))
}
else {
console.log(` Error: ${message}`);
>console.log(` Error: ${message}`) : any
>console.log : any
>console : any
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
>log : any
>message : string
>` Error: ${message}` : string
>message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15))
}
});
}
@@ -382,47 +393,51 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
// Initialize files constituting the program as all .ts files in the current directory
const currentDirectoryFiles = fs.readdirSync(process.cwd()).
>currentDirectoryFiles : any
>currentDirectoryFiles : any, Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5))
>fs.readdirSync(process.cwd()). filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts") : any
>fs.readdirSync(process.cwd()). filter : any
>fs.readdirSync(process.cwd()) : any
>fs.readdirSync : any
>fs : any
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
>readdirSync : any
>process.cwd() : any
>process.cwd : any
>process : any
>process : any, Symbol(process, Decl(APISample_watcher.ts, 7, 11))
>cwd : any
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
>filter : any
>fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : (fileName: any) => boolean
>fileName : any
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
>fileName.length >= 3 : boolean
>fileName.length : any
>fileName : any
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>length : any
>3 : number
>fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
>fileName.substr(fileName.length - 3, 3) : any
>fileName.substr : any
>fileName : any
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>substr : any
>fileName.length - 3 : number
>fileName.length : any
>fileName : any
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
>length : any
>3 : number
>3 : number
>".ts" : string
// Start the watcher
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
>watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }) : void
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void
>currentDirectoryFiles : any
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void, Symbol(watch, Decl(APISample_watcher.ts, 12, 33))
>currentDirectoryFiles : any, Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5))
>{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; }
>module : ts.ModuleKind
>ts.ModuleKind.CommonJS : ts.ModuleKind
>ts.ModuleKind : typeof ts.ModuleKind
>ts : typeof ts
>ModuleKind : typeof ts.ModuleKind
>CommonJS : ts.ModuleKind
>module : ts.ModuleKind, Symbol(module, Decl(APISample_watcher.ts, 102, 30))
>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
@@ -1,33 +1,33 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
declare module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
export var Origin: { x: number; y: number; }
>Origin : { x: number; y: number; }
>x : number
>y : number
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 1, 14))
>x : number, Symbol(x, Decl(module.d.ts, 1, 24))
>y : number, Symbol(y, Decl(module.d.ts, 1, 35))
}
=== tests/cases/conformance/internalModules/DeclarationMerging/function.d.ts ===
declare function Point(): { x: number; y: number; }
>Point : typeof Point
>x : number
>y : number
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
>x : number, Symbol(x, Decl(function.d.ts, 0, 27))
>y : number, Symbol(y, Decl(function.d.ts, 0, 38))
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
var cl: { x: number; y: number; }
>cl : { x: number; y: number; }
>x : number
>y : number
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : number, Symbol(x, Decl(test.ts, 0, 9))
>y : number, Symbol(y, Decl(test.ts, 0, 20))
var cl = Point();
>cl : { x: number; y: number; }
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>Point() : { x: number; y: number; }
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
var cl = Point.Origin;
>cl : { x: number; y: number; }
>Point.Origin : { x: number; y: number; }
>Point : typeof Point
>Origin : { x: number; y: number; }
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>Point.Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
>Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
@@ -1,59 +1,61 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
declare module A {
>A : typeof A
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
export module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
export var Origin: {
>Origin : { x: number; y: number; }
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 2, 18))
x: number;
>x : number
>x : number, Symbol(x, Decl(module.d.ts, 2, 28))
y: number;
>y : number
>y : number, Symbol(y, Decl(module.d.ts, 3, 22))
}
}
}
=== tests/cases/conformance/internalModules/DeclarationMerging/class.d.ts ===
declare module A {
>A : typeof A
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
export class Point {
>Point : Point
>Point : Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
constructor(x: number, y: number);
>x : number
>y : number
>x : number, Symbol(x, Decl(class.d.ts, 2, 20))
>y : number, Symbol(y, Decl(class.d.ts, 2, 30))
x: number;
>x : number
>x : number, Symbol(x, Decl(class.d.ts, 2, 42))
y: number;
>y : number
>y : number, Symbol(y, Decl(class.d.ts, 3, 18))
}
}
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
var p: { x: number; y: number; }
>p : { x: number; y: number; }
>x : number
>y : number
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : number, Symbol(x, Decl(test.ts, 0, 8))
>y : number, Symbol(y, Decl(test.ts, 0, 19))
var p = A.Point.Origin;
>p : { x: number; y: number; }
>A.Point.Origin : { x: number; y: number; }
>A.Point : typeof A.Point
>A : typeof A
>Point : typeof A.Point
>Origin : { x: number; y: number; }
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>A.Point.Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
>Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
var p = new A.Point(0, 0); // unexpected error here, bug 840000
>p : { x: number; y: number; }
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>new A.Point(0, 0) : A.Point
>A.Point : typeof A.Point
>A : typeof A
>Point : typeof A.Point
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
>0 : number
>0 : number
@@ -1,53 +1,55 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
declare module A {
>A : typeof A
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
export module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
export var Origin: {
>Origin : { x: number; y: number; }
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 2, 18))
x: number;
>x : number
>x : number, Symbol(x, Decl(module.d.ts, 2, 28))
y: number;
>y : number
>y : number, Symbol(y, Decl(module.d.ts, 3, 22))
}
}
}
=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts ===
module A {
>A : typeof A
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
export class Point {
>Point : Point
>Point : Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
constructor(public x: number, public y: number) { }
>x : number
>y : number
>x : number, Symbol(x, Decl(classPoint.ts, 2, 20))
>y : number, Symbol(y, Decl(classPoint.ts, 2, 37))
}
}
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
var p: { x: number; y: number; }
>p : { x: number; y: number; }
>x : number
>y : number
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : number, Symbol(x, Decl(test.ts, 0, 8))
>y : number, Symbol(y, Decl(test.ts, 0, 19))
var p = A.Point.Origin;
>p : { x: number; y: number; }
>A.Point.Origin : { x: number; y: number; }
>A.Point : typeof A.Point
>A : typeof A
>Point : typeof A.Point
>Origin : { x: number; y: number; }
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>A.Point.Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
>Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
var p = new A.Point(0, 0); // unexpected error here, bug 840000
>p : { x: number; y: number; }
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>new A.Point(0, 0) : A.Point
>A.Point : typeof A.Point
>A : typeof A
>Point : typeof A.Point
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
>0 : number
>0 : number
@@ -1,37 +1,39 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
declare module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
export var Origin: { x: number; y: number; }
>Origin : { x: number; y: number; }
>x : number
>y : number
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 1, 14))
>x : number, Symbol(x, Decl(module.d.ts, 1, 24))
>y : number, Symbol(y, Decl(module.d.ts, 1, 35))
}
=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts ===
function Point() {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
return { x: 0, y: 0 };
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>y : number
>x : number, Symbol(x, Decl(function.ts, 1, 12))
>0 : number
>y : number, Symbol(y, Decl(function.ts, 1, 18))
>0 : number
}
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
var cl: { x: number; y: number; }
>cl : { x: number; y: number; }
>x : number
>y : number
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : number, Symbol(x, Decl(test.ts, 0, 9))
>y : number, Symbol(y, Decl(test.ts, 0, 20))
var cl = Point();
>cl : { x: number; y: number; }
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>Point() : { x: number; y: number; }
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
var cl = Point.Origin;
>cl : { x: number; y: number; }
>Point.Origin : { x: number; y: number; }
>Point : typeof Point
>Origin : { x: number; y: number; }
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>Point.Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
>Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
@@ -1,8 +1,8 @@
=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction4.ts ===
var v = (a, b) => {
>v : (a: any, b: any) => void
>v : (a: any, b: any) => void, Symbol(v, Decl(ArrowFunction4.ts, 0, 3))
>(a, b) => { } : (a: any, b: any) => void
>a : any
>b : any
>a : any, Symbol(a, Decl(ArrowFunction4.ts, 0, 9))
>b : any, Symbol(b, Decl(ArrowFunction4.ts, 0, 11))
};
@@ -1,49 +1,55 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts ===
class Point {
>Point : Point
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
constructor(public x: number, public y: number) { }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 16))
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 33))
static Origin(): Point { return { x: 0, y: 0 }; }
>Origin : () => Point
>Point : Point
>Origin : () => Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 55))
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 3, 37))
>0 : number
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 3, 43))
>0 : number
}
module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
function Origin() { return ""; }// not an error, since not exported
>Origin : () => string
>Origin : () => string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 6, 14))
>"" : string
}
module A {
>A : typeof A
>A : typeof A, Symbol(A, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 8, 1))
export class Point {
>Point : Point
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
constructor(public x: number, public y: number) { }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 20))
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 37))
static Origin(): Point { return { x: 0, y: 0 }; }
>Origin : () => Point
>Point : Point
>Origin : () => Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 59))
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 15, 41))
>0 : number
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 15, 47))
>0 : number
}
export module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
function Origin() { return ""; }// not an error since not exported
>Origin : () => string
>Origin : () => string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 18, 25))
>"" : string
}
}
@@ -1,49 +1,55 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts ===
class Point {
>Point : Point
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
constructor(public x: number, public y: number) { }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 16))
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 33))
static Origin: Point = { x: 0, y: 0 };
>Origin : Point
>Point : Point
>Origin : Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 55))
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 3, 28))
>0 : number
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 3, 34))
>0 : number
}
module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
var Origin = ""; // not an error, since not exported
>Origin : string
>Origin : string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 7, 7))
>"" : string
}
module A {
>A : typeof A
>A : typeof A, Symbol(A, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 8, 1))
export class Point {
>Point : Point
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
constructor(public x: number, public y: number) { }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 20))
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 37))
static Origin: Point = { x: 0, y: 0 };
>Origin : Point
>Point : Point
>Origin : Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 59))
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>y : number
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 15, 32))
>0 : number
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 15, 38))
>0 : number
}
export module Point {
>Point : typeof Point
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
var Origin = ""; // not an error since not exported
>Origin : string
>Origin : string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 19, 11))
>"" : string
}
}
@@ -1,5 +1,6 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>v : boolean, Symbol(v, Decl(ES3For-ofTypeCheck2.ts, 0, 8))
>[true] : boolean[]
>true : boolean
@@ -1,8 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
>union : string[] | number[], Symbol(union, Decl(ES3For-ofTypeCheck6.ts, 0, 3))
for (var v of union) { }
>v : string | number
>union : string[] | number[]
>v : string | number, Symbol(v, Decl(ES3For-ofTypeCheck6.ts, 1, 8))
>union : string[] | number[], Symbol(union, Decl(ES3For-ofTypeCheck6.ts, 0, 3))
+13 -12
View File
@@ -1,29 +1,30 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts ===
function foo() {
>foo : () => { x: number; }
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
return { x: 0 };
>{ x: 0 } : { x: number; }
>x : number
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
>0 : number
}
for (foo().x of []) {
>foo().x : number
>foo().x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
>[] : undefined[]
for (foo().x of [])
>foo().x : number
>foo().x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
>[] : undefined[]
var p = foo().x;
>p : number
>foo().x : number
>p : number, Symbol(p, Decl(ES5For-of10.ts, 5, 11))
>foo().x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
}
+2 -2
View File
@@ -1,8 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts ===
var v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of11.ts, 0, 3))
for (v of []) { }
>v : any
>v : any, Symbol(v, Decl(ES5For-of11.ts, 0, 3))
>[] : undefined[]
+6 -3
View File
@@ -1,9 +1,12 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts ===
for (let v of ['a', 'b', 'c']) {
>v : string
>v : string, Symbol(v, Decl(ES5For-of13.ts, 0, 8))
>['a', 'b', 'c'] : string[]
>'a' : string
>'b' : string
>'c' : string
var x = v;
>x : string
>v : string
>x : string, Symbol(x, Decl(ES5For-of13.ts, 1, 7))
>v : string, Symbol(v, Decl(ES5For-of13.ts, 0, 8))
}
+3 -3
View File
@@ -1,9 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
for (const v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of14.ts, 0, 10))
>[] : undefined[]
var x = v;
>x : any
>v : any
>x : any, Symbol(x, Decl(ES5For-of14.ts, 1, 7))
>v : any, Symbol(v, Decl(ES5For-of14.ts, 0, 10))
}
+5 -5
View File
@@ -1,17 +1,17 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts ===
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of15.ts, 0, 8))
>[] : undefined[]
v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of15.ts, 0, 8))
for (const v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of15.ts, 2, 14))
>[] : undefined[]
var x = v;
>x : any
>v : any
>x : any, Symbol(x, Decl(ES5For-of15.ts, 3, 11))
>v : any, Symbol(v, Decl(ES5For-of15.ts, 2, 14))
}
}
+6 -6
View File
@@ -1,21 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts ===
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of16.ts, 0, 8))
>[] : undefined[]
v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of16.ts, 0, 8))
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of16.ts, 2, 12))
>[] : undefined[]
var x = v;
>x : any
>v : any
>x : any, Symbol(x, Decl(ES5For-of16.ts, 3, 11))
>v : any, Symbol(v, Decl(ES5For-of16.ts, 2, 12))
v++;
>v++ : number
>v : any
>v : any, Symbol(v, Decl(ES5For-of16.ts, 2, 12))
}
}
+4 -4
View File
@@ -1,16 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts ===
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of18.ts, 0, 8))
>[] : undefined[]
v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of18.ts, 0, 8))
}
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of18.ts, 3, 8))
>[] : undefined[]
v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of18.ts, 3, 8))
}
+5 -5
View File
@@ -1,20 +1,20 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts ===
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of19.ts, 0, 8))
>[] : undefined[]
v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of19.ts, 0, 8))
function foo() {
>foo : () => void
>foo : () => void, Symbol(foo, Decl(ES5For-of19.ts, 1, 6))
for (const v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of19.ts, 3, 18))
>[] : undefined[]
v;
>v : any
>v : any, Symbol(v, Decl(ES5For-of19.ts, 3, 18))
}
}
}
+3 -3
View File
@@ -1,9 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts ===
for (var v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of2.ts, 0, 8))
>[] : undefined[]
var x = v;
>x : any
>v : any
>x : any, Symbol(x, Decl(ES5For-of2.ts, 1, 7))
>v : any, Symbol(v, Decl(ES5For-of2.ts, 0, 8))
}
+2 -2
View File
@@ -1,9 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts ===
for (let v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of21.ts, 0, 8))
>[] : undefined[]
for (let _i of []) { }
>_i : any
>_i : any, Symbol(_i, Decl(ES5For-of21.ts, 1, 12))
>[] : undefined[]
}
+8 -4
View File
@@ -1,12 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts ===
var a = [1, 2, 3];
>a : number[]
>a : number[], Symbol(a, Decl(ES5For-of24.ts, 0, 3))
>[1, 2, 3] : number[]
>1 : number
>2 : number
>3 : number
for (var v of a) {
>v : number
>a : number[]
>v : number, Symbol(v, Decl(ES5For-of24.ts, 1, 8))
>a : number[], Symbol(a, Decl(ES5For-of24.ts, 0, 3))
let a = 0;
>a : number
>a : number, Symbol(a, Decl(ES5For-of24.ts, 2, 7))
>0 : number
}
+8 -5
View File
@@ -1,15 +1,18 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts ===
var a = [1, 2, 3];
>a : number[]
>a : number[], Symbol(a, Decl(ES5For-of25.ts, 0, 3))
>[1, 2, 3] : number[]
>1 : number
>2 : number
>3 : number
for (var v of a) {
>v : number
>a : number[]
>v : number, Symbol(v, Decl(ES5For-of25.ts, 1, 8))
>a : number[], Symbol(a, Decl(ES5For-of25.ts, 0, 3))
v;
>v : number
>v : number, Symbol(v, Decl(ES5For-of25.ts, 1, 8))
a;
>a : number[]
>a : number[], Symbol(a, Decl(ES5For-of25.ts, 0, 3))
}
+6 -3
View File
@@ -1,9 +1,12 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts ===
for (var v of ['a', 'b', 'c'])
>v : string
>v : string, Symbol(v, Decl(ES5For-of3.ts, 0, 8))
>['a', 'b', 'c'] : string[]
>'a' : string
>'b' : string
>'c' : string
var x = v;
>x : string
>v : string
>x : string, Symbol(x, Decl(ES5For-of3.ts, 1, 7))
>v : string, Symbol(v, Decl(ES5For-of3.ts, 0, 8))
@@ -1,12 +1,18 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (3 errors) ====
var a: string, b: number;
var tuple: [number, string] = [2, "3"];
for ([a = 1, b = ""] of tuple) {
~~~~~~~~~~~~~~~
!!! error TS2461: Type 'string | number' is not an array type.
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a;
b;
}
+5 -5
View File
@@ -1,13 +1,13 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts ===
for (var v of [])
>v : any
>v : any, Symbol(v, Decl(ES5For-of4.ts, 0, 8))
>[] : undefined[]
var x = v;
>x : any
>v : any
>x : any, Symbol(x, Decl(ES5For-of4.ts, 1, 7))
>v : any, Symbol(v, Decl(ES5For-of4.ts, 0, 8))
var y = v;
>y : any
>v : any
>y : any, Symbol(y, Decl(ES5For-of4.ts, 2, 3))
>v : any, Symbol(v, Decl(ES5For-of4.ts, 0, 8))
+3 -3
View File
@@ -1,9 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts ===
for (var _a of []) {
>_a : any
>_a : any, Symbol(_a, Decl(ES5For-of5.ts, 0, 8))
>[] : undefined[]
var x = _a;
>x : any
>_a : any
>x : any, Symbol(x, Decl(ES5For-of5.ts, 1, 7))
>_a : any, Symbol(_a, Decl(ES5For-of5.ts, 0, 8))
}
+5 -5
View File
@@ -1,16 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts ===
for (var w of []) {
>w : any
>w : any, Symbol(w, Decl(ES5For-of6.ts, 0, 8))
>[] : undefined[]
for (var v of []) {
>v : any
>v : any, Symbol(v, Decl(ES5For-of6.ts, 1, 12))
>[] : undefined[]
var x = [w, v];
>x : any[]
>x : any[], Symbol(x, Decl(ES5For-of6.ts, 2, 11))
>[w, v] : any[]
>w : any
>v : any
>w : any, Symbol(w, Decl(ES5For-of6.ts, 0, 8))
>v : any, Symbol(v, Decl(ES5For-of6.ts, 1, 12))
}
}
+13 -12
View File
@@ -1,30 +1,31 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts ===
function foo() {
>foo : () => { x: number; }
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
return { x: 0 };
>{ x: 0 } : { x: number; }
>x : number
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
>0 : number
}
for (foo().x of []) {
>foo().x : number
>foo().x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
>[] : undefined[]
for (foo().x of []) {
>foo().x : number
>foo().x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
>[] : undefined[]
var p = foo().x;
>p : number
>foo().x : number
>p : number, Symbol(p, Decl(ES5For-of9.ts, 5, 11))
>foo().x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
}
}
@@ -1,4 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts ===
for (var v of "") { }
>v : string
>v : string, Symbol(v, Decl(ES5For-ofTypeCheck1.ts, 0, 8))
>"" : string
@@ -1,5 +1,6 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>v : boolean, Symbol(v, Decl(ES5For-ofTypeCheck2.ts, 0, 8))
>[true] : boolean[]
>true : boolean
@@ -1,9 +1,11 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck3.ts ===
var tuple: [string, number] = ["", 0];
>tuple : [string, number]
>tuple : [string, number], Symbol(tuple, Decl(ES5For-ofTypeCheck3.ts, 0, 3))
>["", 0] : [string, number]
>"" : string
>0 : number
for (var v of tuple) { }
>v : string | number
>tuple : [string, number]
>v : string | number, Symbol(v, Decl(ES5For-ofTypeCheck3.ts, 1, 8))
>tuple : [string, number], Symbol(tuple, Decl(ES5For-ofTypeCheck3.ts, 0, 3))
@@ -1,8 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck4.ts ===
var union: string | string[];
>union : string | string[]
>union : string | string[], Symbol(union, Decl(ES5For-ofTypeCheck4.ts, 0, 3))
for (const v of union) { }
>v : string
>union : string | string[]
>v : string, Symbol(v, Decl(ES5For-ofTypeCheck4.ts, 1, 10))
>union : string | string[], Symbol(union, Decl(ES5For-ofTypeCheck4.ts, 0, 3))
@@ -1,8 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck5.ts ===
var union: string | number[];
>union : string | number[]
>union : string | number[], Symbol(union, Decl(ES5For-ofTypeCheck5.ts, 0, 3))
for (var v of union) { }
>v : string | number
>union : string | number[]
>v : string | number, Symbol(v, Decl(ES5For-ofTypeCheck5.ts, 1, 8))
>union : string | number[], Symbol(union, Decl(ES5For-ofTypeCheck5.ts, 0, 3))
@@ -1,8 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
>union : string[] | number[], Symbol(union, Decl(ES5For-ofTypeCheck6.ts, 0, 3))
for (var v of union) { }
>v : string | number
>union : string[] | number[]
>v : string | number, Symbol(v, Decl(ES5For-ofTypeCheck6.ts, 1, 8))
>union : string[] | number[], Symbol(union, Decl(ES5For-ofTypeCheck6.ts, 0, 3))
@@ -14,6 +14,7 @@ obj[Symbol.foo];
var Symbol;
var obj = (_a = {},
_a[Symbol.foo] = 0,
_a);
_a
);
obj[Symbol.foo];
var _a;

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