1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
tests/cases/compiler/parseInvalidNullableTypes.ts(1,30): error TS2677: A type predicate's type must be assignable to its parameter's type.
Type 'string | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.
tests/cases/compiler/parseInvalidNullableTypes.ts(1,30): error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string | null | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(5,16): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'string | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(6,16): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'number | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(8,16): error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string | null | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(9,16): error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'number | null | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(11,25): error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string | null | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(12,5): error TS2322: Type 'boolean' is not assignable to type 'string'.
tests/cases/compiler/parseInvalidNullableTypes.ts(15,16): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'any'?
tests/cases/compiler/parseInvalidNullableTypes.ts(16,10): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'number | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(18,16): error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'any'?
tests/cases/compiler/parseInvalidNullableTypes.ts(19,10): error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'number | null | undefined'?
tests/cases/compiler/parseInvalidNullableTypes.ts(21,8): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'unknown'?
tests/cases/compiler/parseInvalidNullableTypes.ts(22,8): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'never'?
tests/cases/compiler/parseInvalidNullableTypes.ts(23,8): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'void'?
tests/cases/compiler/parseInvalidNullableTypes.ts(24,8): error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'undefined'?
==== tests/cases/compiler/parseInvalidNullableTypes.ts (16 errors) ====
function f1(a: string): a is ?string {
~~~~~~~
!!! error TS2677: A type predicate's type must be assignable to its parameter's type.
!!! error TS2677: Type 'string | null' is not assignable to type 'string'.
!!! error TS2677: Type 'null' is not assignable to type 'string'.
~~~~~~~
!!! error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string | null | undefined'?
return true;
}
function f2(a: string?) {}
~~~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'string | undefined'?
function f3(a: number?) {}
~~~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'number | undefined'?
function f4(a: ?string) {}
~~~~~~~
!!! error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string | null | undefined'?
function f5(a: ?number) {}
~~~~~~~
!!! error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'number | null | undefined'?
function f6(a: string): ?string {
~~~~~~~
!!! error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'string | null | undefined'?
return true;
~~~~~~~~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
}
const a = 1 as any?;
~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'any'?
const b: number? = 1;
~~~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'number | undefined'?
const c = 1 as ?any;
~~~~
!!! error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'any'?
const d: ?number = 1;
~~~~~~~
!!! error TS17020: '?' at the start of a type is not valid TypeScript syntax. Did you mean to write 'number | null | undefined'?
let e: unknown?;
~~~~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'unknown'?
let f: never?;
~~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'never'?
let g: void?;
~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'void'?
let h: undefined?;
~~~~~~~~~~
!!! error TS17019: '?' at the end of a type is not valid TypeScript syntax. Did you mean to write 'undefined'?
|