Skip to content
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

TS error `Type '"constants"' cannot be used to index type 'T' (2536) when consuming .d.ts #853

Closed
peterblazejewicz opened this issue Mar 13, 2020 · 2 comments

Comments

@peterblazejewicz
Copy link

I'm writing 3rd part TypeScript/Definition file that consumes Jimp (this part works marvelously):

import mergeImg from 'merge-img';
import { resolve } from 'path';
import Jimp from 'jimp';

const fixturePath = resolve(__dirname, 'fixtures');

mergeImg(['image-1.png', 'image-2.jpg']).then(img => {
    // Save image as file
    img.write('out.png', () => console.log('done'));
});
export default function mergeImg(
    images: Array<string | ImageDescriptor | Buffer | Jimp>,
    options?: Options,
): Promise<Jimp>;

I cannot see the outcome of the adding TS support as the tsc tooling complains:

Error: Errors in typescript@next for external dependencies:
node_modules/@jimp/core/types/utils.d.ts(16,3): error TS2536: Type '"class"' cannot be used to index type 'T'.
node_modules/@jimp/core/types/utils.d.ts(17,3): error TS2536: Type '"constants"' cannot be used to index type 'T'.

Relevant jimp def type:

export type WellFormedValues<T extends any> = 
  T['class'] &
  T['constants'];

https://www.google.com/search?q=typescript+TS2536&oq=typescript+TS2536&aqs=chrome..69i57.1779j0j1&sourceid=chrome&ie=UTF-8

Shoudl this one be changed by restructuring consuming code? Or there in the upstream source?

Thanks folks!

@crutchcorn
Copy link
Member

Thanks for raising this issue! Sorry for missing it beforehand 😅 This should be fixed in #858

@crutchcorn
Copy link
Member

@hipstersmoothie think we can close this issue out now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants