-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
fix(Cache): typescript Map
generic type fixed
#308
base: master
Are you sure you want to change the base?
Conversation
make `value` and `returns` as generic type
- disable @typescript-eslint/no-explicit-any to be able treat `value` as any - fixed failed build caused by `Not all constituents of type 'T | function' are callable`
cache now full support like built-in `Map` forked from: https://stackoverflow.com/a/68805082/6404439
detach `dump` from CacheMapper
chore(deps-dev): add `@types/chai` `@types/mocha` refactor(eslintrc): disable unsupported es-syntax for typescript
feat: import `chai.expect` fixed for objects not being sorted by NodeJS built-in `Map`
should be same `3`
fix: CacheMapper using private name
to generify `Cache` sctructure
hotifx Exported variable <variable name> has or is using private name <private name>
const Cache = require('../dist/cache'); | ||
const cache = new Cache(); | ||
|
||
it('get & set', () => { | ||
cache.set('foo', 123); | ||
cache.get('foo').should.eql(123); | ||
should.equal(cache.get('foo'), 123); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@types/chat
plus import {should} 'chat'; should();
should be enough to correct the type of [any object].prorotype.should
, just like this: https://github.com/SukkaW/rollup-plugin-swc/blob/master/test/index.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@types/chat
plusimport {should} 'chat'; should();
should be enough to correct the type of[any object].prorotype.should
, just like this: https://github.com/SukkaW/rollup-plugin-swc/blob/master/test/index.ts
at my device using prototype.should getting error (throw undefined and make all tests failed), instead giving result test failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont know, why. But using normal chai API can give result failure correctly instead throw all tests runner, that was made me confused, because throw from node_modules
paths instead from the tests files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm, i think this error caused by running on monorepo/workspace project. cuz all dependents grouped at single node_modules
. but, this method easily to sync between packages. maybe, caused by version conflict (auto fixed by yarn), i dont know. Remembering all hexo packages has different dev dependencies versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error says:
cannot read property 'should' of undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sometimes got error like:
cannot read property 'eql' ... so on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so to prevent useless error, prefer using original chai expect, should
API for safety :)
from package `hexo-util`
refactor: split cache typescript test
chore(CacheMapper): drop `size` manipulator chore(Cache): get `CacheMapper` size by keys count
prevent exposed to index exports (VSCode, Intellij IDEA)
create new variable `newValue` to manipulate value parameter
fixed by count the `Map.keys` length
feat: add overload `get` method
feat: add CacheMapper
implement built-in javascript
Map
with full function usages.CacheMapper
implementingMap<KEY, VALUE>
which is genericableMap<string, V>
to prevent variable class imported usingprivate
name, whichV
is Generic typeCache<V>
implementingCacheMapper<string, V>
fix: generic type
Cache
classExported variable 'cache' has or is using private name 'cache'
because type
any
is not allowed by ESLint so I created a mapper class with full typeStrong which can be generalizedfixed generic type screenshot
chore(deps-dev): add
@types/chai
and@types/mocha
to support mocha, chai for used in typescript, we need
@types/chai
and@types/mocha
feat: add strict type test for
Cache
define cache class with various type (still on-going creating an tests)