Definitelytyped: Cannot find name 'Partial'

Created on 28 Jan 2017  路  11Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/4.14.51 package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).

Getting an error with the latest version of lodash. It seems like Partial was recently added to the following file but it isn't defined. Maybe I'm doing something wrong.

Line 245 of the following file

Image: https://cl.ly/0T3w1Q3a1T1a

Most helpful comment

I'm getting the same.

On line 245 we have:

type PartialObject<T> = Partial<T>;

On line 247 a namespace is defined with pretty much everything else defined within it, so I'm expecting the above to be:

type PartialObject<T> = _.Partial<T>;

however, that doesn't work because Partial, defined on line 10634 is not generic.

type PartialObject<T> = _.Partial;

The above gets rid of the red squiggles in vs code but probably doesn't solve the problem. I just don't have enough experience in this area to know whether a type is missing, i.e. Partial, whether my hack would work, or whether something else is needed.

For now, I've fixed my package.json to require version 4.14.50 as the problem appears to be in the .51 file only.

All 11 comments

I'm getting the same.

On line 245 we have:

type PartialObject<T> = Partial<T>;

On line 247 a namespace is defined with pretty much everything else defined within it, so I'm expecting the above to be:

type PartialObject<T> = _.Partial<T>;

however, that doesn't work because Partial, defined on line 10634 is not generic.

type PartialObject<T> = _.Partial;

The above gets rid of the red squiggles in vs code but probably doesn't solve the problem. I just don't have enough experience in this area to know whether a type is missing, i.e. Partial, whether my hack would work, or whether something else is needed.

For now, I've fixed my package.json to require version 4.14.50 as the problem appears to be in the .51 file only.

Ran into this today on our CI server too. It looks like a bug in the definition to me as well. @lukas-zech-software, it looks like you made the change here. Are we missing something, or is this a bug that slipped through?

Here's a link to the pull request. I'm seeing references to typescript v2.1, which I am not running.

Yeah, Partial defined in typescript v2.1 here, and announced here.

Try upgrading typescript to v2.1 and see if the error goes away. Little hamstrung to test myself atm.

The changes introduced in #13994 will only compile with Typescript 2.1 or higher as the Partial keyword was introduced in this version.

The error has nothing to do with _.Partial, the naming is only coincidentally alike with the Partial keyword from Typescript (see here for details)

As @andy-ms pointed out here you can still install the old typings compatible with Typescript 2.0 by using @types/[email protected]

@carusology If your CI relies on the typings I would suggest to always use a fixed version or even a distinct commit for the typings in your package.json as there is currently no way to use SemVer with DefinitelyTyped and every new feature introduced would break your build if you always install the newest typings

Heh, @lukas-zech-software, you don't need to worry about my random build server, I know you didn't do anything wrong. I was just unaware of the new type on v2.1.

Thanks for chiming in so quickly.

Woke up to our team wondering why TypeScript stopped compiling. Is there going to be a fix placed in the typings file to resolve the namespace issue? I understand the problem is a TypeScript 2.1 issue and not Lodash. But an ETA, scope required for a fix, and/or if anyone has next steps would be really nice to know.

@ashblue As already described above in this issue and even more detailed in this PR this is not an error in the typings and therefore won't be fixed at all.

You will need to install the typings with the version fixed to the older version still supporting Typescript 2.0 by either using @types/[email protected] or @types/[email protected] and keep it fixed at this version.

The typings are not backwards compatible and you must install an older version of the typings or upgrade to Typescript 2.1

See also SPFx issue 394. If you are dependent on a third party library that uses a ~ pattern, then you cannot control what version "npm install" chooses.

You can control what npm install does quite exactly by locking down the dependency tree by using npm shrinkwrap which is highly advisable for all projects used in production

Going to close this issue. Thanks for the response guys.

Was this page helpful?
0 / 5 - 0 ratings