Skip to content

Commit

Permalink
fix(instrumenter): support explicit resource management in TS (#4928)
Browse files Browse the repository at this point in the history
Support explicit resource management (`using` declarations) in TS files.

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html

Fixes #4876
  • Loading branch information
nicojs authored Aug 1, 2024
1 parent 4b8885c commit 2bd046a
Show file tree
Hide file tree
Showing 5 changed files with 2,164 additions and 339 deletions.
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/instrumenter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@babel/generator": "~7.25.0",
"@babel/parser": "~7.25.0",
"@babel/plugin-proposal-decorators": "~7.24.7",
"@babel/plugin-proposal-explicit-resource-management": "^7.24.7",
"@babel/preset-typescript": "~7.24.7",
"@stryker-mutator/api": "8.3.0",
"@stryker-mutator/util": "8.3.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/instrumenter/src/parsers/ts-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ async function parse(text: string, fileName: string, isTSX: boolean): Promise<ba
configFile: false,
babelrc: false,
presets: [[require.resolve('@babel/preset-typescript'), { isTSX, allExtensions: true }]],
plugins: [[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }]],
plugins: [
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
[require.resolve('@babel/plugin-proposal-explicit-resource-management')],
],
});
if (ast === null) {
throw new Error(`Expected ${fileName} to contain a babel.types.file, but it yielded null`);
Expand Down
Loading

0 comments on commit 2bd046a

Please sign in to comment.