Comparing version
28
index.ts
@@ -1,27 +0,1 @@ | ||
function isValidType(type: string): boolean { | ||
console.log(type); | ||
const validTypes = [ | ||
"string", | ||
"u8", | ||
"i8", | ||
"u16", | ||
"i16", | ||
"u32", | ||
"i32", | ||
"u64", | ||
"i64", | ||
"f32", | ||
"f64", | ||
"bool", | ||
"boolean", | ||
// ...this.schemas.map((v) => v.name) | ||
]; | ||
if (type.endsWith("| null")) return isValidType(type.slice(0, type.length - 7)); | ||
if (type.includes("<")) return isValidType(type.slice(type.indexOf("<") + 1, type.lastIndexOf(">"))); | ||
if (validTypes.includes(type)) return true; | ||
return false; | ||
} | ||
console.log(isValidType("string | null")) | ||
console.log(isValidType("Array<string | null>")) | ||
export * from "./assembly/index.ts"; |
{ | ||
"name": "json-as", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0-beta.6", | ||
"author": "Jairus Tanaka", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -9,3 +9,3 @@ <h5 align="center"> | ||
</span> | ||
AssemblyScript - v1.0.0-beta.5 | ||
AssemblyScript - v1.0.0-beta.6 | ||
</pre> | ||
@@ -35,3 +35,3 @@ </h5> | ||
```bash | ||
npm install json-as@1.0.0-beta.5 | ||
npm install json-as@1.0.0-beta.6 | ||
``` | ||
@@ -38,0 +38,0 @@ |
@@ -133,4 +133,2 @@ import { IdentifierExpression, Source, StringLiteralExpression, IntegerLiteralExpression, FloatLiteralExpression, NullExpression, TrueExpression, FalseExpression, Node, Tokenizer } from "assemblyscript/dist/assemblyscript.js"; | ||
const value = member.initializer ? toString(member.initializer) : null; | ||
if (!this.isValidType(type, node)) | ||
throwError("Invalid Type. " + type + " is not a JSON-compatible type. Either decorate it with @omit, set it to private, or remove it.", member.type.range); | ||
if (type.startsWith("(") && type.includes("=>")) | ||
@@ -137,0 +135,0 @@ continue; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
500385
-0.18%9377
-0.28%