Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

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:

inputoutput
nothingnothing

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
0

Notes

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