diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2e49c7db455e5..3b4859b2ae16c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11662,7 +11662,7 @@ namespace ts { // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && isPropertyIdenticalTo(singleProp, prop)) { + if (isInstantiation && compareProperties(singleProp, prop, (a, b) => a === b ? Ternary.True : Ternary.False) === Ternary.True) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -15870,8 +15870,9 @@ namespace ts { outerTypeParameters = addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || emptyArray; - typeParameters = (target.objectFlags & ObjectFlags.Reference || target.symbol.flags & SymbolFlags.TypeLiteral) && !target.aliasTypeArguments ? - filter(typeParameters, tp => isTypeParameterPossiblyReferenced(tp, declaration)) : + const allDeclarations = type.objectFlags & ObjectFlags.Reference ? [declaration] : type.symbol.declarations!; + typeParameters = (target.objectFlags & ObjectFlags.Reference || target.symbol.flags & SymbolFlags.Method || target.symbol.flags & SymbolFlags.TypeLiteral) && !target.aliasTypeArguments ? + filter(typeParameters, tp => some(allDeclarations, d => isTypeParameterPossiblyReferenced(tp, d))) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -15918,7 +15919,7 @@ namespace ts { return true; } } - return !!forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node: Node): boolean { @@ -15930,6 +15931,9 @@ namespace ts { getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality case SyntaxKind.TypeQuery: return true; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + return (!(node as FunctionLikeDeclaration).type && !!(node as FunctionLikeDeclaration).body) || !!forEachChild(node, containsReference); } return !!forEachChild(node, containsReference); } diff --git a/tests/baselines/reference/bivariantInferences.symbols b/tests/baselines/reference/bivariantInferences.symbols index f7b25569d8cd3..0697c171c54e8 100644 --- a/tests/baselines/reference/bivariantInferences.symbols +++ b/tests/baselines/reference/bivariantInferences.symbols @@ -24,8 +24,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[]; let x = a.equalsShallow(b); >x : Symbol(x, Decl(bivariantInferences.ts, 9, 3)) ->a.equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20)) +>a.equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20)) >a : Symbol(a, Decl(bivariantInferences.ts, 6, 13)) ->equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20)) +>equalsShallow : Symbol(Array.equalsShallow, Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20), Decl(bivariantInferences.ts, 2, 20)) >b : Symbol(b, Decl(bivariantInferences.ts, 7, 13)) diff --git a/tests/baselines/reference/bivariantInferences.types b/tests/baselines/reference/bivariantInferences.types index 7ad35660c556f..ac987cbddaca4 100644 --- a/tests/baselines/reference/bivariantInferences.types +++ b/tests/baselines/reference/bivariantInferences.types @@ -19,8 +19,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[]; let x = a.equalsShallow(b); >x : boolean >a.equalsShallow(b) : boolean ->a.equalsShallow : (this: readonly T[], other: readonly T[]) => boolean +>a.equalsShallow : ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) >a : (string | number)[] | null[] | undefined[] | {}[] ->equalsShallow : (this: readonly T[], other: readonly T[]) => boolean +>equalsShallow : ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) >b : (string | number)[] | null[] | undefined[] | {}[] diff --git a/tests/baselines/reference/completionEntryForUnionMethod.baseline b/tests/baselines/reference/completionEntryForUnionMethod.baseline index 8a2eb2859eddb..d7cfb032e5b33 100644 --- a/tests/baselines/reference/completionEntryForUnionMethod.baseline +++ b/tests/baselines/reference/completionEntryForUnionMethod.baseline @@ -124,7 +124,7 @@ }, { "text": "toString", - "kind": "methodName" + "kind": "propertyName" }, { "text": "(", @@ -198,7 +198,7 @@ }, { "text": "toLocaleString", - "kind": "methodName" + "kind": "propertyName" }, { "text": "(", @@ -981,7 +981,7 @@ }, { "text": "join", - "kind": "methodName" + "kind": "propertyName" }, { "text": "(", diff --git a/tests/baselines/reference/mixinAccessModifiers.symbols b/tests/baselines/reference/mixinAccessModifiers.symbols index 41cc19129a2fe..e7847dbcfd3bf 100644 --- a/tests/baselines/reference/mixinAccessModifiers.symbols +++ b/tests/baselines/reference/mixinAccessModifiers.symbols @@ -387,13 +387,13 @@ function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}> >b : Symbol(b, Decl(mixinAccessModifiers.ts, 127, 71)) x.privateMethod(); // Error, private constituent makes method inaccessible ->x.privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27)) +>x.privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 107, 27)) >x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12)) ->privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27)) +>privateMethod : Symbol(ProtectedGeneric.privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 107, 27)) x.protectedMethod(); // Error, protected when all constituents are protected ->x.protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27)) +>x.protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 108, 27)) >x : Symbol(x, Decl(mixinAccessModifiers.ts, 127, 12)) ->protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27)) +>protectedMethod : Symbol(ProtectedGeneric.protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 108, 27)) } diff --git a/tests/baselines/reference/mixinAccessModifiers.types b/tests/baselines/reference/mixinAccessModifiers.types index 4ff6c4de289af..9b4cb432ab2e2 100644 --- a/tests/baselines/reference/mixinAccessModifiers.types +++ b/tests/baselines/reference/mixinAccessModifiers.types @@ -373,14 +373,14 @@ function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}> x.privateMethod(); // Error, private constituent makes method inaccessible >x.privateMethod() : void ->x.privateMethod : () => void +>x.privateMethod : (() => void) & (() => void) >x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }> ->privateMethod : () => void +>privateMethod : (() => void) & (() => void) x.protectedMethod(); // Error, protected when all constituents are protected >x.protectedMethod() : void ->x.protectedMethod : () => void +>x.protectedMethod : (() => void) & (() => void) >x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }> ->protectedMethod : () => void +>protectedMethod : (() => void) & (() => void) } diff --git a/tests/baselines/reference/sliceResultCast.symbols b/tests/baselines/reference/sliceResultCast.symbols index 0f8a4761baaa4..5fed27ca3fd5c 100644 --- a/tests/baselines/reference/sliceResultCast.symbols +++ b/tests/baselines/reference/sliceResultCast.symbols @@ -3,7 +3,7 @@ declare var x: [number, string] | [number, string, string]; >x : Symbol(x, Decl(sliceResultCast.ts, 0, 11)) x.slice(1) as readonly string[]; ->x.slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --)) +>x.slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(sliceResultCast.ts, 0, 11)) ->slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --)) +>slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/sliceResultCast.types b/tests/baselines/reference/sliceResultCast.types index 221046e037d96..99f799f27ff38 100644 --- a/tests/baselines/reference/sliceResultCast.types +++ b/tests/baselines/reference/sliceResultCast.types @@ -5,8 +5,8 @@ declare var x: [number, string] | [number, string, string]; x.slice(1) as readonly string[]; >x.slice(1) as readonly string[] : readonly string[] >x.slice(1) : (string | number)[] ->x.slice : (start?: number, end?: number) => (string | number)[] +>x.slice : ((start?: number, end?: number) => (string | number)[]) | ((start?: number, end?: number) => (string | number)[]) >x : [number, string] | [number, string, string] ->slice : (start?: number, end?: number) => (string | number)[] +>slice : ((start?: number, end?: number) => (string | number)[]) | ((start?: number, end?: number) => (string | number)[]) >1 : 1 diff --git a/tests/baselines/reference/stackDepthLimitCastingType.js b/tests/baselines/reference/stackDepthLimitCastingType.js new file mode 100644 index 0000000000000..10a2785919adc --- /dev/null +++ b/tests/baselines/reference/stackDepthLimitCastingType.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/stackDepthLimitCastingType.ts] //// + +//// [index.d.ts] +declare global { + interface JQueryXHR { } + class Model { + initialize(attributes?: T, options?: CombinedModelConstructorOptions): void; + fetch(options?: any): JQueryXHR; + } + interface ModelConstructorOptions { + collection?: Collection; + } + class Collection { + without(...values: TModel[]): TModel[]; + } + type CombinedModelConstructorOptions = Model> = ModelConstructorOptions & E; +} + +export { + Model +}; +export as namespace Backbone; + +//// [index.d.ts] +import * as Backbone from "backbone"; +declare module "backbone" { + interface ModelWithCache extends Model { + fetch(options?: any): JQueryXHR; + } +} +export {}; +export as namespace BackboneFetchCache; + +//// [index.ts] +import * as Backbone from "backbone"; +import * as BackboneFetchCache from "backbone-fetch-cache"; + + +const hoge = new Backbone.Model() as Backbone.ModelWithCache; +hoge.fetch(null as any); + +//// [index.js] +"use strict"; +exports.__esModule = true; +var Backbone = require("backbone"); +var hoge = new Backbone.Model(); +hoge.fetch(null); diff --git a/tests/baselines/reference/stackDepthLimitCastingType.symbols b/tests/baselines/reference/stackDepthLimitCastingType.symbols new file mode 100644 index 0000000000000..dd8f720f0b2d3 --- /dev/null +++ b/tests/baselines/reference/stackDepthLimitCastingType.symbols @@ -0,0 +1,110 @@ +=== tests/cases/compiler/node_modules/backbone/index.d.ts === +declare global { +>global : Symbol(global, Decl(index.d.ts, 0, 0)) + + interface JQueryXHR { } +>JQueryXHR : Symbol(JQueryXHR, Decl(index.d.ts, 0, 16)) + + class Model { +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) +>T : Symbol(T, Decl(index.d.ts, 2, 16)) +>E : Symbol(E, Decl(index.d.ts, 2, 24)) + + initialize(attributes?: T, options?: CombinedModelConstructorOptions): void; +>initialize : Symbol(Model.initialize, Decl(index.d.ts, 2, 34)) +>attributes : Symbol(attributes, Decl(index.d.ts, 3, 19)) +>T : Symbol(T, Decl(index.d.ts, 2, 16)) +>options : Symbol(options, Decl(index.d.ts, 3, 34)) +>CombinedModelConstructorOptions : Symbol(CombinedModelConstructorOptions, Decl(index.d.ts, 11, 5)) +>E : Symbol(E, Decl(index.d.ts, 2, 24)) + + fetch(options?: any): JQueryXHR; +>fetch : Symbol(Model.fetch, Decl(index.d.ts, 3, 93)) +>options : Symbol(options, Decl(index.d.ts, 4, 14)) +>JQueryXHR : Symbol(JQueryXHR, Decl(index.d.ts, 0, 16)) + } + interface ModelConstructorOptions { +>ModelConstructorOptions : Symbol(ModelConstructorOptions, Decl(index.d.ts, 5, 5)) +>TModel : Symbol(TModel, Decl(index.d.ts, 6, 38)) +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) + + collection?: Collection; +>collection : Symbol(ModelConstructorOptions.collection, Decl(index.d.ts, 6, 69)) +>Collection : Symbol(Collection, Decl(index.d.ts, 8, 5)) +>TModel : Symbol(TModel, Decl(index.d.ts, 6, 38)) + } + class Collection { +>Collection : Symbol(Collection, Decl(index.d.ts, 8, 5)) +>TModel : Symbol(TModel, Decl(index.d.ts, 9, 21)) +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) + + without(...values: TModel[]): TModel[]; +>without : Symbol(Collection.without, Decl(index.d.ts, 9, 52)) +>values : Symbol(values, Decl(index.d.ts, 10, 16)) +>TModel : Symbol(TModel, Decl(index.d.ts, 9, 21)) +>TModel : Symbol(TModel, Decl(index.d.ts, 9, 21)) + } + type CombinedModelConstructorOptions = Model> = ModelConstructorOptions & E; +>CombinedModelConstructorOptions : Symbol(CombinedModelConstructorOptions, Decl(index.d.ts, 11, 5)) +>E : Symbol(E, Decl(index.d.ts, 12, 41)) +>M : Symbol(M, Decl(index.d.ts, 12, 43)) +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) +>E : Symbol(E, Decl(index.d.ts, 12, 41)) +>Model : Symbol(Model, Decl(index.d.ts, 1, 27)) +>ModelConstructorOptions : Symbol(ModelConstructorOptions, Decl(index.d.ts, 5, 5)) +>M : Symbol(M, Decl(index.d.ts, 12, 43)) +>E : Symbol(E, Decl(index.d.ts, 12, 41)) +} + +export { + Model +>Model : Symbol(Model, Decl(index.d.ts, 15, 8)) + +}; +export as namespace Backbone; +>Backbone : Symbol(Backbone, Decl(index.d.ts, 17, 2)) + +=== tests/cases/compiler/node_modules/backbone-fetch-cache/index.d.ts === +import * as Backbone from "backbone"; +>Backbone : Symbol(Backbone, Decl(index.d.ts, 0, 6)) + +declare module "backbone" { +>"backbone" : Symbol(Backbone, Decl(index.d.ts, 0, 0), Decl(index.d.ts, 0, 37)) + + interface ModelWithCache extends Model { +>ModelWithCache : Symbol(ModelWithCache, Decl(index.d.ts, 1, 27)) +>Model : Symbol(Backbone.Model, Decl(index.d.ts, 1, 27)) + + fetch(options?: any): JQueryXHR; +>fetch : Symbol(ModelWithCache.fetch, Decl(index.d.ts, 2, 44)) +>options : Symbol(options, Decl(index.d.ts, 3, 14)) +>JQueryXHR : Symbol(JQueryXHR, Decl(index.d.ts, 0, 16)) + } +} +export {}; +export as namespace BackboneFetchCache; +>BackboneFetchCache : Symbol(BackboneFetchCache, Decl(index.d.ts, 6, 10)) + +=== tests/cases/compiler/index.ts === +import * as Backbone from "backbone"; +>Backbone : Symbol(Backbone, Decl(index.ts, 0, 6)) + +import * as BackboneFetchCache from "backbone-fetch-cache"; +>BackboneFetchCache : Symbol(BackboneFetchCache, Decl(index.ts, 1, 6)) + + +const hoge = new Backbone.Model() as Backbone.ModelWithCache; +>hoge : Symbol(hoge, Decl(index.ts, 4, 5)) +>Backbone.Model : Symbol(Backbone.Model, Decl(index.d.ts, 15, 8)) +>Backbone : Symbol(Backbone, Decl(index.ts, 0, 6)) +>Model : Symbol(Backbone.Model, Decl(index.d.ts, 15, 8)) +>Backbone : Symbol(Backbone, Decl(index.ts, 0, 6)) +>ModelWithCache : Symbol(Backbone.ModelWithCache, Decl(index.d.ts, 1, 27)) + +hoge.fetch(null as any); +>hoge.fetch : Symbol(Backbone.ModelWithCache.fetch, Decl(index.d.ts, 2, 44)) +>hoge : Symbol(hoge, Decl(index.ts, 4, 5)) +>fetch : Symbol(Backbone.ModelWithCache.fetch, Decl(index.d.ts, 2, 44)) + diff --git a/tests/baselines/reference/stackDepthLimitCastingType.types b/tests/baselines/reference/stackDepthLimitCastingType.types new file mode 100644 index 0000000000000..27d09998e3010 --- /dev/null +++ b/tests/baselines/reference/stackDepthLimitCastingType.types @@ -0,0 +1,82 @@ +=== tests/cases/compiler/node_modules/backbone/index.d.ts === +declare global { +>global : typeof global + + interface JQueryXHR { } + class Model { +>Model : Model + + initialize(attributes?: T, options?: CombinedModelConstructorOptions): void; +>initialize : (attributes?: T | undefined, options?: CombinedModelConstructorOptions | undefined) => void +>attributes : T | undefined +>options : CombinedModelConstructorOptions | undefined + + fetch(options?: any): JQueryXHR; +>fetch : (options?: any) => JQueryXHR +>options : any + } + interface ModelConstructorOptions { + collection?: Collection; +>collection : Collection | undefined + } + class Collection { +>Collection : Collection + + without(...values: TModel[]): TModel[]; +>without : (...values: TModel[]) => TModel[] +>values : TModel[] + } + type CombinedModelConstructorOptions = Model> = ModelConstructorOptions & E; +>CombinedModelConstructorOptions : CombinedModelConstructorOptions +} + +export { + Model +>Model : typeof Model + +}; +export as namespace Backbone; +>Backbone : typeof import("tests/cases/compiler/node_modules/backbone/index") + +=== tests/cases/compiler/node_modules/backbone-fetch-cache/index.d.ts === +import * as Backbone from "backbone"; +>Backbone : typeof Backbone + +declare module "backbone" { +>"backbone" : typeof Backbone + + interface ModelWithCache extends Model { + fetch(options?: any): JQueryXHR; +>fetch : (options?: any) => JQueryXHR +>options : any + } +} +export {}; +export as namespace BackboneFetchCache; +>BackboneFetchCache : typeof import("tests/cases/compiler/node_modules/backbone-fetch-cache/index") + +=== tests/cases/compiler/index.ts === +import * as Backbone from "backbone"; +>Backbone : typeof Backbone + +import * as BackboneFetchCache from "backbone-fetch-cache"; +>BackboneFetchCache : typeof BackboneFetchCache + + +const hoge = new Backbone.Model() as Backbone.ModelWithCache; +>hoge : Backbone.ModelWithCache +>new Backbone.Model() as Backbone.ModelWithCache : Backbone.ModelWithCache +>new Backbone.Model() : Backbone.Model> +>Backbone.Model : typeof Backbone.Model +>Backbone : typeof Backbone +>Model : typeof Backbone.Model +>Backbone : any + +hoge.fetch(null as any); +>hoge.fetch(null as any) : JQueryXHR +>hoge.fetch : (options?: any) => JQueryXHR +>hoge : Backbone.ModelWithCache +>fetch : (options?: any) => JQueryXHR +>null as any : any +>null : null + diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.symbols b/tests/baselines/reference/typeParameterExtendingUnion1.symbols index c7dd566f7f515..cb36861febafa 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion1.symbols @@ -33,9 +33,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11)) a.run(); ->a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32)) ->run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.types b/tests/baselines/reference/typeParameterExtendingUnion1.types index feda22d1a9d09..5cc8d010b78b9 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.types +++ b/tests/baselines/reference/typeParameterExtendingUnion1.types @@ -30,9 +30,9 @@ function f(a: T) { a.run(); >a.run() : void ->a.run : () => void +>a.run : (() => void) | (() => void) >a : Cat | Dog ->run : () => void +>run : (() => void) | (() => void) run(a); >run(a) : void diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.symbols b/tests/baselines/reference/typeParameterExtendingUnion2.symbols index 2728cf6257021..b9c2eed403414 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion2.symbols @@ -20,9 +20,9 @@ function run(a: Cat | Dog) { >Dog : Symbol(Dog, Decl(typeParameterExtendingUnion2.ts, 1, 33)) a.run(); ->a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 4, 13)) ->run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) } function f(a: T) { @@ -34,9 +34,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion2.ts, 8, 11)) a.run(); ->a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 8, 32)) ->run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.types b/tests/baselines/reference/typeParameterExtendingUnion2.types index 2539d4ec3bdc6..475e418f4103a 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.types +++ b/tests/baselines/reference/typeParameterExtendingUnion2.types @@ -19,9 +19,9 @@ function run(a: Cat | Dog) { a.run(); >a.run() : void ->a.run : () => void +>a.run : (() => void) | (() => void) >a : Cat | Dog ->run : () => void +>run : (() => void) | (() => void) } function f(a: T) { @@ -30,9 +30,9 @@ function f(a: T) { a.run(); >a.run() : void ->a.run : () => void +>a.run : (() => void) | (() => void) >a : Cat | Dog ->run : () => void +>run : (() => void) | (() => void) run(a); >run(a) : void diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt index 6f3a7581e64bf..2b96990092f3d 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt @@ -16,14 +16,14 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( Type 'Promise>' is not assignable to type 'Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Call signature return types 'AsyncGenerator' and 'AsyncIterable' are incompatible. - The types returned by '[Symbol.asyncIterator]().next(...)' are incompatible between these types. - Type 'Promise>' is not assignable to type 'Promise>'. + The types of '[Symbol.asyncIterator]().next' are incompatible between these types. + Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(25,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Call signature return types 'AsyncGenerator' and 'AsyncIterable' are incompatible. - The types returned by '[Symbol.asyncIterator]().next(...)' are incompatible between these types. - Type 'Promise>' is not assignable to type 'Promise>'. + The types of '[Symbol.asyncIterator]().next' are incompatible between these types. + Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(31,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. @@ -93,8 +93,8 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. !!! error TS2322: Call signature return types 'AsyncGenerator' and 'AsyncIterable' are incompatible. -!!! error TS2322: The types returned by '[Symbol.asyncIterator]().next(...)' are incompatible between these types. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. +!!! error TS2322: The types of '[Symbol.asyncIterator]().next' are incompatible between these types. +!!! error TS2322: Type '(...args: [] | [undefined]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. yield "a"; }; const assignability5: () => AsyncIterable = async function * () { @@ -107,8 +107,8 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. !!! error TS2322: Call signature return types 'AsyncGenerator' and 'AsyncIterable' are incompatible. -!!! error TS2322: The types returned by '[Symbol.asyncIterator]().next(...)' are incompatible between these types. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. +!!! error TS2322: The types of '[Symbol.asyncIterator]().next' are incompatible between these types. +!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [undefined]) => Promise>'. yield* (async function * () { yield "a"; })(); }; const assignability7: () => AsyncIterator = async function * () { diff --git a/tests/cases/compiler/stackDepthLimitCastingType.ts b/tests/cases/compiler/stackDepthLimitCastingType.ts new file mode 100644 index 0000000000000..bd5ab7a432e1d --- /dev/null +++ b/tests/cases/compiler/stackDepthLimitCastingType.ts @@ -0,0 +1,40 @@ +// @strict: true +// @skipLibCheck: true +// @filename: node_modules/backbone/index.d.ts +declare global { + interface JQueryXHR { } + class Model { + initialize(attributes?: T, options?: CombinedModelConstructorOptions): void; + fetch(options?: any): JQueryXHR; + } + interface ModelConstructorOptions { + collection?: Collection; + } + class Collection { + without(...values: TModel[]): TModel[]; + } + type CombinedModelConstructorOptions = Model> = ModelConstructorOptions & E; +} + +export { + Model +}; +export as namespace Backbone; + +// @filename: node_modules/backbone-fetch-cache/index.d.ts +import * as Backbone from "backbone"; +declare module "backbone" { + interface ModelWithCache extends Model { + fetch(options?: any): JQueryXHR; + } +} +export {}; +export as namespace BackboneFetchCache; + +// @filename: index.ts +import * as Backbone from "backbone"; +import * as BackboneFetchCache from "backbone-fetch-cache"; + + +const hoge = new Backbone.Model() as Backbone.ModelWithCache; +hoge.fetch(null as any); \ No newline at end of file