Skip to content

Commit

Permalink
Fix dts walker (close #642)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed May 22, 2023
1 parent 314653d commit 812f09c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/dts_walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
regexpImportExportExpr = regexp.MustCompile(`^(import|export)\s*(type\s*)?('|"|\*|\{)`)
regexpImportExportExpr = regexp.MustCompile(`^(import|export)(\s+type)?\s*('|"|[a-zA-Z0-9_\$]+\s+from|\*|\{)`)
regexpFromExpr = regexp.MustCompile(`(\}|\*|\s)from\s*('|")`)
regexpImportPathExpr = regexp.MustCompile(`^import\s*('|")`)
regexpImportCallExpr = regexp.MustCompile(`(import|require)\(('|").+?('|")\)`)
Expand Down
21 changes: 21 additions & 0 deletions test/issue-642/issue-642.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
assertEquals,
assertStringIncludes,
} from "https://deno.land/[email protected]/testing/asserts.ts";

const { version } = await fetch("http://localhost:8080/status.json").then(
(r) => r.json(),
);

Deno.test("issue #642", async () => {
const res = await fetch(
`http://localhost:8080/v${version}/[email protected]/lib/Mutex.d.ts`,
{ redirect: "manual" },
);
assertEquals(res.status, 200);
assertEquals(
res.headers.get("content-type")!,
"application/typescript; charset=utf-8",
);
assertStringIncludes(await res.text(), "./MutexInterface.d.ts");
});

0 comments on commit 812f09c

Please sign in to comment.