-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve binding element type inference using CheckMode (rebased) #56753
Improve binding element type inference using CheckMode (rebased) #56753
Conversation
Signed-off-by: Babak K. Shandiz <[email protected]>
Signed-off-by: Babak K. Shandiz <[email protected]>
Signed-off-by: Babak K. Shandiz <[email protected]>
Signed-off-by: Babak K. Shandiz <[email protected]>
@@ -11634,6 +11634,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) { | |||
return getTypeOfFuncClassEnumModule(symbol); | |||
} | |||
|
|||
if (checkMode !== CheckMode.Normal && checkMode) { | |||
return anyType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that there is a non-zero chance that this PR will get picked up at some point (cc @jakebailey ). If the team decides to go with it then this should return errorType
:
return anyType; | |
return errorType; |
I think that there is no harm in returning that here already now (unless proven otherwise)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. Since, it's an error (of course, not a circularity one but still), I think you're right about changing the return value from anyType
to errorType
.
Applied in the last commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I might have read this late or smth. I think that errorType
should be returned if you encounter the circularity error but here you explicitly want to prevent the error from being reported and I think that it should extend to the returned type. So despite my initial reaction, I would recommend returning anyType
here. Sorry for the confusion 🙈
@babakks Will this PR also solve #49989 (comment)? |
@n9 Yes. I just checked the test output and it's now inferring the right type:
|
Great! Thank you! Hopefully someone will merge it soon. |
@n9 Sorry, but seems there's a problem. Actually, the type of Anyway, thanks for bringing this useful test case. I can use it as an extra check for the PR. |
Yes, you are right. 😎 |
Signed-off-by: Babak K. Shandiz <[email protected]>
…hecking Signed-off-by: Babak K. Shandiz <[email protected]>
…ls in a loop Signed-off-by: Babak K. Shandiz <[email protected]>
@n9 While working on the PR, I noticed it's not actually wrong. So, I've included your test case in the new test files. |
@babakks What is not wrong? |
@n9 I wanted to make sure that the type of |
@sandersn @Andarist I think this is ready for review now. By the way, I always had a hard time debugging TypeScript checker code, because of its complicated nature and repeate/recursive-like calls that you couldn't just put ordinary (non-conditional) breakpoints. So, I made this simple VS Code extension that helps with setting call-stack bound breakpoints (which will only hit, when you're at a specific call-trace). I think it might be useful for you guys too. Here's the link to it: https://marketplace.visualstudio.com/items?itemName=babakks.vscode-js-custom-breakpoint |
Hmm, I just do not understand Lines 77 to 94 in e872af5
|
@n9 Yeah, that was my concern, too. But after checking other (unrelated) test cases noticed this is not necessarily wrong. That notation is used in baseline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change and a sync with main
, and I'll get the extended tests running for this
src/compiler/checker.ts
Outdated
// For a contextually typed parameter it is possible that a type has already | ||
// been assigned (in assignTypeToParameterAndFixTypeParameters), and we want | ||
// to preserve this type. In fact, we need to _prefer_ that type, but it won't | ||
// be assigned until contextual typing is complete, so we need to defer in | ||
// cases where contextual typing may take place. | ||
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) { | ||
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !(checkMode !== CheckMode.Normal && checkMode)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !(checkMode !== CheckMode.Normal && checkMode)) { | |
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) { | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied the suggested change. Also, merged the latest main
into the branch.
Signed-off-by: Babak K. Shandiz <[email protected]>
Signed-off-by: Babak K. Shandiz <[email protected]> diff --git a/.dprint.jsonc b/.dprint.jsonc index 98a8c53f8..88316e24f 100644 --- a/.dprint.jsonc +++ b/.dprint.jsonc @@ -30,6 +30,7 @@ "importDeclaration.sortNamedImports": "maintain" }, "prettier": { + "newLineKind": "lf", "associations": [ "**/*.{yaml,yml}" ], @@ -55,8 +56,8 @@ ], // Note: if adding new languages, make sure settings.template.json is updated too. "plugins": [ - "https://plugins.dprint.dev/typescript-0.88.3.wasm", - "https://plugins.dprint.dev/json-0.19.0.wasm", - "https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe" + "https://plugins.dprint.dev/typescript-0.88.8.wasm", + "https://plugins.dprint.dev/json-0.19.1.wasm", + "https://plugins.dprint.dev/prettier-0.32.1.json@19aa403ef0862ba8c41164e3dc6f84c0b7a66c2b11e42726b23dd25e6302ada9" ] } diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 9526309bd..e4d4b1f67 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,15 +1,15 @@ ---- -blank_issues_enabled: false -contact_links: - - about: 'Please ask and answer usage questions on Stack Overflow.' - name: Question - url: 'https://stackoverflow.com/questions/tagged/typescript' - - about: 'Alternatively, you can use the TypeScript Community Discord.' - name: Chat - url: 'https://discord.gg/typescript' - - about: 'Please check the FAQ before filing new issues' - name: 'TypeScript FAQ' - url: 'https://github.com/microsoft/TypeScript/wiki/FAQ' - - about: 'Please raise issues about the site on its own repo.' - name: Website - url: 'https://github.com/microsoft/TypeScript-Website/issues/new' +--- +blank_issues_enabled: false +contact_links: + - about: 'Please ask and answer usage questions on Stack Overflow.' + name: Question + url: 'https://stackoverflow.com/questions/tagged/typescript' + - about: 'Alternatively, you can use the TypeScript Community Discord.' + name: Chat + url: 'https://discord.gg/typescript' + - about: 'Please check the FAQ before filing new issues' + name: 'TypeScript FAQ' + url: 'https://github.com/microsoft/TypeScript/wiki/FAQ' + - about: 'Please raise issues about the site on its own repo.' + name: Website + url: 'https://github.com/microsoft/TypeScript-Website/issues/new' diff --git a/.github/workflows/accept-baselines-fix-lints.yaml b/.github/workflows/accept-baselines-fix-lints.yaml index b382f3fde..a5d301f14 100644 --- a/.github/workflows/accept-baselines-fix-lints.yaml +++ b/.github/workflows/accept-baselines-fix-lints.yaml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - name: Configure Git, Run Tests, Update Baselines, Apply Fixes run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67551fb65..d7e88b7f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Use node version ${{ matrix.node-version }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: ${{ matrix.node-version }} check-latest: true @@ -56,7 +56,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -70,7 +70,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -91,7 +91,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -108,7 +108,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -123,7 +123,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -171,7 +171,7 @@ jobs: path: base ref: ${{ github.base_ref }} - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -205,7 +205,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -222,7 +222,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true @@ -242,7 +242,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: '*' check-latest: true diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml index f3321ebaa..159d6101f 100644 --- a/.github/workflows/close-issues.yml +++ b/.github/workflows/close-issues.yml @@ -1,49 +1,49 @@ -name: Close issues - -on: - schedule: - - cron: '0 1 * * *' - workflow_dispatch: - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - close-issues: - runs-on: ubuntu-latest - if: github.repository == 'microsoft/TypeScript' - permissions: - contents: read # Apparently required to create issues - issues: write - - steps: - - name: Close issues - env: - GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - run: | - DATE=$(date --date='2 days ago' --iso-8601) - - close_issues() { - echo "Closing issues marked as '$1'." - for issue in $(gh issue list --limit 100 --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do - echo "Closing https://github.com/${{ github.repository }}/issues/$issue" - gh issue close $issue --repo ${{ github.repository }} --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes." - done - } - - close_issues "Duplicate" - close_issues "Unactionable" - close_issues "Not a Defect" - close_issues "External" - close_issues "Working as Intended" - close_issues "Question" - close_issues "Out of Scope" - close_issues "Declined" - close_issues "Won't Fix" - close_issues "Too Complex" +name: Close issues + +on: + schedule: + - cron: '0 1 * * *' + workflow_dispatch: + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + close-issues: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + permissions: + contents: read # Apparently required to create issues + issues: write + + steps: + - name: Close issues + env: + GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + run: | + DATE=$(date --date='2 days ago' --iso-8601) + + close_issues() { + echo "Closing issues marked as '$1'." + for issue in $(gh issue list --limit 100 --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do + echo "Closing https://github.com/${{ github.repository }}/issues/$issue" + gh issue close $issue --repo ${{ github.repository }} --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes." + done + } + + close_issues "Duplicate" + close_issues "Unactionable" + close_issues "Not a Defect" + close_issues "External" + close_issues "Working as Intended" + close_issues "Question" + close_issues "Out of Scope" + close_issues "Declined" + close_issues "Won't Fix" + close_issues "Too Complex" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index dcb27e10c..c7791363a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/init@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12 with: config-file: ./.github/codeql/codeql-configuration.yml # Override language selection by uncommenting this and choosing your languages @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below). - name: Autobuild - uses: github/codeql-action/autobuild@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/autobuild@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -70,4 +70,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12 diff --git a/.github/workflows/error-deltas-watchdog.yaml b/.github/workflows/error-deltas-watchdog.yaml index 86aee16a7..2d74e1fb9 100644 --- a/.github/workflows/error-deltas-watchdog.yaml +++ b/.github/workflows/error-deltas-watchdog.yaml @@ -1,45 +1,45 @@ -name: 'typescript-error-deltas Watchdog' - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * 3' # Every Wednesday - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - check-for-recent: - runs-on: ubuntu-latest - if: github.repository == 'microsoft/TypeScript' - permissions: - contents: read # Apparently required to create issues - issues: write - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAGS: '@navya9singh @RyanCavanaugh @DanielRosenwasser' - steps: - - name: NewErrors - run: | # --json and --jq prints exactly one issue number per line of output - DATE=$(date --date="7 days ago" --iso-8601) - gh issue list --repo microsoft/typescript --search "[NewErrors] created:>=$DATE" --state all --json number --jq ".[].number" \ - | grep -qe "[0-9]" \ - || gh issue create --repo ${{ github.repository }} --title "No NewErrors issue since $DATE" --body "$TAGS Please check the [pipeline](https://typescript.visualstudio.com/TypeScript/_build?definitionId=48)." - - name: ServerErrors TS - run: | - DATE=$(date --date="7 days ago" --iso-8601) - gh issue list --repo microsoft/typescript --search "[ServerErrors][TypeScript] created:>=$DATE" --state all --json number --jq ".[].number" \ - | grep -qe "[0-9]" \ - || gh issue create --repo ${{ github.repository }} --title "No TypeScript ServerErrors issue since $DATE" --body "$TAGS Please check the [pipeline](https://typescript.visualstudio.com/TypeScript/_build?definitionId=59)." - - name: ServerErrors JS - run: | - DATE=$(date --date="7 days ago" --iso-8601) - gh issue list --repo microsoft/typescript --search "[ServerErrors][JavaScript] created:>=$DATE" --state all --json number --jq ".[].number" \ - | grep -qe "[0-9]" \ - || gh issue create --repo ${{ github.repository }} --title "No JavaScript ServerErrors issue since $DATE" --body "$TAGS Please check the [pipeline](https://typescript.visualstudio.com/TypeScript/_build?definitionId=58)." +name: 'typescript-error-deltas Watchdog' + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 3' # Every Wednesday + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + check-for-recent: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + permissions: + contents: read # Apparently required to create issues + issues: write + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAGS: '@navya9singh @RyanCavanaugh @DanielRosenwasser' + steps: + - name: NewErrors + run: | # --json and --jq prints exactly one issue number per line of output + DATE=$(date --date="7 days ago" --iso-8601) + gh issue list --repo microsoft/typescript --search "[NewErrors] created:>=$DATE" --state all --json number --jq ".[].number" \ + | grep -qe "[0-9]" \ + || gh issue create --repo ${{ github.repository }} --title "No NewErrors issue since $DATE" --body "$TAGS Please check the [pipeline](https://typescript.visualstudio.com/TypeScript/_build?definitionId=48)." + - name: ServerErrors TS + run: | + DATE=$(date --date="7 days ago" --iso-8601) + gh issue list --repo microsoft/typescript --search "[ServerErrors][TypeScript] created:>=$DATE" --state all --json number --jq ".[].number" \ + | grep -qe "[0-9]" \ + || gh issue create --repo ${{ github.repository }} --title "No TypeScript ServerErrors issue since $DATE" --body "$TAGS Please check the [pipeline](https://typescript.visualstudio.com/TypeScript/_build?definitionId=59)." + - name: ServerErrors JS + run: | + DATE=$(date --date="7 days ago" --iso-8601) + gh issue list --repo microsoft/typescript --search "[ServerErrors][JavaScript] created:>=$DATE" --state all --json number --jq ".[].number" \ + | grep -qe "[0-9]" \ + || gh issue create --repo ${{ github.repository }} --title "No JavaScript ServerErrors issue since $DATE" --body "$TAGS Please check the [pipeline](https://typescript.visualstudio.com/TypeScript/_build?definitionId=58)." diff --git a/.github/workflows/new-release-branch.yaml b/.github/workflows/new-release-branch.yaml index fd38d8bf1..99a0c0557 100644 --- a/.github/workflows/new-release-branch.yaml +++ b/.github/workflows/new-release-branch.yaml @@ -1,52 +1,52 @@ -name: New Release Branch - -on: - repository_dispatch: - types: [new-release-branch] - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ - fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. - token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 - - run: | - npm --version - # corepack enable npm - npm install -g $(jq -r '.packageManager' < package.json) - npm --version - - run: | - git checkout -b ${{ github.event.client_payload.branch_name }} - sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json - sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' src/compiler/corePublic.ts - sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts - sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts - sed -i -e 's/const version\(: string\)\{0,1\} = `${versionMajorMinor}.0-.*`/const version = `${versionMajorMinor}.0-${{ github.event.client_payload.core_tag || 'dev' }}`/g' src/compiler/corePublic.ts - npm ci - npm install # update package-lock.json to ensure the version bump is included - npx hereby LKG - npm test - git diff - git add package.json package-lock.json - git add src/compiler/corePublic.ts - git add tests/baselines/reference/api/typescript.d.ts - git add tests/baselines/reference/api/tsserverlibrary.d.ts - git add --force ./lib - git config user.email "[email protected]" - git config user.name "TypeScript Bot" - git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG' - git push --set-upstream origin ${{ github.event.client_payload.branch_name }} +name: New Release Branch + +on: + repository_dispatch: + types: [new-release-branch] + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - run: | + npm --version + # corepack enable npm + npm install -g $(jq -r '.packageManager' < package.json) + npm --version + - run: | + git checkout -b ${{ github.event.client_payload.branch_name }} + sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json + sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' src/compiler/corePublic.ts + sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts + sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts + sed -i -e 's/const version\(: string\)\{0,1\} = `${versionMajorMinor}.0-.*`/const version = `${versionMajorMinor}.0-${{ github.event.client_payload.core_tag || 'dev' }}`/g' src/compiler/corePublic.ts + npm ci + npm install # update package-lock.json to ensure the version bump is included + npx hereby LKG + npm test + git diff + git add package.json package-lock.json + git add src/compiler/corePublic.ts + git add tests/baselines/reference/api/typescript.d.ts + git add tests/baselines/reference/api/tsserverlibrary.d.ts + git add --force ./lib + git config user.email "[email protected]" + git config user.name "TypeScript Bot" + git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG' + git push --set-upstream origin ${{ github.event.client_payload.branch_name }} diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 00664d82c..b81409194 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -1,46 +1,46 @@ -name: Publish Nightly - -on: - schedule: - - cron: '0 7 * * *' - # enable users to manually trigger with workflow_dispatch - workflow_dispatch: {} - repository_dispatch: - types: [publish-nightly] - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - if: github.repository == 'microsoft/TypeScript' - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 - with: - # Use NODE_AUTH_TOKEN environment variable to authenticate to this registry. - registry-url: https://registry.npmjs.org/ - - run: | - npm --version - # corepack enable npm - npm install -g $(jq -r '.packageManager' < package.json) - npm --version - - name: Setup and publish nightly - run: | - npm whoami - npm ci - npx hereby configure-nightly - npx hereby LKG - npx hereby runtests-parallel - npx hereby clean - npm publish --tag next - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} +name: Publish Nightly + +on: + schedule: + - cron: '0 7 * * *' + # enable users to manually trigger with workflow_dispatch + workflow_dispatch: {} + repository_dispatch: + types: [publish-nightly] + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + with: + # Use NODE_AUTH_TOKEN environment variable to authenticate to this registry. + registry-url: https://registry.npmjs.org/ + - run: | + npm --version + # corepack enable npm + npm install -g $(jq -r '.packageManager' < package.json) + npm --version + - name: Setup and publish nightly + run: | + npm whoami + npm ci + npx hereby configure-nightly + npx hereby LKG + npx hereby runtests-parallel + npx hereby clean + npm publish --tag next + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/pr-modified-files.yml b/.github/workflows/pr-modified-files.yml index 09841f73f..1784558ec 100644 --- a/.github/workflows/pr-modified-files.yml +++ b/.github/workflows/pr-modified-files.yml @@ -1,136 +1,136 @@ -name: Check modified files -on: - # For security reasons, we have to use pull_request_target here. - # This differs from pull_request in that it runs at the _base_ of the PR, - # e.g. main. This allows us to access secrets. In this workflow, we should - # never actually clone the PR, as it may contain malicious code. - # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ - pull_request_target: - branches: - - main - -# We only ever need one of these running on a single PR. -# Just let the newest one complete if there are multiple running. -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - manage-prs: - runs-on: ubuntu-latest - if: github.repository == 'microsoft/TypeScript' - - # No need to set explicit permissions; we are using typescript-bot's token, not github-actions' token. - - env: - GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - - steps: - - name: Check if PR author is in pr_owners.txt - id: pr_owner - run: | - curl -s https://raw.githubusercontent.com/microsoft/TypeScript/main/.github/pr_owners.txt > pr_owners.txt - if grep -Fxq -m1 "${{ github.event.pull_request.user.login }}" pr_owners.txt; then - echo "pr_owner=true" >> "$GITHUB_OUTPUT" - else - echo "pr_owner=false" >> "$GITHUB_OUTPUT" - fi - - - name: Create scripts - run: | - cat > is_changed.sh <<'EOF' - #!/bin/bash - FILENAME=changed_files.txt - if [ ! -f $FILENAME ]; then - # The gh command only returns info for the first 100 files. To get - # the rest, we have to use the graphql API. See: - # https://github.com/cli/cli/issues/5368#issuecomment-1344253654 - gh api graphql -f query=' - query($endCursor: String) { - repository(owner: "microsoft", name: "TypeScript") { - pullRequest(number: ${{ github.event.pull_request.number }}) { - files(first: 100, after: $endCursor) { - pageInfo{ hasNextPage, endCursor } - nodes { - path - } - } - } - } - }' --paginate --jq '.data.repository.pullRequest.files.nodes.[].path' > $FILENAME - fi - for file in "$@"; do - grep -Fxq -m1 "$file" $FILENAME && exit 0 - done - exit 1 - EOF - chmod +x is_changed.sh - - cat > already_commented.sh <<'EOF' - #!/bin/bash - FILENAME=bot_comments.txt - if [ ! -f $FILENAME ]; then - gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} \ - --json 'comments' --jq '.comments[] | select(.author.login == "typescript-bot") | .body' > $FILENAME - fi - exec grep -Fq -m1 "$1" $FILENAME - EOF - chmod +x already_commented.sh - - - name: Generated DOM files - if: steps.pr_owner.outputs.pr_owner == 'false' - run: | - if ./is_changed.sh "src/lib/dom.generated.d.ts" \ - "src/lib/dom.iterable.generated.d.ts" \ - "src/lib/webworker.generated.d.ts" \ - "src/lib/webworker.iterable.generated.d.ts"; then - MESSAGE="It looks like you've sent a pull request to update some generated declaration files related to the DOM." - MESSAGE+=" These files aren't meant to be edited by hand, as they are synchronized with files in" - MESSAGE+=" [the TypeScript-DOM-lib-generator repository](https://github.com/microsoft/TypeScript-DOM-lib-generator)." - MESSAGE+=" You can [read more here](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#contributing-libdts-fixes)." - MESSAGE+=" For house-keeping purposes, this pull request will be closed." - - gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --comment "$MESSAGE" - exit 1 # Stop the pipeline; we just closed the PR. - fi - - - name: Check if PR modifies protocol.ts - run: | - if ./is_changed.sh "src/server/protocol.ts"; then - MESSAGE="Thanks for the PR! It looks like you've changed the TSServer protocol in some way." - MESSAGE+=" Please ensure that any changes here don't break consumers of the current TSServer API." - MESSAGE+=" For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you." - MESSAGE+=" Feel free to loop in other consumers/maintainers if necessary." - - if ./already_commented.sh "It looks like you've changed the TSServer protocol in some way."; then - echo "Already commented." - else - gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE" - fi - fi - - - name: Check for breaking changes - run: | - if ./is_changed.sh "tests/baselines/reference/api/typescript.d.ts" \ - "tests/baselines/reference/api/tsserverlibrary.d.ts"; then - MESSAGE="Looks like you're introducing a change to the public API surface area." - MESSAGE+=" If this includes breaking changes, please document them" - MESSAGE+=" [on our wiki's API Breaking Changes page](https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes)." - MESSAGE+=$'\n\n' - MESSAGE+="Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up." - - if ./already_commented.sh "Looks like you're introducing a change to the public API surface area."; then - echo "Already commented." - else - gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE" - fi - fi +name: Check modified files +on: + # For security reasons, we have to use pull_request_target here. + # This differs from pull_request in that it runs at the _base_ of the PR, + # e.g. main. This allows us to access secrets. In this workflow, we should + # never actually clone the PR, as it may contain malicious code. + # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ + pull_request_target: + branches: + - main + +# We only ever need one of these running on a single PR. +# Just let the newest one complete if there are multiple running. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + manage-prs: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + + # No need to set explicit permissions; we are using typescript-bot's token, not github-actions' token. + + env: + GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + + steps: + - name: Check if PR author is in pr_owners.txt + id: pr_owner + run: | + curl -s https://raw.githubusercontent.com/microsoft/TypeScript/main/.github/pr_owners.txt > pr_owners.txt + if grep -Fxq -m1 "${{ github.event.pull_request.user.login }}" pr_owners.txt; then + echo "pr_owner=true" >> "$GITHUB_OUTPUT" + else + echo "pr_owner=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create scripts + run: | + cat > is_changed.sh <<'EOF' + #!/bin/bash + FILENAME=changed_files.txt + if [ ! -f $FILENAME ]; then + # The gh command only returns info for the first 100 files. To get + # the rest, we have to use the graphql API. See: + # https://github.com/cli/cli/issues/5368#issuecomment-1344253654 + gh api graphql -f query=' + query($endCursor: String) { + repository(owner: "microsoft", name: "TypeScript") { + pullRequest(number: ${{ github.event.pull_request.number }}) { + files(first: 100, after: $endCursor) { + pageInfo{ hasNextPage, endCursor } + nodes { + path + } + } + } + } + }' --paginate --jq '.data.repository.pullRequest.files.nodes.[].path' > $FILENAME + fi + for file in "$@"; do + grep -Fxq -m1 "$file" $FILENAME && exit 0 + done + exit 1 + EOF + chmod +x is_changed.sh + + cat > already_commented.sh <<'EOF' + #!/bin/bash + FILENAME=bot_comments.txt + if [ ! -f $FILENAME ]; then + gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} \ + --json 'comments' --jq '.comments[] | select(.author.login == "typescript-bot") | .body' > $FILENAME + fi + exec grep -Fq -m1 "$1" $FILENAME + EOF + chmod +x already_commented.sh + + - name: Generated DOM files + if: steps.pr_owner.outputs.pr_owner == 'false' + run: | + if ./is_changed.sh "src/lib/dom.generated.d.ts" \ + "src/lib/dom.iterable.generated.d.ts" \ + "src/lib/webworker.generated.d.ts" \ + "src/lib/webworker.iterable.generated.d.ts"; then + MESSAGE="It looks like you've sent a pull request to update some generated declaration files related to the DOM." + MESSAGE+=" These files aren't meant to be edited by hand, as they are synchronized with files in" + MESSAGE+=" [the TypeScript-DOM-lib-generator repository](https://github.com/microsoft/TypeScript-DOM-lib-generator)." + MESSAGE+=" You can [read more here](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#contributing-libdts-fixes)." + MESSAGE+=" For house-keeping purposes, this pull request will be closed." + + gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --comment "$MESSAGE" + exit 1 # Stop the pipeline; we just closed the PR. + fi + + - name: Check if PR modifies protocol.ts + run: | + if ./is_changed.sh "src/server/protocol.ts"; then + MESSAGE="Thanks for the PR! It looks like you've changed the TSServer protocol in some way." + MESSAGE+=" Please ensure that any changes here don't break consumers of the current TSServer API." + MESSAGE+=" For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you." + MESSAGE+=" Feel free to loop in other consumers/maintainers if necessary." + + if ./already_commented.sh "It looks like you've changed the TSServer protocol in some way."; then + echo "Already commented." + else + gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE" + fi + fi + + - name: Check for breaking changes + run: | + if ./is_changed.sh "tests/baselines/reference/api/typescript.d.ts" \ + "tests/baselines/reference/api/tsserverlibrary.d.ts"; then + MESSAGE="Looks like you're introducing a change to the public API surface area." + MESSAGE+=" If this includes breaking changes, please document them" + MESSAGE+=" [on our wiki's API Breaking Changes page](https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes)." + MESSAGE+=$'\n\n' + MESSAGE+="Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up." + + if ./already_commented.sh "Looks like you're introducing a change to the public API surface area."; then + echo "Already commented." + else + gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE" + fi + fi diff --git a/.github/workflows/release-branch-artifact.yaml b/.github/workflows/release-branch-artifact.yaml index 24be83d5a..ed4552496 100644 --- a/.github/workflows/release-branch-artifact.yaml +++ b/.github/workflows/release-branch-artifact.yaml @@ -1,47 +1,47 @@ -name: Create Releasable Package Drop - -on: - push: - branches: - - release-* - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 - - run: | - npm --version - # corepack enable npm - npm install -g $(jq -r '.packageManager' < package.json) - npm --version - - name: npm install and test - run: | - npm ci - npm test - - name: Installing browsers - run: npx playwright install --with-deps - - name: Validate the browser can import TypeScript - run: npx hereby test-browser-integration - - name: LKG, clean, and pack - run: | - npx hereby LKG - npx hereby clean - npm pack ./ - mv typescript-*.tgz typescript.tgz - - name: Upload built tarfile - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 - with: - name: tgz - path: typescript.tgz +name: Create Releasable Package Drop + +on: + push: + branches: + - release-* + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - run: | + npm --version + # corepack enable npm + npm install -g $(jq -r '.packageManager' < package.json) + npm --version + - name: npm install and test + run: | + npm ci + npm test + - name: Installing browsers + run: npx playwright install --with-deps + - name: Validate the browser can import TypeScript + run: npx hereby test-browser-integration + - name: LKG, clean, and pack + run: | + npx hereby LKG + npx hereby clean + npm pack ./ + mv typescript-*.tgz typescript.tgz + - name: Upload built tarfile + uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 + with: + name: tgz + path: typescript.tgz diff --git a/.github/workflows/rich-navigation.yml b/.github/workflows/rich-navigation.yml index 3dfbe6695..badc34d74 100644 --- a/.github/workflows/rich-navigation.yml +++ b/.github/workflows/rich-navigation.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - name: Install dependencies run: npm ci diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 6367f8fcd..22e69e6df 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -47,7 +47,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: 'Upload artifact' - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 with: name: SARIF file path: results.sarif @@ -55,6 +55,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: 'Upload to code-scanning' - uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12 with: sarif_file: results.sarif diff --git a/.github/workflows/set-version.yaml b/.github/workflows/set-version.yaml index 11d57994f..cf490ad79 100644 --- a/.github/workflows/set-version.yaml +++ b/.github/workflows/set-version.yaml @@ -1,56 +1,56 @@ -name: Set branch version - -on: - repository_dispatch: - types: [set-version] - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - ref: ${{ github.event.client_payload.branch_name }} - token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 - - run: | - npm --version - # corepack enable npm - npm install -g $(jq -r '.packageManager' < package.json) - npm --version - # notably, this is essentially the same script as `new-release-branch.yaml` (with fewer inputs), but it assumes the branch already exists - # do note that executing the transform below will prevent the `configurePrerelease` script from running on the source, as it makes the - # `version` identifier no longer match the regex it uses - # required client_payload members: - # branch_name - the target branch - # package_version - the full version string (eg, `3.9.1-rc` or `3.9.2`) - # core_major_minor - the major.minor pair associated with the desired package_version (eg, `3.9` for `3.9.3`) - - run: | - sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json - sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' src/compiler/corePublic.ts - sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts - sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts - sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts - npm ci - npm install # update package-lock.json to ensure the version bump is included - npx hereby LKG - npm test - git diff - git add package.json package-lock.json - git add src/compiler/corePublic.ts - git add tests/baselines/reference/api/typescript.d.ts - git add tests/baselines/reference/api/tsserverlibrary.d.ts - git add --force ./lib - git config user.email "[email protected]" - git config user.name "TypeScript Bot" - git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG' - git push +name: Set branch version + +on: + repository_dispatch: + types: [set-version] + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.client_payload.branch_name }} + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - run: | + npm --version + # corepack enable npm + npm install -g $(jq -r '.packageManager' < package.json) + npm --version + # notably, this is essentially the same script as `new-release-branch.yaml` (with fewer inputs), but it assumes the branch already exists + # do note that executing the transform below will prevent the `configurePrerelease` script from running on the source, as it makes the + # `version` identifier no longer match the regex it uses + # required client_payload members: + # branch_name - the target branch + # package_version - the full version string (eg, `3.9.1-rc` or `3.9.2`) + # core_major_minor - the major.minor pair associated with the desired package_version (eg, `3.9` for `3.9.3`) + - run: | + sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json + sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' src/compiler/corePublic.ts + sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts + sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts + sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts + npm ci + npm install # update package-lock.json to ensure the version bump is included + npx hereby LKG + npm test + git diff + git add package.json package-lock.json + git add src/compiler/corePublic.ts + git add tests/baselines/reference/api/typescript.d.ts + git add tests/baselines/reference/api/tsserverlibrary.d.ts + git add --force ./lib + git config user.email "[email protected]" + git config user.name "TypeScript Bot" + git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG' + git push diff --git a/.github/workflows/sync-branch.yaml b/.github/workflows/sync-branch.yaml index 3a40e9b9a..309de471f 100644 --- a/.github/workflows/sync-branch.yaml +++ b/.github/workflows/sync-branch.yaml @@ -1,44 +1,44 @@ -name: Sync branch with master - -on: - repository_dispatch: - types: [sync-branch] - workflow_dispatch: - inputs: - branch_name: - description: 'Target Branch Name' - required: true - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }} - filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ - fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. - token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - # required client_payload members: - # branch_name - the target branch - - run: | - git config user.email "[email protected]" - git config user.name "TypeScript Bot" - git fetch origin main - git merge origin/main --no-ff - npm ci - npx hereby LKG - git add --force ./lib - git commit -m 'Update LKG' - git push +name: Sync branch with master + +on: + repository_dispatch: + types: [sync-branch] + workflow_dispatch: + inputs: + branch_name: + description: 'Target Branch Name' + required: true + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }} + filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + # required client_payload members: + # branch_name - the target branch + - run: | + git config user.email "[email protected]" + git config user.name "TypeScript Bot" + git fetch origin main + git merge origin/main --no-ff + npm ci + npx hereby LKG + git add --force ./lib + git commit -m 'Update LKG' + git push diff --git a/.github/workflows/twoslash-repros.yaml b/.github/workflows/twoslash-repros.yaml index bafe8950f..c11f4a9c1 100644 --- a/.github/workflows/twoslash-repros.yaml +++ b/.github/workflows/twoslash-repros.yaml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. - if: ${{ !github.event.inputs.bisect }} uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - uses: microsoft/TypeScript-Twoslash-Repro-Action@80178415feb0ebd3ed88d09e263a7cb8c8d6e1d2 # master with: github-token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/update-package-lock.yaml b/.github/workflows/update-package-lock.yaml index 5b0613cc3..ef83b693f 100644 --- a/.github/workflows/update-package-lock.yaml +++ b/.github/workflows/update-package-lock.yaml @@ -1,52 +1,53 @@ -name: Update package-lock.json - -on: - schedule: - # This is probably 6am UTC, which is 10pm PST or 11pm PDT - # Alternatively, 6am local is also fine - - cron: '0 6 * * *' - workflow_dispatch: {} - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - if: github.repository == 'microsoft/TypeScript' - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 - with: - node-version: 16 - - run: | - npm --version - # corepack enable npm - npm install -g $(jq -r '.packageManager' < package.json) - npm --version - - - name: Update package-lock.json and push - run: | - rm package-lock.json - npm install - - if git diff --exit-code --name-only package-lock.json; then - echo "No change." - else - npm test - npx hereby LKG - git config user.email "[email protected]" - git config user.name "TypeScript Bot" - git add -f package-lock.json - git commit -m "Update package-lock.json" - git push - fi +name: Update package-lock.json + +on: + schedule: + # This is probably 6am UTC, which is 10pm PST or 11pm PDT + # Alternatively, 6am local is also fine + - cron: '0 6 * * *' + workflow_dispatch: {} + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript' + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} + - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + with: + node-version: '*' + check-latest: true + - run: | + npm --version + # corepack enable npm + npm install -g $(jq -r '.packageManager' < package.json) + npm --version + + - name: Update package-lock.json and push + run: | + rm package-lock.json + npm install + + if git diff --exit-code --name-only package-lock.json; then + echo "No change." + else + npm test + npx hereby LKG + git config user.email "[email protected]" + git config user.name "TypeScript Bot" + git add -f package-lock.json + git commit -m "Update package-lock.json" + git push + fi diff --git a/.gulp.js b/.gulp.js index 009d8b66a..b167b3a36 100644 --- a/.gulp.js +++ b/.gulp.js @@ -1,14 +1,8 @@ const cp = require("child_process"); const path = require("path"); -const chalk = require("chalk"); const argv = process.argv.slice(2); -// --tasks-simple is used by VS Code to infer a task list; try and keep that working. -if (!argv.includes("--tasks-simple")) { - console.error(chalk.yellowBright("Warning: using gulp shim; please consider running hereby directly.")); -} - const args = [ ...process.execArgv, path.join(__dirname, "node_modules", "hereby", "bin", "hereby.js"), diff --git a/package-lock.json b/package-lock.json index 669a85602..4e5578da6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "chalk": "^4.1.2", "chokidar": "^3.5.3", "diff": "^5.1.0", - "dprint": "^0.42.3", + "dprint": "^0.45.0", "esbuild": "^0.19.0", "eslint": "^8.22.0", "eslint-formatter-autolinkable-stylish": "^1.2.0", @@ -52,7 +52,7 @@ "playwright": "^1.38.0", "source-map-support": "^0.5.21", "tslib": "^2.5.0", - "typescript": "^5.3.2", + "typescript": "5.4.0-dev.20231206", "which": "^2.0.2" }, "engines": { @@ -75,9 +75,9 @@ "dev": true }, "node_modules/@dprint/darwin-arm64": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/darwin-arm64/-/darwin-arm64-0.42.5.tgz", - "integrity": "sha512-3bBBlaAXQ9WTC+jvd2/iyj7cVp0G58/v5R7+YADUl5K9xF+Ah+xLFm6xw4Iwq+zsYaWDimRmLnM5iRSJC9qv1Q==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/darwin-arm64/-/darwin-arm64-0.45.0.tgz", + "integrity": "sha512-pkSSmixIKXr5t32bhXIUbpIBm8F8uhsJcUUvfkFNsRbQvNwRp71ribZpE8dKl0ZFOlAFeWD6WLE8smp/QtiGUA==", "cpu": [ "arm64" ], @@ -88,9 +88,9 @@ ] }, "node_modules/@dprint/darwin-x64": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/darwin-x64/-/darwin-x64-0.42.5.tgz", - "integrity": "sha512-gwx6lODOckU3xGv0zVFad/SMMtwBleiBAzm3UVw/WkGiCVo3XrIZ6EdLr4zCmB4A2R+SOxODU70WtONCF0dGnQ==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/darwin-x64/-/darwin-x64-0.45.0.tgz", + "integrity": "sha512-PHcXSrRO53KH9N+YPbPtr40NnDo2t7hO7KLMfl2ktRNLjrmKg6F8XDDsr2C7Z11k3jyEEU2Jq8hhpaKHwNapmQ==", "cpu": [ "x64" ], @@ -101,9 +101,9 @@ ] }, "node_modules/@dprint/linux-arm64-glibc": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-glibc/-/linux-arm64-glibc-0.42.5.tgz", - "integrity": "sha512-ijJm+zOxHK3Chnis3y5kVzvBr21Ugyodqpz1chClNWkaR+0/BYDik+lxZVrbxZw8gxqPu8iisOceCQQC42Bkzg==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-glibc/-/linux-arm64-glibc-0.45.0.tgz", + "integrity": "sha512-NgIpvZHpiQaY4DxSygxknxBtvKE2KLK9dEbUNKNE098yTHhGq7ouPsoM7RtsO34RHJ3tEZLLJEuBHn20XP8LMg==", "cpu": [ "arm64" ], @@ -114,9 +114,9 @@ ] }, "node_modules/@dprint/linux-arm64-musl": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-musl/-/linux-arm64-musl-0.42.5.tgz", - "integrity": "sha512-OLbJgv14AvJRVBi+ZCXBH0rsMSIdCZi/z1hCTRUb901VB2OVf81k5vvBn7HS5S9wMQ2HIG8GFOyckBg0qhEgAQ==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-musl/-/linux-arm64-musl-0.45.0.tgz", + "integrity": "sha512-Y8p+FC0RNyKCGQjy99Uh1LSPrlQtUTvo4brdvU1THF3pyWu6Bg1p6NiP5a6SjE/6t9CMKZJz39zPreQtnDkSDA==", "cpu": [ "arm64" ], @@ -127,9 +127,9 @@ ] }, "node_modules/@dprint/linux-x64-glibc": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/linux-x64-glibc/-/linux-x64-glibc-0.42.5.tgz", - "integrity": "sha512-tWh1kMbTi/lxS6hQJCDnriZonzGYN6FcN2AqF1C/TdRNjacFVvQnxZTdHPLJbgw0mSujHPinl3NtvllZ9CwVqA==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/linux-x64-glibc/-/linux-x64-glibc-0.45.0.tgz", + "integrity": "sha512-u03NCZIpJhE5gIl9Q7jNL4sOPBFd/8BLVBiuLoLtbiTZQ+NNudHKgGNATJBU67q1MKpqKnt8/gQm139cJkHhrw==", "cpu": [ "x64" ], @@ -140,9 +140,9 @@ ] }, "node_modules/@dprint/linux-x64-musl": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/linux-x64-musl/-/linux-x64-musl-0.42.5.tgz", - "integrity": "sha512-GObJlhUqQpaXKRMTUUEkdYgWgS1aVyMUQZFn3dBmLycl4F2gXWxKgYB6R47ESVeejsEvE9fTTuxlpK6fOHjaKQ==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/linux-x64-musl/-/linux-x64-musl-0.45.0.tgz", + "integrity": "sha512-DQN8LPtxismkeU1X+sQywa80kWwCBcpQh9fXoJcvTEHrgzHBqbG2SEsUZpM12oKEua1KE/iBh+vgZ+4I3TdI2A==", "cpu": [ "x64" ], @@ -153,9 +153,9 @@ ] }, "node_modules/@dprint/win32-x64": { - "version": "0.42.5", - "resolved": "https://registry.npmjs.org/@dprint/win32-x64/-/win32-x64-0.42.5.tgz", - "integrity": "sha512-N2N1FlmbEFbH/WqoKGdsZplBpfq9qdhfkJHQH1poVG3KxqT0dq01oqAfnC3ZQaSBoBrBfp5GyRtj7KwCxdqxXA==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@dprint/win32-x64/-/win32-x64-0.45.0.tgz", + "integrity": "sha512-aZHIWG2jIlEp4BER1QG6YYqPd6TxT9S77AeUkWJixNiMEo+33mPRVCBcugRWI/WJWveX8yWFVXkToORtnSFeEA==", "cpu": [ "x64" ], @@ -165,10 +165,26 @@ "win32" ] }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.11.tgz", + "integrity": "sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@esbuild/android-arm": { - "version": "0.19.8", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.8.tgz", - "integrity": "sha512-31E2lxlGM1KEfivQl8Yf5aYU/mflz9g06H6S15ITUFQueMFtFjESRMoDSkvMo8thYvLBax+VKTPlpnx+sPicOA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.11.tgz", + "integrity": "sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==", "cpu": [ "arm" ], @@ -182,9 +198,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.19.8", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.8.tgz", - "integrity": "sha512-B8JbS61bEunhfx8kasogFENgQfr/dIp+ggYXwTqdbMAgGDhRa3AaPpQMuQU0rNxDLECj6FhDzk1cF9WHMVwrtA==", + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.11.tgz", + "integrity": "sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==", "cpu": [ "arm64" ], @@ -198,9 +214,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.19.8", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.8.tgz", - …
@typescript-bot run dt |
Heya @weswigham, I've started to run the public perf test suite on this PR at da1c5a8. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at da1c5a8. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at da1c5a8. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the tarball bundle task on this PR at da1c5a8. You can monitor the build here. |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
Hey @weswigham, the results of running the DT tests are ready. |
@weswigham Here are the results of running the top-repos suite comparing Something interesting changed - please have a look. Details
|
Fixes #49989
Rebased/updated version of PR #50586
This is an updated version of my old PR (#50586), which is now rebased on top of the latest
main
branch. I've applied @weswigham's comment (here) on this PR.