Search code examples
assemblyscript

Is it possible to use string literal types in AssemblyScript?


Is it possible to create a string literal type in AssemblyScript that resembles the type keyword used in TypeScript?

TypeScript example:

export type MyType = 'foo' | 'bar';

Solution

  • Not currently:

    > asc assembly/index.ts --target debug
    
    ERROR AS100: Not implemented: union types
       :
     1 │ export type MyType = 'foo' | 'bar';
       │                              ~~~~~
       └─ in assembly/index.ts(1,30)
    

    There is an issue open.