Fix get latest match error format (#744)

* Fix getLatestMatch error format

* add test
This commit is contained in:
Nathan Shively-Sanders
2020-02-18 10:25:05 -08:00
committed by Andrew Branch
parent 7c0b14d775
commit 32b0439b20
2 changed files with 6 additions and 1 deletions

View File

@@ -40,4 +40,9 @@ describe(TypingsVersions, () => {
expect(versions.get({ major: 2, minor: 0 }).versionDirectoryName).toEqual("v2");
expect(versions.get({ major: 2, minor: 0 }).subDirectoryPath).toEqual("jquery/v2");
});
it("formats missing version error nicely", () => {
expect(() => versions.get({ major: 111, minor: 1001 })).toThrow("Could not find version 111.1001");
expect(() => versions.get({ major: 111 })).toThrow("Could not find version 111.*");
});
});

View File

@@ -479,7 +479,7 @@ export class TypingsVersions {
private getLatestMatch(version: TypingVersion): TypingsData {
const data = this.tryGetLatestMatch(version);
if (!data) {
throw new Error(`Could not find version ${version}`);
throw new Error(`Could not find version ${version.major}.${version.minor ?? "*"}`);
}
return data;
}