You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for using keyword (TypeScript 5.2) #1628
The syntax is correct when you are using Symbol.asyncDispose. Please take a look at this simplified example from the handbook:
async function doWork() {
// Do fake work for half a second.
await new Promise(resolve => setTimeout(resolve, 500));
}
function loggy(id: string): AsyncDisposable {
console.log(`Constructing ${id}`);
return {
async [Symbol.asyncDispose]() {
console.log(`Disposing (async) ${id}`);
await doWork();
},
}
}
async function func() {
await using a = loggy("a");
}
func();
And it works as expected when I compile it with esbuild. But Webpack with ts-loader keeps failing with an error:
You may need an additional loader to handle the result of these loaders.
Does this new keyword collide with my favorite undocumented RxJS function using? Since I haven't found documentation when I've looked for it in the past, I'm always concerned there could be a breaking change with it at some point
Activity
fregante commentedon Nov 1, 2023
What's causing this issue? It seems that TS 5.2 is already supported and tested (#1633), so how come
ts-loaderalso needs to be updated?johnnyreilly commentedon Nov 1, 2023
Suspect this may be a tsconfig.json issue. No change should be required to ts-loader
fregante commentedon Nov 1, 2023
You may be right, for some reason
tscitself is failing on the files, even if I use the suggested TypeScript config:{ "compilerOptions": { "target": "es2022", "lib": ["es2022", "esnext.disposable", "dom"] } }Seen at the bottom of the section https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#using-declarations-and-explicit-resource-management
My config is based on @sindresorhus/tsconfig.json.
fregante commentedon Nov 2, 2023
The error is between the chair and the monitor. 😅
The syntax is:
not
I think ts-loader is working correctly here. 👍
dkhovrich commentedon Nov 2, 2023
The syntax is correct when you are using
Symbol.asyncDispose. Please take a look at this simplified example from the handbook:And it works as expected when I compile it with esbuild. But Webpack with ts-loader keeps failing with an error:
dkhovrich commentedon Nov 2, 2023
Hm, I could make it work with no error after I changed
compilerOptions.targetfromESNexttoes2022.A bit weird, but I think that's okay.
Thanks! :)
mfp22 commentedon Apr 15, 2024
Does this new keyword collide with my favorite undocumented RxJS function
using? Since I haven't found documentation when I've looked for it in the past, I'm always concerned there could be a breaking change with it at some point