Skip to content

assemblyManager.get() return value does not evaluate to correct type #5568

@garrettjstevens

Description

@garrettjstevens

If you take a simple plugin like this:

import Plugin from '@jbrowse/core/Plugin'
import PluginManager from '@jbrowse/core/PluginManager'
import {
  type AbstractSessionModel,
  isAbstractMenuManager,
} from '@jbrowse/core/util'


export default class ApolloIntroPlugin extends Plugin {
  name = 'ApolloIntroPlugin'

  configure(pluginManager: PluginManager) {
    if (isAbstractMenuManager(pluginManager.rootModel)) {
      pluginManager.rootModel.appendToMenu('Add', {
        label: 'Widget',
        onClick: (session: AbstractSessionModel) => {
          const { assemblyManager } = session
          const assembly = assemblyManager.get('assemblyName')
          console.log(assembly)
        },
      })
    }
  }
}

And run a type-aware lint on it, you get output like this:

/path/to/plugin/src/index.ts
  18:17  error  Unsafe assignment of an error typed value  @typescript-eslint/no-unsafe-assignment

✖ 1 problem (1 error, 0 warnings)

And if you hover over assembly in an editor, it shows the type as any.

What's odd is this error does not appear in the current main branch of Apollo, but when I try to reproduce it outside of the Apollo repository, I always get the error, no matter how much I try to match the dependency versions. And when I upgrade @jbrowse/core in the Apollo repository, this same error appears.

Reproducible repo at: https://github.com/garrettjstevens/jbrowse-plugin-5568-repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions