Skip to content

Make index signature declarations without a type annotation an implicit any, not a grammar error - #65283

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:index-signature-implicit-any
Nov 3, 2026
Merged

Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:index-signature-implicit-any

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Extracted out of #65063

interface I {
  [key: string];
}

was previously a grammar error; now it's an implicit any.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 16:55
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 3, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review identifies no active issues with the index-signature behavior and AST API changes.

No open issues 🎉

1 file not reviewed
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
What changed in this PR

This PR separates the index-signature behavior change from #65063: omitted value types become implicit any rather than grammar errors, with matching optionality in the TypeScript AST API.

Changes:

  • Replace TS1021 with implicit-any diagnostic TS7062 when noImplicitAny is enabled.
  • Make index-signature types optional in the AST schema and generated factory APIs.
  • Add compiler and API tests, including declaration emit, and update diagnostic baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​indexSignatureMissingType.ts Tests omitted types with both noImplicitAny settings.
tsc/​testdata/​baselines/​reference/​conformance/​parserObjectType6.errors.txt Adds implicit-any diagnostic for an empty signature.
tsc/​testdata/​baselines/​reference/​conformance/​parserIndexSignature8.errors.txt Adds implicit-any diagnostics alongside invalid-key errors.
tsc/​testdata/​baselines/​reference/​conformance/​parserIndexSignature7.errors.txt Replaces the missing-type grammar diagnostic.
tsc/​testdata/​baselines/​reference/​conformance/​parserIndexSignature6.errors.txt Records implicit any alongside the boolean-key error.
tsc/​testdata/​baselines/​reference/​conformance/​parserIndexSignature11.errors.txt Removes the obsolete missing-type error.
tsc/​testdata/​baselines/​reference/​compiler/​indexWithoutParamType.errors.txt Records implicit any for an empty signature.
tsc/​testdata/​baselines/​reference/​compiler/​indexTypeCheck.errors.txt Removes errors for permitted omitted types.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureWithoutTypeAnnotation1.errors.txt Updates the class index-signature diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureTypeCheck2.errors.txt Adds implicit-any diagnostics for malformed signatures.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureTypeCheck.errors.txt Adds implicit-any diagnostics while retaining parameter errors.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMustHaveTypeAnnotation.errors.txt Replaces missing-type grammar errors with TS7062.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=true).types Records inferred any types with checking enabled.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=true).symbols Records symbol bindings with checking enabled.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=true).js Records JavaScript and explicit-any declaration emit.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=true).errors.txt Records implicit-any and existing validation errors.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=false).types Records inferred any types with checking disabled.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=false).symbols Records symbol bindings with checking disabled.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=false).js Records JavaScript and declaration emit with checking disabled.
tsc/​testdata/​baselines/​reference/​compiler/​indexSignatureMissingType(noimplicitany=false).errors.txt Confirms only unrelated validation errors remain.
tsc/​testdata/​baselines/​reference/​compiler/​indexerConstraints2.errors.txt Updates the missing-type diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​giant.errors.txt Removes obsolete missing-type grammar errors.
tsc/​testdata/​baselines/​reference/​compiler/​arraySigChecking.errors.txt Adds implicit any alongside an invalid-key error.
tsc/​internal/​diagnostics/​diagnostics_generated.go Regenerates Go diagnostic definitions.
tsc/​internal/​diagnostics/​diagnosticMessages.json Replaces TS1021 with TS7062.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Updates generated diagnostic messages.
tsc/​internal/​checker/​grammarchecks.go Removes the mandatory value-type grammar check.
tsc/​internal/​checker/​checker.go Reports implicit any for unannotated index signatures.
tools/​scripts/​tsc/​ast.json Marks index-signature types optional in the schema.
packages/​typescript/​test/​sync/​ast.test.ts Tests parsed and factory-created signatures without types.
packages/​typescript/​src/​ast/​factory.generated.ts Allows omitted types in create and update factories.
packages/​typescript/​src/​ast/​ast.generated.ts Removes the required-type override.

Review effort: Balanced

@jakebailey Jake Bailey (jakebailey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but merge conflict

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 3, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Nov 3, 2026
Merged via the queue into microsoft:main with commit e3d3877 Nov 3, 2026
34 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the index-signature-implicit-any branch November 3, 2026 21:13
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants