microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.69k stars 12.44k forks source link

Fail with no pointer to problem - impossible to find and fix #17187

Closed oklas closed 7 years ago

oklas commented 7 years ago

TypeScript Version: 2.4.1

Code works fine, as expected:

      if (this._callbacks['ready']) {
        this._callbacks['ready']()
      }

but it error linting by tslint 5.5.0:

ERROR: src/__Connection.ts[74, 29]: object access via string literals is disallowed
ERROR: src/__Connection.ts[217, 27]: object access via string literals is disallowed

Code rewrited as required by tslint:

      if (this._callbacks.ready) {
        this._callbacks.ready()
      }

fail in compiler with stack dump: (impossible to find and fix)

  ? Test suite failed to run

    Debug Failure.

      at typeToString (node_modules/typescript/lib/typescript.js:28777:22)
      at reportNonexistentProperty (node_modules/typescript/lib/typescript.js:40012:157)
      at checkPropertyAccessExpressionOrQualifiedName (node_modules/typescript/lib/typescript.js:39958:21)
      at checkPropertyAccessExpression (node_modules/typescript/lib/typescript.js:39936:20)
      at checkExpressionWorker (node_modules/typescript/lib/typescript.js:42941:28)
      at checkExpression (node_modules/typescript/lib/typescript.js:42898:42)
      at checkIfStatement (node_modules/typescript/lib/typescript.js:44967:13)
      at checkSourceElement (node_modules/typescript/lib/typescript.js:46748:28)

      at Object.forEach (node_modules/typescript/lib/typescript.js:1506:30)
      at checkBlock (node_modules/typescript/lib/typescript.js:44563:16)
RyanCavanaugh commented 7 years ago

@oklas this is going to be a tough bug to track down without a self-contained repro we can run. Can you share more of your code so that we can reproduce the bug locally?

oklas commented 7 years ago

Thanks for quick answer. The repo and line exactly is:

https://github.com/oklas/wrtc-simple-data/blob/08a6d88dd90a646c332159127b5559f8029c67c4/src/Connection.ts#L74

weswigham commented 7 years ago

This should be fixed by #17311.