Skip to content

Ignored error in class constructor causes method usage errors to be ignored #36268

@katz12

Description

@katz12

TypeScript Version: 3.5.3

Search Terms:
ts-ignore in class constructor
class method no error on parameter usage

Code

class Foo {
  bar: string
  constructor(bar: string) {
    this.bar = bar
  }

  baz(buzz: number) {
    return buzz + 1
  }
}

// @ts-ignore
const instance = new Foo()
instance.baz('buzz')

Expected behavior:
The invocation of instance.baz('buzz') should report that the parameter should be a number instead of a string.

Actual behavior:
There is no error on that line.
If I fix the ts-ignore on the line above, it then reports the error correctly.

Playground Link:
http://www.typescriptlang.org/play/?ts=3.8.0-dev.20200116#code/MYGwhgzhAEBiD29oG8BQ1oCMwCcBc0EALjgJYB2A5utMPOcTgK7BHw4AU2+hJFlAShQ0MRABakIAOm7QAvFlw0AvqhrYAXlyYaNBckwC2mAKY4haDBhwmiTHOSw6N0ANTQAjCtSrUAej9oAAEiCABaUkpydhNUOgYiaApiMHJgE3lochMAdzhEDgFUZKJU9JkwLQByTGcqgSA

Related Issues:
Could not find any through Google or here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Error InstabilityErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepancies

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions