Skip to content

Commit

Permalink
fix: Handle cyclical reference to current file (#83)
Browse files Browse the repository at this point in the history
Closes #82
  • Loading branch information
timfish authored May 28, 2024
1 parent 1e05e4b commit 0d9f351
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ function createHook (meta) {
return url
}

// If the file is referencing itself, we need to skip adding the iitm search params
if (url.url === parentURL) {
return {
url: url.url,
shortCircuit: true,
format: url.format
}
}

specifiers.set(url.url, specifier)

return {
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/cyclical-self.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// File generated from our OpenAPI spec by Stainless.
import * as BatchesAPI from './cyclical-self.mjs'
export class Batches {}
export class BatchesPage {}
(function (Batches) {
Batches.BatchesPage = BatchesAPI.BatchesPage
// eslint-disable-next-line no-class-assign
})(Batches || (Batches = {}))
4 changes: 4 additions & 0 deletions test/hook/cyclical-self.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Batches, BatchesPage } from '../fixtures/cyclical-self.mjs'
import { strictEqual } from 'assert'

strictEqual(Batches.BatchesPage, BatchesPage)

0 comments on commit 0d9f351

Please sign in to comment.