Merged Declarations for Classes and Interfaces#3333
Merged Declarations for Classes and Interfaces#3333aozgaa merged 37 commits intomicrosoft:masterfrom aozgaa:mergedDeclarationClassInterface
Conversation
This reverts commit 813d227.
|
Hi @aozgaa, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
src/compiler/binder.ts
Outdated
There was a problem hiding this comment.
This isn't exported, so you don't need this.
src/compiler/binder.ts
Outdated
There was a problem hiding this comment.
Nit: Can you put single quotes around node just so this reads easier? Thanks!
src/compiler/types.ts
Outdated
There was a problem hiding this comment.
If you do the other change I suggested (https://github.com/Microsoft/TypeScript/pull/3333/files#r31552915), then this goes away, and ClassExcludes becomes (Value | Type) & ~(ValueModule | Interface)
There was a problem hiding this comment.
why not just letting classes and interfaces merge, and reporting an error later on in CheckClassDeclaration for instance if the class is not ambient? just like we do with merging order for module/class and module/class being in different files.
src/compiler/binder.ts
Outdated
There was a problem hiding this comment.
should not this be inAmbientContext instead?
|
👍 |
|
Thoughs @mhegazy, @ahejlsberg ? |
src/compiler/binder.ts
Outdated
There was a problem hiding this comment.
Remove the leading space if you get the chance.
|
There are apparently some issues with the build - you probably need to fix up baselines that don't agree with the merge. |
|
@DanielRosenwasser The error codes needed to be changed as part of merging the upstream fixes and this broke some of the baselines. No other errors occurred. They've been added now :). |
|
👍 |
1 similar comment
|
👍 |
Merged Declarations for Classes and Interfaces
|
This should be added to the |
|
How does this work with imported module? When I have like this application.ts import * as amqp from 'amqplib';
// I want to merge declaration with `interface amqp.ExchangeOptions`
interface ExchangeOptions {
'x-recent-history-length' : number;
}
interface amqp.ExchangeOptions {
'x-recent-history-length' : number;
}Which one should work? |
|
Neither one of those would work here. You'd need to do the following: declare module 'amqplib' {
interface ExchangeOptions {
'x-recent-history-length' : number;
}
} |
|
Thanks! |
|
@JsonFreeman Is there an equivalent for external modules? |
|
This doesn't appear to be possible but feels like it should: interface Foo {
readonly name: string
}
class Foo {
constructor(name: string) {
this.name = name; //error
}
} |
|
@nbransby thanks, I'll open an issue for you. |
This implements the proposal in #3332.