Comments (7)
What build issues does it cause? Please provide reproduction, showing expectation and actual behavior.
from node-lru-cache.
We are using "coap": "^1.3.0", and when building it seams to get confused about the namespace and class. It should work just fine but for some reason it takes the namespace instead of the class.
Thay do this in there code https://github.com/coapjs/node-coap/blob/master/lib/server.ts
class CoapLRUCache<K extends {}, V extends {}> extends LRUCache<K, V> {
pruneTimer: NodeJS.Timeout
}
node_modules/coap/dist/lib/server.d.ts:11:10 - error TS2617: 'LRUCache' can only be imported by using 'import LRUCache = require("lru-cache")' or by turning on the 'esModuleInterop' flag and using a default import.
11 import { LRUCache } from 'lru-cache';
from node-lru-cache.
Give me some code and a command to run so that I can see it happening. LRUCache seems to build just fine in every situation I've used it, so there's something particular to either your setup or theirs, but if I can't reproduce it, I cannot help you, sorry.
from node-lru-cache.
I created a smal sample, the first error is easy to get around and thats just to add { } aroung 3 import BufferListStream from 'bl';
But the last one seams to get the compiler to go bananas, npm run start works but npm run build do not. Only thing i can think of is that its to do with the namespace and class name.
https://github.com/JimmyBjorklund/t-coap
from node-lru-cache.
That is not the problem.
node_modules/coap/dist/lib/server.d.ts:11:8 - error TS1259: Module '"/Users/isaacs/dev/isaacs/lru-cache/t-coap/node_modules/@types/lru-cache/index"' can only be default-imported using the 'esModuleInterop' flag
11 import LRUCache from 'lru-cache';
~~~~~~~~
This patch will fix the issue for you:
diff --git a/tsconfig.json b/tsconfig.json
index b1937c9..6229b40 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,6 +1,7 @@
{
"compileOnSave": true,
"compilerOptions": {
+ "esModuleInterop": true,
"allowJs": true,
"baseUrl": ".",
"experimentalDecorators": true,
Or, since really this is an issue with the coap
lib, not your code, you could use this patch to avoid type checking code you don't own:
diff --git a/tsconfig.json b/tsconfig.json
index b1937c9..5dcef04 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,6 +2,7 @@
"compileOnSave": true,
"compilerOptions": {
"allowJs": true,
+ "skipLibCheck": true,
"baseUrl": ".",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Not a problem with lru-cache.
from node-lru-cache.
Also, coap is using lru-cache v6 (current is v10.2.0). If they upgrade to the latest lru-cache, then they can also ditch @types/lru-cache, because the types are included.
I recommend you suggest this to them.
from node-lru-cache.
Thanks.
from node-lru-cache.
Related Issues (20)
- Unexpected token '(' HOT 8
- Private field '#head' must be declared in an enclosing class HOT 2
- `ttl` documentation HOT 5
- Cache size HOT 1
- Not working with IOS14.x.x versions HOT 1
- Is the signal passed to the fetchMethod always triggering the abort event? HOT 1
- Advice on avoiding fetches being aborted due to eviction HOT 3
- Cache in Remix app always empty? HOT 2
- Type error: 'LRUCache' can only be imported by using a default import HOT 6
- Fetch value and ttl simultaneously HOT 1
- ERR_REQUIRE_ESM on AWS Lambda with Node 18.x HOT 5
- fetch: truthy promise resolution typing
- Distinguish ttl removed items from manually deleted items
- `max` option is not strictly followed, throwing `RangeError: Map maximum size exceeded` when adding lots of items HOT 22
- LRUCache seems to incorrectly implement Map<K, V> HOT 1
- Question: I am confused if I need to implement length and dispose manually or will it just work? HOT 3
- ./min exports files are missing since v10.0.2 HOT 2
- Add a getOrSet() convenience method to delegate memoization / lazy initialization to the cache
- LRU Cache is not a constructor issue in Microsoft Office addin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-lru-cache.