Skip to content

VS Code: intersection types, type not assignable #38113

@sKopheK

Description

@sKopheK

Hello, using VS Code to have typed JS (checkJs: true), but it seems to be having troubles with intersection types that work in both TS and JS in TS Playground without any error. Interestingly enough, properties from a second intersected type are correctly detected by VS Code despite the error on assignment of the typed value (see intellisence tooltip on the screenshot in Actual behavior).

TypeScript Version: 3.9.0-dev.20200420

Search Terms:
not assignable, Intersection types

Code

const ExtraProps = {
    one: 1,
    two: 2
}

class Test { }

/** @type {Test & ExtraProps} */
const inst = new Test();
inst.one;    // no complains

Playground Link

Assigning a properly defined type also does not work:

/**
 * @typedef {{[x in "one"|"two"]: number}} ExtraPropsType
 */

/** @type {Test & ExtraPropsType} */
const inst = new Test();

Expected behavior:
image

Actual behavior:
image

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions