Skip to content
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

🐛 Panic in semantic_model/scope.rs when opening a typescript file #2711

Closed
1 task done
spion opened this issue May 4, 2024 · 1 comment
Closed
1 task done

🐛 Panic in semantic_model/scope.rs when opening a typescript file #2711

spion opened this issue May 4, 2024 · 1 comment

Comments

@spion
Copy link

spion commented May 4, 2024

Environment information

% dum biome rage
$ biome
$ /home/spion/Projects/ionic-solidjs/node_modules/.bin/biome rage
CLI:
  Version:                      1.7.2
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.6.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

  1. I checked out the pull request here Switch to monorepo, separate into multiple packages, Ionic routing, camelCased properties, fixes and enhancements ionic-solidjs/ionic-solidjs#2 and installed dependencies which includes biome. I installed the vscode biome LSP extension
  2. After opening a specific file, biome shuts down

I got the following .vscode setting to ensure the same version is being used in that workspace

{
  "biome.lspBin": "./node_modules/.bin/biome"
}

And the output of the logs:

├─┘
├─┐biome_lsp::handlers::text_document::did_open{params=DidOpenTextDocumentParams { text_document: TextDocumentItem { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/spion/Projects/ionic-solidjs/packages/ionicons/src/index.ts", query: None, fragment: None }, language_id: "typescript", version: 1, text: "import type { JSX as IonicJSX } from 'ionicons/dist/types/components';\nimport type { JSX as JSXBase } from 'solid-js';\n\n// `tsup` removes an alias of first JSX import (IonicJSX) and uses only the JSX identifier\n// which makes problem when it's used directly in the 'solid-js' module.\ntype __$IonIconsJSXIntrinsicElements = IonicJSX.IntrinsicElements;\n\ntype WithElements<T> = {\n\t[P in keyof T]?: T[P] &\n\t\t(P extends keyof HTMLElementTagNameMap ? JSXBase.HTMLAttributes<HTMLElementTagNameMap[P]> : {});\n};\n\n// Add the Ionic JSX namespace to the solid-js' JSX namespace\ndeclare module 'solid-js' {\n\texport namespace JSX {\n\t\tinterface IntrinsicElements extends WithElements<__$IonIconsJSXIntrinsicElements> {}\n\t}\n}\n\nexport * from './icons';\n" } }}
│ ├─  0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: TypeScript { definition_file: false }, variant: Standard, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "packages/ionicons/src/index.ts" }
│ ├─  0ms DEBUG biome_service::workspace The file has the following feature sets: 
│ │ {Lint: Supported, OrganizeImports: Supported, Format: Supported, Search: FileNotSupported}
│ ├─  0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: TypeScript { definition_file: false }, variant: Standard, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "packages/ionicons/src/index.ts" }
│ ├─┐biome_js_parser::parse::parse{}
│ ├─┘
│ ├─┐biome_json_parser::parse{}
│ ├─┘
│ ├─  0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: TypeScript { definition_file: false }, variant: Standard, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "packages/ionicons/src/index.ts" }
│ ├─┐biome_service::workspace::server::Pulling diagnostics{categories=RuleCategories(SYNTAX | LINT | ACTION)}
│ │ ├─┐biome_service::file_handlers::javascript::Linting JavaScript file{path=BiomePath { path: "packages/ionicons/src/index.ts" }, language=Js(JsFileSource { language: TypeScript { definition_file: false }, variant: Standard, module_kind: Module, version: ES2022, embedding_kind: None })}
│ │ │ ├─  0ms INFO biome_service::file_handlers::javascript Analyze file packages/ionicons/src/index.ts
│ │ │ ├─  0ms ERROR biome_cli::panic Biome encountered an unexpected error
│ │ │ │ 
│ │ │ │ This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:
│ │ │ │ 
│ │ │ │ Source Location: crates/biome_js_semantic/src/semantic_model/scope.rs:115:33
│ │ │ │ Thread Name: tokio-runtime-worker
│ │ │ │ Message: no entry found for key
│ │ │ │ 
│ │ ├─┘
│ ├─┘
├─┘
┘
INFO biome_cli::commands::daemon Received shutdown signal

The code of the file in question:

import type { JSX as IonicJSX } from 'ionicons/dist/types/components';
import type { JSX as JSXBase } from 'solid-js';

// `tsup` removes an alias of first JSX import (IonicJSX) and uses only the JSX identifier
// which makes problem when it's used directly in the 'solid-js' module.
type __$IonIconsJSXIntrinsicElements = IonicJSX.IntrinsicElements;

type WithElements<T> = {
	[P in keyof T]?: T[P] &
		(P extends keyof HTMLElementTagNameMap ? JSXBase.HTMLAttributes<HTMLElementTagNameMap[P]> : {});
};

// Add the Ionic JSX namespace to the solid-js' JSX namespace
declare module 'solid-js' {
	export namespace JSX {
		interface IntrinsicElements extends WithElements<__$IonIconsJSXIntrinsicElements> {}
	}
}

export * from './icons';

Expected result

Biome LSP works normally.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@spion spion changed the title 🐛 Panic 🐛 Panic in semantic_model/scope.rs when opening a typescript file May 4, 2024
@spion
Copy link
Author

spion commented May 4, 2024

I just tested this with latest main - it looks like the issue may've been fixed. (possibly by the conditional types PR, although the text there indicated that it may not be related as this conditional type doesn't use infer)

@spion spion closed this as completed May 4, 2024
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

No branches or pull requests

1 participant