Skip to content

Typescript compiler crashes when an interface member property is encountered which is a generic function with a type parameter that extends an unknown type #28728

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

Closed
lorefnon opened this issue Nov 29, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Declaration Emit The issue relates to the emission of d.ts files

Comments

@lorefnon
Copy link

lorefnon commented Nov 29, 2018

TypeScript Version: "3.3.0-dev.20181129"

Search Terms:

  • This is unknown parent for type parameter
  • 163

Code

export interface Foo {
    preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined 
}
// tsconfig.json
{
    "compilerOptions": {
        "moduleResolution": "node",
        "target": "es6",
        "strict": true,
        "sourceMap": true,
        "declaration": true,
        "declarationDir": "lib",
        "outDir": "lib"
    }
}

Expected behavior:

Compiler reports an error about the type T2 not being defined

Actual behavior:

Compiler crashes and does not provide any information on what needs to be done to resolve the issue.

$ tsc
C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:71037
                throw e;
                ^

Error: Debug Failure. This is unknown parent for type parameter: 165
    at getTypeParameterConstraintVisibilityError (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:64630:37)
    at handleSymbolAccessibilityError (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:64756:33)
    at checkEntityNameVisibility (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:65080:13)
    at visitDeclarationSubtree (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:65226:25)
    at visitNode (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:53392:23)
    at Object.visitEachChild (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:53502:112)
    at visitDeclarationSubtree (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:65278:43)
    at Object.visitNodes (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:53429:48)
    at visitDeclarationSubtree (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:65291:76)
    at Object.visitNode (C:\Users\loref\Projects\ts-test\node_modules\typescript\lib\tsc.js:53392:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Playground Link:

Not reproducible

Related Issues:

#25456

@lorefnon
Copy link
Author

A reproducer can be found in this repo: https://github.com/lorefnon/ts-issue-28728

@weswigham weswigham added Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output labels Nov 30, 2018
@weswigham weswigham added this to the TypeScript 3.2.2 milestone Nov 30, 2018
@weswigham weswigham added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Declaration Emit The issue relates to the emission of d.ts files
Projects
None yet
Development

No branches or pull requests

2 participants