@@ -122,7 +122,8 @@ async function runTests(
122122 expectOnly : boolean ,
123123 tsLocal : string | undefined ,
124124) : Promise < void > {
125- const isOlderVersion = / ^ v \d + $ / . test ( basename ( dirPath ) ) ;
125+ const parent = dirname ( dirPath ) ;
126+ const isOlderVersion = basename ( parent ) !== "types" && / ^ v \d + ( \. \d + ) ? $ / . test ( basename ( dirPath ) ) ;
126127
127128 const indexText = await readFile ( joinPaths ( dirPath , "index.d.ts" ) , "utf-8" ) ;
128129 // If this *is* on DefinitelyTyped, types-publisher will fail if it can't parse the header.
@@ -219,13 +220,10 @@ async function testTypesVersion(
219220}
220221
221222function assertPathIsInDefinitelyTyped ( dirPath : string ) : void {
223+ // A DefinitelyTyped package must be a child of a "types" directory,
224+ // or be an older version and a grandchild of a "types" directory
222225 const parent = dirname ( dirPath ) ;
223- const types = / ^ v \d+ ( \.\d+ ) ?$ / . test ( basename ( dirPath ) ) ? dirname ( parent ) : parent ;
224- // TODO: It's not clear whether this assertion makes sense, and it's broken on Azure Pipelines
225- // Re-enable it later if it makes sense.
226- // const dt = dirname(types);
227- // if (basename(dt) !== "DefinitelyTyped" || basename(types) !== "types") {
228- if ( basename ( types ) !== "types" ) {
226+ if ( basename ( parent ) !== "types" && ( basename ( dirname ( parent ) ) !== "types" || ! / ^ v \d + ( \. \d + ) ? $ / . test ( basename ( dirPath ) ) ) ) {
229227 throw new Error ( "Since this type definition includes a header (a comment starting with `// Type definitions for`), "
230228 + "assumed this was a DefinitelyTyped package.\n"
231229 + "But it is not in a `DefinitelyTyped/types/xxx` directory: "
0 commit comments