Merge branch 'master' into es6ImportExportEmit

This commit is contained in:
Mohamed Hegazy
2015-03-17 13:03:17 -07:00
65 changed files with 1030 additions and 303 deletions
+1
View File
@@ -0,0 +1 @@
*.js linguist-language=TypeScript
+1 -10
View File
@@ -3,13 +3,4 @@ language: node_js
node_js:
- '0.10'
sudo: false
before_script: npm install -g codeclimate-test-reporter
after_script:
- cat coverage/lcov.info | codeclimate
addons:
code_climate:
repo_token: 9852ac5362c8cc38c07ca5adc0f94c20c6c79bd78e17933dc284598a65338656
sudo: false
+2 -3
View File
@@ -38,10 +38,9 @@
"mocha": "latest",
"chai": "latest",
"browserify": "latest",
"istanbul": "latest",
"codeclimate-test-reporter": "latest"
"istanbul": "latest"
},
"scripts": {
"test": "jake generate-code-coverage"
"test": "jake runtests"
}
}
+7 -6
View File
@@ -322,13 +322,14 @@ module ts {
}
else {
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
if (state === ModuleInstanceState.ConstEnumOnly) {
// mark value module as module that contains only enums
node.symbol.constEnumOnlyModule = true;
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
if (node.symbol.constEnumOnlyModule === undefined) {
// non-merged case - use the current state
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly;
}
else if (node.symbol.constEnumOnlyModule) {
// const only value module was merged with instantiated module - reset flag
node.symbol.constEnumOnlyModule = false;
else {
// merged case: module is const enum only if all its pieces are non-instantiated or const enum
node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly;
}
}
}
+80 -40
View File
@@ -79,8 +79,7 @@ module ts {
let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false);
let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false);
@@ -3519,6 +3518,7 @@ module ts {
return t => {
for (let i = 0; i < context.typeParameters.length; i++) {
if (t === context.typeParameters[i]) {
context.inferences[i].isFixed = true;
return getInferredType(context, i);
}
}
@@ -4377,8 +4377,11 @@ module ts {
}
function reportNoCommonSupertypeError(types: Type[], errorLocation: Node, errorMessageChainHead: DiagnosticMessageChain): void {
// The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate
// to not be the common supertype. So if it weren't for this one downfallType (and possibly others),
// the type in question could have been the common supertype.
let bestSupertype: Type;
let bestSupertypeDownfallType: Type; // The type that caused bestSupertype not to be the common supertype
let bestSupertypeDownfallType: Type;
let bestSupertypeScore = 0;
for (let i = 0; i < types.length; i++) {
@@ -4393,6 +4396,8 @@ module ts {
}
}
Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType");
if (score > bestSupertypeScore) {
bestSupertype = types[i];
bestSupertypeDownfallType = downfallType;
@@ -4575,13 +4580,12 @@ module ts {
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
let inferences: TypeInferences[] = [];
for (let unused of typeParameters) {
inferences.push({ primary: undefined, secondary: undefined });
inferences.push({ primary: undefined, secondary: undefined, isFixed: false });
}
return {
typeParameters: typeParameters,
inferUnionTypes: inferUnionTypes,
inferenceCount: 0,
inferences: inferences,
typeParameters,
inferUnionTypes,
inferences,
inferredTypes: new Array(typeParameters.length),
};
}
@@ -4627,11 +4631,21 @@ module ts {
for (let i = 0; i < typeParameters.length; i++) {
if (target === typeParameters[i]) {
let inferences = context.inferences[i];
let candidates = inferiority ?
inferences.secondary || (inferences.secondary = []) :
inferences.primary || (inferences.primary = []);
if (!contains(candidates, source)) candidates.push(source);
break;
if (!inferences.isFixed) {
// Any inferences that are made to a type parameter in a union type are inferior
// to inferences made to a flat (non-union) type. This is because if we infer to
// T | string[], we really don't know if we should be inferring to T or not (because
// the correct constituent on the target side could be string[]). Therefore, we put
// such inferior inferences into a secondary bucket, and only use them if the primary
// bucket is empty.
let candidates = inferiority ?
inferences.secondary || (inferences.secondary = []) :
inferences.primary || (inferences.primary = []);
if (!contains(candidates, source)) {
candidates.push(source);
}
}
return;
}
}
}
@@ -4737,21 +4751,35 @@ module ts {
function getInferredType(context: InferenceContext, index: number): Type {
let inferredType = context.inferredTypes[index];
let inferenceSucceeded: boolean;
if (!inferredType) {
let inferences = getInferenceCandidates(context, index);
if (inferences.length) {
// Infer widened union or supertype, or the undefined type for no common supertype
// Infer widened union or supertype, or the unknown type for no common supertype
let unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences);
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType;
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType;
inferenceSucceeded = !!unionOrSuperType;
}
else {
// Infer the empty object type when no inferences were made
// Infer the empty object type when no inferences were made. It is important to remember that
// in this case, inference still succeeds, meaning there is no error for not having inference
// candidates. An inference error only occurs when there are *conflicting* candidates, i.e.
// candidates with no common supertype.
inferredType = emptyObjectType;
inferenceSucceeded = true;
}
if (inferredType !== inferenceFailureType) {
// Only do the constraint check if inference succeeded (to prevent cascading errors)
if (inferenceSucceeded) {
let constraint = getConstraintOfTypeParameter(context.typeParameters[index]);
inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType;
}
else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) {
// If inference failed, it is necessary to record the index of the failed type parameter (the one we are on).
// It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments.
// So if this failure is on preceding type parameter, this type parameter is the new failure index.
context.failedTypeParameterIndex = index;
}
context.inferredTypes[index] = inferredType;
}
return inferredType;
@@ -6348,11 +6376,32 @@ module ts {
return getSignatureInstantiation(signature, getInferredTypes(context));
}
function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[]): InferenceContext {
function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void {
let typeParameters = signature.typeParameters;
let context = createInferenceContext(typeParameters, /*inferUnionTypes*/ false);
let inferenceMapper = createInferenceMapper(context);
// Clear out all the inference results from the last time inferTypeArguments was called on this context
for (let i = 0; i < typeParameters.length; i++) {
// As an optimization, we don't have to clear (and later recompute) inferred types
// for type parameters that have already been fixed on the previous call to inferTypeArguments.
// It would be just as correct to reset all of them. But then we'd be repeating the same work
// for the type parameters that were fixed, namely the work done by getInferredType.
if (!context.inferences[i].isFixed) {
context.inferredTypes[i] = undefined;
}
}
// On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not
// fixed last time. This means that a type parameter that failed inference last time may succeed this time,
// or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter,
// because it may change. So here we reset it. However, getInferredType will not revisit any type parameters
// that were previously fixed. So if a fixed type parameter failed previously, it will fail again because
// it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter,
// we will lose information that we won't recover this time around.
if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) {
context.failedTypeParameterIndex = undefined;
}
// We perform two passes over the arguments. In the first pass we infer from all arguments, but use
// wildcards for all context sensitive function expressions.
for (let i = 0; i < args.length; i++) {
@@ -6387,18 +6436,7 @@ module ts {
}
}
let inferredTypes = getInferredTypes(context);
// Inference has failed if the inferenceFailureType type is in list of inferences
context.failedTypeParameterIndex = indexOf(inferredTypes, inferenceFailureType);
// Wipe out the inferenceFailureType from the array so that error recovery can work properly
for (let i = 0; i < inferredTypes.length; i++) {
if (inferredTypes[i] === inferenceFailureType) {
inferredTypes[i] = unknownType;
}
}
return context;
getInferredTypes(context);
}
function checkTypeArguments(signature: Signature, typeArguments: TypeNode[], typeArgumentResultTypes: Type[], reportErrors: boolean): boolean {
@@ -6632,15 +6670,17 @@ module ts {
return resolveErrorCall(node);
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>) {
for (let current of candidates) {
if (!hasCorrectArity(node, args, current)) {
for (let originalCandidate of candidates) {
if (!hasCorrectArity(node, args, originalCandidate)) {
continue;
}
let originalCandidate = current;
let inferenceResult: InferenceContext;
let candidate: Signature;
let typeArgumentsAreValid: boolean;
let inferenceContext = originalCandidate.typeParameters
? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false)
: undefined;
while (true) {
candidate = originalCandidate;
if (candidate.typeParameters) {
@@ -6650,9 +6690,9 @@ module ts {
typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)
}
else {
inferenceResult = inferTypeArguments(candidate, args, excludeArgument);
typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0;
typeArgumentTypes = inferenceResult.inferredTypes;
inferTypeArguments(candidate, args, excludeArgument, inferenceContext);
typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined;
typeArgumentTypes = inferenceContext.inferredTypes;
}
if (!typeArgumentsAreValid) {
break;
@@ -6682,7 +6722,7 @@ module ts {
else {
candidateForTypeArgumentError = originalCandidate;
if (!typeArguments) {
resultOfFailedInference = inferenceResult;
resultOfFailedInference = inferenceContext;
}
}
}
-8
View File
@@ -5516,14 +5516,6 @@ module ts {
}
}
function getFirstExportAssignment(sourceFile: SourceFile) {
return forEach(sourceFile.statements, node => {
if (node.kind === SyntaxKind.ExportAssignment) {
return <ExportAssignment>node;
}
});
}
function sortAMDModules(amdModules: {name: string; path: string}[]) {
// AMD modules with declared variable names go first
return amdModules.sort((moduleA, moduleB) => {
+29 -23
View File
@@ -2,8 +2,10 @@
/// <reference path="emitter.ts" />
module ts {
/* @internal */ export let programTime = 0;
/* @internal */ export let emitTime = 0;
/* @internal */ export let ioReadTime = 0;
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export let version = "1.5.0.0";
@@ -36,33 +38,34 @@ module ts {
}
text = "";
}
return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
}
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
try {
var start = new Date().getTime();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
ioWriteTime += new Date().getTime() - start;
}
catch (e) {
if (onError) {
@@ -120,16 +123,19 @@ module ts {
let diagnostics = createDiagnosticCollection();
let seenNoDefaultLib = options.noLib;
let commonSourceDirectory: string;
host = host || createCompilerHost(options);
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
let start = new Date().getTime();
host = host || createCompilerHost(options);
forEach(rootNames, name => processRootFile(name, false));
if (!seenNoDefaultLib) {
processRootFile(host.getDefaultLibFileName(options), true);
}
verifyCompilerOptions();
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
programTime += new Date().getTime() - start;
program = {
getSourceFile: getSourceFile,
+15 -24
View File
@@ -320,22 +320,16 @@ module ts {
}
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
ts.ioReadTime = 0;
ts.parseTime = 0;
ts.bindTime = 0;
ts.checkTime = 0;
ts.emitTime = 0;
var start = new Date().getTime();
ioReadTime = 0;
ioWriteTime = 0;
programTime = 0;
bindTime = 0;
checkTime = 0;
emitTime = 0;
var program = createProgram(fileNames, compilerOptions, compilerHost);
var programTime = new Date().getTime() - start;
var exitStatus = compileProgram();
var end = new Date().getTime() - start;
var compileTime = end - programTime;
if (compilerOptions.listFiles) {
forEach(program.getSourceFiles(), file => {
sys.write(file.fileName + sys.newLine);
@@ -356,19 +350,16 @@ module ts {
}
// Individual component times.
// Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3
// measured parse time along with read IO as a single counter. We preserve that
// behavior so we can accurately compare times. For actual parse times (in isolation)
// is reported below.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
reportTimeStatistic("I/O read", ioReadTime);
reportTimeStatistic("I/O write", ioWriteTime);
reportTimeStatistic("Parse time", programTime);
reportTimeStatistic("Bind time", ts.bindTime);
reportTimeStatistic("Check time", ts.checkTime);
reportTimeStatistic("Emit time", ts.emitTime);
reportTimeStatistic("Parse time w/o IO", ts.parseTime);
reportTimeStatistic("IO read", ts.ioReadTime);
reportTimeStatistic("Compile time", compileTime);
reportTimeStatistic("Total time", end);
reportTimeStatistic("Bind time", bindTime);
reportTimeStatistic("Check time", checkTime);
reportTimeStatistic("Emit time", emitTime);
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
}
return { program, exitStatus };
+4
View File
@@ -1487,11 +1487,15 @@ module ts {
(t: Type): Type;
}
// @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
isFixed: boolean; // Whether the type parameter is fixed, as defined in section 4.12.2 of the TypeScript spec
// If a type parameter is fixed, no more inferences can be made for the type parameter
}
// @internal
export interface InferenceContext {
typeParameters: TypeParameter[]; // Type parameters for which inferences are made
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
+5 -3
View File
@@ -1621,8 +1621,9 @@ module FourSlash {
this.taoInvalidReason = 'verifyIndentationAtCurrentPosition NYI';
var actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition);
if (actual != numberOfSpaces) {
this.raiseError('verifyIndentationAtCurrentPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
var lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
if (actual !== numberOfSpaces) {
this.raiseError('verifyIndentationAtCurrentPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual);
}
}
@@ -1630,8 +1631,9 @@ module FourSlash {
this.taoInvalidReason = 'verifyIndentationAtPosition NYI';
var actual = this.getIndentation(fileName, position);
var lineCol = this.getLineColStringAtPosition(position);
if (actual !== numberOfSpaces) {
this.raiseError('verifyIndentationAtPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
this.raiseError('verifyIndentationAtPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual);
}
}
+53 -9
View File
@@ -359,6 +359,7 @@ module ts.formatting {
case SyntaxKind.ModuleBlock:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TypeLiteral:
case SyntaxKind.TupleType:
case SyntaxKind.CaseBlock:
case SyntaxKind.DefaultClause:
case SyntaxKind.CaseClause:
@@ -370,6 +371,8 @@ module ts.formatting {
case SyntaxKind.ExportAssignment:
case SyntaxKind.ReturnStatement:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
return true;
}
return false;
@@ -390,6 +393,7 @@ module ts.formatting {
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
@@ -431,46 +435,85 @@ module ts.formatting {
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.TypeLiteral:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
case SyntaxKind.CaseBlock:
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
case SyntaxKind.CatchClause:
return isCompletedNode((<CatchClause>n).block, sourceFile);
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.CallSignature:
case SyntaxKind.NewExpression:
if (!(<NewExpression>n).arguments) {
return true;
}
// fall through
case SyntaxKind.CallExpression:
case SyntaxKind.ConstructSignature:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.ParenthesizedType:
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
return isCompletedNode((<SignatureDeclaration>n).type, sourceFile);
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
return !(<FunctionLikeDeclaration>n).body || isCompletedNode((<FunctionLikeDeclaration>n).body, sourceFile);
if ((<FunctionLikeDeclaration>n).body) {
return isCompletedNode((<FunctionLikeDeclaration>n).body, sourceFile);
}
if ((<FunctionLikeDeclaration>n).type) {
return isCompletedNode((<FunctionLikeDeclaration>n).type, sourceFile);
}
// Even though type parameters can be unclosed, we can get away with
// having at least a closing paren.
return hasChildOfKind(n, SyntaxKind.CloseParenToken, sourceFile);
case SyntaxKind.ModuleDeclaration:
return (<ModuleDeclaration>n).body && isCompletedNode((<ModuleDeclaration>n).body, sourceFile);
case SyntaxKind.IfStatement:
if ((<IfStatement>n).elseStatement) {
return isCompletedNode((<IfStatement>n).elseStatement, sourceFile);
}
return isCompletedNode((<IfStatement>n).thenStatement, sourceFile);
case SyntaxKind.ExpressionStatement:
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile);
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ComputedPropertyName:
case SyntaxKind.TupleType:
return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile);
case SyntaxKind.IndexSignature:
if ((<IndexSignatureDeclaration>n).type) {
return isCompletedNode((<IndexSignatureDeclaration>n).type, sourceFile);
}
return hasChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
case SyntaxKind.CaseClause:
case SyntaxKind.DefaultClause:
// there is no such thing as terminator token for CaseClause\DefaultClause so for simplicitly always consider them non-completed
// there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed
return false;
case SyntaxKind.ForStatement:
return isCompletedNode((<ForStatement>n).statement, sourceFile);
case SyntaxKind.ForInStatement:
return isCompletedNode((<ForInStatement>n).statement, sourceFile);
case SyntaxKind.ForOfStatement:
return isCompletedNode((<ForOfStatement>n).statement, sourceFile);
case SyntaxKind.WhileStatement:
return isCompletedNode((<WhileStatement>n).statement, sourceFile);
return isCompletedNode((<IterationStatement>n).statement, sourceFile);
case SyntaxKind.DoStatement:
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
let hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile);
@@ -478,6 +521,7 @@ module ts.formatting {
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
}
return isCompletedNode((<DoStatement>n).statement, sourceFile);
default:
return true;
}
+4
View File
@@ -79,6 +79,10 @@ module ts {
};
}
export function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean {
return !!findChildOfKind(n, kind, sourceFile);
}
export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node {
return forEach(n.getChildren(sourceFile), c => c.kind === kind && c);
}
@@ -1176,17 +1176,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -3769,38 +3769,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
@@ -1207,17 +1207,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -3915,38 +3915,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
@@ -1208,17 +1208,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -3865,38 +3865,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
@@ -1245,17 +1245,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -4038,38 +4038,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
@@ -0,0 +1,26 @@
//// [constEnumOnlyModuleMerging.ts]
module Outer {
export var x = 1;
}
module Outer {
export const enum A { X }
}
module B {
import O = Outer;
var x = O.A.X;
var y = O.x;
}
//// [constEnumOnlyModuleMerging.js]
var Outer;
(function (Outer) {
Outer.x = 1;
})(Outer || (Outer = {}));
var B;
(function (B) {
var O = Outer;
var x = 0 /* X */;
var y = O.x;
})(B || (B = {}));
@@ -0,0 +1,37 @@
=== tests/cases/compiler/constEnumOnlyModuleMerging.ts ===
module Outer {
>Outer : typeof Outer
export var x = 1;
>x : number
}
module Outer {
>Outer : typeof Outer
export const enum A { X }
>A : A
>X : A
}
module B {
>B : typeof B
import O = Outer;
>O : typeof O
>Outer : typeof O
var x = O.A.X;
>x : O.A
>O.A.X : O.A
>O.A : typeof O.A
>O : typeof O
>A : typeof O.A
>X : O.A
var y = O.x;
>y : number
>O.x : number
>O : typeof O
>x : number
}
@@ -0,0 +1,21 @@
//// [typeParameterFixingWithConstraints.ts]
interface IBar {
[barId: string]: any;
}
interface IFoo {
foo<TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar;
}
var foo: IFoo;
foo.foo({ bar: null }, bar => null, bar => null);
//// [typeParameterFixingWithConstraints.js]
var foo;
foo.foo({
bar: null
}, function (bar) {
return null;
}, function (bar) {
return null;
});
@@ -0,0 +1,44 @@
=== tests/cases/compiler/typeParameterFixingWithConstraints.ts ===
interface IBar {
>IBar : IBar
[barId: string]: any;
>barId : string
}
interface IFoo {
>IFoo : IFoo
foo<TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar;
>foo : <TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar
>TBar : TBar
>IBar : IBar
>bar : TBar
>TBar : TBar
>bar1 : (bar: TBar) => TBar
>bar : TBar
>TBar : TBar
>TBar : TBar
>bar2 : (bar: TBar) => TBar
>bar : TBar
>TBar : TBar
>TBar : TBar
>TBar : TBar
}
var foo: IFoo;
>foo : IFoo
>IFoo : IFoo
foo.foo({ bar: null }, bar => null, bar => null);
>foo.foo({ bar: null }, bar => null, bar => null) : IBar
>foo.foo : <TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar
>foo : IFoo
>foo : <TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar
>{ bar: null } : { [x: string]: null; bar: null; }
>bar : null
>bar => null : (bar: IBar) => any
>bar : IBar
>bar => null : (bar: IBar) => any
>bar : IBar
@@ -0,0 +1,28 @@
//// [typeParameterFixingWithContextSensitiveArguments.ts]
function f<T, U>(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(b, x => x.a, a); // type [A, A]
var d2 = f(b, x => x.a, null); // type [B, A]
var d3 = f(b, x => x.b, null); // type [B, any]
//// [typeParameterFixingWithContextSensitiveArguments.js]
function f(y, f, x) {
return [
y,
f(x)
];
}
var a, b;
var d = f(b, function (x) {
return x.a;
}, a); // type [A, A]
var d2 = f(b, function (x) {
return x.a;
}, null); // type [B, A]
var d3 = f(b, function (x) {
return x.b;
}, null); // type [B, any]
@@ -0,0 +1,71 @@
=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts ===
function f<T, U>(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; }
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>T : T
>U : U
>y : T
>T : T
>f : (x: T) => U
>x : T
>T : T
>U : U
>x : T
>T : T
>T : T
>U : U
>[y, f(x)] : [T, U]
>y : T
>f(x) : U
>f : (x: T) => U
>x : T
interface A { a: A; }
>A : A
>a : A
>A : A
interface B extends A { b; }
>B : B
>A : A
>b : any
var a: A, b: B;
>a : A
>A : A
>b : B
>B : B
var d = f(b, x => x.a, a); // type [A, A]
>d : [A, A]
>f(b, x => x.a, a) : [A, A]
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>b : B
>x => x.a : (x: A) => A
>x : A
>x.a : A
>x : A
>a : A
>a : A
var d2 = f(b, x => x.a, null); // type [B, A]
>d2 : [B, A]
>f(b, x => x.a, null) : [B, A]
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>b : B
>x => x.a : (x: B) => A
>x : B
>x.a : A
>x : B
>a : A
var d3 = f(b, x => x.b, null); // type [B, any]
>d3 : [B, any]
>f(b, x => x.b, null) : [B, any]
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>b : B
>x => x.b : (x: B) => any
>x : B
>x.b : any
>x : B
>b : any
@@ -0,0 +1,15 @@
tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts(7,25): error TS2345: Argument of type '(x: A) => A' is not assignable to parameter of type '(x: A) => B'.
Type 'A' is not assignable to type 'B'.
==== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts (1 errors) ====
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(a, b, x => x, x => x); // A => A not assignable to A => B
~~~~~~
!!! error TS2345: Argument of type '(x: A) => A' is not assignable to parameter of type '(x: A) => B'.
!!! error TS2345: Type 'A' is not assignable to type 'B'.
@@ -0,0 +1,22 @@
//// [typeParameterFixingWithContextSensitiveArguments2.ts]
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(a, b, x => x, x => x); // A => A not assignable to A => B
//// [typeParameterFixingWithContextSensitiveArguments2.js]
function f(y, y1, p, p1) {
return [
y,
p1(y)
];
}
var a, b;
var d = f(a, b, function (x) {
return x;
}, function (x) {
return x;
}); // A => A not assignable to A => B
@@ -0,0 +1,15 @@
tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts(7,29): error TS2345: Argument of type '(t2: A) => A' is not assignable to parameter of type '(t2: A) => B'.
Type 'A' is not assignable to type 'B'.
==== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts (1 errors) ====
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; }
interface A { a: A; }
interface B extends A { b: B; }
var a: A, b: B;
var d = f(a, b, u2 => u2.b, t2 => t2);
~~~~~~~~
!!! error TS2345: Argument of type '(t2: A) => A' is not assignable to parameter of type '(t2: A) => B'.
!!! error TS2345: Type 'A' is not assignable to type 'B'.
@@ -0,0 +1,22 @@
//// [typeParameterFixingWithContextSensitiveArguments3.ts]
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; }
interface A { a: A; }
interface B extends A { b: B; }
var a: A, b: B;
var d = f(a, b, u2 => u2.b, t2 => t2);
//// [typeParameterFixingWithContextSensitiveArguments3.js]
function f(t1, u1, pf1, pf2) {
return [
t1,
pf2(t1)
];
}
var a, b;
var d = f(a, b, function (u2) {
return u2.b;
}, function (t2) {
return t2;
});
@@ -0,0 +1,22 @@
//// [typeParameterFixingWithContextSensitiveArguments4.ts]
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(a, b, x => x, x => <any>x); // Type [A, B]
//// [typeParameterFixingWithContextSensitiveArguments4.js]
function f(y, y1, p, p1) {
return [
y,
p1(y)
];
}
var a, b;
var d = f(a, b, function (x) {
return x;
}, function (x) {
return x;
}); // Type [A, B]
@@ -0,0 +1,55 @@
=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments4.ts ===
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; }
>f : <T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U) => [T, U]
>T : T
>U : U
>y : T
>T : T
>y1 : U
>U : U
>p : (z: U) => T
>z : U
>U : U
>T : T
>p1 : (x: T) => U
>x : T
>T : T
>U : U
>T : T
>U : U
>[y, p1(y)] : [T, U]
>y : T
>p1(y) : U
>p1 : (x: T) => U
>y : T
interface A { a: A; }
>A : A
>a : A
>A : A
interface B extends A { b; }
>B : B
>A : A
>b : any
var a: A, b: B;
>a : A
>A : A
>b : B
>B : B
var d = f(a, b, x => x, x => <any>x); // Type [A, B]
>d : [A, B]
>f(a, b, x => x, x => <any>x) : [A, B]
>f : <T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U) => [T, U]
>a : A
>b : B
>x => x : (x: B) => B
>x : B
>x : B
>x => <any>x : (x: A) => any
>x : A
><any>x : any
>x : A
@@ -0,0 +1,22 @@
//// [typeParameterFixingWithContextSensitiveArguments5.ts]
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; }
interface A { a: A; }
interface B extends A { b: any; }
var a: A, b: B;
var d = f(a, b, u2 => u2.b, t2 => t2);
//// [typeParameterFixingWithContextSensitiveArguments5.js]
function f(t1, u1, pf1, pf2) {
return [
t1,
pf2(t1)
];
}
var a, b;
var d = f(a, b, function (u2) {
return u2.b;
}, function (t2) {
return t2;
});
@@ -0,0 +1,56 @@
=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments5.ts ===
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; }
>f : <T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U) => [T, U]
>T : T
>U : U
>t1 : T
>T : T
>u1 : U
>U : U
>pf1 : (u2: U) => T
>u2 : U
>U : U
>T : T
>pf2 : (t2: T) => U
>t2 : T
>T : T
>U : U
>T : T
>U : U
>[t1, pf2(t1)] : [T, U]
>t1 : T
>pf2(t1) : U
>pf2 : (t2: T) => U
>t1 : T
interface A { a: A; }
>A : A
>a : A
>A : A
interface B extends A { b: any; }
>B : B
>A : A
>b : any
var a: A, b: B;
>a : A
>A : A
>b : B
>B : B
var d = f(a, b, u2 => u2.b, t2 => t2);
>d : [any, B]
>f(a, b, u2 => u2.b, t2 => t2) : [any, B]
>f : <T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U) => [T, U]
>a : A
>b : B
>u2 => u2.b : (u2: B) => any
>u2 : B
>u2.b : any
>u2 : B
>b : any
>t2 => t2 : (t2: any) => any
>t2 : any
>t2 : any
@@ -0,0 +1,13 @@
module Outer {
export var x = 1;
}
module Outer {
export const enum A { X }
}
module B {
import O = Outer;
var x = O.A.X;
var y = O.x;
}
@@ -0,0 +1,10 @@
interface IBar {
[barId: string]: any;
}
interface IFoo {
foo<TBar extends IBar>(bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar): TBar;
}
var foo: IFoo;
foo.foo({ bar: null }, bar => null, bar => null);
@@ -0,0 +1,9 @@
function f<T, U>(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(b, x => x.a, a); // type [A, A]
var d2 = f(b, x => x.a, null); // type [B, A]
var d3 = f(b, x => x.b, null); // type [B, any]
@@ -0,0 +1,7 @@
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(a, b, x => x, x => x); // A => A not assignable to A => B
@@ -0,0 +1,7 @@
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; }
interface A { a: A; }
interface B extends A { b: B; }
var a: A, b: B;
var d = f(a, b, u2 => u2.b, t2 => t2);
@@ -0,0 +1,7 @@
function f<T, U>(y: T, y1: U, p: (z: U) => T, p1: (x: T) => U): [T, U] { return [y, p1(y)]; }
interface A { a: A; }
interface B extends A { b; }
var a: A, b: B;
var d = f(a, b, x => x, x => <any>x); // Type [A, B]
@@ -0,0 +1,7 @@
function f<T, U>(t1: T, u1: U, pf1: (u2: U) => T, pf2: (t2: T) => U): [T, U] { return [t1, pf2(t1)]; }
interface A { a: A; }
interface B extends A { b: any; }
var a: A, b: B;
var d = f(a, b, u2 => u2.b, t2 => t2);
+4 -4
View File
@@ -176,8 +176,8 @@
////// the purpose of this test is to verity smart indent
////// works for unterminated function arguments at the end of a file.
////function unterminatedListIndentation(a,
////{| "indent": 0 |}
////{| "indent": 4 |}
test.markers().forEach((marker) => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,17 @@
/// <reference path="fourslash.ts"/>
////
////new Array
////{| "indent": 0 |}
////new Array;
////{| "indent": 0 |}
////new Array(0);
////{| "indent": 0 |}
////new Array(;
////{| "indent": 0 |}
////new Array(
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts"/>
////var /*1*/[/*2*/a,/*3*/b,/*4*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 8);
verifyIndentationAfterNewLine("3", 8);
verifyIndentationAfterNewLine("4", 8);
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts"/>
////var /*1*/[/*2*/a,/*3*/b/*4*/]/*5*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 8);
verifyIndentationAfterNewLine("3", 8);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 0);
@@ -0,0 +1,13 @@
/// <reference path="fourslash.ts"/>
////var x = (/*1*/1/*2*/)/*3*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 0);
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts"/>
////var y = (
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -4,4 +4,4 @@
/////**/
goTo.marker();
verify.indentationIs(0);
verify.indentationIs(4);
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts"/>
////var /*1*/{/*2*/a,/*3*/b:/*4*/k,/*5*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 8);
verifyIndentationAfterNewLine("3", 8);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 8);
@@ -0,0 +1,16 @@
/// <reference path="fourslash.ts"/>
////var /*1*/{/*2*/a,/*3*/b:/*4*/k,/*5*/}/*6*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 8);
verifyIndentationAfterNewLine("3", 8);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 8);
verifyIndentationAfterNewLine("6", 0);
@@ -0,0 +1,36 @@
/// <reference path='fourslash.ts' />
////class Foo {
//// get foo(a,
//// /*1*/b,/*0*/
//// //comment/*2*/
//// /*3*/c
//// ) {
//// }
//// set foo(a,
//// /*5*/b,/*4*/
//// //comment/*6*/
//// /*7*/c
//// ) {
//// }
////}
goTo.marker("0");
edit.insert("\r\n");
verify.indentationIs(8);
goTo.marker("1");
verify.currentLineContentIs(" b,");
goTo.marker("2");
verify.currentLineContentIs(" //comment");
goTo.marker("3");
verify.currentLineContentIs(" c");
goTo.marker("4");
edit.insert("\r\n");
verify.indentationIs(8);
goTo.marker("5");
verify.currentLineContentIs(" b,");
goTo.marker("6");
verify.currentLineContentIs(" //comment");
goTo.marker("7");
verify.currentLineContentIs(" c");
@@ -0,0 +1,36 @@
/// <reference path='fourslash.ts' />
////class Foo {
//// get foo(a,
//// /*1*/b,/*0*/
//// //comment/*2*/
//// /*3*/c
//// ) {
//// }
//// set foo(a,
//// /*5*/b,/*4*/
//// //comment/*6*/
//// /*7*/c
//// ) {
//// }
////}
goTo.marker("0");
edit.insert("\r\n");
verify.indentationIs(8);
goTo.marker("1");
verify.currentLineContentIs(" b,");
goTo.marker("2");
verify.currentLineContentIs(" //comment");
goTo.marker("3");
verify.currentLineContentIs(" c");
goTo.marker("4");
edit.insert("\r\n");
verify.indentationIs(8);
goTo.marker("5");
verify.currentLineContentIs(" b,");
goTo.marker("6");
verify.currentLineContentIs(" //comment");
goTo.marker("7");
verify.currentLineContentIs(" c");
@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
////class Foo {
//// get foo() {
////{| "indent": 8 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,8 @@
/// <reference path='fourslash.ts' />
////var x: () => {
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
////var x = {
//// [1123123123132
////{| "indent": 4 |}
////}
// Note that we currently do NOT indent further in a computed property.
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,8 @@
/// <reference path='fourslash.ts' />
////var x: new () => {
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
////function /*1*/f/*2*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts' />
////function f</*1*/A/*2*/,B/*3*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 4);
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts' />
////function f<A,B,C>/*1*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
@@ -0,0 +1,17 @@
/// <reference path='fourslash.ts' />
////function f<A,B,C>/*1*/(/*2*/a: A, /*3*/b:/*4*/B, c/*5*/, d: C/*6*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\r\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 4);
verifyIndentationAfterNewLine("4", 4);
verifyIndentationAfterNewLine("5", 4);
verifyIndentationAfterNewLine("6", 4);
@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
////function f<A,B,C>(a: A, b:B, c, d: C): {
////{| "indent": 4 |}
////
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,10 @@
/// <reference path='fourslash.ts' />
////function f<A,B,C>(a: A, b:B, c, d: C): {
////{| "indent": 4 |}
////} {
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
////class C {
////[x: string
////{| "indent": 4 |}
////
// Note that we currently do NOT indent further in an index signature.
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,8 @@
/// <reference path='fourslash.ts' />
////var x: {
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
@@ -0,0 +1,8 @@
/// <reference path='fourslash.ts' />
////var x: [string, number,
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});