Fix JS without runtime typechecks. Fixes #1017

This commit is contained in:
Mark Probst 2018-08-08 08:56:59 -07:00
Родитель 671441f36b
Коммит 9e75c2995b
2 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -242,7 +242,11 @@ export class JavaScriptRenderer extends ConvenienceRenderer {
this.ensureBlankLine();
this.emitBlock([this.serializerFunctionLine(t, name), " "], "", () => {
this.emitLine("return JSON.stringify(uncast(value, ", typeMap, "), null, 2);");
if (!this._jsOptions.runtimeTypecheck) {
this.emitLine("return JSON.stringify(value);");
} else {
this.emitLine("return JSON.stringify(uncast(value, ", typeMap, "), null, 2);");
}
});
});
if (this._jsOptions.runtimeTypecheck) {

Просмотреть файл

@ -524,7 +524,11 @@ export const TypeScriptLanguage: Language = {
skipMiscJSON: false,
skipSchema: ["keyword-unions.schema"], // can't handle "constructor" property
rendererOptions: { "explicit-unions": "yes" },
quickTestRendererOptions: [{ "nice-property-names": "true" }, { "declare-unions": "true" }],
quickTestRendererOptions: [
{ "runtime-typecheck": "false" },
{ "nice-property-names": "true" },
{ "declare-unions": "true" }
],
sourceFiles: ["src/language/TypeScript.ts"]
};
@ -545,7 +549,7 @@ export const JavaScriptLanguage: Language = {
skipMiscJSON: false,
skipSchema: ["keyword-unions.schema"], // can't handle "constructor" property
rendererOptions: {},
quickTestRendererOptions: [],
quickTestRendererOptions: [{ "runtime-typecheck": "false" }],
sourceFiles: ["src/language/JavaScript.ts"]
};
@ -567,7 +571,11 @@ export const FlowLanguage: Language = {
"keyword-unions.schema" // can't handle "constructor" property
],
rendererOptions: { "explicit-unions": "yes" },
quickTestRendererOptions: [],
quickTestRendererOptions: [
{ "runtime-typecheck": "false" },
{ "nice-property-names": "true" },
{ "declare-unions": "true" }
],
sourceFiles: ["src/language/Flow.ts"]
};