mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into inlineSourceMaps
This commit is contained in:
+10
-5
@@ -239,11 +239,7 @@ module ts {
|
||||
if (symbolKind & SymbolFlags.IsContainer) {
|
||||
container = node;
|
||||
|
||||
if (lastContainer) {
|
||||
lastContainer.nextContainer = container;
|
||||
}
|
||||
|
||||
lastContainer = container;
|
||||
addToContainerChain(container);
|
||||
}
|
||||
|
||||
if (isBlockScopeContainer) {
|
||||
@@ -262,6 +258,14 @@ module ts {
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
}
|
||||
|
||||
function addToContainerChain(node: Node) {
|
||||
if (lastContainer) {
|
||||
lastContainer.nextContainer = node;
|
||||
}
|
||||
|
||||
lastContainer = node;
|
||||
}
|
||||
|
||||
function bindDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) {
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
@@ -403,6 +407,7 @@ module ts {
|
||||
default:
|
||||
if (!blockScopeContainer.locals) {
|
||||
blockScopeContainer.locals = {};
|
||||
addToContainerChain(blockScopeContainer);
|
||||
}
|
||||
declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
|
||||
+71
-73
@@ -114,11 +114,10 @@ module ts {
|
||||
let globalIterableType: ObjectType;
|
||||
|
||||
let anyArrayType: Type;
|
||||
let globalTypedPropertyDescriptorType: ObjectType;
|
||||
let globalClassDecoratorType: ObjectType;
|
||||
let globalParameterDecoratorType: ObjectType;
|
||||
let globalPropertyDecoratorType: ObjectType;
|
||||
let globalMethodDecoratorType: ObjectType;
|
||||
let getGlobalClassDecoratorType: () => ObjectType;
|
||||
let getGlobalParameterDecoratorType: () => ObjectType;
|
||||
let getGlobalPropertyDecoratorType: () => ObjectType;
|
||||
let getGlobalMethodDecoratorType: () => ObjectType;
|
||||
|
||||
let tupleTypes: Map<TupleType> = {};
|
||||
let unionTypes: Map<UnionType> = {};
|
||||
@@ -2516,10 +2515,11 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclaredTypeOfClass(symbol: Symbol): InterfaceType {
|
||||
function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType {
|
||||
let links = getSymbolLinks(symbol);
|
||||
if (!links.declaredType) {
|
||||
let type = links.declaredType = <InterfaceType>createObjectType(TypeFlags.Class, symbol);
|
||||
let kind = symbol.flags & SymbolFlags.Class ? TypeFlags.Class : TypeFlags.Interface;
|
||||
let type = links.declaredType = <InterfaceType>createObjectType(kind, symbol);
|
||||
let typeParameters = getTypeParametersOfClassOrInterface(symbol);
|
||||
if (typeParameters) {
|
||||
type.flags |= TypeFlags.Reference;
|
||||
@@ -2529,35 +2529,6 @@ module ts {
|
||||
(<GenericType>type).target = <GenericType>type;
|
||||
(<GenericType>type).typeArguments = type.typeParameters;
|
||||
}
|
||||
|
||||
type.declaredProperties = getNamedMembers(symbol.members);
|
||||
type.declaredCallSignatures = emptyArray;
|
||||
type.declaredConstructSignatures = emptyArray;
|
||||
type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String);
|
||||
type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number);
|
||||
}
|
||||
return <InterfaceType>links.declaredType;
|
||||
}
|
||||
|
||||
function getDeclaredTypeOfInterface(symbol: Symbol): InterfaceType {
|
||||
let links = getSymbolLinks(symbol);
|
||||
if (!links.declaredType) {
|
||||
let type = links.declaredType = <InterfaceType>createObjectType(TypeFlags.Interface, symbol);
|
||||
let typeParameters = getTypeParametersOfClassOrInterface(symbol);
|
||||
if (typeParameters) {
|
||||
type.flags |= TypeFlags.Reference;
|
||||
type.typeParameters = typeParameters;
|
||||
(<GenericType>type).instantiations = {};
|
||||
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
|
||||
(<GenericType>type).target = <GenericType>type;
|
||||
(<GenericType>type).typeArguments = type.typeParameters;
|
||||
}
|
||||
|
||||
type.declaredProperties = getNamedMembers(symbol.members);
|
||||
type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]);
|
||||
type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]);
|
||||
type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String);
|
||||
type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number);
|
||||
}
|
||||
return <InterfaceType>links.declaredType;
|
||||
}
|
||||
@@ -2613,11 +2584,8 @@ module ts {
|
||||
|
||||
function getDeclaredTypeOfSymbol(symbol: Symbol): Type {
|
||||
Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0);
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
return getDeclaredTypeOfClass(symbol);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Interface) {
|
||||
return getDeclaredTypeOfInterface(symbol);
|
||||
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
|
||||
return getDeclaredTypeOfClassOrInterface(symbol);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.TypeAlias) {
|
||||
return getDeclaredTypeOfTypeAlias(symbol);
|
||||
@@ -2666,15 +2634,28 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers {
|
||||
if (!(<InterfaceTypeWithDeclaredMembers>type).declaredProperties) {
|
||||
var symbol = type.symbol;
|
||||
(<InterfaceTypeWithDeclaredMembers>type).declaredProperties = getNamedMembers(symbol.members);
|
||||
(<InterfaceTypeWithDeclaredMembers>type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]);
|
||||
(<InterfaceTypeWithDeclaredMembers>type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]);
|
||||
(<InterfaceTypeWithDeclaredMembers>type).declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String);
|
||||
(<InterfaceTypeWithDeclaredMembers>type).declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number);
|
||||
}
|
||||
return <InterfaceTypeWithDeclaredMembers>type;
|
||||
}
|
||||
|
||||
function resolveClassOrInterfaceMembers(type: InterfaceType): void {
|
||||
let members = type.symbol.members;
|
||||
let callSignatures = type.declaredCallSignatures;
|
||||
let constructSignatures = type.declaredConstructSignatures;
|
||||
let stringIndexType = type.declaredStringIndexType;
|
||||
let numberIndexType = type.declaredNumberIndexType;
|
||||
let baseTypes = getBaseTypes(type);
|
||||
let target = resolveDeclaredMembers(type);
|
||||
let members = target.symbol.members;
|
||||
let callSignatures = target.declaredCallSignatures;
|
||||
let constructSignatures = target.declaredConstructSignatures;
|
||||
let stringIndexType = target.declaredStringIndexType;
|
||||
let numberIndexType = target.declaredNumberIndexType;
|
||||
let baseTypes = getBaseTypes(target);
|
||||
if (baseTypes.length) {
|
||||
members = createSymbolTable(type.declaredProperties);
|
||||
members = createSymbolTable(target.declaredProperties);
|
||||
for (let baseType of baseTypes) {
|
||||
addInheritedMembers(members, getPropertiesOfObjectType(baseType));
|
||||
callSignatures = concatenate(callSignatures, getSignaturesOfType(baseType, SignatureKind.Call));
|
||||
@@ -2687,7 +2668,7 @@ module ts {
|
||||
}
|
||||
|
||||
function resolveTypeReferenceMembers(type: TypeReference): void {
|
||||
let target = type.target;
|
||||
let target = resolveDeclaredMembers(type.target);
|
||||
let mapper = createTypeMapper(target.typeParameters, type.typeArguments);
|
||||
let members = createInstantiatedSymbolTable(target.declaredProperties, mapper);
|
||||
let callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature);
|
||||
@@ -2843,7 +2824,7 @@ module ts {
|
||||
callSignatures = getSignaturesOfSymbol(symbol);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
let classType = getDeclaredTypeOfClass(symbol);
|
||||
let classType = getDeclaredTypeOfClassOrInterface(symbol);
|
||||
constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]);
|
||||
if (!constructSignatures.length) {
|
||||
constructSignatures = getDefaultConstructSignatures(classType);
|
||||
@@ -2956,7 +2937,7 @@ module ts {
|
||||
let type = getApparentType(current);
|
||||
if (type !== unknownType) {
|
||||
let prop = getPropertyOfType(type, name);
|
||||
if (!prop) {
|
||||
if (!prop || getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected)) {
|
||||
return undefined;
|
||||
}
|
||||
if (!props) {
|
||||
@@ -3084,7 +3065,7 @@ module ts {
|
||||
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
|
||||
let links = getNodeLinks(declaration);
|
||||
if (!links.resolvedSignature) {
|
||||
let classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClass((<ClassDeclaration>declaration.parent).symbol) : undefined;
|
||||
let classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface((<ClassDeclaration>declaration.parent).symbol) : undefined;
|
||||
let typeParameters = classType ? classType.typeParameters :
|
||||
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
|
||||
let parameters: Symbol[] = [];
|
||||
@@ -3788,7 +3769,7 @@ module ts {
|
||||
}
|
||||
|
||||
function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper {
|
||||
return t => mapper2(mapper1(t));
|
||||
return t => instantiateType(mapper1(t), mapper2);
|
||||
}
|
||||
|
||||
function instantiateTypeParameter(typeParameter: TypeParameter, mapper: TypeMapper): TypeParameter {
|
||||
@@ -3859,7 +3840,7 @@ module ts {
|
||||
function instantiateType(type: Type, mapper: TypeMapper): Type {
|
||||
if (mapper !== identityMapper) {
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
return mapper(type);
|
||||
return mapper(<TypeParameter>type);
|
||||
}
|
||||
if (type.flags & TypeFlags.Anonymous) {
|
||||
return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ?
|
||||
@@ -8808,24 +8789,24 @@ module ts {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
let classSymbol = getSymbolOfNode(node.parent);
|
||||
let classConstructorType = getTypeOfSymbol(classSymbol);
|
||||
let classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]);
|
||||
let classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]);
|
||||
checkTypeAssignableTo(exprType, classDecoratorType, node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node);
|
||||
checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
let methodType = getTypeOfNode(node.parent);
|
||||
let methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]);
|
||||
let methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]);
|
||||
checkTypeAssignableTo(exprType, methodDecoratorType, node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
checkTypeAssignableTo(exprType, globalParameterDecoratorType, node);
|
||||
checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -9367,7 +9348,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (node.condition) checkExpression(node.condition);
|
||||
if (node.iterator) checkExpression(node.iterator);
|
||||
if (node.incrementor) checkExpression(node.incrementor);
|
||||
checkSourceElement(node.statement);
|
||||
}
|
||||
|
||||
@@ -10152,7 +10133,7 @@ module ts {
|
||||
}
|
||||
|
||||
let seen: Map<{ prop: Symbol; containingType: Type }> = {};
|
||||
forEach(type.declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; });
|
||||
forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; });
|
||||
let ok = true;
|
||||
|
||||
for (let base of baseTypes) {
|
||||
@@ -10708,9 +10689,15 @@ module ts {
|
||||
}
|
||||
checkExternalModuleExports(container);
|
||||
|
||||
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {
|
||||
// export assignment is deprecated in es6 or above
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
|
||||
if (node.isExportEquals) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
// export assignment is deprecated in es6 or above
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
|
||||
}
|
||||
else if (compilerOptions.module === ModuleKind.System) {
|
||||
// system modules does not support export assignment
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11533,9 +11520,11 @@ module ts {
|
||||
|
||||
function getExportNameSubstitution(symbol: Symbol, location: Node, getGeneratedNameForNode: (Node: Node) => string): string {
|
||||
if (isExternalModuleSymbol(symbol.parent)) {
|
||||
// If this is es6 or higher, just use the name of the export
|
||||
// 1. If this is es6 or higher, just use the name of the export
|
||||
// no need to qualify it.
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
// 2. export mechanism for System modules is different from CJS\AMD
|
||||
// and it does not need qualifications for exports
|
||||
if (languageVersion >= ScriptTarget.ES6 || compilerOptions.module === ModuleKind.System) {
|
||||
return undefined;
|
||||
}
|
||||
return "exports." + unescapeIdentifier(symbol.name);
|
||||
@@ -11896,6 +11885,15 @@ module ts {
|
||||
return !!resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
||||
}
|
||||
|
||||
function getReferencedValueDeclaration(reference: Identifier): Declaration {
|
||||
Debug.assert(!nodeIsSynthesized(reference));
|
||||
let symbol =
|
||||
getNodeLinks(reference).resolvedSymbol ||
|
||||
resolveName(reference, reference.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
||||
|
||||
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
|
||||
}
|
||||
|
||||
function getBlockScopedVariableId(n: Identifier): number {
|
||||
Debug.assert(!nodeIsSynthesized(n));
|
||||
|
||||
@@ -11954,6 +11952,7 @@ module ts {
|
||||
resolvesToSomeValue,
|
||||
collectLinkedAliases,
|
||||
getBlockScopedVariableId,
|
||||
getReferencedValueDeclaration,
|
||||
serializeTypeOfNode,
|
||||
serializeParameterTypesOfNode,
|
||||
serializeReturnTypeOfNode,
|
||||
@@ -11987,11 +11986,10 @@ module ts {
|
||||
globalNumberType = getGlobalType("Number");
|
||||
globalBooleanType = getGlobalType("Boolean");
|
||||
globalRegExpType = getGlobalType("RegExp");
|
||||
globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1);
|
||||
globalClassDecoratorType = getGlobalType("ClassDecorator");
|
||||
globalPropertyDecoratorType = getGlobalType("PropertyDecorator");
|
||||
globalMethodDecoratorType = getGlobalType("MethodDecorator");
|
||||
globalParameterDecoratorType = getGlobalType("ParameterDecorator");
|
||||
getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator"));
|
||||
getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator"));
|
||||
getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator"));
|
||||
getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator"));
|
||||
|
||||
// If we're in ES6 mode, load the TemplateStringsArray.
|
||||
// Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios.
|
||||
@@ -12018,7 +12016,7 @@ module ts {
|
||||
function isReservedWordInStrictMode(node: Identifier): boolean {
|
||||
// Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word
|
||||
return (node.parserContextFlags & ParserContextFlags.StrictMode) &&
|
||||
(node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord);
|
||||
(SyntaxKind.FirstFutureReservedWord <= node.originalKeywordKind && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord);
|
||||
}
|
||||
|
||||
function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
|
||||
@@ -12038,7 +12036,7 @@ module ts {
|
||||
let nameBindings = impotClause.namedBindings;
|
||||
if (nameBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
let name = <Identifier>(<NamespaceImport>nameBindings).name;
|
||||
if (name.originalKeywordKind) {
|
||||
if (isReservedWordInStrictMode(name)) {
|
||||
let nameText = declarationNameToString(name);
|
||||
return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
|
||||
}
|
||||
@@ -12047,7 +12045,7 @@ module ts {
|
||||
let reportError = false;
|
||||
for (let element of (<NamedImports>nameBindings).elements) {
|
||||
let name = element.name;
|
||||
if (name.originalKeywordKind) {
|
||||
if (isReservedWordInStrictMode(name)) {
|
||||
let nameText = declarationNameToString(name);
|
||||
reportError = reportError || grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
|
||||
}
|
||||
|
||||
@@ -58,11 +58,13 @@ module ts {
|
||||
shortName: "m",
|
||||
type: {
|
||||
"commonjs": ModuleKind.CommonJS,
|
||||
"amd": ModuleKind.AMD
|
||||
"amd": ModuleKind.AMD,
|
||||
"system": ModuleKind.System,
|
||||
"umd": ModuleKind.UMD,
|
||||
},
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd,
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd,
|
||||
paramType: Diagnostics.KIND,
|
||||
error: Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd
|
||||
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
|
||||
},
|
||||
{
|
||||
name: "noEmit",
|
||||
@@ -118,6 +120,13 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_comments_to_output,
|
||||
},
|
||||
{
|
||||
name: "rootDir",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
{
|
||||
name: "separateCompilation",
|
||||
type: "boolean",
|
||||
@@ -151,7 +160,7 @@ module ts {
|
||||
type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 },
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
|
||||
paramType: Diagnostics.VERSION,
|
||||
error: Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6
|
||||
error: Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
|
||||
},
|
||||
{
|
||||
name: "version",
|
||||
@@ -285,12 +294,27 @@ module ts {
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
export function readConfigFile(fileName: string): any {
|
||||
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
|
||||
try {
|
||||
var text = sys.readFile(fileName);
|
||||
return /\S/.test(text) ? JSON.parse(text) : {};
|
||||
}
|
||||
catch (e) {
|
||||
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
|
||||
}
|
||||
return parseConfigFileText(fileName, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the text of the tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
* @param jsonText The text of the config file
|
||||
*/
|
||||
export function parseConfigFileText(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
|
||||
try {
|
||||
return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} };
|
||||
}
|
||||
catch (e) {
|
||||
return { error: createCompilerDiagnostic(Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +324,7 @@ module ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine {
|
||||
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
var errors: Diagnostic[] = [];
|
||||
|
||||
return {
|
||||
@@ -359,7 +383,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var sysFiles = sys.readDirectory(basePath, ".ts");
|
||||
var sysFiles = host.readDirectory(basePath, ".ts");
|
||||
for (var i = 0; i < sysFiles.length; i++) {
|
||||
var name = sysFiles[i];
|
||||
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
|
||||
|
||||
@@ -281,6 +281,17 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function memoize<T>(callback: () => T): () => T {
|
||||
let value: T;
|
||||
return () => {
|
||||
if (callback) {
|
||||
value = callback();
|
||||
callback = undefined;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string {
|
||||
baseIndex = baseIndex || 0;
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ module ts {
|
||||
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
|
||||
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." },
|
||||
Cannot_compile_external_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." },
|
||||
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
|
||||
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
|
||||
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
|
||||
@@ -175,6 +175,7 @@ module ts {
|
||||
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." },
|
||||
Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." },
|
||||
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." },
|
||||
@@ -439,6 +440,7 @@ module ts {
|
||||
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
|
||||
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
|
||||
Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." },
|
||||
Failed_to_parse_file_0_Colon_1: { code: 5014, category: DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." },
|
||||
Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." },
|
||||
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
|
||||
Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
|
||||
@@ -467,7 +469,7 @@ module ts {
|
||||
Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." },
|
||||
Do_not_emit_outputs: { code: 6010, category: DiagnosticCategory.Message, key: "Do not emit outputs." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
|
||||
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" },
|
||||
Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." },
|
||||
Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." },
|
||||
@@ -488,8 +490,8 @@ module ts {
|
||||
Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
|
||||
Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
|
||||
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." },
|
||||
Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." },
|
||||
Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." },
|
||||
Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." },
|
||||
Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." },
|
||||
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: DiagnosticCategory.Error, key: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." },
|
||||
Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
|
||||
Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
|
||||
@@ -500,6 +502,8 @@ module ts {
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
|
||||
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
|
||||
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
|
||||
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
|
||||
@@ -631,7 +631,7 @@
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
|
||||
"Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1204
|
||||
},
|
||||
@@ -687,6 +687,10 @@
|
||||
"category": "Error",
|
||||
"code": 1217
|
||||
},
|
||||
"Export assignment is not supported when '--module' flag is 'system'.": {
|
||||
"category": "Error",
|
||||
"code": 1218
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -1744,6 +1748,10 @@
|
||||
"category": "Error",
|
||||
"code": 5013
|
||||
},
|
||||
"Failed to parse file '{0}': {1}.": {
|
||||
"category": "Error",
|
||||
"code": 5014
|
||||
},
|
||||
"Unknown compiler option '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 5023
|
||||
@@ -1857,7 +1865,7 @@
|
||||
"category": "Message",
|
||||
"code": 6015
|
||||
},
|
||||
"Specify module code generation: 'commonjs' or 'amd'": {
|
||||
"Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'": {
|
||||
"category": "Message",
|
||||
"code": 6016
|
||||
},
|
||||
@@ -1941,11 +1949,11 @@
|
||||
"category": "Error",
|
||||
"code": 6045
|
||||
},
|
||||
"Argument for '--module' option must be 'commonjs' or 'amd'.": {
|
||||
"Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'.": {
|
||||
"category": "Error",
|
||||
"code": 6046
|
||||
},
|
||||
"Argument for '--target' option must be 'es3', 'es5', or 'es6'.": {
|
||||
"Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'.": {
|
||||
"category": "Error",
|
||||
"code": 6047
|
||||
},
|
||||
@@ -1989,6 +1997,15 @@
|
||||
"category": "Message",
|
||||
"code": 6057
|
||||
},
|
||||
"Specifies the root directory of input files. Use to control the output directory structure with --outDir.": {
|
||||
"category": "Message",
|
||||
"code": 6058
|
||||
},
|
||||
"File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files.": {
|
||||
"category": "Error",
|
||||
"code": 6059
|
||||
},
|
||||
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+732
-81
File diff suppressed because it is too large
Load Diff
@@ -194,7 +194,7 @@ module ts {
|
||||
case SyntaxKind.ForStatement:
|
||||
return visitNode(cbNode, (<ForStatement>node).initializer) ||
|
||||
visitNode(cbNode, (<ForStatement>node).condition) ||
|
||||
visitNode(cbNode, (<ForStatement>node).iterator) ||
|
||||
visitNode(cbNode, (<ForStatement>node).incrementor) ||
|
||||
visitNode(cbNode, (<ForStatement>node).statement);
|
||||
case SyntaxKind.ForInStatement:
|
||||
return visitNode(cbNode, (<ForInStatement>node).initializer) ||
|
||||
@@ -3497,7 +3497,7 @@ module ts {
|
||||
}
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
if (token !== SyntaxKind.CloseParenToken) {
|
||||
forStatement.iterator = allowInAnd(parseExpression);
|
||||
forStatement.incrementor = allowInAnd(parseExpression);
|
||||
}
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
forOrForInOrForOfStatement = forStatement;
|
||||
|
||||
+70
-35
@@ -455,6 +455,66 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string {
|
||||
let commonPathComponents: string[];
|
||||
let currentDirectory = host.getCurrentDirectory();
|
||||
forEach(files, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
if (isDeclarationFile(sourceFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory);
|
||||
sourcePathComponents.pop(); // The base file name is not part of the common directory path
|
||||
|
||||
if (!commonPathComponents) {
|
||||
// first file
|
||||
commonPathComponents = sourcePathComponents;
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
|
||||
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||
if (i === 0) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
return;
|
||||
}
|
||||
|
||||
// New common path found that is 0 -> i-1
|
||||
commonPathComponents.length = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents
|
||||
if (sourcePathComponents.length < commonPathComponents.length) {
|
||||
commonPathComponents.length = sourcePathComponents.length;
|
||||
}
|
||||
});
|
||||
|
||||
return getNormalizedPathFromPathComponents(commonPathComponents);
|
||||
}
|
||||
|
||||
function checkSourceFilesBelongToPath(sourceFiles: SourceFile[], rootDirectory: string): boolean {
|
||||
let allFilesBelongToPath = true;
|
||||
if (sourceFiles) {
|
||||
let currentDirectory = host.getCurrentDirectory();
|
||||
let absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
||||
|
||||
for (var sourceFile of sourceFiles) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
||||
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
||||
allFilesBelongToPath = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allFilesBelongToPath;
|
||||
}
|
||||
|
||||
function verifyCompilerOptions() {
|
||||
if (options.separateCompilation) {
|
||||
if (options.sourceMap) {
|
||||
@@ -526,7 +586,7 @@ module ts {
|
||||
|
||||
// Cannot specify module gen target when in es6 or above
|
||||
if (options.module && languageVersion >= ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourceRoot
|
||||
@@ -536,41 +596,16 @@ module ts {
|
||||
(options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated
|
||||
(!options.out || firstExternalModuleSourceFile !== undefined))) {
|
||||
|
||||
let commonPathComponents: string[];
|
||||
forEach(files, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)
|
||||
&& !fileExtensionIs(sourceFile.fileName, ".js")) {
|
||||
let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory());
|
||||
sourcePathComponents.pop(); // FileName is not part of directory
|
||||
if (commonPathComponents) {
|
||||
for (let i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
|
||||
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||
if (i === 0) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
return;
|
||||
}
|
||||
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
|
||||
// If a rootDir is specified and is valid use it as the commonSourceDirectory
|
||||
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory());
|
||||
}
|
||||
else {
|
||||
// Compute the commonSourceDirectory from the input files
|
||||
commonSourceDirectory = computeCommonSourceDirectory(files);
|
||||
}
|
||||
|
||||
// New common path found that is 0 -> i-1
|
||||
commonPathComponents.length = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the fileComponent path completely matched and less than already found update the length
|
||||
if (sourcePathComponents.length < commonPathComponents.length) {
|
||||
commonPathComponents.length = sourcePathComponents.length;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// first file
|
||||
commonPathComponents = sourcePathComponents;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
commonSourceDirectory = getNormalizedPathFromPathComponents(commonPathComponents);
|
||||
if (commonSourceDirectory) {
|
||||
if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) {
|
||||
// Make sure directory path ends with directory separator so this string can directly
|
||||
// used to replace with "" to get the relative path of the source file and the relative path doesn't
|
||||
// start with / making it rooted path
|
||||
|
||||
@@ -352,7 +352,7 @@ module ts {
|
||||
export function isLineBreak(ch: number): boolean {
|
||||
// ES5 7.3:
|
||||
// The ECMAScript line terminator characters are listed in Table 3.
|
||||
// Table 3 — Line Terminator Characters
|
||||
// Table 3: Line Terminator Characters
|
||||
// Code Unit Value Name Formal Name
|
||||
// \u000A Line Feed <LF>
|
||||
// \u000D Carriage Return <CR>
|
||||
|
||||
+8
-5
@@ -208,12 +208,15 @@ module ts {
|
||||
|
||||
if (!cachedProgram) {
|
||||
if (configFileName) {
|
||||
var configObject = readConfigFile(configFileName);
|
||||
if (!configObject) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFileName));
|
||||
|
||||
let result = readConfigFile(configFileName);
|
||||
if (result.error) {
|
||||
reportDiagnostic(result.error);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFileName));
|
||||
|
||||
let configObject = result.config;
|
||||
let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName));
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
@@ -230,7 +233,7 @@ module ts {
|
||||
compilerHost.getSourceFile = getSourceFile;
|
||||
}
|
||||
|
||||
var compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
let compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
|
||||
if (!compilerOptions.watch) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
|
||||
+17
-6
@@ -795,7 +795,7 @@ module ts {
|
||||
export interface ForStatement extends IterationStatement {
|
||||
initializer?: VariableDeclarationList | Expression;
|
||||
condition?: Expression;
|
||||
iterator?: Expression;
|
||||
incrementor?: Expression;
|
||||
}
|
||||
|
||||
export interface ForInStatement extends IterationStatement {
|
||||
@@ -1032,6 +1032,10 @@ module ts {
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
|
||||
export interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string): string[];
|
||||
}
|
||||
|
||||
export interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
@@ -1274,6 +1278,7 @@ module ts {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
resolvesToSomeValue(location: Node, name: string): boolean;
|
||||
getBlockScopedVariableId(node: Identifier): number;
|
||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
|
||||
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
|
||||
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
|
||||
@@ -1486,6 +1491,13 @@ module ts {
|
||||
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
|
||||
export interface InterfaceType extends ObjectType {
|
||||
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
}
|
||||
|
||||
export interface InterfaceTypeWithBaseTypes extends InterfaceType {
|
||||
baseTypes: ObjectType[];
|
||||
}
|
||||
|
||||
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
declaredProperties: Symbol[]; // Declared members
|
||||
declaredCallSignatures: Signature[]; // Declared call signatures
|
||||
declaredConstructSignatures: Signature[]; // Declared construct signatures
|
||||
@@ -1493,10 +1505,6 @@ module ts {
|
||||
declaredNumberIndexType: Type; // Declared numeric index type
|
||||
}
|
||||
|
||||
export interface InterfaceTypeWithBaseTypes extends InterfaceType {
|
||||
baseTypes: ObjectType[];
|
||||
}
|
||||
|
||||
// Type references (TypeFlags.Reference)
|
||||
export interface TypeReference extends ObjectType {
|
||||
target: GenericType; // Type reference target
|
||||
@@ -1578,7 +1586,7 @@ module ts {
|
||||
|
||||
/* @internal */
|
||||
export interface TypeMapper {
|
||||
(t: Type): Type;
|
||||
(t: TypeParameter): Type;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1657,6 +1665,7 @@ module ts {
|
||||
preserveConstEnums?: boolean;
|
||||
project?: string;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
@@ -1673,6 +1682,8 @@ module ts {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
AMD = 2,
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
}
|
||||
|
||||
export interface LineAndCharacter {
|
||||
|
||||
@@ -775,7 +775,7 @@ module ts {
|
||||
let forStatement = <ForStatement>parent;
|
||||
return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) ||
|
||||
forStatement.condition === node ||
|
||||
forStatement.iterator === node;
|
||||
forStatement.incrementor === node;
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
let forInStatement = <ForInStatement | ForOfStatement>parent;
|
||||
|
||||
Reference in New Issue
Block a user