diff --git a/internal/checker/checker.go b/internal/checker/checker.go index ef8cdad811..cdd73dc455 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -21351,20 +21351,44 @@ func (c *Checker) getDefaultOrUnknownFromTypeParameter(t *Type) *Type { return core.IfElse(result != nil, result, c.unknownType) } -func (c *Checker) getNamedMembers(members ast.SymbolTable) []*ast.Symbol { +func (c *Checker) getNamedMembers(members ast.SymbolTable, container *ast.Symbol) []*ast.Symbol { if len(members) == 0 { return nil } + // For classes and interfaces, we store explicitly declared members ahead of inherited members. This ensures we process + // explicitly declared members first in type relations, which is beneficial because explicitly declared members are more + // likely to contain discriminating differences. See for example https://github.com/microsoft/typescript-go/issues/1968. result := make([]*ast.Symbol, 0, len(members)) + var containedCount int + if container != nil && container.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) != 0 { + for id, symbol := range members { + if c.isNamedMember(symbol, id) && c.isDeclarationContainedBy(symbol, container) { + result = append(result, symbol) + } + } + containedCount = len(result) + } for id, symbol := range members { - if c.isNamedMember(symbol, id) { + if c.isNamedMember(symbol, id) && (container == nil || container.Flags&(ast.SymbolFlagsClass|ast.SymbolFlagsInterface) == 0 || !c.isDeclarationContainedBy(symbol, container)) { result = append(result, symbol) } } - c.sortSymbols(result) + c.sortSymbols(result[:containedCount]) + c.sortSymbols(result[containedCount:]) return result } +func (c *Checker) isDeclarationContainedBy(symbol *ast.Symbol, container *ast.Symbol) bool { + if declaration := symbol.ValueDeclaration; declaration != nil { + for _, d := range container.Declarations { + if declaration.Loc.ContainedBy(d.Loc) { + return true + } + } + } + return false +} + func (c *Checker) isNamedMember(symbol *ast.Symbol, id string) bool { return !isReservedMemberName(id) && c.symbolIsValue(symbol) } @@ -24338,7 +24362,7 @@ func (c *Checker) setStructuredTypeMembers(t *Type, members ast.SymbolTable, cal t.objectFlags |= ObjectFlagsMembersResolved data := t.AsStructuredType() data.members = members - data.properties = c.getNamedMembers(members) + data.properties = c.getNamedMembers(members, t.symbol) if len(callSignatures) != 0 { if len(constructSignatures) != 0 { data.signatures = core.Concatenate(callSignatures, constructSignatures) diff --git a/internal/checker/services.go b/internal/checker/services.go index f4b8aa19df..1ef3b8e3a5 100644 --- a/internal/checker/services.go +++ b/internal/checker/services.go @@ -271,7 +271,7 @@ func (c *Checker) getAugmentedPropertiesOfType(t *Type) []*ast.Symbol { } } } - return c.getNamedMembers(propsByName) + return c.getNamedMembers(propsByName, nil) } func (c *Checker) TryGetMemberInModuleExportsAndProperties(memberName string, moduleSymbol *ast.Symbol) *ast.Symbol { diff --git a/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.symbols b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.symbols new file mode 100644 index 0000000000..9c655b0125 --- /dev/null +++ b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.symbols @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/explicitMembersBeforeInherited.ts] //// + +=== explicitMembersBeforeInherited.ts === +// https://github.com/microsoft/typescript-go/issues/1968 + +type IndentationTree = TopNode | VirtualNode | LineNode | BlankNode; +>IndentationTree : Symbol(IndentationTree, Decl(explicitMembersBeforeInherited.ts, 0, 0)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>TopNode : Symbol(TopNode, Decl(explicitMembersBeforeInherited.ts, 11, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>VirtualNode : Symbol(VirtualNode, Decl(explicitMembersBeforeInherited.ts, 7, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>LineNode : Symbol(LineNode, Decl(explicitMembersBeforeInherited.ts, 15, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) +>BlankNode : Symbol(BlankNode, Decl(explicitMembersBeforeInherited.ts, 19, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 2, 21)) + +type IndentationSubTree = Exclude, TopNode>; +>IndentationSubTree : Symbol(IndentationSubTree, Decl(explicitMembersBeforeInherited.ts, 2, 83)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 3, 24)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>IndentationTree : Symbol(IndentationTree, Decl(explicitMembersBeforeInherited.ts, 0, 0)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 3, 24)) +>TopNode : Symbol(TopNode, Decl(explicitMembersBeforeInherited.ts, 11, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 3, 24)) + +interface NodeBase { +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 5, 19)) + + subs: IndentationSubTree[]; +>subs : Symbol(NodeBase.subs, Decl(explicitMembersBeforeInherited.ts, 5, 23)) +>IndentationSubTree : Symbol(IndentationSubTree, Decl(explicitMembersBeforeInherited.ts, 2, 83)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 5, 19)) +} + +interface VirtualNode extends NodeBase { +>VirtualNode : Symbol(VirtualNode, Decl(explicitMembersBeforeInherited.ts, 7, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 9, 22)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 9, 22)) + + type: 'virtual'; +>type : Symbol(VirtualNode.type, Decl(explicitMembersBeforeInherited.ts, 9, 46)) +} + +interface TopNode extends NodeBase { +>TopNode : Symbol(TopNode, Decl(explicitMembersBeforeInherited.ts, 11, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 13, 18)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 13, 18)) + + type: 'top'; +>type : Symbol(TopNode.type, Decl(explicitMembersBeforeInherited.ts, 13, 42)) +} + +interface LineNode extends NodeBase { +>LineNode : Symbol(LineNode, Decl(explicitMembersBeforeInherited.ts, 15, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 17, 19)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 17, 19)) + + type: 'line'; +>type : Symbol(LineNode.type, Decl(explicitMembersBeforeInherited.ts, 17, 43)) +} + +interface BlankNode extends NodeBase { +>BlankNode : Symbol(BlankNode, Decl(explicitMembersBeforeInherited.ts, 19, 1)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 21, 20)) +>NodeBase : Symbol(NodeBase, Decl(explicitMembersBeforeInherited.ts, 3, 69)) +>L : Symbol(L, Decl(explicitMembersBeforeInherited.ts, 21, 20)) + + type: 'blank'; +>type : Symbol(BlankNode.type, Decl(explicitMembersBeforeInherited.ts, 21, 44)) +} + diff --git a/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.types b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.types new file mode 100644 index 0000000000..10ec1583c3 --- /dev/null +++ b/testdata/baselines/reference/compiler/explicitMembersBeforeInherited.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/explicitMembersBeforeInherited.ts] //// + +=== explicitMembersBeforeInherited.ts === +// https://github.com/microsoft/typescript-go/issues/1968 + +type IndentationTree = TopNode | VirtualNode | LineNode | BlankNode; +>IndentationTree : IndentationTree + +type IndentationSubTree = Exclude, TopNode>; +>IndentationSubTree : IndentationSubTree + +interface NodeBase { + subs: IndentationSubTree[]; +>subs : IndentationSubTree[] +} + +interface VirtualNode extends NodeBase { + type: 'virtual'; +>type : "virtual" +} + +interface TopNode extends NodeBase { + type: 'top'; +>type : "top" +} + +interface LineNode extends NodeBase { + type: 'line'; +>type : "line" +} + +interface BlankNode extends NodeBase { + type: 'blank'; +>type : "blank" +} + diff --git a/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt b/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt index c44c91fa63..c22688b1bd 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt @@ -1,6 +1,6 @@ arrayAssignmentTest1.ts(46,5): error TS2741: Property 'IM1' is missing in type 'undefined[]' but required in type 'I1'. arrayAssignmentTest1.ts(47,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C1': IM1, C1M1 -arrayAssignmentTest1.ts(48,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': IM1, C1M1, C2M1 +arrayAssignmentTest1.ts(48,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': C2M1, IM1, C1M1 arrayAssignmentTest1.ts(49,5): error TS2741: Property 'CM3M1' is missing in type 'undefined[]' but required in type 'C3'. arrayAssignmentTest1.ts(60,1): error TS2322: Type 'C3[]' is not assignable to type 'I1[]'. Property 'IM1' is missing in type 'C3' but required in type 'I1'. @@ -11,9 +11,9 @@ arrayAssignmentTest1.ts(65,1): error TS2322: Type 'C3[]' is not assignable to ty arrayAssignmentTest1.ts(68,1): error TS2322: Type 'C1[]' is not assignable to type 'C2[]'. Property 'C2M1' is missing in type 'C1' but required in type 'C2'. arrayAssignmentTest1.ts(69,1): error TS2322: Type 'I1[]' is not assignable to type 'C2[]'. - Type 'I1' is missing the following properties from type 'C2': C1M1, C2M1 + Type 'I1' is missing the following properties from type 'C2': C2M1, C1M1 arrayAssignmentTest1.ts(70,1): error TS2322: Type 'C3[]' is not assignable to type 'C2[]'. - Type 'C3' is missing the following properties from type 'C2': IM1, C1M1, C2M1 + Type 'C3' is missing the following properties from type 'C2': C2M1, IM1, C1M1 arrayAssignmentTest1.ts(75,1): error TS2322: Type 'C2[]' is not assignable to type 'C3[]'. Property 'CM3M1' is missing in type 'C2' but required in type 'C3'. arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is not assignable to type 'C3[]'. @@ -83,7 +83,7 @@ arrayAssignmentTest1.ts(85,1): error TS2740: Type 'I1' is missing the following !!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C1': IM1, C1M1 var c2_error: C2 = []; // should be an error - is ~~~~~~~~ -!!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': IM1, C1M1, C2M1 +!!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': C2M1, IM1, C1M1 var c3_error: C3 = []; // should be an error - is ~~~~~~~~ !!! error TS2741: Property 'CM3M1' is missing in type 'undefined[]' but required in type 'C3'. @@ -125,11 +125,11 @@ arrayAssignmentTest1.ts(85,1): error TS2740: Type 'I1' is missing the following arr_c2 = arr_i1; // should be an error - subtype relationship - is ~~~~~~ !!! error TS2322: Type 'I1[]' is not assignable to type 'C2[]'. -!!! error TS2322: Type 'I1' is missing the following properties from type 'C2': C1M1, C2M1 +!!! error TS2322: Type 'I1' is missing the following properties from type 'C2': C2M1, C1M1 arr_c2 = arr_c3; // should be an error - is ~~~~~~ !!! error TS2322: Type 'C3[]' is not assignable to type 'C2[]'. -!!! error TS2322: Type 'C3' is missing the following properties from type 'C2': IM1, C1M1, C2M1 +!!! error TS2322: Type 'C3' is missing the following properties from type 'C2': C2M1, IM1, C1M1 // "clean up bug" occurs at this point // if you move these three expressions to another file, they raise an error diff --git a/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt.diff new file mode 100644 index 0000000000..00a9d051eb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/arrayAssignmentTest1.errors.txt.diff @@ -0,0 +1,45 @@ +--- old.arrayAssignmentTest1.errors.txt ++++ new.arrayAssignmentTest1.errors.txt +@@= skipped -0, +0 lines =@@ + arrayAssignmentTest1.ts(46,5): error TS2741: Property 'IM1' is missing in type 'undefined[]' but required in type 'I1'. + arrayAssignmentTest1.ts(47,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C1': IM1, C1M1 +-arrayAssignmentTest1.ts(48,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': IM1, C1M1, C2M1 ++arrayAssignmentTest1.ts(48,5): error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': C2M1, IM1, C1M1 + arrayAssignmentTest1.ts(49,5): error TS2741: Property 'CM3M1' is missing in type 'undefined[]' but required in type 'C3'. + arrayAssignmentTest1.ts(60,1): error TS2322: Type 'C3[]' is not assignable to type 'I1[]'. + Property 'IM1' is missing in type 'C3' but required in type 'I1'. +@@= skipped -10, +10 lines =@@ + arrayAssignmentTest1.ts(68,1): error TS2322: Type 'C1[]' is not assignable to type 'C2[]'. + Property 'C2M1' is missing in type 'C1' but required in type 'C2'. + arrayAssignmentTest1.ts(69,1): error TS2322: Type 'I1[]' is not assignable to type 'C2[]'. +- Type 'I1' is missing the following properties from type 'C2': C1M1, C2M1 ++ Type 'I1' is missing the following properties from type 'C2': C2M1, C1M1 + arrayAssignmentTest1.ts(70,1): error TS2322: Type 'C3[]' is not assignable to type 'C2[]'. +- Type 'C3' is missing the following properties from type 'C2': IM1, C1M1, C2M1 ++ Type 'C3' is missing the following properties from type 'C2': C2M1, IM1, C1M1 + arrayAssignmentTest1.ts(75,1): error TS2322: Type 'C2[]' is not assignable to type 'C3[]'. + Property 'CM3M1' is missing in type 'C2' but required in type 'C3'. + arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is not assignable to type 'C3[]'. +@@= skipped -72, +72 lines =@@ + !!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C1': IM1, C1M1 + var c2_error: C2 = []; // should be an error - is + ~~~~~~~~ +-!!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': IM1, C1M1, C2M1 ++!!! error TS2739: Type 'undefined[]' is missing the following properties from type 'C2': C2M1, IM1, C1M1 + var c3_error: C3 = []; // should be an error - is + ~~~~~~~~ + !!! error TS2741: Property 'CM3M1' is missing in type 'undefined[]' but required in type 'C3'. +@@= skipped -42, +42 lines =@@ + arr_c2 = arr_i1; // should be an error - subtype relationship - is + ~~~~~~ + !!! error TS2322: Type 'I1[]' is not assignable to type 'C2[]'. +-!!! error TS2322: Type 'I1' is missing the following properties from type 'C2': C1M1, C2M1 ++!!! error TS2322: Type 'I1' is missing the following properties from type 'C2': C2M1, C1M1 + arr_c2 = arr_c3; // should be an error - is + ~~~~~~ + !!! error TS2322: Type 'C3[]' is not assignable to type 'C2[]'. +-!!! error TS2322: Type 'C3' is missing the following properties from type 'C2': IM1, C1M1, C2M1 ++!!! error TS2322: Type 'C3' is missing the following properties from type 'C2': C2M1, IM1, C1M1 + + // "clean up bug" occurs at this point + // if you move these three expressions to another file, they raise an error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt index 66e34d66b4..6679063d1a 100644 --- a/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt @@ -1,5 +1,5 @@ chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,64): error TS2741: Property 'z' is missing in type 'B' but required in type 'C'. -chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': y, z +chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': z, y ==== chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (2 errors) ==== @@ -27,5 +27,5 @@ chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS !!! related TS2728 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:15:5: 'z' is declared here. !!! related TS6502 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature. ~~~~~ -!!! error TS2739: Type 'A' is missing the following properties from type 'C': y, z +!!! error TS2739: Type 'A' is missing the following properties from type 'C': z, y !!! related TS6502 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt.diff new file mode 100644 index 0000000000..cf03d78758 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt ++++ new.chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt +@@= skipped -0, +0 lines =@@ + chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,64): error TS2741: Property 'z' is missing in type 'B' but required in type 'C'. +-chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': y, z ++chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': z, y + + + ==== chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (2 errors) ==== +@@= skipped -26, +26 lines =@@ + !!! related TS2728 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:15:5: 'z' is declared here. + !!! related TS6502 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature. + ~~~~~ +-!!! error TS2739: Type 'A' is missing the following properties from type 'C': y, z ++!!! error TS2739: Type 'A' is missing the following properties from type 'C': z, y + !!! related TS6502 chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js index dcd7eb5ad3..d405fb0d4c 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js @@ -90,17 +90,17 @@ export declare class FooItem { export type Constructor = new (...args: any[]) => T; export declare function WithTags>(Base: T): { new (...args: any[]): { + tags(): void; foo(): void; name?: string; - tags(): void; }; getTags(): void; } & T; declare const Test_base: { new (...args: any[]): { + tags(): void; foo(): void; name?: string; - tags(): void; }; getTags(): void; } & typeof FooItem; diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js.diff b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js.diff index 93a883c6db..0b51041b0e 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile.js.diff @@ -25,4 +25,24 @@ + tags(c: any): any; }; }; - export declare class FooItem { \ No newline at end of file + export declare class FooItem { +@@= skipped -10, +10 lines =@@ + export type Constructor = new (...args: any[]) => T; + export declare function WithTags>(Base: T): { + new (...args: any[]): { ++ tags(): void; + foo(): void; + name?: string; +- tags(): void; + }; + getTags(): void; + } & T; + declare const Test_base: { + new (...args: any[]): { ++ tags(): void; + foo(): void; + name?: string; +- tags(): void; + }; + getTags(): void; + } & typeof FooItem; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js index 3dfa5c2c71..8a40cc2ccb 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js @@ -83,19 +83,19 @@ export declare class FooItem { export type Constructor = new (...args: any[]) => T; export declare function WithTags>(Base: T): { new (...args: any[]): { + tags(): void; foo(): void; name?: string; property: string; - tags(): void; }; getTags(): void; } & T; declare const Test_base: { new (...args: any[]): { + tags(): void; foo(): void; name?: string; property: string; - tags(): void; }; getTags(): void; } & typeof FooItem; diff --git a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff index 70ffad67fd..c62bce2f6f 100644 --- a/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/emitClassExpressionInDeclarationFile2.js.diff @@ -65,19 +65,19 @@ +export type Constructor = new (...args: any[]) => T; +export declare function WithTags>(Base: T): { + new (...args: any[]): { ++ tags(): void; + foo(): void; + name?: string; + property: string; -+ tags(): void; + }; + getTags(): void; +} & T; +declare const Test_base: { + new (...args: any[]): { ++ tags(): void; + foo(): void; + name?: string; + property: string; -+ tags(): void; + }; + getTags(): void; +} & typeof FooItem; diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt index f6a19bd078..def250f002 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt @@ -46,7 +46,7 @@ assignmentCompatWithCallSignatures3.ts(80,1): error TS2322: Type '(x: Base[], y: Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type 'Derived2[]'. Type 'Base[]' is not assignable to type 'Derived2[]'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. @@ -208,7 +208,7 @@ assignmentCompatWithCallSignatures3.ts(86,1): error TS2322: Type '(x: { a: strin !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2[]'. !!! error TS2322: Type 'Base[]' is not assignable to type 'Derived2[]'. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar var b13: >(x: Array, y: T) => T; a13 = b13; // ok b13 = a13; // ok diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt.diff index de725b8ce8..02b5d803a4 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithCallSignatures3.errors.txt.diff @@ -9,8 +9,9 @@ Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type 'Derived2[]'. Type 'Base[]' is not assignable to type 'Derived2[]'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz -assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '>(x: Base[], y: T) => T'. ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar +assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. @@ -24,7 +25,9 @@ !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2[]'. !!! error TS2322: Type 'Base[]' is not assignable to type 'Derived2[]'. -@@= skipped -9, +9 lines =@@ +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + var b13: >(x: Array, y: T) => T; a13 = b13; // ok b13 = a13; // ok ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt index e1cf90bbd2..fc64e02f7c 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt @@ -46,7 +46,7 @@ assignmentCompatWithConstructSignatures3.ts(80,1): error TS2322: Type 'new (x: B Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type 'Derived2[]'. Type 'Base[]' is not assignable to type 'Derived2[]'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. @@ -208,7 +208,7 @@ assignmentCompatWithConstructSignatures3.ts(86,1): error TS2322: Type 'new (x: { !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2[]'. !!! error TS2322: Type 'Base[]' is not assignable to type 'Derived2[]'. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar var b13: new >(x: Array, y: T) => T; a13 = b13; // ok b13 = a13; // ok diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt.diff index 1464d1c52a..c2b4ac4c1a 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithConstructSignatures3.errors.txt.diff @@ -9,8 +9,9 @@ Types of parameters 'y' and 'y' are incompatible. Type 'T' is not assignable to type 'Derived2[]'. Type 'Base[]' is not assignable to type 'Derived2[]'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz -assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new >(x: Base[], y: T) => T'. ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar +assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. 'Derived[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Derived[]'. @@ -24,7 +25,9 @@ !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2[]'. !!! error TS2322: Type 'Base[]' is not assignable to type 'Derived2[]'. -@@= skipped -9, +9 lines =@@ +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + var b13: new >(x: Array, y: T) => T; a13 = b13; // ok b13 = a13; // ok ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt index 29afe5af4a..f990fc308d 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt @@ -3,7 +3,7 @@ assignmentCompatWithNumericIndexer.ts(14,1): error TS2322: Type 'A' is not assig Property 'bar' is missing in type 'Base' but required in type 'Derived'. assignmentCompatWithNumericIndexer.ts(18,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. 'number' index signatures are incompatible. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithNumericIndexer.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. 'number' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -19,7 +19,7 @@ assignmentCompatWithNumericIndexer.ts(36,9): error TS2322: Type '{ [x: number]: assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. 'number' index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar ==== assignmentCompatWithNumericIndexer.ts (6 errors) ==== @@ -49,7 +49,7 @@ assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not as ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. !!! error TS2322: 'number' index signatures are incompatible. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar module Generics { class A { @@ -89,7 +89,7 @@ assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not as !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. !!! error TS2322: 'number' index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar var b3: { [x: number]: T; } a = b3; // ok diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt.diff new file mode 100644 index 0000000000..58154d87b2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.assignmentCompatWithNumericIndexer.errors.txt ++++ new.assignmentCompatWithNumericIndexer.errors.txt +@@= skipped -2, +2 lines =@@ + Property 'bar' is missing in type 'Base' but required in type 'Derived'. + assignmentCompatWithNumericIndexer.ts(18,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + 'number' index signatures are incompatible. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + assignmentCompatWithNumericIndexer.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. + 'number' index signatures are incompatible. + Type 'Derived' is not assignable to type 'T'. +@@= skipped -16, +16 lines =@@ + assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + 'number' index signatures are incompatible. + Type 'T' is not assignable to type 'Derived2'. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + + ==== assignmentCompatWithNumericIndexer.ts (6 errors) ==== +@@= skipped -30, +30 lines =@@ + ~~ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + !!! error TS2322: 'number' index signatures are incompatible. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + module Generics { + class A { +@@= skipped -40, +40 lines =@@ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + !!! error TS2322: 'number' index signatures are incompatible. + !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + var b3: { [x: number]: T; } + a = b3; // ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt index c922ace647..0afe61148c 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt @@ -3,7 +3,7 @@ assignmentCompatWithNumericIndexer2.ts(14,1): error TS2322: Type 'A' is not assi Property 'bar' is missing in type 'Base' but required in type 'Derived'. assignmentCompatWithNumericIndexer2.ts(18,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. 'number' index signatures are incompatible. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithNumericIndexer2.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. 'number' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -19,7 +19,7 @@ assignmentCompatWithNumericIndexer2.ts(36,9): error TS2322: Type '{ [x: number]: assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. 'number' index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar ==== assignmentCompatWithNumericIndexer2.ts (6 errors) ==== @@ -49,7 +49,7 @@ assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not a ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. !!! error TS2322: 'number' index signatures are incompatible. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar module Generics { interface A { @@ -89,7 +89,7 @@ assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not a !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. !!! error TS2322: 'number' index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar var b3: { [x: number]: T; } a = b3; // ok diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt.diff new file mode 100644 index 0000000000..c450b6b5d2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithNumericIndexer2.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.assignmentCompatWithNumericIndexer2.errors.txt ++++ new.assignmentCompatWithNumericIndexer2.errors.txt +@@= skipped -2, +2 lines =@@ + Property 'bar' is missing in type 'Base' but required in type 'Derived'. + assignmentCompatWithNumericIndexer2.ts(18,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + 'number' index signatures are incompatible. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + assignmentCompatWithNumericIndexer2.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. + 'number' index signatures are incompatible. + Type 'Derived' is not assignable to type 'T'. +@@= skipped -16, +16 lines =@@ + assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + 'number' index signatures are incompatible. + Type 'T' is not assignable to type 'Derived2'. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + + ==== assignmentCompatWithNumericIndexer2.ts (6 errors) ==== +@@= skipped -30, +30 lines =@@ + ~~ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + !!! error TS2322: 'number' index signatures are incompatible. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + module Generics { + interface A { +@@= skipped -40, +40 lines =@@ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. + !!! error TS2322: 'number' index signatures are incompatible. + !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + var b3: { [x: number]: T; } + a = b3; // ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt index 3244816f12..ea6734d5a8 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt @@ -3,13 +3,13 @@ assignmentCompatWithStringIndexer.ts(15,1): error TS2322: Type 'A' is not assign Property 'bar' is missing in type 'Base' but required in type 'Derived'. assignmentCompatWithStringIndexer.ts(19,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. 'string' index signatures are incompatible. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithStringIndexer.ts(33,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. 'string' index signatures are incompatible. Property 'bar' is missing in type 'Base' but required in type 'Derived'. assignmentCompatWithStringIndexer.ts(41,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. 'string' index signatures are incompatible. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithStringIndexer.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. 'string' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -25,7 +25,7 @@ assignmentCompatWithStringIndexer.ts(50,9): error TS2322: Type '{ [x: string]: D assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. 'string' index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar ==== assignmentCompatWithStringIndexer.ts (8 errors) ==== @@ -56,7 +56,7 @@ assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not ass ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: 'string' index signatures are incompatible. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar module Generics { class A { @@ -87,7 +87,7 @@ assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not ass ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: 'string' index signatures are incompatible. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar function foo() { var b3: { [x: string]: Derived; }; @@ -118,6 +118,6 @@ assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not ass !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: 'string' index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt.diff new file mode 100644 index 0000000000..d5dd56892b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer.errors.txt.diff @@ -0,0 +1,53 @@ +--- old.assignmentCompatWithStringIndexer.errors.txt ++++ new.assignmentCompatWithStringIndexer.errors.txt +@@= skipped -2, +2 lines =@@ + Property 'bar' is missing in type 'Base' but required in type 'Derived'. + assignmentCompatWithStringIndexer.ts(19,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + 'string' index signatures are incompatible. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + assignmentCompatWithStringIndexer.ts(33,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. + 'string' index signatures are incompatible. + Property 'bar' is missing in type 'Base' but required in type 'Derived'. + assignmentCompatWithStringIndexer.ts(41,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + 'string' index signatures are incompatible. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + assignmentCompatWithStringIndexer.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. + 'string' index signatures are incompatible. + Type 'Derived' is not assignable to type 'T'. +@@= skipped -22, +22 lines =@@ + assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + 'string' index signatures are incompatible. + Type 'T' is not assignable to type 'Derived2'. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + + ==== assignmentCompatWithStringIndexer.ts (8 errors) ==== +@@= skipped -31, +31 lines =@@ + ~~ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + !!! error TS2322: 'string' index signatures are incompatible. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + module Generics { + class A { +@@= skipped -31, +31 lines =@@ + ~~ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + !!! error TS2322: 'string' index signatures are incompatible. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + function foo() { + var b3: { [x: string]: Derived; }; +@@= skipped -31, +31 lines =@@ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + !!! error TS2322: 'string' index signatures are incompatible. + !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt index 1d9087e850..c330a9fa38 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt @@ -3,13 +3,13 @@ assignmentCompatWithStringIndexer2.ts(15,1): error TS2322: Type 'A' is not assig Property 'bar' is missing in type 'Base' but required in type 'Derived'. assignmentCompatWithStringIndexer2.ts(19,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. 'string' index signatures are incompatible. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithStringIndexer2.ts(33,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. 'string' index signatures are incompatible. Property 'bar' is missing in type 'Base' but required in type 'Derived'. assignmentCompatWithStringIndexer2.ts(41,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. 'string' index signatures are incompatible. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar assignmentCompatWithStringIndexer2.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. 'string' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -25,7 +25,7 @@ assignmentCompatWithStringIndexer2.ts(50,9): error TS2322: Type '{ [x: string]: assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. 'string' index signatures are incompatible. Type 'T' is not assignable to type 'Derived2'. - Type 'Base' is missing the following properties from type 'Derived2': bar, baz + Type 'Base' is missing the following properties from type 'Derived2': baz, bar ==== assignmentCompatWithStringIndexer2.ts (8 errors) ==== @@ -56,7 +56,7 @@ assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not as ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: 'string' index signatures are incompatible. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar module Generics { interface A { @@ -87,7 +87,7 @@ assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not as ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: 'string' index signatures are incompatible. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar function foo() { var b3: { [x: string]: Derived; }; @@ -118,6 +118,6 @@ assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not as !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. !!! error TS2322: 'string' index signatures are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. -!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz +!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt.diff new file mode 100644 index 0000000000..286b1397ae --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/assignmentCompatWithStringIndexer2.errors.txt.diff @@ -0,0 +1,53 @@ +--- old.assignmentCompatWithStringIndexer2.errors.txt ++++ new.assignmentCompatWithStringIndexer2.errors.txt +@@= skipped -2, +2 lines =@@ + Property 'bar' is missing in type 'Base' but required in type 'Derived'. + assignmentCompatWithStringIndexer2.ts(19,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + 'string' index signatures are incompatible. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + assignmentCompatWithStringIndexer2.ts(33,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. + 'string' index signatures are incompatible. + Property 'bar' is missing in type 'Base' but required in type 'Derived'. + assignmentCompatWithStringIndexer2.ts(41,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + 'string' index signatures are incompatible. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + assignmentCompatWithStringIndexer2.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. + 'string' index signatures are incompatible. + Type 'Derived' is not assignable to type 'T'. +@@= skipped -22, +22 lines =@@ + assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + 'string' index signatures are incompatible. + Type 'T' is not assignable to type 'Derived2'. +- Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++ Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + + ==== assignmentCompatWithStringIndexer2.ts (8 errors) ==== +@@= skipped -31, +31 lines =@@ + ~~ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + !!! error TS2322: 'string' index signatures are incompatible. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + module Generics { + interface A { +@@= skipped -31, +31 lines =@@ + ~~ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + !!! error TS2322: 'string' index signatures are incompatible. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + + function foo() { + var b3: { [x: string]: Derived; }; +@@= skipped -31, +31 lines =@@ + !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. + !!! error TS2322: 'string' index signatures are incompatible. + !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. +-!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': bar, baz ++!!! error TS2322: Type 'Base' is missing the following properties from type 'Derived2': baz, bar + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt index 2e7173670a..e560d45c47 100644 --- a/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt @@ -1,5 +1,5 @@ implementingAnInterfaceExtendingClassWithPrivates.ts(9,7): error TS2420: Class 'Bar' incorrectly implements interface 'I'. - Type 'Bar' is missing the following properties from type 'I': x, y + Type 'Bar' is missing the following properties from type 'I': y, x implementingAnInterfaceExtendingClassWithPrivates.ts(12,7): error TS2420: Class 'Bar2' incorrectly implements interface 'I'. Property 'x' is missing in type 'Bar2' but required in type 'I'. implementingAnInterfaceExtendingClassWithPrivates.ts(16,7): error TS2420: Class 'Bar3' incorrectly implements interface 'I'. @@ -20,7 +20,7 @@ implementingAnInterfaceExtendingClassWithPrivates.ts(21,7): error TS2420: Class class Bar implements I { // error ~~~ !!! error TS2420: Class 'Bar' incorrectly implements interface 'I'. -!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': x, y +!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': y, x } class Bar2 implements I { // error diff --git a/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt.diff new file mode 100644 index 0000000000..1319fb2b29 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithPrivates.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.implementingAnInterfaceExtendingClassWithPrivates.errors.txt ++++ new.implementingAnInterfaceExtendingClassWithPrivates.errors.txt +@@= skipped -0, +0 lines =@@ + implementingAnInterfaceExtendingClassWithPrivates.ts(9,7): error TS2420: Class 'Bar' incorrectly implements interface 'I'. +- Type 'Bar' is missing the following properties from type 'I': x, y ++ Type 'Bar' is missing the following properties from type 'I': y, x + implementingAnInterfaceExtendingClassWithPrivates.ts(12,7): error TS2420: Class 'Bar2' incorrectly implements interface 'I'. + Property 'x' is missing in type 'Bar2' but required in type 'I'. + implementingAnInterfaceExtendingClassWithPrivates.ts(16,7): error TS2420: Class 'Bar3' incorrectly implements interface 'I'. +@@= skipped -19, +19 lines =@@ + class Bar implements I { // error + ~~~ + !!! error TS2420: Class 'Bar' incorrectly implements interface 'I'. +-!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': x, y ++!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': y, x + } + + class Bar2 implements I { // error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt index 94c2056164..b5fbbfe9c2 100644 --- a/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt @@ -1,5 +1,5 @@ implementingAnInterfaceExtendingClassWithProtecteds.ts(9,7): error TS2420: Class 'Bar' incorrectly implements interface 'I'. - Type 'Bar' is missing the following properties from type 'I': x, y + Type 'Bar' is missing the following properties from type 'I': y, x implementingAnInterfaceExtendingClassWithProtecteds.ts(12,7): error TS2420: Class 'Bar2' incorrectly implements interface 'I'. Property 'x' is missing in type 'Bar2' but required in type 'I'. implementingAnInterfaceExtendingClassWithProtecteds.ts(16,7): error TS2420: Class 'Bar3' incorrectly implements interface 'I'. @@ -24,7 +24,7 @@ implementingAnInterfaceExtendingClassWithProtecteds.ts(29,7): error TS2420: Clas class Bar implements I { // error ~~~ !!! error TS2420: Class 'Bar' incorrectly implements interface 'I'. -!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': x, y +!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': y, x } class Bar2 implements I { // error diff --git a/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt.diff new file mode 100644 index 0000000000..19359b0ea1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.implementingAnInterfaceExtendingClassWithProtecteds.errors.txt ++++ new.implementingAnInterfaceExtendingClassWithProtecteds.errors.txt +@@= skipped -0, +0 lines =@@ + implementingAnInterfaceExtendingClassWithProtecteds.ts(9,7): error TS2420: Class 'Bar' incorrectly implements interface 'I'. +- Type 'Bar' is missing the following properties from type 'I': x, y ++ Type 'Bar' is missing the following properties from type 'I': y, x + implementingAnInterfaceExtendingClassWithProtecteds.ts(12,7): error TS2420: Class 'Bar2' incorrectly implements interface 'I'. + Property 'x' is missing in type 'Bar2' but required in type 'I'. + implementingAnInterfaceExtendingClassWithProtecteds.ts(16,7): error TS2420: Class 'Bar3' incorrectly implements interface 'I'. +@@= skipped -23, +23 lines =@@ + class Bar implements I { // error + ~~~ + !!! error TS2420: Class 'Bar' incorrectly implements interface 'I'. +-!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': x, y ++!!! error TS2420: Type 'Bar' is missing the following properties from type 'I': y, x + } + + class Bar2 implements I { // error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt b/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt index 2a1a60034e..8074f33db8 100644 --- a/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt @@ -2,7 +2,7 @@ invalidReturnStatements.ts(2,17): error TS2355: A function whose declared type i invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. -invalidReturnStatements.ts(16,22): error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': dispose, name +invalidReturnStatements.ts(16,22): error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': name, dispose invalidReturnStatements.ts(18,22): error TS2741: Property 'name' is missing in type 'C' but required in type 'D'. @@ -32,7 +32,7 @@ invalidReturnStatements.ts(18,22): error TS2741: Property 'name' is missing in t } function fn10(): D { return { id: 12 }; } ~~~~~~ -!!! error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': dispose, name +!!! error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': name, dispose function fn11(): D { return new C(); } ~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt.diff new file mode 100644 index 0000000000..98ba66663f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/invalidReturnStatements.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.invalidReturnStatements.errors.txt ++++ new.invalidReturnStatements.errors.txt +@@= skipped -1, +1 lines =@@ + invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. + invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. + invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. +-invalidReturnStatements.ts(16,22): error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': dispose, name ++invalidReturnStatements.ts(16,22): error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': name, dispose + invalidReturnStatements.ts(18,22): error TS2741: Property 'name' is missing in type 'C' but required in type 'D'. + + +@@= skipped -30, +30 lines =@@ + } + function fn10(): D { return { id: 12 }; } + ~~~~~~ +-!!! error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': dispose, name ++!!! error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': name, dispose + + function fn11(): D { return new C(); } + ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index be6b9a3a2f..1bde762230 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -2,7 +2,7 @@ b.js(4,20): error TS2352: Conversion of type 'number' to type 'string' may be a b.js(45,23): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. b.js(49,26): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x + Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p b.js(51,24): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. b.js(52,24): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. @@ -75,7 +75,7 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. someDerived = /** @type {SomeDerived} */(someOther); // Error ~~~~~~~~~~~ !!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p someOther = /** @type {SomeOther} */(someDerived); // Error ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt index 353e324db2..1e4a84b919 100644 --- a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt @@ -2,7 +2,7 @@ typeAssertions.ts(5,9): error TS2558: Expected 0 type arguments, but got 1. typeAssertions.ts(31,12): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. typeAssertions.ts(35,15): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x + Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p typeAssertions.ts(37,13): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. typeAssertions.ts(38,13): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. @@ -67,7 +67,7 @@ typeAssertions.ts(48,50): error TS1128: Declaration or statement expected. someDerived = someOther; // Error ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p someOther = someDerived; // Error ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt.diff new file mode 100644 index 0000000000..1a7ccf094b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.typeAssertions.errors.txt ++++ new.typeAssertions.errors.txt +@@= skipped -1, +1 lines =@@ + typeAssertions.ts(31,12): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. + typeAssertions.ts(35,15): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +- Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x ++ Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p + typeAssertions.ts(37,13): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. + typeAssertions.ts(38,13): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +@@= skipped -65, +65 lines =@@ + someDerived = someOther; // Error + ~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +-!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x ++!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p + + someOther = someDerived; // Error + ~~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index a8e9b0d3d7..75ffbcabed 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -1,6 +1,12 @@ --- old.jsdocTypeTagCast.errors.txt +++ new.jsdocTypeTagCast.errors.txt -@@= skipped -6, +6 lines =@@ +@@= skipped -1, +1 lines =@@ + b.js(45,23): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. + b.js(49,26): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +- Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x ++ Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p + b.js(51,24): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. b.js(52,24): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. @@ -11,7 +17,7 @@ b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. b.js(67,2): error TS2322: Type 'string | number' is not assignable to type 'string'. -@@= skipped -14, +10 lines =@@ +@@= skipped -19, +15 lines =@@ ==== a.ts (0 errors) ==== var W: string; @@ -20,7 +26,16 @@ // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); -@@= skipped -76, +76 lines =@@ +@@= skipped -58, +58 lines =@@ + someDerived = /** @type {SomeDerived} */(someOther); // Error + ~~~~~~~~~~~ + !!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +-!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x ++!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': x, p + + someOther = /** @type {SomeOther} */(someDerived); // Error + ~~~~~~~~~ +@@= skipped -18, +18 lines =@@ someFakeClass = someDerived; someBase = someFakeClass; // Error diff --git a/testdata/tests/cases/compiler/explicitMembersBeforeInherited.ts b/testdata/tests/cases/compiler/explicitMembersBeforeInherited.ts new file mode 100644 index 0000000000..99c86ac4d7 --- /dev/null +++ b/testdata/tests/cases/compiler/explicitMembersBeforeInherited.ts @@ -0,0 +1,27 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/typescript-go/issues/1968 + +type IndentationTree = TopNode | VirtualNode | LineNode | BlankNode; +type IndentationSubTree = Exclude, TopNode>; + +interface NodeBase { + subs: IndentationSubTree[]; +} + +interface VirtualNode extends NodeBase { + type: 'virtual'; +} + +interface TopNode extends NodeBase { + type: 'top'; +} + +interface LineNode extends NodeBase { + type: 'line'; +} + +interface BlankNode extends NodeBase { + type: 'blank'; +}