diff --git a/tests/baselines/reference/errorsWithCallablesInUnions01.errors.txt b/tests/baselines/reference/errorsWithCallablesInUnions01.errors.txt deleted file mode 100644 index 4881c4f7ff..0000000000 --- a/tests/baselines/reference/errorsWithCallablesInUnions01.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -tests/cases/compiler/errorsWithCallablesInUnions01.ts(10,12): error TS2322: Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn | IDirectivePrePost'. - Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn'. - Types of parameters 'x' and 'scope' are incompatible. - Type 'number' is not assignable to type 'string'. - - -==== tests/cases/compiler/errorsWithCallablesInUnions01.ts (1 errors) ==== - interface IDirectiveLinkFn { - (scope: TScope): void; - } - - interface IDirectivePrePost { - pre?: IDirectiveLinkFn; - post?: IDirectiveLinkFn; - } - - export let blah: IDirectiveLinkFn | IDirectivePrePost = (x: string) => {} - ~~~~ -!!! error TS2322: Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn | IDirectivePrePost'. -!!! error TS2322: Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn'. -!!! error TS2322: Types of parameters 'x' and 'scope' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - \ No newline at end of file diff --git a/tests/baselines/reference/errorsWithCallablesInUnions01.js b/tests/baselines/reference/errorsWithCallablesInUnions01.js deleted file mode 100644 index f9ea8041b1..0000000000 --- a/tests/baselines/reference/errorsWithCallablesInUnions01.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [errorsWithCallablesInUnions01.ts] -interface IDirectiveLinkFn { - (scope: TScope): void; -} - -interface IDirectivePrePost { - pre?: IDirectiveLinkFn; - post?: IDirectiveLinkFn; -} - -export let blah: IDirectiveLinkFn | IDirectivePrePost = (x: string) => {} - - -//// [errorsWithCallablesInUnions01.js] -"use strict"; -exports.__esModule = true; -exports.blah = function (x) { }; diff --git a/tests/baselines/reference/errorsWithCallablesInUnions01.symbols b/tests/baselines/reference/errorsWithCallablesInUnions01.symbols deleted file mode 100644 index 40b48dc245..0000000000 --- a/tests/baselines/reference/errorsWithCallablesInUnions01.symbols +++ /dev/null @@ -1,31 +0,0 @@ -=== tests/cases/compiler/errorsWithCallablesInUnions01.ts === -interface IDirectiveLinkFn { ->IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithCallablesInUnions01.ts, 0, 0)) ->TScope : Symbol(TScope, Decl(errorsWithCallablesInUnions01.ts, 0, 27)) - - (scope: TScope): void; ->scope : Symbol(scope, Decl(errorsWithCallablesInUnions01.ts, 1, 5)) ->TScope : Symbol(TScope, Decl(errorsWithCallablesInUnions01.ts, 0, 27)) -} - -interface IDirectivePrePost { ->IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithCallablesInUnions01.ts, 2, 1)) ->TScope : Symbol(TScope, Decl(errorsWithCallablesInUnions01.ts, 4, 28)) - - pre?: IDirectiveLinkFn; ->pre : Symbol(IDirectivePrePost.pre, Decl(errorsWithCallablesInUnions01.ts, 4, 37)) ->IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithCallablesInUnions01.ts, 0, 0)) ->TScope : Symbol(TScope, Decl(errorsWithCallablesInUnions01.ts, 4, 28)) - - post?: IDirectiveLinkFn; ->post : Symbol(IDirectivePrePost.post, Decl(errorsWithCallablesInUnions01.ts, 5, 35)) ->IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithCallablesInUnions01.ts, 0, 0)) ->TScope : Symbol(TScope, Decl(errorsWithCallablesInUnions01.ts, 4, 28)) -} - -export let blah: IDirectiveLinkFn | IDirectivePrePost = (x: string) => {} ->blah : Symbol(blah, Decl(errorsWithCallablesInUnions01.ts, 9, 10)) ->IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithCallablesInUnions01.ts, 0, 0)) ->IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithCallablesInUnions01.ts, 2, 1)) ->x : Symbol(x, Decl(errorsWithCallablesInUnions01.ts, 9, 73)) - diff --git a/tests/baselines/reference/errorsWithCallablesInUnions01.types b/tests/baselines/reference/errorsWithCallablesInUnions01.types deleted file mode 100644 index 492d870b6e..0000000000 --- a/tests/baselines/reference/errorsWithCallablesInUnions01.types +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/compiler/errorsWithCallablesInUnions01.ts === -interface IDirectiveLinkFn { - (scope: TScope): void; ->scope : TScope -} - -interface IDirectivePrePost { - pre?: IDirectiveLinkFn; ->pre : IDirectiveLinkFn - - post?: IDirectiveLinkFn; ->post : IDirectiveLinkFn -} - -export let blah: IDirectiveLinkFn | IDirectivePrePost = (x: string) => {} ->blah : IDirectiveLinkFn | IDirectivePrePost ->(x: string) => {} : (x: string) => void ->x : string - diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.errors.txt b/tests/baselines/reference/errorsWithInvokablesInUnions01.errors.txt new file mode 100644 index 0000000000..b70d3d744e --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/errorsWithInvokablesInUnions01.ts(14,12): error TS2322: Type '(x: string) => void' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. + Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn'. + Types of parameters 'x' and 'scope' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/errorsWithInvokablesInUnions01.ts(16,12): error TS2322: Type 'typeof ctor' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. + Type 'typeof ctor' is not assignable to type 'ConstructableA'. + Type 'ctor' is not assignable to type '{ somePropA: any; }'. + Property 'somePropA' is missing in type 'ctor'. + + +==== tests/cases/compiler/errorsWithInvokablesInUnions01.ts (2 errors) ==== + interface ConstructableA { + new(): { somePropA: any }; + } + + interface IDirectiveLinkFn { + (scope: TScope): void; + } + + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} + ~~~~ +!!! error TS2322: Type '(x: string) => void' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. +!!! error TS2322: Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn'. +!!! error TS2322: Types of parameters 'x' and 'scope' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { + ~~~~ +!!! error TS2322: Type 'typeof ctor' is not assignable to type 'ConstructableA | IDirectiveLinkFn | IDirectivePrePost'. +!!! error TS2322: Type 'typeof ctor' is not assignable to type 'ConstructableA'. +!!! error TS2322: Type 'ctor' is not assignable to type '{ somePropA: any; }'. +!!! error TS2322: Property 'somePropA' is missing in type 'ctor'. + someUnaccountedProp: any; + } + \ No newline at end of file diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.js b/tests/baselines/reference/errorsWithInvokablesInUnions01.js new file mode 100644 index 0000000000..47c2df0fc2 --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.js @@ -0,0 +1,30 @@ +//// [errorsWithInvokablesInUnions01.ts] +interface ConstructableA { + new(): { somePropA: any }; +} + +interface IDirectiveLinkFn { + (scope: TScope): void; +} + +interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { + someUnaccountedProp: any; +} + + +//// [errorsWithInvokablesInUnions01.js] +"use strict"; +exports.__esModule = true; +exports.blah = function (x) { }; +exports.ctor = /** @class */ (function () { + function class_1() { + } + return class_1; +}()); diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.symbols b/tests/baselines/reference/errorsWithInvokablesInUnions01.symbols new file mode 100644 index 0000000000..a82cecb766 --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.symbols @@ -0,0 +1,49 @@ +=== tests/cases/compiler/errorsWithInvokablesInUnions01.ts === +interface ConstructableA { +>ConstructableA : Symbol(ConstructableA, Decl(errorsWithInvokablesInUnions01.ts, 0, 0)) + + new(): { somePropA: any }; +>somePropA : Symbol(somePropA, Decl(errorsWithInvokablesInUnions01.ts, 1, 10)) +} + +interface IDirectiveLinkFn { +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 4, 27)) + + (scope: TScope): void; +>scope : Symbol(scope, Decl(errorsWithInvokablesInUnions01.ts, 5, 5)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 4, 27)) +} + +interface IDirectivePrePost { +>IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithInvokablesInUnions01.ts, 6, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 8, 28)) + + pre?: IDirectiveLinkFn; +>pre : Symbol(IDirectivePrePost.pre, Decl(errorsWithInvokablesInUnions01.ts, 8, 37)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 8, 28)) + + post?: IDirectiveLinkFn; +>post : Symbol(IDirectivePrePost.post, Decl(errorsWithInvokablesInUnions01.ts, 9, 35)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>TScope : Symbol(TScope, Decl(errorsWithInvokablesInUnions01.ts, 8, 28)) +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} +>blah : Symbol(blah, Decl(errorsWithInvokablesInUnions01.ts, 13, 10)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>ConstructableA : Symbol(ConstructableA, Decl(errorsWithInvokablesInUnions01.ts, 0, 0)) +>IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithInvokablesInUnions01.ts, 6, 1)) +>x : Symbol(x, Decl(errorsWithInvokablesInUnions01.ts, 13, 90)) + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { +>ctor : Symbol(ctor, Decl(errorsWithInvokablesInUnions01.ts, 15, 10)) +>IDirectiveLinkFn : Symbol(IDirectiveLinkFn, Decl(errorsWithInvokablesInUnions01.ts, 2, 1)) +>ConstructableA : Symbol(ConstructableA, Decl(errorsWithInvokablesInUnions01.ts, 0, 0)) +>IDirectivePrePost : Symbol(IDirectivePrePost, Decl(errorsWithInvokablesInUnions01.ts, 6, 1)) + + someUnaccountedProp: any; +>someUnaccountedProp : Symbol(ctor.someUnaccountedProp, Decl(errorsWithInvokablesInUnions01.ts, 15, 96)) +} + diff --git a/tests/baselines/reference/errorsWithInvokablesInUnions01.types b/tests/baselines/reference/errorsWithInvokablesInUnions01.types new file mode 100644 index 0000000000..3497a71cad --- /dev/null +++ b/tests/baselines/reference/errorsWithInvokablesInUnions01.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/errorsWithInvokablesInUnions01.ts === +interface ConstructableA { + new(): { somePropA: any }; +>somePropA : any +} + +interface IDirectiveLinkFn { + (scope: TScope): void; +>scope : TScope +} + +interface IDirectivePrePost { + pre?: IDirectiveLinkFn; +>pre : IDirectiveLinkFn + + post?: IDirectiveLinkFn; +>post : IDirectiveLinkFn +} + +export let blah: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = (x: string) => {} +>blah : ConstructableA | IDirectiveLinkFn | IDirectivePrePost +>(x: string) => {} : (x: string) => void +>x : string + +export let ctor: IDirectiveLinkFn | ConstructableA | IDirectivePrePost = class { +>ctor : ConstructableA | IDirectiveLinkFn | IDirectivePrePost +>class { someUnaccountedProp: any;} : typeof ctor + + someUnaccountedProp: any; +>someUnaccountedProp : any +} +