export type for core
Give a name to a type annotation and export it from a module.
Command Type
keyword
Signature
> export type {flags} (name) (type)
Parameters
name: Name of the type alias.type: Equals sign followed by a type, as written after:on a parameter.
Input/output types:
| input | output |
|---|---|
| nothing | nothing |
Examples
Export a type alias from a module and import it with a command.
> module geo {
export type Point = record<x: int, y: int>
export def origin []: nothing -> Point { {x: 0, y: 0} }
}
use geo [Point origin]
let p: Point = origin
$p.y
0Notes
This command is a parser keyword. use <module> <name>, use <module> [<names>] and use <module> * import a type alias. A bare use <module> doesn't, because a type alias name can't take the module name as a prefix the way a command name does.
For details, check: https://www.nushell.sh/book/thinking_in_nu.html