Merge pull request #1522 from asger-semmle/ts-stringify-recursive-type-alias

Approved by xiemaisi
This commit is contained in:
semmle-qlci
2019-07-03 08:25:50 +01:00
committed by GitHub
9 changed files with 29 additions and 6 deletions

View File

@@ -244,7 +244,7 @@ function parseSingleFile(filename: string): {ast: ts.SourceFile, code: string} {
function handleOpenProjectCommand(command: OpenProjectCommand) {
let tsConfigFilename = String(command.tsConfig);
let tsConfig = ts.readConfigFile(tsConfigFilename, ts.sys.readFile)
let tsConfig = ts.readConfigFile(tsConfigFilename, ts.sys.readFile);
let basePath = pathlib.dirname(tsConfigFilename);
let parseConfigHost: ts.ParseConfigHost = {

View File

@@ -436,7 +436,10 @@ export class TypeTable {
let toStringValue: string;
// Some types can't be stringified. Just discard the type if we can't stringify it.
try {
toStringValue = this.typeChecker.typeToString(type);
toStringValue = this.typeChecker.typeToString(
type,
undefined,
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
} catch (e) {
console.warn("Recovered from a compiler crash while stringifying a type. Discarding the type.");
console.warn(e.stack);
@@ -454,7 +457,11 @@ export class TypeTable {
// Some types can't be stringified. Just discard the type if we can't stringify it.
try {
toStringValue =
this.typeChecker.signatureToString(signature, signature.declaration, ts.TypeFormatFlags.None, kind);
this.typeChecker.signatureToString(
signature,
signature.declaration,
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,
kind);
} catch (e) {
console.warn("Recovered from a compiler crash while stringifying a signature. Discarding the signature.");
console.warn(e.stack);