Open sylc opened 1 month ago
deno-lint(constructor-super)
class Base { #name: string #index: number constructor(foo: { name: string, index: number }) { this.#name = foo.name this.#index = foo.index } print() { console.log(`${this.#name} - ${this.#index}`) } } class Derived extends Base { constructor(foo: string) constructor(foo: { name: string, index: number } | string) { if (typeof foo === "string") { super({ name: foo, index: 0 }) } else { super(foo) } } } new Derived('hello').print()
No warning. (the ts playground site is happy with it as well)
deno 1.43.1 (release, x86_64-pc-windows-msvc) v8 12.4.254.12 typescript 5.4.3
As i was writing this I found a workaround (apart from disabling the lint)
class Derived extends Base { constructor(foo: string) constructor(foo: { name: string, index: number } | string) { let arg: { name: string, index: number } | string; if (typeof foo === "string") { arg = { name: foo, index: 0 } } else { arg = foo } super(arg) } }
Lint Name
deno-lint(constructor-super)
Code Snippet
Expected Result
No warning. (the ts playground site is happy with it as well)
Actual Result
Additional Info
Version
deno 1.43.1 (release, x86_64-pc-windows-msvc) v8 12.4.254.12 typescript 5.4.3
workaround
As i was writing this I found a workaround (apart from disabling the lint)