Skip to content

Commit

Permalink
Improve dts transform (fix #95)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Aug 10, 2021
1 parent cc04958 commit d1487d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/dts_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ func getTypesPath(wd string, p NpmPackage, subpath string) string {
types = "index.d.ts"
}
}
return fmt.Sprintf("%s@%s%s", p.Name, p.Version, ensureSuffix(path.Join("/", types), ".d.ts"))

if !strings.HasSuffix(types, ".d.ts") && fileExists(path.Join(wd, "node_modules", p.Name, types, "index.d.ts")) {
types = types + "/index.d.ts"
}

return fmt.Sprintf("%s@%s/%s", p.Name, p.Version, strings.TrimPrefix(ensureSuffix(types, ".d.ts"), "/"))
}

func onSemicolon(data []byte, atEOF bool) (advance int, token []byte, err error) {
Expand Down

0 comments on commit d1487d9

Please sign in to comment.