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

Differences in syntax colorization on file full of errors #241813

Closed
aiday-mar opened this issue Feb 25, 2025 · 2 comments · Fixed by #242085
Closed

Differences in syntax colorization on file full of errors #241813

aiday-mar opened this issue Feb 25, 2025 · 2 comments · Fixed by #242085
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tree-sitter verified Verification succeeded
Milestone

Comments

@aiday-mar
Copy link
Contributor

aiday-mar commented Feb 25, 2025

Testing #241709

  • use the abyss color theme
  • open the following file
file
// 1002
export const issue1002 = 'hi

// 1003
const issue1003 = true && ();

// 1005
interface Foo = { };
const arr = [1, 2 3];
export const foo()) = 3;

// 1009

// 1010 at the bottom

// 1011: An element access expression should take an argument
const data2 = []
const data = data2[];

// ajajaj
// aa

// 1014
// supposed to throw an error?

// 1015
// supposed to throw an error?

// 1016

// 1017: An index signature cannot have a rest parameter.

// 1018: An index signature parameter cannot have an accessibility modifier
interface NumberOrStringDictionary {
    [private index: string]: number | string | boolean;
}

// 1019: An index signature parameter cannot have a question mark
interface NumberOrStringDictionary {
    [index?: string]: number | string | boolean;
}

// 1020: An index signature parameter cannot have an initializer

// 1022: An index signature parameter type must be 'string' or 'number'

// 1028:  Accessibility modifier already seen.
class Hi {
    private public hi: string;
}

// 1029: '{0}' modifier must precede '{1}' modifier.

class Hi {
}

// 1031: '{0}' modifier cannot appear on a class element.

// 1035: Only ambient modules can use quoted names.

module "Module" {
    export class Class {
    }
}



// 1044: 'private' modifier cannot appear on a module or namespace element


private import hi from './hi';

// 1042: '{0}' modifier cannot be used here.

class Hi {
}

// 1047: A rest parameter cannot be optional.

// 1051: A set accessor must have exactly one parameter
class Hi {
    private _hi: string;

    set hi(value: string, value2: string) {
        this._hi = value;
    }
}

// 1053: A 'set' accessor cannot have rest parameter

class Hi {
    private _hi: string;

    set hi(...value: string) {
        this._hi = value;
    }
}

// 1054: A 'get' accessor cannot have parameters.
class Hi {
    private _hi: string;

    get hi() {
        return this._hi;
    }
}

// 1064:
export class LoginService {
    async isLoggedIn(): boolean {
    }
}
async function hi(): boolean {
}

// 1068: Unexpected token. A constructor, method, accessor, or property was expected.
class Test {
}

// 1070:
interface OptionRequirement {
    private someBool: boolean;
    someString: string;
}

// or
interface IFoo {
    abstract foo(): void;
}

// 1071

interface NumberOrStringDictionary {
    private [index: string]: number | string | boolean;
}

// 1095: A 'set' accessor cannot have a return type annotation.
class Hi {
    private _hi: string;

    set hi(value: string): void {
        this._hi = value;
    }
}

// 1098: Type parameter list can not be empty

// 1104: A 'continue' statement can only be used within an enclosing iteration statement
if (true) {
    continue;
}

// 1105: A 'break' statement can only be used within an enclosing iteration or switch statement
if (true) {
    break;
}

// 1107: Jump target cannot cross function boundary
const groups = [[]];
groups.forEach(function (group) {
    // names also an array
    group.forEach(function (name) {
        if (name == 'SAM') {
            break;
        }
    })
})

// 1108: A 'return' statement can only be used within a function body.ts(1108)
if (true) {
    return;
}

// 1109: Expression expected.
export const foo()) = 3;

// 1113: A 'default' clause cannot appear more than once in a 'switch' statement
const hi = true;
switch (hi) {
    case true:
        break;
    default:
        break;
    default:
        break;
}

// 1128: Declaration or statement expected
function myFunction(a: number, b: number) {
}
myFunction(1, 2);)

// 1130 : "'case' or 'default' expected.
const hi = true;
switch (hi) {
    ;
    case true:
        break;
}

// 1155: const' declarations must be initialized

// 1157: 'let' declarations can only be declared inside a block
const text = "Some text";
if (text.length > 0)
    let data = "Some value";

// 1161 : Unterminated regular expression literal
const regex = new RegExp(/\.\/images\/);

// 1163 : A 'yield' expression is only allowed in a generator body
while (true) {
    yield take('FETCH01_REQUEST');
}

// 1172 : 'extends' clause already seen
class IFar {
}

class IBar {
}


// 1173 : 'extends' clause must precede 'implements' clause
class IFar {
}

interface IBar {
}

class Far implements IBar extends IFar {

}

// 1174 : Classes can only extend a single class.ts(1174)

class IFar {
}

class IBar {
}

class Far extends IBar, IFar {
}

// 1175: 'implements' clause already seen
interface IFar {
}

interface IBar {
}

class Far implements IBar implements IFar {

}

// 1176: Interface declaration can not have implements clause
interface IFar {
}

interface IBar implements IFar {
}

// 1188: Only a single variable declaration is allowed in a 'for...of' statement.ts(1188)
const bar = [];
for (of bar) {
}

// 1190: The variable declaration of a 'for...of' statement cannot have an initializer.ts(1190)
const iterable = [10, 20, 30];
for (const value = 50 of iterable) {
    console.log(value);
}

// 1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified.ts(1196)
try {
} catch (err: Error) {
}

// 1200 : Line terminator not permitted before arrow
const data = [];

// 1206: Decorators are not valid here.ts(1206)

// 1238: Unable to resolve signature of class decorator when called as an expression.
// The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.ts(1238)

function xxx(arg: string) {
    function f(target) {
        function ff(msg: string) {
            return new target(arg + ":" + msg)
        }
        return ff
    }
    return f
}

// 1241: Unable to resolve signature of method decorator when called as an expression.
// The runtime will invoke the decorator with 2 arguments, but the decorator expects 3.ts(1241)
function test(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) {
    return descriptor;
}

class Test {
    @test
    hello() {
    }
}

// 1244: Abstract methods can only appear within an abstract class.ts(1244)
class IFoo {
    abstract foo(): void { }
}

// 1245: Method 'foo' cannot have an implementation because it is marked abstract.ts(1245)
class IFoo {
    abstract foo(): void { }
}

// 1270: Decorator function return type '(msg: string) => any' is not assignable to type 'void | typeof A'.ts(1270)
@xxx("xxx")
class A {
}

function xxx(arg: string) {
    function f(target) {
        function ff(msg: string) {
            return new target(arg + ":" + msg)
        }
        return ff
    }
    return f
}

// 1300 : 'with' statements are not allowed in an async function block.ts(1300)


// 1375 : 'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.ts(1375)
const hi = await foo()
function foo() { }

// 1390: 'super' is not allowed as a parameter name.ts(1390)

class Bar {
    hi: string;
}

class Foo extends Bar {
    constructor(super.hi) { }
}

// 1472: 'catch' or 'finally' expected.ts(1472)
try {
}

// 1524: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference
export declare namespace MyNamespace {
    const myFunc = () => 3;
}

// 1320

export class CancelablePromise implements PromiseLike<any> {
    constructor() {
        // Some mumbo jumbo
    }
    public then(resolveFn, rejectFn): CancelablePromise {
        let s = 'hi'
        return new CancelablePromise(s);
    }
}

let p = new Promise(() => { });
let cp = new CancelablePromise(p);
await cp;

// 2300

export class TestJS {
}

export class TestJS {
}

// 2307: Cannot find module './hi' or its corresponding type declarations

// 2310: Type 'Hi' recursively references itself as a base type.ts(2310)

interface Hi extends Hi {
}

// 2322: Type 'Bar' is not assignable to type 'string | number | symbol'.ts(2322)
class Bar { }
const bars = [];
const bar = new Bar();

// 2335: super' can only be referenced in a derived class.ts(2335)
class Foo {
    constructor() {
        super()
    }
}

// 2339: Static members cannot reference class type parameters.
class Hi {
    static foo() {
        this.hi = 'hi';
    }
}

// 2341 : Property 'hi' is private and only accessible within class 'Bar'.ts(2341)
class Bar {
}

class Foo extends Bar {
    constructor() {
        super();
        super.hi();
    }
}

// 2347: Untyped function calls may not accept type arguments.ts(2347)

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from "rxjs/Observable";
import 'rxjs/Rx';
import { ITemp } from "../interfaces/temp";

export interface ITemp {
    id: number,
    name: string,
    age: number
}

@Injectable()
export class HttpService {

    http: any;
    baseUrl: String;

    constructor(http: HttpClient) {
        this.http = http;
        this.baseUrl = 'some_url';
    }

    getHomeDetails(): Observable<ITemp> {
        return this.http.get<ITemp>(this.baseUrl); //problem is here
        //when mouse is pointed on get<ITemp> it shows "Untyped function calls may not accept type arguments"

    }
}

// 2348: Value of type 'typeof Hi' is not callable. Did you mean to include 'new'?ts(2348)
class Hi {

}
const hi = Hi()

// 2349: This expression is not callable.
// Type 'String' has no call signatures.ts(2349)

// 2350: Only a void function can be called with the 'new' keyword.ts(2350)
function foo(): string {
    return 'hi';
}

// 2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.ts(2355)
function foo(): string { }

// 2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.ts(2358)
class Bar { }
const hi: string = 'hi';

// 2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362)
interface Dimensions {
    width: Number,
    height: Number
}

// 2365: Operator '>=' cannot be applied to types 'string' and 'number'
const year = 'hi';
if (year >= 00) {
}

// 2369: A parameter property is only allowed in a constructor implementation
function () {
}

// or

class Hi {
    use(): boolean { return true; }
}

// 2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'
with (obj) { }

// 2415: Class 'Foo' incorrectly extends base class 'Bar'.
// Property 'hi' is private in type 'Bar' but not in type 'Foo'.ts(2415)
class Bar {
}

class Foo extends Bar {
    public hi: string;
}

// 2416: Property 'hi' in type 'Foo' is not assignable to the same property in base type 'Hi'.
// Type 'number' is not assignable to type 'string'.ts(2416)
interface Hi {
    hi: string;
}
class Foo implements Hi {
    hi: number = 2;
}

// 2451: Cannot redeclare block-scoped variable 'hi'.ts(2451)
let hi = 'hi';
let hi = 'bye';

// 2506: 'Hi' is referenced directly or indirectly in its own base expression.ts(2506)
class Hi extends Hi {
}

// 2538 : Type 'MyClass' cannot be used as an index type.ts(2538)
class MyClass { }
const array = [];
const myObject = new MyClass();
array[myObject] = "something";

// 2677 : A type predicate's type must be assignable to its parameter's type.
// Type 'string' is not assignable to type 'T'.
// 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.ts(2677)
const isString = <T>(value: T): value is string {
    return typeof value === 'string'
}

// 2681: A constructor cannot have a 'this' parameter.ts(2681)
class Foo {
    constructor(this) {
    }
}

// 2693: 'string' only refers to a type, but is being used as a value here.

// 80007: 'await' has no effect on the type of this expression.ts(80007)
const hi = await foo()
function foo() { }

// 1010
// incorrect with copilot
/*

  • Notice the difference in colorization on line 2, 49, 61 and 71 for example
@aiday-mar
Copy link
Contributor Author

Screen.Recording.2025-02-25.at.09.51.46.mp4

@alexr00 alexr00 added this to the February 2025 milestone Feb 25, 2025
@alexr00 alexr00 added bug Issue identified by VS Code Team member as probable bug tree-sitter labels Feb 26, 2025
@alexr00
Copy link
Member

alexr00 commented Feb 26, 2025

In the places where there are errors, it is expected that the coloring will be different. However, I found some other differences with that file.

@vs-code-engineering vs-code-engineering bot added the unreleased Patch has not yet been released in VS Code Insiders label Feb 26, 2025
@vs-code-engineering vs-code-engineering bot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Feb 27, 2025
@meganrogge meganrogge added the verified Verification succeeded label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tree-sitter verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants