Skip to content

[Bug] class private #fields are tokenised as invalid in monaco #3254

Closed

Description

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 Code

monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
	noSemanticValidation: true,
	noSyntaxValidation: false
});

// compiler options
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
	target: monaco.languages.typescript.ScriptTarget.ESNext,
	allowNonTsExtensions: true
});

// extra libraries
var libSource = [
	'declare class Facts {',
	'    /**',
	'     * Returns the next fact',
	'     */',
	'    static next():string',
	'}'
].join('\n');
var libUri = 'ts:filename/facts.d.ts';
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
// When resolving definitions and references, the editor will try to use created models.
// Creating a model for the library allows "peek definition/references" commands to work with the library.
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));

var jsCode = [
	'"use strict";',
	'',
	'class Chuck {',
	'    static #callCount = 1',
	'    greet() {',
	'        Chuck.#callCount++;',
	'        return `${Chuck.#callCount}: ${Facts.next()}`();',
	'    }',
	'}'
].join('\n');

monaco.editor.create(document.getElementById('container'), {
	value: jsCode,
	language: 'javascript'
});

Reproduction Steps

in a javascript code editor, write a class with #private fields & inspect the token

Actual (Problematic) Behavior

private class fields are tokenised as invalid in monaoc
image

In VSCode desktop it is tokenised as part of the variable...
image

Expected Behavior

Private token to be tokenised as part of variable or keywork or other (just not invalid)

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable buggrammarshelp wantedIssues identified as good community contribution opportunitieslanguages-basic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions