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

Interface types aren't compatible in 2.3.2 #294

Closed
bytemain opened this issue Nov 11, 2022 · 4 comments · Fixed by #341
Closed

Interface types aren't compatible in 2.3.2 #294

bytemain opened this issue Nov 11, 2022 · 4 comments · Fixed by #341

Comments

@bytemain
Copy link

bytemain commented Nov 11, 2022

I meet a typing issue in 2.3.2:

it worked on 2.3.1.

import classNames from 'classnames';

export interface ValidateType {
  error?: boolean;
}

const result: ValidateType | undefined = {
  error: true
} as ValidateType;

const data = classNames(result);
console.log(`🚀 ~ file: index.ts ~ line 10 ~ data`, data);

CleanShot 2022-11-11 at 19 58 56@2x

[{
	"resource": "/private/tmp/artin-QVhj2J/index.ts",
	"owner": "typescript",
	"code": "2345",
	"severity": 8,
	"message": "Argument of type '[ValidateType]' is not assignable to parameter of type 'ArgumentArray'.\n  Type 'ValidateType' is not assignable to type 'Argument'.\n    Type 'ValidateType' is not assignable to type 'Mapping'.\n      Index signature for type 'string' is missing in type 'ValidateType'.",
	"source": "ts",
	"startLineNumber": 11,
	"startColumn": 25,
	"endLineNumber": 11,
	"endColumn": 31
}]
@bytemain
Copy link
Author

bytemain commented Nov 11, 2022

import classNames from 'classnames';

export interface ValidateType {
  error: boolean;
  [key: string]: any;
}

const result: ValidateType = {
  error: true,
};

const data = classNames(result);
console.log(`🚀 ~ file: index.ts ~ line 10 ~ data`, data);

this one is work.

@dcousens
Copy link
Collaborator

dcousens commented Nov 24, 2022

Issue broken down

type Foo = {
  bar: boolean
}

const foo: Foo = { bar: true }
classNames(foo) // ok
interface Foo { // hmmm
  bar: boolean
}

const foo: Foo = { bar: true }
classNames(foo) // Argument of type '[Foo]' is not assignable to parameter of type 'ArgumentArray'

@dcousens dcousens changed the title [2.3.2] typing issue Interface types aren't compatible in 2.3.2 Nov 24, 2022
@jonkoops jonkoops added bug and removed question labels Dec 14, 2023
@jonkoops
Copy link
Collaborator

@dcousens do we have a solution in the works for this issue? Anything that can be added to the failing test PR to fix this?

@jonkoops
Copy link
Collaborator

So the reason for this regression is that the type for Mapping was changed from Record<string, any> to Record<string, unknown>. We could revert this to the original, which should resolve the issue, it doesn't really affect the type-safety of our code, or of users in any meaningful way anyways

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

Successfully merging a pull request may close this issue.

3 participants