Fixes parsing bug for TS versions >= 3
This commit is contained in:
Родитель
fef4df579a
Коммит
dc3dfbd99a
2
index.ts
2
index.ts
|
@ -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.`));
|
||||
|
|
10
test/test.ts
10
test/test.ts
|
@ -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", () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче