TypeScript/tests/baselines/reference/unparenthesizedFunctionTypeInUnionOrIntersection.errors.txt
uhyo b6f09ccf06
Better error message for unparenthesized function/constructor type notation in union/intersection types (#39570)
* add graceful error message for unparenthesized function types in union and intersection

* add unparenthesizedFunctionTypeInUnionOrIntersection test

* add unparenthesizedConstructorTypeInUnionOrIntersection test

* Update src/compiler/parser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* pass isInUnionType to parseFunctionOrConstructorTypeToError

* Apply suggestions from code review

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* syntax fix

* refactor isStartOfFunctionType into isStartOfFunctionTypeOrConstructorType

* Update src/compiler/parser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* hoist isUnionType

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-07-15 14:43:56 -07:00

80 lines
5.9 KiB
Plaintext

tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(1,19): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(2,19): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(3,12): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(4,12): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(5,19): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(8,4): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(11,19): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(12,19): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(13,12): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(14,12): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(15,19): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(18,4): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(20,37): error TS1385: Function type notation must be parenthesized when used in a union type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(21,31): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(22,16): error TS1387: Function type notation must be parenthesized when used in an intersection type.
tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts(22,37): error TS1385: Function type notation must be parenthesized when used in a union type.
==== tests/cases/compiler/unparenthesizedFunctionTypeInUnionOrIntersection.ts (16 errors) ====
type U1 = string | () => void;
~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type U2 = string | (foo: number) => void
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type U3 = | () => number
~~~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type U4 = | (foo?: number) => void;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type U5 = string | (number: number, foo?: string) => void | number;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type U6 =
| string
| (...args: any[]) => void
~~~~~~~~~~~~~~~~~~~~~~~~~
| number;
~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type I1 = string & () => void;
~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type I2 = string & (...foo: number[]) => void;
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type I3 = & () => boolean
~~~~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type I4 = & () => boolean & null;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type I5 = string & (any: any, any2: any) => any & any;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type I6 =
& string
& (foo: any) => void;
~~~~~~~~~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type M1 = string | number & string | () => number;
~~~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type M2 = any & string | any & () => void;
~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
type M3 = any & (foo: any) => void | () => void & any;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1387: Function type notation must be parenthesized when used in an intersection type.
~~~~~~~~~~~~~~~~~
!!! error TS1385: Function type notation must be parenthesized when used in a union type.
type OK1 = string | (number);
type OK2 = string | ((number));
type OK3 = string | (()=> void);
type OK4 = string | (()=> string | number);