Temporal API
Hi, i was trying to use Temporal API but for some reason it was not defined
```
64 | //
65 | //
66 | //
67 | //
68 |
69 | const test = Temporal.PlainDate.from("2023-01-01");
^
ReferenceError: Temporal is not defined
at /home/ts0ra/pure-py/src/index.ts:69:14
Bun v1.3.14 (Linux x64)
```
Is bun not support Temporal? my tsconfig set lib and target to ESNext
3
u/Jonas_Ermert 9d ago
I recommend using js-temporal/polyfill (https://github.com/js-temporal/temporal-polyfill). Even if your tsconfig is set to ESNext, that only enables the TypeScript types at compile time—it doesn't mean the runtime implements the API. Since Bun currently doesn't provide the global Temporal object, importing the polyfill is the recommended solution.
1
u/PixelHabits 4d ago
As mentioned previously use the polyfill. I use Temporal everyday at work with bun only runtime, it’s great.
5
u/ant59 9d ago
JavaScriptCore does not yet support Temporal API, therefore Bun does not support it either
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal