Skip to content

Commit

Permalink
fix: assert oldMethod existence, and pin typescript version (#1549)
Browse files Browse the repository at this point in the history
* fix: assert oldMethod existence, and pin typescript version
  • Loading branch information
sofisl authored Feb 7, 2024
1 parent 1b42f5a commit 66a39fa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"timekeeper": "^2.0.0",
"tmp": "0.2.1",
"ts-node": "^10.7.0",
"typescript": "^5.1.6"
"typescript": "5.1.6"
},
"dependencies": {
"@google-cloud/common": "^5.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/cls/async-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ export class AsyncHooksCLS<Context extends {}> implements CLS<Context> {
if (ee[method]) {
shimmer.wrap(ee, method, oldMethod => {
return function (this: {}, event: string, cb: Func<void>) {
return oldMethod.call(this, event, that.bindWithCurrentContext(cb));
return oldMethod!.call(
this,
event,
that.bindWithCurrentContext(cb)
);
};
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ let traceAgent: StackdriverTracer;
function initConfig(userConfig: Forceable<Config>): TopLevelConfig {
let envSetConfig = {};
if (process.env.GCLOUD_TRACE_CONFIG) {
envSetConfig = require(path.resolve(
process.env.GCLOUD_TRACE_CONFIG!
)) as Config;
envSetConfig = require(
path.resolve(process.env.GCLOUD_TRACE_CONFIG!)
) as Config;
}
// Configuration order of precedence:
// 1. Environment Variables
Expand Down
9 changes: 5 additions & 4 deletions test/test-span-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ describe('SpanData', () => {

for (const sourceMapType of sourceMapTypes) {
it(`uses source maps when available in stack traces: ${sourceMapType}`, () => {
const {applyGeneric} =
require(`./fixtures/source-maps-test/${sourceMapType}`) as {
applyGeneric: <T>(fn: () => T) => T;
};
const {applyGeneric} = require(
`./fixtures/source-maps-test/${sourceMapType}`
) as {
applyGeneric: <T>(fn: () => T) => T;
};
const spanData = applyGeneric(
() => new CommonSpanData(trace, 'name', '0', 0)
);
Expand Down
6 changes: 3 additions & 3 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ function getFixturesForModule<T>(moduleName: string): Array<FixtureHelper<T>> {
return moduleNameMatches && versionCompatible;
})
.map(key => {
const version =
require(`./plugins/fixtures/${key}/node_modules/${moduleName}/package.json`)
.version as string;
const version = require(
`./plugins/fixtures/${key}/node_modules/${moduleName}/package.json`
).version as string;
const parsedVersion = semver.parse(version)!;
const getModule: () => T = () => require(`./plugins/fixtures/${key}`);
// Convenience function -- returns if.skip if the selected module's
Expand Down

0 comments on commit 66a39fa

Please sign in to comment.