-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
When this package is installed in a fresh vite project, a function that has a type annotation to return an interface (of anything, as long as it is not an empty interface) mysteriously requires that a returned object's should key be of type Assertion if it returns an object literal
This is a problem, even if it is intended behaviour because a larger project that contains a function anywhere (in typescript) generally suffers from this mysterious behaviour.
It was not immediately obvious that this typing behaviour was from this package, however it is clearly the source or is causing it, an issue with this repository.
This bug was initially found by refactoring large sections of typing after installing this library.
This library extends the Object interface to add should: Chai.Assertion, which was very annoying to identify and results in this package being uninstalled (as it was not being used at the time)
Reproduction
Exact file from repo,
git clone https://github.com/ActuallyHappening/messing-about.git
Code (from repo):
interface test {
anything: "here";
asLongAs: "there is at least one property";
inThe: "interface";
}
function func(): test {
return {
should: "what is this `Assertion` type?", // Error here, copy-pasted below
/*
Type 'string' is not assignable to type 'Assertion'.ts(2322)
index.d.ts(1940, 5): The expected type comes from property 'should' which is declared here on type 'test'
*/
};
};System Info
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M2
Memory: 108.75 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
Browsers:
Brave Browser: 104.1.42.97
Chrome: 105.0.5195.125
Safari: 16.0Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.