Reputation: 8506
Below is my code
interface platformItem {
Result: {
name: string;
age: number;
};
}
const man: platformItem.Result;
The vscode will show warning which is no export member from platformItem, seems I can not use platformItem.result.
Upvotes: 0
Views: 59
Reputation: 4149
Here are three different approaches. Playground
interface platformItem {
Result: {
name: string;
age: number;
};
}
const man: platformItem["Result"] = { name: "Max Power", age: 30 };
type Man = {
name: string;
age: number;
};
interface platformItem {
Result: Man;
}
const man: Man = { name: "Max Power", age: 30 };
namespace platformItem {
export type Result = {
name: string;
age: number;
};
}
interface platformItem {
Result: platformItem.Result;
}
const man: platformItem.Result = { name: "Max Power", age: 30 };
Upvotes: 0