Skip to content

fix(eslint-plugin): ensure consistent TSMappedType AST shape #11086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dbarabashh
Copy link
Contributor

PR Checklist

Overview

var a: { [k in any]: any }              // No modifiers
var b: { [k in any]?: any }             // Optional modifier
var c: { readonly [k in any]: any }     // Readonly modifier
var d: { +readonly [k in any]?: any }   // +readonly and optional modifier
var e: { -readonly [k in any]: any }    // -readonly modifier

Example a: { [k in any]: any }

{
  type: "TSMappedType",
  constraint: {
    type: "TSAnyKeyword"
  },
  key: {
    type: "Identifier",
    name: "k"
  },
  nameType: null,
  optional: false,             // Now has explicit false value
  readonly: undefined,         // Now has explicit undefined value
  typeAnnotation: {
    type: "TSAnyKeyword"
  }
}

Example b: { [k in any]?: any }

{
  type: "TSMappedType",
  constraint: {
    type: "TSAnyKeyword"
  },
  key: {
    type: "Identifier",
    name: "k"
  },
  nameType: null,
  optional: true,              // Has true value because of ? modifier
  readonly: undefined,         // Now has explicit undefined value
  typeAnnotation: {
    type: "TSAnyKeyword"
  }
}

Example c: { readonly [k in any]: any }

{
  type: "TSMappedType",
  constraint: {
    type: "TSAnyKeyword"
  },
  key: {
    type: "Identifier",
    name: "k"
  },
  nameType: null,
  optional: false,             // Now has explicit false value
  readonly: true,              // Has true value because of readonly modifier
  typeAnnotation: {
    type: "TSAnyKeyword"
  }
}

Example d: { +readonly [k in any]?: any }

{
  type: "TSMappedType",
  constraint: {
    type: "TSAnyKeyword"
  },
  key: {
    type: "Identifier",
    name: "k"
  },
  nameType: null,
  optional: true,              // Has true value because of ? modifier
  readonly: "+",               // Has "+" value because of +readonly modifier
  typeAnnotation: {
    type: "TSAnyKeyword"
  }
}

Example e: { -readonly [k in any]: any }

{
  type: "TSMappedType",
  constraint: {
    type: "TSAnyKeyword"
  },
  key: {
    type: "Identifier",
    name: "k"
  },
  nameType: null,
  optional: false,             // Now has explicit false value
  readonly: "-",               // Has "-" value because of -readonly modifier
  typeAnnotation: {
    type: "TSAnyKeyword"
  }
}

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @dbarabashh!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Apr 17, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit b6e71eb
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6801227f0629b900087be6a6
😎 Deploy Preview https://deploy-preview-11086--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (🔴 down 3 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Apr 17, 2025

View your CI Pipeline Execution ↗ for commit b6e71eb.

Command Status Duration Result
nx typecheck ast-spec ✅ Succeeded <1s View ↗
nx run-many --target=build --exclude website --... ✅ Succeeded 3s View ↗
nx run-many --target=clean ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-04-18 12:39:33 UTC

@dbarabashh dbarabashh changed the title fix(typescript-estree): Inconsistent TSMappedType AST shape fix(typescript-estree): ensure consistent TSMappedType AST shape Apr 17, 2025
@dbarabashh dbarabashh changed the title fix(typescript-estree): ensure consistent TSMappedType AST shape fix(eslint-plugin): ensure consistent TSMappedType AST shape Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Inconsistent TSMappedType AST shape
1 participant