-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use faster, stricter prop type comparison when merging props in union prop creation #43696
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
586bb7b
Use faster, stricter prop type comparison when merging props in union…
weswigham 488ed1f
Be better at determining this usage in methods, accept baselines
weswigham 2fa57aa
Merge branch 'master' into fix-backbone-stackout
weswigham 252b34b
Small style change
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//// [tests/cases/compiler/stackDepthLimitCastingType.ts] //// | ||
|
||
//// [index.d.ts] | ||
declare global { | ||
interface JQueryXHR { } | ||
class Model<T = any, E = {}> { | ||
initialize(attributes?: T, options?: CombinedModelConstructorOptions<E, this>): void; | ||
fetch(options?: any): JQueryXHR; | ||
} | ||
interface ModelConstructorOptions<TModel extends Model = Model> { | ||
collection?: Collection<TModel>; | ||
} | ||
class Collection<TModel extends Model = Model> { | ||
without(...values: TModel[]): TModel[]; | ||
} | ||
type CombinedModelConstructorOptions<E, M extends Model<any, E> = Model> = ModelConstructorOptions<M> & 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); |
110 changes: 110 additions & 0 deletions
110
tests/baselines/reference/stackDepthLimitCastingType.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T = any, E = {}> { | ||
>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<E, this>): 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<TModel extends Model = Model> { | ||
>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<TModel>; | ||
>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<TModel extends Model = Model> { | ||
>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<E, M extends Model<any, E> = Model> = ModelConstructorOptions<M> & 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)) | ||
|
82 changes: 82 additions & 0 deletions
82
tests/baselines/reference/stackDepthLimitCastingType.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
=== tests/cases/compiler/node_modules/backbone/index.d.ts === | ||
declare global { | ||
>global : typeof global | ||
|
||
interface JQueryXHR { } | ||
class Model<T = any, E = {}> { | ||
>Model : Model<T, E> | ||
|
||
initialize(attributes?: T, options?: CombinedModelConstructorOptions<E, this>): void; | ||
>initialize : (attributes?: T | undefined, options?: CombinedModelConstructorOptions<E, this> | undefined) => void | ||
>attributes : T | undefined | ||
>options : CombinedModelConstructorOptions<E, this> | undefined | ||
|
||
fetch(options?: any): JQueryXHR; | ||
>fetch : (options?: any) => JQueryXHR | ||
>options : any | ||
} | ||
interface ModelConstructorOptions<TModel extends Model = Model> { | ||
collection?: Collection<TModel>; | ||
>collection : Collection<TModel> | undefined | ||
} | ||
class Collection<TModel extends Model = Model> { | ||
>Collection : Collection<TModel> | ||
|
||
without(...values: TModel[]): TModel[]; | ||
>without : (...values: TModel[]) => TModel[] | ||
>values : TModel[] | ||
} | ||
type CombinedModelConstructorOptions<E, M extends Model<any, E> = Model> = ModelConstructorOptions<M> & E; | ||
>CombinedModelConstructorOptions : CombinedModelConstructorOptions<E, M> | ||
} | ||
|
||
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<any, ModelConstructorOptions<Backbone.ModelWithCache>> | ||
>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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why skip object references here? are references really the only object types that won't work?
I'd suggest instead declaring
const allDeclarations = type.objectFlags & ObjectFlags.Reference ? [(<TypeReference>type).node!] : type.symbol.declarations!
just belowdeclarations
, then:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
Reference
s use their.node
to track their content, not their declarations. Because reasons.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd still prefer
const allDeclarations = type.objectFlags & ObjectFlags.Reference ? [] : type.symbol.declarations!
then