mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
16 lines
663 B
TypeScript
16 lines
663 B
TypeScript
//// [tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts] ////
|
|
|
|
//// [assignmentCompatFunctionsWithOptionalArgs.ts]
|
|
function foo(x: { id: number; name?: string; }): void;
|
|
foo({ id: 1234 }); // Ok
|
|
foo({ id: 1234, name: "hello" }); // Ok
|
|
foo({ id: 1234, name: false }); // Error, name of wrong type
|
|
foo({ name: "hello" }); // Error, id required but missing
|
|
|
|
//// [assignmentCompatFunctionsWithOptionalArgs.js]
|
|
"use strict";
|
|
foo({ id: 1234 }); // Ok
|
|
foo({ id: 1234, name: "hello" }); // Ok
|
|
foo({ id: 1234, name: false }); // Error, name of wrong type
|
|
foo({ name: "hello" }); // Error, id required but missing
|