diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 007a935a4ae..52860bc0209 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37,7 +37,9 @@ module ts { var emptyArray: any[] = []; var emptySymbols: SymbolTable = {}; - + + var compilerOptions = program.getCompilerOptions(); + var checker: TypeChecker = { getProgram: () => program, getDiagnostics: getDiagnostics, @@ -972,7 +974,8 @@ module ts { } function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { - var stringWriter = createSingleLineTextWriter(flags & TypeFormatFlags.NoTruncation ? undefined : 100); + var maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100; + var stringWriter = createSingleLineTextWriter(maxLength); // TODO(shkamat): typeToString should take enclosingDeclaration as input, once we have implemented enclosingDeclaration writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter); return stringWriter.getText(); @@ -1364,7 +1367,7 @@ module ts { return type; function checkImplicitAny(type: Type) { - if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) { + if (!fullTypeCheck || !compilerOptions.noImplicitAny) { return; } // We need to have ended up with 'any', 'any[]', 'any[][]', etc. @@ -1467,7 +1470,7 @@ module ts { } // Otherwise, fall back to 'any'. else { - if (program.getCompilerOptions().noImplicitAny) { + if (compilerOptions.noImplicitAny) { error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbol.name); } @@ -3159,7 +3162,7 @@ module ts { if (propType !== widenedType) { propTypeWasWidened = true; - if (program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { + if (compilerOptions.noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType)); } } @@ -3987,7 +3990,7 @@ module ts { } // Fall back to any. - if (program.getCompilerOptions().noImplicitAny && objectType !== anyType) { + if (compilerOptions.noImplicitAny && objectType !== anyType) { error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } @@ -4332,7 +4335,7 @@ module ts { var declaration = signature.declaration; if (declaration && (declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature)) { // When resolved signature is a call signature (and not a construct signature) the result type is any - if (program.getCompilerOptions().noImplicitAny) { + if (compilerOptions.noImplicitAny) { error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -4378,7 +4381,7 @@ module ts { var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); - if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { + if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType)); } @@ -4400,7 +4403,7 @@ module ts { var widenedType = getWidenedType(commonType); // Check and report for noImplicitAny if the best common type implicitly gets widened to an 'any'/arrays-of-'any' type. - if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { + if (fullTypeCheck && compilerOptions.noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { var typeName = typeToString(widenedType); if (func.name) { @@ -4976,7 +4979,7 @@ module ts { checkCollisionWithCapturedThisVariable(node, node.name); checkCollistionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); - if (program.getCompilerOptions().noImplicitAny && !node.type) { + if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { case SyntaxKind.ConstructSignature: error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); @@ -5532,7 +5535,7 @@ module ts { } // If there is no body and no explicit return type, then report an error. - if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) { + if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) { // Ignore privates within ambient contexts; they exist purely for documentative purposes to avoid name clashing. // (e.g. privates within .d.ts files do not expose type information) if (!isPrivateWithinAmbient(node)) { @@ -7177,7 +7180,7 @@ module ts { function shouldEmitDeclarations() { // If the declaration emit and there are no errors being reported in program or by checker // declarations can be emitted - return program.getCompilerOptions().declaration && + return compilerOptions.declaration && !program.getDiagnostics().length && !getDiagnostics().length; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c156e3181c1..c13b47a066c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -955,6 +955,7 @@ module ts { locale?: string; mapRoot?: string; module?: ModuleKind; + noErrorTruncation?: boolean; noImplicitAny?: boolean; noLib?: boolean; noLibCheck?: boolean; @@ -967,7 +968,6 @@ module ts { target?: ScriptTarget; version?: boolean; watch?: boolean; - [option: string]: any; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 654f240b4b5..5ee3139d8f7 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -622,6 +622,7 @@ module Harness { options = options || { noResolve: false }; options.target = options.target || ts.ScriptTarget.ES3; options.module = options.module || ts.ModuleKind.None; + options.noErrorTruncation = true; if (settingsCallback) { settingsCallback(null); @@ -725,6 +726,10 @@ module Harness { options.emitBOM = !!setting.value; break; + case 'errortruncation': + options.noErrorTruncation = setting.value === 'false'; + break; + default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1030,7 +1035,7 @@ module Harness { var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom"]; + var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt index c0a826e06a0..cb877f5e57b 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt +++ b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt @@ -10,7 +10,7 @@ ~ !!! Expression expected. ~~~ -!!! Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arr...': +!!! Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }': !!! Property 'isArray' is missing in type 'Number'. var xs4: typeof Array; ~ @@ -18,4 +18,4 @@ ~ !!! Expression expected. ~~~ -!!! Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arr...'. \ No newline at end of file +!!! Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 5fc04ea8d90..973dfe92ca2 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -52,7 +52,7 @@ var b8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; a8 = b8; // error, { foo: number } and Base are incompatible ~~ -!!! Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T)...' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': +!!! Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': !!! Types of parameters 'y' and 'y' are incompatible: !!! Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived': !!! Types of parameters 'arg2' and 'arg2' are incompatible: @@ -61,7 +61,7 @@ !!! Type 'number' is not assignable to type 'string'. b8 = a8; // error, { foo: number } and Base are incompatible ~~ -!!! Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T)...': +!!! Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U': !!! Types of parameters 'y' and 'y' are incompatible: !!! Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any': !!! Types of parameters 'arg2' and 'arg2' are incompatible: diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 9c895e57f08..c5055b16e89 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -52,7 +52,7 @@ var b8: new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; a8 = b8; // error, type mismatch ~~ -!!! Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r...' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': +!!! Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': !!! Types of parameters 'y' and 'y' are incompatible: !!! Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived': !!! Types of parameters 'arg2' and 'arg2' are incompatible: @@ -61,7 +61,7 @@ !!! Type 'number' is not assignable to type 'string'. b8 = a8; // error ~~ -!!! Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r...': +!!! Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U': !!! Types of parameters 'y' and 'y' are incompatible: !!! Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any': !!! Types of parameters 'arg2' and 'arg2' are incompatible: @@ -93,24 +93,24 @@ var b16: new (x: (a: T) => T) => T[]; a16 = b16; // error ~~~ -!!! Type 'new (x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: bo...': +!!! Type 'new (x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }': !!! Types of parameters 'x' and 'x' are incompatible: !!! Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'. b16 = a16; // error ~~~ -!!! Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: bo...' is not assignable to type 'new (x: (a: T) => T) => T[]': +!!! Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new (x: (a: T) => T) => T[]': !!! Types of parameters 'x' and 'x' are incompatible: !!! Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'. var b17: new (x: (a: T) => T) => any[]; a17 = b17; // error ~~~ -!!! Type 'new (x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: {...': +!!! Type 'new (x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; }': !!! Types of parameters 'x' and 'x' are incompatible: !!! Type '(a: any) => any' is not assignable to type '{ new (a: T): T; new (a: T): T; }'. b17 = a17; // error ~~~ -!!! Type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: {...' is not assignable to type 'new (x: (a: T) => T) => any[]': +!!! Type '{ new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; }' is not assignable to type 'new (x: (a: T) => T) => any[]': !!! Types of parameters 'x' and 'x' are incompatible: !!! Type '{ new (a: T): T; new (a: T): T; }' is not assignable to type '(a: any) => any'. } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index f7798de7d1d..81cd8b924f0 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -68,7 +68,7 @@ ~~ !!! Interface 'I4' incorrectly extends interface 'A': !!! Types of property 'a8' are incompatible: -!!! Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T)...' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': +!!! Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': !!! Types of parameters 'y' and 'y' are incompatible: !!! Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived': !!! Types of parameters 'arg2' and 'arg2' are incompatible: diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 29bc90a6bdf..2d267d5a260 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -58,7 +58,7 @@ ~~ !!! Interface 'I4' incorrectly extends interface 'A': !!! Types of property 'a8' are incompatible: -!!! Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r...' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': +!!! Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived': !!! Types of parameters 'y' and 'y' are incompatible: !!! Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived': !!! Types of parameters 'arg2' and 'arg2' are incompatible: diff --git a/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt b/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt index 5172fb47ec3..9b19634265d 100644 --- a/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt +++ b/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt @@ -8,4 +8,4 @@ !!! Property 'getOwnPropertyNamess' does not exist on type '{ a: string; b: number; }'. Object.getOwnPropertyNamess(null); ~~~~~~~~~~~~~~~~~~~~ -!!! Property 'getOwnPropertyNamess' does not exist on type '{ (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any...'. \ No newline at end of file +!!! Property 'getOwnPropertyNamess' does not exist on type '{ (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; }'. \ No newline at end of file diff --git a/tests/baselines/reference/errorWithTruncatedType.errors.txt b/tests/baselines/reference/errorWithTruncatedType.errors.txt new file mode 100644 index 00000000000..7d3cab5f3c5 --- /dev/null +++ b/tests/baselines/reference/errorWithTruncatedType.errors.txt @@ -0,0 +1,15 @@ +==== tests/cases/compiler/errorWithTruncatedType.ts (1 errors) ==== + + var x: { + propertyWithAnExceedinglyLongName1: string; + propertyWithAnExceedinglyLongName2: string; + propertyWithAnExceedinglyLongName3: string; + propertyWithAnExceedinglyLongName4: string; + propertyWithAnExceedinglyLongName5: string; + }; + + // String representation of type of 'x' should be truncated in error message + var s: string = x; + ~ +!!! Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propert...' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/errorWithTruncatedType.js b/tests/baselines/reference/errorWithTruncatedType.js new file mode 100644 index 00000000000..5fd45579a29 --- /dev/null +++ b/tests/baselines/reference/errorWithTruncatedType.js @@ -0,0 +1,18 @@ +//// [errorWithTruncatedType.ts] + +var x: { + propertyWithAnExceedinglyLongName1: string; + propertyWithAnExceedinglyLongName2: string; + propertyWithAnExceedinglyLongName3: string; + propertyWithAnExceedinglyLongName4: string; + propertyWithAnExceedinglyLongName5: string; +}; + +// String representation of type of 'x' should be truncated in error message +var s: string = x; + + +//// [errorWithTruncatedType.js] +var x; +// String representation of type of 'x' should be truncated in error message +var s = x; diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index ed088598bab..1a74ee37809 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -98,7 +98,7 @@ // error var b: { [x: number]: string; } = { ~ -!!! Type '{ [x: number]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e...' is not assignable to type '{ [x: number]: string; }': +!!! Type '{ [x: number]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }': !!! Index signatures are incompatible: !!! Type '{}' is not assignable to type 'string'. a: '', diff --git a/tests/baselines/reference/propertyAccess.errors.txt b/tests/baselines/reference/propertyAccess.errors.txt index 29a62c3fe8c..acb32459571 100644 --- a/tests/baselines/reference/propertyAccess.errors.txt +++ b/tests/baselines/reference/propertyAccess.errors.txt @@ -41,7 +41,7 @@ // Dotted property access of property that doesn't exist on value's apparent type var cc = obj.qqq; // error ~~~ -!!! Property 'qqq' does not exist on type '{ 10: string; x: string; y: number; z: { n: string; m: number; o: () => boolean; }; 'literal prop...'. +!!! Property 'qqq' does not exist on type '{ 10: string; x: string; y: number; z: { n: string; m: number; o: () => boolean; }; 'literal property': number; }'. // Bracket notation property access using string literal value on type with property of that literal name var dd = obj['literal property']; diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index 35d118de6ff..5ac77d01f63 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -1,5 +1,5 @@ ==== tests/cases/compiler/redefineArray.ts (1 errors) ==== Array = function (n:number, s:string) {return n;}; ~~~~~ -!!! Type '(n: number, s: string) => number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arr...': +!!! Type '(n: number, s: string) => number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }': !!! Property 'isArray' is missing in type '(n: number, s: string) => number'. \ No newline at end of file diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index 894a83fc88a..5ccca110ce8 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -128,7 +128,7 @@ // error var b: { [x: string]: string; } = { ~ -!!! Type '{ [x: string]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e...' is not assignable to type '{ [x: string]: string; }': +!!! Type '{ [x: string]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }': !!! Index signatures are incompatible: !!! Type '{}' is not assignable to type 'string'. a: '', diff --git a/tests/baselines/reference/typeName1.errors.txt b/tests/baselines/reference/typeName1.errors.txt index 8deb7dc43d6..92b3279ab81 100644 --- a/tests/baselines/reference/typeName1.errors.txt +++ b/tests/baselines/reference/typeName1.errors.txt @@ -24,7 +24,7 @@ !!! Property 'x' is missing in type 'Number'. var x5:{ (s:string):number;(n:number):string;x;y;z:number;f(n:number):string;f(s:string):number; }=3; ~~ -!!! Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s:...': +!!! Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }': !!! Property 'x' is missing in type 'Number'. var x6:{ z:number;f:{(n:number):string;(s:string):number;}; }=3; ~~ @@ -53,7 +53,7 @@ !!! Property 'length' is missing in type 'Number'. var x12:{z:I;x:boolean;y:(s:string)=>boolean;w:{ z:I;[s:string]:{ x; y; };[n:number]:{x; y;};():boolean; };}[][]=3; ~~~ -!!! Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [x: string]: { x: any; y: any; }...': +!!! Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [x: string]: { x: any; y: any; }; [x: number]: { x: any; y: any; }; z: I; }; }[][]': !!! Property 'length' is missing in type 'Number'. var x13:{ new(): number; new(n:number):number; x: string; w: {y: number;}; (): {}; } = 3; ~~~ diff --git a/tests/cases/compiler/errorWithTruncatedType.ts b/tests/cases/compiler/errorWithTruncatedType.ts new file mode 100644 index 00000000000..307ff642ed9 --- /dev/null +++ b/tests/cases/compiler/errorWithTruncatedType.ts @@ -0,0 +1,12 @@ +// @errortruncation: true + +var x: { + propertyWithAnExceedinglyLongName1: string; + propertyWithAnExceedinglyLongName2: string; + propertyWithAnExceedinglyLongName3: string; + propertyWithAnExceedinglyLongName4: string; + propertyWithAnExceedinglyLongName5: string; +}; + +// String representation of type of 'x' should be truncated in error message +var s: string = x;