mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'main' into fix11498
# Conflicts: # src/compiler/diagnosticMessages.json # src/compiler/utilities.ts
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"reporter": ["lcovonly", "cobertura"],
|
||||
"reporter": ["lcovonly", "cobertura", "v8", "codecov"],
|
||||
"src": "src",
|
||||
"include": ["src/**", "built/local/**"],
|
||||
"exclude": ["**/node_modules/**"],
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@
|
||||
// Note: if adding new languages, make sure settings.template.json is updated too.
|
||||
// Also, if updating typescript, update the one in package.json.
|
||||
"plugins": [
|
||||
"https://plugins.dprint.dev/typescript-0.91.1.wasm",
|
||||
"https://plugins.dprint.dev/typescript-0.91.6.wasm",
|
||||
"https://plugins.dprint.dev/json-0.19.3.wasm",
|
||||
"https://plugins.dprint.dev/prettier-0.40.0.json@68c668863ec834d4be0f6f5ccaab415df75336a992aceb7eeeb14fdf096a9e9c"
|
||||
"https://plugins.dprint.dev/prettier-0.46.1.json@e5bd083088a8dfc6e5ce2d3c9bee81489b065bd5345ef55b59f5d96627928b7a"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ body:
|
||||
|
||||
Please keep and fill in the line that best applies.
|
||||
value: |
|
||||
- This is a crash
|
||||
- This changed between versions ______ and _______
|
||||
- This changed in commit or PR _______
|
||||
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
comment: false
|
||||
|
||||
coverage:
|
||||
precision: 5
|
||||
status:
|
||||
patch:
|
||||
default:
|
||||
informational: true
|
||||
project:
|
||||
default:
|
||||
informational: true
|
||||
|
||||
github_checks:
|
||||
annotations: false
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
|
||||
|
||||
+55
-33
@@ -37,7 +37,7 @@ jobs:
|
||||
bundle:
|
||||
- 'true'
|
||||
include:
|
||||
- node-version: '*'
|
||||
- node-version: 'lts/*'
|
||||
bundle: false
|
||||
os: ubuntu-latest
|
||||
exclude:
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- name: Use node version ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
check-latest: true
|
||||
@@ -69,15 +69,46 @@ jobs:
|
||||
git add tests/baselines/reference
|
||||
git diff --staged --exit-code
|
||||
|
||||
coverage:
|
||||
runs-on:
|
||||
- 'self-hosted'
|
||||
- '1ES.Pool=TypeScript-1ES-GitHub-Large'
|
||||
- '1ES.ImageOverride=ubuntu-22.04'
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Run tests with coverage
|
||||
run: npm test -- --no-lint --coverage
|
||||
|
||||
- name: Upload coverage artifact
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
|
||||
- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
|
||||
with:
|
||||
use_oidc: true
|
||||
disable_search: true
|
||||
files: ./coverage/codecov.json
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Linter
|
||||
@@ -88,10 +119,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Unused exports
|
||||
@@ -102,10 +132,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
||||
@@ -123,10 +152,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Installing browsers
|
||||
@@ -140,10 +168,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Build src
|
||||
@@ -155,10 +182,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
npm --version
|
||||
# corepack enable npm
|
||||
@@ -204,10 +230,9 @@ jobs:
|
||||
path: base
|
||||
ref: ${{ github.base_ref }}
|
||||
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
npm --version
|
||||
# corepack enable npm
|
||||
@@ -238,10 +263,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Build scripts
|
||||
@@ -255,10 +279,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Build tsc
|
||||
@@ -275,10 +298,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: npm ci
|
||||
|
||||
- name: Remove all baselines
|
||||
@@ -312,7 +334,7 @@ jobs:
|
||||
|
||||
- name: Upload baseline diff artifact
|
||||
if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }}
|
||||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
with:
|
||||
name: fix_baselines.patch
|
||||
path: fix_baselines.patch
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
|
||||
uses: github/codeql-action/init@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
|
||||
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@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
|
||||
uses: github/codeql-action/autobuild@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
|
||||
|
||||
# ℹ️ 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@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
|
||||
uses: github/codeql-action/analyze@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
# Use NODE_AUTH_TOKEN environment variable to authenticate to this registry.
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ inputs.branch_name }}
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
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@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
# Use NODE_AUTH_TOKEN environment variable to authenticate to this registry.
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
npm pack ./
|
||||
mv typescript-*.tgz typescript.tgz
|
||||
- name: Upload built tarfile
|
||||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
with:
|
||||
name: tgz
|
||||
path: typescript.tgz
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Run analysis'
|
||||
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -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@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
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@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
|
||||
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ inputs.branch_name }}
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
|
||||
@@ -55,7 +55,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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: microsoft/TypeScript-Twoslash-Repro-Action@8680b5b290d48a7badbc7ba65971d526c61b86b8 # master
|
||||
|
||||
@@ -25,10 +25,9 @@ jobs:
|
||||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||
with:
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
node-version: 'lts/*'
|
||||
- run: |
|
||||
npm --version
|
||||
# corepack enable npm
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
"ignore": [
|
||||
"scripts/failed-tests.d.cts"
|
||||
],
|
||||
"ignoreDependencies": ["c8", "eslint-formatter-autolinkable-stylish", "mocha-fivemat-progress-reporter"],
|
||||
"ignoreDependencies": ["c8", "eslint-formatter-autolinkable-stylish", "mocha-fivemat-progress-reporter", "monocart-coverage-reports"],
|
||||
"ignoreExportsUsedInFile": {
|
||||
"enum": true,
|
||||
"interface": true,
|
||||
|
||||
Generated
+916
-834
File diff suppressed because it is too large
Load Diff
+18
-17
@@ -39,12 +39,12 @@
|
||||
"!**/.gitattributes"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@dprint/formatter": "^0.3.0",
|
||||
"@dprint/typescript": "0.91.1",
|
||||
"@dprint/formatter": "^0.4.1",
|
||||
"@dprint/typescript": "0.91.6",
|
||||
"@esfx/canceltoken": "^1.0.0",
|
||||
"@eslint/js": "^8.57.0",
|
||||
"@octokit/rest": "^21.0.0",
|
||||
"@types/chai": "^4.3.16",
|
||||
"@octokit/rest": "^21.0.1",
|
||||
"@types/chai": "^4.3.17",
|
||||
"@types/diff": "^5.2.1",
|
||||
"@types/minimist": "^1.2.5",
|
||||
"@types/mocha": "^10.0.7",
|
||||
@@ -52,33 +52,34 @@
|
||||
"@types/node": "latest",
|
||||
"@types/source-map-support": "^0.5.10",
|
||||
"@types/which": "^3.0.4",
|
||||
"@typescript-eslint/utils": "^7.14.1",
|
||||
"@typescript-eslint/utils": "^7.18.0",
|
||||
"azure-devops-node-api": "^14.0.1",
|
||||
"c8": "^10.1.2",
|
||||
"chai": "^4.4.1",
|
||||
"chai": "^4.5.0",
|
||||
"chalk": "^4.1.2",
|
||||
"chokidar": "^3.6.0",
|
||||
"diff": "^5.2.0",
|
||||
"dprint": "^0.46.3",
|
||||
"esbuild": "^0.22.0",
|
||||
"dprint": "^0.47.2",
|
||||
"esbuild": "^0.23.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-formatter-autolinkable-stylish": "^1.3.0",
|
||||
"fast-xml-parser": "^4.4.0",
|
||||
"glob": "^10.4.2",
|
||||
"globals": "^13.24.0",
|
||||
"hereby": "^1.8.9",
|
||||
"fast-xml-parser": "^4.4.1",
|
||||
"glob": "^10.4.5",
|
||||
"globals": "^15.9.0",
|
||||
"hereby": "^1.9.0",
|
||||
"jsonc-parser": "^3.3.1",
|
||||
"knip": "^5.25.1",
|
||||
"knip": "^5.27.0",
|
||||
"minimist": "^1.2.8",
|
||||
"mocha": "^10.5.2",
|
||||
"mocha": "^10.7.0",
|
||||
"mocha-fivemat-progress-reporter": "^0.1.0",
|
||||
"monocart-coverage-reports": "^2.10.0",
|
||||
"ms": "^2.1.3",
|
||||
"node-fetch": "^3.3.2",
|
||||
"playwright": "^1.45.0",
|
||||
"playwright": "^1.45.3",
|
||||
"source-map-support": "^0.5.21",
|
||||
"tslib": "^2.6.3",
|
||||
"typescript": "^5.5.2",
|
||||
"typescript-eslint": "^7.14.1",
|
||||
"typescript": "^5.5.4",
|
||||
"typescript-eslint": "^7.18.0",
|
||||
"which": "^3.0.1"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
+15
-4
@@ -32,7 +32,7 @@ export const coverageDir = "coverage";
|
||||
* @param {boolean} [options.watching]
|
||||
*/
|
||||
export async function runConsoleTests(runJs, defaultReporter, runInParallel, options = {}) {
|
||||
const testTimeout = cmdLineOptions.timeout;
|
||||
let testTimeout = cmdLineOptions.timeout;
|
||||
const tests = cmdLineOptions.tests;
|
||||
const skipSysTests = cmdLineOptions.skipSysTests;
|
||||
const inspect = cmdLineOptions.break || cmdLineOptions.inspect;
|
||||
@@ -45,6 +45,12 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
|
||||
const shards = +cmdLineOptions.shards || undefined;
|
||||
const shardId = +cmdLineOptions.shardId || undefined;
|
||||
const coverage = cmdLineOptions.coverage;
|
||||
|
||||
if (coverage && testTimeout) {
|
||||
testTimeout *= 2;
|
||||
console.log(chalk.yellowBright(`[coverage] doubling test timeout to ${testTimeout}ms...`));
|
||||
}
|
||||
|
||||
if (!cmdLineOptions.dirty) {
|
||||
if (options.watching) {
|
||||
console.log(chalk.yellowBright(`[watch] cleaning test directories...`));
|
||||
@@ -142,9 +148,14 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
|
||||
process.env.NODE_V8_COVERAGE = path.resolve(coverageDir, "tmp");
|
||||
}
|
||||
|
||||
await exec(process.execPath, args, { token: options.token });
|
||||
if (coverage) {
|
||||
await exec("npm", ["--prefer-offline", "exec", "--", "c8", "report"], { token: options.token });
|
||||
try {
|
||||
await exec(process.execPath, args, { token: options.token });
|
||||
}
|
||||
finally {
|
||||
// Calculate coverage even if tests failed.
|
||||
if (coverage) {
|
||||
await exec("npm", ["--prefer-offline", "exec", "--", "c8", "report", "--experimental-monocart"], { token: options.token });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
@@ -508,7 +508,7 @@ formatter.setConfig({
|
||||
* @returns {string}
|
||||
*/
|
||||
function dprint(contents) {
|
||||
const result = formatter.formatText("dummy.d.ts", contents);
|
||||
const result = formatter.formatText({ filePath: "dummy.d.ts", fileText: contents });
|
||||
return result.replace(/\r\n/g, "\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ export * from "../transformers/generators.js";
|
||||
export * from "../transformers/module/module.js";
|
||||
export * from "../transformers/module/system.js";
|
||||
export * from "../transformers/module/esnextAnd2015.js";
|
||||
export * from "../transformers/module/node.js";
|
||||
export * from "../transformers/module/impliedNodeFormatDependent.js";
|
||||
export * from "../transformers/declarations/diagnostics.js";
|
||||
export * from "../transformers/declarations.js";
|
||||
export * from "../transformer.js";
|
||||
|
||||
+12
-6
@@ -21,6 +21,7 @@ import {
|
||||
concatenate,
|
||||
convertToOptionsWithAbsolutePaths,
|
||||
createGetCanonicalFileName,
|
||||
createModeMismatchDetails,
|
||||
createModuleNotFoundChain,
|
||||
createProgram,
|
||||
CustomTransformers,
|
||||
@@ -70,7 +71,6 @@ import {
|
||||
ReadBuildProgramHost,
|
||||
ReadonlyCollection,
|
||||
RepopulateDiagnosticChainInfo,
|
||||
RepopulateModuleNotFoundDiagnosticChain,
|
||||
returnFalse,
|
||||
returnUndefined,
|
||||
sameMap,
|
||||
@@ -111,8 +111,8 @@ export interface ReusableDiagnosticRelatedInformation {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface ReusableRepopulateModuleNotFoundChain {
|
||||
info: RepopulateModuleNotFoundDiagnosticChain;
|
||||
export interface ReusableRepopulateInfoChain {
|
||||
info: RepopulateDiagnosticChainInfo;
|
||||
next?: ReusableDiagnosticMessageChain[];
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ export type SerializedDiagnosticMessageChain = Omit<DiagnosticMessageChain, "nex
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export type ReusableDiagnosticMessageChain = SerializedDiagnosticMessageChain | ReusableRepopulateModuleNotFoundChain;
|
||||
export type ReusableDiagnosticMessageChain = SerializedDiagnosticMessageChain | ReusableRepopulateInfoChain;
|
||||
|
||||
/**
|
||||
* Signature (Hash of d.ts emitted), is string if it was emitted using same d.ts.map option as what compilerOptions indicate, otherwise tuple of string
|
||||
@@ -538,7 +538,13 @@ function convertOrRepopulateDiagnosticMessageChain<T extends DiagnosticMessageCh
|
||||
repopulateInfo: (chain: T) => RepopulateDiagnosticChainInfo | undefined,
|
||||
): DiagnosticMessageChain {
|
||||
const info = repopulateInfo(chain);
|
||||
if (info) {
|
||||
if (info === true) {
|
||||
return {
|
||||
...createModeMismatchDetails(sourceFile!),
|
||||
next: convertOrRepopulateDiagnosticMessageChainArray(chain.next as T[], sourceFile, newProgram, repopulateInfo),
|
||||
};
|
||||
}
|
||||
else if (info) {
|
||||
return {
|
||||
...createModuleNotFoundChain(sourceFile!, newProgram, info.moduleReference, info.mode, info.packageName || info.moduleReference),
|
||||
next: convertOrRepopulateDiagnosticMessageChainArray(chain.next as T[], sourceFile, newProgram, repopulateInfo),
|
||||
@@ -600,7 +606,7 @@ function convertToDiagnosticRelatedInformation(
|
||||
file: sourceFile,
|
||||
messageText: isString(diagnostic.messageText) ?
|
||||
diagnostic.messageText :
|
||||
convertOrRepopulateDiagnosticMessageChain(diagnostic.messageText, sourceFile, newProgram, chain => (chain as ReusableRepopulateModuleNotFoundChain).info),
|
||||
convertOrRepopulateDiagnosticMessageChain(diagnostic.messageText, sourceFile, newProgram, chain => (chain as ReusableRepopulateInfoChain).info),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
computeSignatureWithDiagnostics,
|
||||
CustomTransformers,
|
||||
Debug,
|
||||
EmitOnly,
|
||||
EmitOutput,
|
||||
emptyArray,
|
||||
GetCanonicalFileName,
|
||||
@@ -418,7 +419,7 @@ export namespace BuilderState {
|
||||
);
|
||||
},
|
||||
cancellationToken,
|
||||
/*emitOnly*/ true,
|
||||
EmitOnly.BuilderSignature,
|
||||
/*customTransformers*/ undefined,
|
||||
/*forceDtsEmit*/ true,
|
||||
);
|
||||
|
||||
+694
-319
File diff suppressed because it is too large
Load Diff
@@ -236,6 +236,7 @@ const libEntries: [string, string][] = [
|
||||
["esnext.array", "lib.esnext.array.d.ts"],
|
||||
["esnext.regexp", "lib.esnext.regexp.d.ts"],
|
||||
["esnext.string", "lib.esnext.string.d.ts"],
|
||||
["esnext.iterator", "lib.esnext.iterator.d.ts"],
|
||||
["decorators", "lib.decorators.d.ts"],
|
||||
["decorators.legacy", "lib.decorators.legacy.d.ts"],
|
||||
];
|
||||
@@ -258,6 +259,8 @@ export const libs = libEntries.map(entry => entry[0]);
|
||||
export const libMap = new Map(libEntries);
|
||||
|
||||
// Watch related options
|
||||
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal */
|
||||
export const optionsForWatch: CommandLineOption[] = [
|
||||
{
|
||||
@@ -467,7 +470,6 @@ export const commonOptionsWithBuild: CommandLineOption[] = [
|
||||
affectsBuildInfo: true,
|
||||
showInSimplifiedHelpView: true,
|
||||
category: Diagnostics.Emit,
|
||||
transpileOptionValue: undefined,
|
||||
defaultValueDescription: false,
|
||||
description: Diagnostics.Create_sourcemaps_for_d_ts_files,
|
||||
},
|
||||
@@ -795,6 +797,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
type: "boolean",
|
||||
affectsEmit: true,
|
||||
affectsBuildInfo: true,
|
||||
affectsSourceFile: true,
|
||||
category: Diagnostics.Emit,
|
||||
description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
|
||||
defaultValueDescription: false,
|
||||
@@ -914,6 +917,16 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
|
||||
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
|
||||
},
|
||||
{
|
||||
name: "strictBuiltinIteratorReturn",
|
||||
type: "boolean",
|
||||
affectsSemanticDiagnostics: true,
|
||||
affectsBuildInfo: true,
|
||||
strictFlag: true,
|
||||
category: Diagnostics.Type_Checking,
|
||||
description: Diagnostics.Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any,
|
||||
defaultValueDescription: Diagnostics.false_unless_strict_is_set,
|
||||
},
|
||||
{
|
||||
name: "noImplicitThis",
|
||||
type: "boolean",
|
||||
@@ -1191,6 +1204,15 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
category: Diagnostics.Modules,
|
||||
description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports,
|
||||
},
|
||||
{
|
||||
name: "noUncheckedSideEffectImports",
|
||||
type: "boolean",
|
||||
affectsSemanticDiagnostics: true,
|
||||
affectsBuildInfo: true,
|
||||
category: Diagnostics.Modules,
|
||||
description: Diagnostics.Check_side_effect_imports,
|
||||
defaultValueDescription: false,
|
||||
},
|
||||
|
||||
// Source Maps
|
||||
{
|
||||
@@ -1265,6 +1287,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
affectsEmit: true,
|
||||
affectsBuildInfo: true,
|
||||
affectsModuleResolution: true,
|
||||
affectsSourceFile: true,
|
||||
category: Diagnostics.Language_and_Environment,
|
||||
description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
|
||||
defaultValueDescription: "react",
|
||||
@@ -1598,6 +1621,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
},
|
||||
];
|
||||
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal */
|
||||
export const optionDeclarations: CommandLineOption[] = [
|
||||
...commonOptionsWithBuild,
|
||||
@@ -1681,6 +1705,7 @@ export const buildOpts: CommandLineOption[] = [
|
||||
...optionsForBuild,
|
||||
];
|
||||
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal */
|
||||
export const typeAcquisitionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
@@ -1743,7 +1768,9 @@ const compilerOptionsAlternateMode: AlternateModeDiagnostics = {
|
||||
getOptionsNameMap: getBuildOptionsNameMap,
|
||||
};
|
||||
|
||||
const defaultInitCompilerOptions: CompilerOptions = {
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal @knipignore */
|
||||
export const defaultInitCompilerOptions: CompilerOptions = {
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES2016,
|
||||
strict: true,
|
||||
|
||||
+14
-30
@@ -396,7 +396,7 @@ export function flatten<T>(array: T[][] | readonly (T | readonly T[] | undefined
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function flatMap<T, U>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[] {
|
||||
export function flatMap<T, U extends {}>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[] {
|
||||
let result: U[] | undefined;
|
||||
if (array !== undefined) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@@ -806,7 +806,7 @@ export function sortAndDeduplicate(array: readonly string[]): SortedReadonlyArra
|
||||
export function sortAndDeduplicate<T>(array: readonly T[], comparer: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T>;
|
||||
/** @internal */
|
||||
export function sortAndDeduplicate<T>(array: readonly T[], comparer?: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T> {
|
||||
return deduplicateSorted(sort(array, comparer), equalityComparer ?? comparer ?? compareStringsCaseSensitive as any as Comparer<T>);
|
||||
return deduplicateSorted(toSorted(array, comparer), equalityComparer ?? comparer ?? compareStringsCaseSensitive as any as Comparer<T>);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -917,18 +917,13 @@ export function relativeComplement<T>(arrayA: T[] | undefined, arrayB: T[] | und
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function append<TArray extends any[] | undefined, TValue extends NonNullable<TArray>[number] | undefined>(to: TArray, value: TValue): [undefined, undefined] extends [TArray, TValue] ? TArray : NonNullable<TArray>[number][];
|
||||
export function append<T extends {}>(to: T[], value: T | undefined): T[];
|
||||
/** @internal */
|
||||
export function append<T>(to: T[], value: T | undefined): T[];
|
||||
export function append<T extends {}>(to: T[] | undefined, value: T): T[];
|
||||
/** @internal */
|
||||
export function append<T>(to: T[] | undefined, value: T): T[];
|
||||
/** @internal */
|
||||
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined;
|
||||
/** @internal */
|
||||
export function append<T>(to: T[], value: T | undefined): void;
|
||||
/** @internal */
|
||||
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined {
|
||||
if (value === undefined) return to as T[];
|
||||
export function append<T extends {}>(to: T[] | undefined, value: T | undefined): T[] | undefined;
|
||||
export function append<T extends {}>(to: T[] | undefined, value: T | undefined): T[] | undefined {
|
||||
if (value === undefined) return to;
|
||||
if (to === undefined) return [value];
|
||||
to.push(value);
|
||||
return to;
|
||||
@@ -948,13 +943,13 @@ export function append<T>(to: T[] | undefined, value: T | undefined): T[] | unde
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function combine<T>(xs: T[] | undefined, ys: T[] | undefined): T[] | undefined;
|
||||
export function combine<T extends {}>(xs: T[] | undefined, ys: T[] | undefined): T[] | undefined;
|
||||
/** @internal */
|
||||
export function combine<T>(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined;
|
||||
export function combine<T extends {}>(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined;
|
||||
/** @internal */
|
||||
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined;
|
||||
export function combine<T extends {}>(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined;
|
||||
/** @internal */
|
||||
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined) {
|
||||
export function combine<T extends {}>(xs: T | T[] | undefined, ys: T | T[] | undefined) {
|
||||
if (xs === undefined) return ys;
|
||||
if (ys === undefined) return xs;
|
||||
if (isArray(xs)) return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
|
||||
@@ -1035,12 +1030,12 @@ function stableSortIndices<T>(array: readonly T[], indices: number[], comparer:
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new sorted array.
|
||||
* Returns a new sorted array. This sort is stable, meaning elements equal to each other maintain their relative position in the array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function sort<T>(array: readonly T[], comparer?: Comparer<T>): SortedReadonlyArray<T> {
|
||||
return (array.length === 0 ? array : array.slice().sort(comparer)) as SortedReadonlyArray<T>;
|
||||
export function toSorted<T>(array: readonly T[], comparer?: Comparer<T>): SortedReadonlyArray<T> {
|
||||
return (array.length === 0 ? emptyArray : array.slice().sort(comparer)) as readonly T[] as SortedReadonlyArray<T>;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -1050,17 +1045,6 @@ export function* arrayReverseIterator<T>(array: readonly T[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stable sort of an array. Elements equal to each other maintain their relative position in the array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function stableSort<T>(array: readonly T[], comparer: Comparer<T>): SortedReadonlyArray<T> {
|
||||
const indices = indicesOf(array);
|
||||
stableSortIndices(array, indices, comparer);
|
||||
return indices.map(i => array[i]) as SortedArray<T> as SortedReadonlyArray<T>;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function rangeEquals<T>(array1: readonly T[], array2: readonly T[], pos: number, end: number) {
|
||||
while (pos < end) {
|
||||
|
||||
@@ -79,11 +79,11 @@ import {
|
||||
SignatureFlags,
|
||||
SnippetKind,
|
||||
SortedReadonlyArray,
|
||||
stableSort,
|
||||
Symbol,
|
||||
SymbolFlags,
|
||||
symbolName,
|
||||
SyntaxKind,
|
||||
toSorted,
|
||||
TransformFlags,
|
||||
Type,
|
||||
TypeFacts,
|
||||
@@ -436,7 +436,7 @@ export namespace Debug {
|
||||
}
|
||||
}
|
||||
|
||||
const sorted = stableSort<[number, string]>(result, (x, y) => compareValues(x[0], y[0]));
|
||||
const sorted = toSorted<[number, string]>(result, (x, y) => compareValues(x[0], y[0]));
|
||||
enumMemberCache.set(enumObject, sorted);
|
||||
return sorted;
|
||||
}
|
||||
|
||||
@@ -967,10 +967,14 @@
|
||||
"category": "Error",
|
||||
"code": 1292
|
||||
},
|
||||
"'deferred' modifier can only appear on a parameter declaration.": {
|
||||
"ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'.": {
|
||||
"category": "Error",
|
||||
"code": 1293
|
||||
},
|
||||
"'deferred' modifier can only appear on a parameter declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1294
|
||||
},
|
||||
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
@@ -1805,6 +1809,19 @@
|
||||
"category": "Error",
|
||||
"code": 1537
|
||||
},
|
||||
"Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set.": {
|
||||
"category": "Error",
|
||||
"code": 1538
|
||||
},
|
||||
"A 'bigint' literal cannot be used as a property name.": {
|
||||
"category": "Error",
|
||||
"code": 1539
|
||||
},
|
||||
"A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.": {
|
||||
"category": "Suggestion",
|
||||
"code": 1540,
|
||||
"reportsDeprecated": true
|
||||
},
|
||||
|
||||
"The types of '{0}' are incompatible between these types.": {
|
||||
"category": "Error",
|
||||
@@ -2684,10 +2701,6 @@
|
||||
"category": "Error",
|
||||
"code": 2524
|
||||
},
|
||||
"Initializer provides no value for this binding element and the binding element has no default value.": {
|
||||
"category": "Error",
|
||||
"code": 2525
|
||||
},
|
||||
"A 'this' type is available only in a non-static member of a class or interface.": {
|
||||
"category": "Error",
|
||||
"code": 2526
|
||||
@@ -3911,10 +3924,30 @@
|
||||
"category": "Error",
|
||||
"code": 2868
|
||||
},
|
||||
"A 'deferred' parameter must have a type that permits functions.": {
|
||||
"Right operand of ?? is unreachable because the left operand is never nullish.": {
|
||||
"category": "Error",
|
||||
"code": 2869
|
||||
},
|
||||
"This binary expression is never nullish. Are you missing parentheses?": {
|
||||
"category": "Error",
|
||||
"code": 2870
|
||||
},
|
||||
"This expression is always nullish.": {
|
||||
"category": "Error",
|
||||
"code": 2871
|
||||
},
|
||||
"This kind of expression is always truthy.": {
|
||||
"category": "Error",
|
||||
"code": 2872
|
||||
},
|
||||
"This kind of expression is always falsy.": {
|
||||
"category": "Error",
|
||||
"code": 2873
|
||||
},
|
||||
"A 'deferred' parameter must have a type that permits functions.": {
|
||||
"category": "Error",
|
||||
"code": 2874
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -4220,7 +4253,7 @@
|
||||
"category": "Error",
|
||||
"code": 4092
|
||||
},
|
||||
"Property '{0}' of exported class expression may not be private or protected.": {
|
||||
"Property '{0}' of exported anonymous class type may not be private or protected.": {
|
||||
"category": "Error",
|
||||
"code": 4094
|
||||
},
|
||||
@@ -5121,10 +5154,6 @@
|
||||
"category": "Message",
|
||||
"code": 6144
|
||||
},
|
||||
"Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified.": {
|
||||
"category": "Message",
|
||||
"code": 6145
|
||||
},
|
||||
"Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.": {
|
||||
"category": "Message",
|
||||
"code": 6146
|
||||
@@ -6380,6 +6409,10 @@
|
||||
"code": 6719
|
||||
},
|
||||
|
||||
"Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'.": {
|
||||
"category": "Message",
|
||||
"code": 6720
|
||||
},
|
||||
"Default catch clause variables as 'unknown' instead of 'any'.": {
|
||||
"category": "Message",
|
||||
"code": 6803
|
||||
@@ -6392,6 +6425,10 @@
|
||||
"category": "Message",
|
||||
"code": 6805
|
||||
},
|
||||
"Check side effect imports.": {
|
||||
"category": "Message",
|
||||
"code": 6806
|
||||
},
|
||||
|
||||
"one of:": {
|
||||
"category": "Message",
|
||||
|
||||
@@ -131,6 +131,7 @@ import {
|
||||
getEmitFlags,
|
||||
getEmitHelpers,
|
||||
getEmitModuleKind,
|
||||
getEmitModuleResolutionKind,
|
||||
getEmitScriptTarget,
|
||||
getExternalModuleName,
|
||||
getIdentifierTypeArguments,
|
||||
@@ -373,7 +374,6 @@ import {
|
||||
SourceMapSource,
|
||||
SpreadAssignment,
|
||||
SpreadElement,
|
||||
stableSort,
|
||||
Statement,
|
||||
StringLiteral,
|
||||
supportedJSExtensionsFlat,
|
||||
@@ -393,6 +393,7 @@ import {
|
||||
ThrowStatement,
|
||||
TokenFlags,
|
||||
tokenToString,
|
||||
toSorted,
|
||||
tracing,
|
||||
TransformationResult,
|
||||
transformNodes,
|
||||
@@ -828,6 +829,7 @@ export function emitFiles(
|
||||
newLine: compilerOptions.newLine,
|
||||
noEmitHelpers: compilerOptions.noEmitHelpers,
|
||||
module: getEmitModuleKind(compilerOptions),
|
||||
moduleResolution: getEmitModuleResolutionKind(compilerOptions),
|
||||
target: getEmitScriptTarget(compilerOptions),
|
||||
sourceMap: compilerOptions.sourceMap,
|
||||
inlineSourceMap: compilerOptions.inlineSourceMap,
|
||||
@@ -903,8 +905,9 @@ export function emitFiles(
|
||||
newLine: compilerOptions.newLine,
|
||||
noEmitHelpers: true,
|
||||
module: compilerOptions.module,
|
||||
moduleResolution: compilerOptions.moduleResolution,
|
||||
target: compilerOptions.target,
|
||||
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
||||
sourceMap: emitOnly !== EmitOnly.BuilderSignature && compilerOptions.declarationMap,
|
||||
inlineSourceMap: compilerOptions.inlineSourceMap,
|
||||
extendedDiagnostics: compilerOptions.extendedDiagnostics,
|
||||
onlyPrintJsDocStyle: true,
|
||||
@@ -958,6 +961,7 @@ export function emitFiles(
|
||||
}
|
||||
|
||||
function markLinkedReferences(file: SourceFile) {
|
||||
if (ts.isSourceFileJS(file)) return; // JS files don't use reference calculations as they don't do import ellision, no need to calculate it
|
||||
ts.forEachChildRecursively(file, n => {
|
||||
if (isImportEqualsDeclaration(n) && !(ts.getSyntacticModifierFlags(n) & ts.ModifierFlags.Export)) return "skip"; // These are deferred and marked in a chain when referenced
|
||||
if (ts.isImportDeclaration(n)) return "skip"; // likewise, these are ultimately what get marked by calls on other nodes - we want to skip them
|
||||
@@ -2068,7 +2072,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
|
||||
function getSortedEmitHelpers(node: Node) {
|
||||
const helpers = getEmitHelpers(node);
|
||||
return helpers && stableSort(helpers, compareEmitHelpers);
|
||||
return helpers && toSorted(helpers, compareEmitHelpers);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -71,7 +71,6 @@ import {
|
||||
ReportEmitErrorSummary,
|
||||
SolutionBuilder,
|
||||
SolutionBuilderHostBase,
|
||||
sort,
|
||||
SourceFile,
|
||||
startsWith,
|
||||
startTracing,
|
||||
@@ -80,6 +79,7 @@ import {
|
||||
sys,
|
||||
System,
|
||||
toPath,
|
||||
toSorted,
|
||||
tracing,
|
||||
validateLocaleAndSetLanguage,
|
||||
version,
|
||||
@@ -170,7 +170,7 @@ function shouldBePretty(sys: System, options: CompilerOptions | BuildOptions) {
|
||||
function getOptionsForHelp(commandLine: ParsedCommandLine) {
|
||||
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
|
||||
return !!commandLine.options.all ?
|
||||
sort(optionDeclarations, (a, b) => compareStringsCaseInsensitive(a.name, b.name)) :
|
||||
toSorted(optionDeclarations, (a, b) => compareStringsCaseInsensitive(a.name, b.name)) :
|
||||
filter(optionDeclarations.slice(), v => !!v.showInSimplifiedHelpView);
|
||||
}
|
||||
|
||||
|
||||
@@ -6562,6 +6562,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
return updateSatisfiesExpression(outerExpression, expression, outerExpression.type);
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return updateNonNullExpression(outerExpression, expression);
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return updateExpressionWithTypeArguments(outerExpression, expression, outerExpression.typeArguments);
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
return updatePartiallyEmittedExpression(outerExpression, expression);
|
||||
}
|
||||
|
||||
@@ -51,10 +51,12 @@ import {
|
||||
getAllAccessorDeclarations,
|
||||
getEmitFlags,
|
||||
getEmitHelpers,
|
||||
getEmitModuleFormatOfFileWorker,
|
||||
getEmitModuleKind,
|
||||
getESModuleInterop,
|
||||
getExternalModuleName,
|
||||
getExternalModuleNameFromPath,
|
||||
getImpliedNodeFormatForEmitWorker,
|
||||
getJSDocType,
|
||||
getJSDocTypeTag,
|
||||
getModifiers,
|
||||
@@ -628,9 +630,10 @@ export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All):
|
||||
return (kinds & OuterExpressionKinds.Parentheses) !== 0;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.SatisfiesExpression:
|
||||
return (kinds & OuterExpressionKinds.TypeAssertions) !== 0;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (kinds & OuterExpressionKinds.ExpressionsWithTypeArguments) !== 0;
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return (kinds & OuterExpressionKinds.NonNullAssertions) !== 0;
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
@@ -687,7 +690,7 @@ export function createExternalHelpersImportDeclarationIfNeeded(nodeFactory: Node
|
||||
if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
||||
let namedBindings: NamedImportBindings | undefined;
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
if ((moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ModuleKind.ESNext) {
|
||||
if ((moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === ModuleKind.ESNext) {
|
||||
// use named imports
|
||||
const helpers = getEmitHelpers(sourceFile);
|
||||
if (helpers) {
|
||||
@@ -743,10 +746,8 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory: NodeFactory, node
|
||||
return externalHelpersModuleName;
|
||||
}
|
||||
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
let create = (hasExportStarsToExportValues || (getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault))
|
||||
&& moduleKind !== ModuleKind.System
|
||||
&& (moduleKind < ModuleKind.ES2015 || node.impliedNodeFormat === ModuleKind.CommonJS);
|
||||
&& getEmitModuleFormatOfFileWorker(node, compilerOptions) < ModuleKind.System;
|
||||
if (!create) {
|
||||
const helpers = getEmitHelpers(node);
|
||||
if (helpers) {
|
||||
|
||||
@@ -94,12 +94,12 @@ import {
|
||||
ResolvedTypeReferenceDirective,
|
||||
ResolvedTypeReferenceDirectiveWithFailedLookupLocations,
|
||||
some,
|
||||
sort,
|
||||
startsWith,
|
||||
supportedDeclarationExtensions,
|
||||
supportedJSExtensionsFlat,
|
||||
supportedTSImplementationExtensions,
|
||||
toPath,
|
||||
toSorted,
|
||||
tryExtractTSExtension,
|
||||
tryGetExtensionFromPath,
|
||||
tryParsePatterns,
|
||||
@@ -2382,17 +2382,11 @@ export interface PackageJsonInfoContents {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined {
|
||||
const parts = getPathComponents(fileName);
|
||||
parts.pop();
|
||||
while (parts.length > 0) {
|
||||
const pkg = getPackageJsonInfo(getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
|
||||
if (pkg) {
|
||||
return pkg;
|
||||
}
|
||||
parts.pop();
|
||||
}
|
||||
return undefined;
|
||||
export function getPackageScopeForPath(directory: string, state: ModuleResolutionState): PackageJsonInfo | undefined {
|
||||
return forEachAncestorDirectory(
|
||||
directory,
|
||||
dir => getPackageJsonInfo(dir, /*onlyRecordFailures*/ false, state),
|
||||
);
|
||||
}
|
||||
|
||||
function getVersionPathsOfPackageJsonInfo(packageJsonInfo: PackageJsonInfo, state: ModuleResolutionState): VersionPaths | undefined {
|
||||
@@ -2568,7 +2562,7 @@ function noKeyStartsWithDot(obj: MapLike<unknown>) {
|
||||
}
|
||||
|
||||
function loadModuleFromSelfNameReference(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
|
||||
const directoryPath = getNormalizedAbsolutePath(combinePaths(directory, "dummy"), state.host.getCurrentDirectory?.());
|
||||
const directoryPath = getNormalizedAbsolutePath(directory, state.host.getCurrentDirectory?.());
|
||||
const scope = getPackageScopeForPath(directoryPath, state);
|
||||
if (!scope || !scope.contents.packageJsonContent.exports) {
|
||||
return undefined;
|
||||
@@ -2649,7 +2643,7 @@ function loadModuleFromImports(extensions: Extensions, moduleName: string, direc
|
||||
}
|
||||
return toSearchResult(/*value*/ undefined);
|
||||
}
|
||||
const directoryPath = getNormalizedAbsolutePath(combinePaths(directory, "dummy"), state.host.getCurrentDirectory?.());
|
||||
const directoryPath = getNormalizedAbsolutePath(directory, state.host.getCurrentDirectory?.());
|
||||
const scope = getPackageScopeForPath(directoryPath, state);
|
||||
if (!scope) {
|
||||
if (state.traceEnabled) {
|
||||
@@ -2701,7 +2695,7 @@ function loadModuleFromImportsOrExports(extensions: Extensions, state: ModuleRes
|
||||
const target = (lookupTable as { [idx: string]: unknown; })[moduleName];
|
||||
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
|
||||
}
|
||||
const expandingKeys = sort(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => hasOneAsterisk(k) || endsWith(k, "/")), comparePatternKeys);
|
||||
const expandingKeys = toSorted(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => hasOneAsterisk(k) || endsWith(k, "/")), comparePatternKeys);
|
||||
for (const potentialTarget of expandingKeys) {
|
||||
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
||||
const target = (lookupTable as { [idx: string]: unknown; })[potentialTarget];
|
||||
|
||||
@@ -37,9 +37,9 @@ import {
|
||||
getBaseFileName,
|
||||
GetCanonicalFileName,
|
||||
getConditions,
|
||||
getDefaultResolutionModeForFileWorker,
|
||||
getDirectoryPath,
|
||||
getEmitModuleResolutionKind,
|
||||
getModeForResolutionAtIndex,
|
||||
getModuleNameStringLiteralAt,
|
||||
getModuleSpecifierEndingPreference,
|
||||
getNodeModulePathParts,
|
||||
@@ -143,12 +143,13 @@ export interface ModuleSpecifierPreferences {
|
||||
/**
|
||||
* @param syntaxImpliedNodeFormat Used when the import syntax implies ESM or CJS irrespective of the mode of the file.
|
||||
*/
|
||||
getAllowedEndingsInPreferredOrder(syntaxImpliedNodeFormat?: SourceFile["impliedNodeFormat"]): ModuleSpecifierEnding[];
|
||||
getAllowedEndingsInPreferredOrder(syntaxImpliedNodeFormat?: ResolutionMode): ModuleSpecifierEnding[];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getModuleSpecifierPreferences(
|
||||
{ importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences,
|
||||
host: Pick<ModuleSpecifierResolutionHost, "getDefaultResolutionModeForFile">,
|
||||
compilerOptions: CompilerOptions,
|
||||
importingSourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat">,
|
||||
oldImportSpecifier?: string,
|
||||
@@ -163,8 +164,10 @@ export function getModuleSpecifierPreferences(
|
||||
importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative :
|
||||
RelativePreference.Shortest,
|
||||
getAllowedEndingsInPreferredOrder: syntaxImpliedNodeFormat => {
|
||||
const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
||||
if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === ModuleKind.ESNext) {
|
||||
const impliedNodeFormat = getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions);
|
||||
const preferredEnding = syntaxImpliedNodeFormat !== impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
||||
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
||||
if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === ModuleKind.ESNext && ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext) {
|
||||
if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
|
||||
return [ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.JsExtension];
|
||||
}
|
||||
@@ -204,7 +207,7 @@ export function getModuleSpecifierPreferences(
|
||||
}
|
||||
return getModuleSpecifierEndingPreference(
|
||||
importModuleSpecifierEnding,
|
||||
resolutionMode ?? importingSourceFile.impliedNodeFormat,
|
||||
resolutionMode ?? getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions),
|
||||
compilerOptions,
|
||||
isFullSourceFile(importingSourceFile) ? importingSourceFile : undefined,
|
||||
);
|
||||
@@ -225,7 +228,7 @@ export function updateModuleSpecifier(
|
||||
oldImportSpecifier: string,
|
||||
options: ModuleSpecifierOptions = {},
|
||||
): string | undefined {
|
||||
const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options);
|
||||
const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getModuleSpecifierPreferences({}, host, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options);
|
||||
if (res === oldImportSpecifier) return undefined;
|
||||
return res;
|
||||
}
|
||||
@@ -245,7 +248,7 @@ export function getModuleSpecifier(
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
options: ModuleSpecifierOptions = {},
|
||||
): string {
|
||||
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile), {}, options);
|
||||
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getModuleSpecifierPreferences({}, host, compilerOptions, importingSourceFile), {}, options);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -275,7 +278,7 @@ function getModuleSpecifierWorker(
|
||||
const info = getInfo(importingSourceFileName, host);
|
||||
const modulePaths = getAllModulePaths(info, toFileName, host, userPreferences, compilerOptions, options);
|
||||
return firstDefined(modulePaths, modulePath => tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode)) ||
|
||||
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
||||
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions), preferences);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -403,7 +406,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
|
||||
compilerOptions,
|
||||
host,
|
||||
importMode,
|
||||
getModuleSpecifierPreferences({}, compilerOptions, importingFile),
|
||||
getModuleSpecifierPreferences({}, host, compilerOptions, importingFile),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -417,7 +420,7 @@ function computeModuleSpecifiers(
|
||||
forAutoImport: boolean,
|
||||
): ModuleSpecifierResult {
|
||||
const info = getInfo(importingSourceFile.fileName, host);
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, host, compilerOptions, importingSourceFile);
|
||||
const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, modulePath =>
|
||||
forEach(
|
||||
host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
|
||||
@@ -425,7 +428,11 @@ function computeModuleSpecifiers(
|
||||
if (reason.kind !== FileIncludeKind.Import || reason.file !== importingSourceFile.path) return undefined;
|
||||
// If the candidate import mode doesn't match the mode we're generating for, don't consider it
|
||||
// TODO: maybe useful to keep around as an alternative option for certain contexts where the mode is overridable
|
||||
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return undefined;
|
||||
const existingMode = host.getModeForResolutionAtIndex(importingSourceFile, reason.index);
|
||||
const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
|
||||
if (existingMode !== targetMode && existingMode !== undefined && targetMode !== undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
||||
// If the preference is for non relative and the module specifier is relative, ignore it
|
||||
return preferences.relativePreference !== RelativePreference.NonRelative || !pathIsRelative(specifier) ?
|
||||
@@ -737,7 +744,7 @@ function getAllModulePathsWorker(info: Info, importedFileName: string, host: Mod
|
||||
// This should populate all the relevant symlinks in the symlink cache, and most, if not all, of these resolutions
|
||||
// should get (re)used.
|
||||
const state = getTemporaryModuleResolutionState(cache.getPackageJsonInfoCache(), host, {});
|
||||
const packageJson = getPackageScopeForPath(info.importingSourceFileName, state);
|
||||
const packageJson = getPackageScopeForPath(getDirectoryPath(info.importingSourceFileName), state);
|
||||
if (packageJson) {
|
||||
const toResolve = getAllRuntimeDependencies(packageJson.contents.packageJsonContent);
|
||||
for (const depName of (toResolve || emptyArray)) {
|
||||
@@ -1093,7 +1100,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan
|
||||
|
||||
// Simplify the full file path to something that can be resolved by Node.
|
||||
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, host, options, importingSourceFile);
|
||||
const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
|
||||
let moduleSpecifier = path;
|
||||
let isPackageRootPath = false;
|
||||
@@ -1153,7 +1160,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan
|
||||
const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath);
|
||||
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
||||
const packageJsonContent: Record<string, any> | undefined = cachedPackageJson?.contents.packageJsonContent || tryParseJson(host.readFile!(packageJsonPath)!);
|
||||
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
||||
const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
|
||||
if (getResolvePackageJsonExports(options)) {
|
||||
// The package name that we found in node_modules could be different from the package
|
||||
// name in the package.json content via url/filepath dependency specifiers. We need to
|
||||
@@ -1348,3 +1355,7 @@ function getRelativePathIfInSameVolume(path: string, directoryPath: string, getC
|
||||
function isPathRelativeToParent(path: string): boolean {
|
||||
return startsWith(path, "..");
|
||||
}
|
||||
|
||||
function getDefaultResolutionModeForFile(file: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, host: Pick<ModuleSpecifierResolutionHost, "getDefaultResolutionModeForFile">, compilerOptions: CompilerOptions) {
|
||||
return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
attachFileToDiagnostics,
|
||||
AwaitExpression,
|
||||
BaseNodeFactory,
|
||||
BigIntLiteral,
|
||||
BinaryExpression,
|
||||
BinaryOperatorToken,
|
||||
BindingElement,
|
||||
@@ -2637,7 +2638,7 @@ namespace Parser {
|
||||
function createIdentifier(isIdentifier: boolean, diagnosticMessage?: DiagnosticMessage, privateIdentifierDiagnosticMessage?: DiagnosticMessage): Identifier {
|
||||
if (isIdentifier) {
|
||||
identifierCount++;
|
||||
const pos = getNodePos();
|
||||
const pos = scanner.hasPrecedingJSDocLeadingAsterisks() ? scanner.getTokenStart() : getNodePos();
|
||||
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
|
||||
const originalKeywordKind = token();
|
||||
const text = internIdentifier(scanner.getTokenValue());
|
||||
@@ -2692,7 +2693,8 @@ namespace Parser {
|
||||
function isLiteralPropertyName(): boolean {
|
||||
return tokenIsIdentifierOrKeyword(token()) ||
|
||||
token() === SyntaxKind.StringLiteral ||
|
||||
token() === SyntaxKind.NumericLiteral;
|
||||
token() === SyntaxKind.NumericLiteral ||
|
||||
token() === SyntaxKind.BigIntLiteral;
|
||||
}
|
||||
|
||||
function isImportAttributeName(): boolean {
|
||||
@@ -2700,8 +2702,8 @@ namespace Parser {
|
||||
}
|
||||
|
||||
function parsePropertyNameWorker(allowComputedPropertyNames: boolean): PropertyName {
|
||||
if (token() === SyntaxKind.StringLiteral || token() === SyntaxKind.NumericLiteral) {
|
||||
const node = parseLiteralNode() as StringLiteral | NumericLiteral;
|
||||
if (token() === SyntaxKind.StringLiteral || token() === SyntaxKind.NumericLiteral || token() === SyntaxKind.BigIntLiteral) {
|
||||
const node = parseLiteralNode() as StringLiteral | NumericLiteral | BigIntLiteral;
|
||||
node.text = internIdentifier(node.text);
|
||||
return node;
|
||||
}
|
||||
@@ -8059,6 +8061,7 @@ namespace Parser {
|
||||
tokenIsIdentifierOrKeyword(token()) ||
|
||||
token() === SyntaxKind.StringLiteral ||
|
||||
token() === SyntaxKind.NumericLiteral ||
|
||||
token() === SyntaxKind.BigIntLiteral ||
|
||||
token() === SyntaxKind.AsteriskToken ||
|
||||
token() === SyntaxKind.OpenBracketToken
|
||||
) {
|
||||
|
||||
@@ -31,11 +31,14 @@ function tryGetPerformance() {
|
||||
if (isNodeLikeSystem()) {
|
||||
try {
|
||||
// By default, only write native events when generating a cpu profile or using the v8 profiler.
|
||||
const { performance } = require("perf_hooks") as typeof import("perf_hooks");
|
||||
return {
|
||||
shouldWriteNativeEvents: false,
|
||||
performance,
|
||||
};
|
||||
// Some environments may polyfill this module with an empty object; verify the object has the expected shape.
|
||||
const { performance } = require("perf_hooks") as Partial<typeof import("perf_hooks")>;
|
||||
if (performance) {
|
||||
return {
|
||||
shouldWriteNativeEvents: false,
|
||||
performance,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// ignore errors
|
||||
|
||||
+177
-99
@@ -175,6 +175,7 @@ import {
|
||||
ImportClause,
|
||||
ImportDeclaration,
|
||||
ImportOrExportSpecifier,
|
||||
importSyntaxAffectsModuleResolution,
|
||||
InternalEmitFlags,
|
||||
inverseJsxOptionMap,
|
||||
isAmbientModule,
|
||||
@@ -301,7 +302,6 @@ import {
|
||||
sourceFileAffectingCompilerOptions,
|
||||
sourceFileMayBeEmitted,
|
||||
SourceOfProjectReferenceRedirect,
|
||||
stableSort,
|
||||
startsWith,
|
||||
Statement,
|
||||
StringLiteral,
|
||||
@@ -315,6 +315,7 @@ import {
|
||||
toFileNameLowerCase,
|
||||
tokenToString,
|
||||
toPath as ts_toPath,
|
||||
toSorted,
|
||||
trace,
|
||||
tracing,
|
||||
tryCast,
|
||||
@@ -840,9 +841,11 @@ export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageCha
|
||||
* @internal
|
||||
*/
|
||||
export interface SourceFileImportsList {
|
||||
/** @internal */ imports: SourceFile["imports"];
|
||||
/** @internal */ moduleAugmentations: SourceFile["moduleAugmentations"];
|
||||
imports: SourceFile["imports"];
|
||||
moduleAugmentations: SourceFile["moduleAugmentations"];
|
||||
impliedNodeFormat?: ResolutionMode;
|
||||
fileName: string;
|
||||
packageJsonScope?: SourceFile["packageJsonScope"];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -866,7 +869,7 @@ export function getModeForFileReference(ref: FileReference | string, containingF
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
*/
|
||||
export function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions?: CompilerOptions): ResolutionMode {
|
||||
@@ -888,22 +891,47 @@ export function isExclusivelyTypeOnlyImportOrExport(decl: ImportDeclaration | Ex
|
||||
|
||||
/**
|
||||
* Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
* Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
|
||||
* settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
|
||||
* which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
|
||||
* overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
|
||||
* Some examples:
|
||||
*
|
||||
* ```ts
|
||||
* // tsc foo.mts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
||||
*
|
||||
* // tsc foo.cts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution bundler
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
||||
* // supports conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution node10
|
||||
* import {} from "mod";
|
||||
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
||||
* // does not support conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module commonjs --moduleResolution node10
|
||||
* import type {} from "mod" with { "resolution-mode": "import" };
|
||||
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
||||
* ```
|
||||
*
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions: CompilerOptions) {
|
||||
export function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike, compilerOptions: CompilerOptions) {
|
||||
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
||||
}
|
||||
|
||||
function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions?: CompilerOptions) {
|
||||
function getModeForUsageLocationWorker(file: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, usage: StringLiteralLike, compilerOptions?: CompilerOptions) {
|
||||
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent) || isJSDocImportTag(usage.parent)) {
|
||||
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
||||
if (isTypeOnly) {
|
||||
@@ -919,20 +947,36 @@ function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMod
|
||||
return override;
|
||||
}
|
||||
}
|
||||
if (compilerOptions && getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) {
|
||||
return (usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(usage.parent, /*requireStringLiteralLikeArgument*/ false))
|
||||
? ModuleKind.CommonJS
|
||||
: ModuleKind.ESNext;
|
||||
|
||||
if (compilerOptions && importSyntaxAffectsModuleResolution(compilerOptions)) {
|
||||
return getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions);
|
||||
}
|
||||
if (file.impliedNodeFormat === undefined) return undefined;
|
||||
if (file.impliedNodeFormat !== ModuleKind.ESNext) {
|
||||
// in cjs files, import call expressions are esm format, otherwise everything is cjs
|
||||
return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? ModuleKind.ESNext : ModuleKind.CommonJS;
|
||||
}
|
||||
|
||||
function getEmitSyntaxForUsageLocationWorker(file: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, usage: StringLiteralLike, compilerOptions?: CompilerOptions): ResolutionMode {
|
||||
if (!compilerOptions) {
|
||||
// This should always be provided, but we try to fail somewhat
|
||||
// gracefully to allow projects like ts-node time to update.
|
||||
return undefined;
|
||||
}
|
||||
// in esm files, import=require statements are cjs format, otherwise everything is esm
|
||||
// imports are only parent'd up to their containing declaration/expression, so access farther parents with care
|
||||
const exprParentParent = walkUpParenthesizedExpressions(usage.parent)?.parent;
|
||||
return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? ModuleKind.CommonJS : ModuleKind.ESNext;
|
||||
if (exprParentParent && isImportEqualsDeclaration(exprParentParent) || isRequireCall(usage.parent, /*requireStringLiteralLikeArgument*/ false)) {
|
||||
return ModuleKind.CommonJS;
|
||||
}
|
||||
if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
|
||||
return shouldTransformImportCallWorker(file, compilerOptions) ? ModuleKind.CommonJS : ModuleKind.ESNext;
|
||||
}
|
||||
// If we're in --module preserve on an input file, we know that an import
|
||||
// is an import. But if this is a declaration file, we'd prefer to use the
|
||||
// impliedNodeFormat. Since we want things to be consistent between the two,
|
||||
// we need to issue errors when the user writes ESM syntax in a definitely-CJS
|
||||
// file, until/unless declaration emit can indicate a true ESM import. On the
|
||||
// other hand, writing CJS syntax in a definitely-ESM file is fine, since declaration
|
||||
// emit preserves the CJS syntax.
|
||||
const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
|
||||
return fileEmitMode === ModuleKind.CommonJS ? ModuleKind.CommonJS :
|
||||
emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === ModuleKind.Preserve ? ModuleKind.ESNext :
|
||||
undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -1028,7 +1072,7 @@ function getTypeReferenceResolutionName<T extends FileReference | string>(entry:
|
||||
|
||||
const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter<FileReference | string, SourceFile | undefined> = {
|
||||
getName: getTypeReferenceResolutionName,
|
||||
getMode: (entry, file) => getModeForFileReference(entry, file?.impliedNodeFormat),
|
||||
getMode: (entry, file, compilerOptions) => getModeForFileReference(entry, file && getDefaultResolutionModeForFileWorker(file, compilerOptions)),
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
@@ -1348,22 +1392,20 @@ export function getImpliedNodeFormatForFileWorker(
|
||||
host: ModuleResolutionHost,
|
||||
options: CompilerOptions,
|
||||
) {
|
||||
switch (getEmitModuleResolutionKind(options)) {
|
||||
case ModuleResolutionKind.Node16:
|
||||
case ModuleResolutionKind.NodeNext:
|
||||
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
|
||||
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
|
||||
fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
|
||||
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
const moduleResolution = getEmitModuleResolutionKind(options);
|
||||
const shouldLookupFromPackageJson = ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext
|
||||
|| pathContainsNodeModules(fileName);
|
||||
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
|
||||
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
|
||||
shouldLookupFromPackageJson && fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
|
||||
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
||||
|
||||
function lookupFromPackageJson(): Partial<CreateSourceFileOptions> {
|
||||
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
||||
const packageJsonLocations: string[] = [];
|
||||
state.failedLookupLocations = packageJsonLocations;
|
||||
state.affectingLocations = packageJsonLocations;
|
||||
const packageJsonScope = getPackageScopeForPath(fileName, state);
|
||||
const packageJsonScope = getPackageScopeForPath(getDirectoryPath(fileName), state);
|
||||
const impliedNodeFormat = packageJsonScope?.contents.packageJsonContent.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS;
|
||||
return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
|
||||
}
|
||||
@@ -1545,7 +1587,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
let commonSourceDirectory: string;
|
||||
let typeChecker: TypeChecker;
|
||||
let classifiableNames: Set<__String>;
|
||||
const ambientModuleNameToUnmodifiedFileName = new Map<string, string>();
|
||||
let fileReasons = createMultiMap<Path, FileIncludeReason>();
|
||||
let filesWithReferencesProcessed: Set<Path> | undefined;
|
||||
let fileReasonsToChain: Map<Path, FileReasonToChainCache> | undefined;
|
||||
@@ -1843,7 +1884,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
}
|
||||
}
|
||||
|
||||
files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
|
||||
files = toSorted(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
|
||||
processingDefaultLibFiles = undefined;
|
||||
processingOtherFiles = undefined;
|
||||
filesWithReferencesProcessed = undefined;
|
||||
@@ -1928,6 +1969,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
isSourceFileFromExternalLibrary,
|
||||
isSourceFileDefaultLibrary,
|
||||
getModeForUsageLocation,
|
||||
getEmitSyntaxForUsageLocation,
|
||||
getModeForResolutionAtIndex,
|
||||
getSourceFileFromReference,
|
||||
getLibFileFromReference,
|
||||
@@ -1956,6 +1998,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
forEachResolvedProjectReference,
|
||||
isSourceOfProjectReferenceRedirect,
|
||||
getRedirectReferenceForResolutionFromSourceOfProject,
|
||||
getCompilerOptionsForFile,
|
||||
getDefaultResolutionModeForFile,
|
||||
getEmitModuleFormatOfFile,
|
||||
getImpliedNodeFormatForEmit,
|
||||
shouldTransformImportCall,
|
||||
emitBuildInfo,
|
||||
fileExists,
|
||||
readFile,
|
||||
@@ -2250,52 +2297,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
canReuseResolutionsInFile: () =>
|
||||
containingFile === oldProgram?.getSourceFile(containingFile.fileName) &&
|
||||
!hasInvalidatedResolutions(containingFile.path),
|
||||
isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule,
|
||||
resolveToOwnAmbientModule: true,
|
||||
});
|
||||
}
|
||||
|
||||
function moduleNameResolvesToAmbientModule(moduleName: StringLiteralLike, file: SourceFile) {
|
||||
// We know moduleName resolves to an ambient module provided that moduleName:
|
||||
// - is in the list of ambient modules locally declared in the current source file.
|
||||
// - resolved to an ambient module in the old program whose declaration is in an unmodified file
|
||||
// (so the same module declaration will land in the new program)
|
||||
if (contains(file.ambientModuleNames, moduleName.text)) {
|
||||
if (isTraceEnabled(options, host)) {
|
||||
trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file);
|
||||
}
|
||||
}
|
||||
|
||||
// If we change our policy of rechecking failed lookups on each program create,
|
||||
// we should adjust the value returned here.
|
||||
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: StringLiteralLike, file: SourceFile): boolean {
|
||||
const resolutionToFile = oldProgram?.getResolvedModule(file, moduleName.text, getModeForUsageLocation(file, moduleName))?.resolvedModule;
|
||||
const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName);
|
||||
if (resolutionToFile && resolvedFile) {
|
||||
// In the old program, we resolved to an ambient module that was in the same
|
||||
// place as we expected to find an actual module file.
|
||||
// We actually need to return 'false' here even though this seems like a 'true' case
|
||||
// because the normal module resolution algorithm will find this anyway.
|
||||
return false;
|
||||
}
|
||||
|
||||
// at least one of declarations should come from non-modified source file
|
||||
const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
|
||||
|
||||
if (!unmodifiedFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isTraceEnabled(options, host)) {
|
||||
trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: readonly FileReference[], containingFile: SourceFile): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[];
|
||||
function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: readonly string[], containingFile: string): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[];
|
||||
function resolveTypeReferenceDirectiveNamesReusingOldState<T extends string | FileReference>(typeDirectiveNames: readonly T[], containingFile: string | SourceFile): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] {
|
||||
@@ -2333,7 +2338,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
getResolutionFromOldProgram: (name: string, mode: ResolutionMode) => Resolution | undefined;
|
||||
getResolved: (oldResolution: Resolution) => ResolutionWithResolvedFileName | undefined;
|
||||
canReuseResolutionsInFile: () => boolean;
|
||||
isEntryResolvingToAmbientModule?: (entry: Entry, containingFile: SourceFileOrString) => boolean;
|
||||
resolveToOwnAmbientModule?: true;
|
||||
}
|
||||
|
||||
function resolveNamesReusingOldState<Entry, SourceFileOrString, SourceFileOrUndefined extends SourceFile | undefined, Resolution>({
|
||||
@@ -2346,10 +2351,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
getResolutionFromOldProgram,
|
||||
getResolved,
|
||||
canReuseResolutionsInFile,
|
||||
isEntryResolvingToAmbientModule,
|
||||
resolveToOwnAmbientModule,
|
||||
}: ResolveNamesReusingOldStateInput<Entry, SourceFileOrString, SourceFileOrUndefined, Resolution>): readonly Resolution[] {
|
||||
if (!entries.length) return emptyArray;
|
||||
if (structureIsReused === StructureIsReused.Not && (!isEntryResolvingToAmbientModule || !containingSourceFile!.ambientModuleNames.length)) {
|
||||
if (structureIsReused === StructureIsReused.Not && (!resolveToOwnAmbientModule || !containingSourceFile!.ambientModuleNames.length)) {
|
||||
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
|
||||
// the best we can do is fallback to the default logic.
|
||||
return resolutionWorker(
|
||||
@@ -2394,14 +2399,27 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isEntryResolvingToAmbientModule?.(entry, containingFile)) {
|
||||
(result ??= new Array(entries.length))[i] = emptyResolution;
|
||||
}
|
||||
else {
|
||||
// Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
|
||||
(unknownEntries ??= []).push(entry);
|
||||
(unknownEntryIndices ??= []).push(i);
|
||||
if (resolveToOwnAmbientModule) {
|
||||
const name = nameAndModeGetter.getName(entry);
|
||||
// We know moduleName resolves to an ambient module provided that moduleName:
|
||||
// - is in the list of ambient modules locally declared in the current source file.
|
||||
if (contains(containingSourceFile!.ambientModuleNames, name)) {
|
||||
if (isTraceEnabled(options, host)) {
|
||||
trace(
|
||||
host,
|
||||
Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1,
|
||||
name,
|
||||
getNormalizedAbsolutePath(containingSourceFile!.originalFileName, currentDirectory),
|
||||
);
|
||||
}
|
||||
(result ??= new Array(entries.length))[i] = emptyResolution;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
|
||||
(unknownEntries ??= []).push(entry);
|
||||
(unknownEntryIndices ??= []).push(i);
|
||||
}
|
||||
|
||||
if (!unknownEntries) return result!;
|
||||
@@ -2586,11 +2604,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
// add file to the modified list so that we will resolve it later
|
||||
modifiedSourceFiles.push(newSourceFile);
|
||||
}
|
||||
else {
|
||||
for (const moduleName of oldSourceFile.ambientModuleNames) {
|
||||
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldSourceFile.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// if file has passed all checks it should be safe to reuse it
|
||||
newSourceFiles.push(newSourceFile);
|
||||
@@ -2704,6 +2717,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
getSymlinkCache,
|
||||
writeFile: writeFileCallback || writeFile,
|
||||
isEmitBlocked,
|
||||
shouldTransformImportCall,
|
||||
getEmitModuleFormatOfFile,
|
||||
getDefaultResolutionModeForFile,
|
||||
getModeForResolutionAtIndex,
|
||||
readFile: f => host.readFile(f),
|
||||
fileExists: f => {
|
||||
// Use local caches
|
||||
@@ -3991,11 +4008,15 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
// store resolved type directive on the file
|
||||
const fileName = ref.fileName;
|
||||
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
||||
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
||||
const mode = ref.resolutionMode || getDefaultResolutionModeForFile(file);
|
||||
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: FileIncludeKind.TypeReferenceDirective, file: file.path, index });
|
||||
}
|
||||
}
|
||||
|
||||
function getCompilerOptionsForFile(file: SourceFile): CompilerOptions {
|
||||
return getRedirectReferenceForResolution(file)?.commandLine.options || options;
|
||||
}
|
||||
|
||||
function processTypeReferenceDirective(
|
||||
typeReferenceDirective: string,
|
||||
mode: ResolutionMode,
|
||||
@@ -4110,7 +4131,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
const resolutions = resolvedModulesProcessing?.get(file.path) ||
|
||||
resolveModuleNamesReusingOldState(moduleNames, file);
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options;
|
||||
const optionsForFile = getCompilerOptionsForFile(file);
|
||||
const resolutionsInFile = createModeAwareCache<ResolutionWithFailedLookupLocations>();
|
||||
(resolvedModules ??= new Map()).set(file.path, resolutionsInFile);
|
||||
for (let index = 0; index < moduleNames.length; index++) {
|
||||
@@ -4700,7 +4721,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
}
|
||||
else {
|
||||
reasons?.forEach(processReason);
|
||||
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
||||
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
|
||||
}
|
||||
|
||||
if (fileProcessingReason) processReason(fileProcessingReason);
|
||||
@@ -5134,13 +5155,70 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
}
|
||||
|
||||
function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode {
|
||||
const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options;
|
||||
return getModeForUsageLocationWorker(file, usage, optionsForFile);
|
||||
return getModeForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
||||
}
|
||||
|
||||
function getEmitSyntaxForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode {
|
||||
return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
||||
}
|
||||
|
||||
function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode {
|
||||
return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
|
||||
}
|
||||
|
||||
function getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode {
|
||||
return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
|
||||
function getImpliedNodeFormatForEmit(sourceFile: SourceFile): ResolutionMode {
|
||||
return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
|
||||
function getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind {
|
||||
return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
|
||||
function shouldTransformImportCall(sourceFile: SourceFile): boolean {
|
||||
return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
}
|
||||
|
||||
function shouldTransformImportCallWorker(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): boolean {
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
if (ModuleKind.Node16 <= moduleKind && moduleKind <= ModuleKind.NodeNext || moduleKind === ModuleKind.Preserve) {
|
||||
return false;
|
||||
}
|
||||
return getEmitModuleFormatOfFileWorker(sourceFile, options) < ModuleKind.ES2015;
|
||||
}
|
||||
/** @internal Prefer `program.getEmitModuleFormatOfFile` when possible. */
|
||||
export function getEmitModuleFormatOfFileWorker(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ModuleKind {
|
||||
return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
|
||||
}
|
||||
/** @internal Prefer `program.getImpliedNodeFormatForEmit` when possible. */
|
||||
export function getImpliedNodeFormatForEmitWorker(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ResolutionMode {
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
if (ModuleKind.Node16 <= moduleKind && moduleKind <= ModuleKind.NodeNext) {
|
||||
return sourceFile.impliedNodeFormat;
|
||||
}
|
||||
if (
|
||||
sourceFile.impliedNodeFormat === ModuleKind.CommonJS
|
||||
&& (sourceFile.packageJsonScope?.contents.packageJsonContent.type === "commonjs"
|
||||
|| fileExtensionIsOneOf(sourceFile.fileName, [Extension.Cjs, Extension.Cts]))
|
||||
) {
|
||||
return ModuleKind.CommonJS;
|
||||
}
|
||||
if (
|
||||
sourceFile.impliedNodeFormat === ModuleKind.ESNext
|
||||
&& (sourceFile.packageJsonScope?.contents.packageJsonContent.type === "module"
|
||||
|| fileExtensionIsOneOf(sourceFile.fileName, [Extension.Mjs, Extension.Mts]))
|
||||
) {
|
||||
return ModuleKind.ESNext;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/** @internal Prefer `program.getDefaultResolutionModeForFile` when possible. */
|
||||
export function getDefaultResolutionModeForFileWorker(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ResolutionMode {
|
||||
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : undefined;
|
||||
}
|
||||
|
||||
interface HostForUseSourceOfProjectReferenceRedirect {
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
CompilerOptions,
|
||||
createModeAwareCache,
|
||||
createModuleResolutionCache,
|
||||
createMultiMap,
|
||||
createTypeReferenceDirectiveResolutionCache,
|
||||
createTypeReferenceResolutionLoader,
|
||||
Debug,
|
||||
@@ -39,7 +38,6 @@ import {
|
||||
isDiskPathRoot,
|
||||
isEmittedFileOfProgram,
|
||||
isExternalModuleNameRelative,
|
||||
isExternalOrCommonJsModule,
|
||||
isNodeModulesDirectory,
|
||||
isRootedDiskPath,
|
||||
isTraceEnabled,
|
||||
@@ -572,7 +570,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
let filesWithChangedSetOfUnresolvedImports: Path[] | undefined;
|
||||
let filesWithInvalidatedResolutions: Set<Path> | undefined;
|
||||
let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyMap<Path, readonly string[]> | undefined;
|
||||
const nonRelativeExternalModuleResolutions = createMultiMap<string, ResolutionWithFailedLookupLocations>();
|
||||
const nonRelativeExternalModuleResolutions = new Set<ResolutionWithFailedLookupLocations>();
|
||||
|
||||
const resolutionsWithFailedLookups = new Set<ResolutionWithFailedLookupLocations>();
|
||||
const resolutionsWithOnlyAffectingLocations = new Set<ResolutionWithFailedLookupLocations>();
|
||||
@@ -755,8 +753,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
|
||||
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
||||
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
||||
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
||||
nonRelativeExternalModuleResolutions.clear();
|
||||
watchFailedLookupLocationOfNonRelativeModuleResolutions();
|
||||
isSymlinkCache.clear();
|
||||
}
|
||||
|
||||
@@ -776,13 +773,12 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
function finishCachingPerDirectoryResolution(newProgram: Program | undefined, oldProgram: Program | undefined) {
|
||||
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
|
||||
allModuleAndTypeResolutionsAreInvalidated = false;
|
||||
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
||||
nonRelativeExternalModuleResolutions.clear();
|
||||
watchFailedLookupLocationOfNonRelativeModuleResolutions();
|
||||
// Update file watches
|
||||
if (newProgram !== oldProgram) {
|
||||
cleanupLibResolutionWatching(newProgram);
|
||||
newProgram?.getSourceFiles().forEach(newFile => {
|
||||
const expected = isExternalOrCommonJsModule(newFile) ? newFile.packageJsonLocations?.length ?? 0 : 0;
|
||||
const expected = newFile.packageJsonLocations?.length ?? 0;
|
||||
const existing = impliedFormatPackageJsons.get(newFile.resolvedPath) ?? emptyArray;
|
||||
for (let i = existing.length; i < expected; i++) {
|
||||
createFileWatcherOfAffectingLocation(newFile.packageJsonLocations![i], /*forResolution*/ false);
|
||||
@@ -1103,7 +1099,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
watchFailedLookupLocationOfResolution(resolution);
|
||||
}
|
||||
else {
|
||||
nonRelativeExternalModuleResolutions.add(name, resolution);
|
||||
nonRelativeExternalModuleResolutions.add(resolution);
|
||||
}
|
||||
const resolved = getResolutionWithResolvedFileName(resolution);
|
||||
if (resolved && resolved.resolvedFileName) {
|
||||
@@ -1236,14 +1232,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
packageJsonMap?.delete(resolutionHost.toPath(path));
|
||||
}
|
||||
|
||||
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions: ResolutionWithFailedLookupLocations[], name: string) {
|
||||
const program = resolutionHost.getCurrentProgram();
|
||||
if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
|
||||
resolutions.forEach(watchFailedLookupLocationOfResolution);
|
||||
}
|
||||
else {
|
||||
resolutions.forEach(resolution => watchAffectingLocationsOfResolution(resolution, /*addToResolutionsWithOnlyAffectingLocations*/ true));
|
||||
}
|
||||
function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
|
||||
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
|
||||
nonRelativeExternalModuleResolutions.clear();
|
||||
}
|
||||
|
||||
function createDirectoryWatcherForPackageDir(
|
||||
|
||||
+21
-11
@@ -65,6 +65,8 @@ export interface Scanner {
|
||||
hasPrecedingLineBreak(): boolean;
|
||||
/** @internal */
|
||||
hasPrecedingJSDocComment(): boolean;
|
||||
/** @internal */
|
||||
hasPrecedingJSDocLeadingAsterisks(): boolean;
|
||||
isIdentifier(): boolean;
|
||||
isReservedWord(): boolean;
|
||||
isUnterminated(): boolean;
|
||||
@@ -1005,7 +1007,7 @@ const enum EscapeSequenceScanningFlags {
|
||||
AtomEscape = 1 << 5,
|
||||
|
||||
ReportInvalidEscapeErrors = RegularExpression | ReportErrors,
|
||||
ScanExtendedUnicodeEscape = String | AnyUnicodeMode,
|
||||
AllowExtendedUnicodeEscape = String | AnyUnicodeMode,
|
||||
}
|
||||
|
||||
const enum ClassSetExpressionType {
|
||||
@@ -1060,6 +1062,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
hasExtendedUnicodeEscape: () => (tokenFlags & TokenFlags.ExtendedUnicodeEscape) !== 0,
|
||||
hasPrecedingLineBreak: () => (tokenFlags & TokenFlags.PrecedingLineBreak) !== 0,
|
||||
hasPrecedingJSDocComment: () => (tokenFlags & TokenFlags.PrecedingJSDocComment) !== 0,
|
||||
hasPrecedingJSDocLeadingAsterisks: () => (tokenFlags & TokenFlags.PrecedingJSDocLeadingAsterisks) !== 0,
|
||||
isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
|
||||
isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
|
||||
isUnterminated: () => (tokenFlags & TokenFlags.Unterminated) !== 0,
|
||||
@@ -1607,13 +1610,17 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
case CharacterCodes.doubleQuote:
|
||||
return '"';
|
||||
case CharacterCodes.u:
|
||||
if (
|
||||
flags & EscapeSequenceScanningFlags.ScanExtendedUnicodeEscape &&
|
||||
pos < end && charCodeUnchecked(pos) === CharacterCodes.openBrace
|
||||
) {
|
||||
if (pos < end && charCodeUnchecked(pos) === CharacterCodes.openBrace) {
|
||||
// '\u{DDDDDD}'
|
||||
pos -= 2;
|
||||
return scanExtendedUnicodeEscape(!!(flags & EscapeSequenceScanningFlags.ReportInvalidEscapeErrors));
|
||||
const result = scanExtendedUnicodeEscape(!!(flags & EscapeSequenceScanningFlags.ReportInvalidEscapeErrors));
|
||||
if (!(flags & EscapeSequenceScanningFlags.AllowExtendedUnicodeEscape)) {
|
||||
tokenFlags |= TokenFlags.ContainsInvalidEscape;
|
||||
if (flags & EscapeSequenceScanningFlags.ReportInvalidEscapeErrors) {
|
||||
error(Diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, pos - start);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// '\uDDDD'
|
||||
for (; pos < start + 6; pos++) {
|
||||
@@ -1638,7 +1645,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
const nextStart = pos;
|
||||
let nextPos = pos + 2;
|
||||
for (; nextPos < nextStart + 6; nextPos++) {
|
||||
if (!isHexDigit(charCodeUnchecked(pos))) {
|
||||
if (!isHexDigit(charCodeUnchecked(nextPos))) {
|
||||
// leave the error to the next call
|
||||
return escapedValueString;
|
||||
}
|
||||
@@ -1875,7 +1882,6 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
function scan(): SyntaxKind {
|
||||
fullStartPos = pos;
|
||||
tokenFlags = TokenFlags.None;
|
||||
let asteriskSeen = false;
|
||||
while (true) {
|
||||
tokenStart = pos;
|
||||
if (pos >= end) {
|
||||
@@ -1996,9 +2002,13 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
return pos += 2, token = SyntaxKind.AsteriskAsteriskToken;
|
||||
}
|
||||
pos++;
|
||||
if (skipJsDocLeadingAsterisks && !asteriskSeen && (tokenFlags & TokenFlags.PrecedingLineBreak)) {
|
||||
if (
|
||||
skipJsDocLeadingAsterisks &&
|
||||
(tokenFlags & TokenFlags.PrecedingJSDocLeadingAsterisks) === 0 &&
|
||||
(tokenFlags & TokenFlags.PrecedingLineBreak)
|
||||
) {
|
||||
// decoration at the start of a JSDoc comment line
|
||||
asteriskSeen = true;
|
||||
tokenFlags |= TokenFlags.PrecedingJSDocLeadingAsterisks;
|
||||
continue;
|
||||
}
|
||||
return token = SyntaxKind.AsteriskToken;
|
||||
@@ -3547,7 +3557,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
}
|
||||
|
||||
function scanSourceCharacter(): string {
|
||||
const size = anyUnicodeMode ? charSize(charCodeChecked(pos)) : 1;
|
||||
const size = anyUnicodeMode ? charSize(codePointChecked(pos)) : 1;
|
||||
pos += size;
|
||||
return size > 0 ? text.substring(pos - size, pos) : "";
|
||||
}
|
||||
|
||||
+1
-1
@@ -1604,7 +1604,7 @@ export let sys: System = (() => {
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
clearScreen: () => {
|
||||
process.stdout.write("\x1Bc");
|
||||
process.stdout.write("\x1B[2J\x1B[3J\x1B[H");
|
||||
},
|
||||
setBlocking: () => {
|
||||
const handle = (process.stdout as any)?._handle as { setBlocking?: (value: boolean) => void; };
|
||||
|
||||
@@ -65,10 +65,10 @@ import {
|
||||
transformESDecorators,
|
||||
transformESNext,
|
||||
transformGenerators,
|
||||
transformImpliedNodeFormatDependentModule,
|
||||
transformJsx,
|
||||
transformLegacyDecorators,
|
||||
transformModule,
|
||||
transformNodeModule,
|
||||
transformSystemModule,
|
||||
transformTypeScript,
|
||||
VariableDeclaration,
|
||||
@@ -77,17 +77,23 @@ import * as performance from "./_namespaces/ts.performance.js";
|
||||
|
||||
function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<SourceFile | Bundle> {
|
||||
switch (moduleKind) {
|
||||
case ModuleKind.Preserve:
|
||||
// `transformECMAScriptModule` contains logic for preserving
|
||||
// CJS input syntax in `--module preserve`
|
||||
return transformECMAScriptModule;
|
||||
case ModuleKind.ESNext:
|
||||
case ModuleKind.ES2022:
|
||||
case ModuleKind.ES2020:
|
||||
case ModuleKind.ES2015:
|
||||
case ModuleKind.Preserve:
|
||||
return transformECMAScriptModule;
|
||||
case ModuleKind.System:
|
||||
return transformSystemModule;
|
||||
case ModuleKind.Node16:
|
||||
case ModuleKind.NodeNext:
|
||||
return transformNodeModule;
|
||||
case ModuleKind.CommonJS:
|
||||
// Wraps `transformModule` and `transformECMAScriptModule` and
|
||||
// selects between them based on the `impliedNodeFormat` of the
|
||||
// source file.
|
||||
return transformImpliedNodeFormatDependentModule;
|
||||
case ModuleKind.System:
|
||||
return transformSystemModule;
|
||||
default:
|
||||
return transformModule;
|
||||
}
|
||||
|
||||
@@ -2416,11 +2416,11 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
||||
factory.createBlock(
|
||||
setTextRange(
|
||||
factory.createNodeArray(statements),
|
||||
/*location*/ constructor ? constructor.body!.statements : node.members,
|
||||
/*location*/ constructor?.body?.statements ?? node.members,
|
||||
),
|
||||
multiLine,
|
||||
),
|
||||
/*location*/ constructor ? constructor.body : undefined,
|
||||
/*location*/ constructor?.body,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,10 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
function reportPrivateInBaseOfClassExpression(propertyName: string) {
|
||||
if (errorNameNode || errorFallbackNode) {
|
||||
context.addDiagnostic(
|
||||
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName),
|
||||
addRelatedInfo(
|
||||
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected, propertyName),
|
||||
...(isVariableDeclaration((errorNameNode || errorFallbackNode)!.parent) ? [createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Add_a_type_annotation_to_the_variable_0, errorDeclarationNameWithFallback())] : []),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
isArrayBindingElement,
|
||||
isArrayBindingOrAssignmentElement,
|
||||
isArrayBindingOrAssignmentPattern,
|
||||
isBigIntLiteral,
|
||||
isBindingElement,
|
||||
isBindingName,
|
||||
isBindingOrAssignmentElement,
|
||||
@@ -558,7 +559,7 @@ function createDestructuringPropertyAccess(flattenContext: FlattenContext, value
|
||||
const argumentExpression = ensureIdentifier(flattenContext, Debug.checkDefined(visitNode(propertyName.expression, flattenContext.visitor, isExpression)), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName);
|
||||
return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
|
||||
}
|
||||
else if (isStringOrNumericLiteralLike(propertyName)) {
|
||||
else if (isStringOrNumericLiteralLike(propertyName) || isBigIntLiteral(propertyName)) {
|
||||
const argumentExpression = factory.cloneNode(propertyName);
|
||||
return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
|
||||
}
|
||||
|
||||
@@ -2946,7 +2946,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile
|
||||
const statement = unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
|
||||
return isIterationStatement(statement, /*lookInLabeledStatements*/ false)
|
||||
? visitIterationStatement(statement, /*outermostLabeledStatement*/ node)
|
||||
: factory.restoreEnclosingLabel(Debug.checkDefined(visitNode(statement, visitor, isStatement, factory.liftToBlock)), node, convertedLoopState && resetLabel);
|
||||
: factory.restoreEnclosingLabel(visitNode(statement, visitor, isStatement, factory.liftToBlock) ?? setTextRange(factory.createEmptyStatement(), statement), node, convertedLoopState && resetLabel);
|
||||
}
|
||||
|
||||
function visitIterationStatement(node: IterationStatement, outermostLabeledStatement: LabeledStatement) {
|
||||
|
||||
+5
-4
@@ -14,7 +14,7 @@ import {
|
||||
} from "../../_namespaces/ts.js";
|
||||
|
||||
/** @internal */
|
||||
export function transformNodeModule(context: TransformationContext) {
|
||||
export function transformImpliedNodeFormatDependentModule(context: TransformationContext) {
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
|
||||
@@ -30,6 +30,7 @@ export function transformNodeModule(context: TransformationContext) {
|
||||
|
||||
const cjsOnSubstituteNode = context.onSubstituteNode;
|
||||
const cjsOnEmitNode = context.onEmitNode;
|
||||
const getEmitModuleFormatOfFile = (file: SourceFile) => context.getEmitHost().getEmitModuleFormatOfFile(file);
|
||||
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
context.onEmitNode = onEmitNode;
|
||||
@@ -51,7 +52,7 @@ export function transformNodeModule(context: TransformationContext) {
|
||||
if (!currentSourceFile) {
|
||||
return previousOnSubstituteNode(hint, node);
|
||||
}
|
||||
if (currentSourceFile.impliedNodeFormat === ModuleKind.ESNext) {
|
||||
if (getEmitModuleFormatOfFile(currentSourceFile) >= ModuleKind.ES2015) {
|
||||
return esmOnSubstituteNode(hint, node);
|
||||
}
|
||||
return cjsOnSubstituteNode(hint, node);
|
||||
@@ -65,14 +66,14 @@ export function transformNodeModule(context: TransformationContext) {
|
||||
if (!currentSourceFile) {
|
||||
return previousOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
if (currentSourceFile.impliedNodeFormat === ModuleKind.ESNext) {
|
||||
if (getEmitModuleFormatOfFile(currentSourceFile) >= ModuleKind.ES2015) {
|
||||
return esmOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
return cjsOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
|
||||
function getModuleTransformForFile(file: SourceFile): typeof esmTransform {
|
||||
return file.impliedNodeFormat === ModuleKind.ESNext ? esmTransform : cjsTransform;
|
||||
return getEmitModuleFormatOfFile(file) >= ModuleKind.ES2015 ? esmTransform : cjsTransform;
|
||||
}
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
@@ -797,7 +797,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
return visitPartiallyEmittedExpression(node as PartiallyEmittedExpression, valueIsDiscarded);
|
||||
case SyntaxKind.CallExpression:
|
||||
if (isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
|
||||
if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
|
||||
return visitImportCallExpression(node);
|
||||
}
|
||||
break;
|
||||
@@ -993,7 +993,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
||||
return factory.updateLabeledStatement(
|
||||
node,
|
||||
node.label,
|
||||
Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory.liftToBlock)),
|
||||
visitNode(node.statement, topLevelNestedVisitor, isStatement, factory.liftToBlock) ?? setTextRange(factory.createEmptyStatement(), node.statement),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1019,7 +1019,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
||||
return factory.updateIfStatement(
|
||||
node,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
Debug.checkDefined(visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory.liftToBlock)),
|
||||
visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory.liftToBlock) ?? factory.createBlock([]),
|
||||
visitNode(node.elseStatement, topLevelNestedVisitor, isStatement, factory.liftToBlock),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1419,7 +1419,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc
|
||||
return factory.updateLabeledStatement(
|
||||
node,
|
||||
node.label,
|
||||
Debug.checkDefined(visitNode(node.statement, topLevelNestedVisitor, isStatement, factory.liftToBlock)),
|
||||
visitNode(node.statement, topLevelNestedVisitor, isStatement, factory.liftToBlock) ?? factory.createExpressionStatement(factory.createIdentifier("")),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1445,7 +1445,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc
|
||||
return factory.updateIfStatement(
|
||||
node,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
Debug.checkDefined(visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory.liftToBlock)),
|
||||
visitNode(node.thenStatement, topLevelNestedVisitor, isStatement, factory.liftToBlock) ?? factory.createBlock([]),
|
||||
visitNode(node.elseStatement, topLevelNestedVisitor, isStatement, factory.liftToBlock),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1690,7 +1690,7 @@ export function transformTypeScript(context: TransformationContext) {
|
||||
}
|
||||
|
||||
function visitParenthesizedExpression(node: ParenthesizedExpression): Expression {
|
||||
const innerExpression = skipOuterExpressions(node.expression, ~OuterExpressionKinds.Assertions);
|
||||
const innerExpression = skipOuterExpressions(node.expression, ~(OuterExpressionKinds.Assertions | OuterExpressionKinds.ExpressionsWithTypeArguments));
|
||||
if (isAssertionExpression(innerExpression) || isSatisfiesExpression(innerExpression)) {
|
||||
// Make sure we consider all nested cast expressions, e.g.:
|
||||
// (<any><number><any>-A).x;
|
||||
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
isClassStaticBlockDeclaration,
|
||||
isDefaultImport,
|
||||
isExpressionStatement,
|
||||
isFunctionDeclaration,
|
||||
isGeneratedIdentifier,
|
||||
isGeneratedPrivateIdentifier,
|
||||
isIdentifier,
|
||||
@@ -321,7 +322,7 @@ export function collectExternalModuleInfo(context: TransformationContext, source
|
||||
}
|
||||
|
||||
function addExportedFunctionDeclaration(node: FunctionDeclaration, name: ModuleExportName | undefined, isDefault: boolean) {
|
||||
exportedFunctions.add(node);
|
||||
exportedFunctions.add(getOriginalNode(node, isFunctionDeclaration));
|
||||
if (isDefault) {
|
||||
// export default function() { }
|
||||
// function x() { } + export { x as default };
|
||||
|
||||
+120
-20
@@ -919,11 +919,22 @@ export const enum RelationComparisonResult {
|
||||
None = 0,
|
||||
Succeeded = 1 << 0, // Should be truthy
|
||||
Failed = 1 << 1,
|
||||
Reported = 1 << 2,
|
||||
|
||||
ReportsUnmeasurable = 1 << 3,
|
||||
ReportsUnreliable = 1 << 4,
|
||||
ReportsMask = ReportsUnmeasurable | ReportsUnreliable,
|
||||
|
||||
ComplexityOverflow = 1 << 5,
|
||||
StackDepthOverflow = 1 << 6,
|
||||
Overflow = ComplexityOverflow | StackDepthOverflow,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const enum PredicateSemantics {
|
||||
None = 0,
|
||||
Always = 1 << 0,
|
||||
Never = 1 << 1,
|
||||
Sometimes = Always | Never,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -1726,7 +1737,14 @@ export interface QualifiedName extends Node, FlowContainer {
|
||||
|
||||
export type EntityName = Identifier | QualifiedName;
|
||||
|
||||
export type PropertyName = Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier;
|
||||
export type PropertyName =
|
||||
| Identifier
|
||||
| StringLiteral
|
||||
| NoSubstitutionTemplateLiteral
|
||||
| NumericLiteral
|
||||
| ComputedPropertyName
|
||||
| PrivateIdentifier
|
||||
| BigIntLiteral;
|
||||
|
||||
export type MemberName = Identifier | PrivateIdentifier;
|
||||
|
||||
@@ -2345,7 +2363,8 @@ export interface LiteralTypeNode extends TypeNode {
|
||||
|
||||
export interface StringLiteral extends LiteralExpression, Declaration {
|
||||
readonly kind: SyntaxKind.StringLiteral;
|
||||
/** @internal */ readonly textSourceNode?: Identifier | StringLiteralLike | NumericLiteral | PrivateIdentifier | JsxNamespacedName; // Allows a StringLiteral to get its text from another node (used by transforms).
|
||||
/** @internal */
|
||||
readonly textSourceNode?: Identifier | StringLiteralLike | NumericLiteral | PrivateIdentifier | JsxNamespacedName | BigIntLiteral; // Allows a StringLiteral to get its text from another node (used by transforms).
|
||||
/**
|
||||
* Note: this is only set when synthesizing a node, not during parsing.
|
||||
*
|
||||
@@ -2355,7 +2374,7 @@ export interface StringLiteral extends LiteralExpression, Declaration {
|
||||
}
|
||||
|
||||
export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral;
|
||||
export type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName;
|
||||
export type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName | BigIntLiteral;
|
||||
|
||||
export interface TemplateLiteralTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.TemplateLiteralType;
|
||||
@@ -2820,6 +2839,8 @@ export const enum TokenFlags {
|
||||
/** @internal */
|
||||
ContainsInvalidSeparator = 1 << 14, // e.g. `0_1`
|
||||
/** @internal */
|
||||
PrecedingJSDocLeadingAsterisks = 1 << 15,
|
||||
/** @internal */
|
||||
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier,
|
||||
/** @internal */
|
||||
WithSpecifier = HexSpecifier | BinaryOrOctalSpecifier,
|
||||
@@ -4656,6 +4677,7 @@ export type FilePreprocessingDiagnostics = FilePreprocessingLibReferenceDiagnost
|
||||
export const enum EmitOnly {
|
||||
Js,
|
||||
Dts,
|
||||
BuilderSignature,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -4763,21 +4785,79 @@ export interface Program extends ScriptReferenceHost {
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
* Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
|
||||
* settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
|
||||
* which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
|
||||
* overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
|
||||
* Some examples:
|
||||
*
|
||||
* ```ts
|
||||
* // tsc foo.mts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
||||
*
|
||||
* // tsc foo.cts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution bundler
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
||||
* // supports conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution node10
|
||||
* import {} from "mod";
|
||||
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
||||
* // does not support conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module commonjs --moduleResolution node10
|
||||
* import type {} from "mod" with { "resolution-mode": "import" };
|
||||
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
||||
* ```
|
||||
*/
|
||||
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
|
||||
* explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
|
||||
* `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
|
||||
* input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
|
||||
* `undefined`, as the result would have no impact on module resolution, emit, or type checking.
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This function only returns a result
|
||||
* when module resolution settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided
|
||||
* via import attributes, which cause an `import` or `require` condition to be used during resolution regardless of module resolution
|
||||
* settings. In absence of overriding attributes, and in modes that support differing resolution, the result indicates the syntax the
|
||||
* usage would emit to JavaScript. Some examples:
|
||||
*
|
||||
* ```ts
|
||||
* // tsc foo.mts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
||||
*
|
||||
* // tsc foo.cts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution bundler
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
||||
* // supports conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution node10
|
||||
* import {} from "mod";
|
||||
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
||||
* // does not support conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module commonjs --moduleResolution node10
|
||||
* import type {} from "mod" with { "resolution-mode": "import" };
|
||||
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
||||
* ```
|
||||
*/
|
||||
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
/**
|
||||
* @internal
|
||||
* The resolution mode to use for module resolution or module specifier resolution
|
||||
* outside the context of an existing module reference, where
|
||||
* `program.getModeForUsageLocation` should be used instead.
|
||||
*/
|
||||
getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode;
|
||||
/** @internal */ getImpliedNodeFormatForEmit(sourceFile: SourceFile): ResolutionMode;
|
||||
/** @internal */ getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind;
|
||||
/** @internal */ shouldTransformImportCall(sourceFile: SourceFile): boolean;
|
||||
|
||||
// For testing purposes only.
|
||||
// This is set on created program to let us know how the program was created using old program
|
||||
@@ -4832,6 +4912,7 @@ export interface Program extends ScriptReferenceHost {
|
||||
/** @internal */ getResolvedProjectReferenceByPath(projectReferencePath: Path): ResolvedProjectReference | undefined;
|
||||
/** @internal */ getRedirectReferenceForResolutionFromSourceOfProject(filePath: Path): ResolvedProjectReference | undefined;
|
||||
/** @internal */ isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
/** @internal */ getCompilerOptionsForFile(file: SourceFile): CompilerOptions;
|
||||
/** @internal */ getBuildInfo?(): BuildInfo;
|
||||
/** @internal */ emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
|
||||
/**
|
||||
@@ -4947,8 +5028,12 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost {
|
||||
getSourceFile(fileName: string): SourceFile | undefined;
|
||||
getProjectReferenceRedirect(fileName: string): string | undefined;
|
||||
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
getEmitSyntaxForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
getRedirectReferenceForResolutionFromSourceOfProject(filePath: Path): ResolvedProjectReference | undefined;
|
||||
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode;
|
||||
getImpliedNodeFormatForEmit(sourceFile: SourceFile): ResolutionMode;
|
||||
getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind;
|
||||
|
||||
getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined;
|
||||
|
||||
@@ -5002,6 +5087,7 @@ export interface TypeChecker {
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined;
|
||||
/** @internal */ typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** @internal */ typePredicateToTypePredicateNode(typePredicate: TypePredicate, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): TypePredicateNode | undefined;
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined;
|
||||
/** @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
@@ -5182,7 +5268,7 @@ export interface TypeChecker {
|
||||
/** @internal */ createPromiseType(type: Type): Type;
|
||||
/** @internal */ getPromiseType(): Type;
|
||||
/** @internal */ getPromiseLikeType(): Type;
|
||||
/** @internal */ getAsyncIterableType(): Type | undefined;
|
||||
/** @internal */ getAnyAsyncIterableType(): Type | undefined;
|
||||
|
||||
/**
|
||||
* Returns true if the "source" type is assignable to the "target" type.
|
||||
@@ -5213,7 +5299,6 @@ export interface TypeChecker {
|
||||
/** @internal */ createIndexInfo(keyType: Type, type: Type, isReadonly: boolean, declaration?: SignatureDeclaration): IndexInfo;
|
||||
/** @internal */ isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
||||
/** @internal */ tryFindAmbientModule(moduleName: string): Symbol | undefined;
|
||||
/** @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined;
|
||||
|
||||
/** @internal */ getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker;
|
||||
|
||||
@@ -5613,6 +5698,9 @@ export interface RequireVariableDeclarationList extends VariableDeclarationList
|
||||
readonly declarations: NodeArray<VariableDeclarationInitializedTo<RequireOrImportCall>>;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type CanHaveModuleSpecifier = AnyImportOrBareOrAccessedRequire | AliasDeclarationNode | ExportDeclaration | ImportTypeNode;
|
||||
|
||||
/** @internal */
|
||||
export type LateVisibilityPaintedStatement =
|
||||
| AnyImportOrJsDocImport
|
||||
@@ -6706,7 +6794,7 @@ export const enum AccessFlags {
|
||||
NoIndexSignatures = 1 << 1,
|
||||
Writing = 1 << 2,
|
||||
CacheSymbol = 1 << 3,
|
||||
NoTupleBoundsCheck = 1 << 4,
|
||||
AllowMissing = 1 << 4,
|
||||
ExpressionPosition = 1 << 5,
|
||||
ReportDeprecated = 1 << 6,
|
||||
SuppressNoImplicitAnyError = 1 << 7,
|
||||
@@ -7051,7 +7139,10 @@ export interface RepopulateModuleNotFoundDiagnosticChain {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type RepopulateDiagnosticChainInfo = RepopulateModuleNotFoundDiagnosticChain;
|
||||
export type RepopulateModeMismatchDiagnosticChain = true;
|
||||
|
||||
/** @internal */
|
||||
export type RepopulateDiagnosticChainInfo = RepopulateModuleNotFoundDiagnosticChain | RepopulateModeMismatchDiagnosticChain;
|
||||
|
||||
/**
|
||||
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
|
||||
@@ -7347,6 +7438,7 @@ export interface CompilerOptions {
|
||||
strictBindCallApply?: boolean; // Always combine with strict property
|
||||
strictNullChecks?: boolean; // Always combine with strict property
|
||||
strictPropertyInitialization?: boolean; // Always combine with strict property
|
||||
strictBuiltinIteratorReturn?: boolean; // Always combine with strict property
|
||||
stripInternal?: boolean;
|
||||
/** @deprecated */
|
||||
suppressExcessPropertyErrors?: boolean;
|
||||
@@ -7356,6 +7448,7 @@ export interface CompilerOptions {
|
||||
target?: ScriptTarget;
|
||||
traceResolution?: boolean;
|
||||
useUnknownInCatchVariables?: boolean;
|
||||
noUncheckedSideEffectImports?: boolean;
|
||||
resolveJsonModule?: boolean;
|
||||
types?: string[];
|
||||
/** Paths used to compute primary types search locations */
|
||||
@@ -8371,6 +8464,8 @@ export interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolution
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
|
||||
isEmitBlocked(emitFileName: string): boolean;
|
||||
shouldTransformImportCall(sourceFile: SourceFile): boolean;
|
||||
getEmitModuleFormatOfFile(sourceFile: SourceFile): ModuleKind;
|
||||
|
||||
writeFile: WriteFileCallback;
|
||||
getBuildInfo(): BuildInfo | undefined;
|
||||
@@ -8394,11 +8489,12 @@ export const enum OuterExpressionKinds {
|
||||
TypeAssertions = 1 << 1,
|
||||
NonNullAssertions = 1 << 2,
|
||||
PartiallyEmittedExpressions = 1 << 3,
|
||||
ExpressionsWithTypeArguments = 1 << 4,
|
||||
|
||||
Assertions = TypeAssertions | NonNullAssertions,
|
||||
All = Parentheses | Assertions | PartiallyEmittedExpressions,
|
||||
All = Parentheses | Assertions | PartiallyEmittedExpressions | ExpressionsWithTypeArguments,
|
||||
|
||||
ExcludeJSDocTypeAssertion = 1 << 4,
|
||||
ExcludeJSDocTypeAssertion = 1 << 31,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -8408,6 +8504,7 @@ export type OuterExpression =
|
||||
| SatisfiesExpression
|
||||
| AsExpression
|
||||
| NonNullExpression
|
||||
| ExpressionWithTypeArguments
|
||||
| PartiallyEmittedExpression;
|
||||
|
||||
/** @internal */
|
||||
@@ -9613,6 +9710,7 @@ export interface PrinterOptions {
|
||||
omitTrailingSemicolon?: boolean;
|
||||
noEmitHelpers?: boolean;
|
||||
/** @internal */ module?: CompilerOptions["module"];
|
||||
/** @internal */ moduleResolution?: CompilerOptions["moduleResolution"];
|
||||
/** @internal */ target?: CompilerOptions["target"];
|
||||
/** @internal */ sourceMap?: boolean;
|
||||
/** @internal */ inlineSourceMap?: boolean;
|
||||
@@ -9747,6 +9845,8 @@ export interface ModuleSpecifierResolutionHost {
|
||||
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>;
|
||||
getCommonSourceDirectory(): string;
|
||||
getDefaultResolutionModeForFile(sourceFile: SourceFile): ResolutionMode;
|
||||
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
|
||||
getModuleResolutionCache?(): ModuleResolutionCache | undefined;
|
||||
trace?(s: string): void;
|
||||
|
||||
+109
-11
@@ -5,7 +5,6 @@ import {
|
||||
addRange,
|
||||
affectsDeclarationPathOptionDeclarations,
|
||||
affectsEmitOptionDeclarations,
|
||||
AliasDeclarationNode,
|
||||
AllAccessorDeclarations,
|
||||
AmbientModuleDeclaration,
|
||||
AmpersandAmpersandEqualsToken,
|
||||
@@ -41,6 +40,7 @@ import {
|
||||
canHaveDecorators,
|
||||
canHaveLocals,
|
||||
canHaveModifiers,
|
||||
CanHaveModuleSpecifier,
|
||||
CanonicalDiagnostic,
|
||||
CaseBlock,
|
||||
CaseClause,
|
||||
@@ -167,6 +167,7 @@ import {
|
||||
getCommonSourceDirectory,
|
||||
getContainerFlags,
|
||||
getDirectoryPath,
|
||||
getImpliedNodeFormatForEmitWorker,
|
||||
getJSDocAugmentsTag,
|
||||
getJSDocDeferredTagNoCache,
|
||||
getJSDocDeprecatedTagNoCache,
|
||||
@@ -287,6 +288,7 @@ import {
|
||||
isIdentifier,
|
||||
isIdentifierStart,
|
||||
isIdentifierText,
|
||||
isImportDeclaration,
|
||||
isImportTypeNode,
|
||||
isInterfaceDeclaration,
|
||||
isJSDoc,
|
||||
@@ -509,7 +511,6 @@ import {
|
||||
skipTrivia,
|
||||
SnippetKind,
|
||||
some,
|
||||
sort,
|
||||
SortedArray,
|
||||
SourceFile,
|
||||
SourceFileLike,
|
||||
@@ -544,6 +545,7 @@ import {
|
||||
TokenFlags,
|
||||
tokenToString,
|
||||
toPath,
|
||||
toSorted,
|
||||
tracing,
|
||||
TransformFlags,
|
||||
TransientSymbol,
|
||||
@@ -845,6 +847,38 @@ export function createModuleNotFoundChain(sourceFile: SourceFile, host: TypeChec
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function createModeMismatchDetails(currentSourceFile: SourceFile) {
|
||||
const ext = tryGetExtensionFromPath(currentSourceFile.fileName);
|
||||
const scope = currentSourceFile.packageJsonScope;
|
||||
const targetExt = ext === Extension.Ts ? Extension.Mts : ext === Extension.Js ? Extension.Mjs : undefined;
|
||||
const result = scope && !scope.contents.packageJsonContent.type ?
|
||||
targetExt ?
|
||||
chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
|
||||
targetExt,
|
||||
combinePaths(scope.packageDirectory, "package.json"),
|
||||
) :
|
||||
chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0,
|
||||
combinePaths(scope.packageDirectory, "package.json"),
|
||||
) :
|
||||
targetExt ?
|
||||
chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module,
|
||||
targetExt,
|
||||
) :
|
||||
chainDiagnosticMessages(
|
||||
/*details*/ undefined,
|
||||
Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module,
|
||||
);
|
||||
result.repopulateInfo = () => true;
|
||||
return result;
|
||||
}
|
||||
|
||||
function packageIdIsEqual(a: PackageId | undefined, b: PackageId | undefined): boolean {
|
||||
return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version && a.peerDependencies === b.peerDependencies;
|
||||
}
|
||||
@@ -1226,6 +1260,16 @@ export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFil
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastDecorator.end);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getNonModifierTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number {
|
||||
const lastModifier = !nodeIsMissing(node) && canHaveModifiers(node) && node.modifiers ? last(node.modifiers) : undefined;
|
||||
if (!lastModifier) {
|
||||
return getTokenPosOfNode(node, sourceFile);
|
||||
}
|
||||
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastModifier.end);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string {
|
||||
return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
|
||||
@@ -2174,6 +2218,7 @@ export function tryGetTextOfPropertyName(name: PropertyName | NoSubstitutionTemp
|
||||
return name.emitNode?.autoGenerate ? undefined : name.escapedText;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.BigIntLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return escapeLeadingUnderscores(name.text);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
@@ -3551,6 +3596,7 @@ export function isInExpressionContext(node: Node): boolean {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (parent as ExpressionWithTypeArguments).expression === node && !isPartOfTypeNode(parent);
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
// TODO(jakebailey): it's possible that node could be the name, too
|
||||
return (parent as ShorthandPropertyAssignment).objectAssignmentInitializer === node;
|
||||
case SyntaxKind.SatisfiesExpression:
|
||||
return node === (parent as SatisfiesExpression).expression;
|
||||
@@ -4116,7 +4162,26 @@ export function isFunctionSymbol(symbol: Symbol | undefined) {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function tryGetModuleSpecifierFromDeclaration(node: AnyImportOrBareOrAccessedRequire | AliasDeclarationNode | ExportDeclaration | ImportTypeNode | JSDocImportTag): StringLiteralLike | undefined {
|
||||
export function canHaveModuleSpecifier(node: Node | undefined): node is CanHaveModuleSpecifier {
|
||||
switch (node?.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.NamespaceExport:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ImportType:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function tryGetModuleSpecifierFromDeclaration(node: CanHaveModuleSpecifier | JSDocImportTag): StringLiteralLike | undefined {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
@@ -5168,6 +5233,7 @@ export function getPropertyNameForPropertyNameNode(name: PropertyName | JsxAttri
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.BigIntLiteral:
|
||||
return escapeLeadingUnderscores(name.text);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
const nameExpression = name.expression;
|
||||
@@ -7140,7 +7206,8 @@ export function modifierToFlag(token: SyntaxKind): ModifierFlags {
|
||||
return ModifierFlags.None;
|
||||
}
|
||||
|
||||
function isBinaryLogicalOperator(token: SyntaxKind): boolean {
|
||||
/** @internal */
|
||||
export function isBinaryLogicalOperator(token: SyntaxKind): boolean {
|
||||
return token === SyntaxKind.BarBarToken || token === SyntaxKind.AmpersandAmpersandToken;
|
||||
}
|
||||
|
||||
@@ -8692,11 +8759,11 @@ function isFileModuleFromUsingJSXTag(file: SourceFile): Node | undefined {
|
||||
* Note that this requires file.impliedNodeFormat be set already; meaning it must be set very early on
|
||||
* in SourceFile construction.
|
||||
*/
|
||||
function isFileForcedToBeModuleByFormat(file: SourceFile): true | undefined {
|
||||
function isFileForcedToBeModuleByFormat(file: SourceFile, options: CompilerOptions): true | undefined {
|
||||
// Excludes declaration files - they still require an explicit `export {}` or the like
|
||||
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
||||
// that aren't esm-mode (meaning not in a `type: module` scope).
|
||||
return (file.impliedNodeFormat === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts]))) && !file.isDeclarationFile ? true : undefined;
|
||||
return (getImpliedNodeFormatForEmitWorker(file, options) === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts]))) && !file.isDeclarationFile ? true : undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -8717,17 +8784,29 @@ export function getSetExternalModuleIndicator(options: CompilerOptions): (file:
|
||||
// If module is nodenext or node16, all esm format files are modules
|
||||
// If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
|
||||
// otherwise, the presence of import or export statments (or import.meta) implies module-ness
|
||||
const checks: ((file: SourceFile) => Node | true | undefined)[] = [isFileProbablyExternalModule];
|
||||
const checks: ((file: SourceFile, options: CompilerOptions) => Node | true | undefined)[] = [isFileProbablyExternalModule];
|
||||
if (options.jsx === JsxEmit.ReactJSX || options.jsx === JsxEmit.ReactJSXDev) {
|
||||
checks.push(isFileModuleFromUsingJSXTag);
|
||||
}
|
||||
checks.push(isFileForcedToBeModuleByFormat);
|
||||
const combined = or(...checks);
|
||||
const callback = (file: SourceFile) => void (file.externalModuleIndicator = combined(file));
|
||||
const callback = (file: SourceFile) => void (file.externalModuleIndicator = combined(file, options));
|
||||
return callback;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Returns true if an `import` and a `require` of the same module specifier
|
||||
* can resolve to a different file.
|
||||
*/
|
||||
export function importSyntaxAffectsModuleResolution(options: CompilerOptions) {
|
||||
const moduleResolution = getEmitModuleResolutionKind(options);
|
||||
return ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext
|
||||
|| getResolvePackageJsonExports(options)
|
||||
|| getResolvePackageJsonImports(options);
|
||||
}
|
||||
|
||||
type CompilerOptionKeys = keyof { [K in keyof CompilerOptions as string extends K ? never : K]: any; };
|
||||
function createComputedCompilerOptions<T extends Record<string, CompilerOptionKeys[]>>(
|
||||
options: {
|
||||
@@ -8947,6 +9026,12 @@ export const computedOptions = createComputedCompilerOptions({
|
||||
return getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
|
||||
},
|
||||
},
|
||||
strictBuiltinIteratorReturn: {
|
||||
dependencies: ["strict"],
|
||||
computeValue: compilerOptions => {
|
||||
return getStrictOptionValue(compilerOptions, "strictBuiltinIteratorReturn");
|
||||
},
|
||||
},
|
||||
alwaysStrict: {
|
||||
dependencies: ["strict"],
|
||||
computeValue: compilerOptions => {
|
||||
@@ -9034,6 +9119,7 @@ export type StrictOptionName =
|
||||
| "strictFunctionTypes"
|
||||
| "strictBindCallApply"
|
||||
| "strictPropertyInitialization"
|
||||
| "strictBuiltinIteratorReturn"
|
||||
| "alwaysStrict"
|
||||
| "useUnknownInCatchVariables";
|
||||
|
||||
@@ -9084,10 +9170,16 @@ export function getJSXTransformEnabled(options: CompilerOptions): boolean {
|
||||
export function getJSXImplicitImportBase(compilerOptions: CompilerOptions, file?: SourceFile): string | undefined {
|
||||
const jsxImportSourcePragmas = file?.pragmas.get("jsximportsource");
|
||||
const jsxImportSourcePragma = isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas;
|
||||
const jsxRuntimePragmas = file?.pragmas.get("jsxruntime");
|
||||
const jsxRuntimePragma = isArray(jsxRuntimePragmas) ? jsxRuntimePragmas[jsxRuntimePragmas.length - 1] : jsxRuntimePragmas;
|
||||
if (jsxRuntimePragma?.arguments.factory === "classic") {
|
||||
return undefined;
|
||||
}
|
||||
return compilerOptions.jsx === JsxEmit.ReactJSX ||
|
||||
compilerOptions.jsx === JsxEmit.ReactJSXDev ||
|
||||
compilerOptions.jsxImportSource ||
|
||||
jsxImportSourcePragma ?
|
||||
jsxImportSourcePragma ||
|
||||
jsxRuntimePragma?.arguments.factory === "automatic" ?
|
||||
jsxImportSourcePragma?.arguments.factory || compilerOptions.jsxImportSource || "react" :
|
||||
undefined;
|
||||
}
|
||||
@@ -9516,7 +9608,7 @@ export function matchFiles(path: string, extensions: readonly string[] | undefin
|
||||
visited.set(canonicalPath, true);
|
||||
const { files, directories } = getFileSystemEntries(path);
|
||||
|
||||
for (const current of sort<string>(files, compareStringsCaseSensitive)) {
|
||||
for (const current of toSorted<string>(files, compareStringsCaseSensitive)) {
|
||||
const name = combinePaths(path, current);
|
||||
const absoluteName = combinePaths(absolutePath, current);
|
||||
if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
|
||||
@@ -9539,7 +9631,7 @@ export function matchFiles(path: string, extensions: readonly string[] | undefin
|
||||
}
|
||||
}
|
||||
|
||||
for (const current of sort<string>(directories, compareStringsCaseSensitive)) {
|
||||
for (const current of toSorted<string>(directories, compareStringsCaseSensitive)) {
|
||||
const name = combinePaths(path, current);
|
||||
const absoluteName = combinePaths(absolutePath, current);
|
||||
if (
|
||||
@@ -11693,6 +11785,12 @@ export function hasInferredType(node: Node): node is HasInferredType {
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isSideEffectImport(node: Node): boolean {
|
||||
const ancestor = findAncestor(node, isImportDeclaration);
|
||||
return !!ancestor && !ancestor.importClause;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getLambdaArgument(node: Node): FunctionLikeDeclaration | undefined {
|
||||
switch (node.kind) {
|
||||
|
||||
@@ -57,6 +57,7 @@ import {
|
||||
getDirectoryPath,
|
||||
getEmitDeclarations,
|
||||
getEmitScriptTarget,
|
||||
getImpliedNodeFormatForEmitWorker,
|
||||
getLineAndCharacterOfPosition,
|
||||
getNameOfScriptTarget,
|
||||
getNewLineCharacter,
|
||||
@@ -352,13 +353,14 @@ export function explainFiles(program: Program, write: (s: string) => void) {
|
||||
for (const file of program.getSourceFiles()) {
|
||||
write(`${toFileName(file, relativeFileName)}`);
|
||||
reasons.get(file.path)?.forEach(reason => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
||||
explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)?.forEach(d => write(` ${d.messageText}`));
|
||||
explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file), relativeFileName)?.forEach(d => write(` ${d.messageText}`));
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function explainIfFileIsRedirectAndImpliedFormat(
|
||||
file: SourceFile,
|
||||
options: CompilerOptions,
|
||||
fileNameConvertor?: (fileName: string) => string,
|
||||
): DiagnosticMessageChain[] | undefined {
|
||||
let result: DiagnosticMessageChain[] | undefined;
|
||||
@@ -377,7 +379,7 @@ export function explainIfFileIsRedirectAndImpliedFormat(
|
||||
));
|
||||
}
|
||||
if (isExternalOrCommonJsModule(file)) {
|
||||
switch (file.impliedNodeFormat) {
|
||||
switch (getImpliedNodeFormatForEmitWorker(file, options)) {
|
||||
case ModuleKind.ESNext:
|
||||
if (file.packageJsonScope) {
|
||||
(result ??= []).push(chainDiagnosticMessages(
|
||||
|
||||
@@ -486,8 +486,8 @@ export function updateMissingFilePathsWatch(
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface WildcardDirectoryWatcher {
|
||||
watcher: FileWatcher;
|
||||
export interface WildcardDirectoryWatcher<T extends FileWatcher = FileWatcher> {
|
||||
watcher: T;
|
||||
flags: WatchDirectoryFlags;
|
||||
}
|
||||
|
||||
@@ -499,10 +499,10 @@ export interface WildcardDirectoryWatcher {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function updateWatchingWildcardDirectories(
|
||||
existingWatchedForWildcards: Map<string, WildcardDirectoryWatcher>,
|
||||
export function updateWatchingWildcardDirectories<T extends FileWatcher>(
|
||||
existingWatchedForWildcards: Map<string, WildcardDirectoryWatcher<T>>,
|
||||
wildcardDirectories: MapLike<WatchDirectoryFlags> | undefined,
|
||||
watchDirectory: (directory: string, flags: WatchDirectoryFlags) => FileWatcher,
|
||||
watchDirectory: (directory: string, flags: WatchDirectoryFlags) => T,
|
||||
) {
|
||||
if (wildcardDirectories) {
|
||||
mutateMap(
|
||||
@@ -522,7 +522,7 @@ export function updateWatchingWildcardDirectories(
|
||||
clearMap(existingWatchedForWildcards, closeFileWatcherOf);
|
||||
}
|
||||
|
||||
function createWildcardDirectoryWatcher(directory: string, flags: WatchDirectoryFlags): WildcardDirectoryWatcher {
|
||||
function createWildcardDirectoryWatcher(directory: string, flags: WatchDirectoryFlags): WildcardDirectoryWatcher<T> {
|
||||
// Create new watch and recursive info
|
||||
return {
|
||||
watcher: watchDirectory(directory, flags),
|
||||
@@ -530,7 +530,7 @@ export function updateWatchingWildcardDirectories(
|
||||
};
|
||||
}
|
||||
|
||||
function updateWildcardDirectoryWatcher(existingWatcher: WildcardDirectoryWatcher, flags: WatchDirectoryFlags, directory: string) {
|
||||
function updateWildcardDirectoryWatcher(existingWatcher: WildcardDirectoryWatcher<T>, flags: WatchDirectoryFlags, directory: string) {
|
||||
// Watcher needs to be updated if the recursive flags dont match
|
||||
if (existingWatcher.flags === flags) {
|
||||
return;
|
||||
|
||||
@@ -300,6 +300,7 @@ export class SessionClient implements LanguageService {
|
||||
|
||||
return entry as { name: string; kind: ScriptElementKind; kindModifiers: string; sortText: string; }; // TODO: GH#18217
|
||||
}),
|
||||
defaultCommitCharacters: response.body!.defaultCommitCharacters,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ export class SortedMap<K, V> {
|
||||
this._copyOnWrite = false;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public *values() {
|
||||
@@ -154,6 +155,7 @@ export class SortedMap<K, V> {
|
||||
this._copyOnWrite = false;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public *entries() {
|
||||
@@ -179,6 +181,7 @@ export class SortedMap<K, V> {
|
||||
this._copyOnWrite = false;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public [Symbol.iterator]() {
|
||||
|
||||
@@ -1024,7 +1024,7 @@ export class TestState {
|
||||
}
|
||||
|
||||
if (ts.hasProperty(options, "isGlobalCompletion") && actualCompletions.isGlobalCompletion !== options.isGlobalCompletion) {
|
||||
this.raiseError(`Expected 'isGlobalCompletion to be ${options.isGlobalCompletion}, got ${actualCompletions.isGlobalCompletion}`);
|
||||
this.raiseError(`Expected 'isGlobalCompletion' to be ${options.isGlobalCompletion}, got ${actualCompletions.isGlobalCompletion}`);
|
||||
}
|
||||
|
||||
if (ts.hasProperty(options, "optionalReplacementSpan")) {
|
||||
@@ -1035,6 +1035,14 @@ export class TestState {
|
||||
);
|
||||
}
|
||||
|
||||
if (ts.hasProperty(options, "defaultCommitCharacters")) {
|
||||
assert.deepEqual(
|
||||
actualCompletions.defaultCommitCharacters?.sort(),
|
||||
options.defaultCommitCharacters?.sort(),
|
||||
"Expected 'defaultCommitCharacters' properties to match",
|
||||
);
|
||||
}
|
||||
|
||||
const nameToEntries = new Map<string, ts.CompletionEntry[]>();
|
||||
const nameAndSourceToData = new Map<string, ts.CompletionEntryData | false>();
|
||||
for (const entry of actualCompletions.entries) {
|
||||
@@ -1181,6 +1189,13 @@ export class TestState {
|
||||
assert.equal(actual.isSnippet, expected.isSnippet, `At entry ${actual.name}: Expected 'isSnippet' properties to match`);
|
||||
assert.equal(actual.source, expected.source, `At entry ${actual.name}: Expected 'source' values to match`);
|
||||
assert.equal(actual.sortText, expected.sortText || ts.Completions.SortText.LocationPriority, `At entry ${actual.name}: Expected 'sortText' properties to match`);
|
||||
if (ts.hasProperty(expected, "commitCharacters")) {
|
||||
assert.deepEqual(
|
||||
actual.commitCharacters?.sort(),
|
||||
expected.commitCharacters?.sort(),
|
||||
`At entry ${actual.name}: Expected 'commitCharacters' values to match`,
|
||||
);
|
||||
}
|
||||
if (expected.sourceDisplay && actual.sourceDisplay) {
|
||||
assert.equal(ts.displayPartsToString(actual.sourceDisplay), expected.sourceDisplay, `At entry ${actual.name}: Expected 'sourceDisplay' properties to match`);
|
||||
}
|
||||
@@ -1606,7 +1621,7 @@ export class TestState {
|
||||
}
|
||||
}
|
||||
let pos = 0;
|
||||
const sortedDetails = ts.stableSort(details, (a, b) => ts.compareValues(a.location, b.location));
|
||||
const sortedDetails = ts.toSorted(details, (a, b) => ts.compareValues(a.location, b.location));
|
||||
if (!canDetermineContextIdInline) {
|
||||
// Assign contextIds
|
||||
sortedDetails.forEach(({ span, type }) => {
|
||||
|
||||
@@ -1121,7 +1121,7 @@ export namespace Completion {
|
||||
].map(keywordEntry);
|
||||
|
||||
export function sorted(entries: readonly ExpectedCompletionEntry[]): readonly ExpectedCompletionEntry[] {
|
||||
return ts.stableSort(entries, compareExpectedCompletionEntries);
|
||||
return ts.toSorted(entries, compareExpectedCompletionEntries);
|
||||
}
|
||||
|
||||
// If you want to use a function like `globalsPlus`, that function needs to sort
|
||||
@@ -1797,6 +1797,7 @@ export interface ExpectedCompletionEntryObject {
|
||||
readonly labelDetails?: ExpectedCompletionEntryLabelDetails;
|
||||
readonly tags?: readonly ts.JSDocTagInfo[];
|
||||
readonly sortText?: ts.Completions.SortText;
|
||||
readonly commitCharacters?: string[]; // If not specified, won't assert about this
|
||||
}
|
||||
|
||||
export interface ExpectedCompletionEntryLabelDetails {
|
||||
@@ -1820,6 +1821,7 @@ export interface VerifyCompletionsOptions {
|
||||
readonly excludes?: ArrayOrSingle<string>;
|
||||
readonly preferences?: ts.UserPreferences;
|
||||
readonly triggerCharacter?: ts.CompletionsTriggerCharacter;
|
||||
readonly defaultCommitCharacters?: string[]; // Only tested if set
|
||||
}
|
||||
|
||||
export interface VerifySignatureHelpOptions {
|
||||
|
||||
@@ -547,7 +547,7 @@ export namespace Compiler {
|
||||
export const diagnosticSummaryMarker = "__diagnosticSummary";
|
||||
export const globalErrorsMarker = "__globalErrors";
|
||||
export function* iterateErrorBaseline(inputFiles: readonly TestFile[], diagnostics: readonly ts.Diagnostic[], options?: { pretty?: boolean; caseSensitive?: boolean; currentDirectory?: string; }): IterableIterator<[string, string, number]> {
|
||||
diagnostics = ts.sort(diagnostics, ts.compareDiagnostics);
|
||||
diagnostics = ts.toSorted(diagnostics, ts.compareDiagnostics);
|
||||
let outputLines = "";
|
||||
// Count up all errors that were found in files other than lib.d.ts so we don't miss any
|
||||
let totalErrorsReportedInNonLibraryNonTsconfigFiles = 0;
|
||||
|
||||
+14
-6
@@ -2,14 +2,22 @@
|
||||
/// Window Async Iterable APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface FileSystemDirectoryHandle {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
|
||||
entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
|
||||
keys(): AsyncIterableIterator<string>;
|
||||
values(): AsyncIterableIterator<FileSystemHandle>;
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
|
||||
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemHandle>;
|
||||
}
|
||||
|
||||
interface ReadableStreamAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadableStream<R = any> {
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
}
|
||||
|
||||
Vendored
+349
-858
File diff suppressed because it is too large
Load Diff
Vendored
+35
-23
@@ -1,30 +1,34 @@
|
||||
/// <reference lib="dom" />
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all key/value pairs contained in this object.
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all keys f the key/value pairs contained in this object.
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): HeadersIterator<string>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): IterableIterator<[number, Node]>;
|
||||
entries(): ArrayIterator<[number, Node]>;
|
||||
/**
|
||||
* Performs the specified action for each node in an list.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
|
||||
@@ -34,21 +38,21 @@ interface NodeList {
|
||||
/**
|
||||
* Returns an list of keys in the list
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the list
|
||||
*/
|
||||
values(): IterableIterator<Node>;
|
||||
values(): ArrayIterator<Node>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<Node>;
|
||||
[Symbol.iterator](): ArrayIterator<Node>;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): IterableIterator<[number, TNode]>;
|
||||
entries(): ArrayIterator<[number, TNode]>;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each node in an list.
|
||||
@@ -59,55 +63,63 @@ interface NodeListOf<TNode extends Node> {
|
||||
/**
|
||||
* Returns an list of keys in the list
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the list
|
||||
*/
|
||||
values(): IterableIterator<TNode>;
|
||||
values(): ArrayIterator<TNode>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<TNode>;
|
||||
[Symbol.iterator](): ArrayIterator<TNode>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionBase {
|
||||
[Symbol.iterator](): IterableIterator<Element>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionOf<T extends Element> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): IterableIterator<[string, string | File]>;
|
||||
entries(): FormDataIterator<[string, string | File]>;
|
||||
/**
|
||||
* Returns a list of keys in the list
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): FormDataIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the list
|
||||
*/
|
||||
values(): IterableIterator<string | File>;
|
||||
values(): FormDataIterator<string | File>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<string | File>;
|
||||
[Symbol.iterator](): FormDataIterator<string | File>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the search params
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/**
|
||||
* Returns a list of keys in the search params
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the search params
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
/**
|
||||
* iterate over key/value pairs
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
}
|
||||
|
||||
Vendored
+95
-79
@@ -23,36 +23,36 @@ interface BaseAudioContext {
|
||||
}
|
||||
|
||||
interface CSSKeyframesRule {
|
||||
[Symbol.iterator](): IterableIterator<CSSKeyframeRule>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSKeyframeRule>;
|
||||
}
|
||||
|
||||
interface CSSNumericArray {
|
||||
[Symbol.iterator](): IterableIterator<CSSNumericValue>;
|
||||
entries(): IterableIterator<[number, CSSNumericValue]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<CSSNumericValue>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSNumericValue>;
|
||||
entries(): ArrayIterator<[number, CSSNumericValue]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSNumericValue>;
|
||||
}
|
||||
|
||||
interface CSSRuleList {
|
||||
[Symbol.iterator](): IterableIterator<CSSRule>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSRule>;
|
||||
}
|
||||
|
||||
interface CSSStyleDeclaration {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface CSSTransformValue {
|
||||
[Symbol.iterator](): IterableIterator<CSSTransformComponent>;
|
||||
entries(): IterableIterator<[number, CSSTransformComponent]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<CSSTransformComponent>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSTransformComponent>;
|
||||
entries(): ArrayIterator<[number, CSSTransformComponent]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSTransformComponent>;
|
||||
}
|
||||
|
||||
interface CSSUnparsedValue {
|
||||
[Symbol.iterator](): IterableIterator<CSSUnparsedSegment>;
|
||||
entries(): IterableIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<CSSUnparsedSegment>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSUnparsedSegment>;
|
||||
entries(): ArrayIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSUnparsedSegment>;
|
||||
}
|
||||
|
||||
interface Cache {
|
||||
@@ -74,72 +74,80 @@ interface CustomStateSet extends Set<string> {
|
||||
}
|
||||
|
||||
interface DOMRectList {
|
||||
[Symbol.iterator](): IterableIterator<DOMRect>;
|
||||
[Symbol.iterator](): ArrayIterator<DOMRect>;
|
||||
}
|
||||
|
||||
interface DOMStringList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
entries(): IterableIterator<[number, string]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
entries(): ArrayIterator<[number, string]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface DataTransferItemList {
|
||||
[Symbol.iterator](): IterableIterator<DataTransferItem>;
|
||||
[Symbol.iterator](): ArrayIterator<DataTransferItem>;
|
||||
}
|
||||
|
||||
interface EventCounts extends ReadonlyMap<string, number> {
|
||||
}
|
||||
|
||||
interface FileList {
|
||||
[Symbol.iterator](): IterableIterator<File>;
|
||||
[Symbol.iterator](): ArrayIterator<File>;
|
||||
}
|
||||
|
||||
interface FontFaceSet extends Set<FontFace> {
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
|
||||
[Symbol.iterator](): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
||||
entries(): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns a list of keys in the list. */
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): FormDataIterator<string>;
|
||||
/** Returns a list of values in the list. */
|
||||
values(): IterableIterator<FormDataEntryValue>;
|
||||
values(): FormDataIterator<FormDataEntryValue>;
|
||||
}
|
||||
|
||||
interface HTMLAllCollection {
|
||||
[Symbol.iterator](): IterableIterator<Element>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionBase {
|
||||
[Symbol.iterator](): IterableIterator<Element>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionOf<T extends Element> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface HTMLFormElement {
|
||||
[Symbol.iterator](): IterableIterator<Element>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLSelectElement {
|
||||
[Symbol.iterator](): IterableIterator<HTMLOptionElement>;
|
||||
[Symbol.iterator](): ArrayIterator<HTMLOptionElement>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): HeadersIterator<string>;
|
||||
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
|
||||
values(): IterableIterator<string>;
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface Highlight extends Set<AbstractRange> {
|
||||
@@ -179,32 +187,32 @@ interface MIDIOutput {
|
||||
interface MIDIOutputMap extends ReadonlyMap<string, MIDIOutput> {
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): MediaKeyStatusMapIterator<T>;
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMap {
|
||||
[Symbol.iterator](): IterableIterator<[BufferSource, MediaKeyStatus]>;
|
||||
entries(): IterableIterator<[BufferSource, MediaKeyStatus]>;
|
||||
keys(): IterableIterator<BufferSource>;
|
||||
values(): IterableIterator<MediaKeyStatus>;
|
||||
[Symbol.iterator](): MediaKeyStatusMapIterator<[BufferSource, MediaKeyStatus]>;
|
||||
entries(): MediaKeyStatusMapIterator<[BufferSource, MediaKeyStatus]>;
|
||||
keys(): MediaKeyStatusMapIterator<BufferSource>;
|
||||
values(): MediaKeyStatusMapIterator<MediaKeyStatus>;
|
||||
}
|
||||
|
||||
interface MediaList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface MessageEvent<T = any> {
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/initMessageEvent)
|
||||
*/
|
||||
/** @deprecated */
|
||||
initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: Iterable<MessagePort>): void;
|
||||
}
|
||||
|
||||
interface MimeTypeArray {
|
||||
[Symbol.iterator](): IterableIterator<MimeType>;
|
||||
[Symbol.iterator](): ArrayIterator<MimeType>;
|
||||
}
|
||||
|
||||
interface NamedNodeMap {
|
||||
[Symbol.iterator](): IterableIterator<Attr>;
|
||||
[Symbol.iterator](): ArrayIterator<Attr>;
|
||||
}
|
||||
|
||||
interface Navigator {
|
||||
@@ -219,82 +227,86 @@ interface Navigator {
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): IterableIterator<Node>;
|
||||
[Symbol.iterator](): ArrayIterator<Node>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): IterableIterator<[number, Node]>;
|
||||
entries(): ArrayIterator<[number, Node]>;
|
||||
/** Returns an list of keys in the list. */
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/** Returns an list of values in the list. */
|
||||
values(): IterableIterator<Node>;
|
||||
values(): ArrayIterator<Node>;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): IterableIterator<TNode>;
|
||||
[Symbol.iterator](): ArrayIterator<TNode>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): IterableIterator<[number, TNode]>;
|
||||
entries(): ArrayIterator<[number, TNode]>;
|
||||
/** Returns an list of keys in the list. */
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/** Returns an list of values in the list. */
|
||||
values(): IterableIterator<TNode>;
|
||||
values(): ArrayIterator<TNode>;
|
||||
}
|
||||
|
||||
interface Plugin {
|
||||
[Symbol.iterator](): IterableIterator<MimeType>;
|
||||
[Symbol.iterator](): ArrayIterator<MimeType>;
|
||||
}
|
||||
|
||||
interface PluginArray {
|
||||
[Symbol.iterator](): IterableIterator<Plugin>;
|
||||
[Symbol.iterator](): ArrayIterator<Plugin>;
|
||||
}
|
||||
|
||||
interface RTCRtpTransceiver {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/RTCRtpTransceiver/setCodecPreferences) */
|
||||
setCodecPreferences(codecs: Iterable<RTCRtpCodecCapability>): void;
|
||||
setCodecPreferences(codecs: Iterable<RTCRtpCodec>): void;
|
||||
}
|
||||
|
||||
interface RTCStatsReport extends ReadonlyMap<string, any> {
|
||||
}
|
||||
|
||||
interface SVGLengthList {
|
||||
[Symbol.iterator](): IterableIterator<SVGLength>;
|
||||
[Symbol.iterator](): ArrayIterator<SVGLength>;
|
||||
}
|
||||
|
||||
interface SVGNumberList {
|
||||
[Symbol.iterator](): IterableIterator<SVGNumber>;
|
||||
[Symbol.iterator](): ArrayIterator<SVGNumber>;
|
||||
}
|
||||
|
||||
interface SVGPointList {
|
||||
[Symbol.iterator](): IterableIterator<DOMPoint>;
|
||||
[Symbol.iterator](): ArrayIterator<DOMPoint>;
|
||||
}
|
||||
|
||||
interface SVGStringList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface SVGTransformList {
|
||||
[Symbol.iterator](): IterableIterator<SVGTransform>;
|
||||
[Symbol.iterator](): ArrayIterator<SVGTransform>;
|
||||
}
|
||||
|
||||
interface SourceBufferList {
|
||||
[Symbol.iterator](): IterableIterator<SourceBuffer>;
|
||||
[Symbol.iterator](): ArrayIterator<SourceBuffer>;
|
||||
}
|
||||
|
||||
interface SpeechRecognitionResult {
|
||||
[Symbol.iterator](): IterableIterator<SpeechRecognitionAlternative>;
|
||||
[Symbol.iterator](): ArrayIterator<SpeechRecognitionAlternative>;
|
||||
}
|
||||
|
||||
interface SpeechRecognitionResultList {
|
||||
[Symbol.iterator](): IterableIterator<SpeechRecognitionResult>;
|
||||
[Symbol.iterator](): ArrayIterator<SpeechRecognitionResult>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnlyIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<T>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnly {
|
||||
[Symbol.iterator](): IterableIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): IterableIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): IterableIterator<string>;
|
||||
values(): IterableIterator<Iterable<CSSStyleValue>>;
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): StylePropertyMapReadOnlyIterator<string>;
|
||||
values(): StylePropertyMapReadOnlyIterator<Iterable<CSSStyleValue>>;
|
||||
}
|
||||
|
||||
interface StyleSheetList {
|
||||
[Symbol.iterator](): IterableIterator<CSSStyleSheet>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSStyleSheet>;
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
@@ -313,25 +325,29 @@ interface SubtleCrypto {
|
||||
}
|
||||
|
||||
interface TextTrackCueList {
|
||||
[Symbol.iterator](): IterableIterator<TextTrackCue>;
|
||||
[Symbol.iterator](): ArrayIterator<TextTrackCue>;
|
||||
}
|
||||
|
||||
interface TextTrackList {
|
||||
[Symbol.iterator](): IterableIterator<TextTrack>;
|
||||
[Symbol.iterator](): ArrayIterator<TextTrack>;
|
||||
}
|
||||
|
||||
interface TouchList {
|
||||
[Symbol.iterator](): IterableIterator<Touch>;
|
||||
[Symbol.iterator](): ArrayIterator<Touch>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns an array of key, value pairs for every entry in the search params. */
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns a list of keys in the search params. */
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/** Returns a list of values in the search params. */
|
||||
values(): IterableIterator<string>;
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
}
|
||||
|
||||
interface WEBGL_draw_buffers {
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
/// <reference lib="es2015.iterable" />
|
||||
|
||||
interface Generator<T = unknown, TReturn = any, TNext = unknown> extends Iterator<T, TReturn, TNext> {
|
||||
interface Generator<T = unknown, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
return(value: TReturn): IteratorResult<T, TReturn>;
|
||||
throw(e: any): IteratorResult<T, TReturn>;
|
||||
[Symbol.iterator](): Generator<T, TReturn, TNext>;
|
||||
|
||||
Vendored
+100
-68
@@ -20,39 +20,59 @@ interface IteratorReturnResult<TReturn> {
|
||||
|
||||
type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
|
||||
|
||||
interface Iterator<T, TReturn = any, TNext = undefined> {
|
||||
interface Iterator<T, TReturn = any, TNext = any> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
return?(value?: TReturn): IteratorResult<T, TReturn>;
|
||||
throw?(e?: any): IteratorResult<T, TReturn>;
|
||||
}
|
||||
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
interface Iterable<T, TReturn = any, TNext = any> {
|
||||
[Symbol.iterator](): Iterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
/**
|
||||
* Describes a user-defined {@link Iterator} that is also iterable.
|
||||
*/
|
||||
interface IterableIterator<T, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes an {@link Iterator} produced by the runtime that inherits from the intrinsic `Iterator.prototype`.
|
||||
*/
|
||||
interface IteratorObject<T, TReturn = unknown, TNext = unknown> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the `TReturn` type used for built-in iterators produced by `Array`, `Map`, `Set`, and others.
|
||||
* This is `undefined` when `strictBuiltInIteratorReturn` is `true`; otherwise, this is `any`.
|
||||
*/
|
||||
type BuiltinIteratorReturn = intrinsic;
|
||||
|
||||
interface ArrayIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
entries(): ArrayIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
values(): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
@@ -73,67 +93,71 @@ interface ArrayConstructor {
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator of values in the array. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
entries(): ArrayIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
values(): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
[Symbol.iterator](): ArrayIterator<any>;
|
||||
}
|
||||
|
||||
interface MapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): MapIterator<T>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
[Symbol.iterator](): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
entries(): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
keys(): MapIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
values(): MapIterator<V>;
|
||||
}
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
[Symbol.iterator](): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
entries(): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
keys(): MapIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
values(): MapIterator<V>;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
@@ -147,42 +171,46 @@ interface WeakMapConstructor {
|
||||
new <K extends WeakKey, V>(iterable: Iterable<readonly [K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface SetIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
entries(): SetIterator<[T, T]>;
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set.
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
keys(): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
values(): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
entries(): SetIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set.
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
keys(): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
values(): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
@@ -215,25 +243,29 @@ interface PromiseConstructor {
|
||||
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
||||
}
|
||||
|
||||
interface StringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StringIterator<T>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): StringIterator<string>;
|
||||
}
|
||||
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
@@ -249,19 +281,19 @@ interface Int8ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
@@ -277,21 +309,21 @@ interface Uint8ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
@@ -307,21 +339,21 @@ interface Uint8ClampedArrayConstructor {
|
||||
}
|
||||
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
@@ -337,19 +369,19 @@ interface Int16ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
@@ -365,19 +397,19 @@ interface Uint16ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
@@ -393,19 +425,19 @@ interface Int32ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
@@ -421,19 +453,19 @@ interface Uint32ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
@@ -449,19 +481,19 @@ interface Float32ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
/// <reference lib="es2018.asynciterable" />
|
||||
|
||||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
|
||||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw(e: any): Promise<IteratorResult<T, TReturn>>;
|
||||
[Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
|
||||
|
||||
Vendored
+16
-6
@@ -9,17 +9,27 @@ interface SymbolConstructor {
|
||||
readonly asyncIterator: unique symbol;
|
||||
}
|
||||
|
||||
interface AsyncIterator<T, TReturn = any, TNext = undefined> {
|
||||
interface AsyncIterator<T, TReturn = any, TNext = any> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
|
||||
}
|
||||
|
||||
interface AsyncIterable<T> {
|
||||
[Symbol.asyncIterator](): AsyncIterator<T>;
|
||||
interface AsyncIterable<T, TReturn = any, TNext = any> {
|
||||
[Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
||||
/**
|
||||
* Describes a user-defined {@link AsyncIterator} that is also async iterable.
|
||||
*/
|
||||
interface AsyncIterableIterator<T, TReturn = any, TNext = any> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes an {@link AsyncIterator} produced by the runtime that inherits from the intrinsic `AsyncIterator.prototype`.
|
||||
*/
|
||||
interface AsyncIteratorObject<T, TReturn = unknown, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): AsyncIteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
Vendored
+8
-8
@@ -153,7 +153,7 @@ interface BigInt64Array {
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/** Yields index, value pairs for every entry in the array. */
|
||||
entries(): IterableIterator<[number, bigint]>;
|
||||
entries(): ArrayIterator<[number, bigint]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -238,7 +238,7 @@ interface BigInt64Array {
|
||||
join(separator?: string): string;
|
||||
|
||||
/** Yields each index in the array. */
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -360,9 +360,9 @@ interface BigInt64Array {
|
||||
valueOf(): BigInt64Array;
|
||||
|
||||
/** Yields each value in the array. */
|
||||
values(): IterableIterator<bigint>;
|
||||
values(): ArrayIterator<bigint>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<bigint>;
|
||||
[Symbol.iterator](): ArrayIterator<bigint>;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigInt64Array";
|
||||
|
||||
@@ -425,7 +425,7 @@ interface BigUint64Array {
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/** Yields index, value pairs for every entry in the array. */
|
||||
entries(): IterableIterator<[number, bigint]>;
|
||||
entries(): ArrayIterator<[number, bigint]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -510,7 +510,7 @@ interface BigUint64Array {
|
||||
join(separator?: string): string;
|
||||
|
||||
/** Yields each index in the array. */
|
||||
keys(): IterableIterator<number>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -632,9 +632,9 @@ interface BigUint64Array {
|
||||
valueOf(): BigUint64Array;
|
||||
|
||||
/** Yields each value in the array. */
|
||||
values(): IterableIterator<bigint>;
|
||||
values(): ArrayIterator<bigint>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<bigint>;
|
||||
[Symbol.iterator](): ArrayIterator<bigint>;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigUint64Array";
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
/// <reference lib="es2015.iterable" />
|
||||
/// <reference lib="es2020.symbol.wellknown" />
|
||||
|
||||
interface String {
|
||||
/**
|
||||
@@ -6,7 +6,7 @@ interface String {
|
||||
* containing the results of that search.
|
||||
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
|
||||
*/
|
||||
matchAll(regexp: RegExp): IterableIterator<RegExpExecArray>;
|
||||
matchAll(regexp: RegExp): RegExpStringIterator<RegExpExecArray>;
|
||||
|
||||
/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
|
||||
toLocaleLowerCase(locales?: Intl.LocalesArgument): string;
|
||||
|
||||
Vendored
+5
-1
@@ -9,11 +9,15 @@ interface SymbolConstructor {
|
||||
readonly matchAll: unique symbol;
|
||||
}
|
||||
|
||||
interface RegExpStringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): RegExpStringIterator<T>;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an iterable of matches
|
||||
* containing the results of that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.matchAll](str: string): IterableIterator<RegExpMatchArray>;
|
||||
[Symbol.matchAll](str: string): RegExpStringIterator<RegExpMatchArray>;
|
||||
}
|
||||
|
||||
Vendored
+5
-1
@@ -28,6 +28,10 @@ declare namespace Intl {
|
||||
granularity: "grapheme" | "word" | "sentence";
|
||||
}
|
||||
|
||||
interface SegmentIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): SegmentIterator<T>;
|
||||
}
|
||||
|
||||
interface Segments {
|
||||
/**
|
||||
* Returns an object describing the segment in the original string that includes the code unit at a specified index.
|
||||
@@ -37,7 +41,7 @@ declare namespace Intl {
|
||||
containing(codeUnitIndex?: number): SegmentData;
|
||||
|
||||
/** Returns an iterator to iterate over the segments. */
|
||||
[Symbol.iterator](): IterableIterator<SegmentData>;
|
||||
[Symbol.iterator](): SegmentIterator<SegmentData>;
|
||||
}
|
||||
|
||||
interface SegmentData {
|
||||
|
||||
Vendored
+5
-5
@@ -185,7 +185,7 @@ interface Int8Array {
|
||||
/**
|
||||
* Copies the array and returns the copy with the elements in reverse order.
|
||||
*/
|
||||
toReversed(): Uint8Array;
|
||||
toReversed(): Int8Array;
|
||||
|
||||
/**
|
||||
* Copies and sorts the array.
|
||||
@@ -193,11 +193,11 @@ interface Int8Array {
|
||||
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
|
||||
* value otherwise. If omitted, the elements are sorted in ascending order.
|
||||
* ```ts
|
||||
* const myNums = Uint8Array.from([11, 2, 22, 1]);
|
||||
* myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22]
|
||||
* const myNums = Int8Array.from([11, 2, 22, 1]);
|
||||
* myNums.toSorted((a, b) => a - b) // Int8Array(4) [1, 2, 11, 22]
|
||||
* ```
|
||||
*/
|
||||
toSorted(compareFn?: (a: number, b: number) => number): Uint8Array;
|
||||
toSorted(compareFn?: (a: number, b: number) => number): Int8Array;
|
||||
|
||||
/**
|
||||
* Copies the array and inserts the given number at the provided index.
|
||||
@@ -206,7 +206,7 @@ interface Int8Array {
|
||||
* @param value The value to insert into the copied array.
|
||||
* @returns A copy of the original array with the inserted value.
|
||||
*/
|
||||
with(index: number, value: number): Uint8Array;
|
||||
with(index: number, value: number): Int8Array;
|
||||
}
|
||||
|
||||
interface Uint8Array {
|
||||
|
||||
Vendored
+1
@@ -8,3 +8,4 @@
|
||||
/// <reference lib="esnext.array" />
|
||||
/// <reference lib="esnext.regexp" />
|
||||
/// <reference lib="esnext.string" />
|
||||
/// <reference lib="esnext.iterator" />
|
||||
|
||||
Vendored
+130
@@ -0,0 +1,130 @@
|
||||
/// <reference lib="es2015.iterable" />
|
||||
|
||||
// NOTE: This is specified as what is essentially an unreachable module. All actual global declarations can be found
|
||||
// in the `declare global` section, below. This is necessary as there is currently no way to declare an `abstract`
|
||||
// member without declaring a `class`, but declaring `class Iterator<T>` globally would conflict with TypeScript's
|
||||
// general purpose `Iterator<T>` interface.
|
||||
export {};
|
||||
|
||||
// Abstract type that allows us to mark `next` as `abstract`
|
||||
declare abstract class Iterator<T, TResult = undefined, TNext = unknown> { // eslint-disable-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
abstract next(value?: TNext): IteratorResult<T, TResult>;
|
||||
}
|
||||
|
||||
// Merge all members of `IteratorObject<T>` into `Iterator<T>`
|
||||
interface Iterator<T, TResult, TNext> extends globalThis.IteratorObject<T, TResult, TNext> {}
|
||||
|
||||
// Capture the `Iterator` constructor in a type we can use in the `extends` clause of `IteratorConstructor`.
|
||||
type IteratorObjectConstructor = typeof Iterator;
|
||||
|
||||
declare global {
|
||||
// Global `IteratorObject<T, TReturn, TNext>` interface that can be augmented by polyfills
|
||||
interface IteratorObject<T, TReturn, TNext> {
|
||||
/**
|
||||
* Returns this iterator.
|
||||
*/
|
||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the result of applying the callback to the values from this iterator.
|
||||
* @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator.
|
||||
*/
|
||||
map<U>(callbackfn: (value: T, index: number) => U): IteratorObject<U, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are those from this iterator for which the provided predicate returns true.
|
||||
* @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator.
|
||||
*/
|
||||
filter<S extends T>(predicate: (value: T, index: number) => value is S): IteratorObject<S, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are those from this iterator for which the provided predicate returns true.
|
||||
* @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator.
|
||||
*/
|
||||
filter(predicate: (value: T, index: number) => unknown): IteratorObject<T, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached.
|
||||
* @param limit The maximum number of values to yield.
|
||||
*/
|
||||
take(limit: number): IteratorObject<T, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the values from this iterator after skipping the provided count.
|
||||
* @param count The number of values to drop.
|
||||
*/
|
||||
drop(count: number): IteratorObject<T, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables.
|
||||
* @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result.
|
||||
*/
|
||||
flatMap<U>(callback: (value: T, index: number) => Iterator<U, unknown, undefined> | Iterable<U, unknown, undefined>): IteratorObject<U, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a value from the iterator.
|
||||
*/
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T;
|
||||
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a value from the iterator.
|
||||
*/
|
||||
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
|
||||
|
||||
/**
|
||||
* Creates a new array from the values yielded by this iterator.
|
||||
*/
|
||||
toArray(): T[];
|
||||
|
||||
/**
|
||||
* Performs the specified action for each element in the iterator.
|
||||
* @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number) => void): void;
|
||||
|
||||
/**
|
||||
* Determines whether the specified callback function returns true for any element of this iterator.
|
||||
* @param predicate A function that accepts up to two arguments. The some method calls
|
||||
* the predicate function for each element in this iterator until the predicate returns a value
|
||||
* true, or until the end of the iterator.
|
||||
*/
|
||||
some(predicate: (value: T, index: number) => unknown): boolean;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of this iterator satisfy the specified test.
|
||||
* @param predicate A function that accepts up to two arguments. The every method calls
|
||||
* the predicate function for each element in this iterator until the predicate returns
|
||||
* false, or until the end of this iterator.
|
||||
*/
|
||||
every(predicate: (value: T, index: number) => unknown): boolean;
|
||||
|
||||
/**
|
||||
* Returns the value of the first element in this iterator where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of this iterator, in
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
*/
|
||||
find<S extends T>(predicate: (value: T, index: number) => value is S): S | undefined;
|
||||
find(predicate: (value: T, index: number) => unknown): T | undefined;
|
||||
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
// Global `IteratorConstructor` interface that can be augmented by polyfills
|
||||
interface IteratorConstructor extends IteratorObjectConstructor {
|
||||
/**
|
||||
* Creates a native iterator from an iterator or iterable object.
|
||||
* Returns its input if the input already inherits from the built-in Iterator class.
|
||||
* @param value An iterator or iterable object to convert a native iterator.
|
||||
*/
|
||||
from<T>(value: Iterator<T, unknown, undefined> | Iterable<T, unknown, undefined>): IteratorObject<T, undefined, unknown>;
|
||||
}
|
||||
|
||||
var Iterator: IteratorConstructor;
|
||||
}
|
||||
@@ -80,6 +80,7 @@
|
||||
"esnext.array",
|
||||
"esnext.regexp",
|
||||
"esnext.string",
|
||||
"esnext.iterator",
|
||||
"decorators",
|
||||
"decorators.legacy",
|
||||
// Default libraries
|
||||
|
||||
+14
-6
@@ -2,14 +2,22 @@
|
||||
/// Worker Async Iterable APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface FileSystemDirectoryHandle {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
|
||||
entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
|
||||
keys(): AsyncIterableIterator<string>;
|
||||
values(): AsyncIterableIterator<FileSystemHandle>;
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
|
||||
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemHandle>;
|
||||
}
|
||||
|
||||
interface ReadableStreamAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadableStream<R = any> {
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
}
|
||||
|
||||
Vendored
+79
-100
@@ -322,10 +322,6 @@ interface ImageEncodeOptions {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface JsonWebKey {
|
||||
alg?: string;
|
||||
crv?: string;
|
||||
@@ -396,6 +392,10 @@ interface MediaEncodingConfiguration extends MediaConfiguration {
|
||||
type: MediaEncodingType;
|
||||
}
|
||||
|
||||
interface MediaStreamTrackProcessorInit {
|
||||
maxBufferSize?: number;
|
||||
}
|
||||
|
||||
interface MessageEventInit<T = any> extends EventInit {
|
||||
data?: T;
|
||||
lastEventId?: string;
|
||||
@@ -1649,6 +1649,8 @@ interface CanvasShadowStyles {
|
||||
}
|
||||
|
||||
interface CanvasState {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isContextLost) */
|
||||
isContextLost(): boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/reset) */
|
||||
reset(): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/restore) */
|
||||
@@ -1982,9 +1984,7 @@ interface DOMMatrix extends DOMMatrixReadOnly {
|
||||
rotateAxisAngleSelf(x?: number, y?: number, z?: number, angle?: number): DOMMatrix;
|
||||
rotateFromVectorSelf(x?: number, y?: number): DOMMatrix;
|
||||
rotateSelf(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrix/scale3dSelf) */
|
||||
scale3dSelf(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrix/scaleSelf) */
|
||||
scaleSelf(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
skewXSelf(sx?: number): DOMMatrix;
|
||||
skewYSelf(sy?: number): DOMMatrix;
|
||||
@@ -2001,88 +2001,48 @@ declare var DOMMatrix: {
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly) */
|
||||
interface DOMMatrixReadOnly {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/a) */
|
||||
readonly a: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/b) */
|
||||
readonly b: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/c) */
|
||||
readonly c: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/d) */
|
||||
readonly d: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/e) */
|
||||
readonly e: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/f) */
|
||||
readonly f: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/is2D) */
|
||||
readonly is2D: boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/isIdentity) */
|
||||
readonly isIdentity: boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m11) */
|
||||
readonly m11: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m12) */
|
||||
readonly m12: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m13) */
|
||||
readonly m13: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m14) */
|
||||
readonly m14: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m21) */
|
||||
readonly m21: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m22) */
|
||||
readonly m22: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m23) */
|
||||
readonly m23: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m24) */
|
||||
readonly m24: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m31) */
|
||||
readonly m31: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m32) */
|
||||
readonly m32: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m33) */
|
||||
readonly m33: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m34) */
|
||||
readonly m34: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m41) */
|
||||
readonly m41: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m42) */
|
||||
readonly m42: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m43) */
|
||||
readonly m43: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m44) */
|
||||
readonly m44: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/flipX) */
|
||||
flipX(): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/flipY) */
|
||||
flipY(): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/inverse) */
|
||||
inverse(): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/multiply) */
|
||||
multiply(other?: DOMMatrixInit): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/rotate) */
|
||||
rotate(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/rotateAxisAngle) */
|
||||
rotateAxisAngle(x?: number, y?: number, z?: number, angle?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/rotateFromVector) */
|
||||
rotateFromVector(x?: number, y?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scale) */
|
||||
scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scale3d) */
|
||||
scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scaleNonUniform)
|
||||
*/
|
||||
/** @deprecated */
|
||||
scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/skewX) */
|
||||
skewX(sx?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/skewY) */
|
||||
skewY(sy?: number): DOMMatrix;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/toFloat32Array) */
|
||||
toFloat32Array(): Float32Array;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/toFloat64Array) */
|
||||
toFloat64Array(): Float64Array;
|
||||
toJSON(): any;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/transformPoint) */
|
||||
transformPoint(point?: DOMPointInit): DOMPoint;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/translate) */
|
||||
translate(tx?: number, ty?: number, tz?: number): DOMMatrix;
|
||||
@@ -2125,7 +2085,6 @@ interface DOMPointReadOnly {
|
||||
readonly y: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/z) */
|
||||
readonly z: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/matrixTransform) */
|
||||
matrixTransform(matrix?: DOMMatrixInit): DOMPoint;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/toJSON) */
|
||||
toJSON(): any;
|
||||
@@ -2140,15 +2099,10 @@ declare var DOMPointReadOnly: {
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad) */
|
||||
interface DOMQuad {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p1) */
|
||||
readonly p1: DOMPoint;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p2) */
|
||||
readonly p2: DOMPoint;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p3) */
|
||||
readonly p3: DOMPoint;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p4) */
|
||||
readonly p4: DOMPoint;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/getBounds) */
|
||||
getBounds(): DOMRect;
|
||||
toJSON(): any;
|
||||
}
|
||||
@@ -2171,6 +2125,7 @@ interface DOMRect extends DOMRectReadOnly {
|
||||
declare var DOMRect: {
|
||||
prototype: DOMRect;
|
||||
new(x?: number, y?: number, width?: number, height?: number): DOMRect;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRect/fromRect_static) */
|
||||
fromRect(other?: DOMRectInit): DOMRect;
|
||||
};
|
||||
|
||||
@@ -2396,15 +2351,10 @@ declare var EncodedVideoChunk: {
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
|
||||
*/
|
||||
interface ErrorEvent extends Event {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */
|
||||
readonly colno: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */
|
||||
readonly error: any;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */
|
||||
readonly filename: string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */
|
||||
readonly lineno: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */
|
||||
readonly message: string;
|
||||
}
|
||||
|
||||
@@ -3721,7 +3671,7 @@ interface IDBTransaction extends EventTarget {
|
||||
/**
|
||||
* Returns a list of the names of object stores in the transaction's scope. For an upgrade transaction this is all object stores in the database.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/objectStoreNames)
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/ObjectStoreNames)
|
||||
*/
|
||||
readonly objectStoreNames: DOMStringList;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/abort_event) */
|
||||
@@ -3848,6 +3798,11 @@ declare var ImageData: {
|
||||
new(data: Uint8ClampedArray, sw: number, sh?: number, settings?: ImageDataSettings): ImageData;
|
||||
};
|
||||
|
||||
interface ImportMeta {
|
||||
url: string;
|
||||
resolve(specifier: string): string;
|
||||
}
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/KHR_parallel_shader_compile) */
|
||||
interface KHR_parallel_shader_compile {
|
||||
readonly COMPLETION_STATUS_KHR: 0x91B1;
|
||||
@@ -3901,6 +3856,26 @@ declare var MediaCapabilities: {
|
||||
new(): MediaCapabilities;
|
||||
};
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/MediaSourceHandle) */
|
||||
interface MediaSourceHandle {
|
||||
}
|
||||
|
||||
declare var MediaSourceHandle: {
|
||||
prototype: MediaSourceHandle;
|
||||
new(): MediaSourceHandle;
|
||||
};
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/MediaStreamTrackProcessor) */
|
||||
interface MediaStreamTrackProcessor {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/MediaStreamTrackProcessor/readable) */
|
||||
readonly readable: ReadableStream;
|
||||
}
|
||||
|
||||
declare var MediaStreamTrackProcessor: {
|
||||
prototype: MediaStreamTrackProcessor;
|
||||
new(init: MediaStreamTrackProcessorInit): MediaStreamTrackProcessor;
|
||||
};
|
||||
|
||||
/**
|
||||
* This Channel Messaging API interface allows us to create a new message channel and send data through it via its two MessagePort properties.
|
||||
*
|
||||
@@ -3962,11 +3937,7 @@ interface MessageEvent<T = any> extends Event {
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
|
||||
*/
|
||||
readonly source: MessageEventSource | null;
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/initMessageEvent)
|
||||
*/
|
||||
/** @deprecated */
|
||||
initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: MessagePort[]): void;
|
||||
}
|
||||
|
||||
@@ -4298,7 +4269,9 @@ interface OffscreenCanvas extends EventTarget {
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/height)
|
||||
*/
|
||||
height: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/contextlost_event) */
|
||||
oncontextlost: ((this: OffscreenCanvas, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/contextrestored_event) */
|
||||
oncontextrestored: ((this: OffscreenCanvas, ev: Event) => any) | null;
|
||||
/**
|
||||
* These attributes return the dimensions of the OffscreenCanvas object's bitmap.
|
||||
@@ -4350,8 +4323,6 @@ declare var OffscreenCanvas: {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/OffscreenCanvasRenderingContext2D) */
|
||||
interface OffscreenCanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform {
|
||||
readonly canvas: OffscreenCanvas;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/OffscreenCanvasRenderingContext2D/commit) */
|
||||
commit(): void;
|
||||
}
|
||||
|
||||
declare var OffscreenCanvasRenderingContext2D: {
|
||||
@@ -4941,6 +4912,7 @@ declare var Report: {
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReportBody) */
|
||||
interface ReportBody {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReportBody/toJSON) */
|
||||
toJSON(): any;
|
||||
}
|
||||
|
||||
@@ -5000,11 +4972,7 @@ interface Request extends Body {
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
|
||||
*/
|
||||
readonly integrity: string;
|
||||
/**
|
||||
* Returns a boolean indicating whether or not request can outlive the global in which it was created.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
|
||||
*/
|
||||
/** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
|
||||
readonly keepalive: boolean;
|
||||
/**
|
||||
* Returns request's HTTP method, which is "GET" by default.
|
||||
@@ -5676,9 +5644,11 @@ declare var URL: {
|
||||
prototype: URL;
|
||||
new(url: string | URL, base?: string | URL): URL;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
|
||||
canParse(url: string | URL, base?: string): boolean;
|
||||
canParse(url: string | URL, base?: string | URL): boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */
|
||||
createObjectURL(obj: Blob): string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */
|
||||
parse(url: string | URL, base?: string | URL): URL | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */
|
||||
revokeObjectURL(url: string): void;
|
||||
};
|
||||
@@ -5766,6 +5736,7 @@ interface VideoDecoderEventMap {
|
||||
interface VideoDecoder extends EventTarget {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoDecoder/decodeQueueSize) */
|
||||
readonly decodeQueueSize: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoDecoder/dequeue_event) */
|
||||
ondequeue: ((this: VideoDecoder, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoDecoder/state) */
|
||||
readonly state: CodecState;
|
||||
@@ -5788,6 +5759,7 @@ interface VideoDecoder extends EventTarget {
|
||||
declare var VideoDecoder: {
|
||||
prototype: VideoDecoder;
|
||||
new(init: VideoDecoderInit): VideoDecoder;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoDecoder/isConfigSupported_static) */
|
||||
isConfigSupported(config: VideoDecoderConfig): Promise<VideoDecoderSupport>;
|
||||
};
|
||||
|
||||
@@ -5803,6 +5775,7 @@ interface VideoEncoderEventMap {
|
||||
interface VideoEncoder extends EventTarget {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/encodeQueueSize) */
|
||||
readonly encodeQueueSize: number;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/dequeue_event) */
|
||||
ondequeue: ((this: VideoEncoder, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/state) */
|
||||
readonly state: CodecState;
|
||||
@@ -5812,6 +5785,7 @@ interface VideoEncoder extends EventTarget {
|
||||
configure(config: VideoEncoderConfig): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/encode) */
|
||||
encode(frame: VideoFrame, options?: VideoEncoderEncodeOptions): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/flush) */
|
||||
flush(): Promise<void>;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/reset) */
|
||||
reset(): void;
|
||||
@@ -5824,6 +5798,7 @@ interface VideoEncoder extends EventTarget {
|
||||
declare var VideoEncoder: {
|
||||
prototype: VideoEncoder;
|
||||
new(init: VideoEncoderInit): VideoEncoder;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoEncoder/isConfigSupported_static) */
|
||||
isConfigSupported(config: VideoEncoderConfig): Promise<VideoEncoderSupport>;
|
||||
};
|
||||
|
||||
@@ -5855,6 +5830,7 @@ interface VideoFrame {
|
||||
clone(): VideoFrame;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoFrame/close) */
|
||||
close(): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/VideoFrame/copyTo) */
|
||||
copyTo(destination: AllowSharedBufferSource, options?: VideoFrameCopyToOptions): Promise<PlaneLayout[]>;
|
||||
}
|
||||
|
||||
@@ -6632,7 +6608,7 @@ interface WebGL2RenderingContextBase {
|
||||
clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: number): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clientWaitSync) */
|
||||
clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64): GLenum;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/compressedTexImage3D) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/compressedTexImage2D) */
|
||||
compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr): void;
|
||||
compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: number, srcLengthOverride?: GLuint): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/compressedTexSubImage3D) */
|
||||
@@ -7513,6 +7489,7 @@ declare var WebGLRenderingContext: {
|
||||
};
|
||||
|
||||
interface WebGLRenderingContextBase {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferColorSpace) */
|
||||
drawingBufferColorSpace: PredefinedColorSpace;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferHeight) */
|
||||
readonly drawingBufferHeight: GLsizei;
|
||||
@@ -8222,7 +8199,7 @@ declare var WebGLVertexArrayObject: {
|
||||
new(): WebGLVertexArrayObject;
|
||||
};
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLVertexArrayObjectOES) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLVertexArrayObject) */
|
||||
interface WebGLVertexArrayObjectOES {
|
||||
}
|
||||
|
||||
@@ -8433,24 +8410,24 @@ interface WindowOrWorkerGlobalScope {
|
||||
/**
|
||||
* Available only in secure contexts.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/caches)
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/caches)
|
||||
*/
|
||||
readonly caches: CacheStorage;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/crossOriginIsolated) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/crossOriginIsolated) */
|
||||
readonly crossOriginIsolated: boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/crypto_property) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/crypto) */
|
||||
readonly crypto: Crypto;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/indexedDB) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/indexedDB) */
|
||||
readonly indexedDB: IDBFactory;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/isSecureContext) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/isSecureContext) */
|
||||
readonly isSecureContext: boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/origin) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/origin) */
|
||||
readonly origin: string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/performance_property) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/performance) */
|
||||
readonly performance: Performance;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/atob) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
|
||||
atob(data: string): string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/btoa) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
|
||||
btoa(data: string): string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/clearInterval) */
|
||||
clearInterval(id: number | undefined): void;
|
||||
@@ -8547,7 +8524,9 @@ interface WorkerGlobalScope extends EventTarget, FontFaceSource, WindowOrWorkerG
|
||||
onoffline: ((this: WorkerGlobalScope, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/online_event) */
|
||||
ononline: ((this: WorkerGlobalScope, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/rejectionhandled_event) */
|
||||
onrejectionhandled: ((this: WorkerGlobalScope, ev: PromiseRejectionEvent) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/unhandledrejection_event) */
|
||||
onunhandledrejection: ((this: WorkerGlobalScope, ev: PromiseRejectionEvent) => any) | null;
|
||||
/**
|
||||
* Returns workerGlobal.
|
||||
@@ -8881,7 +8860,7 @@ interface Console {
|
||||
clear(): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */
|
||||
count(label?: string): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countreset_static) */
|
||||
countReset(label?: string): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */
|
||||
debug(...data: any[]): void;
|
||||
@@ -8893,9 +8872,9 @@ interface Console {
|
||||
error(...data: any[]): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */
|
||||
group(...data: any[]): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupcollapsed_static) */
|
||||
groupCollapsed(...data: any[]): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupend_static) */
|
||||
groupEnd(): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */
|
||||
info(...data: any[]): void;
|
||||
@@ -8905,9 +8884,9 @@ interface Console {
|
||||
table(tabularData?: any, properties?: string[]): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */
|
||||
time(label?: string): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeend_static) */
|
||||
timeEnd(label?: string): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timelog_static) */
|
||||
timeLog(label?: string, ...data: any[]): void;
|
||||
timeStamp(label?: string): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
|
||||
@@ -8930,9 +8909,7 @@ declare namespace WebAssembly {
|
||||
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/JavaScript_interface/Global) */
|
||||
interface Global<T extends ValueType = ValueType> {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/JavaScript_interface/Global/value) */
|
||||
value: ValueTypeMap[T];
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/JavaScript_interface/Global/valueOf) */
|
||||
valueOf(): ValueTypeMap[T];
|
||||
}
|
||||
|
||||
@@ -9210,7 +9187,9 @@ declare var onlanguagechange: ((this: DedicatedWorkerGlobalScope, ev: Event) =>
|
||||
declare var onoffline: ((this: DedicatedWorkerGlobalScope, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/online_event) */
|
||||
declare var ononline: ((this: DedicatedWorkerGlobalScope, ev: Event) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/rejectionhandled_event) */
|
||||
declare var onrejectionhandled: ((this: DedicatedWorkerGlobalScope, ev: PromiseRejectionEvent) => any) | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/unhandledrejection_event) */
|
||||
declare var onunhandledrejection: ((this: DedicatedWorkerGlobalScope, ev: PromiseRejectionEvent) => any) | null;
|
||||
/**
|
||||
* Returns workerGlobal.
|
||||
@@ -9235,24 +9214,24 @@ declare var fonts: FontFaceSet;
|
||||
/**
|
||||
* Available only in secure contexts.
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/caches)
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/caches)
|
||||
*/
|
||||
declare var caches: CacheStorage;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/crossOriginIsolated) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/crossOriginIsolated) */
|
||||
declare var crossOriginIsolated: boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/crypto_property) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/crypto) */
|
||||
declare var crypto: Crypto;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/indexedDB) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/indexedDB) */
|
||||
declare var indexedDB: IDBFactory;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/isSecureContext) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/isSecureContext) */
|
||||
declare var isSecureContext: boolean;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/origin) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/origin) */
|
||||
declare var origin: string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/performance_property) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/performance) */
|
||||
declare var performance: Performance;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/atob) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
|
||||
declare function atob(data: string): string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/btoa) */
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
|
||||
declare function btoa(data: string): string;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/clearInterval) */
|
||||
declare function clearInterval(id: number | undefined): void;
|
||||
@@ -9329,7 +9308,7 @@ type ReportList = Report[];
|
||||
type RequestInfo = Request | string;
|
||||
type TexImageSource = ImageBitmap | ImageData | OffscreenCanvas | VideoFrame;
|
||||
type TimerHandler = string | Function;
|
||||
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | ReadableStream | WritableStream | TransformStream | VideoFrame | ArrayBuffer;
|
||||
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | VideoFrame | ArrayBuffer;
|
||||
type Uint32List = Uint32Array | GLuint[];
|
||||
type XMLHttpRequestBodyInit = Blob | BufferSource | FormData | URLSearchParams | string;
|
||||
type AlphaOption = "discard" | "keep";
|
||||
|
||||
+47
-35
@@ -8,24 +8,24 @@ interface AbortSignal {
|
||||
}
|
||||
|
||||
interface CSSNumericArray {
|
||||
[Symbol.iterator](): IterableIterator<CSSNumericValue>;
|
||||
entries(): IterableIterator<[number, CSSNumericValue]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<CSSNumericValue>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSNumericValue>;
|
||||
entries(): ArrayIterator<[number, CSSNumericValue]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSNumericValue>;
|
||||
}
|
||||
|
||||
interface CSSTransformValue {
|
||||
[Symbol.iterator](): IterableIterator<CSSTransformComponent>;
|
||||
entries(): IterableIterator<[number, CSSTransformComponent]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<CSSTransformComponent>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSTransformComponent>;
|
||||
entries(): ArrayIterator<[number, CSSTransformComponent]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSTransformComponent>;
|
||||
}
|
||||
|
||||
interface CSSUnparsedValue {
|
||||
[Symbol.iterator](): IterableIterator<CSSUnparsedSegment>;
|
||||
entries(): IterableIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<CSSUnparsedSegment>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSUnparsedSegment>;
|
||||
entries(): ArrayIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSUnparsedSegment>;
|
||||
}
|
||||
|
||||
interface Cache {
|
||||
@@ -44,34 +44,42 @@ interface CanvasPathDrawingStyles {
|
||||
}
|
||||
|
||||
interface DOMStringList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface FileList {
|
||||
[Symbol.iterator](): IterableIterator<File>;
|
||||
[Symbol.iterator](): ArrayIterator<File>;
|
||||
}
|
||||
|
||||
interface FontFaceSet extends Set<FontFace> {
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
|
||||
[Symbol.iterator](): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
||||
entries(): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns a list of keys in the list. */
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): FormDataIterator<string>;
|
||||
/** Returns a list of values in the list. */
|
||||
values(): IterableIterator<FormDataEntryValue>;
|
||||
values(): FormDataIterator<FormDataEntryValue>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): HeadersIterator<string>;
|
||||
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
|
||||
values(): IterableIterator<string>;
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface IDBDatabase {
|
||||
@@ -95,19 +103,19 @@ interface IDBObjectStore {
|
||||
}
|
||||
|
||||
interface MessageEvent<T = any> {
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/initMessageEvent)
|
||||
*/
|
||||
/** @deprecated */
|
||||
initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: Iterable<MessagePort>): void;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnlyIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<T>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnly {
|
||||
[Symbol.iterator](): IterableIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): IterableIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): IterableIterator<string>;
|
||||
values(): IterableIterator<Iterable<CSSStyleValue>>;
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): StylePropertyMapReadOnlyIterator<string>;
|
||||
values(): StylePropertyMapReadOnlyIterator<Iterable<CSSStyleValue>>;
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
@@ -125,14 +133,18 @@ interface SubtleCrypto {
|
||||
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns an array of key, value pairs for every entry in the search params. */
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns a list of keys in the search params. */
|
||||
keys(): IterableIterator<string>;
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/** Returns a list of values in the search params. */
|
||||
values(): IterableIterator<string>;
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
}
|
||||
|
||||
interface WEBGL_draw_buffers {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+142
-73
@@ -33,6 +33,8 @@ import {
|
||||
emptyOptions,
|
||||
endsWith,
|
||||
ensureTrailingDirectorySeparator,
|
||||
equateStringsCaseInsensitive,
|
||||
equateStringsCaseSensitive,
|
||||
ExtendedConfigCacheEntry,
|
||||
FileExtensionInfo,
|
||||
fileExtensionIs,
|
||||
@@ -1060,7 +1062,7 @@ export interface ParsedConfig {
|
||||
*/
|
||||
projects: Map<NormalizedPath, boolean>;
|
||||
parsedCommandLine?: ParsedCommandLine;
|
||||
watchedDirectories?: Map<string, WildcardDirectoryWatcher>;
|
||||
watchedDirectories?: Map<string, WildcardDirectoryWatcher<WildcardWatcher>>;
|
||||
/**
|
||||
* true if watchedDirectories need to be updated as per parsedCommandLine's updated watched directories
|
||||
*/
|
||||
@@ -1852,80 +1854,22 @@ export class ProjectService {
|
||||
/**
|
||||
* This is to watch whenever files are added or removed to the wildcard directories
|
||||
*/
|
||||
private watchWildcardDirectory(directory: string, flags: WatchDirectoryFlags, configFileName: NormalizedPath, config: ParsedConfig) {
|
||||
private watchWildcardDirectory(
|
||||
directory: string,
|
||||
flags: WatchDirectoryFlags,
|
||||
configFileName: NormalizedPath,
|
||||
config: ParsedConfig,
|
||||
) {
|
||||
let watcher: FileWatcher | undefined = this.watchFactory.watchDirectory(
|
||||
directory,
|
||||
fileOrDirectory => {
|
||||
const fileOrDirectoryPath = this.toPath(fileOrDirectory);
|
||||
const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
||||
if (
|
||||
getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) &&
|
||||
(fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))
|
||||
) {
|
||||
const file = this.getNormalizedAbsolutePath(fileOrDirectory);
|
||||
this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
|
||||
this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
|
||||
this.watchPackageJsonFile(file, fileOrDirectoryPath, result);
|
||||
}
|
||||
|
||||
const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
|
||||
if (
|
||||
isIgnoredFileFromWildCardWatching({
|
||||
watchedDirPath: this.toPath(directory),
|
||||
fileOrDirectory,
|
||||
fileOrDirectoryPath,
|
||||
configFileName,
|
||||
extraFileExtensions: this.hostConfiguration.extraFileExtensions,
|
||||
currentDirectory: this.currentDirectory,
|
||||
options: config.parsedCommandLine!.options,
|
||||
program: configuredProjectForConfig?.getCurrentProgram() || config.parsedCommandLine!.fileNames,
|
||||
useCaseSensitiveFileNames: this.host.useCaseSensitiveFileNames,
|
||||
writeLog: s => this.logger.info(s),
|
||||
toPath: s => this.toPath(s),
|
||||
getScriptKind: configuredProjectForConfig ? (fileName => configuredProjectForConfig.getScriptKind(fileName)) : undefined,
|
||||
})
|
||||
) return;
|
||||
|
||||
// Reload is pending, do the reload
|
||||
if (config.updateLevel !== ProgramUpdateLevel.Full) config.updateLevel = ProgramUpdateLevel.RootNamesAndUpdate;
|
||||
config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => {
|
||||
if (!watchWildcardDirectories) return;
|
||||
const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath);
|
||||
if (!project) return;
|
||||
|
||||
if (
|
||||
configuredProjectForConfig !== project &&
|
||||
this.getHostPreferences().includeCompletionsForModuleExports
|
||||
) {
|
||||
const path = this.toPath(configFileName);
|
||||
if (find(project.getCurrentProgram()?.getResolvedProjectReferences(), ref => ref?.sourceFile.path === path)) {
|
||||
project.markAutoImportProviderAsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Load root file names for configured project with the config file name
|
||||
// But only schedule update if project references this config file
|
||||
const updateLevel = configuredProjectForConfig === project ? ProgramUpdateLevel.RootNamesAndUpdate : ProgramUpdateLevel.Update;
|
||||
if (project.pendingUpdateLevel > updateLevel) return;
|
||||
|
||||
// don't trigger callback on open, existing files
|
||||
if (this.openFiles.has(fileOrDirectoryPath)) {
|
||||
const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
|
||||
if (info.isAttached(project)) {
|
||||
const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ProgramUpdateLevel.Update) as ProgramUpdateLevel;
|
||||
project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
});
|
||||
},
|
||||
fileOrDirectory =>
|
||||
this.onWildCardDirectoryWatcherInvoke(
|
||||
directory,
|
||||
configFileName,
|
||||
config,
|
||||
result,
|
||||
fileOrDirectory,
|
||||
),
|
||||
flags,
|
||||
this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine!.watchOptions, getDirectoryPath(configFileName)),
|
||||
WatchType.WildcardDirectory,
|
||||
@@ -1949,6 +1893,84 @@ export class ProjectService {
|
||||
return result;
|
||||
}
|
||||
|
||||
private onWildCardDirectoryWatcherInvoke(
|
||||
directory: string,
|
||||
configFileName: NormalizedPath,
|
||||
config: ParsedConfig,
|
||||
wildCardWatcher: WildcardWatcher,
|
||||
fileOrDirectory: string,
|
||||
) {
|
||||
const fileOrDirectoryPath = this.toPath(fileOrDirectory);
|
||||
const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
||||
if (
|
||||
getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) &&
|
||||
(fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))
|
||||
) {
|
||||
const file = this.getNormalizedAbsolutePath(fileOrDirectory);
|
||||
this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
|
||||
this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
|
||||
this.watchPackageJsonFile(file, fileOrDirectoryPath, wildCardWatcher);
|
||||
}
|
||||
|
||||
const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
|
||||
if (
|
||||
isIgnoredFileFromWildCardWatching({
|
||||
watchedDirPath: this.toPath(directory),
|
||||
fileOrDirectory,
|
||||
fileOrDirectoryPath,
|
||||
configFileName,
|
||||
extraFileExtensions: this.hostConfiguration.extraFileExtensions,
|
||||
currentDirectory: this.currentDirectory,
|
||||
options: config.parsedCommandLine!.options,
|
||||
program: configuredProjectForConfig?.getCurrentProgram() || config.parsedCommandLine!.fileNames,
|
||||
useCaseSensitiveFileNames: this.host.useCaseSensitiveFileNames,
|
||||
writeLog: s => this.logger.info(s),
|
||||
toPath: s => this.toPath(s),
|
||||
getScriptKind: configuredProjectForConfig ? (fileName => configuredProjectForConfig.getScriptKind(fileName)) : undefined,
|
||||
})
|
||||
) return;
|
||||
|
||||
// Reload is pending, do the reload
|
||||
if (config.updateLevel !== ProgramUpdateLevel.Full) config.updateLevel = ProgramUpdateLevel.RootNamesAndUpdate;
|
||||
config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => {
|
||||
if (!watchWildcardDirectories) return;
|
||||
const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath);
|
||||
if (!project) return;
|
||||
|
||||
if (
|
||||
configuredProjectForConfig !== project &&
|
||||
this.getHostPreferences().includeCompletionsForModuleExports
|
||||
) {
|
||||
const path = this.toPath(configFileName);
|
||||
if (find(project.getCurrentProgram()?.getResolvedProjectReferences(), ref => ref?.sourceFile.path === path)) {
|
||||
project.markAutoImportProviderAsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Load root file names for configured project with the config file name
|
||||
// But only schedule update if project references this config file
|
||||
const updateLevel = configuredProjectForConfig === project ? ProgramUpdateLevel.RootNamesAndUpdate : ProgramUpdateLevel.Update;
|
||||
if (project.pendingUpdateLevel > updateLevel) return;
|
||||
|
||||
// don't trigger callback on open, existing files
|
||||
if (this.openFiles.has(fileOrDirectoryPath)) {
|
||||
const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
|
||||
if (info.isAttached(project)) {
|
||||
const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ProgramUpdateLevel.Update) as ProgramUpdateLevel;
|
||||
project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath: NormalizedPath, loadReason: string) {
|
||||
const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
||||
if (!configFileExistenceInfo?.config) return false;
|
||||
@@ -4434,8 +4456,42 @@ export class ProjectService {
|
||||
this.removeOrphanScriptInfos();
|
||||
}
|
||||
|
||||
private tryInvokeWildCardDirectories(info: ScriptInfo) {
|
||||
// This might not have reflected in projects,
|
||||
this.configFileExistenceInfoCache.forEach((configFileExistenceInfo, config) => {
|
||||
if (
|
||||
!configFileExistenceInfo.config?.parsedCommandLine ||
|
||||
contains(
|
||||
configFileExistenceInfo.config.parsedCommandLine.fileNames,
|
||||
info.fileName,
|
||||
!this.host.useCaseSensitiveFileNames ? equateStringsCaseInsensitive : equateStringsCaseSensitive,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
configFileExistenceInfo.config.watchedDirectories?.forEach((watcher, directory) => {
|
||||
if (containsPath(directory, info.fileName, !this.host.useCaseSensitiveFileNames)) {
|
||||
this.logger.info(`Invoking ${config}:: wildcard for open scriptInfo:: ${info.fileName}`);
|
||||
this.onWildCardDirectoryWatcherInvoke(
|
||||
directory,
|
||||
config,
|
||||
configFileExistenceInfo.config!,
|
||||
watcher.watcher,
|
||||
info.fileName,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult {
|
||||
const existing = this.getScriptInfoForPath(normalizedPathToPath(
|
||||
fileName,
|
||||
projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory,
|
||||
this.toCanonicalFileName,
|
||||
));
|
||||
const info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath);
|
||||
if (!existing && info && !info.isDynamic) this.tryInvokeWildCardDirectories(info);
|
||||
const { retainProjects, ...result } = this.assignProjectToOpenedScriptInfo(info);
|
||||
this.cleanupProjectsAndScriptInfos(
|
||||
retainProjects,
|
||||
@@ -4636,10 +4692,16 @@ export class ProjectService {
|
||||
|
||||
/** @internal */
|
||||
applyChangesInOpenFiles(openFiles: Iterable<OpenFileArguments> | undefined, changedFiles?: Iterable<ChangeFileArguments>, closedFiles?: string[]): void {
|
||||
let existingOpenScriptInfos: (ScriptInfo | undefined)[] | undefined;
|
||||
let openScriptInfos: ScriptInfo[] | undefined;
|
||||
let assignOrphanScriptInfosToInferredProject = false;
|
||||
if (openFiles) {
|
||||
for (const file of openFiles) {
|
||||
(existingOpenScriptInfos ??= []).push(this.getScriptInfoForPath(normalizedPathToPath(
|
||||
toNormalizedPath(file.fileName),
|
||||
file.projectRootPath ? this.getNormalizedAbsolutePath(file.projectRootPath) : this.currentDirectory,
|
||||
this.toCanonicalFileName,
|
||||
)));
|
||||
// Create script infos so we have the new content for all the open files before we do any updates to projects
|
||||
const info = this.getOrCreateOpenScriptInfo(
|
||||
toNormalizedPath(file.fileName),
|
||||
@@ -4670,6 +4732,13 @@ export class ProjectService {
|
||||
|
||||
// All the script infos now exist, so ok to go update projects for open files
|
||||
let retainProjects: Set<ConfiguredProject> | undefined;
|
||||
forEach(
|
||||
existingOpenScriptInfos,
|
||||
(existing, index) =>
|
||||
!existing && openScriptInfos![index] && !openScriptInfos![index].isDynamic ?
|
||||
this.tryInvokeWildCardDirectories(openScriptInfos![index]) :
|
||||
undefined,
|
||||
);
|
||||
openScriptInfos?.forEach(info => this.assignProjectToOpenedScriptInfo(info).retainProjects?.forEach(p => (retainProjects ??= new Set()).add(p)));
|
||||
|
||||
// While closing files there could be open files that needed assigning new inferred projects, do it now
|
||||
|
||||
+10
-8
@@ -112,7 +112,6 @@ import {
|
||||
returnTrue,
|
||||
ScriptKind,
|
||||
some,
|
||||
sort,
|
||||
sortAndDeduplicate,
|
||||
SortedReadonlyArray,
|
||||
SourceFile,
|
||||
@@ -125,6 +124,7 @@ import {
|
||||
ThrottledCancellationToken,
|
||||
timestamp,
|
||||
toPath,
|
||||
toSorted,
|
||||
tracing,
|
||||
TypeAcquisition,
|
||||
updateErrorForNoInputFiles,
|
||||
@@ -775,7 +775,8 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
// As an optimization, don't hit the disks for files we already know don't exist
|
||||
// (because we're watching for their creation).
|
||||
const path = this.toPath(file);
|
||||
return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
|
||||
return !!this.projectService.getScriptInfoForPath(path) ||
|
||||
(!this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -1077,7 +1078,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
}
|
||||
|
||||
protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition {
|
||||
if (!newTypeAcquisition || !newTypeAcquisition.include) {
|
||||
if (!newTypeAcquisition.enable || !newTypeAcquisition.include) {
|
||||
// Nothing to filter out, so just return as-is
|
||||
return newTypeAcquisition;
|
||||
}
|
||||
@@ -1085,7 +1086,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
}
|
||||
|
||||
getExternalFiles(updateLevel?: ProgramUpdateLevel): SortedReadonlyArray<string> {
|
||||
return sort(flatMap(this.plugins, plugin => {
|
||||
return toSorted(flatMap(this.plugins, plugin => {
|
||||
if (typeof plugin.module.getExternalFiles !== "function") return;
|
||||
try {
|
||||
return plugin.module.getExternalFiles(this, updateLevel || ProgramUpdateLevel.Update);
|
||||
@@ -1508,7 +1509,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
typeAcquisition,
|
||||
unresolvedImports,
|
||||
};
|
||||
const typingFiles = !typeAcquisition || !typeAcquisition.enable ? emptyArray : sort(newTypings);
|
||||
const typingFiles = !typeAcquisition || !typeAcquisition.enable ? emptyArray : toSorted(newTypings);
|
||||
if (enumerateInsertsAndDeletes<string, string>(typingFiles, this.typingFiles, getStringComparer(!this.useCaseSensitiveFileNames()), /*inserted*/ noop, removed => this.detachScriptInfoFromProject(removed))) {
|
||||
// If typing files changed, then only schedule project update
|
||||
this.typingFiles = typingFiles;
|
||||
@@ -1627,8 +1628,9 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
}
|
||||
|
||||
protected removeExistingTypings(include: string[]): string[] {
|
||||
if (!include.length) return include;
|
||||
const existing = getAutomaticTypeDirectiveNames(this.getCompilerOptions(), this.directoryStructureHost);
|
||||
return include.filter(i => !existing.includes(i));
|
||||
return filter(include, i => !existing.includes(i));
|
||||
}
|
||||
|
||||
private updateGraphWorker() {
|
||||
@@ -2318,7 +2320,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
runWithTemporaryFileUpdate(rootFile: string, updatedText: string, cb: (updatedProgram: Program, originalProgram: Program | undefined, updatedFile: SourceFile) => void) {
|
||||
const originalProgram = this.program;
|
||||
const rootSourceFile = Debug.checkDefined(this.program?.getSourceFile(rootFile), "Expected file to be part of program");
|
||||
const originalText = Debug.checkDefined(rootSourceFile.getText());
|
||||
const originalText = Debug.checkDefined(rootSourceFile.getFullText());
|
||||
|
||||
this.getScriptInfo(rootFile)?.editContent(0, originalText.length, updatedText);
|
||||
this.updateGraph();
|
||||
@@ -2326,7 +2328,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
cb(this.program!, originalProgram, (this.program?.getSourceFile(rootFile))!);
|
||||
}
|
||||
finally {
|
||||
this.getScriptInfo(rootFile)?.editContent(0, this.program!.getSourceFile(rootFile)!.getText().length, originalText);
|
||||
this.getScriptInfo(rootFile)?.editContent(0, updatedText.length, originalText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-36
@@ -486,7 +486,7 @@ type Projects = readonly Project[] | {
|
||||
/**
|
||||
* This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
|
||||
*/
|
||||
function combineProjectOutput<T, U>(
|
||||
function combineProjectOutput<T, U extends {}>(
|
||||
defaultValue: T,
|
||||
getValue: (path: Path) => T,
|
||||
projects: Projects,
|
||||
@@ -1712,7 +1712,7 @@ export class Session<TMessage = string> implements EventSender {
|
||||
const packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
|
||||
const packageJsonCache = project.getModuleResolutionCache()?.getPackageJsonInfoCache();
|
||||
const compilerOptions = project.getCompilationSettings();
|
||||
const packageJson = getPackageScopeForPath(getNormalizedAbsolutePath(packageDirectory + "/package.json", project.getCurrentDirectory()), getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions));
|
||||
const packageJson = getPackageScopeForPath(getNormalizedAbsolutePath(packageDirectory, project.getCurrentDirectory()), getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions));
|
||||
if (!packageJson) return undefined;
|
||||
// Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext -
|
||||
// Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
|
||||
@@ -2452,43 +2452,13 @@ export class Session<TMessage = string> implements EventSender {
|
||||
const prefix = args.prefix || "";
|
||||
const entries = mapDefined<CompletionEntry, protocol.CompletionEntry>(completions.entries, entry => {
|
||||
if (completions.isMemberCompletion || startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) {
|
||||
const {
|
||||
name,
|
||||
kind,
|
||||
kindModifiers,
|
||||
sortText,
|
||||
insertText,
|
||||
filterText,
|
||||
replacementSpan,
|
||||
hasAction,
|
||||
source,
|
||||
sourceDisplay,
|
||||
labelDetails,
|
||||
isSnippet,
|
||||
isRecommended,
|
||||
isPackageJsonImport,
|
||||
isImportStatementCompletion,
|
||||
data,
|
||||
} = entry;
|
||||
const convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
|
||||
const convertedSpan = entry.replacementSpan ? toProtocolTextSpan(entry.replacementSpan, scriptInfo) : undefined;
|
||||
// Use `hasAction || undefined` to avoid serializing `false`.
|
||||
return {
|
||||
name,
|
||||
kind,
|
||||
kindModifiers,
|
||||
sortText,
|
||||
insertText,
|
||||
filterText,
|
||||
...entry,
|
||||
replacementSpan: convertedSpan,
|
||||
isSnippet,
|
||||
hasAction: hasAction || undefined,
|
||||
source,
|
||||
sourceDisplay,
|
||||
labelDetails,
|
||||
isRecommended,
|
||||
isPackageJsonImport,
|
||||
isImportStatementCompletion,
|
||||
data,
|
||||
hasAction: entry.hasAction || undefined,
|
||||
symbol: undefined,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -285,7 +285,7 @@ function isInsideAwaitableBody(node: Node) {
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, errorCode: number, sourceFile: SourceFile, checker: TypeChecker, insertionSite: Expression, fixedDeclarations?: Set<number>) {
|
||||
if (isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
||||
const exprType = checker.getTypeAtLocation(insertionSite);
|
||||
const asyncIter = checker.getAsyncIterableType();
|
||||
const asyncIter = checker.getAnyAsyncIterableType();
|
||||
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
||||
const forOf = insertionSite.parent;
|
||||
changeTracker.replaceNode(sourceFile, forOf, factory.updateForOfStatement(forOf, factory.createToken(SyntaxKind.AwaitKeyword), forOf.initializer, forOf.expression, forOf.statement));
|
||||
|
||||
@@ -369,7 +369,7 @@ function getInfo(sourceFile: SourceFile, tokenPos: number, errorCode: number, ch
|
||||
const moduleDeclaration = find(symbol.declarations, isModuleDeclaration);
|
||||
const moduleDeclarationSourceFile = moduleDeclaration?.getSourceFile();
|
||||
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
||||
return { kind: InfoKind.Function, token, call: parent.parent, sourceFile, modifierFlags: ModifierFlags.Export, parentDeclaration: moduleDeclaration };
|
||||
return { kind: InfoKind.Function, token, call: parent.parent, sourceFile: moduleDeclarationSourceFile, modifierFlags: ModifierFlags.Export, parentDeclaration: moduleDeclaration };
|
||||
}
|
||||
|
||||
const moduleSourceFile = find(symbol.declarations, isSourceFile);
|
||||
|
||||
@@ -91,6 +91,7 @@ import {
|
||||
TypeChecker,
|
||||
TypeFlags,
|
||||
TypeNode,
|
||||
TypePredicate,
|
||||
UnionReduction,
|
||||
VariableDeclaration,
|
||||
VariableStatement,
|
||||
@@ -103,6 +104,7 @@ import {
|
||||
createImportAdder,
|
||||
eachDiagnostic,
|
||||
registerCodeFix,
|
||||
typePredicateToAutoImportableTypeNode,
|
||||
typeToAutoImportableTypeNode,
|
||||
} from "../_namespaces/ts.codefix.js";
|
||||
import { getIdentifierForNode } from "../refactors/helpers.js";
|
||||
@@ -872,9 +874,28 @@ function withContext<T>(
|
||||
return relativeType(node);
|
||||
}
|
||||
|
||||
let type = isValueSignatureDeclaration(node) ?
|
||||
tryGetReturnType(node) :
|
||||
typeChecker.getTypeAtLocation(node);
|
||||
let type: Type | undefined;
|
||||
|
||||
if (isValueSignatureDeclaration(node)) {
|
||||
const signature = typeChecker.getSignatureFromDeclaration(node);
|
||||
if (signature) {
|
||||
const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
|
||||
if (typePredicate) {
|
||||
if (!typePredicate.type) {
|
||||
return emptyInferenceResult;
|
||||
}
|
||||
return {
|
||||
typeNode: typePredicateToTypeNode(typePredicate, findAncestor(node, isDeclaration) ?? sourceFile, getFlags(typePredicate.type)),
|
||||
mutatedTarget: false,
|
||||
};
|
||||
}
|
||||
type = typeChecker.getReturnTypeOfSignature(signature);
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = typeChecker.getTypeAtLocation(node);
|
||||
}
|
||||
|
||||
if (!type) {
|
||||
return emptyInferenceResult;
|
||||
}
|
||||
@@ -895,15 +916,18 @@ function withContext<T>(
|
||||
if (isParameter(node) && typeChecker.requiresAddingImplicitUndefined(node)) {
|
||||
type = typeChecker.getUnionType([typeChecker.getUndefinedType(), type], UnionReduction.None);
|
||||
}
|
||||
const flags = (
|
||||
isVariableDeclaration(node) ||
|
||||
(isPropertyDeclaration(node) && hasSyntacticModifier(node, ModifierFlags.Static | ModifierFlags.Readonly))
|
||||
) && type.flags & TypeFlags.UniqueESSymbol ?
|
||||
NodeBuilderFlags.AllowUniqueESSymbolType : NodeBuilderFlags.None;
|
||||
return {
|
||||
typeNode: typeToTypeNode(type, findAncestor(node, isDeclaration) ?? sourceFile, flags),
|
||||
typeNode: typeToTypeNode(type, findAncestor(node, isDeclaration) ?? sourceFile, getFlags(type)),
|
||||
mutatedTarget: false,
|
||||
};
|
||||
|
||||
function getFlags(type: Type) {
|
||||
return (
|
||||
isVariableDeclaration(node) ||
|
||||
(isPropertyDeclaration(node) && hasSyntacticModifier(node, ModifierFlags.Static | ModifierFlags.Readonly))
|
||||
) && type.flags & TypeFlags.UniqueESSymbol ?
|
||||
NodeBuilderFlags.AllowUniqueESSymbolType : NodeBuilderFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
function createTypeOfFromEntityNameExpression(node: EntityNameExpression) {
|
||||
@@ -1084,11 +1108,18 @@ function withContext<T>(
|
||||
return isTruncated ? factory.createKeywordTypeNode(SyntaxKind.AnyKeyword) : result;
|
||||
}
|
||||
|
||||
function tryGetReturnType(node: SignatureDeclaration): Type | undefined {
|
||||
const signature = typeChecker.getSignatureFromDeclaration(node);
|
||||
if (signature) {
|
||||
return typeChecker.getReturnTypeOfSignature(signature);
|
||||
}
|
||||
function typePredicateToTypeNode(typePredicate: TypePredicate, enclosingDeclaration: Node, flags = NodeBuilderFlags.None): TypeNode | undefined {
|
||||
let isTruncated = false;
|
||||
const result = typePredicateToAutoImportableTypeNode(typeChecker, importAdder, typePredicate, enclosingDeclaration, scriptTarget, declarationEmitNodeBuilderFlags | flags, {
|
||||
moduleResolverHost: program,
|
||||
trackSymbol() {
|
||||
return true;
|
||||
},
|
||||
reportTruncationError() {
|
||||
isTruncated = true;
|
||||
},
|
||||
});
|
||||
return isTruncated ? factory.createKeywordTypeNode(SyntaxKind.AnyKeyword) : result;
|
||||
}
|
||||
|
||||
function addTypeToVariableLike(decl: ParameterDeclaration | VariableDeclaration | PropertyDeclaration): DiagnosticOrDiagnosticAndArguments | undefined {
|
||||
|
||||
@@ -105,6 +105,7 @@ import {
|
||||
TypeFlags,
|
||||
TypeNode,
|
||||
TypeParameterDeclaration,
|
||||
TypePredicate,
|
||||
unescapeLeadingUnderscores,
|
||||
UnionType,
|
||||
UserPreferences,
|
||||
@@ -602,6 +603,20 @@ export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder:
|
||||
return getSynthesizedDeepClone(typeNode);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function typePredicateToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, typePredicate: TypePredicate, contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined {
|
||||
let typePredicateNode = checker.typePredicateToTypePredicateNode(typePredicate, contextNode, flags, tracker);
|
||||
if (typePredicateNode?.type && isImportTypeNode(typePredicateNode.type)) {
|
||||
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typePredicateNode.type, scriptTarget);
|
||||
if (importableReference) {
|
||||
importSymbols(importAdder, importableReference.symbols);
|
||||
typePredicateNode = factory.updateTypePredicateNode(typePredicateNode, typePredicateNode.assertsModifier, typePredicateNode.parameterName, importableReference.typeNode);
|
||||
}
|
||||
}
|
||||
// Ensure nodes are fresh so they can have different positions when going through formatting.
|
||||
return getSynthesizedDeepClone(typePredicateNode);
|
||||
}
|
||||
|
||||
function typeContainsTypeParameter(type: Type) {
|
||||
if (type.isUnionOrIntersection()) {
|
||||
return type.types.some(typeContainsTypeParameter);
|
||||
@@ -899,6 +914,12 @@ export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNo
|
||||
if (isLiteralImportTypeNode(node) && node.qualifier) {
|
||||
// Symbol for the left-most thing after the dot
|
||||
const firstIdentifier = getFirstIdentifier(node.qualifier);
|
||||
if (!firstIdentifier.symbol) {
|
||||
// if symbol is missing then this doesn't come from a synthesized import type node
|
||||
// it has to be an import type node authored by the user and thus it has to be valid
|
||||
// it can't refer to reserved internal symbol names and such
|
||||
return visitEachChild(node, visit, /*context*/ undefined);
|
||||
}
|
||||
const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
|
||||
const qualifier = name !== firstIdentifier.text
|
||||
? replaceFirstIdentifierOfEntityName(node.qualifier, factory.createIdentifier(name))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user