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

Crash in compareSignaturesRelated from @types/jest-in-case #30171

Closed
sandersn opened this issue Mar 1, 2019 · 2 comments
Closed

Crash in compareSignaturesRelated from @types/jest-in-case #30171

sandersn opened this issue Mar 1, 2019 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue High Priority

Comments

@sandersn
Copy link
Member

sandersn commented Mar 1, 2019

From the nightly DT run.

  1. Clone DT, go to types/jest-in-case, run tsc:
✔ jest-in-case  [master|✔]$ tsl
/home/nathansa/ts/built/local/tsc.js:88011
                throw e;
                ^

TypeError: Cannot read property 'length' of undefined
    at Object.unescapeLeadingUnderscores (/home/nathansa/ts/built/local/tsc.js:12932:19)
    at compareSignaturesRelated (/home/nathansa/ts/built/local/tsc.js:41802:103)
    at signatureRelatedTo (/home/nathansa/ts/built/local/tsc.js:43198:24)
    at signaturesRelatedTo (/home/nathansa/ts/built/local/tsc.js:43169:30)
    at structuredTypeRelatedTo (/home/nathansa/ts/built/local/tsc.js:42875:39)
    at recursiveTypeRelatedTo (/home/nathansa/ts/built/local/tsc.js:42624:64)
    at isRelatedTo (/home/nathansa/ts/built/local/tsc.js:42247:38)
    at checkTypeRelatedTo (/home/nathansa/ts/built/local/tsc.js:42029:26)
    at checkTypeRelatedToAndOptionallyElaborate (/home/nathansa/ts/built/local/tsc.js:41354:24)
    at checkApplicableSignature (/home/nathansa/ts/built/local/tsc.js:49718:26)
// @Filename: index.d.ts
declare const global: NodeJS.Global;
interface Config {
    name?: string;
    only?: boolean;
    skip?: boolean;
    [key: string]: any;
}
type Tester<Opts> = (opts: Opts, done: jest.DoneCallback) => any;
type TestCases<Opts> = ReadonlyArray<Opts> | { [name: string]: Opts };
declare function cases<Opts extends Config>(title: string, tester: Tester<Opts>, testCases: TestCases<Opts>): void;
export = cases;
// @Filename: jest-in-case-tests.ts
// (this is only the piece of the tests required to cause the crash)
import cases = require("jest-in-case");
test('array', () => {
    const tester = jest.fn(opts => {
        expect(add(opts.augend, opts.addend)).toBe(opts.total);
    });
    cases(title, tester, testCases);
});
@sandersn sandersn changed the title Cannot read property 'length' of undefined in @types/jest-in-case Crash in compareSignaturesRelated from @types/jest-in-case Mar 1, 2019
@sandersn
Copy link
Member Author

sandersn commented Mar 1, 2019

Here's a small repro:

interface Mock<Y> extends Function {
    (...args: Y): any;
}
type Tester = (opts: any, done: (...args: any[]) => any) => any;
declare function cases(tester: Tester): void;
declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>;
cases(fn(opts => { }));

Looks like it's probably to do with return type inference.

@sandersn sandersn added Bug A bug in TypeScript High Priority labels Mar 1, 2019
@sandersn
Copy link
Member Author

sandersn commented Mar 1, 2019

Probably from #30114? The keywords, at least, match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue High Priority
Projects
None yet
Development

No branches or pull requests

2 participants