microsoft / monaco-editor

A browser based code editor

Home Page:https://microsoft.github.io/monaco-editor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] typescript type check

BayMax619 opened this issue · comments

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.47.0#XQAAAALkBAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw7VuRmAlP8UHl2wTDSACH-qdgDy04VOvD7Jmc6fs3N2mfiPPtNst-DOIbdc9WJIeJWkZ_8CKRyWOAPtv8hjI2Q2FNfCzKK6_qZOxN-SICsCgqt89H-1cX5-iQ-rI1OUyebpgJrcyYrLSaQuHGmc2O7p3waofGmpJ2_RqEA05xpQ9qNCFTGnCpb2RZbnIymB9i78qLLlfq3SAM8KuTfthQ5BEQ2gGRBT6kb_wsQAkaAWRWe_2LcbzC4D2kxo5IgQ0p3R_ERItVwZe1afxNhUNwfdJm9-GeX8T6PInV70kUsPIJJtAz9UeNspMaIRZre84RqmaXLa_fBdXnGMVmtihaWn1lFJfESDCQXkXU0wySzW8dFYOwnBwJN1xkBIS65yY6SbG9V5csxIvok2JwFuNDKkb9fBNJlRYt5CQFA7ni5DoqIJcZAlJyPVhXHdYkHg-VwcU5CdAsbIz0EcYBqc7CbPBfxKSJZTPPGVEJAPGTg_uo2rN0X1KFdxUK_-giUwnQsKWs-SYsETbkclSir1oiiAeuCO9SkbIyYt88NnIna47YYs01uSQSNZ9uZ8krC5Vt9fdwoMjcIT3IYk9oRLfj_FNIsatiMux24bZpRRkc322AO_0if3GxgkoE2qsoftcgLsHgzCGpnaJ0W81B82_QKQ00HiJegCUUhz3LBJh_uBcQZTI6lmk8M06gaSXPbvVgfukY4u9zac9fqf0wUyo

Monaco Editor Playground Code

class Test<T> {
}
class Test1 {
}
class Test2 {
}

declare class Global {
    static tryGetBean(bean: string):string;
    static tryGetBean(bean: number):number;
    static tryGetBean(bean: Test<string>):number;
}

Global.tryGetBean('123');
Global.tryGetBean(123);
let test1: Test<string> = new Test<string>();
let test2: Test<number> = new Test<number>();
let test3 = new Test1();
Global.tryGetBean(test1);
// why no errors
Global.tryGetBean(test2);
Global.tryGetBean(test3);

Reproduction Steps

Global.tryGetBean method called without type check.

Actual (Problematic) Behavior

no errors

Expected Behavior

Global.tryGetBean(test2);
Global.tryGetBean(test3);
report should error

Additional Context

noStrictGenericChecks: false,
noImplicitAny: false,

this isnt a monaco issue
TS is structurally typed and only compares properties, but Test has none
e.g. with class Test<T> { value: T; } it would error
see https://www.totaltypescript.com/the-empty-object-type-in-typescript