If you know how to fix the issue, make a pull request instead.
@types/xxxx
package and had problems.Definitions by:
in index.d.ts
) so they can respond.I just did an update of my npm packages and started getting an error in my builds:
ERROR in [at-loader] ./node_modules/@types/lodash/index.d.ts:12651:53
Type 'T' does not satisfy the constraint 'object'.
This initially confused me, as I'm not including lodash in my project. After some digging, it appears that TypeDoc recently updated their type dependencies (https://github.com/TypeStrong/typedoc/pull/689/commits/afd6b606631c096624c3a1bf0c0a91ba1d1c640c#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R36). I would put in an issue there, but this seems more to be an issue specific to the types.
What it's complaining about, specifically seems to be this:
//_.isWeakSet
interface LoDashStatic {
/**
* Checks if value is classified as a WeakSet object.
*
* @param value The value to check.
* @returns Returns true if value is correctly classified, else false.
*/
isWeakSet<T>(value?: any): value is WeakSet<T>;
}
In particular, "isWeakSet
If I alter T to extend object, the error goes away, but wanted to make sure that's the appropriate fix.
What version of typescript are you using? I suspect this is due to a
breaking change in TS 2.7
On Feb 2, 2018 2:04 PM, "Benjamin McGregor" notifications@github.com
wrote:
If you know how to fix the issue, make a pull request instead.
- I tried using the @types/xxxx package and had problems.
- I tried using the latest stable version of tsc.
https://www.npmjs.com/package/typescript
https://www.npmjs.com/package/typescript- I have a question that is inappropriate for StackOverflow
https://stackoverflow.com/. (Please ask any appropriate questions
there).- Mention
https://github.com/blog/821-mention-somebody-they-re-notified the
authors (see Definitions by: in index.d.ts) so they can respond.
- Authors: @bczengel https://github.com/bczengel @chrootsu
https://github.com/chrootsu @stepancar
https://github.com/stepancar @ericanderson
https://github.com/ericanderson @aj-r https://github.com/aj-r
@Ailrun https://github.com/ailrun
I just did an update of my npm packages and started getting an error in my
builds:ERROR in [at-loader] ./node_modules//index.d.ts:12651:53
Type 'T' does not satisfy the constraint 'object'.This initially confused me, as I'm not including lodash in my project.
After some digging, it appears that TypeDoc recently updated their type
dependencies (TypeStrong/typedoc@afd6b60#diff-
b9cfc7f2cdf78a7f4b91a753d10865a2R36
https://github.com/TypeStrong/typedoc/commit/afd6b606631c096624c3a1bf0c0a91ba1d1c640c#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R36).
I would put in an issue there, but this seems more to be an issue specific
to the types.What it's complaining about, specifically seems to be this:
//_.isWeakSet interface LoDashStatic { /** * Checks if value is classified as a WeakSet object. * * @param value The value to check. * @returns Returns true if value is correctly classified, else false. */ isWeakSet<T>(value?: any): value is WeakSet<T>; }
In particular, "isWeakSet(value?: any): value is WeakSet<T>;"
If I alter T to extend object, the error goes away, but wanted to make
sure that's the appropriate fix.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/23375, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGpes7zWmpvZcg82WaIC5E6Rd81hjLTaks5tQ1uggaJpZM4R3oZa
.
[email protected] right now.
Ok. Looks like we need to update our WeakSet and WeakMap interfaces to be
compatible with 2.7. However that will break backwards compatibility with
older versions of typescript.
On Feb 2, 2018 2:43 PM, "Benjamin McGregor" notifications@github.com
wrote:
[email protected] right now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/23375#issuecomment-362686310,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGpesyITc1u44NahxpUvzoew-Hgco-fLks5tQ2VHgaJpZM4R3oZa
.
Ok, yeah, switching back to [email protected] got rid of the error, so that seems to be the issue.
Looks like there are a lot of open lodash issues right now. I'd appreciate if anyone made a PR for this (@bczengel @chrootsu @stepancar @ericanderson @https://github.com/ailrun @https://github.com/e-cloud @thorn0 @jtmthf @Domir). Just comment here if you're working on it so we don't step on each other's feet :)
This is killing me right now - has anyone found a workaround in TypeScript 2.7? I'll see if I can find one.
You could try targeting es5? Ultimately we just need to update lodash's
WeakSet interface to match typescript's (I.e. add "extends object") and
update the function call as the OP mentioned. It's a really easy fix so if
someone submits a PR I'll review it.
On Feb 14, 2018 9:40 PM, "Christian Stewart" notifications@github.com
wrote:
This is killing me right now - has anyone found a workaround in TypeScript
2.7? I'll see if I can find one.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/23375#issuecomment-365810491,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGpes6HFVSSJ-HXCEfL5DAVKP55qiVMmks5tU5k5gaJpZM4R3oZa
.
Nice one, I think targeting es5 with commonjs modules fixes it as a nice short-term workaround.
AJ Richardson writes:
You could try targeting es5? Ultimately we just need to update lodash's
WeakSet interface to match typescript's (I.e. add "extends object") and
update the function call as the OP mentioned. It's a really easy fix so if
someone submits a PR I'll review it.
I have tried this and it seems to work, mostly. Except for one of my projects.
Tsconfig:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"moduleResolution": "node",
"lib": ["es2015", "es2016", "es2017", "dom"],
"strict": true,
"sourceMap": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declarationDir": "dist/types",
"outDir": "dist/es",
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"test",
"dist",
"coverage",
"node_modules",
"prototree"
]
}
Error:
node_modules/@types/lodash/index.d.ts(12651,53): error TS2344: Type 'T' does not satisfy the constraint 'object'.
Targeting es5 doesn't seem to fix the error.
It's probably the lib: es2016 and es2017 that's doing it. You can try
removing the while libs and replacing them with the specific parts of the
libs that you need (e.g. es2016.Promise).
On Feb 14, 2018 11:13 PM, "Christian Stewart" notifications@github.com
wrote:
>
AJ Richardson writes:
You could try targeting es5? Ultimately we just need to update lodash's
WeakSet interface to match typescript's (I.e. add "extends object") and
update the function call as the OP mentioned. It's a really easy fix so
if
someone submits a PR I'll review it.I have tried this and it seems to work, mostly. Except for one of my
projects.Tsconfig:
{ "compilerOptions": { "module": "commonjs", "target": "es5", "moduleResolution": "node", "lib": ["es2015", "es2016", "es2017", "dom"], "strict": true, "sourceMap": true, "declaration": true, "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "declarationDir": "dist/types", "outDir": "dist/es", "typeRoots": [ "node_modules/@types" ] }, "exclude": [ "test", "dist", "coverage", "node_modules", "prototree" ] }
Error:
node_modules/@types/lodash/index.d.ts(12651,53): error TS2344: Type 'T' does not satisfy the constraint 'object'.
Targeting es5 doesn't seem to fix the error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/23375#issuecomment-365820810,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGpes_sHLrApbLkMqvqklIsGMP9rN1Mjks5tU67mgaJpZM4R3oZa
.
Removing es2016
and es2017
doesn't help. Downgrading to ts-2.6
@Ixonal @paralin @thehappycoder what version of @types/lodash
are you using? I can't reproduce this error in the latest version (4.14.103). I checked the types and it looks like this now:
isWeakSet(value?: any): value is WeakSet<object>;
So it looks like someone has fixed this already.
@aj-r 4.14.74, but it's a third party dependency, so I'm not really in control of the versioning.
Ok, so your third party probably needs to update their dependency. You might be able to control the version anyway by running npm install -S @types/lodash@latest
(or similar in yarn). See if that fixes it.
Ok, yeah, looks like that built successfully
@Ixonal want to close this issue if it's working now?
I had this error with @types/lodash
4.14.78 upon upgrading to typescript 2.7.2
found this thread, updated @types/lodash
to 4.14.108, and the error is gone! seems like this should be closed to me
Lodash version: [email protected] and @types/[email protected]
Working fine.
Does this line need to be updated?
Suggestion:
interface WeakSet<T extends object> { }
Currently:
interface WeakSet<T> { }
This issue is blocking update to angular 6. Angular 6 requires typescript version >= 2.7.2 .
Is it possible to update lodash? I see people suggesting a change, could those changes be accepted?
fixed this by installing latest types. "@types/lodash": "^4.14.110",
npm install @types/lodash^4.14.110
@Ixonal can you close this issue if it's working? Unfortunately I don't have the power to close it :(
Sorry, thought y'all had close power :D
This is broken again @4.14.129, but in a new place. I can fix things by changing
isWeakSet<T>(value?: any): value is WeakSet<T>;
to
isWeakSet<T extends object>(value?: any): value is WeakSet<T>;
@agillesp I don't follow - the current definition for that function is:
isWeakSet(value?: any): value is WeakSet<object>;
There is no T
parameter (although maybe there should be).
@aj-r a type parameter should only be used if the function explicitly uses that type. Seeing as
function isWeakSet<T extends object>(value?: any): value is WeakSet<T> {
return value instanceof WeakSet;
}
does not use T
anywhere in its body, nor does it actually determine that value
is a WeakSet<T>
_specifically_, the type parameter is not only unnecessary, but actually harmful since it incorrectly constrains the type of value
more than was actually determined, which could eventually lead to a runtime error due to a wrong assumption about the contained type of the WeakSet
.
Ah, drat, sorry for the noise (and wasting your time). This was bubbling up from a subdir node_modules
which had a much older version installed. All is well now.
Most helpful comment
Ok, so your third party probably needs to update their dependency. You might be able to control the version anyway by running
npm install -S @types/lodash@latest
(or similar in yarn). See if that fixes it.