Skip to content

"Object is of type 'unknown'" when using event handler on non-ts svelte component  #396

Closed
@dominic-simplan

Description

@dominic-simplan

Describe the bug
After upgrading to the latest (101.7.0) VSCode plugin, I get an error when using an event handler on a svelte component, which is written in plain js.

Usage:

import { PlainJsComponent } from "otherLibrary";

<div>
    <PlainJsComponent on:someEvent={onSomeEvent}/>
</div>

Manual typings (which worked previously):
declare module 'otherLibrary';

Error message: Object is of type 'unknown'

If I remove the event handler, no error is display.
Don't know if this is a bug or if I just need to adjust my type definitions. If it is the latter, in which way do I need to adjust the type definitions?

Expected behavior
It should be possible to use a non-ts svelte component from a ts svelte component.

System (please complete the following information):

  • OS: Windows 10
  • IDE: VSCode 1.47.2
  • Plugin/Package: "Svelte for VSCode 101.7.0"
"svelte": "^3.24.0",
"svelte-check": "^0.1.55",
"svelte-loader": "^2.13.6",
"svelte-preprocess": "^4.0.8",
"@tsconfig/svelte": "^1.0.3",
"typescript": "^3.9.7",

tsconfig:

{
    "extends": "@tsconfig/svelte/tsconfig.json",
    "include": [
        "src/**/*",
        "src/node_modules"
    ],
    "exclude": [
        "node_modules/*",
        "dist/*"
    ],
    "compilerOptions": {
        "strict": true,
        "noImplicitAny": true,
        "resolveJsonModule": true,
        "sourceMap": true,
        "importsNotUsedAsValues": "remove"
    }
}

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions