Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript debugger (Watch) incorrectly gives "Uncaught ReferenceError: <class> is not defined" for extern classes in another file #130517

Closed
sean-mcmanus opened this issue Aug 10, 2021 · 1 comment
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *out-of-scope Posted issue is not in scope of VS Code

Comments

@sean-mcmanus
Copy link
Contributor

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.59.0
  • OS Version: Windows.

Steps to Reproduce:

  1. Use test.ts with
import {
    Task, TaskProvider
} from 'vscode';

export class CppBuildTaskProvider2 implements TaskProvider {
    static CppBuildScriptType: string = 'cppbuild';

    public async provideTasks(): Promise<Task[] | undefined> {
        return undefined;
    }

    public resolveTask(_task: Task): Task | undefined {
        return undefined;
    }
}
  1. Debug an existing extension that references the CppBuildTaskProvider2.CppBuildScriptType and add that to the Watch window, e.g.
import { CppBuildTaskProvider2 } from './test';

export function activate(context: vscode.ExtensionContext) {
    let errMsg: string = CppBuildTaskProvider2.CppBuildScriptType;
}

Bug: See the screenshot: The debugger (Watch window) gives Uncaught ReferenceError: CppBuildTaskProvider2 is not defined.

image

Note that the value can be seen via assigning it to a local variable.

@weinand weinand assigned connor4312 and unassigned weinand Aug 10, 2021
@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Aug 10, 2021
@connor4312
Copy link
Member

This is because TypeScript doesn't expose that as a local and instead rewrites the import, for instance if you look at the compiled code:

image

It's a feature request on TS to emit a names mapping for imports microsoft/TypeScript#9627

@connor4312 connor4312 added upstream Issue identified as 'upstream' component related (exists outside of VS Code) *out-of-scope Posted issue is not in scope of VS Code and removed upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

3 participants