Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Flip typesVersions #306

Merged
merged 5 commits into from
Sep 1, 2020
Merged

Flip typesVersions #306

merged 5 commits into from
Sep 1, 2020

Conversation

sandersn
Copy link
Member

  1. Update @DefinitelyTyped dependencies to @next
  2. Simplify+invert runTests

Next steps:

  1. I'll wait until I get all my DT changes to pass, then I'll publish @DefinitelyTyped.
  2. Then I'll update this PR to @definitelytyped/*@latest, merge and publish a new version of dtslint.
  3. Then I'll create PRs for the DT changes. I created the first one at https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46960/files for testing purposes.

1. Update @DefinitelyTyped dependencies
2. Simplify+invert runTests
src/index.ts Outdated
const isLatest = hi === TypeScriptVersion.latest;
let versionPath = isLatest ? dirPath : joinPaths(dirPath, `ts${hi}`);
let versionIndexText = isLatest ? indexText : await readFile(joinPaths(versionPath, "index.d.ts"), "utf-8");
console.log('testing from', low, 'to', hi, 'in', versionPath)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how noisy this will be in normal use of dtslint, but it surely makes the standalone output more readable.

@sandersn
Copy link
Member Author

sandersn commented Aug 26, 2020

Update: 10 of 14 packages with typesVersions are working with this PR. But one of the non-working ones is node 🙃

@sandersn
Copy link
Member Author

sandersn commented Sep 1, 2020

Checking each individual package is working. I discovered that Minimum TypeScript Version wasn't propagating to subdirectories, so I had to fix that.

I'm going to send out PRs to DT tomorrow; @andrewbranch @elibarzilay can you take a look at this?

package.json Outdated
"@definitelytyped/utils": "latest",
"@definitelytyped/header-parser": "0.0.49-next.0",
"@definitelytyped/typescript-versions": "0.0.47-next.0",
"@definitelytyped/utils": "0.0.47-next.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update these after shipping 0.0.47 and before merging this PR.

if (onlyTestTsNext || tsLocal) {
const tsVersion = tsLocal ? "local" : TypeScriptVersion.latest;
if (typesVersions.length === 0) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only-next/only-local case is now much simpler because it doesn't have to search for the latest version inside a ts* directory

function getTsVersion(i: number): TsVersion {
return i === typesVersions.length
? TypeScriptVersion.latest
: assertDefined(TypeScriptVersion.previous(typesVersions[i]));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The all-versions code is completely rewritten -- it now generates low/hi ranges and iterates over them.

Also, we only care about the // Minimum Typescript Version comment from the root index.d.ts, so just need to read that once upfront.

expectOnly: boolean,
tsLocal: string | undefined,
inTypesVersionDirectory?: boolean,
isLatest: boolean,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testTypesVersion is now called in many fewer places, so I

  1. Shifted undefined checking out, to only places it applies.
  2. Shifted min-version checking out, to only places it applies.
  3. Made the last parameter required.

): Promise<void> {
const minVersionFromComment = getTypeScriptVersionFromComment(indexText);
if (minVersionFromComment !== undefined && inTypesVersionDirectory) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headers are already not allowed in subdirectories, so this check isn't needed.

src/index.ts Outdated Show resolved Hide resolved
@sandersn sandersn merged commit 90a45fc into master Sep 1, 2020
@sandersn sandersn deleted the update-flip-typesVersions branch September 1, 2020 18:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants