assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

String literals are failing

Open npenin opened this issue 2 years ago • 4 comments

Assembly script fails on parsing union string literals (https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types). An example as simple as this fails:

export type BufferEncoding = 'utf8' | 'ascii';
ERROR TS1005: 'null' expected.

 export type BufferEncoding = 'utf8' | 'ascii';

npenin avatar May 27 '22 08:05 npenin

union string literals doesn't support yet

MaxGraey avatar May 27 '22 08:05 MaxGraey

Is there anyway I can help to make this happen ?

npenin avatar Jun 01 '22 12:06 npenin

The implementation of only union string literals (without mixed types like "str" | 123 | true) should not be too difficult. The only place where there may be difficulties is in type checking (diagnostics).

MaxGraey avatar Jun 01 '22 13:06 MaxGraey

If AS treats a string union as just string (for now, at least), then (I think...) TypeScript will be able to handle the rest (f.e. good type errors in VS Code or with tsc).

trusktr avatar Jun 11 '22 18:06 trusktr