declarations-tests.mjs 534 B

12345678910111213141516171819202122232425262728
  1. export function returnsOne() {
  2. return 1;
  3. }
  4. export class hasStaticFieldTwo {
  5. static two = 2;
  6. }
  7. const expectedValue = 10;
  8. const didNotHoistClass = (() => {
  9. try {
  10. new ShouldNotBeHoisted();
  11. } catch (e) {
  12. if (e instanceof ReferenceError) return 4;
  13. }
  14. return 0;
  15. })();
  16. export const passed =
  17. returnsOne() + hasStaticFieldTwo.two + shouldBeHoisted() + didNotHoistClass === expectedValue;
  18. export function shouldBeHoisted() {
  19. return 3;
  20. }
  21. export class ShouldNotBeHoisted {
  22. static no = 5;
  23. }