generic-cast.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // https://github.com/prettier/prettier/issues/4171
  2. function y() {
  3. const fits = <Immutable.Map<string, any>>fits();
  4. const fitsObjLiteral = <Immutable.Map<string, any>>{ a: "test" };
  5. const fitsArrayLiteral = <Immutable.Map<string, any>>["test", "test2"]
  6. const breakAfterCast = <Immutable.Map<string, any>>someExistingConfigMap.mergeDeep(fallbackOpts);
  7. const stillTooLong = <Immutable.Map<string, boolean, number, object, null, undefined, any, void, never>>someExistingConfigMap.mergeDeep(fallbackOptions);
  8. const stillTooLong2 = <Immutable.Map<string, boolean, number, object, null, undefined, any, void, never> | undefined>someExistingConfigMap.mergeDeep(fallbackOptions);
  9. const stillTooLong3 = <Immutable.Map<string>>someExistingConfigMap.mergeDeep(fallbackOptions.someMethodWithLongName(param1, param2));
  10. const stillTooLong4 = <Immutable.Map<string, boolean, number, object, null, undefined, any, void, never> | undefined>someExistingConfigMap.mergeDeep(fallbackOptions.someMethodWithLongName(param1, param2));
  11. const testObjLiteral = <Immutable.Map<string, any>>{ property1: "myPropertyVal" };
  12. const testObjLiteral2 = <Immutable.Map<string, any, number, boolean, object, null, undefined, never, "extra long">>{ property1: "myPropertyVal" };
  13. const testArrayLiteral = <Immutable.Map<string, any>>["first", "second", "third"];
  14. const testArrayLiteral2 = <Immutable.Map<string, any, number, boolean, object, null, undefined, never, "extra long">>["first", "second", "third"];
  15. const insideFuncCall = myFunc(param1, <Immutable.Map<string, any>>param2, param3)
  16. }
  17. // https://github.com/prettier/prettier/issues/4168
  18. function x() {
  19. const fits = <PermissionsChecker<any> | undefined>(<any>permissions)[type];
  20. const fitsObjLiteral = <PermissionsChecker<any> | undefined>{ a: "test" };
  21. const fitsArrayLiteral = <PermissionsChecker<any> | undefined>["t1", "t2"];
  22. const breakAfterCast = <PermissionsChecker<any> | undefined>(<any>permissions)[receiverType];
  23. const stillTooLong = <PermissionsChecker<object> | undefined | number | string | boolean>(<any>permissions)[receiverType];
  24. const stillTooLong2 = <PermissionsChecker<object> | undefined | number | string | boolean | null | never>(<any>permissions)[receiverType];
  25. const stillTooLong3 = <PermissionsChecker<object> | undefined>(<any>permissions.someMethodWithLongName(parameter1, parameter2))[receiverTypeLongName];
  26. const stillTooLong4 = <PermissionsChecker<object> | undefined | number | string | boolean | null | never>(<any>permissions.someMethodWithLongName(parameter1, parameter2))[receiverTypeLongName];
  27. const testObjLiteral = <PermissionsChecker<any> | undefined>{ prop1: "myPropVal" };
  28. const testObjLiteral2 = <PermissionsChecker<object> | undefined | number | string | boolean | null | never | object>{ prop1: "myPropVal" };
  29. const testArrayLiteral = <PermissionsChecker<any> | undefined>["first", "second", "third"];
  30. const testArrayLiteral2 = <PermissionsChecker<object> | undefined | number | string | boolean | null | never | object>["first", "second", "third"];
  31. const insideFuncCall = myFunc(param1, <PermissionsChecker<any> | undefined>param2, param3)
  32. }