Skip to content

toString doesn't work on getter #628

Closed
@trusktr

Description

@trusktr

I have:

class Vector2 {
	public constructor(
		public x: f64 = 0,
		public y: f64 = 0
	) {}

	get X(): f64 {
		return this.x
	}
	set X(val: f64) {
		this.x = val
	}
}

const v = new Vector2(1, 2)
const x: string = v.x.toString() // works fine
const X: string = v.X.toString() // ERROR TS2339: Property 'toString' does not exist on type 'f64'.

The use of toString doesn't work on the result of the getter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions