-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Lodash All declarations of 'WeakMap' must have identical type parameters. #14324
Comments
Some more info: Targeting Author mention: @bczengel - Thanks! |
I only seem to get this error from {
'target': 'es5',
'module': 'commonjs',
'declaration': false,
'removeComments': true,
'noLib': false,
'lib': [ 'es2016', 'dom' ],
'emitDecoratorMetadata': true,
'experimentalDecorators': true,
'sourceMap': true,
'pretty': true,
'allowUnreachableCode': false,
'allowUnusedLabels': false,
'noImplicitAny': false,
'noImplicitReturns': true,
'noImplicitUseStrict': false,
'noFallthroughCasesInSwitch': true,
'typeRoots': [ '../../node_modules/@types', '../../node_modules' ],
'types': [ 'node', 'jasmine', 'protractor', 'systemjs', 'hammerjs' ] },
'exclude': [ 'desktop', 'nativescript', 'node_modules', 'dist', 'src' ],
'compileOnSave': false
} I don't get the error. |
This problem seems to be arising because of changes in the TypeScript compiler. Using
I was able to compile with:
But I could not compile with
I believe the problem lies with @types/lodash (for its mis-matching |
Do you use yarn? I have run into exactly this error using yarn to install my deps. When using npm, all is fine. EDIT: turns out npm resolved to an older version of typescript than yarn. So my problem is consistent with what @eschwartz reported. |
I also used yarn to install initial dependencies. |
My issue was with the latest version of Typescript, same as @eschwartz. I use npm. |
The definition of interface WeakMap<K, V> { But in the current nightlies it has changed to: interface WeakMap<K extends object, V> { The stub in |
Can we make the fix in I'm just not sure how updates and versioning works with types within DefinitelyTyped. Can someone give me some guidance? |
@bczengel, @chrootsu, or @stepancar -- could you share you thoughts on this issue? |
Is a fix available? Or maybe a temporary workaround ? |
the workaround I'm using is to comment out the weakmap definition: file: // Backward compatibility with --target es5
declare global {
interface Set<T> { }
interface Map<K, V> { }
interface WeakSet<T> { }
//interface WeakMap<K, V> { }
} |
Stay with angular 2.1.4 because of DefinitelyTyped/DefinitelyTyped#14324 DefinitelyTyped/DefinitelyTyped#14324
Thnx @nippur72 |
lodash - change WeakMap declaration - fix DefinitelyTyped#14324
Revert "lodash - change WeakMap declaration - fix DefinitelyTyped#14324"
Thanks, @budiadiono! |
It's generally not a great idea, to modify files in The workaround I found was to use an earlier build of TypeScript. I do not believe this is an issue for any official release of TS (yet). So you shouldn't have any problems if you're using TS v2.1.4. And as I said earlier, I found this bug with TS v2.2.0-dev.20170201, but not with v2.2.0-dev.20161229. |
IMO, the best workaround is to Once fixed you can remove it. |
+1 |
I found this about the |
@eschwartz my fix breaks backward compatibility, since the |
Can't we use version control, to manage backwards-breaking changes? I mean, publish a if it's really going to break with old TS versions, we'd be breaking semver to release as |
You mean v5? Proper versioning of typing is really problematic. We have library version, typescript version, and typing version :) For example i use I can suggest something like in scala: Example: |
what about |
Yea, i like, btw
|
|
** NG Live Development Server is running on http://localhost:4200. **
|
@duard had the same problem. |
I had to upgrade not only Now this works: |
There are still two packages that seem to mention in, including es6-shim, which was the real culprit in my case:
I jury-rigged a fix in node_modules for myself (as right now I'm only doing exploratory work that doesn't matter much), but I don't really fully understand why it was in es6-shim in the first place (actual es6-shim doesn't implement weak maps), so I'm hesitant to make PRs. |
@erikbarke: I have tried the same versions as you have mentioned but no success. Still getting below errors: TS2304 Cannot find name 'object' Below is my package.json:
Can you please help to fix the same issue? |
@dedu2979: try |
I got the same issue, then I installed lodash again, now it works:
->I got : "lodash": "^4.14.1", |
Still it doesn't work :
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents): |
@vietnc 's method worked for me, latest stable tsc with yarn. |
Works for me with @types/lodash: 4.14.63, typescript: 2.2.2 |
not working for me `-- @types/lodash@4.14.64 ../../node_modules/@types/lodash/index.d.ts(12898,29): error TS2304: Cannot find name 'object'. |
If anyone still have that issue. I don't know why but I just did run the command and now is working: I hope that work for u too! bye |
@jvcsizilio what does it do ? |
Installs the latest version of npm. npm@5 just came out a few days ago |
did not work for me :-( |
@phil123456 I think it is for update the npm. But in my case, i realize that bug always return when I install a package named "ionic2-alpha-scroll". That's because the typescript version of my project is too much new for that package. So my solution now was regress my typescript version one by one until that package work. =/ |
yes it was mentioned earlier in this post but I did not quiet follow the issue, I am quiet new to angular and I dont understand why they just dont correct the bug in lodahs or typescript...this issue is mentioned on many other places |
@phil123456 Well... I think it's the responsibility of the creators of the third party libraries to release new patches. Since typescript has evolved. |
It's easy for now, just add in your file tsconfig.json
|
update types/lodash to the last version |
@types/lodash
package and had problems.Definitions by:
inindex.d.ts
) so they can respond.I found this problem compiling a project using Typescript version 2.2.0-dev.20170128 and @types/lodash version 4.14.51. In my case the tsconfig use es6 target. The error message is:
node_modules/@types/lodash/index.d.ts(19421,15): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
If I browse the file to the line indicated in the error message I can see the following comment:
// Backward compatibility with --target es5
Maybe this is the cause of the issue?
Best regards to all
The text was updated successfully, but these errors were encountered: