Skip to content

C# records are translated to invalid TypeScript types because of the <Clone>$ member #458

@ulrichb

Description

@ulrichb

Given C# code link this:

public class TestClass { public TestRecord Hello() => new TestRecord("x"); }

public record TestRecord(string Value);

... produces TS typing like this:

		export class TestRecord {
			constructor(Value: string);
			Value: string;
			ToString(): string;
			GetHashCode(): number;
			Equals(obj: unknown | undefined): boolean;
			Equals(other: NodeDotNetInterop.TestRecord | undefined): boolean;
			<Clone>$(): NodeDotNetInterop.TestRecord;
			Deconstruct(): { Value: string };
		}

... which is invalid TypeScript: compile error at the <Clone>$() line is "Unexpected token. A constructor, method, accessor, or property was expected".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions