TypeScript Version: 3.5.0-rc / next
Search Terms: 3.5, 3.5 union, 3.5 strict
Code
test.ts:
functionfooT<T=string>(bar: T[]|T|undefined){if(bar!==undefined&&!Array.isArray(bar))thrownewError("expected array")elseif(bar!==undefined&&bar.length===0)console.log("empty array")elseconsole.log("array or undef.")}CLI:
npx typescript@3.4.5 --strict true test.ts // compiles
npx typescript@next --strict true test.ts // error
Expected behavior:
Compiles and behaves like ts 3.4.5
Actual behavior:
Error:
test.ts:4:37 - error TS2339: Property 'length' does not exist on type 'T | T[]'.
Property 'length' does not exist on type 'T'.
Related Issues:
Cannot judge, if it is a duplicate of #31380 .
This is some specific case to base further evaluation on.
TypeScript Version: 3.5.0-rc / next
Search Terms: 3.5, 3.5 union, 3.5 strict
Code
test.ts:
CLI:
Expected behavior:
Compiles and behaves like ts 3.4.5
Actual behavior:
Error:
Related Issues:
Cannot judge, if it is a duplicate of #31380 .
This is some specific case to base further evaluation on.