Open bene-starzengruber opened 4 years ago
It's a crash, so by definition something has broken in an unexpected way 😢
Some code snippet that would reproduce this crash would be extremely helpful - would you be able to share an example? We might be able to deduce what went wrong from staring at the code, but it takes a lot longer
So we use TS 3.7.2 and are getting this error while using @mangoweb/scripts-base v0.0.12
We hit this error when we try to initialize a class which extends our Component.ts
We are able to overcome this error with following ways:
"strictFunctionTypes": false
in tsconfig.json@RyanCavanaugh I made a minimal test case for our version of Debug Failure Error: https://github.com/enzy/ts-scriptsbase-debug-failure
I have another minimal repo for this, with typescript@3.8.3
and @apache-arrow/ts@0.17.0
src/test.ts
import { Table } from "@apache-arrow/ts";
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "./dist/"
}
}
<snip>\node_modules\.pnpm\registry.npmjs.org\typescript\3.8.3\node_modules\typescript\lib\tsc.js:81040
throw e;
^
Error: Debug Failure. No error for last overload signature
at resolveCall (<snip>\node_modules\.pnpm\registry.npmjs.org\typescript\3.8.3\node_modules\typescript\lib\tsc.js:47385:38)
at resolveCallExpression (<snip>\node_modules\.pnpm\registry.npmjs.org\typescript\3.8.3\node_modules\typescript\lib\tsc.js:47680:20)
I had this with the latest version of TypeScript (currently 4.3.2), but setting the "includes" property in tsconfig.json removed the issue.
I have encountered this issue in TypeScript 4.4.3, I don't know if further examples are wanted but this minimal repro may be useful since it's standalone (no packages); the error seems to occur no matter the tsconfig options, I tested that it still occurs with no tsconfig at all.
interface CollectionDocument<TIdPrefix extends string> {
id: `${TIdPrefix}_${string}`;
}
type CollectionDocumentIdPrefix<TCollectionDocument extends CollectionDocument<string>> =
TCollectionDocument["id"] extends `${infer TIdPrefix}_${string}` ? TIdPrefix : never;
type CollectionSpecs = { [name: string]: CollectionDocument<string>; };
type CollectionSpecNames<TCollectionNames extends string> = TCollectionNames | `History_${TCollectionNames}`;
interface HistoryDocument<TDocument extends CollectionDocument<string>> extends CollectionDocument<`hist_${CollectionDocumentIdPrefix<TDocument>}`> {
document: TDocument | null;
}
type CollectionFromName<
TCollectionSpecs extends CollectionSpecs,
TCollectionName extends CollectionSpecNames<keyof TCollectionSpecs & string>,
> =
TCollectionName extends `History_${infer TOriginalCollectionName}`
? Collection<HistoryDocument<TCollectionSpecs[TOriginalCollectionName]>>
: Collection<TCollectionSpecs[TCollectionName]>;
class Driver<TCollectionSpecs extends CollectionSpecs = CollectionSpecs> {
public getCollection<TCollectionName extends CollectionSpecNames<keyof TCollectionSpecs & string>>(): CollectionFromName<TCollectionSpecs, TCollectionName> {
// This line seems to be the origin of the error, the 'this' argument specifically
return new Collection<CollectionDocument<string>>(this) as any;
}
}
class Collection<TDocument extends CollectionDocument<string>> {
public driver: Driver;
public document: TDocument;
public constructor(driver: Driver) {
this.driver = driver;
}
}
An other example:
versions: typescript: 4.5.5 and 4.7.0-dev.20220218 mongodb: 4.4.0
import { Collection } from 'mongodb';
import type { OptionalUnlessRequiredId } from 'mongodb';
export type MongoDocument<T> = OptionalUnlessRequiredId<Omit<T, 'id'> & { _id: string }>;
export type MongoDocumentWithPartialId<T> = OptionalUnlessRequiredId<Omit<T, 'id'> & { _id?: string }>;
export declare function toProjectedEntity<T extends Entity>(document: MongoDocumentWithPartialId<T>): any;
export class MongoBaseRepository<T extends Entity> {
readonly collection: Collection<any>;
async loadManyProjectedByFilter(): Promise<any> {
const documents = await this.collection.find<MongoDocument<T>>({}).toArray();
return [documents.map(toProjectedEntity)];
}
}
Only happens if Entity
is an non existing type.
The point about this issue should be to emit more detailed feedback whenever it happens, so we can troubleshoot it by ourselves. This other issue has a suggestion about how to do that: https://github.com/microsoft/TypeScript/issues/33133#issuecomment-526277334 It would already be a great improvement, but if it were also possible to retrieve the file/line where the call happened, it would be perfect.
TypeScript Version: 3.7.2
Search Terms: Debug Failure, No error for last overload signature, Typescript 3.7.2, Sonar
Code / Error Code is not available - executing entity is sonar runner
As well formatted image
or as code...
Expected behavior: Should give some additional information what the problem is
Actual behavior: When looking at the error, I have no idea if it's an issue with my application code, with sonar or with typescript itself