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

Incorrect handling mapped types #16

Closed
timocov opened this issue Sep 18, 2020 · 0 comments
Closed

Incorrect handling mapped types #16

timocov opened this issue Sep 18, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@timocov
Copy link
Owner

timocov commented Sep 18, 2020

Bug report

Input code

interface Foo {
	field: string;
	field2: number;
}

type ReadonlyFoo = Readonly<Foo>;

function bar(foo: ReadonlyFoo): void {
	console.log(foo.field, foo.field2);
}

function baz(): void {
	const foo: Foo = {
		field: '',
		field2: 0,
	};

	bar(foo);

	bar({
		field: '',
		field2: 0,
	});
}

Expected output

function bar(foo) {
    console.log(foo._internal_field, foo._internal_field2);
}
function baz() {
    var foo = {
        _internal_field: '',
        _internal_field2: 0,
    };
    bar(foo);
    bar({
        _internal_field: '',
        _internal_field2: 0,
    });
}

Actual output

function bar(foo) {
    console.log(foo.field, foo.field2);
}
function baz() {
    var foo = {
        _internal_field: '',
        _internal_field2: 0,
    };
    bar(foo);
    bar({
        field: '',
        field2: 0,
    });
}

Additional context

Broken in #15

@timocov timocov added the bug Something isn't working label Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant