mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into fix19349
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
|
||||
|
||||
<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
|
||||
**TypeScript Version:** 2.6.0-dev.201xxxxx
|
||||
**TypeScript Version:** 2.7.0-dev.201xxxxx
|
||||
|
||||
**Code**
|
||||
|
||||
|
||||
+16
-19
@@ -6726,6 +6726,16 @@ namespace ts {
|
||||
isInJavaScriptFile(signature.declaration));
|
||||
}
|
||||
|
||||
function getBaseSignature(signature: Signature) {
|
||||
const typeParameters = signature.typeParameters;
|
||||
if (typeParameters) {
|
||||
const typeEraser = createTypeEraser(typeParameters);
|
||||
const baseConstraints = map(typeParameters, tp => instantiateType(getBaseConstraintOfType(tp), typeEraser) || emptyObjectType);
|
||||
return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true);
|
||||
}
|
||||
return signature;
|
||||
}
|
||||
|
||||
function getOrCreateTypeFromSignature(signature: Signature): ObjectType {
|
||||
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
||||
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
||||
@@ -10955,7 +10965,7 @@ namespace ts {
|
||||
const targetLen = targetSignatures.length;
|
||||
const len = sourceLen < targetLen ? sourceLen : targetLen;
|
||||
for (let i = 0; i < len; i++) {
|
||||
inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
|
||||
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13430,7 +13440,7 @@ namespace ts {
|
||||
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
|
||||
function getContextualTypeForObjectLiteralMethod(node: MethodDeclaration): Type {
|
||||
Debug.assert(isObjectLiteralMethod(node));
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return undefined;
|
||||
}
|
||||
@@ -13549,7 +13559,7 @@ namespace ts {
|
||||
* @returns the contextual type of an expression.
|
||||
*/
|
||||
function getContextualType(node: Expression): Type | undefined {
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return undefined;
|
||||
}
|
||||
@@ -23114,21 +23124,8 @@ namespace ts {
|
||||
|
||||
// Language service support
|
||||
|
||||
function isInsideWithStatementBody(node: Node): boolean {
|
||||
if (node) {
|
||||
while (node.parent) {
|
||||
if (node.parent.kind === SyntaxKind.WithStatement && (<WithStatement>node.parent).statement === node) {
|
||||
return true;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] {
|
||||
if (isInsideWithStatementBody(location)) {
|
||||
if (location.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return [];
|
||||
}
|
||||
@@ -23428,7 +23425,7 @@ namespace ts {
|
||||
return isExternalModule(<SourceFile>node) ? getMergedSymbol(node.symbol) : undefined;
|
||||
}
|
||||
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return undefined;
|
||||
}
|
||||
@@ -23536,7 +23533,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getTypeOfNode(node: Node): Type {
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -4724,7 +4724,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
node.expression = allowInAnd(parseExpression);
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
node.statement = parseStatement();
|
||||
node.statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -451,6 +451,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
PossiblyContainsDynamicImport = 1 << 19,
|
||||
JSDoc = 1 << 20, // If node was parsed inside jsdoc
|
||||
/* @internal */ InWithStatement = 1 << 21, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
|
||||
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
@@ -458,7 +459,7 @@ namespace ts {
|
||||
ReachabilityAndEmitFlags = ReachabilityCheckFlags | HasAsyncFunctions,
|
||||
|
||||
// Parsing context flags
|
||||
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile,
|
||||
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile | InWithStatement,
|
||||
|
||||
// Exclude these flags when parsing a Type
|
||||
TypeExcludesFlags = YieldContext | AwaitContext,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [
|
||||
Diagnostics.Cannot_find_module_0.code,
|
||||
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code,
|
||||
],
|
||||
getCodeActions: context => {
|
||||
|
||||
+1
-1
@@ -408,7 +408,7 @@ declare namespace ts {
|
||||
BlockScoped = 3,
|
||||
ReachabilityCheckFlags = 384,
|
||||
ReachabilityAndEmitFlags = 1408,
|
||||
ContextFlags = 96256,
|
||||
ContextFlags = 2193408,
|
||||
TypeExcludesFlags = 20480,
|
||||
}
|
||||
enum ModifierFlags {
|
||||
|
||||
+1
-1
@@ -408,7 +408,7 @@ declare namespace ts {
|
||||
BlockScoped = 3,
|
||||
ReachabilityCheckFlags = 384,
|
||||
ReachabilityAndEmitFlags = 1408,
|
||||
ContextFlags = 96256,
|
||||
ContextFlags = 2193408,
|
||||
TypeExcludesFlags = 20480,
|
||||
}
|
||||
enum ModifierFlags {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstructorTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: new <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: new (t: any) => string; }'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstructorTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: new <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: new (t: {}) => string; }'.
|
||||
Types of property 'cb' are incompatible.
|
||||
Type 'new <T>(x: T, y: T) => string' is not assignable to type 'new (t: any) => string'.
|
||||
Type 'new <T>(x: T, y: T) => string' is not assignable to type 'new (t: {}) => string'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstructorTypedArguments5.ts(13,14): error TS2345: Argument of type '{ cb: new (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: new (t: string) => string; }'.
|
||||
Types of property 'cb' are incompatible.
|
||||
Type 'new (x: string, y: number) => string' is not assignable to type 'new (t: string) => string'.
|
||||
@@ -19,9 +19,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithCon
|
||||
var arg2: { cb: new <T>(x: T, y: T) => string };
|
||||
var r2 = foo(arg2); // error
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type '{ cb: new <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: new (t: any) => string; }'.
|
||||
!!! error TS2345: Argument of type '{ cb: new <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: new (t: {}) => string; }'.
|
||||
!!! error TS2345: Types of property 'cb' are incompatible.
|
||||
!!! error TS2345: Type 'new <T>(x: T, y: T) => string' is not assignable to type 'new (t: any) => string'.
|
||||
!!! error TS2345: Type 'new <T>(x: T, y: T) => string' is not assignable to type 'new (t: {}) => string'.
|
||||
var arg3: { cb: new (x: string, y: number) => string };
|
||||
var r3 = foo(arg3); // error
|
||||
~~~~
|
||||
|
||||
@@ -53,8 +53,8 @@ var a: {
|
||||
}
|
||||
|
||||
var r = foo(i); // any
|
||||
>r : any
|
||||
>foo(i) : any
|
||||
>r : {}
|
||||
>foo(i) : {}
|
||||
>foo : <T>(x: new (a: T) => T) => T
|
||||
>i : I
|
||||
|
||||
@@ -71,8 +71,8 @@ var r3 = foo(i2); // string
|
||||
>i2 : I2<string>
|
||||
|
||||
var r3b = foo(a); // any
|
||||
>r3b : any
|
||||
>foo(a) : any
|
||||
>r3b : {}
|
||||
>foo(a) : {}
|
||||
>foo : <T>(x: new (a: T) => T) => T
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
@@ -101,15 +101,15 @@ var r4 = foo2(1, i2); // error
|
||||
>i2 : I2<string>
|
||||
|
||||
var r4b = foo2(1, a); // any
|
||||
>r4b : any
|
||||
>foo2(1, a) : any
|
||||
>r4b : {}
|
||||
>foo2(1, a) : {}
|
||||
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
|
||||
>1 : 1
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
var r5 = foo2(1, i); // any
|
||||
>r5 : any
|
||||
>foo2(1, i) : any
|
||||
>r5 : {}
|
||||
>foo2(1, i) : {}
|
||||
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
|
||||
>1 : 1
|
||||
>i : I
|
||||
@@ -141,16 +141,16 @@ function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
|
||||
}
|
||||
|
||||
var r7 = foo3(null, i, ''); // any
|
||||
>r7 : any
|
||||
>foo3(null, i, '') : any
|
||||
>r7 : {}
|
||||
>foo3(null, i, '') : {}
|
||||
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
|
||||
>null : null
|
||||
>i : I
|
||||
>'' : ""
|
||||
|
||||
var r7b = foo3(null, a, ''); // any
|
||||
>r7b : any
|
||||
>foo3(null, a, '') : any
|
||||
>r7b : {}
|
||||
>foo3(null, a, '') : {}
|
||||
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
|
||||
>null : null
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
+10
-10
@@ -87,8 +87,8 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r7 = foo5(b); // new any => string; new(x:number) => any
|
||||
>r7 : { new (x: any): string; new (x: number): any; }
|
||||
>foo5(b) : { new (x: any): string; new (x: number): any; }
|
||||
>r7 : { new (x: {}): string; new (x: number): {}; }
|
||||
>foo5(b) : { new (x: {}): string; new (x: number): {}; }
|
||||
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
|
||||
>b : { new <T>(x: T): string; new <T>(x: number): T; }
|
||||
|
||||
@@ -114,8 +114,8 @@ module GenericParameter {
|
||||
>a : { new (x: boolean): string; new (x: number): boolean; }
|
||||
|
||||
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
|
||||
>r9 : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>foo6(b) : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>r9 : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo6(b) : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>b : { new <T>(x: T): string; new <T>(x: number): T; }
|
||||
|
||||
@@ -137,8 +137,8 @@ module GenericParameter {
|
||||
}
|
||||
|
||||
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
|
||||
>r13 : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>foo7(1, b) : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>r13 : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7(1, b) : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>b : { new <T>(x: T): string; new <T>(x: number): T; }
|
||||
@@ -162,15 +162,15 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
|
||||
>r14 : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>foo7(1, c) : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>r14 : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7(1, c) : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>c : { <T>(x: number): T; new <T>(x: T): string; }
|
||||
|
||||
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
|
||||
>r15 : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>foo7(1, c2) : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>r15 : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7(1, c2) : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments2.ts(31,20): error TS2345: Argument of type 'new <T>(x: T, y: T) => string' is not assignable to parameter of type '{ new (x: any): string; new (x: any, y?: any): string; }'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments2.ts(31,20): error TS2345: Argument of type 'new <T>(x: T, y: T) => string' is not assignable to parameter of type '{ new (x: {}): string; new (x: {}, y?: {}): string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments2.ts (1 errors) ====
|
||||
@@ -34,7 +34,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOve
|
||||
var b: { new <T>(x: T, y: T): string };
|
||||
var r10 = foo6(b); // error
|
||||
~
|
||||
!!! error TS2345: Argument of type 'new <T>(x: T, y: T) => string' is not assignable to parameter of type '{ new (x: any): string; new (x: any, y?: any): string; }'.
|
||||
!!! error TS2345: Argument of type 'new <T>(x: T, y: T) => string' is not assignable to parameter of type '{ new (x: {}): string; new (x: {}, y?: {}): string; }'.
|
||||
|
||||
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
|
||||
return cb;
|
||||
|
||||
@@ -63,8 +63,8 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r6 = foo5(a); // ok
|
||||
>r6 : { new (x: any): string; new (x: number): any; }
|
||||
>foo5(a) : { new (x: any): string; new (x: number): any; }
|
||||
>r6 : { new (x: {}): string; new (x: number): {}; }
|
||||
>foo5(a) : { new (x: {}): string; new (x: number): {}; }
|
||||
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
|
||||
>a : new <T>(x: T) => T
|
||||
|
||||
@@ -115,8 +115,8 @@ module GenericParameter {
|
||||
}
|
||||
|
||||
var r13 = foo7(1, a); // ok
|
||||
>r13 : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>foo7(1, a) : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>r13 : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7(1, a) : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>a : new <T>(x: T) => T
|
||||
@@ -131,8 +131,8 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r14 = foo7(1, c); // ok
|
||||
>r14 : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>foo7(1, c) : { new (x: any): string; new (x: any, y?: any): string; }
|
||||
>r14 : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7(1, c) : { new (x: {}): string; new (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>c : { new <T>(x: T): number; new <T>(x: number): T; }
|
||||
|
||||
@@ -83,8 +83,8 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r7 = foo5(a); // any => string (+1 overload)
|
||||
>r7 : { (x: any): string; (x: number): any; }
|
||||
>foo5(a) : { (x: any): string; (x: number): any; }
|
||||
>r7 : { (x: {}): string; (x: number): {}; }
|
||||
>foo5(a) : { (x: {}): string; (x: number): {}; }
|
||||
>foo5 : <T>(cb: { (x: T): string; (x: number): T; }) => { (x: T): string; (x: number): T; }
|
||||
>a : { <T>(x: T): string; <T>(x: number): T; }
|
||||
|
||||
@@ -112,8 +112,8 @@ module GenericParameter {
|
||||
>x : any
|
||||
|
||||
var r9 = foo6(<T>(x: T) => ''); // any => string (+1 overload)
|
||||
>r9 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo6(<T>(x: T) => '') : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r9 : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo6(<T>(x: T) => '') : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo6 : <T>(cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
><T>(x: T) => '' : <T>(x: T) => string
|
||||
>T : T
|
||||
@@ -122,8 +122,8 @@ module GenericParameter {
|
||||
>'' : ""
|
||||
|
||||
var r11 = foo6(<T>(x: T, y?: T) => ''); // any => string (+1 overload)
|
||||
>r11 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo6(<T>(x: T, y?: T) => '') : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r11 : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo6(<T>(x: T, y?: T) => '') : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo6 : <T>(cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
><T>(x: T, y?: T) => '' : <T>(x: T, y?: T) => string
|
||||
>T : T
|
||||
@@ -160,8 +160,8 @@ module GenericParameter {
|
||||
>x : any
|
||||
|
||||
var r13 = foo7(1, <T>(x: T) => ''); // any => string (+1 overload) [inferences are made for T, but lambda not contextually typed]
|
||||
>r13 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo7(1, <T>(x: T) => '') : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r13 : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7(1, <T>(x: T) => '') : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
><T>(x: T) => '' : <T>(x: T) => string
|
||||
@@ -180,8 +180,8 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r14 = foo7(1, a); // any => string (+1 overload) [inferences are made for T, but lambda not contextually typed]
|
||||
>r14 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo7(1, a) : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r14 : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7(1, a) : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>a : { <T>(x: T): string; <T>(x: number): T; }
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts(28,20): error TS2345: Argument of type '<T>(x: T, y: T) => string' is not assignable to parameter of type '{ (x: any): string; (x: any, y?: any): string; }'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts(28,20): error TS2345: Argument of type '<T>(x: T, y: T) => string' is not assignable to parameter of type '{ (x: {}): string; (x: {}, y?: {}): string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedFunctionTypedArguments2.ts (1 errors) ====
|
||||
@@ -31,7 +31,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOve
|
||||
|
||||
var r10 = foo6(<T>(x: T, y: T) => ''); // error
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '<T>(x: T, y: T) => string' is not assignable to parameter of type '{ (x: any): string; (x: any, y?: any): string; }'.
|
||||
!!! error TS2345: Argument of type '<T>(x: T, y: T) => string' is not assignable to parameter of type '{ (x: {}): string; (x: {}, y?: {}): string; }'.
|
||||
|
||||
function foo7<T>(x:T, cb: { (x: T): string; (x: T, y?: T): string }) {
|
||||
return cb;
|
||||
|
||||
@@ -55,8 +55,8 @@ module GenericParameter {
|
||||
}
|
||||
|
||||
var r6 = foo5(<T>(x: T) => x); // ok
|
||||
>r6 : { (x: any): string; (x: number): any; }
|
||||
>foo5(<T>(x: T) => x) : { (x: any): string; (x: number): any; }
|
||||
>r6 : { (x: {}): string; (x: number): {}; }
|
||||
>foo5(<T>(x: T) => x) : { (x: {}): string; (x: number): {}; }
|
||||
>foo5 : <T>(cb: { (x: T): string; (x: number): T; }) => { (x: T): string; (x: number): T; }
|
||||
><T>(x: T) => x : <T>(x: T) => T
|
||||
>T : T
|
||||
@@ -109,8 +109,8 @@ module GenericParameter {
|
||||
}
|
||||
|
||||
var r13 = foo7(1, <T>(x: T) => x); // ok
|
||||
>r13 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo7(1, <T>(x: T) => x) : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r13 : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7(1, <T>(x: T) => x) : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
><T>(x: T) => x : <T>(x: T) => T
|
||||
@@ -129,8 +129,8 @@ module GenericParameter {
|
||||
>T : T
|
||||
|
||||
var r14 = foo7(1, a); // ok
|
||||
>r14 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo7(1, a) : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r14 : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7(1, a) : { (x: {}): string; (x: {}, y?: {}): string; }
|
||||
>foo7 : <T>(x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
>1 : 1
|
||||
>a : { <T>(x: T): number; <T>(x: number): T; }
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//// [genericFunctionParameters.ts]
|
||||
declare function f1<T>(cb: <S>(x: S) => T): T;
|
||||
declare function f2<T>(cb: <S extends number>(x: S) => T): T;
|
||||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T;
|
||||
|
||||
let x1 = f1(x => x); // {}
|
||||
let x2 = f2(x => x); // number
|
||||
let x3 = f3(x => x); // Array<any>
|
||||
|
||||
// Repro from #19345
|
||||
|
||||
declare const s: <R>(go: <S>(ops: { init(): S; }) => R) => R;
|
||||
const x = s(a => a.init()); // x is any, should have been {}
|
||||
|
||||
|
||||
//// [genericFunctionParameters.js]
|
||||
"use strict";
|
||||
var x1 = f1(function (x) { return x; }); // {}
|
||||
var x2 = f2(function (x) { return x; }); // number
|
||||
var x3 = f3(function (x) { return x; }); // Array<any>
|
||||
var x = s(function (a) { return a.init(); }); // x is any, should have been {}
|
||||
|
||||
|
||||
//// [genericFunctionParameters.d.ts]
|
||||
declare function f1<T>(cb: <S>(x: S) => T): T;
|
||||
declare function f2<T>(cb: <S extends number>(x: S) => T): T;
|
||||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T;
|
||||
declare let x1: {};
|
||||
declare let x2: number;
|
||||
declare let x3: any[];
|
||||
declare const s: <R>(go: <S>(ops: {
|
||||
init(): S;
|
||||
}) => R) => R;
|
||||
declare const x: {};
|
||||
@@ -0,0 +1,72 @@
|
||||
=== tests/cases/conformance/types/typeRelationships/typeInference/genericFunctionParameters.ts ===
|
||||
declare function f1<T>(cb: <S>(x: S) => T): T;
|
||||
>f1 : Symbol(f1, Decl(genericFunctionParameters.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 0, 20))
|
||||
>cb : Symbol(cb, Decl(genericFunctionParameters.ts, 0, 23))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 0, 28))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 0, 31))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 0, 28))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 0, 20))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 0, 20))
|
||||
|
||||
declare function f2<T>(cb: <S extends number>(x: S) => T): T;
|
||||
>f2 : Symbol(f2, Decl(genericFunctionParameters.ts, 0, 46))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 1, 20))
|
||||
>cb : Symbol(cb, Decl(genericFunctionParameters.ts, 1, 23))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 1, 28))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 1, 46))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 1, 28))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 1, 20))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 1, 20))
|
||||
|
||||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T;
|
||||
>f3 : Symbol(f3, Decl(genericFunctionParameters.ts, 1, 61))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 2, 20))
|
||||
>cb : Symbol(cb, Decl(genericFunctionParameters.ts, 2, 23))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 2, 28))
|
||||
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 2, 28))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 2, 48))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 2, 28))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 2, 20))
|
||||
>T : Symbol(T, Decl(genericFunctionParameters.ts, 2, 20))
|
||||
|
||||
let x1 = f1(x => x); // {}
|
||||
>x1 : Symbol(x1, Decl(genericFunctionParameters.ts, 4, 3))
|
||||
>f1 : Symbol(f1, Decl(genericFunctionParameters.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 4, 12))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 4, 12))
|
||||
|
||||
let x2 = f2(x => x); // number
|
||||
>x2 : Symbol(x2, Decl(genericFunctionParameters.ts, 5, 3))
|
||||
>f2 : Symbol(f2, Decl(genericFunctionParameters.ts, 0, 46))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 5, 12))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 5, 12))
|
||||
|
||||
let x3 = f3(x => x); // Array<any>
|
||||
>x3 : Symbol(x3, Decl(genericFunctionParameters.ts, 6, 3))
|
||||
>f3 : Symbol(f3, Decl(genericFunctionParameters.ts, 1, 61))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 6, 12))
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 6, 12))
|
||||
|
||||
// Repro from #19345
|
||||
|
||||
declare const s: <R>(go: <S>(ops: { init(): S; }) => R) => R;
|
||||
>s : Symbol(s, Decl(genericFunctionParameters.ts, 10, 13))
|
||||
>R : Symbol(R, Decl(genericFunctionParameters.ts, 10, 18))
|
||||
>go : Symbol(go, Decl(genericFunctionParameters.ts, 10, 21))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 10, 26))
|
||||
>ops : Symbol(ops, Decl(genericFunctionParameters.ts, 10, 29))
|
||||
>init : Symbol(init, Decl(genericFunctionParameters.ts, 10, 35))
|
||||
>S : Symbol(S, Decl(genericFunctionParameters.ts, 10, 26))
|
||||
>R : Symbol(R, Decl(genericFunctionParameters.ts, 10, 18))
|
||||
>R : Symbol(R, Decl(genericFunctionParameters.ts, 10, 18))
|
||||
|
||||
const x = s(a => a.init()); // x is any, should have been {}
|
||||
>x : Symbol(x, Decl(genericFunctionParameters.ts, 11, 5))
|
||||
>s : Symbol(s, Decl(genericFunctionParameters.ts, 10, 13))
|
||||
>a : Symbol(a, Decl(genericFunctionParameters.ts, 11, 12))
|
||||
>a.init : Symbol(init, Decl(genericFunctionParameters.ts, 10, 35))
|
||||
>a : Symbol(a, Decl(genericFunctionParameters.ts, 11, 12))
|
||||
>init : Symbol(init, Decl(genericFunctionParameters.ts, 10, 35))
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
=== tests/cases/conformance/types/typeRelationships/typeInference/genericFunctionParameters.ts ===
|
||||
declare function f1<T>(cb: <S>(x: S) => T): T;
|
||||
>f1 : <T>(cb: <S>(x: S) => T) => T
|
||||
>T : T
|
||||
>cb : <S>(x: S) => T
|
||||
>S : S
|
||||
>x : S
|
||||
>S : S
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
declare function f2<T>(cb: <S extends number>(x: S) => T): T;
|
||||
>f2 : <T>(cb: <S extends number>(x: S) => T) => T
|
||||
>T : T
|
||||
>cb : <S extends number>(x: S) => T
|
||||
>S : S
|
||||
>x : S
|
||||
>S : S
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T;
|
||||
>f3 : <T>(cb: <S extends S[]>(x: S) => T) => T
|
||||
>T : T
|
||||
>cb : <S extends S[]>(x: S) => T
|
||||
>S : S
|
||||
>Array : T[]
|
||||
>S : S
|
||||
>x : S
|
||||
>S : S
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
let x1 = f1(x => x); // {}
|
||||
>x1 : {}
|
||||
>f1(x => x) : {}
|
||||
>f1 : <T>(cb: <S>(x: S) => T) => T
|
||||
>x => x : <S>(x: S) => S
|
||||
>x : S
|
||||
>x : S
|
||||
|
||||
let x2 = f2(x => x); // number
|
||||
>x2 : number
|
||||
>f2(x => x) : number
|
||||
>f2 : <T>(cb: <S extends number>(x: S) => T) => T
|
||||
>x => x : <S extends number>(x: S) => S
|
||||
>x : S
|
||||
>x : S
|
||||
|
||||
let x3 = f3(x => x); // Array<any>
|
||||
>x3 : any[]
|
||||
>f3(x => x) : any[]
|
||||
>f3 : <T>(cb: <S extends S[]>(x: S) => T) => T
|
||||
>x => x : <S extends S[]>(x: S) => S
|
||||
>x : S
|
||||
>x : S
|
||||
|
||||
// Repro from #19345
|
||||
|
||||
declare const s: <R>(go: <S>(ops: { init(): S; }) => R) => R;
|
||||
>s : <R>(go: <S>(ops: { init(): S; }) => R) => R
|
||||
>R : R
|
||||
>go : <S>(ops: { init(): S; }) => R
|
||||
>S : S
|
||||
>ops : { init(): S; }
|
||||
>init : () => S
|
||||
>S : S
|
||||
>R : R
|
||||
>R : R
|
||||
|
||||
const x = s(a => a.init()); // x is any, should have been {}
|
||||
>x : {}
|
||||
>s(a => a.init()) : {}
|
||||
>s : <R>(go: <S>(ops: { init(): S; }) => R) => R
|
||||
>a => a.init() : <S>(a: { init(): S; }) => S
|
||||
>a : { init(): S; }
|
||||
>a.init() : S
|
||||
>a.init : () => S
|
||||
>a : { init(): S; }
|
||||
>init : () => S
|
||||
|
||||
@@ -1396,8 +1396,8 @@ var r12 = testFunction12(x => x);
|
||||
>x : any
|
||||
|
||||
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>r12a : IPromise<any>
|
||||
>r12.then(testFunction12, testFunction12, testFunction12) : IPromise<any>
|
||||
>r12a : IPromise<{}>
|
||||
>r12.then(testFunction12, testFunction12, testFunction12) : IPromise<{}>
|
||||
>r12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>r12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
@@ -1414,8 +1414,8 @@ var s12 = testFunction12(x => x);
|
||||
>x : any
|
||||
|
||||
var s12a = s12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>s12a : IPromise<any>
|
||||
>s12.then(testFunction12, testFunction12, testFunction12) : IPromise<any>
|
||||
>s12a : IPromise<{}>
|
||||
>s12.then(testFunction12, testFunction12, testFunction12) : IPromise<{}>
|
||||
>s12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
@@ -1424,8 +1424,8 @@ var s12a = s12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>testFunction12 : { <T>(x: T): IPromise<T>; <T>(x: T, y: T): IPromise<T>; }
|
||||
|
||||
var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok
|
||||
>s12b : IPromise<any>
|
||||
>s12.then(testFunction12P, testFunction12P, testFunction12P) : IPromise<any>
|
||||
>s12b : IPromise<{}>
|
||||
>s12.then(testFunction12P, testFunction12P, testFunction12P) : IPromise<{}>
|
||||
>s12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
@@ -1434,8 +1434,8 @@ var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok
|
||||
>testFunction12P : { <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }
|
||||
|
||||
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
|
||||
>s12c : IPromise<any>
|
||||
>s12.then(testFunction12P, testFunction12, testFunction12) : IPromise<any>
|
||||
>s12c : IPromise<{}>
|
||||
>s12.then(testFunction12P, testFunction12, testFunction12) : IPromise<{}>
|
||||
>s12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
|
||||
@@ -1349,8 +1349,8 @@ var r12 = testFunction12(x => x);
|
||||
>x : any
|
||||
|
||||
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>r12a : IPromise<any>
|
||||
>r12.then(testFunction12, testFunction12, testFunction12) : IPromise<any>
|
||||
>r12a : IPromise<{}>
|
||||
>r12.then(testFunction12, testFunction12, testFunction12) : IPromise<{}>
|
||||
>r12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>r12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
@@ -1367,8 +1367,8 @@ var s12 = testFunction12(x => x);
|
||||
>x : any
|
||||
|
||||
var s12a = s12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>s12a : IPromise<any>
|
||||
>s12.then(testFunction12, testFunction12, testFunction12) : IPromise<any>
|
||||
>s12a : IPromise<{}>
|
||||
>s12.then(testFunction12, testFunction12, testFunction12) : IPromise<{}>
|
||||
>s12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
@@ -1377,8 +1377,8 @@ var s12a = s12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>testFunction12 : { <T>(x: T): IPromise<T>; <T>(x: T, y: T): IPromise<T>; }
|
||||
|
||||
var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok
|
||||
>s12b : IPromise<any>
|
||||
>s12.then(testFunction12P, testFunction12P, testFunction12P) : IPromise<any>
|
||||
>s12b : IPromise<{}>
|
||||
>s12.then(testFunction12P, testFunction12P, testFunction12P) : IPromise<{}>
|
||||
>s12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
@@ -1387,8 +1387,8 @@ var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok
|
||||
>testFunction12P : { <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }
|
||||
|
||||
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
|
||||
>s12c : IPromise<any>
|
||||
>s12.then(testFunction12P, testFunction12, testFunction12) : IPromise<any>
|
||||
>s12c : IPromise<{}>
|
||||
>s12.then(testFunction12P, testFunction12, testFunction12) : IPromise<{}>
|
||||
>s12.then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : { <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }
|
||||
|
||||
@@ -66,8 +66,8 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of
|
||||
Types of parameters 'onfulfilled' and 'success' are incompatible.
|
||||
Types of parameters 'value' and 'value' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
|
||||
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
|
||||
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<{}>'.
|
||||
Type 'IPromise<any>' is not assignable to type 'Promise<{}>'.
|
||||
Property 'catch' is missing in type 'IPromise<any>'.
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
|
||||
var s12a = s12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
|
||||
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
|
||||
!!! error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<{}>'.
|
||||
!!! error TS2345: Type 'IPromise<any>' is not assignable to type 'Promise<{}>'.
|
||||
!!! error TS2345: Property 'catch' is missing in type 'IPromise<any>'.
|
||||
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
|
||||
@@ -1349,8 +1349,8 @@ var r12 = testFunction12(x => x);
|
||||
>x : any
|
||||
|
||||
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>r12a : IPromise<IPromise<any>>
|
||||
>r12.then(testFunction12, testFunction12, testFunction12) : IPromise<IPromise<any>>
|
||||
>r12a : IPromise<IPromise<{}>>
|
||||
>r12.then(testFunction12, testFunction12, testFunction12) : IPromise<IPromise<{}>>
|
||||
>r12.then : <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>
|
||||
>r12 : IPromise<(x: any) => any>
|
||||
>then : <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>
|
||||
@@ -1367,8 +1367,8 @@ var s12 = testFunction12(x => x);
|
||||
>x : any
|
||||
|
||||
var s12a = s12.then(testFunction12, testFunction12, testFunction12); // ok
|
||||
>s12a : IPromise<IPromise<any>>
|
||||
>s12.then(testFunction12, testFunction12, testFunction12) : IPromise<IPromise<any>>
|
||||
>s12a : IPromise<IPromise<{}>>
|
||||
>s12.then(testFunction12, testFunction12, testFunction12) : IPromise<IPromise<{}>>
|
||||
>s12.then : <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>
|
||||
@@ -1387,8 +1387,8 @@ var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok
|
||||
>testFunction12P : { <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }
|
||||
|
||||
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok
|
||||
>s12c : IPromise<IPromise<any>>
|
||||
>s12.then(testFunction12P, testFunction12, testFunction12) : IPromise<IPromise<any>>
|
||||
>s12c : IPromise<IPromise<{}>>
|
||||
>s12.then(testFunction12P, testFunction12, testFunction12) : IPromise<IPromise<{}>>
|
||||
>s12.then : <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>
|
||||
>s12 : IPromise<(x: any) => any>
|
||||
>then : <U>(success?: (value: (x: any) => any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
declare function f1<T>(cb: <S>(x: S) => T): T;
|
||||
declare function f2<T>(cb: <S extends number>(x: S) => T): T;
|
||||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T;
|
||||
|
||||
let x1 = f1(x => x); // {}
|
||||
let x2 = f2(x => x); // number
|
||||
let x3 = f3(x => x); // Array<any>
|
||||
|
||||
// Repro from #19345
|
||||
|
||||
declare const s: <R>(go: <S>(ops: { init(): S; }) => R) => R;
|
||||
const x = s(a => a.init()); // x is any, should have been {}
|
||||
@@ -1,11 +1,20 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////import * as abs from "abs";
|
||||
// @moduleResolution: node
|
||||
// @noImplicitAny: true
|
||||
|
||||
// @Filename: /node_modules/abs/index.js
|
||||
////not read
|
||||
|
||||
// @Filename: /a.ts
|
||||
/////**/import * as abs from "abs";
|
||||
|
||||
test.setTypesRegistry({
|
||||
"abs": undefined,
|
||||
});
|
||||
|
||||
goTo.marker();
|
||||
|
||||
verify.codeFixAvailable([{
|
||||
description: "Install '@types/abs'",
|
||||
commands: [{
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////import * as abs from "abs";
|
||||
|
||||
test.setTypesRegistry({
|
||||
"abs": undefined,
|
||||
});
|
||||
|
||||
// We only give the fix for an implicit-any module, not for a missing module.
|
||||
verify.not.codeFixAvailable();
|
||||
Reference in New Issue
Block a user