Skip to content

chore: Adding create permission check for the plus button on tabs list#39672

Closed
ankitakinger wants to merge 17 commits intoreleasefrom
chore/add-create-permission-check
Closed

chore: Adding create permission check for the plus button on tabs list#39672
ankitakinger wants to merge 17 commits intoreleasefrom
chore/add-create-permission-check

Conversation

@ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Mar 11, 2025

Description

  • Adding create permission check for the plus button on tabs list to fix a bad UX on EE.
  • Removing an unused classname.
  • Updating filenames.
  • Updating storybook for Entity item.
  • Refactoring focus retention strategy function definition for getEntityParentUrl and updating handleRemoveFocusHistory in focus retention saga

Fixes #39673

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Warning

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13810368612
Commit: 7bc2574
Cypress dashboard.
Tags: @tag.All
Spec:
It seems like no tests ran 😔. We are not able to recognize it, please check workflow here.


Wed, 12 Mar 2025 11:46:01 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • The editor now displays the “Add” tab more consistently—visible by default and hidden only under specific conditions—providing a more predictable file action experience.
    • Navigation focus has been enhanced for smoother transitions and improved context retention between views.
  • Style

    • Refined the presentation of error notifications for push failures, resulting in clearer and more user-friendly alerts.

@ankitakinger ankitakinger requested a review from a team as a code owner March 11, 2025 14:16
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

This pull request refactors the add tab functionality in the EditorTabs component by enhancing its conditional logic with an additional permission check. It updates several import paths to use centralized focus strategy types, removes obsolete re-exports from FocusSetters, and introduces new generator methods to include branch information in URL keys. New files have been added to re-export focus setter functionalities and to define FocusStrategy types, while minor UI adjustments (such as a CSS class removal) and a simplification in the datasource saga have also been implemented.

Changes

Files Change Summary
app/client/src/pages/AppIDE/.../EditorTabs/index.tsx
app/client/src/pages/Editor/.../PushFailedWarning.tsx
Updated UI: Modified the add tab logic in EditorTabs to include a permission check and simplified rendering; removed an unused CSS class in PushFailedWarning.
app/client/src/ce/navigation/FocusElements/AppIDE.ts
app/client/src/sagas/FocusRetentionSaga.ts
app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts
Focus Strategy Updates: Updated import paths to use "ee/navigation/FocusStrategy/types", removed legacy interface declarations, and added new generator methods (e.g., getUrlKey) for URL key construction.
app/client/src/ee/navigation/AppIDEFocusSetters.ts
app/client/src/ce/navigation/FocusStrategy/types.ts
app/client/src/ee/navigation/FocusStrategy/types.ts
New Type & Re-export Files: Introduced new files to define FocusStrategy types and re-export focus setter functionality for improved modularity.
app/client/src/ee/navigation/FocusSetters.ts Removed Export: Deleted the re-export of FocusSetters from the CE module to prevent legacy access to its members.
app/client/src/ce/sagas/DatasourcesSagas.ts Datasource Saga Simplification: Streamlined the assignment of currentUrl in the deleteDatasourceSaga by removing template literal usage.

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Event
    participant FS as Focus Strategy (AppIDEFocusStrategy)
    participant GC as Git Selector
    U->>FS: Invoke getUrlKey(url)
    FS->>GC: Retrieve current branch
    GC-->>FS: Return branch
    FS-->>U: Return url + '#' + branch
Loading

Possibly related PRs

Suggested labels

Bug, Enhancement, Medium

Suggested reviewers

  • hetunandu
  • ayushpahwa

Poem

Code shifts like a gentle breeze,
As permissions and types align with ease.
Tabs reveal and re-exports bloom,
With URL keys that chase away the gloom.
Celebrate this commit with a joyful code tune!
😄🚀


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Mar 11, 2025
@ankitakinger ankitakinger added the ok-to-test Required label for CI label Mar 11, 2025
@ankitakinger ankitakinger removed the request for review from a team March 11, 2025 14:33
@github-actions github-actions bot added IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Mar 11, 2025
@ankitakinger ankitakinger requested a review from hetunandu March 11, 2025 14:33
@ankitakinger ankitakinger requested a review from a team as a code owner March 11, 2025 17:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/Postgres2_Spec.ts (1)

1-731: 🛠️ Refactor suggestion

Replace Sleep and Wait calls with proper Cypress waiting mechanisms.

The test uses numerous instances of agHelper.Sleep() and cy.wait() which violate the coding guidelines and can lead to flaky tests. These fixed time delays should be replaced with Cypress's built-in waiting mechanisms.

Example patterns to use instead:

- agHelper.Sleep(2000);
+ cy.get('.selector').should('be.visible');
- cy.wait('@postExecute');
+ cy.wait('@postExecute').its('response.statusCode').should('eq', 200);
🧹 Nitpick comments (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/datasourcestorages/base/DatasourceStorageServiceCEImpl.java (1)

280-293: Good implementation of metadata setting.

The method correctly retrieves and sets organization and instance IDs in the metadata map.

Consider adding error handling for cases where either Mono might fail, as this could affect the datasource storage flow.

 private Mono<DatasourceStorage> setAdditionalMetadataInDatasourceStorage(DatasourceStorage datasourceStorage) {
     Mono<String> organizationIdMono = organizationService.getCurrentUserOrganizationId();
     Mono<String> instanceIdMono = configService.getInstanceId();
 
     Map<String, Object> metadata = new HashMap<>();
 
-    return organizationIdMono.zipWith(instanceIdMono).map(tuple -> {
+    return organizationIdMono.zipWith(instanceIdMono)
+            .onErrorResume(error -> {
+                log.error("Error retrieving metadata for datasource storage: {}", error.getMessage());
+                return Mono.just(Tuples.of("", ""));
+            })
+            .map(tuple -> {
         // Change this to ORGANIZATION_ID once we have the organizationId field in the datasource storage
         metadata.put(ORGANIZATION_ID, tuple.getT1());
         metadata.put(INSTANCE_ID, tuple.getT2());
         datasourceStorage.setMetadata(metadata);
         return datasourceStorage;
-    });
+    });
 }
app/client/src/ce/navigation/FocusStrategy/types.ts (3)

22-24: Address eslint-disabled type issues now

Consider fixing the any types now rather than postponing. Using more specific types would improve type safety and make future maintenance easier.

-  // TODO: Fix this the next time the file is edited
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  ) => Generator<any, Array<FocusPath>, any>;
+  ) => Generator<unknown, Array<FocusPath>, unknown>;

29-31: Address eslint-disabled type issues now

Same issue here - consider addressing these type issues now rather than later.

-  // TODO: Fix this the next time the file is edited
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  ) => Generator<any, Array<FocusPath>, any>;
+  ) => Generator<unknown, Array<FocusPath>, unknown>;

41-43: Address eslint-disabled type issues now

And here as well - consider addressing these type issues now rather than later.

-  // TODO: Fix this the next time the file is edited
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  ) => Generator<any, void, any>;
+  ) => Generator<unknown, void, unknown>;
🛑 Comments failed to post (1)
app/client/src/ce/sagas/moduleInterfaceSagas.ts (1)

17-21: ⚠️ Potential issue

Generator function isn't using yield

The function is declared as a generator with the function* syntax, but it doesn't contain any yield statements. If this function doesn't need to yield control during execution, consider using a regular function instead.

-export function* handleModuleWidgetCreationSaga(
-  props: HandleModuleWidgetCreationSagaPayload,
-) {
-  return props.widgets;
-}
+export function handleModuleWidgetCreationSaga(
+  props: HandleModuleWidgetCreationSagaPayload,
+) {
+  return props.widgets;
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

export function handleModuleWidgetCreationSaga(
  props: HandleModuleWidgetCreationSagaPayload,
) {
  return props.widgets;
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 17-21: This generator function doesn't contain yield.

(lint/correctness/useYield)

KelvinOm
KelvinOm previously approved these changes Mar 11, 2025
Copy link
Member

@hetunandu hetunandu left a comment

Choose a reason for hiding this comment

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

PR has a lot of miscellaneous changes. Can we separate it out?

);

removeKeys.push(`${parentPath}#${branch}`);
if (focusEntityInfo.params.basePageId) {
Copy link
Member

Choose a reason for hiding this comment

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

This adds a implicit configuration which does something separately for AppIDE vs other IDEs. Since other IDEs could also have git, we should find a better way to identify this.

I this the focusStategy should define this instead of us doing this in this Saga

@ankitakinger ankitakinger requested a review from a team as a code owner March 12, 2025 06:10
@ankitakinger ankitakinger added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 6d8086b and eab2050.

📒 Files selected for processing (8)
  • app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts (3 hunks)
  • app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts (2 hunks)
  • app/client/src/ce/navigation/FocusStrategy/types.ts (1 hunks)
  • app/client/src/ce/sagas/DatasourcesSagas.ts (3 hunks)
  • app/client/src/ce/sagas/JSActionSagas.ts (3 hunks)
  • app/client/src/sagas/ActionSagas.ts (4 hunks)
  • app/client/src/sagas/FocusRetentionSaga.ts (2 hunks)
  • app/client/src/sagas/WidgetDeletionSagas.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/client/src/sagas/FocusRetentionSaga.ts
  • app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts
  • app/client/src/ce/navigation/FocusStrategy/types.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts

[error] 11-13: This generator function doesn't contain yield.

(lint/correctness/useYield)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: perform-test / ci-test-result
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
🔇 Additional comments (12)
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts (1)

1-1: Update to import source for FocusStrategy type looks good.

The import statement has been updated to use the centralized type definition from the EE module, which aligns with the architectural changes mentioned in the PR objectives.

app/client/src/ce/sagas/DatasourcesSagas.ts (3)

187-187: Import added for Git branch selection

The import for selectGitApplicationCurrentBranch from selectors/gitModSelectors supports the focus history enhancement.


445-447: Branch selection for focus history tracking

Good addition of branch context for focus history management.


457-460: Enhanced URL with branch information

The URL now includes the branch information as a fragment, improving focus history tracking across branches.

app/client/src/sagas/WidgetDeletionSagas.ts (3)

61-61: Import added for Git branch selection

The import for Git branch selector is consistent with other sagas.


342-349: Branch-aware focus history in widget deletion

Properly integrates branch context into focus history management for widget deletion.


495-503: Branch context added to bulk widget deletion

Correctly handles branch context for focus history in the bulk deletion saga.

app/client/src/ce/sagas/JSActionSagas.ts (2)

80-80: Import added for Git branch selection

The import for Git branch selector maintains consistency with other sagas.


337-349: Branch context added for JS collection deletion

Good integration of branch information in focus history for JS collection deletion.

app/client/src/sagas/ActionSagas.ts (3)

147-147: Import added for Git branch selection

Consistent with other sagas, the selector import enhances focus history functionality.


581-633: Branch context added to action deletion

Proper integration of branch information in focus history for action deletion.


1269-1276: Branch context added to action tab closure

The implementation correctly includes branch information for focus history tracking.

@KelvinOm KelvinOm requested review from KelvinOm and removed request for a team and KelvinOm March 12, 2025 08:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between f26de0a and 7bc2574.

📒 Files selected for processing (5)
  • app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts (2 hunks)
  • app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts (2 hunks)
  • app/client/src/ce/navigation/FocusStrategy/types.ts (1 hunks)
  • app/client/src/ce/sagas/DatasourcesSagas.ts (1 hunks)
  • app/client/src/sagas/FocusRetentionSaga.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/ce/sagas/DatasourcesSagas.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/sagas/FocusRetentionSaga.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts

[error] 14-16: This generator function doesn't contain yield.

(lint/correctness/useYield)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (8)
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts (2)

1-1: Import path update looks good.

The import is now referencing the new centralized types file, which improves code organization.


11-13: Method signature update is appropriate.

The getEntityParentUrl method has been converted to an arrow function, which is consistent with the method implementation pattern.

app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts (2)

2-5: Import path update looks good.

The import is now referencing the new centralized types file, which improves code organization.


294-300: Implementation of getUrlKey looks correct.

The generator function properly yields to select the Git branch from Redux state and returns a URL with the branch information appended. This implementation will help maintain focused state across different branches.

app/client/src/ce/navigation/FocusStrategy/types.ts (4)

1-9: New type definitions look good.

The imports and FocusPath interface are well-defined and provide good type safety.


11-13: FocusElementsConfigList type is well-structured.

Good use of mapped type to create a mapping from FocusEntity to arrays of FocusElementConfig.


33-43: New getUrlKey method is appropriate.

The addition of the getUrlKey method to the interface matches the implementations we've seen in the other files. The documentation comment is helpful.


44-50: waitForPathLoad method signature looks correct.

The method signature for the generator function is properly defined, although it has the same TODO item about fixing the ESLint disable in the future.

Comment on lines +14 to +16
getUrlKey: function* (url: string) {
return url;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Generator function should use yield statements.

This generator function doesn't contain any yield statements, which negates the purpose of using a generator. This should be either:

  • Modified to use yield (if asynchronous behavior is needed), similar to how it's implemented in AppIDEFocusStrategy
  • Changed to a regular function or arrow function if no generator behavior is needed
-  getUrlKey: function* (url: string) {
-    return url;
-  },
+  getUrlKey: (url: string): string => {
+    return url;
+  },

Or if you need to match the interface but don't need yield functionality in this specific implementation:

-  getUrlKey: function* (url: string) {
-    return url;
-  },
+  getUrlKey: function* (url: string) {
+    // For NoIDE implementation, we don't need branch information
+    const result = url;
+    yield;
+    return result;
+  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
getUrlKey: function* (url: string) {
return url;
},
// Option 1: If generator behavior is not needed, convert to a regular arrow function.
getUrlKey: (url: string): string => {
return url;
},
// Option 2: If you need to maintain the generator interface, add a yield.
/*
getUrlKey: function* (url: string) {
// For NoIDE implementation, we don't need branch information
const result = url;
yield;
return result;
},
*/
🧰 Tools
🪛 Biome (1.9.4)

[error] 14-16: This generator function doesn't contain yield.

(lint/correctness/useYield)

Comment on lines +15 to +32
export interface FocusStrategy {
focusElements: FocusElementsConfigList;
/** based on the route change, what states need to be set in the upcoming route **/
getEntitiesForSet: (
previousPath: string,
currentPath: string,
state: AppsmithLocationState,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) => Generator<any, Array<FocusPath>, any>;
/** based on the route change, what states need to be stored for the previous route **/
getEntitiesForStore: (
path: string,
currentPath: string,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) => Generator<any, Array<FocusPath>, any>;
/** For entities with hierarchy, return the parent entity path for storing its state **/
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Interface methods are well-documented.

The FocusStrategy interface methods are clearly documented with comments explaining their purpose. The TODO comments for fixing ESLint disables should be addressed in a future update.

Keep track of these TODOs for future updates:


🌐 Web query:

What are best practices for avoiding @typescript-eslint/no-explicit-any in generator function signatures?

💡 Result:

To avoid @typescript-eslint/no-explicit-any in generator function signatures while maintaining type safety, consider these best practices:

Use Precise Type Annotations

Replace any with specific types in generator parameters and yield expressions:

function* safeGenerator(): Generator<number, void, string> {
  const input: string = yield 42; // Yield number, accept string via next()
  console.log(input.toUpperCase());
}

This specifies:

  • Yield type: number
  • Return type: void
  • Input type for next(): string

Leverage unknown for Unknown Types

When types aren't immediately known:

function* typeSafeGenerator(): Generator<unknown, void, unknown> {
  const data = yield; // data is unknown
  if (typeof data === 'string') {
    // Type-checked usage
  }
}

Use Interface Contracts

Define explicit interfaces for complex parameters:

interface GeneratorConfig<T> {
  initialValue: T;
  transform: (value: T) => T;
}

function* configuredGenerator<T>({
  initialValue,
  transform
}: GeneratorConfig<T>): Generator<T> {
  let current = initialValue;
  while (true) {
    current = transform(current);
    yield current;
  }
}

Enable Complementary ESLint Rules

Strengthen type safety with these related rules:

Rule Purpose Example Fix
no-unsafe-argument Prevents passing any to functions Type callback parameters
no-unsafe-return Blocks returning any from generators Specify yield return type
no-unsafe-assignment Catches implicit any assignments Add type annotations

Generator-Specific Patterns

  1. Typed Iterators:
function* paginatedResults<T>(urls: string[]): Generator<Promise<T>, void> {
  for (const url of urls) {
    yield fetch(url).then(res => res.json());
  }
}
  1. Type Narrowing:
function* typeCheckedGenerator() {
  const value = yield;
  if (isValidType(value)) {
    // Safely use narrowed type
  }
}
  1. Generic Generators:
function* asyncWrapper<T>(promise: Promise<T>): Generator<Promise<T>, T> {
  return yield promise;
}

Migration Strategy

  1. Enable @typescript-eslint/no-explicit-any with strict mode
  2. Use ESLint's --fix with fixToUnknown: true option[1]
  3. Gradually replace unknown with specific types
  4. Utilize TypeScript's ReturnType and YieldType helpers:
type YieldType<T> = T extends Generator<infer Y> ? Y : never;

By combining these techniques, you maintain generator flexibility while eliminating unsafe any usage. The TypeScript 3.6+ Generator type provides strict type checking for yield/return/next interactions[14], and when combined with proper ESLint configuration, ensures comprehensive type safety across generator lifecycle operations.

Citations:


Action Required: Update Generator Signatures for Strict Typing

The interface is well-documented; however, both generator methods currently use explicit any types (temporarily suppressed by ESLint) that could be improved. In light of best practices, please consider updating the signatures for getEntitiesForSet and getEntitiesForStore as follows:

  • Replace any with precise types:
    Instead of using Generator<any, Array<FocusPath>, any>, annotate the generator with clear types for the yielded value, the return value, and the value accepted by .next(). For example, if the generator yields values of type YieldType, returns an Array<FocusPath>, and accepts inputs of type NextType, use:

    Generator<YieldType, Array<FocusPath>, NextType>
  • Consider using unknown when appropriate:
    If a type isn’t immediately known or can vary, using unknown in place of any can preserve type safety until a more specific type can be determined.

  • Plan for a gradual refactor:
    Address these TODO comments by replacing the ESLint suppressions with proper type annotations based on your generator’s logic. This will improve maintainability and enforce stricter type checking.

Please keep track of these TODOs for a future update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Add permission check for the plus button in tabs list

3 participants