Fixes parsing bug for TS versions >= 3

This commit is contained in:
jamesmcnamara 2018-10-30 14:52:35 -07:00
Родитель fef4df579a
Коммит dc3dfbd99a
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -258,7 +258,7 @@ function parseLabel(strict: boolean): pm.Parser<Label> {
}
const typeScriptVersionLineParser: pm.Parser<TypeScriptVersion> =
pm.regexp(/\/\/ TypeScript Version: (2.(\d))/, 1).chain<TypeScriptVersion>(v =>
pm.regexp(/\/\/ TypeScript Version: (\d.(\d))/, 1).chain<TypeScriptVersion>(v =>
TypeScriptVersion.all.includes(v as TypeScriptVersion)
? pm.succeed(v as TypeScriptVersion)
: pm.fail(`TypeScript ${v} is not yet supported.`));

Просмотреть файл

@ -73,6 +73,16 @@ describe("parseTypeScriptVersionLine", () => {
const src = "// TypeScript Version: 2.3";
assert.equal(parseTypeScriptVersionLine(src), "2.3");
});
it("allows post 3 version tags", () => {
const src = "// TypeScript Version: 3.0";
assert.equal(parseTypeScriptVersionLine(src), "3.0")
})
it("does not allow unallowed version tags", () => {
const src = "// TypeScript Version: 3.7";
assert.throws(() => parseTypeScriptVersionLine(src), `Could not parse version: line is ${src}`);
})
});
describe("tagsToUpdate", () => {