From c0ec0c0927cf93bc6de36f5cda463a29f3593c0c Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 11:32:48 -0700 Subject: [PATCH 01/23] testing --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 35c933c9..45e121e1 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,6 @@ Courier is [Apache 2.0 Licensed](LICENSE.txt). For development and submitting pull requests, please see the [Contributing document](CONTRIBUTING.md). + + +Testing \ No newline at end of file From 83c1b2544185d228f3a2c8de83067fdf96730211 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 11:44:18 -0700 Subject: [PATCH 02/23] copy over typescript-lite --- flowtype/.gitignore | 11 + flowtype/README.md | 316 +++++ flowtype/generator-test/build.sbt | 45 + flowtype/generator/.gitignore | 2 + flowtype/generator/build.sbt | 17 + .../courier/TypeScriptLiteGenerator.java | 171 +++ .../coursera/courier/tslite/GlobalConfig.java | 47 + .../coursera/courier/tslite/TSProperties.java | 67 ++ .../org/coursera/courier/tslite/TSSyntax.java | 1048 +++++++++++++++++ .../main/resources/runtime/CourierRuntime.ts | 20 + .../src/main/resources/rythm-ts/enum.txt | 15 + .../src/main/resources/rythm-ts/fixed.txt | 4 + .../src/main/resources/rythm-ts/record.txt | 21 + .../src/main/resources/rythm-ts/typeref.txt | 6 + .../src/main/resources/rythm-ts/union.txt | 28 + flowtype/testsuite/.gitignore | 5 + flowtype/testsuite/full-build.sh | 6 + flowtype/testsuite/package.json | 28 + flowtype/testsuite/spec/support/jasmine.json | 8 + .../array_bad-item-type-enum-expected.ts | 6 + .../array_bad-item-type.ts | 12 + .../compilation-failures/enum_bad-string.ts | 3 + .../map_bad-value-type.ts | 39 + .../record_wrong-field-type.ts | 6 + .../src/compilation-failures/tslite-bindings | 1 + .../typeref_wrong-type.ts | 3 + .../union_bad-body-content.ts | 8 + .../union_bad-lookup-string.ts | 8 + .../expected-successes/spec/bindings.spec.ts | 649 ++++++++++ .../src/expected-successes/tslite-bindings | 1 + .../typescript-compiler.d.ts | 10 + flowtype/testsuite/tsconfig.json | 45 + flowtype/testsuite/typings.json | 6 + 33 files changed, 2662 insertions(+) create mode 100644 flowtype/.gitignore create mode 100644 flowtype/README.md create mode 100644 flowtype/generator-test/build.sbt create mode 100644 flowtype/generator/.gitignore create mode 100644 flowtype/generator/build.sbt create mode 100644 flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java create mode 100644 flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java create mode 100644 flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java create mode 100644 flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java create mode 100644 flowtype/generator/src/main/resources/runtime/CourierRuntime.ts create mode 100644 flowtype/generator/src/main/resources/rythm-ts/enum.txt create mode 100644 flowtype/generator/src/main/resources/rythm-ts/fixed.txt create mode 100644 flowtype/generator/src/main/resources/rythm-ts/record.txt create mode 100644 flowtype/generator/src/main/resources/rythm-ts/typeref.txt create mode 100644 flowtype/generator/src/main/resources/rythm-ts/union.txt create mode 100644 flowtype/testsuite/.gitignore create mode 100755 flowtype/testsuite/full-build.sh create mode 100644 flowtype/testsuite/package.json create mode 100644 flowtype/testsuite/spec/support/jasmine.json create mode 100644 flowtype/testsuite/src/compilation-failures/array_bad-item-type-enum-expected.ts create mode 100644 flowtype/testsuite/src/compilation-failures/array_bad-item-type.ts create mode 100644 flowtype/testsuite/src/compilation-failures/enum_bad-string.ts create mode 100644 flowtype/testsuite/src/compilation-failures/map_bad-value-type.ts create mode 100644 flowtype/testsuite/src/compilation-failures/record_wrong-field-type.ts create mode 120000 flowtype/testsuite/src/compilation-failures/tslite-bindings create mode 100644 flowtype/testsuite/src/compilation-failures/typeref_wrong-type.ts create mode 100644 flowtype/testsuite/src/compilation-failures/union_bad-body-content.ts create mode 100644 flowtype/testsuite/src/compilation-failures/union_bad-lookup-string.ts create mode 100644 flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts create mode 120000 flowtype/testsuite/src/expected-successes/tslite-bindings create mode 100644 flowtype/testsuite/src/expected-successes/typescript-compiler.d.ts create mode 100644 flowtype/testsuite/tsconfig.json create mode 100644 flowtype/testsuite/typings.json diff --git a/flowtype/.gitignore b/flowtype/.gitignore new file mode 100644 index 00000000..79b9a21f --- /dev/null +++ b/flowtype/.gitignore @@ -0,0 +1,11 @@ +.gradle +build/ + +generator/build +testsuite/testsuiteTests/generated + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/flowtype/README.md b/flowtype/README.md new file mode 100644 index 00000000..d5eb71df --- /dev/null +++ b/flowtype/README.md @@ -0,0 +1,316 @@ +Typescript-Lite Courier Data Binding Generator +============================================== + +Experimental! + +Lightweight Courier bindings for Typescript. + +The guiding philosophy here was to achieve type safety with as small a runtime footprint as possible -- use the fact +that JSON is native to javascript to lightly define types and interfaces that describe your courier specs. + +These bindings will achieve their goal if: + + * You can just cast the result of a JSON HTTP response (or other JSON source) into the base expected + type and stay typesafe without having to cast anything more afterwards. + * You can hand-write JSON in your test-cases and API requests, and those test-cases + fail to compile when the record contract breaks. + * You can enjoy the sweet auto-complete and compile-time warnings you've come to enjoy from typescript. + +These bindings require Typescript 1.8+ + +Features missing in action +-------------------------- + +* **Coercer support**. The strong runtime component of Coercers don't gel easily with the philosophy of casting records + lightly into target typescript interfaces, so there wasn't an easy fit. + * Maybe these get included when Typescript-lite becomes just plain ol typescript. +* **Keyed maps**. Javascript objects naturally only support string-keyed maps. Since we are avoiding runtime + overhead as much as possible we did not want to introduce a new type, nor the means to serialize said type. + * Integrating `Immutable.js` would make a lot of sense when we want to expand into this direction. + * These bindings will coerce keyed maps into string-keyed maps (which they are on the wire anyways) +* **Non-JSON serialization**. Although courier supports more compact binary formats (PSON, Avro, BSON), Typescript-lite + bindings currently only supports valid JSON objects. +* **Default values**. As with the other points, default values require a runtime. +* **Flat-typed definitions**. This was just an oversight. Gotta add these. + +Running the generator from the command line +------------------------------------------- + +Build a fat jar from source and use that. See the below section *Building a fat jar*. + +How code is generated +--------------------- + +**Records:** + +* Records are generated as an interface within the typescript `namespace` specified by your record. + * If you don't use a namespace, the interface will be injected at the top-level + +e.g. the result of [Fortune.courier](https://github.com/coursera/courier/blob/master/reference-suite/src/main/courier/org/example/Fortune.courier): + +```typescript +// ./my-tslite-bindings/org.example.Fortune.ts +import { FortuneTelling } from "./org.example.FortuneTelling"; +import { DateTime } from "./org.example.common.DateTime"; + +/** + * A fortune. + */ +export interface Fortune { + + /** + * The fortune telling. + */ + telling : FortuneTelling; + + createdAt : DateTime; +} +``` + +**Enums:** + +* Enums are represented as [string literal types](https://basarat.gitbooks.io/typescript/content/docs/types/stringLiteralType.html). +* Convenience constants matching the string literals are provided despite having a runtime cost +* Unlike other bindings, Typescript-lite does not include an `UNKNOWN$` option. In case of wire inconsistency + you will have to just fall through to `undefined`. + +e.g. the result of [MagicEightBallAnswer.courier](https://github.com/coursera/courier/blob/master/reference-suite/src/main/courier/org/example/MagicEightBallAnswer.courier): + +```typescript +// ./my-tslite-bindings/org.example.MagicEightBallAnswer.ts +/** + * Magic eight ball answers. + */ +export type MagicEightBallAnswer = "IT_IS_CERTAIN" | "ASK_AGAIN_LATER" | "OUTLOOK_NOT_SO_GOOD" ; +export module MagicEightBallAnswer { + + export const IT_IS_CERTAIN: MagicEightBallAnswer = "IT_IS_CERTAIN"; + + export const ASK_AGAIN_LATER: MagicEightBallAnswer = "ASK_AGAIN_LATER"; + + export const OUTLOOK_NOT_SO_GOOD: MagicEightBallAnswer = "OUTLOOK_NOT_SO_GOOD"; + + export const all: Array = ["IT_IS_CERTAIN", "ASK_AGAIN_LATER", "OUTLOOK_NOT_SO_GOOD"]; +} +``` + +```typescript +// Some other file +// You can use it like this + +const answer: MagicEightBallAnswer = "IT_IS_CERTAIN"; +switch(answer) { + case MagicEightBallAnswer.IT_IS_CERTAIN: + // do something + break; + case MagicEightBallAnswer.ASK_AGAIN_LATER: + // do something + break; + default: + // you should probably always check this...in case you got some new unexpected + // value from a new version of the server software. This is the equivalent of + // testing UNKNOWN$ +} + +console.log(MagicEightBallAnswer.all); // logs all possible enum values to console +``` +**Arrays:** + +* Arrays are represented as typescript arrays. + +**Maps:** + +* Maps are represented as javascript objects, as interfaced by `courier.Map` +* Only string-keyed maps are currently supported. + +**Unions:** + +* Unions are represented as an intersection type between all the members of the union. +* A Run-time `unpack` accessor is provided to test each aspect of the union +* Unlike other serializers, no `UNKNOWN$` member is generated for the union. If all provided accessors end up yielding + undefined, then conclude that it was an unknown union member (see second example) + +e.g. The result of [FortuneTelling.pdsc](https://github.com/coursera/courier/blob/master/reference-suite/src/main/pegasus/org/example/FortuneTelling.pdsc): +```typescript +// file: my-tslite-bindings/org.example.FortuneTelling.ts +import { MagicEightBall } from "./org.example.MagicEightBall"; +import { FortuneCookie } from "./org.example.FortuneCookie"; + +export type FortuneTelling = FortuneTelling.FortuneCookieMember | FortuneTelling.MagicEightBallMember | FortuneTelling.StringMember; +export module FortuneTelling { + export interface FortuneTellingMember { + [key: string]: FortuneCookie | MagicEightBall | string; + } + + export interface FortuneCookieMember extends FortuneTellingMember { + "org.example.FortuneCookie": FortuneCookie; + } + + export interface MagicEightBallMember extends FortuneTellingMember { + "org.example.MagicEightBall": MagicEightBall; + } + + export interface StringMember extends FortuneTellingMember { + "string": string; + } + + export function unpack(union: FortuneTelling) { + return { + fortuneCookie: union["org.example.FortuneCookie"] as FortuneCookie, + magicEightBall: union["org.example.MagicEightBall"] as MagicEightBall, + string$: union["string"] as string + }; + } +} +``` + +Here's how you would use one: +```typescript +import { FortuneTelling } from "./my-tslite-bindings/org.example.FortuneTelling"; +import { MacigEightBall } from "./my-tslite-bindings/org.example.MagicEightBall"; +import { FortuneCookie } from "./my-tslite-bindings/org.example.FortuneCookie"; + +const telling: FortuneTelling = /* Get the union from somewhere...probably the wire */; + +const { fortuneCookie, magicEightBall, string_ } = FortuneTelling.unpack(telling); + +if (fortuneCookie) { + // do something with fortuneCookie +} else if (magicEightBall) { + // do something with magicEightBall +} else if (string$) { + // do something with str +} else { + throw 'a fit because no one will tell your fortune'; +} +``` + +Projections and Optionality +--------------------------- + +These bindings do not currently support projections. If you need to use projections, then +generate your bindings with Optionality of REQUIRED_FIELDS_MAY_BE_ABSENT rather than STRICT +as the 4th argument to the generator tool. + +That said, here is a good way we could evolve to support projections: + +I think [Intersection types](https://basarat.gitbooks.io/typescript/content/docs/types/type-system.html#intersection-type) may be a good approach in typescript + +Imagine the following courier type: + +``` +record Message { + id: string; + subject: string; + body: string; +} +``` + +If we wanted to support projections, we could generate the following types + +```typescript +module Message { + interface Id { + id: string; + } + interface Subject { + subject: string; + } + + interface Body { + body: string; + } +} +type Message = Message.Id & Message.Subject & Message.Body; +``` + +In your application code when you request some projection, instead of using the Message type you could just safely cast the message down to its component projections! For example: + +```typescript +function getMessageIdAndBody(id: string): Promise { + return http.get('/messages/' + id + '?projection=(id,body)').then((resp) => { + return resp.data as (Message.Id & Message.Body); + }) +} +``` + +Any attempt to access `message.subject` from the results of that function would of course fail at compile time. + + +Custom Types +------------ + +Custom Types allow any Typescript type to be bound to any pegasus primitive type. + +For example, say a schema has been defined to represent a "date time" as a unix timestamp long: + +``` +namespace org.example + +typeref DateTime = long +``` + +This results in a typescript file: +```typescript +// ./my-tslite-bindings/org.coursera.customtypes.DateTime.ts +export type DateTime = number; +``` + +JSON Serialization / Deserialization +------------------------------------ + +JSON serialization is trivial in typescript. Just take use `JSON.stringify` on any courier type that compiles. + +```typescript +import { Message } from "./my-tslite-bindings/org.coursera.records.Message"; + +const message: Message = {"body": "Hello Pegasus!"}; +const messageJson = JSON.stringify(message); +``` + +And of course you can read results as well. + +```typescript +import { Message } from "./my-tslite-bindings/org.coursera.records.Message"; + +const messageStr: string = /* Get the message string somehow */ +const message = JSON.parse(messageStr) as Message; +``` + +Runtime library +--------------- + +All generated Typescript-lite bindings depend on a `CourierRuntime.ts` class. This class provides the very minimal +functionality and type definitions necessary for generated bindings to work. + +Building from source +-------------------- + +See the main CONTRIBUTING document for details. + +Building a Fat Jar +------------------ + +```sh +$ sbt +> project typescript-lite-generator +> assembly +``` + +This will build a standalone "fat jar". This is particularly convenient for use as a standalone +commandline application. + +Testing +------- + +1. No testing has been done yet except verifying that the generated files from reference-suite pass `tsc`. + That's next on the list =) + +TODO +---- + +* [ ] Add support for flat type definitions +* [ ] Figure out the best way to distribute the 'fat jar'. +* [ ] Automate distribution of the Fat Jar +* [ ] Publish Fat Jar to remote repos? Typically fat jars should not be published to maven/ivy + repos, but maybe it should be hosted for easy download elsewhere? diff --git a/flowtype/generator-test/build.sbt b/flowtype/generator-test/build.sbt new file mode 100644 index 00000000..9f6f429e --- /dev/null +++ b/flowtype/generator-test/build.sbt @@ -0,0 +1,45 @@ +import sbt.inc.Analysis + +name := "courier-typescript-lite-generator-test" + +packagedArtifacts := Map.empty // do not publish + +libraryDependencies ++= Seq( + ExternalDependencies.JodaTime.jodaTime) + +autoScalaLibrary := false + +crossPaths := false + +// Test Generator +forkedVmCourierGeneratorSettings + +forkedVmCourierMainClass := "org.coursera.courier.TypeScriptLiteGenerator" + +forkedVmCourierClasspath := (dependencyClasspath in Runtime in typescriptLiteGenerator).value.files + +forkedVmSourceDirectory := (sourceDirectory in referenceSuite).value / "main" / "courier" + +forkedVmCourierDest := file("typescript-lite") / "testsuite" / "src" / "tslite-bindings" + +forkedVmAdditionalArgs := Seq("STRICT") + +(compile in Compile) := { + (forkedVmCourierGenerator in Compile).value + + Analysis.Empty +} + +lazy val npmTest = taskKey[Unit]("Executes NPM test") + +npmTest in Test := { + (compile in Compile).value + + val result = """./typescript-lite/testsuite/full-build.sh"""! + + if (result != 0) { + throw new RuntimeException("NPM Build Failed") + } +} + +test in Test := (npmTest in Test).value diff --git a/flowtype/generator/.gitignore b/flowtype/generator/.gitignore new file mode 100644 index 00000000..19ec0db9 --- /dev/null +++ b/flowtype/generator/.gitignore @@ -0,0 +1,2 @@ +src/test/mainGeneratedPegasus +src/main/mainGeneratedPegasus diff --git a/flowtype/generator/build.sbt b/flowtype/generator/build.sbt new file mode 100644 index 00000000..aa4a5926 --- /dev/null +++ b/flowtype/generator/build.sbt @@ -0,0 +1,17 @@ +import sbtassembly.AssemblyPlugin.defaultShellScript + +name := "courier-typescript-lite-generator" + +plainJavaProjectSettings + +libraryDependencies ++= Seq( + ExternalDependencies.Rythm.rythmEngine, + ExternalDependencies.Slf4j.slf4jSimple) + +// Fat Jar +mainClass in assembly := Some("org.coursera.courier.TypeScriptLiteGenerator") + +assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript)) + +assemblyJarName in assembly := s"${name.value}-${version.value}.jar" + diff --git a/flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java new file mode 100644 index 00000000..23de30c5 --- /dev/null +++ b/flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java @@ -0,0 +1,171 @@ +/* + * Copyright 2016 Coursera Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.coursera.courier; + +import com.linkedin.data.schema.DataSchema; +import com.linkedin.pegasus.generator.GeneratorResult; +import com.linkedin.pegasus.generator.spec.*; +import org.apache.commons.io.IOUtils; +import org.coursera.courier.api.DefaultGeneratorRunner; +import org.coursera.courier.api.GeneratedCode; +import org.coursera.courier.api.GeneratedCodeTargetFile; +import org.coursera.courier.api.GeneratorRunnerOptions; +import org.coursera.courier.api.PegasusCodeGenerator; +import org.coursera.courier.lang.DocCommentStyle; +import org.coursera.courier.lang.PoorMansCStyleSourceFormatter; +import org.coursera.courier.tslite.GlobalConfig; +import org.coursera.courier.tslite.TSProperties; +import org.coursera.courier.tslite.TSSyntax; +import org.rythmengine.RythmEngine; +import org.rythmengine.exception.RythmException; +import org.rythmengine.resource.ClasspathResourceLoader; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Collection; +import java.util.Collections; + +/** + * Courier code generator for Typescript. + */ +public class TypeScriptLiteGenerator implements PegasusCodeGenerator { + private static final TSProperties.Optionality defaultOptionality = + TSProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; + + private final GlobalConfig globalConfig; + private final RythmEngine engine; + + public static void main(String[] args) throws Throwable { + // TODO(jbetz): use a CLI parser library + + if (args.length < 3 || args.length > 5) { + throw new IllegalArgumentException( + "Usage: targetPath resolverPath1[:resolverPath2]+ sourcePath1[:sourcePath2]+ [REQUIRED_FIELDS_MAY_BE_ABSENT|STRICT] [EQUATABLE]"); + } + String targetPath = args[0]; + String resolverPath = args[1]; + String sourcePathString = args[2]; + String[] sourcePaths = sourcePathString.split(":"); + + TSProperties.Optionality optionality = defaultOptionality; + if (args.length > 3) { + optionality = TSProperties.Optionality.valueOf(args[3]); + } + + boolean equatable = false; + if (args.length > 4) { + if (!args[4].equals("EQUATABLE")) { + throw new IllegalArgumentException("If present 4th argument must be 'EQUATABLE'"); + } + equatable = true; + } + + GeneratorRunnerOptions options = + new GeneratorRunnerOptions(targetPath, sourcePaths, resolverPath); + + GlobalConfig globalConfig = new GlobalConfig(optionality, equatable, false); + GeneratorResult result = + new DefaultGeneratorRunner().run(new TypeScriptLiteGenerator(globalConfig), options); + + for (File file: result.getTargetFiles()) { + System.out.println(file.getAbsolutePath()); + } + + InputStream runtime = TypeScriptLiteGenerator.class.getClassLoader().getResourceAsStream("runtime/CourierRuntime.ts"); + IOUtils.copy(runtime, new FileOutputStream(new File(targetPath, "CourierRuntime.ts"))); + } + + public TypeScriptLiteGenerator() { + this(new GlobalConfig( + defaultOptionality, + false, + false)); + } + + public TypeScriptLiteGenerator(GlobalConfig globalConfig) { + this.globalConfig = globalConfig; + this.engine = new RythmEngine(); + this.engine.registerResourceLoader(new ClasspathResourceLoader(engine, "/")); + } + + public static class TSCompilationUnit extends GeneratedCodeTargetFile { + public TSCompilationUnit(String name, String namespace) { + super(name, namespace, "ts"); + } + } + + private static final PoorMansCStyleSourceFormatter formatter = + new PoorMansCStyleSourceFormatter(2, DocCommentStyle.ASTRISK_MARGIN); + + /** + * See {@link org.coursera.courier.tslite.TSProperties} for customization options. + */ + @Override + public GeneratedCode generate(ClassTemplateSpec templateSpec) { + + String code; + TSProperties TSProperties = globalConfig.lookupTSProperties(templateSpec); + if (TSProperties.omit) return null; + + TSSyntax syntax = new TSSyntax(TSProperties); + try { + if (templateSpec instanceof RecordTemplateSpec) { + code = engine.render("rythm-ts/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); + } else if (templateSpec instanceof EnumTemplateSpec) { + code = engine.render("rythm-ts/enum.txt", syntax.new TSEnumSyntax((EnumTemplateSpec) templateSpec)); + } else if (templateSpec instanceof UnionTemplateSpec) { + code = engine.render("rythm-ts/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec)); + } else if (templateSpec instanceof TyperefTemplateSpec) { + TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec; + code = engine.render("rythm-ts/typeref.txt", syntax.TSTyperefSyntaxCreate(typerefSpec)); + } else if (templateSpec instanceof FixedTemplateSpec) { + code = engine.render("rythm-ts/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec)); + } else { + return null; // Indicates that we are declining to generate code for the type (e.g. map or array) + } + } catch (RythmException e) { + throw new RuntimeException( + "Internal error in generator while processing " + templateSpec.getFullName(), e); + } + TSCompilationUnit compilationUnit = + new TSCompilationUnit( + templateSpec.getFullName(), ""); + code = formatter.format(code); + return new GeneratedCode(compilationUnit, code); + } + + @Override + public Collection generatePredef() { + return Collections.emptySet(); + } + + @Override + public Collection definedSchemas() { + return Collections.emptySet(); + } + + @Override + public String buildLanguage() { + return "typescript"; + } + + @Override + public String customTypeLanguage() { + return "typescript"; + } +} diff --git a/flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java b/flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java new file mode 100644 index 00000000..8ec7c362 --- /dev/null +++ b/flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java @@ -0,0 +1,47 @@ +package org.coursera.courier.tslite; + +import com.linkedin.data.DataMap; +import com.linkedin.data.schema.DataSchema; +import com.linkedin.pegasus.generator.spec.ClassTemplateSpec; +import com.linkedin.pegasus.generator.spec.UnionTemplateSpec; + +public class GlobalConfig { + public final TSProperties defaults; + + public GlobalConfig( + TSProperties.Optionality defaultOptionality, + boolean defaultEquatable, + boolean defaultOmit) { + defaults = new TSProperties(defaultOptionality, defaultEquatable, defaultOmit); + } + + public TSProperties lookupTSProperties(ClassTemplateSpec templateSpec) { + DataSchema schema = templateSpec.getSchema(); + if (templateSpec instanceof UnionTemplateSpec && templateSpec.getOriginalTyperefSchema() != null) { + schema = templateSpec.getOriginalTyperefSchema(); + } + + if (schema == null) { + return defaults; + } else { + Object typescript = schema.getProperties().get("typescript"); + if (typescript == null || !(typescript instanceof DataMap)) { + return defaults; + } + DataMap properties = ((DataMap) typescript); + + String optionalityString = properties.getString("optionality"); + + TSProperties.Optionality optionality = + optionalityString == null ? defaults.optionality : TSProperties.Optionality.valueOf(optionalityString); + + Boolean maybeEquatable = properties.getBoolean("equatable"); + boolean equatable = maybeEquatable == null ? defaults.equatable : maybeEquatable; + + Boolean maybeOmit = properties.getBoolean("omit"); + boolean omit = maybeOmit == null ? defaults.omit : maybeOmit; + + return new TSProperties(optionality, equatable, omit); + } + } +} diff --git a/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java b/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java new file mode 100644 index 00000000..69d0766e --- /dev/null +++ b/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java @@ -0,0 +1,67 @@ +package org.coursera.courier.tslite; + +/** + * Customizable properties that may be added to a Pegasus schema. + * + * Example usage: + * + * + * { + * "name": "Fortune", + * "namespace": "org.example", + * "type": "record", + * "fields": [ ... ], + * "typescript": { + * "optionality": "STRICT" + * } + * } + * + */ +public class TSProperties { + + /** + * "optionality" property. + * + * Typescript representations of Pegasus primitive types supported by this generator. + */ + public enum Optionality { + + /** + * Allows required fields to be absent, useful when working with projections. + * + * "undefined" is used to represent un-projected fields (required or optional) as well as absent + * optional fields. + */ + REQUIRED_FIELDS_MAY_BE_ABSENT, + + // TODO(jbetz): Remove as soon as we've migrated away from this usage pattern. + /** + * WARNING: this mode is unsafe when used in conjunction with projections, as a read/modify/coercerOutput + * pattern on a projection could result in the default value of primitives (e.g. 0 for ints) + * to be accidentally written. + * + * Required fields generated as non-optional Typescript properties. + * + * Optional fields are generated as optional Typescript properties, where an absent optional field + * value is represented as `nil`. + * + * When reading JSON, if a required field is absent, the field in data binding + * will default to the schema defined default value. + * + * When writing JSON, all required primitive fields will be written, even if they are the + * schema defined default value. + */ + STRICT + } + + public final Optionality optionality; + public final boolean equatable; + public final boolean omit; + + public TSProperties(Optionality optionality, boolean equatable, boolean omit) { + this.optionality = optionality; + this.equatable = equatable; + this.omit = omit; + } + +} diff --git a/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java new file mode 100644 index 00000000..e7e956dd --- /dev/null +++ b/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java @@ -0,0 +1,1048 @@ +/* + * Copyright 2016 Coursera Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.coursera.courier.tslite; + +import com.linkedin.data.DataMap; +import com.linkedin.data.schema.DataSchema; +import com.linkedin.data.schema.DataSchema.Type; +import com.linkedin.data.schema.EnumDataSchema; +import com.linkedin.data.schema.NamedDataSchema; +import com.linkedin.data.schema.PrimitiveDataSchema; +import com.linkedin.data.schema.RecordDataSchema; +import com.linkedin.data.schema.TyperefDataSchema; +import com.linkedin.data.schema.UnionDataSchema; +import com.linkedin.pegasus.generator.spec.*; +import org.coursera.courier.api.ClassTemplateSpecs; +import org.coursera.courier.lang.DocCommentStyle; +import org.coursera.courier.lang.DocEscaping; +import org.coursera.courier.tslite.TSProperties.Optionality; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Map; + +/** + * Main work-horse for populating the ts-lite Rythm templates. + * + * Most work delegates to inner classes, so you probably want to look them (linked below) + * + * Specifically, {@link TSEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link TSTyperefSyntax} are + * used directly to populate the templates. + * + * @see TSPrimitiveTypeSyntax + * @see TSEnumSyntax + * @see TSArraySyntax + * @see TSUnionSyntax + * @see TSMapSyntax + * @see TSTyperefSyntax + * @see TSRecordSyntax + * @see TSFixedSyntax + * @see TSRecordSyntax + * @see TSUnionSyntax + */ +public class TSSyntax { + + /** Config properties passed from the command line parser */ + private final TSProperties TSProperties; + + public TSSyntax(TSProperties TSProperties) { + this.TSProperties = TSProperties; + } + + /** + * Varying levels of reserved keywords copied from https://github.com/Microsoft/TypeScript/issues/2536 + **/ + private static final Set tsKeywords = new HashSet(Arrays.asList(new String[]{ + // Reserved Words + "break", + "case", + "catch", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "else", + "enum", + "export", + "extends", + "false", + "finally", + "for", + "function", + "if", + "import", + "in", + "instanceof", + "new", + "null", + "return", + "super", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "var", + "void", + "while", + "with", + + // Strict Mode Reserved Words + "as", + "implements", + "interface", + "let", + "package", + "private", + "protected", + "public", + "static", + "yield", + + // Contextual Keywords + "any", + "boolean", + "constructor", + "declare", + "get", + "module", + "require", + "number", + "set", + "string", + "symbol", + "type", + "from", + "of" + })); + + + /** Different choices for how to escaping symbols that match reserved ts keywords. */ + private static enum EscapeStrategy { + /** Adds a dollar sign after the symbol name when escaping. e.g.: class becomes class$ */ + MANGLE, + + /** Quotes the symbol when escaping. e.g.: class becomes "class" */ + QUOTE + } + + /** + * Returns the escaped Pegasus symbol for use in Typescript source code. + * + * Pegasus symbols must be of the form [A-Za-z_], so this routine simply checks if the + * symbol collides with a typescript keyword, and if so, escapes it. + * + * @param symbol the symbol to escape + * @param strategy which strategy to use in escaping + * + * @return the escaped Pegasus symbol. + */ + private static String escapeKeyword(String symbol, EscapeStrategy strategy) { + if (tsKeywords.contains(symbol)) { + if (strategy.equals(EscapeStrategy.MANGLE)) { + return symbol + "$"; + } else { + return "\"" + symbol + "\""; + } + } else { + return symbol; + } + } + + /** + * Creates a valid typescript import string given a type name (e.g. "Fortune") and the module name, + * which is usually the pegasus object's namespace. + * + * @param typeName Name of the type to import (e.g. "Fortune") + * @param moduleName That same type's namespace (e.g. "org.example") + * + * @return A fully formed import statement. e.g: import { Fortune } from "./org.example.Fortune" + **/ + private static String importString(String typeName, String moduleName) { + return new StringBuilder() + .append("import { ") + .append(typeName) + .append(" } from \"./") + .append(moduleName) + .append(".") + .append(typeName) + .append("\";") + .toString(); + } + + /** + * Return a full tsdoc for a type. + * + * @param doc the doc string in the type's DataSchema. + * @param deprecation the object listed under the schema's "deprecation" property + * + * @return a fully formed tsdoc for the type. + */ + private static String docComment(String doc, Object deprecation /* nullable */) { + StringBuilder docStr = new StringBuilder(); + + if (doc != null) { + docStr.append(doc.trim()); + } + + if (deprecation != null) { + docStr.append("\n\n").append("@deprecated"); + if (deprecation instanceof String) { + docStr.append(" ").append(((String)deprecation).trim()); + } + } + return DocEscaping.stringToDocComment(docStr.toString(), DocCommentStyle.ASTRISK_MARGIN); + } + + + /** + * Takes a set of imports constructed with {@link #importString}, and produces a valid import block + * for use at the top of a typescript source file + * + * @param imports the set of imports, each of which is a valid import line in typescript + * @return the import block, on separate lines. + */ + private static String flattenImports(Set imports) { + StringBuilder sb = new StringBuilder(); + + for (String import_: imports) { + sb.append(import_).append("\n"); + } + + return sb.toString(); + } + + /** Describes any type we are representing in the generated typescript */ + interface TSTypeSyntax { + + /** Return the simple name of the type, in valid typescript. "number" or "string" for example. */ + public String typeName(); + + /** + * Return the set of modules that must be imported in order for some other module + * to use this type. + **/ + public Set modulesRequiredToUse(); + } + + /** + * Describes any type that can be enclosed by another. According to the restli spec this only applies + * to anonymous unions. https://github.com/linkedin/rest.li/wiki/DATA-Data-Schema-and-Templates + **/ + private interface TSEnclosedTypeSyntax { + public String typeNameQualifiedByEnclosedType(); + } + + /** + * Create a TS*Syntax class around the provided ClassTemplate. + * + * That class will perform the heavy lifting of rendering TS-specific strings into the template. + * + * @param template the ClassTemplate + * @return a TS*Syntax class (see {@link TSSyntax} class-level docs for more info) + */ + private TSTypeSyntax createTypeSyntax(ClassTemplateSpec template) { + if (template instanceof RecordTemplateSpec) { + return new TSRecordSyntax((RecordTemplateSpec) template); + } else if (template instanceof TyperefTemplateSpec) { + return TSTyperefSyntaxCreate((TyperefTemplateSpec) template); + } else if (template instanceof FixedTemplateSpec) { + return TSFixedSyntaxCreate((FixedTemplateSpec) template); + } else if (template instanceof EnumTemplateSpec) { + return new TSEnumSyntax((EnumTemplateSpec) template); + } else if (template instanceof PrimitiveTemplateSpec) { + return new TSPrimitiveTypeSyntax((PrimitiveTemplateSpec) template); + } else if (template instanceof MapTemplateSpec) { + return new TSMapSyntax((MapTemplateSpec) template); + } else if (template instanceof ArrayTemplateSpec) { + return new TSArraySyntax((ArrayTemplateSpec) template); + } else if (template instanceof UnionTemplateSpec) { + return new TSUnionSyntax((UnionTemplateSpec) template); + } else { + throw new RuntimeException("Unrecognized template spec: " + template + " with schema " + template.getSchema()); + } + } + + /** Convenience wrapper around {@link #createTypeSyntax(ClassTemplateSpec)}. */ + private TSTypeSyntax createTypeSyntax(DataSchema schema) { + return createTypeSyntax(ClassTemplateSpec.createFromDataSchema(schema)); + } + + /** + * Returns the type name, prefaced with the enclosing class name if there was one. + * + * For example, a standalone union called MyUnion will just return "MyUnion". + * If that same union were enclosed within MyRecord, this would return "MyRecord.MyUnion". + **/ + String typeNameQualifiedByEnclosingClass(TSTypeSyntax syntax) { + if (syntax instanceof TSEnclosedTypeSyntax) { + return ((TSEnclosedTypeSyntax) syntax).typeNameQualifiedByEnclosedType(); + } else { + return syntax.typeName(); + } + } + + /** TS-specific syntax for Maps */ + private class TSMapSyntax implements TSTypeSyntax { + private final MapTemplateSpec _template; + + TSMapSyntax(MapTemplateSpec _template) { + this._template = _template; + } + + @Override + public String typeName() { + // (This comment is duplicated from TSArraySyntax.typeName for your benefit) + // Sadly the behavior of this function is indirectly controlled by the one calling it: TSRecordFieldSyntax. + // That class has the unfortunate behavior that it can produce 2 different ClassTemplateSpecs, one of which works for + // some cases, and one of which works for the others. See its own "typeName" definition for details but essentially + // it will give us one of the ClassTemplateSpecs and call typeName. If we then return null + // then it will give it a shot with the other ClassTemplateSpec. Unfortunately we have to do this because if + // we try to just use the first one, we will return "Map". This is also why we special-case unions here. + // we have to access a specific ClassTemplate + boolean valueIsUnion = _template.getValueClass() instanceof UnionTemplateSpec; + TSTypeSyntax itemTypeSyntax = valueIsUnion? createTypeSyntax(_template.getValueClass()): _valueTypeSyntax(); + String valueTypeName = typeNameQualifiedByEnclosingClass(itemTypeSyntax); + return valueTypeName == null? null: "Map<" + valueTypeName + ">"; + } + + @Override + public Set modulesRequiredToUse() { + Set modules = new HashSet<>(); + modules.add("import { Map } from \"./CourierRuntime\";"); // Our runtime contains a typedef for Map + modules.addAll(_valueTypeSyntax().modulesRequiredToUse()); // Need the map's value type to compile code that uses this type. + return modules; + } + + // + // Private TSMapSyntax members + // + private TSTypeSyntax _valueTypeSyntax() { + return createTypeSyntax(_template.getSchema().getValues()); + } + } + + /** TS-specific syntax for Arrays */ + private class TSArraySyntax implements TSTypeSyntax { + private final ArrayTemplateSpec _template; + + TSArraySyntax(ArrayTemplateSpec _template) { + this._template = _template; + } + + @Override + public String typeName() { + // Sadly the behavior of this function is indirectly controlled by the one calling it: TSRecordFieldSyntax. + // That class has the unfortunate behavior that it can produce 2 different ClassTemplateSpecs, one of which works for + // some cases, and one of which works for the others. See its own "typeName" definition for details but essentially + // it will give us one of the ClassTemplateSpecs and call typeName. If we then return null + // then it will give it a shot with the other ClassTemplateSpec. Unfortunately we have to do this because if + // we try to just use the first one, we will return "Array". This is also why we special-case unions here. + // we have to access a specific ClassTemplate + boolean itemIsUnion = _template.getItemClass() instanceof UnionTemplateSpec; + TSTypeSyntax itemTypeSyntax = itemIsUnion? createTypeSyntax(_template.getItemClass()): _itemTypeSyntax(); + String itemTypeName = typeNameQualifiedByEnclosingClass(itemTypeSyntax); + return itemTypeName == null? null: "Array<" + itemTypeName + ">"; + } + + @Override + public Set modulesRequiredToUse() { + return _itemTypeSyntax().modulesRequiredToUse(); // Need to import the array's index type to compile code that uses this type + } + + // + // Private TSArraySyntax members + // + private TSTypeSyntax _itemTypeSyntax() { + return createTypeSyntax(_template.getSchema().getItems()); + } + } + + /** Pegasus types that should be rendered as "number" in typescript */ + private static final Set TS_NUMBER_TYPES = new HashSet<>( + Arrays.asList( + new Type[] { Type.INT, Type.LONG, Type.FLOAT, Type.DOUBLE } + ) + ); + + /** Pegasus types that should be rendered as "string" in typescript */ + private static final Set TS_STRING_TYPES = new HashSet<>( + Arrays.asList( + new Type[] { Type.STRING, Type.BYTES, Type.FIXED } + ) + ); + + /** TS-specific syntax for all primitive types: Integer, Long, Float, Double, Boolean, String, Byte. */ + private class TSPrimitiveTypeSyntax implements TSTypeSyntax { + private final PrimitiveTemplateSpec _template; + private final PrimitiveDataSchema _schema; + + TSPrimitiveTypeSyntax(PrimitiveTemplateSpec _template) { + this._template = _template; + this._schema = _template.getSchema(); + } + + @Override + public String typeName() { + Type schemaType = _schema.getType(); + if (TS_NUMBER_TYPES.contains(schemaType)) { + return "number"; + } else if (TS_STRING_TYPES.contains(schemaType)) { + return "string"; + } else if (schemaType == Type.BOOLEAN) { + return "boolean"; + } else { + throw new IllegalArgumentException("Unexpected type " + schemaType + " in schema " + _schema); + } + } + + @Override + public Set modulesRequiredToUse() { + return new HashSet<>(); // using a primitive requires no imports + } + } + + /** + * Helper class that more-or-less wraps {@link NamedDataSchema}. + * + * Helps reduce code bloat for Records, Enums, and Typerefs. + **/ + private class TSNamedTypeSyntax { + private final NamedDataSchema _dataSchema; + + public TSNamedTypeSyntax(NamedDataSchema _dataSchema) { + this._dataSchema = _dataSchema; + } + + public String typeName() { + return TSSyntax.escapeKeyword(this._dataSchema.getName(), EscapeStrategy.MANGLE); + } + + public String docString() { + return docComment( + _dataSchema.getDoc(), + _dataSchema.getProperties().get("deprecated") + ); + } + + public Set modulesRequiredToUse() { + Set modules = new HashSet<>(); + // Named types get their own files, so you have to import them in order to use them. + modules.add(importString(_dataSchema.getName(), _dataSchema.getNamespace())); + return modules; + } + } + + /** TS syntax for Fixed types. */ + public class TSFixedSyntax implements TSTypeSyntax { + private final FixedTemplateSpec _template; + private final TSNamedTypeSyntax _namedSyntax; + + public TSFixedSyntax(FixedTemplateSpec template, TSNamedTypeSyntax namedSyntax) { + this._template = template; + this._namedSyntax = namedSyntax; + } + + public String docString() { + return _namedSyntax.docString(); + } + + public String typeName() { + return _namedSyntax.typeName(); + } + + @Override + public Set modulesRequiredToUse() { + return _namedSyntax.modulesRequiredToUse(); + } + } + + /** Create a new TSFixedSyntax */ + public TSFixedSyntax TSFixedSyntaxCreate(FixedTemplateSpec template) { + return new TSFixedSyntax(template, new TSNamedTypeSyntax(template.getSchema())); + } + + /** + * TS representation of a Union type's member (e.g. the "int" in "union[int]"). + */ + public class TSUnionMemberSyntax { + private final TSUnionSyntax _parentSyntax; + private final UnionDataSchema _schema; + private final UnionTemplateSpec.Member _member; + + public TSUnionMemberSyntax(TSUnionSyntax _parentSyntax, UnionDataSchema _schema, UnionTemplateSpec.Member _member) { + this._parentSyntax = _parentSyntax; + this._schema = _schema; + this._member = _member; + } + + /** + * Provides a partially-qualified representation of this type's "Member" sister. + * For example, if you had a courier union[int] typeref as "MyUnion", this method would + * return "MyUnion.IntMember". + **/ + String fullUnionMemberTypeName() { + return _parentSyntax.typeName() + "." + this.unionMemberTypeName(); + } + + /** + * Returns the symbol used to access this union member's index in the union's "unpack" return object. + * + * For example, given union[FortuneCookie], the return object from "unpack" would be { fortuneCookie: union["namespace.FortuneCookie"] as FortuneCookie } + */ + public String unpackString() { + DataSchema schema = _memberSchema(); + String unpackNameBase; + if (schema instanceof PrimitiveDataSchema) { + unpackNameBase = schema.getUnionMemberKey(); + } else { + unpackNameBase = _memberTypeSyntax().typeName(); + } + + String punctuationEscaped = unpackNameBase.replaceAll("[\\p{Punct}\\p{Space}]", ""); + String lowerCased = Character.toLowerCase(punctuationEscaped.charAt(0)) + punctuationEscaped.substring(1); + + return escapeKeyword(lowerCased, EscapeStrategy.MANGLE); + } + + /** + * Returns the union member class name for the given {@link ClassTemplateSpec} as a Typescript + * source code string. + * + * @return a typescript source code string identifying the union member. + */ + public String unionMemberTypeName() { + DataSchema memberSchema = _memberSchema(); + Type memberType = _memberSchema().getType(); + if (memberSchema.isPrimitive() || memberType == Type.MAP || memberType == Type.ARRAY) { + String unionMemberKey = _memberSchema().getUnionMemberKey(); + String camelCasedName = Character.toUpperCase(unionMemberKey.charAt(0)) + unionMemberKey.substring(1); + return camelCasedName + "Member"; // IntMember, DoubleMember, FixedMember etc + } else if (memberSchema instanceof NamedDataSchema) { + String className = ((NamedDataSchema) memberSchema).getName(); + return className + "Member"; // e.g: FortuneCookieMember + } else { + throw new IllegalArgumentException("Don't know how to handle schema of type " + memberSchema.getType()); + } + } + + public String unionMemberKey() { + return _member.getSchema().getUnionMemberKey(); + } + + public String typeName() { + return _memberTypeSyntax().typeName(); + } + + /** The set of modules imports that need to be included in order to use the type represented by this union member */ + Set typeModules() { + return _memberTypeSyntax().modulesRequiredToUse(); + } + + // + // Private UnionMemberSyntax members + // + private DataSchema _memberSchema() { + return _member.getSchema(); + } + private TSTypeSyntax _memberTypeSyntax() { + return createTypeSyntax(_member.getSchema()); + } + } + + /** TS-specific representation of a Union type. */ + public class TSUnionSyntax implements TSTypeSyntax, TSEnclosedTypeSyntax { + private final UnionTemplateSpec _template; + private final UnionDataSchema _schema; + + public TSUnionSyntax(UnionTemplateSpec _template) { + this._template = _template; + this._schema = _template.getSchema(); + } + + @Override + public String typeNameQualifiedByEnclosedType() { + if (_template.getEnclosingClass() != null) { + return createTypeSyntax(_template.getEnclosingClass()).typeName() + "." + this.typeName(); + } else { + return this.typeName(); + } + } + + @Override + public String typeName() { + if (_template.getTyperefClass() != null) { + // If this union was typerefed then just use the typeref name + TSTyperefSyntax refSyntax = TSTyperefSyntaxCreate(_template.getTyperefClass()); + return refSyntax.typeName(); + } else { + // I actually never figured out why this works, so I'm very sorry if you're dealing + // with the repercussions here. + return escapeKeyword(this._template.getClassName(), EscapeStrategy.MANGLE); + } + } + + /** Return the whole typescript import block for the file in which this union is declared. */ + public String imports() { + Set allImports = new HashSet<>(); + + // Only print out the imports for non-enclosed union types. Enclosed ones will be handled + // by the enclosing record. + if (!_isEnclosedType()) { + for (TSUnionMemberSyntax member: this.members()) { + allImports.addAll(member.typeModules()); + } + } + + return flattenImports(allImports); + } + + @Override + public Set modulesRequiredToUse() { + Set modules = new HashSet(); + // enclosed types dont report modules -- their enclosing types will do so for them! + if (!_isEnclosedType() && this.typeName() != null) { + modules.add(importString(this.typeName(), this._template.getNamespace())); + } + return modules; + } + + public String docString() { + if (this._template.getTyperefClass() != null) { + return new TSNamedTypeSyntax(this._template.getTyperefClass().getSchema()).docString(); + } else { + return ""; + } + } + + /** + * Produces the "MyUnionMember" typename. + * + * For example, union[int, string] produces a few extra types: IntMember, StringMember, etc. Each of those inherit + * from "MyUnionMember" (or whatever your union type is called) + **/ + public String memberBaseTypeName() { + return this.typeName() + "Member"; + } + + /** + * Given union[int, string, FortuneCookie] this returns the typescript equivalent: "number" | "string" | FortuneCookie + **/ + public String unionTypeExpression() { + StringBuilder sb = new StringBuilder(); + + List members = this.members(); + for (int i = 0; i < members.size(); i++) { + boolean isLast = (i == members.size() - 1); + TSUnionMemberSyntax member = members.get(i); + sb.append(member.typeName()); + + if (!isLast) { + sb.append(" | "); + } + } + + return sb.toString(); + } + + /** + * The same as {@link #unionTypeExpression}, but for the *Member interfaces that provide string-lookup. + * + * So given union[int, string, FortuneCookie] this returns "MyUnion.IntMember | MyUnion.StringMember | MyUnion.FortuneCookieMember" + * + */ + public String memberUnionTypeExpression() { + List members = this.members(); + + if (members.isEmpty()) { + return "void"; + } else { + StringBuilder sb = new StringBuilder(); + + + for (int i = 0; i < members.size(); i++) { + boolean isLast = (i == members.size() - 1); + TSUnionMemberSyntax member = members.get(i); + sb.append(member.fullUnionMemberTypeName()); + + if (!isLast) { + sb.append(" | "); + } + } + + return sb.toString(); + } + } + + /** Return the syntax for each member */ + public List members() { + List memberSyntax = new ArrayList<>(); + + for (UnionTemplateSpec.Member member : this._template.getMembers()) { + memberSyntax.add(new TSUnionMemberSyntax(this, _schema, member)); + } + + return memberSyntax; + } + + /** Returns true in the usual case that this isn't some stupid empty union. */ + public boolean requiresCompanionModule() { + return !this._template.getMembers().isEmpty(); + } + + private boolean _isEnclosedType() { + return _template.getEnclosingClass() != null; + } + } + + /** The TS representation of a single field in a Record */ + public class TSRecordFieldSyntax implements TSTypeSyntax { + private final RecordTemplateSpec _template; + private final RecordDataSchema _schema; + private final RecordTemplateSpec.Field _field; + + public TSRecordFieldSyntax(RecordTemplateSpec _template, RecordTemplateSpec.Field _field) { + this._template = _template; + this._schema = _template.getSchema(); + this._field = _field; + } + + @Override + public Set modulesRequiredToUse() { + Set modules = new HashSet<>(); + // since this record lives in its own file you have to import it to use it. + modules.add(importString(_schema.getNamespace(), this.typeName())); + return modules; + } + + /** The typescript property for getting this field. */ + public String accessorName() { + return escapeKeyword(_schemaField().getName(), EscapeStrategy.QUOTE); + } + + public String typeName() { + // To resolve type name we have to determine whether to use the DataSchema in _field.getType() or + // the one in _field.getSchemaField().getType(). We reach first for the schemaField as it does not swallow + // Typerefs. (e.g. if a type was defined as CustomInt, it will give us the string CustomInt, whereas + // field.getType() would dereference all the way to the bottom). + // + // The only problem with schemaField is that it _does_ swallow the type names for enclosed unions. ARGH + // can we catch a break?? Thankfully in the case of the enclosed union it ends up returning null, so + // we back off to _field.getType() if schemaField returned null. + TSTypeSyntax candidateSyntax = createTypeSyntax(_schemaField().getType()); + if (candidateSyntax.typeName() == null || "".equals(candidateSyntax)) { + candidateSyntax = createTypeSyntax(_field.getType()); + } + + return typeNameQualifiedByEnclosingClass(candidateSyntax); + } + + public String docString() { + return docComment( + _schemaField().getDoc(), + _schemaField().getProperties().get("deprecated") + ); + } + + /** The modules that the containing Record module has to import in order to compile. */ + public Set typeModules() { + return _fieldTypeSyntax().modulesRequiredToUse(); + } + + /** + * Just returns a "?" if this was an optional field either due to being decalred optional, or opting not to pass + * the STRICT directive into the generator. + **/ + public String questionMarkIfOptional() { + boolean isFieldOptional = _schemaField().getOptional(); + boolean markFieldAsOptional = isFieldOptional || TSProperties.optionality == Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; + + return markFieldAsOptional? "?": ""; + } + + // + // Private members + // + private RecordDataSchema.Field _schemaField() { + return _field.getSchemaField(); + } + private TSTypeSyntax _fieldTypeSyntax() { + return createTypeSyntax(_schemaField().getType()); + } + } + + /** TS-specific syntax for Records */ + public class TSRecordSyntax implements TSTypeSyntax { + private final RecordTemplateSpec _template; + private final RecordDataSchema _schema; + private final TSNamedTypeSyntax _namedTypeSyntax; + + public TSRecordSyntax(RecordTemplateSpec _template) { + this._template = _template; + this._schema = _template.getSchema(); + this._namedTypeSyntax = new TSNamedTypeSyntax(_schema); + } + + public String docString() { + return _namedTypeSyntax.docString(); + } + + public List fields() { + List fields = new ArrayList<>(); + + for (RecordTemplateSpec.Field fieldSpec: _template.getFields()) { + fields.add(new TSRecordFieldSyntax(_template, fieldSpec)); + } + + return fields; + } + + public Set enclosedUnions() { + Set unions = new HashSet<>(); + for (ClassTemplateSpec spec: ClassTemplateSpecs.allContainedTypes(_template)) { + if (spec instanceof UnionTemplateSpec) { + unions.add(new TSUnionSyntax((UnionTemplateSpec) spec)); + } + } + + return unions; + } + + @Override + public Set modulesRequiredToUse() { + return _namedTypeSyntax.modulesRequiredToUse(); + } + + public String typeName() { + return escapeKeyword(_schema.getName(), EscapeStrategy.MANGLE); + } + + /** + * Returns true if a companion module needs to be declared for this record's interface. This is true if the record + * has enclosing types that must be defined within the record's namespace. + **/ + public boolean requiresCompanionModule() { + return !ClassTemplateSpecs.allContainedTypes(_template).isEmpty(); + } + + /** The complete typescript import block for this record */ + public String imports() { + Set imports = new HashSet<>(); + + for (TSRecordFieldSyntax fieldSyntax: this.fields()) { + imports.addAll(fieldSyntax.typeModules()); + } + + for (TSUnionSyntax union: this.enclosedUnions()) { + for (TSUnionMemberSyntax unionMember: union.members()) { + imports.addAll(unionMember.typeModules()); + } + } + + return flattenImports(imports); + } + } + + /** TS syntax for typerefs. */ + public class TSTyperefSyntax implements TSTypeSyntax { + private final TyperefTemplateSpec _template; + private final TyperefDataSchema _dataSchema; + private final TSNamedTypeSyntax _namedTypeSyntax; + + public TSTyperefSyntax(TyperefTemplateSpec _template, TyperefDataSchema _dataSchema, TSNamedTypeSyntax _namedTypeSyntax) { + this._template = _template; + this._dataSchema = _dataSchema; + this._namedTypeSyntax = _namedTypeSyntax; + } + + public String docString() { + return _namedTypeSyntax.docString(); + } + + @Override + public Set modulesRequiredToUse() { + return _namedTypeSyntax.modulesRequiredToUse(); + } + + public String typeName() { + // Have to use _dataSchema.getName() instead of _template.getClassName() here because otherwise + // generics will return strings like Array instead of Array. Not sure why?? + return escapeKeyword(_dataSchema.getName(), EscapeStrategy.MANGLE); + } + + /** The type that this typeref refers to. */ + public String refTypeName() { + return createTypeSyntax(_refType()).typeName(); + } + + /** Import block for this typeref's module file */ + public String imports() { + // Gotta import the referenced type in order to compile this typeref's own module + Set refTypeImport = createTypeSyntax(_refType()).modulesRequiredToUse(); + return flattenImports(refTypeImport); + } + + // + // Private members + // + private ClassTemplateSpec _refType() { + return ClassTemplateSpec.createFromDataSchema(_dataSchema.getRef()); + } + } + + /** Create a new TyperefSyntax */ + public TSTyperefSyntax TSTyperefSyntaxCreate(TyperefTemplateSpec template) { + return new TSTyperefSyntax(template, template.getSchema(), new TSNamedTypeSyntax(template.getSchema())); + } + + /** TS syntax for the symbol of an enum */ + public class TSEnumSymbolSyntax { + private final EnumTemplateSpec _template; + private final EnumDataSchema _dataSchema; + private final String _symbolString; + + public TSEnumSymbolSyntax(EnumTemplateSpec _template, EnumDataSchema _dataSchema, String _symbolString) { + this._template = _template; + this._dataSchema = _dataSchema; + this._symbolString = _symbolString; + } + + /** + * Returns the quoted value that will be transmitted for this enum over the wire. + * + * Used to make a string-literal union representing the enum. + **/ + public String stringLiteralValue() { + return "\"" + _symbolString + "\""; + } + + /** + * Returns a variable name that can represent the enum value. Will be used to make something like + * const PINEAPPLE: Fruits = "PINEAPPLE"; + */ + public String moduleConstValue() { + return escapeKeyword(_symbolString, EscapeStrategy.MANGLE); + } + + public String docString() { + String symbolDoc = _dataSchema.getSymbolDocs().get(_symbolString); + DataMap deprecatedSymbols = (DataMap) _dataSchema.getProperties().get("deprecatedSymbols"); + Object symbolDeprecation = null; + + if (deprecatedSymbols != null) { + symbolDeprecation = deprecatedSymbols.get(_symbolString); + } + return docComment( + symbolDoc, + symbolDeprecation + ); + } + } + + /** TS syntax for enumerations. {@link TSEnumSymbolSyntax}. */ + public class TSEnumSyntax implements TSTypeSyntax { + private final EnumTemplateSpec _template; + private final EnumDataSchema _dataSchema; + private final TSNamedTypeSyntax _namedTypeSyntax; + + public TSEnumSyntax(EnumTemplateSpec _template) { + this._template = _template; + this._dataSchema = _template.getSchema(); + this._namedTypeSyntax = new TSNamedTypeSyntax(_dataSchema); + } + + public String typeName() { + return _namedTypeSyntax.typeName(); + } + + public String docString() { + return _namedTypeSyntax.docString(); + } + + /** + * Returns true in the usual case that we need a module with the same name as this type in which to house + * the enum's constants. + **/ + public boolean requiresCompanionModule() { + return this.symbols().size() > 0; + } + + /** + * Creates the string literal union for this enum. + * + * e.g. for Fruits { APPLE, ORANGE } it will produce the following valid typescript: + * + * "APPLE" | "ORANGE" + **/ + public String stringLiteralUnion() { + List symbols = this.symbols(); + if (symbols.size() == 0) { + return "void"; // Helps us compile if some bozo declared an empty union. + } else { + return this._interleaveSymbolStrings(" | "); + } + } + + /** + * Creates the typescript array literal for all values of this enum. + * e.g. for Fruits { APPLE, ORANGE } it will produce the following valid typescript: + * + * ["APPLE", "ORANGE"] + */ + public String arrayLiteral() { + return "[" + this._interleaveSymbolStrings(", ") + "]"; + } + + @Override + public Set modulesRequiredToUse() { + // Since this sucker is declared in its own file you've gotta import it to use it. + return _namedTypeSyntax.modulesRequiredToUse(); + } + + /** Syntax for all the values in this enum */ + public List symbols() { + List symbols = new ArrayList<>(); + for (String symbol : _dataSchema.getSymbols()) { + symbols.add(new TSEnumSymbolSyntax(_template, _dataSchema, symbol)); + } + return symbols; + } + + private String _interleaveSymbolStrings(String delimiter) { + List symbols = this.symbols(); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < symbols.size(); i++) { + TSEnumSymbolSyntax symbol = symbols.get(i); + boolean isLast = (i + 1 == symbols.size()); + sb.append(symbol.stringLiteralValue()); + + if (!isLast) { + sb.append(delimiter); + } + } + return sb.toString(); + } + } +} diff --git a/flowtype/generator/src/main/resources/runtime/CourierRuntime.ts b/flowtype/generator/src/main/resources/runtime/CourierRuntime.ts new file mode 100644 index 00000000..6272d9be --- /dev/null +++ b/flowtype/generator/src/main/resources/runtime/CourierRuntime.ts @@ -0,0 +1,20 @@ +// +// Copyright 2016 Coursera Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +export interface Map { + [key: string]: ValueT; +} + diff --git a/flowtype/generator/src/main/resources/rythm-ts/enum.txt b/flowtype/generator/src/main/resources/rythm-ts/enum.txt new file mode 100644 index 00000000..c2614c8d --- /dev/null +++ b/flowtype/generator/src/main/resources/rythm-ts/enum.txt @@ -0,0 +1,15 @@ +@args org.coursera.courier.tslite.TSSyntax.TSEnumSyntax enumeration +@import org.coursera.courier.tslite.TSSyntax.TSEnumSymbolSyntax + +@enumeration.docString() +export type @enumeration.typeName() = @enumeration.stringLiteralUnion(); +@if(enumeration.requiresCompanionModule()) { + export module @enumeration.typeName() { + @for(TSEnumSymbolSyntax symbol : enumeration.symbols()) { + @symbol.docString() + export const @symbol.moduleConstValue(): @enumeration.typeName() = @symbol.stringLiteralValue(); + } + + export const all: Array<@enumeration.typeName()> = @enumeration.arrayLiteral(); + } +} diff --git a/flowtype/generator/src/main/resources/rythm-ts/fixed.txt b/flowtype/generator/src/main/resources/rythm-ts/fixed.txt new file mode 100644 index 00000000..3a151c18 --- /dev/null +++ b/flowtype/generator/src/main/resources/rythm-ts/fixed.txt @@ -0,0 +1,4 @@ +@args org.coursera.courier.tslite.TSSyntax.TSFixedSyntax fixed + +@fixed.docString() +export type @fixed.typeName() = string; diff --git a/flowtype/generator/src/main/resources/rythm-ts/record.txt b/flowtype/generator/src/main/resources/rythm-ts/record.txt new file mode 100644 index 00000000..3a39d2a5 --- /dev/null +++ b/flowtype/generator/src/main/resources/rythm-ts/record.txt @@ -0,0 +1,21 @@ +@args org.coursera.courier.tslite.TSSyntax.TSRecordSyntax record +@import org.coursera.courier.tslite.TSSyntax.TSUnionSyntax +@import org.coursera.courier.tslite.TSSyntax.TSRecordFieldSyntax + +@record.imports() + +@record.docString() +export interface @record.typeName() { + @for(TSRecordFieldSyntax field: record.fields()) { + @field.docString() + @field.accessorName() @field.questionMarkIfOptional(): @field.typeName(); + } +} + +@if(record.requiresCompanionModule()) { + export module @record.typeName() { + @for(TSUnionSyntax union: record.enclosedUnions()) { + @union(union) + } + } +} diff --git a/flowtype/generator/src/main/resources/rythm-ts/typeref.txt b/flowtype/generator/src/main/resources/rythm-ts/typeref.txt new file mode 100644 index 00000000..4b5a2ef4 --- /dev/null +++ b/flowtype/generator/src/main/resources/rythm-ts/typeref.txt @@ -0,0 +1,6 @@ +@args org.coursera.courier.tslite.TSSyntax.TSTyperefSyntax typeref + +@typeref.imports() + +@typeref.docString() +export type @typeref.typeName() = @typeref.refTypeName(); diff --git a/flowtype/generator/src/main/resources/rythm-ts/union.txt b/flowtype/generator/src/main/resources/rythm-ts/union.txt new file mode 100644 index 00000000..31b3308b --- /dev/null +++ b/flowtype/generator/src/main/resources/rythm-ts/union.txt @@ -0,0 +1,28 @@ +@args org.coursera.courier.tslite.TSSyntax.TSUnionSyntax union +@import org.coursera.courier.tslite.TSSyntax.TSUnionSyntax +@import org.coursera.courier.tslite.TSSyntax.TSUnionMemberSyntax + +@union.imports() + +@union.docString() +export type @union.typeName() = @union.memberUnionTypeExpression(); +@if(union.requiresCompanionModule()) { + export module @union.typeName() { + export interface @union.memberBaseTypeName() { + [key: string]: @union.unionTypeExpression(); + } + + @for(TSUnionMemberSyntax member: union.members()) { + export interface @member.unionMemberTypeName() extends @union.memberBaseTypeName() { + "@member.unionMemberKey()": @member.typeName(); + } + } + export function unpack(union: @union.typeName()) { + return { + @for(TSUnionMemberSyntax member: union.members()) { + @member.unpackString(): union["@member.unionMemberKey()"] as @(member.typeName())@if(!member_isLast){,} + } + }; + } + } +} diff --git a/flowtype/testsuite/.gitignore b/flowtype/testsuite/.gitignore new file mode 100644 index 00000000..ce38a3ce --- /dev/null +++ b/flowtype/testsuite/.gitignore @@ -0,0 +1,5 @@ +node_modules +.tmp +typings +src/tslite-bindings +npm-debug.log diff --git a/flowtype/testsuite/full-build.sh b/flowtype/testsuite/full-build.sh new file mode 100755 index 00000000..c15fd89c --- /dev/null +++ b/flowtype/testsuite/full-build.sh @@ -0,0 +1,6 @@ +#!/bin/bash +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +cd $script_dir + +npm run-script full-build diff --git a/flowtype/testsuite/package.json b/flowtype/testsuite/package.json new file mode 100644 index 00000000..6ab3c5f5 --- /dev/null +++ b/flowtype/testsuite/package.json @@ -0,0 +1,28 @@ +{ + "name": "courier-typescript-lite-generator-test", + "version": "1.0.0", + "description": "Test-suite for the typescript-lite courier bindings", + "main": "src/index.js", + "scripts": { + "setup": "npm install && npm run-script typings-install", + "compile": "./node_modules/.bin/tsc", + "typings-install": "./node_modules/.bin/typings install", + "test": "npm run-script compile && ./node_modules/.bin/jasmine", + "full-build": "npm run-script setup && npm run-script test" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/coursera/courier.git" + }, + "author": "Erem Boto", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/coursera/courier/issues" + }, + "homepage": "https://github.com/coursera/courier#readme", + "dependencies": { + "jasmine": "2.4.1", + "typescript": "1.8.9", + "typings": "0.7.10" + } +} diff --git a/flowtype/testsuite/spec/support/jasmine.json b/flowtype/testsuite/spec/support/jasmine.json new file mode 100644 index 00000000..901fcf15 --- /dev/null +++ b/flowtype/testsuite/spec/support/jasmine.json @@ -0,0 +1,8 @@ +{ + "spec_dir": ".tmp/spec", + "spec_files": [ + "**/*[sS]pec.js" + ], + "stopSpecOnExpectationFailure": false, + "random": false +} diff --git a/flowtype/testsuite/src/compilation-failures/array_bad-item-type-enum-expected.ts b/flowtype/testsuite/src/compilation-failures/array_bad-item-type-enum-expected.ts new file mode 100644 index 00000000..bfb65315 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/array_bad-item-type-enum-expected.ts @@ -0,0 +1,6 @@ +import {WithRecordArray} from "./tslite-bindings/org.coursera.arrays.WithRecordArray"; + +const wra: WithRecordArray = { + "empties" : [ { }, { }, { } ], + "fruits" : [ "APPLE", "BANANA", "ORANGE", "BUZZSAW"] // oops a buzzsaw is not a fruit +}; diff --git a/flowtype/testsuite/src/compilation-failures/array_bad-item-type.ts b/flowtype/testsuite/src/compilation-failures/array_bad-item-type.ts new file mode 100644 index 00000000..d45c8fb5 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/array_bad-item-type.ts @@ -0,0 +1,12 @@ +import {WithPrimitivesArray} from "./tslite-bindings/org.coursera.arrays.WithPrimitivesArray"; + +const a: WithPrimitivesArray = { + "bytes" : [ "\u0000\u0001\u0002", + "\u0003\u0004\u0005" ], + "longs" : [ 10, 20, 30 ], + "strings" : [ "a", "b", "c" ], + "doubles" : [ 11.1, 22.2, 33.3 ], + "booleans" : [ false, true ], + "floats" : [ 1.1, 2.2, 3.3 ], + "ints" : [ "1", "2", "3" ] // oops! these should be numbers +}; diff --git a/flowtype/testsuite/src/compilation-failures/enum_bad-string.ts b/flowtype/testsuite/src/compilation-failures/enum_bad-string.ts new file mode 100644 index 00000000..a605d1f0 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/enum_bad-string.ts @@ -0,0 +1,3 @@ +import {Fruits} from "./tslite-bindings/org.coursera.enums.Fruits"; + +const a: Fruits = "BUZZSAW"; // valid objects are only APPLE, BANANA, ORANGE, PINEAPPLE. diff --git a/flowtype/testsuite/src/compilation-failures/map_bad-value-type.ts b/flowtype/testsuite/src/compilation-failures/map_bad-value-type.ts new file mode 100644 index 00000000..39703fb8 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/map_bad-value-type.ts @@ -0,0 +1,39 @@ +import {WithPrimitivesMap} from "./tslite-bindings/org.coursera.maps.WithPrimitivesMap"; + +const wpm: WithPrimitivesMap = { + "bytes" : { + "b" : "\u0003\u0004\u0005", + "c" : "\u0006\u0007\b", + "a" : "\u0000\u0001\u0002" + }, + "longs" : { + "b" : 20, + "c" : 30, + "a" : "what am I doing here?" // oops! not a number + }, + "strings" : { + "b" : "string2", + "c" : "string3", + "a" : "string1" + }, + "doubles" : { + "b" : 22.2, + "c" : 33.3, + "a" : 11.1 + }, + "booleans" : { + "b" : false, + "c" : true, + "a" : true + }, + "floats" : { + "b" : 2.2, + "c" : 3.3, + "a" : 1.1 + }, + "ints" : { + "b" : 2, + "c" : 3, + "a" : 1 + } +}; diff --git a/flowtype/testsuite/src/compilation-failures/record_wrong-field-type.ts b/flowtype/testsuite/src/compilation-failures/record_wrong-field-type.ts new file mode 100644 index 00000000..7d59088f --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/record_wrong-field-type.ts @@ -0,0 +1,6 @@ +import {Message} from "../expected-successes/tslite-bindings/org.coursera.records.Message"; + +const a: Message = { + "title": [], // should be a string + "body": {} // should be a string +} diff --git a/flowtype/testsuite/src/compilation-failures/tslite-bindings b/flowtype/testsuite/src/compilation-failures/tslite-bindings new file mode 120000 index 00000000..b9513be7 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/tslite-bindings @@ -0,0 +1 @@ +../tslite-bindings \ No newline at end of file diff --git a/flowtype/testsuite/src/compilation-failures/typeref_wrong-type.ts b/flowtype/testsuite/src/compilation-failures/typeref_wrong-type.ts new file mode 100644 index 00000000..abee8c97 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/typeref_wrong-type.ts @@ -0,0 +1,3 @@ +import {CustomInt} from "./tslite-bindings/org.coursera.customtypes.CustomInt"; + +const a: CustomInt = "oops im not an int"; diff --git a/flowtype/testsuite/src/compilation-failures/union_bad-body-content.ts b/flowtype/testsuite/src/compilation-failures/union_bad-body-content.ts new file mode 100644 index 00000000..b285e93b --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/union_bad-body-content.ts @@ -0,0 +1,8 @@ +import { Union } from "./tslite-bindings/org.coursera.typerefs.Union"; + +const a: Union = { + "org.coursera.records.Messag": { + "titl": "title", // should be "title" not "titl" + "body": "Hello, Courier." + } +}; diff --git a/flowtype/testsuite/src/compilation-failures/union_bad-lookup-string.ts b/flowtype/testsuite/src/compilation-failures/union_bad-lookup-string.ts new file mode 100644 index 00000000..36e0ece8 --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/union_bad-lookup-string.ts @@ -0,0 +1,8 @@ +import { Union } from "./tslite-bindings/org.coursera.typerefs.Union"; + +const a: Union = { + "org.coursera.records.Messag": { // should be "Message" not "Messag" + "title": "title", + "body": "Hello, Courier." + } +}; diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts new file mode 100644 index 00000000..dbcc9696 --- /dev/null +++ b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts @@ -0,0 +1,649 @@ +import { WithoutNamespace } from "../tslite-bindings/.WithoutNamespace"; +import { Map } from "../tslite-bindings/CourierRuntime"; +import { WithCustomArrayTestId } from "../tslite-bindings/org.coursera.arrays.WithCustomArrayTestId"; +import { WithCustomTypesArray } from "../tslite-bindings/org.coursera.arrays.WithCustomTypesArray"; +import { WithCustomTypesArrayUnion } from "../tslite-bindings/org.coursera.arrays.WithCustomTypesArrayUnion"; +import { WithPrimitivesArray } from "../tslite-bindings/org.coursera.arrays.WithPrimitivesArray"; +import { WithRecordArray } from "../tslite-bindings/org.coursera.arrays.WithRecordArray"; +import { BooleanId } from "../tslite-bindings/org.coursera.customtypes.BooleanId"; +import { BoxedIntId } from "../tslite-bindings/org.coursera.customtypes.BoxedIntId"; +import { ByteId } from "../tslite-bindings/org.coursera.customtypes.ByteId"; +import { CaseClassCustomIntWrapper } from "../tslite-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper"; +import { CaseClassStringIdWrapper } from "../tslite-bindings/org.coursera.customtypes.CaseClassStringIdWrapper"; +import { CharId } from "../tslite-bindings/org.coursera.customtypes.CharId"; +import { CustomArrayTestId } from "../tslite-bindings/org.coursera.customtypes.CustomArrayTestId"; +import { CustomInt } from "../tslite-bindings/org.coursera.customtypes.CustomInt"; +import { CustomIntWrapper } from "../tslite-bindings/org.coursera.customtypes.CustomIntWrapper"; +import { CustomMapTestKeyId } from "../tslite-bindings/org.coursera.customtypes.CustomMapTestKeyId"; +import { CustomMapTestValueId } from "../tslite-bindings/org.coursera.customtypes.CustomMapTestValueId"; +import { CustomRecord } from "../tslite-bindings/org.coursera.customtypes.CustomRecord"; +import { CustomRecordTestId } from "../tslite-bindings/org.coursera.customtypes.CustomRecordTestId"; +import { CustomUnionTestId } from "../tslite-bindings/org.coursera.customtypes.CustomUnionTestId"; +import { DateTime } from "../tslite-bindings/org.coursera.customtypes.DateTime"; +import { DoubleId } from "../tslite-bindings/org.coursera.customtypes.DoubleId"; +import { FloatId } from "../tslite-bindings/org.coursera.customtypes.FloatId"; +import { IntId } from "../tslite-bindings/org.coursera.customtypes.IntId"; +import { LongId } from "../tslite-bindings/org.coursera.customtypes.LongId"; +import { ShortId } from "../tslite-bindings/org.coursera.customtypes.ShortId"; +import { StringId } from "../tslite-bindings/org.coursera.customtypes.StringId"; +import { DeprecatedRecord } from "../tslite-bindings/org.coursera.deprecated.DeprecatedRecord"; +import { EmptyEnum } from "../tslite-bindings/org.coursera.enums.EmptyEnum"; +import { EnumProperties } from "../tslite-bindings/org.coursera.enums.EnumProperties"; +import { Fruits } from "../tslite-bindings/org.coursera.enums.Fruits"; +import { DefaultLiteralEscaping } from "../tslite-bindings/org.coursera.escaping.DefaultLiteralEscaping"; +import { KeywordEscaping } from "../tslite-bindings/org.coursera.escaping.KeywordEscaping"; +import { ReservedClassFieldEscaping } from "../tslite-bindings/org.coursera.escaping.ReservedClassFieldEscaping"; +import { class$ } from "../tslite-bindings/org.coursera.escaping.class"; +import { WithFixed8 } from "../tslite-bindings/org.coursera.fixed.WithFixed8"; +import { Toggle } from "../tslite-bindings/org.coursera.maps.Toggle"; +import { WithComplexTypesMap } from "../tslite-bindings/org.coursera.maps.WithComplexTypesMap"; +import { WithComplexTypesMapUnion } from "../tslite-bindings/org.coursera.maps.WithComplexTypesMapUnion"; +import { WithCustomMapTestIds } from "../tslite-bindings/org.coursera.maps.WithCustomMapTestIds"; +import { WithCustomTypesMap } from "../tslite-bindings/org.coursera.maps.WithCustomTypesMap"; +import { WithPrimitivesMap } from "../tslite-bindings/org.coursera.maps.WithPrimitivesMap"; +import { WithTypedKeyMap } from "../tslite-bindings/org.coursera.maps.WithTypedKeyMap"; +import { CourierFile } from "../tslite-bindings/org.coursera.records.CourierFile"; +import { JsonTest } from "../tslite-bindings/org.coursera.records.JsonTest"; +import { Message } from "../tslite-bindings/org.coursera.records.Message"; +import { WithAnonymousUnionArray } from "../tslite-bindings/org.coursera.arrays.WithAnonymousUnionArray"; +import { Note } from "../tslite-bindings/org.coursera.records.Note"; +import { WithDateTime } from "../tslite-bindings/org.coursera.records.WithDateTime"; +import { WithFlatTypedDefinition } from "../tslite-bindings/org.coursera.records.WithFlatTypedDefinition"; +import { WithInclude } from "../tslite-bindings/org.coursera.records.WithInclude"; +import { WithTypedDefinition } from "../tslite-bindings/org.coursera.records.WithTypedDefinition"; +import { WithUnion } from "../tslite-bindings/org.coursera.records.WithUnion"; +import { Fixed8 } from "../tslite-bindings/org.coursera.fixed.Fixed8"; +import { class$ as EscapedClassRecord} from "../tslite-bindings/org.coursera.records.class"; +import { Simple } from "../tslite-bindings/org.coursera.records.primitivestyle.Simple"; +import { WithComplexTypes } from "../tslite-bindings/org.coursera.records.primitivestyle.WithComplexTypes"; +import { WithPrimitives } from "../tslite-bindings/org.coursera.records.primitivestyle.WithPrimitives"; +import { BooleanTyperef } from "../tslite-bindings/org.coursera.records.test.BooleanTyperef"; +import { BytesTyperef } from "../tslite-bindings/org.coursera.records.test.BytesTyperef"; +import { DoubleTyperef } from "../tslite-bindings/org.coursera.records.test.DoubleTyperef"; +import { Empty } from "../tslite-bindings/org.coursera.records.test.Empty"; +import { FloatTyperef } from "../tslite-bindings/org.coursera.records.test.FloatTyperef"; +import { InlineOptionalRecord } from "../tslite-bindings/org.coursera.records.test.InlineOptionalRecord"; +import { InlineRecord } from "../tslite-bindings/org.coursera.records.test.InlineRecord"; +import { IntCustomType as TestIntCustomType } from "../tslite-bindings/org.coursera.records.test.IntCustomType"; +import { IntTyperef as TestIntTyperef } from "../tslite-bindings/org.coursera.records.test.IntTyperef"; +import { LongTyperef } from "../tslite-bindings/org.coursera.records.test.LongTyperef"; +import { Message as TestMessage } from "../tslite-bindings/org.coursera.records.test.Message"; +import { NumericDefaults } from "../tslite-bindings/org.coursera.records.test.NumericDefaults"; +import { OptionalBooleanTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalBooleanTyperef"; +import { OptionalBytesTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalBytesTyperef"; +import { OptionalDoubleTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalDoubleTyperef"; +import { OptionalFloatTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalFloatTyperef"; +import { OptionalIntCustomType } from "../tslite-bindings/org.coursera.records.test.OptionalIntCustomType"; +import { OptionalIntTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalIntTyperef"; +import { OptionalLongTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalLongTyperef"; +import { OptionalStringTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalStringTyperef"; +import { RecursivelyDefinedRecord } from "../tslite-bindings/org.coursera.records.test.RecursivelyDefinedRecord"; +import { Simple as TestSimple } from "../tslite-bindings/org.coursera.records.test.Simple"; +import { StringTyperef } from "../tslite-bindings/org.coursera.records.test.StringTyperef"; +import { With22Fields } from "../tslite-bindings/org.coursera.records.test.With22Fields"; +import { With23Fields } from "../tslite-bindings/org.coursera.records.test.With23Fields"; +import { WithCaseClassCustomType } from "../tslite-bindings/org.coursera.records.test.WithCaseClassCustomType"; +import { WithComplexTypeDefaults } from "../tslite-bindings/org.coursera.records.test.WithComplexTypeDefaults"; +import { WithComplexTyperefs } from "../tslite-bindings/org.coursera.records.test.WithComplexTyperefs"; +import { WithComplexTypes as TestWithComplexTypes } from "../tslite-bindings/org.coursera.records.test.WithComplexTypes"; +import { WithCourierFile } from "../tslite-bindings/org.coursera.records.test.WithCourierFile"; +import { WithCustomIntWrapper } from "../tslite-bindings/org.coursera.records.test.WithCustomIntWrapper"; +import { WithCustomRecord } from "../tslite-bindings/org.coursera.records.test.WithCustomRecord"; +import { WithCustomRecordTestId } from "../tslite-bindings/org.coursera.records.test.WithCustomRecordTestId"; +import { WithDateTime as TestWithDateTime } from "../tslite-bindings/org.coursera.records.test.WithDateTime"; +import { WithInclude as TestWithInclude } from "../tslite-bindings/org.coursera.records.test.WithInclude"; +import { WithInlineRecord } from "../tslite-bindings/org.coursera.records.test.WithInlineRecord"; +import { WithOmitField } from "../tslite-bindings/org.coursera.records.test.WithOmitField"; +import { WithOptionalComplexTypeDefaults } from "../tslite-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults"; +import { WithOptionalComplexTypes } from "../tslite-bindings/org.coursera.records.test.WithOptionalComplexTypes"; +import { WithOptionalComplexTypesDefaultNone } from "../tslite-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone"; +import { WithOptionalPrimitiveCustomTypes } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes"; +import { WithOptionalPrimitiveDefaultNone } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone"; +import { WithOptionalPrimitiveDefaults } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults"; +import { WithOptionalPrimitiveTyperefs } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs"; +import { WithOptionalPrimitives } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitives"; +import { WithPrimitiveCustomTypes } from "../tslite-bindings/org.coursera.records.test.WithPrimitiveCustomTypes"; +import { WithPrimitiveDefaults } from "../tslite-bindings/org.coursera.records.test.WithPrimitiveDefaults"; +import { WithPrimitiveTyperefs } from "../tslite-bindings/org.coursera.records.test.WithPrimitiveTyperefs"; +import { WithPrimitives as TestWithPrimitives } from "../tslite-bindings/org.coursera.records.test.WithPrimitives"; +import { WithUnionWithInlineRecord } from "../tslite-bindings/org.coursera.records.test.WithUnionWithInlineRecord"; +import { ArrayTyperef } from "../tslite-bindings/org.coursera.typerefs.ArrayTyperef"; +import { EnumTyperef } from "../tslite-bindings/org.coursera.typerefs.EnumTyperef"; +import { FlatTypedDefinition } from "../tslite-bindings/org.coursera.typerefs.FlatTypedDefinition"; +import { InlineRecord as InlineRecordTypeRef } from "../tslite-bindings/org.coursera.typerefs.InlineRecord"; +import { InlineRecord2 } from "../tslite-bindings/org.coursera.typerefs.InlineRecord2"; +import { IntTyperef } from "../tslite-bindings/org.coursera.typerefs.IntTyperef"; +import { MapTyperef } from "../tslite-bindings/org.coursera.typerefs.MapTyperef"; +import { RecordTyperef } from "../tslite-bindings/org.coursera.typerefs.RecordTyperef"; +import { TypedDefinition } from "../tslite-bindings/org.coursera.typerefs.TypedDefinition"; +import { Union } from "../tslite-bindings/org.coursera.typerefs.Union"; +import { UnionTyperef } from "../tslite-bindings/org.coursera.typerefs.UnionTyperef"; +import { UnionWithInlineRecord } from "../tslite-bindings/org.coursera.typerefs.UnionWithInlineRecord"; +import { IntCustomType } from "../tslite-bindings/org.coursera.unions.IntCustomType"; +import { IntTyperef as IntTyperefUnion} from "../tslite-bindings/org.coursera.unions.IntTyperef"; +import { WithComplexTypesUnion } from "../tslite-bindings/org.coursera.unions.WithComplexTypesUnion"; +import { WithCustomUnionTestId } from "../tslite-bindings/org.coursera.unions.WithCustomUnionTestId"; +import { WithEmptyUnion } from "../tslite-bindings/org.coursera.unions.WithEmptyUnion"; +import { WithPrimitiveCustomTypesUnion } from "../tslite-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion"; +import { WithPrimitiveTyperefsUnion } from "../tslite-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion"; +import { WithRecordCustomTypeUnion } from "../tslite-bindings/org.coursera.unions.WithRecordCustomTypeUnion"; +import { Fortune } from "../tslite-bindings/org.example.Fortune"; +import { FortuneCookie } from "../tslite-bindings/org.example.FortuneCookie"; +import { FortuneTelling } from "../tslite-bindings/org.example.FortuneTelling"; +import { MagicEightBall } from "../tslite-bindings/org.example.MagicEightBall"; +import { MagicEightBallAnswer } from "../tslite-bindings/org.example.MagicEightBallAnswer"; +import { TyperefExample } from "../tslite-bindings/org.example.TyperefExample"; +import { DateTime as CommonDateTime } from "../tslite-bindings/org.example.common.DateTime"; +import { Timestamp } from "../tslite-bindings/org.example.common.Timestamp"; +import { DateTime as OtherDateTime } from "../tslite-bindings/org.example.other.DateTime"; +import { record } from "../tslite-bindings/org.example.record"; +import { WithPrimitivesUnion } from "../tslite-bindings/org.coursera.unions.WithPrimitivesUnion"; +import * as ts from "typescript"; +const fs = require('fs'); + +import CustomMatcherFactories = jasmine.CustomMatcherFactories; +import CompilerOptions = ts.CompilerOptions; +import TranspileOptions = ts.TranspileOptions; +import Diagnostic = ts.Diagnostic; + +// Add a jasmine matcher that will attempt to compile a ts file and report +// any compilation errors +const toCompileMatcher: CustomMatcherFactories = { + toCompile: (util: any, customEqualityTesters: any) => { + return { + compare: (fileName: any, message:any) => { + const result: any = {}; + var compilerOptions: CompilerOptions = { + project: "/Users/eboto/code/courier/typescript-lite/testsuite/tsconfig.json", + diagnostics: true + }; + + const program = ts.createProgram( + [fileName], + compilerOptions + ); + + const errors = program.getGlobalDiagnostics() + .concat(program.getSemanticDiagnostics()) + .concat(program.getDeclarationDiagnostics()) + .concat(program.getSyntacticDiagnostics()); + const errorStr = errors.reduce((accum: any, err: Diagnostic) => { + const errFile = err.file; + const msgText = ts.flattenDiagnosticMessageText(err.messageText, "\n"); + const nextAccum = accum + `\n${errFile.path}:${errFile.pos}\n${msgText}\n`; + return nextAccum; + }, ""); + + result.pass = (errors.length == 0); + if (!result.pass) { + result.message = `Compilation expectation failed: ${message} Error was: ${errorStr}`; + } + + return result; + } + }; + } +}; + +// +// Only test the runtime behavior of Unions +// +describe("Unions", () => { + it("should compile from correct javascript and unpack", () => { + const unionOfMessage: WithUnion = { + "value": { + "org.coursera.records.Message": { + "title": "title", + "body": "Hello, Courier." + } + } + }; + const {note, message} = Union.unpack(unionOfMessage.value); + expect(note).toBeUndefined(); + expect(message).not.toBeUndefined(); + expect(message.title).toBe("title"); + expect(message.body).toBe("Hello, Courier."); + }); + + it("should access all primitive unions properly", () => { + const keyShouldNotBeUndefined = (correctUnionKey: string) => (withUnion: WithPrimitivesUnion) => { + const union = withUnion.union; + const keys = Object.keys(union); + keys.forEach((key) => { + if (key == correctUnionKey) { + expect(union[key]).not.toBeUndefined(`Expected '${key}' not to be undefined in ${JSON.stringify(union)}`) + } else { + expect(union[key]).toBeUndefined(`Expected '${key}' to be defined in ${JSON.stringify(union)}. Only '${correctUnionKey}' was supposed to be defined.`); + } + }); + }; + const expectations = [ + [wpu_int, keyShouldNotBeUndefined("int")], + [wpu_long, keyShouldNotBeUndefined("long")], + [wpu_float, keyShouldNotBeUndefined("float")], + [wpu_double, keyShouldNotBeUndefined("double")], + [wpu_bool, keyShouldNotBeUndefined("boolean")], + [wpu_string, keyShouldNotBeUndefined("string")], + [wpu_bytes, keyShouldNotBeUndefined("bytes")] + ] + + expectations.forEach((expectationData) => { + const [unionInstance, expectation] = expectationData; + (expectation as any)(unionInstance); + }); + }); +}); + +// +// Now attempt to compile our examples from src/compilation-failures. They should all fail. +// +describe("The typescript compiler", () => { + beforeEach(() => { + jasmine.addMatchers(toCompileMatcher); + }); + + const expectations = [ + ["should not allow unions with incorrect lookup keys", "union_bad-lookup-string.ts"], + ["should not allow the body of the union to be malformed", "union_bad-body-content.ts"], + ["should not allow records to have the wrong field type", "record_wrong-field-type.ts"], + ["should not allow enums with a bad string value", "enum_bad-string.ts"], + ["should not allow typerefs with the wrong root type", "typeref_wrong-type.ts"], + ["should not allow the wrong type as the item of a primitive array", "array_bad-item-type.ts"], + ["should not allow the wrong type as the item of an enum array", "array_bad-item-type-enum-expected.ts"], + ["should not allow the wrong type as the value of a map", "map_bad-value-type.ts"] + ]; + + expectations.forEach((expectationPair) => { + const [testCaseName, fileTest] = expectationPair; + it(testCaseName, () => { + expect(`src/compilation-failures/${fileTest}`).not.toCompile("It was expected to fail."); + }) + }); +}); + +describe("Enums", () => { + it("Should have successful accessors", () => { + const fruit1: Fruits = "APPLE"; + expect(fruit1).toEqual(Fruits.APPLE); + expect(fruit1 == Fruits.APPLE).toBe(true); + }); + + it("Should have nice switch/case semantics", () => { + const fruit1: Fruits = "APPLE"; + let result: string; + switch (fruit1) { + case "APPLE": + result = "It was an apple"; + break; + case "PEAR": + result = "It was a pear"; + break; + default: + result = "I don't know what it was."; + } + + expect(result).toEqual("It was an apple"); + + switch (fruit1) { + case Fruits.APPLE: + result = "It's still an apple"; + break; + default: + result = "Something else." + } + + expect(result).toEqual("It's still an apple"); + }); + + it("Should transcribe both the class-level and symbol-level documentation from the courier spec", () => { + const fruitsFile = fs.readFileSync("src/tslite-bindings/org.coursera.enums.Fruits.ts").toString(); + const typeComment = "An enum dedicated to the finest of the food groups."; + const symbolComment = "An Apple."; + + expect(fruitsFile).toContain(typeComment); + expect(fruitsFile).toContain(symbolComment); + }); + + it("Should be enumerated with the .all function", () => { + expect(Fruits.all).toEqual(["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]); + }); +}); + + +// +// Now just declare a bunch of JSON types (sourced from courier/reference-suite/src/main/json. +// +// Compilation will fail if generation failed in compatibility with these known-good json types. +// +const customint: CustomInt = 1; // typerefs should work + +const boolid: BooleanId = true; +const byteid: ByteId = "bytes just a string baby!"; +const ref_of_a_ref: CustomIntWrapper = 1; +const fortune_fortuneCookie: Fortune = { + "telling": { + "org.example.FortuneCookie": { + "message": " a message", + "certainty": 0.1, + "luckyNumbers": [1, 2, 3] + } + }, + "createdAt": "2015-01-01T00:00:00.000Z" +}; + +const fortune_magicEightBall: Fortune = { + "telling": { + "org.example.MagicEightBall": { + "question": "A question", + "answer": "IT_IS_CERTAIN" + } + }, + "createdAt": "2015-01-01T00:00:00.000Z" +}; + +const fortuneCookie: FortuneCookie = { + "message": " a message", + "certainty": 0.1, + "luckyNumbers": [1, 2, 3] +}; + +const fortuneCookie_lackingOptional: FortuneCookie = { + "message": "a message", + "luckyNumbers": [1, 2, 3] +}; + +const kw_escaping: KeywordEscaping = { + "type" : "test" +}; + +const msg: Message = { + "title": "example title", + "body": "example body" +}; + +const rcfe: ReservedClassFieldEscaping = { + "data" : "dataText", + "schema": "schemaText", + "copy": "copyText", + "clone": "cloneText" +}; + +const simple: Simple = { "message": "simple message" }; + +const withComplexTypes: TestWithComplexTypes = { + "record": { "message": "record"}, + "enum": "APPLE", + "union": { "org.coursera.records.test.Simple": { "message": "union" }}, + "array": [1, 2], + "map": { "a": 1, "b": 2}, + "complexMap": { "x": { "message": "complexMap"}}, + "custom": 100 +}; + +const wu: WithUnion = { + "value": { + "org.coursera.records.Message": { + "title": "title", + "body": "Hello, Courier." + } + } +}; + +const wctu_empty: WithComplexTypesUnion = { + "union" : { + "org.coursera.records.test.Empty" : { } + } +}; + +const wctu_enum: WithComplexTypesUnion = { + "union" : { + "org.coursera.enums.Fruits" : "APPLE" + } +}; + +const withCustomTypesArr: WithCustomTypesArray = { + "ints" : [ 1, 2, 3 ], + "arrays": [ [ { "message": "a1" } ] ], + "maps": [ { "a": { "message": "m1" } } ], + "unions": [ + { "int": 1 }, + { "string": "str" }, + { "org.coursera.records.test.Simple": { "message": "u1" }} + ], + "fixed": [ "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" ] +}; + +const wctm: WithCustomTypesMap = { + "ints" : { + "b" : 2, + "c" : 3, + "a" : 1 + } +}; + +const wctm2: WithComplexTypesMap = { + "empties" : { + "b" : { }, + "c" : { }, + "a" : { } + }, + "fruits" : { + "b" : "BANANA", + "c" : "ORANGE", + "a" : "APPLE" + }, + "arrays" : { + "a": [ {"message": "v1"}, {"message": "v2"} ] + }, + "maps": { + "o1": { + "i1": { "message": "o1i1" }, + "i2": { "message": "o1i2" } + } + }, + "unions": { + "a": { "int": 1 }, + "b": { "string": "u1" } + }, + "fixed": { + "a": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + } +}; + +const wdt: TestWithDateTime = { + "createdAt": 1420070400000 +}; + +const wp1: WithPrimitiveCustomTypes = { + "intField" : 1 +}; + +const wpu: WithPrimitiveCustomTypesUnion = { + "union" : { + "int" : 1 + } +}; + +const wp2: WithPrimitives = { + "floatField" : 3.3, + "doubleField" : 4.4, + "intField" : 1, + "bytesField" : "\u0000\u0001\u0002", + "longField" : 2, + "booleanField" : true, + "stringField" : "str" +}; + +const wpa: WithPrimitivesArray = { + "bytes" : [ "\u0000\u0001\u0002", + "\u0003\u0004\u0005" ], + "longs" : [ 10, 20, 30 ], + "strings" : [ "a", "b", "c" ], + "doubles" : [ 11.1, 22.2, 33.3 ], + "booleans" : [ false, true ], + "floats" : [ 1.1, 2.2, 3.3 ], + "ints" : [ 1, 2, 3 ] +}; + +const wpm: WithPrimitivesMap = { + "bytes" : { + "b" : "\u0003\u0004\u0005", + "c" : "\u0006\u0007\b", + "a" : "\u0000\u0001\u0002" + }, + "longs" : { + "b" : 20, + "c" : 30, + "a" : 10 + }, + "strings" : { + "b" : "string2", + "c" : "string3", + "a" : "string1" + }, + "doubles" : { + "b" : 22.2, + "c" : 33.3, + "a" : 11.1 + }, + "booleans" : { + "b" : false, + "c" : true, + "a" : true + }, + "floats" : { + "b" : 2.2, + "c" : 3.3, + "a" : 1.1 + }, + "ints" : { + "b" : 2, + "c" : 3, + "a" : 1 + } +}; + + + +const wtkm: WithTypedKeyMap = { + "ints" : { "1": "int" }, + "longs" : { "2": "long" }, + "floats" : { "3.14": "float" }, + "doubles" : { "2.71": "double" }, + "booleans" : { "true": "boolean" }, + "strings" : { "key": "string" }, + "bytes" : { "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007": "bytes" }, + "record" : { "(message~key)": "record" }, + "array" : { "List(1,2)": "array" }, + "enum" : { "APPLE": "enum" }, + "custom" : { "100": "custom" }, + "fixed" : { "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007": "fixed" } +}; + +const wra: WithRecordArray = { + "empties" : [ { }, { }, { } ], + "fruits" : [ "APPLE", "BANANA", "ORANGE" ] +}; + +const wctu_array: WithComplexTypesUnion = { + "union" : { + "array" : [ { "message": "a1" } ] // TODO(eboto): Oops! Looks like it specified this in TS like arraySimple: union["Array"]. It should have just been "array" + } +}; + +const wctu_map: WithComplexTypesUnion = { + "union" : { + "map" : { "a": { "message": "m1" } } + } +}; + + +const wpu_long: WithPrimitivesUnion = { + "union" : { + "long" : 2 + } +}; + +const wpu_bool: WithPrimitivesUnion = { + "union" : { + "boolean" : true + } +}; + +const wpu_string: WithPrimitivesUnion = { + "union" : { + "string" : "thestring" + } +}; + +const wpu_bytes: WithPrimitivesUnion = { + "union" : { + "bytes" : "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + } +}; + + +const wpu_str: WithPrimitivesUnion = { + "union" : { + "string" : "str" + } +}; + +const wpu_int: WithPrimitivesUnion = { + "union" : { + "int" : 1 + } +}; + +const wpu_float: WithPrimitivesUnion = { + "union" : { + "float" : 3.0 + } +}; + +const wpu_double: WithPrimitivesUnion = { + "union" : { + "double" : 4.0 + } +}; + + + + +/* TODO(eboto): This one fails. Why? What is a TypedDefinition? +const wtd: WithTypedDefinition = { + + "value": { + "typeName": "message", + "definition": { + "title": "title", + "body": "Hello, Courier." + } + } +}; +*/ + + +/** TODO(eboto): Uncomment after support for flat type definitions + const wftd: WithFlatTypedDefinition = { + "value": { + "typeName": "message", + "title": "title", + "body": "Hello, Courier." + } +}; + */ + +/* TODO(eboto): This is not working because org.coursera.records.mutable.Simple doesn't exist. Ask jpbetz or saeta if this is actually meant to work. + const withCustomTypesArrMutable: WithCustomTypesArray = { + "ints" : [ 1, 2, 3 ], + "arrays": [ [ { "message": "a1" } ] ], + "maps": [ { "a": { "message": "m1" } } ], + "unions": [ + { "number": 1 }, + { "string": "str" }, + { "org.coursera.records.mutable.Simple": { "message": "u1" }} + ], + "fixed": [ "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" ] + } + */ diff --git a/flowtype/testsuite/src/expected-successes/tslite-bindings b/flowtype/testsuite/src/expected-successes/tslite-bindings new file mode 120000 index 00000000..b9513be7 --- /dev/null +++ b/flowtype/testsuite/src/expected-successes/tslite-bindings @@ -0,0 +1 @@ +../tslite-bindings \ No newline at end of file diff --git a/flowtype/testsuite/src/expected-successes/typescript-compiler.d.ts b/flowtype/testsuite/src/expected-successes/typescript-compiler.d.ts new file mode 100644 index 00000000..a3a929c2 --- /dev/null +++ b/flowtype/testsuite/src/expected-successes/typescript-compiler.d.ts @@ -0,0 +1,10 @@ +declare module "typescript-compiler" { // hilariously, no typings exist for the typescript-compiler package so we have to make our own! + export function compileString(input:string, tscArgs?:any, options?:any, onError?:(diag: any) => any): string; + export function compileStrings(input:any, tscArgs?:any, options?:any, onError?:(diag: any) => any): string; +} + +declare module jasmine { + export interface Matchers { + toCompile(errMsg: string): boolean; + } +} diff --git a/flowtype/testsuite/tsconfig.json b/flowtype/testsuite/tsconfig.json new file mode 100644 index 00000000..f22fb418 --- /dev/null +++ b/flowtype/testsuite/tsconfig.json @@ -0,0 +1,45 @@ +{ + "version": "1.8.7", + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "declaration": false, + "jsx": "react", + "noImplicitAny": true, + "noImplicitReturns": true, + "suppressImplicitAnyIndexErrors": true, + "removeComments": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noEmitOnError": false, + "preserveConstEnums": true, + "inlineSources": false, + "sourceMap": false, + "outDir": "./.tmp", + "rootDir": "./src/expected-successes", + "moduleResolution": "node", + "listFiles": false + }, + "formatCodeOptions": { + "indentSize": 2, + "tabSize": 4, + "newLineCharacter": "\n", + "convertTabsToSpaces": true, + "insertSpaceAfterCommaDelimiter": true, + "insertSpaceAfterSemicolonInForStatements": true, + "insertSpaceBeforeAndAfterBinaryOperators": true, + "insertSpaceAfterKeywordsInControlFlowStatements": true, + "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, + "placeOpenBraceOnNewLineForFunctions": false, + "placeOpenBraceOnNewLineForControlBlocks": false + }, + "exclude": [ + "node_modules", + "jspm_packages", + "typings/browser", + "typings/browser.d.ts", + "src/compilation-failures", + "src/tslite-bindings" + ] +} diff --git a/flowtype/testsuite/typings.json b/flowtype/testsuite/typings.json new file mode 100644 index 00000000..373ac06c --- /dev/null +++ b/flowtype/testsuite/typings.json @@ -0,0 +1,6 @@ +{ + "ambientDependencies": { + "jasmine": "registry:dt/jasmine#2.2.0+20160317120654", + "node": "registry:dt/node#4.0.0+20160330064709" + } +} From 4400395680595486a039c255982470218128bd36 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 13:41:18 -0700 Subject: [PATCH 03/23] add flowtype dir to Build.scala --- project/Build.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/project/Build.scala b/project/Build.scala index bb180fdc..1b0dfc3d 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -172,6 +172,11 @@ object Courier extends Build with OverridablePublishSettings { .dependsOn(generatorApi) .disablePlugins(bintray.BintrayPlugin) + private[this] val flowtypeDir = file("flowtype") + lazy val flowtypeGenerator = Project(id = "flowtype-generator", base = flowtypeDir / "generator") + .dependsOn(generatorApi) + .disablePlugins(bintray.BintrayPlugin) + lazy val cli = Project(id = "courier-cli", base = file("cli")) .dependsOn( javaGenerator, @@ -237,6 +242,7 @@ object Courier extends Build with OverridablePublishSettings { s";project android-runtime;$publishCommand" + s";project swift-generator;$publishCommand" + s";project typescript-lite-generator;$publishCommand" + + s";project flowtype-generator;$publishCommand" + s";++$sbtScalaVersion;project scala-generator;$publishCommand" + s";++$currentScalaVersion;project scala-generator;$publishCommand" + s";++$sbtScalaVersion;project scala-runtime;$publishCommand" + @@ -266,6 +272,8 @@ object Courier extends Build with OverridablePublishSettings { swiftGenerator, typescriptLiteGenerator, typescriptLiteGeneratorTest, + flowtypeGenerator, + flowtypeGeneratorTest, cli) .settings(runtimeVersionSettings) .settings(packagedArtifacts := Map.empty) // disable publish for root aggregate module From 6c141a39f5b1ac68c5a58d7af78c0bcaa073119e Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 13:43:37 -0700 Subject: [PATCH 04/23] update build.sbt under flowtype/ generator and generator-test --- flowtype/generator-test/build.sbt | 10 +++++----- flowtype/generator/build.sbt | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flowtype/generator-test/build.sbt b/flowtype/generator-test/build.sbt index 9f6f429e..cbb78e5a 100644 --- a/flowtype/generator-test/build.sbt +++ b/flowtype/generator-test/build.sbt @@ -1,6 +1,6 @@ import sbt.inc.Analysis -name := "courier-typescript-lite-generator-test" +name := "courier-flowtype-generator-test" packagedArtifacts := Map.empty // do not publish @@ -14,13 +14,13 @@ crossPaths := false // Test Generator forkedVmCourierGeneratorSettings -forkedVmCourierMainClass := "org.coursera.courier.TypeScriptLiteGenerator" +forkedVmCourierMainClass := "org.coursera.courier.flowtypeGenerator" -forkedVmCourierClasspath := (dependencyClasspath in Runtime in typescriptLiteGenerator).value.files +forkedVmCourierClasspath := (dependencyClasspath in Runtime in flowtypeGenerator).value.files forkedVmSourceDirectory := (sourceDirectory in referenceSuite).value / "main" / "courier" -forkedVmCourierDest := file("typescript-lite") / "testsuite" / "src" / "tslite-bindings" +forkedVmCourierDest := file("flowtype") / "testsuite" / "src" / "flowtype-bindings" forkedVmAdditionalArgs := Seq("STRICT") @@ -35,7 +35,7 @@ lazy val npmTest = taskKey[Unit]("Executes NPM test") npmTest in Test := { (compile in Compile).value - val result = """./typescript-lite/testsuite/full-build.sh"""! + val result = """./flowtype/testsuite/full-build.sh"""! if (result != 0) { throw new RuntimeException("NPM Build Failed") diff --git a/flowtype/generator/build.sbt b/flowtype/generator/build.sbt index aa4a5926..b32abdda 100644 --- a/flowtype/generator/build.sbt +++ b/flowtype/generator/build.sbt @@ -1,6 +1,6 @@ import sbtassembly.AssemblyPlugin.defaultShellScript -name := "courier-typescript-lite-generator" +name := "courier-flowtype-generator" plainJavaProjectSettings @@ -9,7 +9,7 @@ libraryDependencies ++= Seq( ExternalDependencies.Slf4j.slf4jSimple) // Fat Jar -mainClass in assembly := Some("org.coursera.courier.TypeScriptLiteGenerator") +mainClass in assembly := Some("org.coursera.courier.flowtypeGenerator") assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript)) From b18c904d7602c66971e48e32600454a6bab8845e Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 13:47:06 -0700 Subject: [PATCH 05/23] flowtypeGeneratorTest --- project/Build.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/project/Build.scala b/project/Build.scala index 1b0dfc3d..aa872cf9 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -183,12 +183,13 @@ object Courier extends Build with OverridablePublishSettings { androidGenerator, scalaGenerator, typescriptLiteGenerator, + flowtypeGenerator, swiftGenerator ).aggregate( javaGenerator, androidGenerator, scalaGenerator, - typescriptLiteGenerator, + flowtypeGenerator, swiftGenerator ).settings( executableFile := { @@ -210,6 +211,11 @@ object Courier extends Build with OverridablePublishSettings { .dependsOn(typescriptLiteGenerator) .disablePlugins(bintray.BintrayPlugin) + lazy val flowtypeGeneratorTest = Project( + id = "flowtype-generator-test", base = flowtypeDir / "generator-test") + .dependsOn(flowtypeGenerator) + .disablePlugins(bintray.BintrayPlugin) + lazy val courierSbtPlugin = Project(id = "sbt-plugin", base = file("sbt-plugin")) .dependsOn(scalaGenerator) .disablePlugins(xerial.sbt.Sonatype) From cb4ebd0f4f993547afb0bff590770d2cff7c65ae Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 14:15:48 -0700 Subject: [PATCH 06/23] Generator error fixed, npm error now --- flowtype/generator-test/build.sbt | 2 +- flowtype/generator/build.sbt | 2 +- ...eGenerator.java => FlowtypeGenerator.java} | 10 ++-- .../{tslite-bindings => flowtype} | 0 .../flowtype-bindings/.WithoutNamespace.ts | 4 ++ .../src/flowtype-bindings/CourierRuntime.ts | 20 ++++++++ ...coursera.arrays.WithAnonymousUnionArray.ts | 48 +++++++++++++++++ ...g.coursera.arrays.WithCustomArrayTestId.ts | 6 +++ ...rg.coursera.arrays.WithCustomTypesArray.ts | 18 +++++++ ...ursera.arrays.WithCustomTypesArrayUnion.ts | 24 +++++++++ ...org.coursera.arrays.WithPrimitivesArray.ts | 16 ++++++ .../org.coursera.arrays.WithRecordArray.ts | 9 ++++ .../org.coursera.customtypes.BooleanId.ts | 1 + .../org.coursera.customtypes.BoxedIntId.ts | 1 + .../org.coursera.customtypes.ByteId.ts | 1 + ...a.customtypes.CaseClassCustomIntWrapper.ts | 3 ++ ...ra.customtypes.CaseClassStringIdWrapper.ts | 3 ++ .../org.coursera.customtypes.CharId.ts | 1 + ....coursera.customtypes.CustomArrayTestId.ts | 1 + .../org.coursera.customtypes.CustomInt.ts | 1 + ...g.coursera.customtypes.CustomIntWrapper.ts | 3 ++ ...coursera.customtypes.CustomMapTestKeyId.ts | 1 + ...ursera.customtypes.CustomMapTestValueId.ts | 1 + .../org.coursera.customtypes.CustomRecord.ts | 3 ++ ...coursera.customtypes.CustomRecordTestId.ts | 1 + ....coursera.customtypes.CustomUnionTestId.ts | 1 + .../org.coursera.customtypes.DateTime.ts | 1 + .../org.coursera.customtypes.DoubleId.ts | 1 + .../org.coursera.customtypes.FloatId.ts | 1 + .../org.coursera.customtypes.IntId.ts | 1 + .../org.coursera.customtypes.LongId.ts | 1 + .../org.coursera.customtypes.ShortId.ts | 1 + .../org.coursera.customtypes.StringId.ts | 1 + ...rg.coursera.deprecated.DeprecatedRecord.ts | 13 +++++ .../org.coursera.enums.EmptyEnum.ts | 1 + .../org.coursera.enums.EnumProperties.ts | 11 ++++ .../org.coursera.enums.Fruits.ts | 18 +++++++ ...oursera.escaping.DefaultLiteralEscaping.ts | 4 ++ .../org.coursera.escaping.KeywordEscaping.ts | 4 ++ ...era.escaping.ReservedClassFieldEscaping.ts | 10 ++++ .../org.coursera.escaping.class.ts | 2 + .../org.coursera.fixed.Fixed8.ts | 1 + .../org.coursera.fixed.WithFixed8.ts | 6 +++ .../org.coursera.maps.Toggle.ts | 9 ++++ .../org.coursera.maps.WithComplexTypesMap.ts | 21 ++++++++ ....coursera.maps.WithComplexTypesMapUnion.ts | 24 +++++++++ .../org.coursera.maps.WithCustomMapTestIds.ts | 7 +++ .../org.coursera.maps.WithCustomTypesMap.ts | 7 +++ .../org.coursera.maps.WithPrimitivesMap.ts | 18 +++++++ .../org.coursera.maps.WithTypedKeyMap.ts | 30 +++++++++++ .../org.coursera.records.CourierFile.ts | 4 ++ .../org.coursera.records.JsonTest.ts | 2 + .../org.coursera.records.Message.ts | 6 +++ .../org.coursera.records.Note.ts | 4 ++ .../org.coursera.records.WithDateTime.ts | 6 +++ ...oursera.records.WithFlatTypedDefinition.ts | 6 +++ .../org.coursera.records.WithInclude.ts | 6 +++ ...rg.coursera.records.WithTypedDefinition.ts | 6 +++ .../org.coursera.records.WithUnion.ts | 6 +++ .../org.coursera.records.class.ts | 4 ++ ....coursera.records.primitivestyle.Simple.ts | 9 ++++ ...records.primitivestyle.WithComplexTypes.ts | 16 ++++++ ...a.records.primitivestyle.WithPrimitives.ts | 16 ++++++ ...rg.coursera.records.test.BooleanTyperef.ts | 1 + .../org.coursera.records.test.BytesTyperef.ts | 1 + ...org.coursera.records.test.DoubleTyperef.ts | 1 + .../org.coursera.records.test.Empty.ts | 2 + .../org.coursera.records.test.Empty2.ts | 2 + .../org.coursera.records.test.FloatTyperef.ts | 1 + ...rsera.records.test.InlineOptionalRecord.ts | 4 ++ .../org.coursera.records.test.InlineRecord.ts | 4 ++ ...org.coursera.records.test.IntCustomType.ts | 1 + .../org.coursera.records.test.IntTyperef.ts | 1 + .../org.coursera.records.test.LongTyperef.ts | 1 + .../org.coursera.records.test.Message.ts | 6 +++ ...g.coursera.records.test.NumericDefaults.ts | 10 ++++ ...era.records.test.OptionalBooleanTyperef.ts | 1 + ...rsera.records.test.OptionalBytesTyperef.ts | 1 + ...sera.records.test.OptionalDoubleTyperef.ts | 1 + ...rsera.records.test.OptionalFloatTyperef.ts | 1 + ...sera.records.test.OptionalIntCustomType.ts | 1 + ...oursera.records.test.OptionalIntTyperef.ts | 1 + ...ursera.records.test.OptionalLongTyperef.ts | 1 + ...sera.records.test.OptionalStringTyperef.ts | 1 + ...a.records.test.RecursivelyDefinedRecord.ts | 6 +++ .../org.coursera.records.test.Simple.ts | 9 ++++ ...org.coursera.records.test.StringTyperef.ts | 1 + .../org.coursera.records.test.With22Fields.ts | 49 ++++++++++++++++++ .../org.coursera.records.test.With23Fields.ts | 51 +++++++++++++++++++ ...ra.records.test.WithCaseClassCustomType.ts | 46 +++++++++++++++++ ...ra.records.test.WithComplexTypeDefaults.ts | 44 ++++++++++++++++ ...ursera.records.test.WithComplexTyperefs.ts | 18 +++++++ ....coursera.records.test.WithComplexTypes.ts | 46 +++++++++++++++++ ...g.coursera.records.test.WithCourierFile.ts | 6 +++ ...rsera.records.test.WithCustomIntWrapper.ts | 6 +++ ....coursera.records.test.WithCustomRecord.ts | 11 ++++ ...era.records.test.WithCustomRecordTestId.ts | 6 +++ .../org.coursera.records.test.WithDateTime.ts | 6 +++ .../org.coursera.records.test.WithInclude.ts | 8 +++ ....coursera.records.test.WithInlineRecord.ts | 9 ++++ ...org.coursera.records.test.WithOmitField.ts | 12 +++++ ...ds.test.WithOptionalComplexTypeDefaults.ts | 44 ++++++++++++++++ ...a.records.test.WithOptionalComplexTypes.ts | 46 +++++++++++++++++ ...est.WithOptionalComplexTypesDefaultNone.ts | 46 +++++++++++++++++ ...s.test.WithOptionalPrimitiveCustomTypes.ts | 6 +++ ...s.test.WithOptionalPrimitiveDefaultNone.ts | 20 ++++++++ ...ords.test.WithOptionalPrimitiveDefaults.ts | 20 ++++++++ ...ords.test.WithOptionalPrimitiveTyperefs.ts | 24 +++++++++ ...era.records.test.WithOptionalPrimitives.ts | 16 ++++++ ...a.records.test.WithPrimitiveCustomTypes.ts | 6 +++ ...sera.records.test.WithPrimitiveDefaults.ts | 20 ++++++++ ...sera.records.test.WithPrimitiveTyperefs.ts | 24 +++++++++ ...rg.coursera.records.test.WithPrimitives.ts | 16 ++++++ ....records.test.WithUnionWithInlineRecord.ts | 6 +++ ...g.coursera.records.test.packaging.Empty.ts | 2 + .../org.coursera.typerefs.ArrayTyperef.ts | 3 ++ .../org.coursera.typerefs.EnumTyperef.ts | 3 ++ ...g.coursera.typerefs.FlatTypedDefinition.ts | 21 ++++++++ .../org.coursera.typerefs.InlineRecord.ts | 4 ++ .../org.coursera.typerefs.InlineRecord2.ts | 2 + .../org.coursera.typerefs.IntTyperef.ts | 1 + .../org.coursera.typerefs.MapTyperef.ts | 4 ++ .../org.coursera.typerefs.RecordTyperef.ts | 3 ++ .../org.coursera.typerefs.TypedDefinition.ts | 21 ++++++++ .../org.coursera.typerefs.Union.ts | 21 ++++++++ .../org.coursera.typerefs.UnionTyperef.ts | 18 +++++++ ...coursera.typerefs.UnionWithInlineRecord.ts | 21 ++++++++ .../org.coursera.unions.IntCustomType.ts | 1 + .../org.coursera.unions.IntTyperef.ts | 1 + ...g.coursera.unions.WithComplexTypesUnion.ts | 38 ++++++++++++++ ...g.coursera.unions.WithCustomUnionTestId.ts | 23 +++++++++ .../org.coursera.unions.WithEmptyUnion.ts | 9 ++++ ...ra.unions.WithPrimitiveCustomTypesUnion.ts | 23 +++++++++ ...rsera.unions.WithPrimitiveTyperefsUnion.ts | 23 +++++++++ ...org.coursera.unions.WithPrimitivesUnion.ts | 45 ++++++++++++++++ ...ursera.unions.WithRecordCustomTypeUnion.ts | 23 +++++++++ .../org.example.Apostrophe.ts | 4 ++ .../flowtype-bindings/org.example.Fortune.ts | 14 +++++ .../org.example.FortuneCookie.ts | 13 +++++ .../org.example.FortuneTelling.ts | 25 +++++++++ .../org.example.MagicEightBall.ts | 8 +++ .../org.example.MagicEightBallAnswer.ts | 16 ++++++ .../org.example.TyperefExample.ts | 6 +++ .../org.example.common.DateTime.ts | 4 ++ .../org.example.common.Timestamp.ts | 4 ++ .../org.example.other.DateTime.ts | 4 ++ .../flowtype-bindings/org.example.record.ts | 2 + 147 files changed, 1539 insertions(+), 7 deletions(-) rename flowtype/generator/src/main/java/org/coursera/courier/{TypeScriptLiteGenerator.java => FlowtypeGenerator.java} (93%) rename flowtype/testsuite/src/expected-successes/{tslite-bindings => flowtype} (100%) create mode 100644 flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts create mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.record.ts diff --git a/flowtype/generator-test/build.sbt b/flowtype/generator-test/build.sbt index cbb78e5a..6cb856a3 100644 --- a/flowtype/generator-test/build.sbt +++ b/flowtype/generator-test/build.sbt @@ -14,7 +14,7 @@ crossPaths := false // Test Generator forkedVmCourierGeneratorSettings -forkedVmCourierMainClass := "org.coursera.courier.flowtypeGenerator" +forkedVmCourierMainClass := "org.coursera.courier.FlowtypeGenerator" forkedVmCourierClasspath := (dependencyClasspath in Runtime in flowtypeGenerator).value.files diff --git a/flowtype/generator/build.sbt b/flowtype/generator/build.sbt index b32abdda..6266157d 100644 --- a/flowtype/generator/build.sbt +++ b/flowtype/generator/build.sbt @@ -9,7 +9,7 @@ libraryDependencies ++= Seq( ExternalDependencies.Slf4j.slf4jSimple) // Fat Jar -mainClass in assembly := Some("org.coursera.courier.flowtypeGenerator") +mainClass in assembly := Some("org.coursera.courier.FlowtypeGenerator") assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript)) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java similarity index 93% rename from flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java rename to flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 23de30c5..d0b81d87 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/TypeScriptLiteGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -43,7 +43,7 @@ /** * Courier code generator for Typescript. */ -public class TypeScriptLiteGenerator implements PegasusCodeGenerator { +public class FlowtypeGenerator implements PegasusCodeGenerator { private static final TSProperties.Optionality defaultOptionality = TSProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; @@ -80,24 +80,24 @@ public static void main(String[] args) throws Throwable { GlobalConfig globalConfig = new GlobalConfig(optionality, equatable, false); GeneratorResult result = - new DefaultGeneratorRunner().run(new TypeScriptLiteGenerator(globalConfig), options); + new DefaultGeneratorRunner().run(new FlowtypeGenerator(globalConfig), options); for (File file: result.getTargetFiles()) { System.out.println(file.getAbsolutePath()); } - InputStream runtime = TypeScriptLiteGenerator.class.getClassLoader().getResourceAsStream("runtime/CourierRuntime.ts"); + InputStream runtime = FlowtypeGenerator.class.getClassLoader().getResourceAsStream("runtime/CourierRuntime.ts"); IOUtils.copy(runtime, new FileOutputStream(new File(targetPath, "CourierRuntime.ts"))); } - public TypeScriptLiteGenerator() { + public FlowtypeGenerator() { this(new GlobalConfig( defaultOptionality, false, false)); } - public TypeScriptLiteGenerator(GlobalConfig globalConfig) { + public FlowtypeGenerator(GlobalConfig globalConfig) { this.globalConfig = globalConfig; this.engine = new RythmEngine(); this.engine.registerResourceLoader(new ClasspathResourceLoader(engine, "/")); diff --git a/flowtype/testsuite/src/expected-successes/tslite-bindings b/flowtype/testsuite/src/expected-successes/flowtype similarity index 100% rename from flowtype/testsuite/src/expected-successes/tslite-bindings rename to flowtype/testsuite/src/expected-successes/flowtype diff --git a/flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts b/flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts new file mode 100644 index 00000000..6e6ee1f9 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts @@ -0,0 +1,4 @@ +export interface WithoutNamespace { + + field1 : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts b/flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts new file mode 100644 index 00000000..6272d9be --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts @@ -0,0 +1,20 @@ +// +// Copyright 2016 Coursera Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +export interface Map { + [key: string]: ValueT; +} + diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts new file mode 100644 index 00000000..6b127146 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts @@ -0,0 +1,48 @@ +import { Map } from "./CourierRuntime"; + +export interface WithAnonymousUnionArray { + + unionsArray : Array; + + unionsMap : Map; +} +export module WithAnonymousUnionArray { + + export type UnionsArray = UnionsArray.IntMember | UnionsArray.StringMember; + export module UnionsArray { + export interface UnionsArrayMember { + [key: string]: number | string; + } + export interface IntMember extends UnionsArrayMember { + "int": number; + } + export interface StringMember extends UnionsArrayMember { + "string": string; + } + export function unpack(union: UnionsArray) { + return { + int: union["int"] as number, + string$: union["string"] as string + }; + } + } + + export type UnionsMap = UnionsMap.StringMember | UnionsMap.IntMember; + export module UnionsMap { + export interface UnionsMapMember { + [key: string]: string | number; + } + export interface StringMember extends UnionsMapMember { + "string": string; + } + export interface IntMember extends UnionsMapMember { + "int": number; + } + export function unpack(union: UnionsMap) { + return { + string$: union["string"] as string, + int: union["int"] as number + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts new file mode 100644 index 00000000..2c91db3e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts @@ -0,0 +1,6 @@ +import { CustomArrayTestId } from "./org.coursera.customtypes.CustomArrayTestId"; + +export interface WithCustomArrayTestId { + + array : Array; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts new file mode 100644 index 00000000..5d755735 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts @@ -0,0 +1,18 @@ +import { Map } from "./CourierRuntime"; +import { WithCustomTypesArrayUnion } from "./org.coursera.arrays.WithCustomTypesArrayUnion"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +import { Fixed8 } from "./org.coursera.fixed.Fixed8"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithCustomTypesArray { + + ints : Array; + + arrays : Array>; + + maps : Array>; + + unions : Array; + + fixed : Array; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts new file mode 100644 index 00000000..7b50c208 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts @@ -0,0 +1,24 @@ +import { Simple } from "./org.coursera.records.test.Simple"; + +export type WithCustomTypesArrayUnion = WithCustomTypesArrayUnion.IntMember | WithCustomTypesArrayUnion.StringMember | WithCustomTypesArrayUnion.SimpleMember; +export module WithCustomTypesArrayUnion { + export interface WithCustomTypesArrayUnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends WithCustomTypesArrayUnionMember { + "int": number; + } + export interface StringMember extends WithCustomTypesArrayUnionMember { + "string": string; + } + export interface SimpleMember extends WithCustomTypesArrayUnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: WithCustomTypesArrayUnion) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts new file mode 100644 index 00000000..621c2c60 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts @@ -0,0 +1,16 @@ +export interface WithPrimitivesArray { + + ints : Array; + + longs : Array; + + floats : Array; + + doubles : Array; + + booleans : Array; + + strings : Array; + + bytes : Array; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts new file mode 100644 index 00000000..d66573f0 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts @@ -0,0 +1,9 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Empty } from "./org.coursera.records.test.Empty"; + +export interface WithRecordArray { + + empties : Array; + + fruits : Array; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts new file mode 100644 index 00000000..680e5f2b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts @@ -0,0 +1 @@ +export type BooleanId = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts new file mode 100644 index 00000000..0deffeb2 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts @@ -0,0 +1 @@ +export type BoxedIntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts new file mode 100644 index 00000000..5d9fa3b3 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts @@ -0,0 +1 @@ +export type ByteId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts new file mode 100644 index 00000000..0674a0f3 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts @@ -0,0 +1,3 @@ +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; + +export type CaseClassCustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts new file mode 100644 index 00000000..d730ad07 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts @@ -0,0 +1,3 @@ +import { StringId } from "./org.coursera.customtypes.StringId"; + +export type CaseClassStringIdWrapper = StringId; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts new file mode 100644 index 00000000..53eebe12 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts @@ -0,0 +1 @@ +export type CharId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts new file mode 100644 index 00000000..2ebdea78 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts @@ -0,0 +1 @@ +export type CustomArrayTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts new file mode 100644 index 00000000..fdd88ddb --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts @@ -0,0 +1 @@ +export type CustomInt = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts new file mode 100644 index 00000000..0e0505e2 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts @@ -0,0 +1,3 @@ +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; + +export type CustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts new file mode 100644 index 00000000..ebefc23e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts @@ -0,0 +1 @@ +export type CustomMapTestKeyId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts new file mode 100644 index 00000000..f0d4cadf --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts @@ -0,0 +1 @@ +export type CustomMapTestValueId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts new file mode 100644 index 00000000..8bb5154d --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts @@ -0,0 +1,3 @@ +import { Message } from "./org.coursera.records.test.Message"; + +export type CustomRecord = Message; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts new file mode 100644 index 00000000..d6d08519 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts @@ -0,0 +1 @@ +export type CustomRecordTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts new file mode 100644 index 00000000..228db52a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts @@ -0,0 +1 @@ +export type CustomUnionTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts new file mode 100644 index 00000000..c0dba863 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts @@ -0,0 +1 @@ +export type DateTime = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts new file mode 100644 index 00000000..1b01067e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts @@ -0,0 +1 @@ +export type DoubleId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts new file mode 100644 index 00000000..4ff30115 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts @@ -0,0 +1 @@ +export type FloatId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts new file mode 100644 index 00000000..82278d55 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts @@ -0,0 +1 @@ +export type IntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts new file mode 100644 index 00000000..779f7749 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts @@ -0,0 +1 @@ +export type LongId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts new file mode 100644 index 00000000..89dd3aea --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts @@ -0,0 +1 @@ +export type ShortId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts new file mode 100644 index 00000000..fc90a2fd --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts @@ -0,0 +1 @@ +export type StringId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts new file mode 100644 index 00000000..cd261109 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts @@ -0,0 +1,13 @@ +/** + * @deprecated Use XYZ instead + */ +export interface DeprecatedRecord { + /** + * @deprecated + */ + field1 : string; + /** + * @deprecated Use XYZ instead + */ + field2 : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts new file mode 100644 index 00000000..bcd99717 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts @@ -0,0 +1 @@ +export type EmptyEnum = void; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts new file mode 100644 index 00000000..5387818a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts @@ -0,0 +1,11 @@ +export type EnumProperties = "APPLE" | "ORANGE" | "BANANA"; +export module EnumProperties { + + export const APPLE: EnumProperties = "APPLE"; + + export const ORANGE: EnumProperties = "ORANGE"; + + export const BANANA: EnumProperties = "BANANA"; + + export const all: Array = ["APPLE", "ORANGE", "BANANA"]; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts new file mode 100644 index 00000000..027c88db --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts @@ -0,0 +1,18 @@ +/** + * An enum dedicated to the finest of the food groups. + */ +export type Fruits = "APPLE" | "BANANA" | "ORANGE" | "PINEAPPLE"; +export module Fruits { + /** + * An Apple. + */ + export const APPLE: Fruits = "APPLE"; + + export const BANANA: Fruits = "BANANA"; + + export const ORANGE: Fruits = "ORANGE"; + + export const PINEAPPLE: Fruits = "PINEAPPLE"; + + export const all: Array = ["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts new file mode 100644 index 00000000..ed6126ad --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts @@ -0,0 +1,4 @@ +export interface DefaultLiteralEscaping { + + stringField : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts new file mode 100644 index 00000000..faeef575 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts @@ -0,0 +1,4 @@ +export interface KeywordEscaping { + + "type" : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts new file mode 100644 index 00000000..8e5b0e22 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts @@ -0,0 +1,10 @@ +export interface ReservedClassFieldEscaping { + + data : string; + + schema : string; + + copy : string; + + clone : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts new file mode 100644 index 00000000..bfe98891 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts @@ -0,0 +1,2 @@ +export interface class$ { +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts new file mode 100644 index 00000000..23cc5d82 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts @@ -0,0 +1 @@ +export type Fixed8 = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts new file mode 100644 index 00000000..b1be2b66 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts @@ -0,0 +1,6 @@ +import { Fixed8 } from "./org.coursera.fixed.Fixed8"; + +export interface WithFixed8 { + + fixed : Fixed8; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts new file mode 100644 index 00000000..d347afe2 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts @@ -0,0 +1,9 @@ +export type Toggle = "UP" | "DOWN"; +export module Toggle { + + export const UP: Toggle = "UP"; + + export const DOWN: Toggle = "DOWN"; + + export const all: Array = ["UP", "DOWN"]; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts new file mode 100644 index 00000000..83946d6c --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts @@ -0,0 +1,21 @@ +import { Map } from "./CourierRuntime"; +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Empty } from "./org.coursera.records.test.Empty"; +import { WithComplexTypesMapUnion } from "./org.coursera.maps.WithComplexTypesMapUnion"; +import { Fixed8 } from "./org.coursera.fixed.Fixed8"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithComplexTypesMap { + + empties : Map; + + fruits : Map; + + arrays : Map>; + + maps : Map>; + + unions : Map; + + fixed : Map; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts new file mode 100644 index 00000000..9e45610a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts @@ -0,0 +1,24 @@ +import { Simple } from "./org.coursera.records.test.Simple"; + +export type WithComplexTypesMapUnion = WithComplexTypesMapUnion.IntMember | WithComplexTypesMapUnion.StringMember | WithComplexTypesMapUnion.SimpleMember; +export module WithComplexTypesMapUnion { + export interface WithComplexTypesMapUnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends WithComplexTypesMapUnionMember { + "int": number; + } + export interface StringMember extends WithComplexTypesMapUnionMember { + "string": string; + } + export interface SimpleMember extends WithComplexTypesMapUnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: WithComplexTypesMapUnion) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts new file mode 100644 index 00000000..7c03e382 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts @@ -0,0 +1,7 @@ +import { Map } from "./CourierRuntime"; +import { CustomMapTestValueId } from "./org.coursera.customtypes.CustomMapTestValueId"; + +export interface WithCustomMapTestIds { + + map : Map; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts new file mode 100644 index 00000000..dae0b6f7 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts @@ -0,0 +1,7 @@ +import { Map } from "./CourierRuntime"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; + +export interface WithCustomTypesMap { + + ints : Map; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts new file mode 100644 index 00000000..2f54b79e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts @@ -0,0 +1,18 @@ +import { Map } from "./CourierRuntime"; + +export interface WithPrimitivesMap { + + ints : Map; + + longs : Map; + + floats : Map; + + doubles : Map; + + booleans : Map; + + strings : Map; + + bytes : Map; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts new file mode 100644 index 00000000..7bb42063 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts @@ -0,0 +1,30 @@ +import { Map } from "./CourierRuntime"; + +export interface WithTypedKeyMap { + + ints : Map; + + longs : Map; + + floats : Map; + + doubles : Map; + + booleans : Map; + + strings : Map; + + bytes : Map; + + record : Map; + + array : Map; + + "enum" : Map; + + custom : Map; + + fixed : Map; + + samePackageEnum ?: Map; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts new file mode 100644 index 00000000..0a4db3e6 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts @@ -0,0 +1,4 @@ +export interface CourierFile { + + find : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts new file mode 100644 index 00000000..2a9078ec --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts @@ -0,0 +1,2 @@ +export interface JsonTest { +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts new file mode 100644 index 00000000..fdfe4181 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts @@ -0,0 +1,6 @@ +export interface Message { + + title ?: string; + + body ?: string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts new file mode 100644 index 00000000..fd44e1ab --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts @@ -0,0 +1,4 @@ +export interface Note { + + text : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts new file mode 100644 index 00000000..841204d9 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts @@ -0,0 +1,6 @@ +import { DateTime } from "./org.coursera.customtypes.DateTime"; + +export interface WithDateTime { + + time : DateTime; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts new file mode 100644 index 00000000..d14f3581 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts @@ -0,0 +1,6 @@ +import { FlatTypedDefinition } from "./org.coursera.typerefs.FlatTypedDefinition"; + +export interface WithFlatTypedDefinition { + + value : FlatTypedDefinition; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts new file mode 100644 index 00000000..022dccf1 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts @@ -0,0 +1,6 @@ +export interface WithInclude { + + find : string; + + direct : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts new file mode 100644 index 00000000..441d1a3b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts @@ -0,0 +1,6 @@ +import { TypedDefinition } from "./org.coursera.typerefs.TypedDefinition"; + +export interface WithTypedDefinition { + + value : TypedDefinition; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts new file mode 100644 index 00000000..742deaaa --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts @@ -0,0 +1,6 @@ +import { Union } from "./org.coursera.typerefs.Union"; + +export interface WithUnion { + + value : Union; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts new file mode 100644 index 00000000..2541bdb1 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts @@ -0,0 +1,4 @@ +export interface class$ { + + "private" : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts new file mode 100644 index 00000000..0075d45e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts @@ -0,0 +1,9 @@ +/** + * A simple record + */ +export interface Simple { + /** + * A simple field + */ + message ?: string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts new file mode 100644 index 00000000..24411359 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts @@ -0,0 +1,16 @@ +export interface WithComplexTypes { + + intField : number; + + longField : number; + + floatField : number; + + doubleField : number; + + booleanField : boolean; + + stringField : string; + + bytesField : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts new file mode 100644 index 00000000..fbe9e99a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts @@ -0,0 +1,16 @@ +export interface WithPrimitives { + + intField : number; + + longField : number; + + floatField : number; + + doubleField : number; + + booleanField : boolean; + + stringField : string; + + bytesField : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts new file mode 100644 index 00000000..c587f330 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts @@ -0,0 +1 @@ +export type BooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts new file mode 100644 index 00000000..5a6800cc --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts @@ -0,0 +1 @@ +export type BytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts new file mode 100644 index 00000000..95a56e53 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts @@ -0,0 +1 @@ +export type DoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts new file mode 100644 index 00000000..119d4b45 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts @@ -0,0 +1,2 @@ +export interface Empty { +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts new file mode 100644 index 00000000..193f531f --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts @@ -0,0 +1,2 @@ +export interface Empty2 { +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts new file mode 100644 index 00000000..2a14e394 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts @@ -0,0 +1 @@ +export type FloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts new file mode 100644 index 00000000..ac5e5d84 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts @@ -0,0 +1,4 @@ +export interface InlineOptionalRecord { + + value : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts new file mode 100644 index 00000000..70beb996 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts @@ -0,0 +1,4 @@ +export interface InlineRecord { + + value : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts new file mode 100644 index 00000000..10d347b5 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts @@ -0,0 +1 @@ +export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts new file mode 100644 index 00000000..cc1e7a3b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts @@ -0,0 +1 @@ +export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts new file mode 100644 index 00000000..edfa2140 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts @@ -0,0 +1 @@ +export type LongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts new file mode 100644 index 00000000..19fe106e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts @@ -0,0 +1,6 @@ +export interface Message { + + title : string; + + body : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts new file mode 100644 index 00000000..e85ef03b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts @@ -0,0 +1,10 @@ +export interface NumericDefaults { + + i : number; + + l : number; + + f : number; + + d : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts new file mode 100644 index 00000000..c596cad7 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts @@ -0,0 +1 @@ +export type OptionalBooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts new file mode 100644 index 00000000..0848ba00 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts @@ -0,0 +1 @@ +export type OptionalBytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts new file mode 100644 index 00000000..c074836b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts @@ -0,0 +1 @@ +export type OptionalDoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts new file mode 100644 index 00000000..8d91a69a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts @@ -0,0 +1 @@ +export type OptionalFloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts new file mode 100644 index 00000000..64de6f02 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts @@ -0,0 +1 @@ +export type OptionalIntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts new file mode 100644 index 00000000..44f23aac --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts @@ -0,0 +1 @@ +export type OptionalIntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts new file mode 100644 index 00000000..14bfc0c2 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts @@ -0,0 +1 @@ +export type OptionalLongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts new file mode 100644 index 00000000..2ba22764 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts @@ -0,0 +1 @@ +export type OptionalStringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts new file mode 100644 index 00000000..4ed4edf7 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts @@ -0,0 +1,6 @@ +import { RecursivelyDefinedRecord } from "./org.coursera.records.test.RecursivelyDefinedRecord"; + +export interface RecursivelyDefinedRecord { + + self ?: RecursivelyDefinedRecord; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts new file mode 100644 index 00000000..0075d45e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts @@ -0,0 +1,9 @@ +/** + * A simple record + */ +export interface Simple { + /** + * A simple field + */ + message ?: string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts new file mode 100644 index 00000000..b1ce0238 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts @@ -0,0 +1 @@ +export type StringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts new file mode 100644 index 00000000..9435f46c --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts @@ -0,0 +1,49 @@ +/** + * Scala's tuple limit is 22. Here we test the limit. + */ +export interface With22Fields { + + field1 : number; + + field2 : number; + + field3 : number; + + field4 : number; + + field5 : number; + + field6 : number; + + field7 : number; + + field8 : number; + + field9 : number; + + field10 : number; + + field11 : number; + + field12 : number; + + field13 : number; + + field14 : number; + + field15 : number; + + field16 : number; + + field17 : number; + + field18 : number; + + field19 : number; + + field20 : number; + + field21 : number; + + field22 : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts new file mode 100644 index 00000000..31ba78d4 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts @@ -0,0 +1,51 @@ +/** + * Scala's tuple limit is 22. Here we test beyond that limit. + */ +export interface With23Fields { + + field1 : number; + + field2 : number; + + field3 : number; + + field4 : number; + + field5 : number; + + field6 : number; + + field7 : number; + + field8 : number; + + field9 : number; + + field10 : number; + + field11 : number; + + field12 : number; + + field13 : number; + + field14 : number; + + field15 : number; + + field16 : number; + + field17 : number; + + field18 : number; + + field19 : number; + + field20 : number; + + field21 : number; + + field22 : number; + + field23 : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts new file mode 100644 index 00000000..ba7af727 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts @@ -0,0 +1,46 @@ +import { Map } from "./CourierRuntime"; +import { StringId } from "./org.coursera.customtypes.StringId"; +import { ByteId } from "./org.coursera.customtypes.ByteId"; +import { DoubleId } from "./org.coursera.customtypes.DoubleId"; +import { CaseClassCustomIntWrapper } from "./org.coursera.customtypes.CaseClassCustomIntWrapper"; +import { BooleanId } from "./org.coursera.customtypes.BooleanId"; +import { BoxedIntId } from "./org.coursera.customtypes.BoxedIntId"; +import { ShortId } from "./org.coursera.customtypes.ShortId"; +import { IntId } from "./org.coursera.customtypes.IntId"; +import { CharId } from "./org.coursera.customtypes.CharId"; +import { LongId } from "./org.coursera.customtypes.LongId"; +import { FloatId } from "./org.coursera.customtypes.FloatId"; +import { CaseClassStringIdWrapper } from "./org.coursera.customtypes.CaseClassStringIdWrapper"; + +export interface WithCaseClassCustomType { + + short : ShortId; + + byte : ByteId; + + char : CharId; + + int : IntId; + + long : LongId; + + float : FloatId; + + double : DoubleId; + + "string" : StringId; + + "boolean" : BooleanId; + + boxedInt : BoxedIntId; + + map : Map; + + mapKeys : Map; + + array : Array; + + chained : CaseClassStringIdWrapper; + + chainedToCoercer : CaseClassCustomIntWrapper; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts new file mode 100644 index 00000000..448107a7 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts @@ -0,0 +1,44 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Map } from "./CourierRuntime"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithComplexTypeDefaults { + + record : Simple; + + "enum" : Fruits; + + union : WithComplexTypeDefaults.Union; + + array : Array; + + map : Map; + + custom : CustomInt; +} +export module WithComplexTypeDefaults { + + export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; + export module Union { + export interface UnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends UnionMember { + "int": number; + } + export interface StringMember extends UnionMember { + "string": string; + } + export interface SimpleMember extends UnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: Union) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts new file mode 100644 index 00000000..b3588fd7 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts @@ -0,0 +1,18 @@ +import { UnionTyperef } from "./org.coursera.typerefs.UnionTyperef"; +import { MapTyperef } from "./org.coursera.typerefs.MapTyperef"; +import { EnumTyperef } from "./org.coursera.typerefs.EnumTyperef"; +import { ArrayTyperef } from "./org.coursera.typerefs.ArrayTyperef"; +import { RecordTyperef } from "./org.coursera.typerefs.RecordTyperef"; + +export interface WithComplexTyperefs { + + "enum" : EnumTyperef; + + record : RecordTyperef; + + map : MapTyperef; + + array : ArrayTyperef; + + union : UnionTyperef; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts new file mode 100644 index 00000000..8bec2b5c --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts @@ -0,0 +1,46 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Map } from "./CourierRuntime"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithComplexTypes { + + record : Simple; + + "enum" : Fruits; + + union : WithComplexTypes.Union; + + array : Array; + + map : Map; + + complexMap : Map; + + custom : CustomInt; +} +export module WithComplexTypes { + + export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; + export module Union { + export interface UnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends UnionMember { + "int": number; + } + export interface StringMember extends UnionMember { + "string": string; + } + export interface SimpleMember extends UnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: Union) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts new file mode 100644 index 00000000..783236b4 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts @@ -0,0 +1,6 @@ +import { CourierFile } from "./org.coursera.records.CourierFile"; + +export interface WithCourierFile { + + courierFile : CourierFile; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts new file mode 100644 index 00000000..c90fa0a4 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts @@ -0,0 +1,6 @@ +import { CustomIntWrapper } from "./org.coursera.customtypes.CustomIntWrapper"; + +export interface WithCustomIntWrapper { + + wrapper : CustomIntWrapper; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts new file mode 100644 index 00000000..bf33730d --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts @@ -0,0 +1,11 @@ +import { Map } from "./CourierRuntime"; +import { CustomRecord } from "./org.coursera.customtypes.CustomRecord"; + +export interface WithCustomRecord { + + custom : CustomRecord; + + customArray : Array; + + customMap : Map; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts new file mode 100644 index 00000000..1899ca89 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts @@ -0,0 +1,6 @@ +import { CustomRecordTestId } from "./org.coursera.customtypes.CustomRecordTestId"; + +export interface WithCustomRecordTestId { + + id : CustomRecordTestId; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts new file mode 100644 index 00000000..5ad65357 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts @@ -0,0 +1,6 @@ +import { DateTime } from "./org.coursera.customtypes.DateTime"; + +export interface WithDateTime { + + createdAt : DateTime; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts new file mode 100644 index 00000000..799d8f30 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts @@ -0,0 +1,8 @@ +export interface WithInclude { + /** + * A simple field + */ + message ?: string; + + direct : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts new file mode 100644 index 00000000..adaf6b71 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts @@ -0,0 +1,9 @@ +import { InlineOptionalRecord } from "./org.coursera.records.test.InlineOptionalRecord"; +import { InlineRecord } from "./org.coursera.records.test.InlineRecord"; + +export interface WithInlineRecord { + + inline : InlineRecord; + + inlineOptional ?: InlineOptionalRecord; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts new file mode 100644 index 00000000..74c9cbc7 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts @@ -0,0 +1,12 @@ +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; + +export interface WithOmitField { + + keep : number; + + omit : number; + + omitCustom : CustomInt; + + keepCustom : CustomInt; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts new file mode 100644 index 00000000..6c44598f --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts @@ -0,0 +1,44 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Map } from "./CourierRuntime"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithOptionalComplexTypeDefaults { + + record ?: Simple; + + "enum" ?: Fruits; + + union ?: WithOptionalComplexTypeDefaults.Union; + + array ?: Array; + + map ?: Map; + + custom ?: CustomInt; +} +export module WithOptionalComplexTypeDefaults { + + export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; + export module Union { + export interface UnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends UnionMember { + "int": number; + } + export interface StringMember extends UnionMember { + "string": string; + } + export interface SimpleMember extends UnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: Union) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts new file mode 100644 index 00000000..54a7dd44 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts @@ -0,0 +1,46 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Map } from "./CourierRuntime"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithOptionalComplexTypes { + + record ?: Simple; + + "enum" ?: Fruits; + + union ?: WithOptionalComplexTypes.Union; + + array ?: Array; + + map ?: Map; + + complexMap ?: Map; + + custom ?: CustomInt; +} +export module WithOptionalComplexTypes { + + export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; + export module Union { + export interface UnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends UnionMember { + "int": number; + } + export interface StringMember extends UnionMember { + "string": string; + } + export interface SimpleMember extends UnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: Union) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts new file mode 100644 index 00000000..168c39fa --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts @@ -0,0 +1,46 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Map } from "./CourierRuntime"; +import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithOptionalComplexTypesDefaultNone { + + record ?: Simple; + + "enum" ?: Fruits; + + union ?: WithOptionalComplexTypesDefaultNone.Union; + + array ?: Array; + + map ?: Map; + + complexMap ?: Map; + + custom ?: CustomInt; +} +export module WithOptionalComplexTypesDefaultNone { + + export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; + export module Union { + export interface UnionMember { + [key: string]: number | string | Simple; + } + export interface IntMember extends UnionMember { + "int": number; + } + export interface StringMember extends UnionMember { + "string": string; + } + export interface SimpleMember extends UnionMember { + "org.coursera.records.test.Simple": Simple; + } + export function unpack(union: Union) { + return { + int: union["int"] as number, + string$: union["string"] as string, + simple: union["org.coursera.records.test.Simple"] as Simple + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts new file mode 100644 index 00000000..7359235d --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts @@ -0,0 +1,6 @@ +import { OptionalIntCustomType } from "./org.coursera.records.test.OptionalIntCustomType"; + +export interface WithOptionalPrimitiveCustomTypes { + + intField ?: OptionalIntCustomType; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts new file mode 100644 index 00000000..47c760f5 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts @@ -0,0 +1,20 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; + +export interface WithOptionalPrimitiveDefaultNone { + + intWithDefault ?: number; + + longWithDefault ?: number; + + floatWithDefault ?: number; + + doubleWithDefault ?: number; + + booleanWithDefault ?: boolean; + + stringWithDefault ?: string; + + bytesWithDefault ?: string; + + enumWithDefault ?: Fruits; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts new file mode 100644 index 00000000..563787b5 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts @@ -0,0 +1,20 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; + +export interface WithOptionalPrimitiveDefaults { + + intWithDefault ?: number; + + longWithDefault ?: number; + + floatWithDefault ?: number; + + doubleWithDefault ?: number; + + booleanWithDefault ?: boolean; + + stringWithDefault ?: string; + + bytesWithDefault ?: string; + + enumWithDefault ?: Fruits; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts new file mode 100644 index 00000000..79486ed9 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts @@ -0,0 +1,24 @@ +import { OptionalBooleanTyperef } from "./org.coursera.records.test.OptionalBooleanTyperef"; +import { OptionalIntTyperef } from "./org.coursera.records.test.OptionalIntTyperef"; +import { OptionalStringTyperef } from "./org.coursera.records.test.OptionalStringTyperef"; +import { OptionalFloatTyperef } from "./org.coursera.records.test.OptionalFloatTyperef"; +import { OptionalLongTyperef } from "./org.coursera.records.test.OptionalLongTyperef"; +import { OptionalDoubleTyperef } from "./org.coursera.records.test.OptionalDoubleTyperef"; +import { OptionalBytesTyperef } from "./org.coursera.records.test.OptionalBytesTyperef"; + +export interface WithOptionalPrimitiveTyperefs { + + intField ?: OptionalIntTyperef; + + longField ?: OptionalLongTyperef; + + floatField ?: OptionalFloatTyperef; + + doubleField ?: OptionalDoubleTyperef; + + booleanField ?: OptionalBooleanTyperef; + + stringField ?: OptionalStringTyperef; + + bytesField ?: OptionalBytesTyperef; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts new file mode 100644 index 00000000..edb7eb4c --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts @@ -0,0 +1,16 @@ +export interface WithOptionalPrimitives { + + intField ?: number; + + longField ?: number; + + floatField ?: number; + + doubleField ?: number; + + booleanField ?: boolean; + + stringField ?: string; + + bytesField ?: string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts new file mode 100644 index 00000000..4ad4a102 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts @@ -0,0 +1,6 @@ +import { IntCustomType } from "./org.coursera.records.test.IntCustomType"; + +export interface WithPrimitiveCustomTypes { + + intField : IntCustomType; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts new file mode 100644 index 00000000..6a134c73 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts @@ -0,0 +1,20 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; + +export interface WithPrimitiveDefaults { + + intWithDefault : number; + + longWithDefault : number; + + floatWithDefault : number; + + doubleWithDefault : number; + + booleanWithDefault : boolean; + + stringWithDefault : string; + + bytesWithDefault : string; + + enumWithDefault : Fruits; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts new file mode 100644 index 00000000..6e16266c --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts @@ -0,0 +1,24 @@ +import { BooleanTyperef } from "./org.coursera.records.test.BooleanTyperef"; +import { StringTyperef } from "./org.coursera.records.test.StringTyperef"; +import { BytesTyperef } from "./org.coursera.records.test.BytesTyperef"; +import { FloatTyperef } from "./org.coursera.records.test.FloatTyperef"; +import { DoubleTyperef } from "./org.coursera.records.test.DoubleTyperef"; +import { LongTyperef } from "./org.coursera.records.test.LongTyperef"; +import { IntTyperef } from "./org.coursera.records.test.IntTyperef"; + +export interface WithPrimitiveTyperefs { + + intField : IntTyperef; + + longField : LongTyperef; + + floatField : FloatTyperef; + + doubleField : DoubleTyperef; + + booleanField : BooleanTyperef; + + stringField : StringTyperef; + + bytesField : BytesTyperef; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts new file mode 100644 index 00000000..fbe9e99a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts @@ -0,0 +1,16 @@ +export interface WithPrimitives { + + intField : number; + + longField : number; + + floatField : number; + + doubleField : number; + + booleanField : boolean; + + stringField : string; + + bytesField : string; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts new file mode 100644 index 00000000..a13d662f --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts @@ -0,0 +1,6 @@ +import { UnionWithInlineRecord } from "./org.coursera.typerefs.UnionWithInlineRecord"; + +export interface WithUnionWithInlineRecord { + + value : UnionWithInlineRecord; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts new file mode 100644 index 00000000..119d4b45 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts @@ -0,0 +1,2 @@ +export interface Empty { +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts new file mode 100644 index 00000000..3d64fba3 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts @@ -0,0 +1,3 @@ +import { Empty } from "./org.coursera.records.test.Empty"; + +export type ArrayTyperef = Array; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts new file mode 100644 index 00000000..a2c76b72 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts @@ -0,0 +1,3 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; + +export type EnumTyperef = Fruits; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts new file mode 100644 index 00000000..d84d84cc --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts @@ -0,0 +1,21 @@ +import { Note } from "./org.coursera.records.Note"; +import { Message } from "./org.coursera.records.Message"; + +export type FlatTypedDefinition = FlatTypedDefinition.NoteMember | FlatTypedDefinition.MessageMember; +export module FlatTypedDefinition { + export interface FlatTypedDefinitionMember { + [key: string]: Note | Message; + } + export interface NoteMember extends FlatTypedDefinitionMember { + "org.coursera.records.Note": Note; + } + export interface MessageMember extends FlatTypedDefinitionMember { + "org.coursera.records.Message": Message; + } + export function unpack(union: FlatTypedDefinition) { + return { + note: union["org.coursera.records.Note"] as Note, + message: union["org.coursera.records.Message"] as Message + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts new file mode 100644 index 00000000..80869ea9 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts @@ -0,0 +1,4 @@ +export interface InlineRecord { + + value ?: number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts new file mode 100644 index 00000000..c913a1ee --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts @@ -0,0 +1,2 @@ +export interface InlineRecord2 { +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts new file mode 100644 index 00000000..cc1e7a3b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts @@ -0,0 +1 @@ +export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts new file mode 100644 index 00000000..f0dc7fee --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts @@ -0,0 +1,4 @@ +import { Map } from "./CourierRuntime"; +import { Empty } from "./org.coursera.records.test.Empty"; + +export type MapTyperef = Map; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts new file mode 100644 index 00000000..c1465964 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts @@ -0,0 +1,3 @@ +import { Empty } from "./org.coursera.records.test.Empty"; + +export type RecordTyperef = Empty; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts new file mode 100644 index 00000000..b46499e5 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts @@ -0,0 +1,21 @@ +import { Note } from "./org.coursera.records.Note"; +import { Message } from "./org.coursera.records.Message"; + +export type TypedDefinition = TypedDefinition.NoteMember | TypedDefinition.MessageMember; +export module TypedDefinition { + export interface TypedDefinitionMember { + [key: string]: Note | Message; + } + export interface NoteMember extends TypedDefinitionMember { + "org.coursera.records.Note": Note; + } + export interface MessageMember extends TypedDefinitionMember { + "org.coursera.records.Message": Message; + } + export function unpack(union: TypedDefinition) { + return { + note: union["org.coursera.records.Note"] as Note, + message: union["org.coursera.records.Message"] as Message + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts new file mode 100644 index 00000000..5d917420 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts @@ -0,0 +1,21 @@ +import { Note } from "./org.coursera.records.Note"; +import { Message } from "./org.coursera.records.Message"; + +export type Union = Union.NoteMember | Union.MessageMember; +export module Union { + export interface UnionMember { + [key: string]: Note | Message; + } + export interface NoteMember extends UnionMember { + "org.coursera.records.Note": Note; + } + export interface MessageMember extends UnionMember { + "org.coursera.records.Message": Message; + } + export function unpack(union: Union) { + return { + note: union["org.coursera.records.Note"] as Note, + message: union["org.coursera.records.Message"] as Message + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts new file mode 100644 index 00000000..2197e6aa --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts @@ -0,0 +1,18 @@ +export type UnionTyperef = UnionTyperef.StringMember | UnionTyperef.IntMember; +export module UnionTyperef { + export interface UnionTyperefMember { + [key: string]: string | number; + } + export interface StringMember extends UnionTyperefMember { + "string": string; + } + export interface IntMember extends UnionTyperefMember { + "int": number; + } + export function unpack(union: UnionTyperef) { + return { + string$: union["string"] as string, + int: union["int"] as number + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts new file mode 100644 index 00000000..73024166 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts @@ -0,0 +1,21 @@ +import { InlineRecord2 } from "./org.coursera.typerefs.InlineRecord2"; +import { InlineRecord } from "./org.coursera.typerefs.InlineRecord"; + +export type UnionWithInlineRecord = UnionWithInlineRecord.InlineRecordMember | UnionWithInlineRecord.InlineRecord2Member; +export module UnionWithInlineRecord { + export interface UnionWithInlineRecordMember { + [key: string]: InlineRecord | InlineRecord2; + } + export interface InlineRecordMember extends UnionWithInlineRecordMember { + "org.coursera.typerefs.InlineRecord": InlineRecord; + } + export interface InlineRecord2Member extends UnionWithInlineRecordMember { + "org.coursera.typerefs.InlineRecord2": InlineRecord2; + } + export function unpack(union: UnionWithInlineRecord) { + return { + inlineRecord: union["org.coursera.typerefs.InlineRecord"] as InlineRecord, + inlineRecord2: union["org.coursera.typerefs.InlineRecord2"] as InlineRecord2 + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts new file mode 100644 index 00000000..10d347b5 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts @@ -0,0 +1 @@ +export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts new file mode 100644 index 00000000..cc1e7a3b --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts @@ -0,0 +1 @@ +export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts new file mode 100644 index 00000000..c5d26034 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts @@ -0,0 +1,38 @@ +import { Fruits } from "./org.coursera.enums.Fruits"; +import { Map } from "./CourierRuntime"; +import { Empty } from "./org.coursera.records.test.Empty"; +import { Simple } from "./org.coursera.records.test.Simple"; + +export interface WithComplexTypesUnion { + + union : WithComplexTypesUnion.Union; +} +export module WithComplexTypesUnion { + + export type Union = Union.EmptyMember | Union.FruitsMember | Union.ArrayMember | Union.MapMember; + export module Union { + export interface UnionMember { + [key: string]: Empty | Fruits | Array | Map; + } + export interface EmptyMember extends UnionMember { + "org.coursera.records.test.Empty": Empty; + } + export interface FruitsMember extends UnionMember { + "org.coursera.enums.Fruits": Fruits; + } + export interface ArrayMember extends UnionMember { + "array": Array; + } + export interface MapMember extends UnionMember { + "map": Map; + } + export function unpack(union: Union) { + return { + empty: union["org.coursera.records.test.Empty"] as Empty, + fruits: union["org.coursera.enums.Fruits"] as Fruits, + arraySimple: union["array"] as Array, + mapSimple: union["map"] as Map + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts new file mode 100644 index 00000000..fd3989fd --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts @@ -0,0 +1,23 @@ +import { CustomUnionTestId } from "./org.coursera.customtypes.CustomUnionTestId"; + +export interface WithCustomUnionTestId { + + union : WithCustomUnionTestId.Union; +} +export module WithCustomUnionTestId { + + export type Union = Union.CustomUnionTestIdMember; + export module Union { + export interface UnionMember { + [key: string]: CustomUnionTestId; + } + export interface CustomUnionTestIdMember extends UnionMember { + "int": CustomUnionTestId; + } + export function unpack(union: Union) { + return { + customUnionTestId: union["int"] as CustomUnionTestId + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts new file mode 100644 index 00000000..2910c2e9 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts @@ -0,0 +1,9 @@ +export interface WithEmptyUnion { + + union : WithEmptyUnion.Union; +} +export module WithEmptyUnion { + + export type Union = void; + +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts new file mode 100644 index 00000000..90e3596e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts @@ -0,0 +1,23 @@ +import { IntCustomType } from "./org.coursera.unions.IntCustomType"; + +export interface WithPrimitiveCustomTypesUnion { + + union : WithPrimitiveCustomTypesUnion.Union; +} +export module WithPrimitiveCustomTypesUnion { + + export type Union = Union.IntCustomTypeMember; + export module Union { + export interface UnionMember { + [key: string]: IntCustomType; + } + export interface IntCustomTypeMember extends UnionMember { + "int": IntCustomType; + } + export function unpack(union: Union) { + return { + intCustomType: union["int"] as IntCustomType + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts new file mode 100644 index 00000000..0071cd4a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts @@ -0,0 +1,23 @@ +import { IntTyperef } from "./org.coursera.unions.IntTyperef"; + +export interface WithPrimitiveTyperefsUnion { + + union : WithPrimitiveTyperefsUnion.Union; +} +export module WithPrimitiveTyperefsUnion { + + export type Union = Union.IntTyperefMember; + export module Union { + export interface UnionMember { + [key: string]: IntTyperef; + } + export interface IntTyperefMember extends UnionMember { + "int": IntTyperef; + } + export function unpack(union: Union) { + return { + intTyperef: union["int"] as IntTyperef + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts new file mode 100644 index 00000000..bdf514cd --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts @@ -0,0 +1,45 @@ +export interface WithPrimitivesUnion { + + union : WithPrimitivesUnion.Union; +} +export module WithPrimitivesUnion { + + export type Union = Union.IntMember | Union.LongMember | Union.FloatMember | Union.DoubleMember | Union.BooleanMember | Union.StringMember | Union.BytesMember; + export module Union { + export interface UnionMember { + [key: string]: number | number | number | number | boolean | string | string; + } + export interface IntMember extends UnionMember { + "int": number; + } + export interface LongMember extends UnionMember { + "long": number; + } + export interface FloatMember extends UnionMember { + "float": number; + } + export interface DoubleMember extends UnionMember { + "double": number; + } + export interface BooleanMember extends UnionMember { + "boolean": boolean; + } + export interface StringMember extends UnionMember { + "string": string; + } + export interface BytesMember extends UnionMember { + "bytes": string; + } + export function unpack(union: Union) { + return { + int: union["int"] as number, + long: union["long"] as number, + float: union["float"] as number, + double: union["double"] as number, + boolean$: union["boolean"] as boolean, + string$: union["string"] as string, + bytes: union["bytes"] as string + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts new file mode 100644 index 00000000..eefbe627 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts @@ -0,0 +1,23 @@ +import { CustomRecord } from "./org.coursera.customtypes.CustomRecord"; + +export interface WithRecordCustomTypeUnion { + + union : WithRecordCustomTypeUnion.Union; +} +export module WithRecordCustomTypeUnion { + + export type Union = Union.CustomRecordMember; + export module Union { + export interface UnionMember { + [key: string]: CustomRecord; + } + export interface CustomRecordMember extends UnionMember { + "org.coursera.records.test.Message": CustomRecord; + } + export function unpack(union: Union) { + return { + customRecord: union["org.coursera.records.test.Message"] as CustomRecord + }; + } + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts new file mode 100644 index 00000000..ca379e0d --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts @@ -0,0 +1,4 @@ +export interface Apostrophe { + + field : number; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts new file mode 100644 index 00000000..b6a75ce3 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts @@ -0,0 +1,14 @@ +import { FortuneTelling } from "./org.example.FortuneTelling"; +import { DateTime } from "./org.example.common.DateTime"; + +/** + * A fortune. + */ +export interface Fortune { + /** + * The fortune telling. + */ + telling : FortuneTelling; + + createdAt : DateTime; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts new file mode 100644 index 00000000..9985e1e2 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts @@ -0,0 +1,13 @@ +/** + * A fortune cookie. + */ +export interface FortuneCookie { + /** + * A fortune cookie message. + */ + message : string; + + certainty ?: number; + + luckyNumbers : Array; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts new file mode 100644 index 00000000..46fc81af --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts @@ -0,0 +1,25 @@ +import { MagicEightBall } from "./org.example.MagicEightBall"; +import { FortuneCookie } from "./org.example.FortuneCookie"; + +export type FortuneTelling = FortuneTelling.FortuneCookieMember | FortuneTelling.MagicEightBallMember | FortuneTelling.StringMember; +export module FortuneTelling { + export interface FortuneTellingMember { + [key: string]: FortuneCookie | MagicEightBall | string; + } + export interface FortuneCookieMember extends FortuneTellingMember { + "org.example.FortuneCookie": FortuneCookie; + } + export interface MagicEightBallMember extends FortuneTellingMember { + "org.example.MagicEightBall": MagicEightBall; + } + export interface StringMember extends FortuneTellingMember { + "string": string; + } + export function unpack(union: FortuneTelling) { + return { + fortuneCookie: union["org.example.FortuneCookie"] as FortuneCookie, + magicEightBall: union["org.example.MagicEightBall"] as MagicEightBall, + string$: union["string"] as string + }; + } +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts new file mode 100644 index 00000000..93787935 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts @@ -0,0 +1,8 @@ +import { MagicEightBallAnswer } from "./org.example.MagicEightBallAnswer"; + +export interface MagicEightBall { + + question : string; + + answer : MagicEightBallAnswer; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts new file mode 100644 index 00000000..1e02b93a --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts @@ -0,0 +1,16 @@ +/** + * Magic eight ball answers. + */ +export type MagicEightBallAnswer = "IT_IS_CERTAIN" | "ASK_AGAIN_LATER" | "OUTLOOK_NOT_SO_GOOD"; +export module MagicEightBallAnswer { + + export const IT_IS_CERTAIN: MagicEightBallAnswer = "IT_IS_CERTAIN"; + /** + * Where later is at least 10 ms from now. + */ + export const ASK_AGAIN_LATER: MagicEightBallAnswer = "ASK_AGAIN_LATER"; + + export const OUTLOOK_NOT_SO_GOOD: MagicEightBallAnswer = "OUTLOOK_NOT_SO_GOOD"; + + export const all: Array = ["IT_IS_CERTAIN", "ASK_AGAIN_LATER", "OUTLOOK_NOT_SO_GOOD"]; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts new file mode 100644 index 00000000..7cf1cd95 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts @@ -0,0 +1,6 @@ +import { Timestamp } from "./org.example.common.Timestamp"; + +export interface TyperefExample { + + time : Timestamp; +} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts new file mode 100644 index 00000000..a2ae7352 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts @@ -0,0 +1,4 @@ +/** + * ISO 8601 date-time. + */ +export type DateTime = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts new file mode 100644 index 00000000..99fd474e --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts @@ -0,0 +1,4 @@ +/** + * A unix timestamp. + */ +export type Timestamp = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts new file mode 100644 index 00000000..a2ae7352 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts @@ -0,0 +1,4 @@ +/** + * ISO 8601 date-time. + */ +export type DateTime = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.record.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.record.ts new file mode 100644 index 00000000..167b3f52 --- /dev/null +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.record.ts @@ -0,0 +1,2 @@ +export interface record { +} From 95720a60e5b50162c71e1d786652aecec831ee6d Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 14:36:02 -0700 Subject: [PATCH 07/23] flowtypes project setup --- flowtype/testsuite/.gitignore | 1 + .../compilation-failures/flowtype-bindings | 1 + .../src/compilation-failures/tslite-bindings | 1 - .../testsuite/src/expected-successes/flowtype | 1 - .../src/expected-successes/flowtype-bindings | 1 + .../expected-successes/spec/bindings.spec.ts | 282 +++++++++--------- flowtype/testsuite/tsconfig.json | 2 +- 7 files changed, 145 insertions(+), 144 deletions(-) create mode 120000 flowtype/testsuite/src/compilation-failures/flowtype-bindings delete mode 120000 flowtype/testsuite/src/compilation-failures/tslite-bindings delete mode 120000 flowtype/testsuite/src/expected-successes/flowtype create mode 120000 flowtype/testsuite/src/expected-successes/flowtype-bindings diff --git a/flowtype/testsuite/.gitignore b/flowtype/testsuite/.gitignore index ce38a3ce..0b65a6bf 100644 --- a/flowtype/testsuite/.gitignore +++ b/flowtype/testsuite/.gitignore @@ -2,4 +2,5 @@ node_modules .tmp typings src/tslite-bindings +src/flowtype-bindings npm-debug.log diff --git a/flowtype/testsuite/src/compilation-failures/flowtype-bindings b/flowtype/testsuite/src/compilation-failures/flowtype-bindings new file mode 120000 index 00000000..334e6edf --- /dev/null +++ b/flowtype/testsuite/src/compilation-failures/flowtype-bindings @@ -0,0 +1 @@ +../flowtype-bindings/ \ No newline at end of file diff --git a/flowtype/testsuite/src/compilation-failures/tslite-bindings b/flowtype/testsuite/src/compilation-failures/tslite-bindings deleted file mode 120000 index b9513be7..00000000 --- a/flowtype/testsuite/src/compilation-failures/tslite-bindings +++ /dev/null @@ -1 +0,0 @@ -../tslite-bindings \ No newline at end of file diff --git a/flowtype/testsuite/src/expected-successes/flowtype b/flowtype/testsuite/src/expected-successes/flowtype deleted file mode 120000 index b9513be7..00000000 --- a/flowtype/testsuite/src/expected-successes/flowtype +++ /dev/null @@ -1 +0,0 @@ -../tslite-bindings \ No newline at end of file diff --git a/flowtype/testsuite/src/expected-successes/flowtype-bindings b/flowtype/testsuite/src/expected-successes/flowtype-bindings new file mode 120000 index 00000000..334e6edf --- /dev/null +++ b/flowtype/testsuite/src/expected-successes/flowtype-bindings @@ -0,0 +1 @@ +../flowtype-bindings/ \ No newline at end of file diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts index dbcc9696..7368be76 100644 --- a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts +++ b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts @@ -1,143 +1,143 @@ -import { WithoutNamespace } from "../tslite-bindings/.WithoutNamespace"; -import { Map } from "../tslite-bindings/CourierRuntime"; -import { WithCustomArrayTestId } from "../tslite-bindings/org.coursera.arrays.WithCustomArrayTestId"; -import { WithCustomTypesArray } from "../tslite-bindings/org.coursera.arrays.WithCustomTypesArray"; -import { WithCustomTypesArrayUnion } from "../tslite-bindings/org.coursera.arrays.WithCustomTypesArrayUnion"; -import { WithPrimitivesArray } from "../tslite-bindings/org.coursera.arrays.WithPrimitivesArray"; -import { WithRecordArray } from "../tslite-bindings/org.coursera.arrays.WithRecordArray"; -import { BooleanId } from "../tslite-bindings/org.coursera.customtypes.BooleanId"; -import { BoxedIntId } from "../tslite-bindings/org.coursera.customtypes.BoxedIntId"; -import { ByteId } from "../tslite-bindings/org.coursera.customtypes.ByteId"; -import { CaseClassCustomIntWrapper } from "../tslite-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper"; -import { CaseClassStringIdWrapper } from "../tslite-bindings/org.coursera.customtypes.CaseClassStringIdWrapper"; -import { CharId } from "../tslite-bindings/org.coursera.customtypes.CharId"; -import { CustomArrayTestId } from "../tslite-bindings/org.coursera.customtypes.CustomArrayTestId"; -import { CustomInt } from "../tslite-bindings/org.coursera.customtypes.CustomInt"; -import { CustomIntWrapper } from "../tslite-bindings/org.coursera.customtypes.CustomIntWrapper"; -import { CustomMapTestKeyId } from "../tslite-bindings/org.coursera.customtypes.CustomMapTestKeyId"; -import { CustomMapTestValueId } from "../tslite-bindings/org.coursera.customtypes.CustomMapTestValueId"; -import { CustomRecord } from "../tslite-bindings/org.coursera.customtypes.CustomRecord"; -import { CustomRecordTestId } from "../tslite-bindings/org.coursera.customtypes.CustomRecordTestId"; -import { CustomUnionTestId } from "../tslite-bindings/org.coursera.customtypes.CustomUnionTestId"; -import { DateTime } from "../tslite-bindings/org.coursera.customtypes.DateTime"; -import { DoubleId } from "../tslite-bindings/org.coursera.customtypes.DoubleId"; -import { FloatId } from "../tslite-bindings/org.coursera.customtypes.FloatId"; -import { IntId } from "../tslite-bindings/org.coursera.customtypes.IntId"; -import { LongId } from "../tslite-bindings/org.coursera.customtypes.LongId"; -import { ShortId } from "../tslite-bindings/org.coursera.customtypes.ShortId"; -import { StringId } from "../tslite-bindings/org.coursera.customtypes.StringId"; -import { DeprecatedRecord } from "../tslite-bindings/org.coursera.deprecated.DeprecatedRecord"; -import { EmptyEnum } from "../tslite-bindings/org.coursera.enums.EmptyEnum"; -import { EnumProperties } from "../tslite-bindings/org.coursera.enums.EnumProperties"; -import { Fruits } from "../tslite-bindings/org.coursera.enums.Fruits"; -import { DefaultLiteralEscaping } from "../tslite-bindings/org.coursera.escaping.DefaultLiteralEscaping"; -import { KeywordEscaping } from "../tslite-bindings/org.coursera.escaping.KeywordEscaping"; -import { ReservedClassFieldEscaping } from "../tslite-bindings/org.coursera.escaping.ReservedClassFieldEscaping"; -import { class$ } from "../tslite-bindings/org.coursera.escaping.class"; -import { WithFixed8 } from "../tslite-bindings/org.coursera.fixed.WithFixed8"; -import { Toggle } from "../tslite-bindings/org.coursera.maps.Toggle"; -import { WithComplexTypesMap } from "../tslite-bindings/org.coursera.maps.WithComplexTypesMap"; -import { WithComplexTypesMapUnion } from "../tslite-bindings/org.coursera.maps.WithComplexTypesMapUnion"; -import { WithCustomMapTestIds } from "../tslite-bindings/org.coursera.maps.WithCustomMapTestIds"; -import { WithCustomTypesMap } from "../tslite-bindings/org.coursera.maps.WithCustomTypesMap"; -import { WithPrimitivesMap } from "../tslite-bindings/org.coursera.maps.WithPrimitivesMap"; -import { WithTypedKeyMap } from "../tslite-bindings/org.coursera.maps.WithTypedKeyMap"; -import { CourierFile } from "../tslite-bindings/org.coursera.records.CourierFile"; -import { JsonTest } from "../tslite-bindings/org.coursera.records.JsonTest"; -import { Message } from "../tslite-bindings/org.coursera.records.Message"; -import { WithAnonymousUnionArray } from "../tslite-bindings/org.coursera.arrays.WithAnonymousUnionArray"; -import { Note } from "../tslite-bindings/org.coursera.records.Note"; -import { WithDateTime } from "../tslite-bindings/org.coursera.records.WithDateTime"; -import { WithFlatTypedDefinition } from "../tslite-bindings/org.coursera.records.WithFlatTypedDefinition"; -import { WithInclude } from "../tslite-bindings/org.coursera.records.WithInclude"; -import { WithTypedDefinition } from "../tslite-bindings/org.coursera.records.WithTypedDefinition"; -import { WithUnion } from "../tslite-bindings/org.coursera.records.WithUnion"; -import { Fixed8 } from "../tslite-bindings/org.coursera.fixed.Fixed8"; -import { class$ as EscapedClassRecord} from "../tslite-bindings/org.coursera.records.class"; -import { Simple } from "../tslite-bindings/org.coursera.records.primitivestyle.Simple"; -import { WithComplexTypes } from "../tslite-bindings/org.coursera.records.primitivestyle.WithComplexTypes"; -import { WithPrimitives } from "../tslite-bindings/org.coursera.records.primitivestyle.WithPrimitives"; -import { BooleanTyperef } from "../tslite-bindings/org.coursera.records.test.BooleanTyperef"; -import { BytesTyperef } from "../tslite-bindings/org.coursera.records.test.BytesTyperef"; -import { DoubleTyperef } from "../tslite-bindings/org.coursera.records.test.DoubleTyperef"; -import { Empty } from "../tslite-bindings/org.coursera.records.test.Empty"; -import { FloatTyperef } from "../tslite-bindings/org.coursera.records.test.FloatTyperef"; -import { InlineOptionalRecord } from "../tslite-bindings/org.coursera.records.test.InlineOptionalRecord"; -import { InlineRecord } from "../tslite-bindings/org.coursera.records.test.InlineRecord"; -import { IntCustomType as TestIntCustomType } from "../tslite-bindings/org.coursera.records.test.IntCustomType"; -import { IntTyperef as TestIntTyperef } from "../tslite-bindings/org.coursera.records.test.IntTyperef"; -import { LongTyperef } from "../tslite-bindings/org.coursera.records.test.LongTyperef"; -import { Message as TestMessage } from "../tslite-bindings/org.coursera.records.test.Message"; -import { NumericDefaults } from "../tslite-bindings/org.coursera.records.test.NumericDefaults"; -import { OptionalBooleanTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalBooleanTyperef"; -import { OptionalBytesTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalBytesTyperef"; -import { OptionalDoubleTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalDoubleTyperef"; -import { OptionalFloatTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalFloatTyperef"; -import { OptionalIntCustomType } from "../tslite-bindings/org.coursera.records.test.OptionalIntCustomType"; -import { OptionalIntTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalIntTyperef"; -import { OptionalLongTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalLongTyperef"; -import { OptionalStringTyperef } from "../tslite-bindings/org.coursera.records.test.OptionalStringTyperef"; -import { RecursivelyDefinedRecord } from "../tslite-bindings/org.coursera.records.test.RecursivelyDefinedRecord"; -import { Simple as TestSimple } from "../tslite-bindings/org.coursera.records.test.Simple"; -import { StringTyperef } from "../tslite-bindings/org.coursera.records.test.StringTyperef"; -import { With22Fields } from "../tslite-bindings/org.coursera.records.test.With22Fields"; -import { With23Fields } from "../tslite-bindings/org.coursera.records.test.With23Fields"; -import { WithCaseClassCustomType } from "../tslite-bindings/org.coursera.records.test.WithCaseClassCustomType"; -import { WithComplexTypeDefaults } from "../tslite-bindings/org.coursera.records.test.WithComplexTypeDefaults"; -import { WithComplexTyperefs } from "../tslite-bindings/org.coursera.records.test.WithComplexTyperefs"; -import { WithComplexTypes as TestWithComplexTypes } from "../tslite-bindings/org.coursera.records.test.WithComplexTypes"; -import { WithCourierFile } from "../tslite-bindings/org.coursera.records.test.WithCourierFile"; -import { WithCustomIntWrapper } from "../tslite-bindings/org.coursera.records.test.WithCustomIntWrapper"; -import { WithCustomRecord } from "../tslite-bindings/org.coursera.records.test.WithCustomRecord"; -import { WithCustomRecordTestId } from "../tslite-bindings/org.coursera.records.test.WithCustomRecordTestId"; -import { WithDateTime as TestWithDateTime } from "../tslite-bindings/org.coursera.records.test.WithDateTime"; -import { WithInclude as TestWithInclude } from "../tslite-bindings/org.coursera.records.test.WithInclude"; -import { WithInlineRecord } from "../tslite-bindings/org.coursera.records.test.WithInlineRecord"; -import { WithOmitField } from "../tslite-bindings/org.coursera.records.test.WithOmitField"; -import { WithOptionalComplexTypeDefaults } from "../tslite-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults"; -import { WithOptionalComplexTypes } from "../tslite-bindings/org.coursera.records.test.WithOptionalComplexTypes"; -import { WithOptionalComplexTypesDefaultNone } from "../tslite-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone"; -import { WithOptionalPrimitiveCustomTypes } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes"; -import { WithOptionalPrimitiveDefaultNone } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone"; -import { WithOptionalPrimitiveDefaults } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults"; -import { WithOptionalPrimitiveTyperefs } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs"; -import { WithOptionalPrimitives } from "../tslite-bindings/org.coursera.records.test.WithOptionalPrimitives"; -import { WithPrimitiveCustomTypes } from "../tslite-bindings/org.coursera.records.test.WithPrimitiveCustomTypes"; -import { WithPrimitiveDefaults } from "../tslite-bindings/org.coursera.records.test.WithPrimitiveDefaults"; -import { WithPrimitiveTyperefs } from "../tslite-bindings/org.coursera.records.test.WithPrimitiveTyperefs"; -import { WithPrimitives as TestWithPrimitives } from "../tslite-bindings/org.coursera.records.test.WithPrimitives"; -import { WithUnionWithInlineRecord } from "../tslite-bindings/org.coursera.records.test.WithUnionWithInlineRecord"; -import { ArrayTyperef } from "../tslite-bindings/org.coursera.typerefs.ArrayTyperef"; -import { EnumTyperef } from "../tslite-bindings/org.coursera.typerefs.EnumTyperef"; -import { FlatTypedDefinition } from "../tslite-bindings/org.coursera.typerefs.FlatTypedDefinition"; -import { InlineRecord as InlineRecordTypeRef } from "../tslite-bindings/org.coursera.typerefs.InlineRecord"; -import { InlineRecord2 } from "../tslite-bindings/org.coursera.typerefs.InlineRecord2"; -import { IntTyperef } from "../tslite-bindings/org.coursera.typerefs.IntTyperef"; -import { MapTyperef } from "../tslite-bindings/org.coursera.typerefs.MapTyperef"; -import { RecordTyperef } from "../tslite-bindings/org.coursera.typerefs.RecordTyperef"; -import { TypedDefinition } from "../tslite-bindings/org.coursera.typerefs.TypedDefinition"; -import { Union } from "../tslite-bindings/org.coursera.typerefs.Union"; -import { UnionTyperef } from "../tslite-bindings/org.coursera.typerefs.UnionTyperef"; -import { UnionWithInlineRecord } from "../tslite-bindings/org.coursera.typerefs.UnionWithInlineRecord"; -import { IntCustomType } from "../tslite-bindings/org.coursera.unions.IntCustomType"; -import { IntTyperef as IntTyperefUnion} from "../tslite-bindings/org.coursera.unions.IntTyperef"; -import { WithComplexTypesUnion } from "../tslite-bindings/org.coursera.unions.WithComplexTypesUnion"; -import { WithCustomUnionTestId } from "../tslite-bindings/org.coursera.unions.WithCustomUnionTestId"; -import { WithEmptyUnion } from "../tslite-bindings/org.coursera.unions.WithEmptyUnion"; -import { WithPrimitiveCustomTypesUnion } from "../tslite-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion"; -import { WithPrimitiveTyperefsUnion } from "../tslite-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion"; -import { WithRecordCustomTypeUnion } from "../tslite-bindings/org.coursera.unions.WithRecordCustomTypeUnion"; -import { Fortune } from "../tslite-bindings/org.example.Fortune"; -import { FortuneCookie } from "../tslite-bindings/org.example.FortuneCookie"; -import { FortuneTelling } from "../tslite-bindings/org.example.FortuneTelling"; -import { MagicEightBall } from "../tslite-bindings/org.example.MagicEightBall"; -import { MagicEightBallAnswer } from "../tslite-bindings/org.example.MagicEightBallAnswer"; -import { TyperefExample } from "../tslite-bindings/org.example.TyperefExample"; -import { DateTime as CommonDateTime } from "../tslite-bindings/org.example.common.DateTime"; -import { Timestamp } from "../tslite-bindings/org.example.common.Timestamp"; -import { DateTime as OtherDateTime } from "../tslite-bindings/org.example.other.DateTime"; -import { record } from "../tslite-bindings/org.example.record"; -import { WithPrimitivesUnion } from "../tslite-bindings/org.coursera.unions.WithPrimitivesUnion"; +import { WithoutNamespace } from "../flowtype-bindings/.WithoutNamespace"; +import { Map } from "../flowtype-bindings/CourierRuntime"; +import { WithCustomArrayTestId } from "../flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId"; +import { WithCustomTypesArray } from "../flowtype-bindings/org.coursera.arrays.WithCustomTypesArray"; +import { WithCustomTypesArrayUnion } from "../flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion"; +import { WithPrimitivesArray } from "../flowtype-bindings/org.coursera.arrays.WithPrimitivesArray"; +import { WithRecordArray } from "../flowtype-bindings/org.coursera.arrays.WithRecordArray"; +import { BooleanId } from "../flowtype-bindings/org.coursera.customtypes.BooleanId"; +import { BoxedIntId } from "../flowtype-bindings/org.coursera.customtypes.BoxedIntId"; +import { ByteId } from "../flowtype-bindings/org.coursera.customtypes.ByteId"; +import { CaseClassCustomIntWrapper } from "../flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper"; +import { CaseClassStringIdWrapper } from "../flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper"; +import { CharId } from "../flowtype-bindings/org.coursera.customtypes.CharId"; +import { CustomArrayTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomArrayTestId"; +import { CustomInt } from "../flowtype-bindings/org.coursera.customtypes.CustomInt"; +import { CustomIntWrapper } from "../flowtype-bindings/org.coursera.customtypes.CustomIntWrapper"; +import { CustomMapTestKeyId } from "../flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId"; +import { CustomMapTestValueId } from "../flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId"; +import { CustomRecord } from "../flowtype-bindings/org.coursera.customtypes.CustomRecord"; +import { CustomRecordTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomRecordTestId"; +import { CustomUnionTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomUnionTestId"; +import { DateTime } from "../flowtype-bindings/org.coursera.customtypes.DateTime"; +import { DoubleId } from "../flowtype-bindings/org.coursera.customtypes.DoubleId"; +import { FloatId } from "../flowtype-bindings/org.coursera.customtypes.FloatId"; +import { IntId } from "../flowtype-bindings/org.coursera.customtypes.IntId"; +import { LongId } from "../flowtype-bindings/org.coursera.customtypes.LongId"; +import { ShortId } from "../flowtype-bindings/org.coursera.customtypes.ShortId"; +import { StringId } from "../flowtype-bindings/org.coursera.customtypes.StringId"; +import { DeprecatedRecord } from "../flowtype-bindings/org.coursera.deprecated.DeprecatedRecord"; +import { EmptyEnum } from "../flowtype-bindings/org.coursera.enums.EmptyEnum"; +import { EnumProperties } from "../flowtype-bindings/org.coursera.enums.EnumProperties"; +import { Fruits } from "../flowtype-bindings/org.coursera.enums.Fruits"; +import { DefaultLiteralEscaping } from "../flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping"; +import { KeywordEscaping } from "../flowtype-bindings/org.coursera.escaping.KeywordEscaping"; +import { ReservedClassFieldEscaping } from "../flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping"; +import { class$ } from "../flowtype-bindings/org.coursera.escaping.class"; +import { WithFixed8 } from "../flowtype-bindings/org.coursera.fixed.WithFixed8"; +import { Toggle } from "../flowtype-bindings/org.coursera.maps.Toggle"; +import { WithComplexTypesMap } from "../flowtype-bindings/org.coursera.maps.WithComplexTypesMap"; +import { WithComplexTypesMapUnion } from "../flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion"; +import { WithCustomMapTestIds } from "../flowtype-bindings/org.coursera.maps.WithCustomMapTestIds"; +import { WithCustomTypesMap } from "../flowtype-bindings/org.coursera.maps.WithCustomTypesMap"; +import { WithPrimitivesMap } from "../flowtype-bindings/org.coursera.maps.WithPrimitivesMap"; +import { WithTypedKeyMap } from "../flowtype-bindings/org.coursera.maps.WithTypedKeyMap"; +import { CourierFile } from "../flowtype-bindings/org.coursera.records.CourierFile"; +import { JsonTest } from "../flowtype-bindings/org.coursera.records.JsonTest"; +import { Message } from "../flowtype-bindings/org.coursera.records.Message"; +import { WithAnonymousUnionArray } from "../flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray"; +import { Note } from "../flowtype-bindings/org.coursera.records.Note"; +import { WithDateTime } from "../flowtype-bindings/org.coursera.records.WithDateTime"; +import { WithFlatTypedDefinition } from "../flowtype-bindings/org.coursera.records.WithFlatTypedDefinition"; +import { WithInclude } from "../flowtype-bindings/org.coursera.records.WithInclude"; +import { WithTypedDefinition } from "../flowtype-bindings/org.coursera.records.WithTypedDefinition"; +import { WithUnion } from "../flowtype-bindings/org.coursera.records.WithUnion"; +import { Fixed8 } from "../flowtype-bindings/org.coursera.fixed.Fixed8"; +import { class$ as EscapedClassRecord} from "../flowtype-bindings/org.coursera.records.class"; +import { Simple } from "../flowtype-bindings/org.coursera.records.primitivestyle.Simple"; +import { WithComplexTypes } from "../flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes"; +import { WithPrimitives } from "../flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives"; +import { BooleanTyperef } from "../flowtype-bindings/org.coursera.records.test.BooleanTyperef"; +import { BytesTyperef } from "../flowtype-bindings/org.coursera.records.test.BytesTyperef"; +import { DoubleTyperef } from "../flowtype-bindings/org.coursera.records.test.DoubleTyperef"; +import { Empty } from "../flowtype-bindings/org.coursera.records.test.Empty"; +import { FloatTyperef } from "../flowtype-bindings/org.coursera.records.test.FloatTyperef"; +import { InlineOptionalRecord } from "../flowtype-bindings/org.coursera.records.test.InlineOptionalRecord"; +import { InlineRecord } from "../flowtype-bindings/org.coursera.records.test.InlineRecord"; +import { IntCustomType as TestIntCustomType } from "../flowtype-bindings/org.coursera.records.test.IntCustomType"; +import { IntTyperef as TestIntTyperef } from "../flowtype-bindings/org.coursera.records.test.IntTyperef"; +import { LongTyperef } from "../flowtype-bindings/org.coursera.records.test.LongTyperef"; +import { Message as TestMessage } from "../flowtype-bindings/org.coursera.records.test.Message"; +import { NumericDefaults } from "../flowtype-bindings/org.coursera.records.test.NumericDefaults"; +import { OptionalBooleanTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef"; +import { OptionalBytesTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef"; +import { OptionalDoubleTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef"; +import { OptionalFloatTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef"; +import { OptionalIntCustomType } from "../flowtype-bindings/org.coursera.records.test.OptionalIntCustomType"; +import { OptionalIntTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalIntTyperef"; +import { OptionalLongTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalLongTyperef"; +import { OptionalStringTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalStringTyperef"; +import { RecursivelyDefinedRecord } from "../flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord"; +import { Simple as TestSimple } from "../flowtype-bindings/org.coursera.records.test.Simple"; +import { StringTyperef } from "../flowtype-bindings/org.coursera.records.test.StringTyperef"; +import { With22Fields } from "../flowtype-bindings/org.coursera.records.test.With22Fields"; +import { With23Fields } from "../flowtype-bindings/org.coursera.records.test.With23Fields"; +import { WithCaseClassCustomType } from "../flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType"; +import { WithComplexTypeDefaults } from "../flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults"; +import { WithComplexTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithComplexTyperefs"; +import { WithComplexTypes as TestWithComplexTypes } from "../flowtype-bindings/org.coursera.records.test.WithComplexTypes"; +import { WithCourierFile } from "../flowtype-bindings/org.coursera.records.test.WithCourierFile"; +import { WithCustomIntWrapper } from "../flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper"; +import { WithCustomRecord } from "../flowtype-bindings/org.coursera.records.test.WithCustomRecord"; +import { WithCustomRecordTestId } from "../flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId"; +import { WithDateTime as TestWithDateTime } from "../flowtype-bindings/org.coursera.records.test.WithDateTime"; +import { WithInclude as TestWithInclude } from "../flowtype-bindings/org.coursera.records.test.WithInclude"; +import { WithInlineRecord } from "../flowtype-bindings/org.coursera.records.test.WithInlineRecord"; +import { WithOmitField } from "../flowtype-bindings/org.coursera.records.test.WithOmitField"; +import { WithOptionalComplexTypeDefaults } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults"; +import { WithOptionalComplexTypes } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes"; +import { WithOptionalComplexTypesDefaultNone } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone"; +import { WithOptionalPrimitiveCustomTypes } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes"; +import { WithOptionalPrimitiveDefaultNone } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone"; +import { WithOptionalPrimitiveDefaults } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults"; +import { WithOptionalPrimitiveTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs"; +import { WithOptionalPrimitives } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives"; +import { WithPrimitiveCustomTypes } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes"; +import { WithPrimitiveDefaults } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults"; +import { WithPrimitiveTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs"; +import { WithPrimitives as TestWithPrimitives } from "../flowtype-bindings/org.coursera.records.test.WithPrimitives"; +import { WithUnionWithInlineRecord } from "../flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord"; +import { ArrayTyperef } from "../flowtype-bindings/org.coursera.typerefs.ArrayTyperef"; +import { EnumTyperef } from "../flowtype-bindings/org.coursera.typerefs.EnumTyperef"; +import { FlatTypedDefinition } from "../flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition"; +import { InlineRecord as InlineRecordTypeRef } from "../flowtype-bindings/org.coursera.typerefs.InlineRecord"; +import { InlineRecord2 } from "../flowtype-bindings/org.coursera.typerefs.InlineRecord2"; +import { IntTyperef } from "../flowtype-bindings/org.coursera.typerefs.IntTyperef"; +import { MapTyperef } from "../flowtype-bindings/org.coursera.typerefs.MapTyperef"; +import { RecordTyperef } from "../flowtype-bindings/org.coursera.typerefs.RecordTyperef"; +import { TypedDefinition } from "../flowtype-bindings/org.coursera.typerefs.TypedDefinition"; +import { Union } from "../flowtype-bindings/org.coursera.typerefs.Union"; +import { UnionTyperef } from "../flowtype-bindings/org.coursera.typerefs.UnionTyperef"; +import { UnionWithInlineRecord } from "../flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord"; +import { IntCustomType } from "../flowtype-bindings/org.coursera.unions.IntCustomType"; +import { IntTyperef as IntTyperefUnion} from "../flowtype-bindings/org.coursera.unions.IntTyperef"; +import { WithComplexTypesUnion } from "../flowtype-bindings/org.coursera.unions.WithComplexTypesUnion"; +import { WithCustomUnionTestId } from "../flowtype-bindings/org.coursera.unions.WithCustomUnionTestId"; +import { WithEmptyUnion } from "../flowtype-bindings/org.coursera.unions.WithEmptyUnion"; +import { WithPrimitiveCustomTypesUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion"; +import { WithPrimitiveTyperefsUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion"; +import { WithRecordCustomTypeUnion } from "../flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion"; +import { Fortune } from "../flowtype-bindings/org.example.Fortune"; +import { FortuneCookie } from "../flowtype-bindings/org.example.FortuneCookie"; +import { FortuneTelling } from "../flowtype-bindings/org.example.FortuneTelling"; +import { MagicEightBall } from "../flowtype-bindings/org.example.MagicEightBall"; +import { MagicEightBallAnswer } from "../flowtype-bindings/org.example.MagicEightBallAnswer"; +import { TyperefExample } from "../flowtype-bindings/org.example.TyperefExample"; +import { DateTime as CommonDateTime } from "../flowtype-bindings/org.example.common.DateTime"; +import { Timestamp } from "../flowtype-bindings/org.example.common.Timestamp"; +import { DateTime as OtherDateTime } from "../flowtype-bindings/org.example.other.DateTime"; +import { record } from "../flowtype-bindings/org.example.record"; +import { WithPrimitivesUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitivesUnion"; import * as ts from "typescript"; const fs = require('fs'); @@ -296,7 +296,7 @@ describe("Enums", () => { }); it("Should transcribe both the class-level and symbol-level documentation from the courier spec", () => { - const fruitsFile = fs.readFileSync("src/tslite-bindings/org.coursera.enums.Fruits.ts").toString(); + const fruitsFile = fs.readFileSync("src/flowtype-bindings/org.coursera.enums.Fruits.ts").toString(); const typeComment = "An enum dedicated to the finest of the food groups."; const symbolComment = "An Apple."; diff --git a/flowtype/testsuite/tsconfig.json b/flowtype/testsuite/tsconfig.json index f22fb418..5914636c 100644 --- a/flowtype/testsuite/tsconfig.json +++ b/flowtype/testsuite/tsconfig.json @@ -40,6 +40,6 @@ "typings/browser", "typings/browser.d.ts", "src/compilation-failures", - "src/tslite-bindings" + "src/flowtype-bindings" ] } From 7b12b8aac56ccc516ea735a8b406ea4fb4d77ce4 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 15:11:52 -0700 Subject: [PATCH 08/23] fix things --- .../coursera/courier/FlowtypeGenerator.java | 28 ++++----- .../FlowtypeProperties.java} | 6 +- .../FlowtypeSyntax.java} | 58 +++++++++---------- .../{tslite => flowtype}/GlobalConfig.java | 16 ++--- .../src/main/resources/rythm-ts/enum.txt | 4 +- .../src/main/resources/rythm-ts/fixed.txt | 2 +- .../src/main/resources/rythm-ts/record.txt | 6 +- .../src/main/resources/rythm-ts/typeref.txt | 2 +- .../src/main/resources/rythm-ts/union.txt | 6 +- 9 files changed, 64 insertions(+), 64 deletions(-) rename flowtype/generator/src/main/java/org/coursera/courier/{tslite/TSProperties.java => flowtype/FlowtypeProperties.java} (91%) rename flowtype/generator/src/main/java/org/coursera/courier/{tslite/TSSyntax.java => flowtype/FlowtypeSyntax.java} (94%) rename flowtype/generator/src/main/java/org/coursera/courier/{tslite => flowtype}/GlobalConfig.java (68%) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index d0b81d87..8733010b 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Coursera Inc. + * Copyright 2017 Coursera Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ import org.coursera.courier.api.PegasusCodeGenerator; import org.coursera.courier.lang.DocCommentStyle; import org.coursera.courier.lang.PoorMansCStyleSourceFormatter; -import org.coursera.courier.tslite.GlobalConfig; -import org.coursera.courier.tslite.TSProperties; -import org.coursera.courier.tslite.TSSyntax; +import org.coursera.courier.flowtype.GlobalConfig; +import org.coursera.courier.flowtype.FlowtypeProperties; +import org.coursera.courier.flowtype.FlowtypeSyntax; import org.rythmengine.RythmEngine; import org.rythmengine.exception.RythmException; import org.rythmengine.resource.ClasspathResourceLoader; @@ -41,11 +41,11 @@ import java.util.Collections; /** - * Courier code generator for Typescript. + * Courier code generator for Flowtype. */ public class FlowtypeGenerator implements PegasusCodeGenerator { - private static final TSProperties.Optionality defaultOptionality = - TSProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; + private static final FlowtypeProperties.Optionality defaultOptionality = + FlowtypeProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; private final GlobalConfig globalConfig; private final RythmEngine engine; @@ -62,9 +62,9 @@ public static void main(String[] args) throws Throwable { String sourcePathString = args[2]; String[] sourcePaths = sourcePathString.split(":"); - TSProperties.Optionality optionality = defaultOptionality; + FlowtypeProperties.Optionality optionality = defaultOptionality; if (args.length > 3) { - optionality = TSProperties.Optionality.valueOf(args[3]); + optionality = FlowtypeProperties.Optionality.valueOf(args[3]); } boolean equatable = false; @@ -113,16 +113,16 @@ public TSCompilationUnit(String name, String namespace) { new PoorMansCStyleSourceFormatter(2, DocCommentStyle.ASTRISK_MARGIN); /** - * See {@link org.coursera.courier.tslite.TSProperties} for customization options. + * See {@link org.coursera.courier.tslite.FlowtypeProperties} for customization options. */ @Override public GeneratedCode generate(ClassTemplateSpec templateSpec) { String code; - TSProperties TSProperties = globalConfig.lookupTSProperties(templateSpec); - if (TSProperties.omit) return null; + FlowtypeProperties FlowtypeProperties = globalConfig.lookupFlowtypeProperties(templateSpec); + if (FlowtypeProperties.omit) return null; - TSSyntax syntax = new TSSyntax(TSProperties); + FlowtypeSyntax syntax = new FlowtypeSyntax(FlowtypeProperties); try { if (templateSpec instanceof RecordTemplateSpec) { code = engine.render("rythm-ts/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); @@ -132,7 +132,7 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { code = engine.render("rythm-ts/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec)); } else if (templateSpec instanceof TyperefTemplateSpec) { TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec; - code = engine.render("rythm-ts/typeref.txt", syntax.TSTyperefSyntaxCreate(typerefSpec)); + code = engine.render("rythm-ts/typeref.txt", syntax.FlowtypeTyperefSyntaxCreate(typerefSpec)); } else if (templateSpec instanceof FixedTemplateSpec) { code = engine.render("rythm-ts/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec)); } else { diff --git a/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeProperties.java similarity index 91% rename from flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java rename to flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeProperties.java index 69d0766e..d7c539d1 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSProperties.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeProperties.java @@ -1,4 +1,4 @@ -package org.coursera.courier.tslite; +package org.coursera.courier.flowtype; /** * Customizable properties that may be added to a Pegasus schema. @@ -17,7 +17,7 @@ * } * */ -public class TSProperties { +public class FlowtypeProperties { /** * "optionality" property. @@ -58,7 +58,7 @@ public enum Optionality { public final boolean equatable; public final boolean omit; - public TSProperties(Optionality optionality, boolean equatable, boolean omit) { + public FlowtypeProperties(Optionality optionality, boolean equatable, boolean omit) { this.optionality = optionality; this.equatable = equatable; this.omit = omit; diff --git a/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java similarity index 94% rename from flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java rename to flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index e7e956dd..734083ef 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/tslite/TSSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.coursera.courier.tslite; +package org.coursera.courier.flowtype; import com.linkedin.data.DataMap; import com.linkedin.data.schema.DataSchema; @@ -29,7 +29,7 @@ import org.coursera.courier.api.ClassTemplateSpecs; import org.coursera.courier.lang.DocCommentStyle; import org.coursera.courier.lang.DocEscaping; -import org.coursera.courier.tslite.TSProperties.Optionality; +import org.coursera.courier.flowtype.FlowtypeProperties.Optionality; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,7 @@ * * Most work delegates to inner classes, so you probably want to look them (linked below) * - * Specifically, {@link TSEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link TSTyperefSyntax} are + * Specifically, {@link TSEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are * used directly to populate the templates. * * @see TSPrimitiveTypeSyntax @@ -51,19 +51,19 @@ * @see TSArraySyntax * @see TSUnionSyntax * @see TSMapSyntax - * @see TSTyperefSyntax + * @see FlowtypeTyperefSyntax * @see TSRecordSyntax * @see TSFixedSyntax * @see TSRecordSyntax * @see TSUnionSyntax */ -public class TSSyntax { +public class FlowtypeSyntax { /** Config properties passed from the command line parser */ - private final TSProperties TSProperties; + private final FlowtypeProperties FlowtypeProperties; - public TSSyntax(TSProperties TSProperties) { - this.TSProperties = TSProperties; + public FlowtypeSyntax(FlowtypeProperties FlowtypeProperties) { + this.FlowtypeProperties = FlowtypeProperties; } /** @@ -260,13 +260,13 @@ private interface TSEnclosedTypeSyntax { * That class will perform the heavy lifting of rendering TS-specific strings into the template. * * @param template the ClassTemplate - * @return a TS*Syntax class (see {@link TSSyntax} class-level docs for more info) + * @return a TS*Syntax class (see {@link FlowtypeSyntax} class-level docs for more info) */ private TSTypeSyntax createTypeSyntax(ClassTemplateSpec template) { if (template instanceof RecordTemplateSpec) { return new TSRecordSyntax((RecordTemplateSpec) template); } else if (template instanceof TyperefTemplateSpec) { - return TSTyperefSyntaxCreate((TyperefTemplateSpec) template); + return FlowtypeTyperefSyntaxCreate((TyperefTemplateSpec) template); } else if (template instanceof FixedTemplateSpec) { return TSFixedSyntaxCreate((FixedTemplateSpec) template); } else if (template instanceof EnumTemplateSpec) { @@ -428,15 +428,15 @@ public Set modulesRequiredToUse() { * * Helps reduce code bloat for Records, Enums, and Typerefs. **/ - private class TSNamedTypeSyntax { + private class FlowtypeNamedTypeSyntax { private final NamedDataSchema _dataSchema; - public TSNamedTypeSyntax(NamedDataSchema _dataSchema) { + public FlowtypeNamedTypeSyntax(NamedDataSchema _dataSchema) { this._dataSchema = _dataSchema; } public String typeName() { - return TSSyntax.escapeKeyword(this._dataSchema.getName(), EscapeStrategy.MANGLE); + return FlowtypeSyntax.escapeKeyword(this._dataSchema.getName(), EscapeStrategy.MANGLE); } public String docString() { @@ -457,9 +457,9 @@ public Set modulesRequiredToUse() { /** TS syntax for Fixed types. */ public class TSFixedSyntax implements TSTypeSyntax { private final FixedTemplateSpec _template; - private final TSNamedTypeSyntax _namedSyntax; + private final FlowtypeNamedTypeSyntax _namedSyntax; - public TSFixedSyntax(FixedTemplateSpec template, TSNamedTypeSyntax namedSyntax) { + public TSFixedSyntax(FixedTemplateSpec template, FlowtypeNamedTypeSyntax namedSyntax) { this._template = template; this._namedSyntax = namedSyntax; } @@ -480,7 +480,7 @@ public Set modulesRequiredToUse() { /** Create a new TSFixedSyntax */ public TSFixedSyntax TSFixedSyntaxCreate(FixedTemplateSpec template) { - return new TSFixedSyntax(template, new TSNamedTypeSyntax(template.getSchema())); + return new TSFixedSyntax(template, new FlowtypeNamedTypeSyntax(template.getSchema())); } /** @@ -594,7 +594,7 @@ public String typeNameQualifiedByEnclosedType() { public String typeName() { if (_template.getTyperefClass() != null) { // If this union was typerefed then just use the typeref name - TSTyperefSyntax refSyntax = TSTyperefSyntaxCreate(_template.getTyperefClass()); + FlowtypeTyperefSyntax refSyntax = FlowtypeTyperefSyntaxCreate(_template.getTyperefClass()); return refSyntax.typeName(); } else { // I actually never figured out why this works, so I'm very sorry if you're dealing @@ -630,7 +630,7 @@ public Set modulesRequiredToUse() { public String docString() { if (this._template.getTyperefClass() != null) { - return new TSNamedTypeSyntax(this._template.getTyperefClass().getSchema()).docString(); + return new FlowtypeNamedTypeSyntax(this._template.getTyperefClass().getSchema()).docString(); } else { return ""; } @@ -776,7 +776,7 @@ public Set typeModules() { **/ public String questionMarkIfOptional() { boolean isFieldOptional = _schemaField().getOptional(); - boolean markFieldAsOptional = isFieldOptional || TSProperties.optionality == Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; + boolean markFieldAsOptional = isFieldOptional || FlowtypeProperties.optionality == Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; return markFieldAsOptional? "?": ""; } @@ -796,12 +796,12 @@ private TSTypeSyntax _fieldTypeSyntax() { public class TSRecordSyntax implements TSTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; - private final TSNamedTypeSyntax _namedTypeSyntax; + private final FlowtypeNamedTypeSyntax _namedTypeSyntax; public TSRecordSyntax(RecordTemplateSpec _template) { this._template = _template; this._schema = _template.getSchema(); - this._namedTypeSyntax = new TSNamedTypeSyntax(_schema); + this._namedTypeSyntax = new FlowtypeNamedTypeSyntax(_schema); } public String docString() { @@ -864,13 +864,13 @@ public String imports() { } } - /** TS syntax for typerefs. */ - public class TSTyperefSyntax implements TSTypeSyntax { + /** Flowtype syntax for typerefs. */ + public class FlowtypeTyperefSyntax implements TSTypeSyntax { private final TyperefTemplateSpec _template; private final TyperefDataSchema _dataSchema; - private final TSNamedTypeSyntax _namedTypeSyntax; + private final FlowtypeNamedTypeSyntax _namedTypeSyntax; - public TSTyperefSyntax(TyperefTemplateSpec _template, TyperefDataSchema _dataSchema, TSNamedTypeSyntax _namedTypeSyntax) { + public FlowtypeTyperefSyntax(TyperefTemplateSpec _template, TyperefDataSchema _dataSchema, FlowtypeNamedTypeSyntax _namedTypeSyntax) { this._template = _template; this._dataSchema = _dataSchema; this._namedTypeSyntax = _namedTypeSyntax; @@ -912,8 +912,8 @@ private ClassTemplateSpec _refType() { } /** Create a new TyperefSyntax */ - public TSTyperefSyntax TSTyperefSyntaxCreate(TyperefTemplateSpec template) { - return new TSTyperefSyntax(template, template.getSchema(), new TSNamedTypeSyntax(template.getSchema())); + public FlowtypeTyperefSyntax FlowtypeTyperefSyntaxCreate(TyperefTemplateSpec template) { + return new FlowtypeTyperefSyntax(template, template.getSchema(), new FlowtypeNamedTypeSyntax(template.getSchema())); } /** TS syntax for the symbol of an enum */ @@ -964,12 +964,12 @@ public String docString() { public class TSEnumSyntax implements TSTypeSyntax { private final EnumTemplateSpec _template; private final EnumDataSchema _dataSchema; - private final TSNamedTypeSyntax _namedTypeSyntax; + private final FlowtypeNamedTypeSyntax _namedTypeSyntax; public TSEnumSyntax(EnumTemplateSpec _template) { this._template = _template; this._dataSchema = _template.getSchema(); - this._namedTypeSyntax = new TSNamedTypeSyntax(_dataSchema); + this._namedTypeSyntax = new FlowtypeNamedTypeSyntax(_dataSchema); } public String typeName() { diff --git a/flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/GlobalConfig.java similarity index 68% rename from flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java rename to flowtype/generator/src/main/java/org/coursera/courier/flowtype/GlobalConfig.java index 8ec7c362..5fa7b92a 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/tslite/GlobalConfig.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/GlobalConfig.java @@ -1,4 +1,4 @@ -package org.coursera.courier.tslite; +package org.coursera.courier.flowtype; import com.linkedin.data.DataMap; import com.linkedin.data.schema.DataSchema; @@ -6,16 +6,16 @@ import com.linkedin.pegasus.generator.spec.UnionTemplateSpec; public class GlobalConfig { - public final TSProperties defaults; + public final FlowtypeProperties defaults; public GlobalConfig( - TSProperties.Optionality defaultOptionality, + FlowtypeProperties.Optionality defaultOptionality, boolean defaultEquatable, boolean defaultOmit) { - defaults = new TSProperties(defaultOptionality, defaultEquatable, defaultOmit); + defaults = new FlowtypeProperties(defaultOptionality, defaultEquatable, defaultOmit); } - public TSProperties lookupTSProperties(ClassTemplateSpec templateSpec) { + public FlowtypeProperties lookupFlowtypeProperties(ClassTemplateSpec templateSpec) { DataSchema schema = templateSpec.getSchema(); if (templateSpec instanceof UnionTemplateSpec && templateSpec.getOriginalTyperefSchema() != null) { schema = templateSpec.getOriginalTyperefSchema(); @@ -32,8 +32,8 @@ public TSProperties lookupTSProperties(ClassTemplateSpec templateSpec) { String optionalityString = properties.getString("optionality"); - TSProperties.Optionality optionality = - optionalityString == null ? defaults.optionality : TSProperties.Optionality.valueOf(optionalityString); + FlowtypeProperties.Optionality optionality = + optionalityString == null ? defaults.optionality : FlowtypeProperties.Optionality.valueOf(optionalityString); Boolean maybeEquatable = properties.getBoolean("equatable"); boolean equatable = maybeEquatable == null ? defaults.equatable : maybeEquatable; @@ -41,7 +41,7 @@ public TSProperties lookupTSProperties(ClassTemplateSpec templateSpec) { Boolean maybeOmit = properties.getBoolean("omit"); boolean omit = maybeOmit == null ? defaults.omit : maybeOmit; - return new TSProperties(optionality, equatable, omit); + return new FlowtypeProperties(optionality, equatable, omit); } } } diff --git a/flowtype/generator/src/main/resources/rythm-ts/enum.txt b/flowtype/generator/src/main/resources/rythm-ts/enum.txt index c2614c8d..38526f68 100644 --- a/flowtype/generator/src/main/resources/rythm-ts/enum.txt +++ b/flowtype/generator/src/main/resources/rythm-ts/enum.txt @@ -1,5 +1,5 @@ -@args org.coursera.courier.tslite.TSSyntax.TSEnumSyntax enumeration -@import org.coursera.courier.tslite.TSSyntax.TSEnumSymbolSyntax +@args org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSyntax enumeration +@import org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSymbolSyntax @enumeration.docString() export type @enumeration.typeName() = @enumeration.stringLiteralUnion(); diff --git a/flowtype/generator/src/main/resources/rythm-ts/fixed.txt b/flowtype/generator/src/main/resources/rythm-ts/fixed.txt index 3a151c18..6e595b9b 100644 --- a/flowtype/generator/src/main/resources/rythm-ts/fixed.txt +++ b/flowtype/generator/src/main/resources/rythm-ts/fixed.txt @@ -1,4 +1,4 @@ -@args org.coursera.courier.tslite.TSSyntax.TSFixedSyntax fixed +@args org.coursera.courier.flowtype.FlowtypeSyntax.TSFixedSyntax fixed @fixed.docString() export type @fixed.typeName() = string; diff --git a/flowtype/generator/src/main/resources/rythm-ts/record.txt b/flowtype/generator/src/main/resources/rythm-ts/record.txt index 3a39d2a5..a1cb1ad5 100644 --- a/flowtype/generator/src/main/resources/rythm-ts/record.txt +++ b/flowtype/generator/src/main/resources/rythm-ts/record.txt @@ -1,6 +1,6 @@ -@args org.coursera.courier.tslite.TSSyntax.TSRecordSyntax record -@import org.coursera.courier.tslite.TSSyntax.TSUnionSyntax -@import org.coursera.courier.tslite.TSSyntax.TSRecordFieldSyntax +@args org.coursera.courier.flowtype.FlowtypeSyntax.TSRecordSyntax record +@import org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionSyntax +@import org.coursera.courier.flowtype.FlowtypeSyntax.TSRecordFieldSyntax @record.imports() diff --git a/flowtype/generator/src/main/resources/rythm-ts/typeref.txt b/flowtype/generator/src/main/resources/rythm-ts/typeref.txt index 4b5a2ef4..33484983 100644 --- a/flowtype/generator/src/main/resources/rythm-ts/typeref.txt +++ b/flowtype/generator/src/main/resources/rythm-ts/typeref.txt @@ -1,4 +1,4 @@ -@args org.coursera.courier.tslite.TSSyntax.TSTyperefSyntax typeref +@args org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeTyperefSyntax typeref @typeref.imports() diff --git a/flowtype/generator/src/main/resources/rythm-ts/union.txt b/flowtype/generator/src/main/resources/rythm-ts/union.txt index 31b3308b..412fd310 100644 --- a/flowtype/generator/src/main/resources/rythm-ts/union.txt +++ b/flowtype/generator/src/main/resources/rythm-ts/union.txt @@ -1,6 +1,6 @@ -@args org.coursera.courier.tslite.TSSyntax.TSUnionSyntax union -@import org.coursera.courier.tslite.TSSyntax.TSUnionSyntax -@import org.coursera.courier.tslite.TSSyntax.TSUnionMemberSyntax +@args org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionSyntax union +@import org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionSyntax +@import org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionMemberSyntax @union.imports() From 26f3637cf031100b327e31c017c3fe08c3bb7f6b Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 15:30:18 -0700 Subject: [PATCH 09/23] change to rhythm --- .../java/org/coursera/courier/FlowtypeGenerator.java | 10 +++++----- .../src/main/resources/{rythm-ts => rythm}/enum.txt | 0 .../src/main/resources/{rythm-ts => rythm}/fixed.txt | 0 .../src/main/resources/{rythm-ts => rythm}/record.txt | 0 .../src/main/resources/{rythm-ts => rythm}/typeref.txt | 1 + .../src/main/resources/{rythm-ts => rythm}/union.txt | 0 .../org.coursera.customtypes.BooleanId.ts | 1 + .../org.coursera.customtypes.BoxedIntId.ts | 1 + .../org.coursera.customtypes.ByteId.ts | 1 + ...g.coursera.customtypes.CaseClassCustomIntWrapper.ts | 1 + ...rg.coursera.customtypes.CaseClassStringIdWrapper.ts | 1 + .../org.coursera.customtypes.CharId.ts | 1 + .../org.coursera.customtypes.CustomArrayTestId.ts | 1 + .../org.coursera.customtypes.CustomInt.ts | 1 + .../org.coursera.customtypes.CustomIntWrapper.ts | 1 + .../org.coursera.customtypes.CustomMapTestKeyId.ts | 1 + .../org.coursera.customtypes.CustomMapTestValueId.ts | 1 + .../org.coursera.customtypes.CustomRecord.ts | 1 + .../org.coursera.customtypes.CustomRecordTestId.ts | 1 + .../org.coursera.customtypes.CustomUnionTestId.ts | 1 + .../org.coursera.customtypes.DateTime.ts | 1 + .../org.coursera.customtypes.DoubleId.ts | 1 + .../org.coursera.customtypes.FloatId.ts | 1 + .../org.coursera.customtypes.IntId.ts | 1 + .../org.coursera.customtypes.LongId.ts | 1 + .../org.coursera.customtypes.ShortId.ts | 1 + .../org.coursera.customtypes.StringId.ts | 1 + .../org.coursera.records.test.BooleanTyperef.ts | 1 + .../org.coursera.records.test.BytesTyperef.ts | 1 + .../org.coursera.records.test.DoubleTyperef.ts | 1 + .../org.coursera.records.test.FloatTyperef.ts | 1 + .../org.coursera.records.test.IntCustomType.ts | 1 + .../org.coursera.records.test.IntTyperef.ts | 1 + .../org.coursera.records.test.LongTyperef.ts | 1 + ...org.coursera.records.test.OptionalBooleanTyperef.ts | 1 + .../org.coursera.records.test.OptionalBytesTyperef.ts | 1 + .../org.coursera.records.test.OptionalDoubleTyperef.ts | 1 + .../org.coursera.records.test.OptionalFloatTyperef.ts | 1 + .../org.coursera.records.test.OptionalIntCustomType.ts | 1 + .../org.coursera.records.test.OptionalIntTyperef.ts | 1 + .../org.coursera.records.test.OptionalLongTyperef.ts | 1 + .../org.coursera.records.test.OptionalStringTyperef.ts | 1 + .../org.coursera.records.test.StringTyperef.ts | 1 + .../org.coursera.typerefs.ArrayTyperef.ts | 1 + .../org.coursera.typerefs.EnumTyperef.ts | 1 + .../org.coursera.typerefs.IntTyperef.ts | 1 + .../org.coursera.typerefs.MapTyperef.ts | 1 + .../org.coursera.typerefs.RecordTyperef.ts | 1 + .../org.coursera.unions.IntCustomType.ts | 1 + .../org.coursera.unions.IntTyperef.ts | 1 + .../flowtype-bindings/org.example.common.DateTime.ts | 1 + .../flowtype-bindings/org.example.common.Timestamp.ts | 1 + .../flowtype-bindings/org.example.other.DateTime.ts | 1 + 53 files changed, 53 insertions(+), 5 deletions(-) rename flowtype/generator/src/main/resources/{rythm-ts => rythm}/enum.txt (100%) rename flowtype/generator/src/main/resources/{rythm-ts => rythm}/fixed.txt (100%) rename flowtype/generator/src/main/resources/{rythm-ts => rythm}/record.txt (100%) rename flowtype/generator/src/main/resources/{rythm-ts => rythm}/typeref.txt (95%) rename flowtype/generator/src/main/resources/{rythm-ts => rythm}/union.txt (100%) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 8733010b..02c0c8a6 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -125,16 +125,16 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { FlowtypeSyntax syntax = new FlowtypeSyntax(FlowtypeProperties); try { if (templateSpec instanceof RecordTemplateSpec) { - code = engine.render("rythm-ts/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); + code = engine.render("rythm/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); } else if (templateSpec instanceof EnumTemplateSpec) { - code = engine.render("rythm-ts/enum.txt", syntax.new TSEnumSyntax((EnumTemplateSpec) templateSpec)); + code = engine.render("rythm/enum.txt", syntax.new TSEnumSyntax((EnumTemplateSpec) templateSpec)); } else if (templateSpec instanceof UnionTemplateSpec) { - code = engine.render("rythm-ts/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec)); + code = engine.render("rythm/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec)); } else if (templateSpec instanceof TyperefTemplateSpec) { TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec; - code = engine.render("rythm-ts/typeref.txt", syntax.FlowtypeTyperefSyntaxCreate(typerefSpec)); + code = engine.render("rythm/typeref.txt", syntax.FlowtypeTyperefSyntaxCreate(typerefSpec)); } else if (templateSpec instanceof FixedTemplateSpec) { - code = engine.render("rythm-ts/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec)); + code = engine.render("rythm/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec)); } else { return null; // Indicates that we are declining to generate code for the type (e.g. map or array) } diff --git a/flowtype/generator/src/main/resources/rythm-ts/enum.txt b/flowtype/generator/src/main/resources/rythm/enum.txt similarity index 100% rename from flowtype/generator/src/main/resources/rythm-ts/enum.txt rename to flowtype/generator/src/main/resources/rythm/enum.txt diff --git a/flowtype/generator/src/main/resources/rythm-ts/fixed.txt b/flowtype/generator/src/main/resources/rythm/fixed.txt similarity index 100% rename from flowtype/generator/src/main/resources/rythm-ts/fixed.txt rename to flowtype/generator/src/main/resources/rythm/fixed.txt diff --git a/flowtype/generator/src/main/resources/rythm-ts/record.txt b/flowtype/generator/src/main/resources/rythm/record.txt similarity index 100% rename from flowtype/generator/src/main/resources/rythm-ts/record.txt rename to flowtype/generator/src/main/resources/rythm/record.txt diff --git a/flowtype/generator/src/main/resources/rythm-ts/typeref.txt b/flowtype/generator/src/main/resources/rythm/typeref.txt similarity index 95% rename from flowtype/generator/src/main/resources/rythm-ts/typeref.txt rename to flowtype/generator/src/main/resources/rythm/typeref.txt index 33484983..586cb9d2 100644 --- a/flowtype/generator/src/main/resources/rythm-ts/typeref.txt +++ b/flowtype/generator/src/main/resources/rythm/typeref.txt @@ -3,4 +3,5 @@ @typeref.imports() @typeref.docString() +// hello export type @typeref.typeName() = @typeref.refTypeName(); diff --git a/flowtype/generator/src/main/resources/rythm-ts/union.txt b/flowtype/generator/src/main/resources/rythm/union.txt similarity index 100% rename from flowtype/generator/src/main/resources/rythm-ts/union.txt rename to flowtype/generator/src/main/resources/rythm/union.txt diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts index 680e5f2b..45ebdf54 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts @@ -1 +1,2 @@ +// hello export type BooleanId = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts index 0deffeb2..b6d89b8b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts @@ -1 +1,2 @@ +// hello export type BoxedIntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts index 5d9fa3b3..46d15863 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts @@ -1 +1,2 @@ +// hello export type ByteId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts index 0674a0f3..dea6c84e 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts @@ -1,3 +1,4 @@ import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +// hello export type CaseClassCustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts index d730ad07..5c3e470f 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts @@ -1,3 +1,4 @@ import { StringId } from "./org.coursera.customtypes.StringId"; +// hello export type CaseClassStringIdWrapper = StringId; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts index 53eebe12..9f8b0443 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts @@ -1 +1,2 @@ +// hello export type CharId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts index 2ebdea78..94119866 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts @@ -1 +1,2 @@ +// hello export type CustomArrayTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts index fdd88ddb..656a1ab9 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts @@ -1 +1,2 @@ +// hello export type CustomInt = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts index 0e0505e2..0de573b1 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts @@ -1,3 +1,4 @@ import { CustomInt } from "./org.coursera.customtypes.CustomInt"; +// hello export type CustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts index ebefc23e..f0de1c0c 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts @@ -1 +1,2 @@ +// hello export type CustomMapTestKeyId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts index f0d4cadf..f5b5d4cb 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts @@ -1 +1,2 @@ +// hello export type CustomMapTestValueId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts index 8bb5154d..ce233847 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts @@ -1,3 +1,4 @@ import { Message } from "./org.coursera.records.test.Message"; +// hello export type CustomRecord = Message; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts index d6d08519..636b9d5b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts @@ -1 +1,2 @@ +// hello export type CustomRecordTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts index 228db52a..18e4d686 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts @@ -1 +1,2 @@ +// hello export type CustomUnionTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts index c0dba863..eaf44636 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts @@ -1 +1,2 @@ +// hello export type DateTime = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts index 1b01067e..4e48c431 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts @@ -1 +1,2 @@ +// hello export type DoubleId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts index 4ff30115..ba01a108 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts @@ -1 +1,2 @@ +// hello export type FloatId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts index 82278d55..bf0ba030 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts @@ -1 +1,2 @@ +// hello export type IntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts index 779f7749..070f9367 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts @@ -1 +1,2 @@ +// hello export type LongId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts index 89dd3aea..7a3cb53c 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts @@ -1 +1,2 @@ +// hello export type ShortId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts index fc90a2fd..7dd4be02 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts @@ -1 +1,2 @@ +// hello export type StringId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts index c587f330..8c3a5805 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts @@ -1 +1,2 @@ +// hello export type BooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts index 5a6800cc..5d46f10f 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts @@ -1 +1,2 @@ +// hello export type BytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts index 95a56e53..bb2b110f 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts @@ -1 +1,2 @@ +// hello export type DoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts index 2a14e394..12198f07 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts @@ -1 +1,2 @@ +// hello export type FloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts index 10d347b5..cdd9e1ff 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts @@ -1 +1,2 @@ +// hello export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts index cc1e7a3b..d64ed25f 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts @@ -1 +1,2 @@ +// hello export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts index edfa2140..5502dfa7 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts @@ -1 +1,2 @@ +// hello export type LongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts index c596cad7..584cbaa5 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalBooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts index 0848ba00..6b5f4ebb 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalBytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts index c074836b..4ec641ba 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalDoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts index 8d91a69a..d40d0c8c 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalFloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts index 64de6f02..257cbab0 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts @@ -1 +1,2 @@ +// hello export type OptionalIntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts index 44f23aac..465493c0 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalIntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts index 14bfc0c2..dacb9121 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalLongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts index 2ba22764..6676ba66 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts @@ -1 +1,2 @@ +// hello export type OptionalStringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts index b1ce0238..3eed1f67 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts @@ -1 +1,2 @@ +// hello export type StringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts index 3d64fba3..70c3e511 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts @@ -1,3 +1,4 @@ import { Empty } from "./org.coursera.records.test.Empty"; +// hello export type ArrayTyperef = Array; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts index a2c76b72..9e3cec86 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts @@ -1,3 +1,4 @@ import { Fruits } from "./org.coursera.enums.Fruits"; +// hello export type EnumTyperef = Fruits; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts index cc1e7a3b..d64ed25f 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts @@ -1 +1,2 @@ +// hello export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts index f0dc7fee..f3bc6f37 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts @@ -1,4 +1,5 @@ import { Map } from "./CourierRuntime"; import { Empty } from "./org.coursera.records.test.Empty"; +// hello export type MapTyperef = Map; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts index c1465964..c867cc92 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts @@ -1,3 +1,4 @@ import { Empty } from "./org.coursera.records.test.Empty"; +// hello export type RecordTyperef = Empty; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts index 10d347b5..cdd9e1ff 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts @@ -1 +1,2 @@ +// hello export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts index cc1e7a3b..d64ed25f 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts @@ -1 +1,2 @@ +// hello export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts index a2ae7352..493fbc63 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts @@ -1,4 +1,5 @@ /** * ISO 8601 date-time. */ +// hello export type DateTime = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts index 99fd474e..75ff05d5 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts @@ -1,4 +1,5 @@ /** * A unix timestamp. */ +// hello export type Timestamp = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts index a2ae7352..493fbc63 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts @@ -1,4 +1,5 @@ /** * ISO 8601 date-time. */ +// hello export type DateTime = string; From 3795d69c78ee0c73fb4b2eff5d9e5d672e481e58 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 16:10:45 -0700 Subject: [PATCH 10/23] enum fixes --- .../src/main/resources/rythm/enum.txt | 12 +----- flowtype/testsuite/package.json | 6 +-- .../expected-successes/spec/bindings.spec.ts | 31 +++++++-------- ...coursera.arrays.WithAnonymousUnionArray.ts | 38 +++++++++---------- .../org.coursera.enums.EmptyEnum.ts | 2 + .../org.coursera.enums.EnumProperties.ts | 12 +----- .../org.coursera.enums.Fruits.ts | 15 +------- .../org.coursera.maps.Toggle.ts | 10 +---- .../org.example.MagicEightBallAnswer.ts | 13 +------ 9 files changed, 47 insertions(+), 92 deletions(-) diff --git a/flowtype/generator/src/main/resources/rythm/enum.txt b/flowtype/generator/src/main/resources/rythm/enum.txt index 38526f68..41444aac 100644 --- a/flowtype/generator/src/main/resources/rythm/enum.txt +++ b/flowtype/generator/src/main/resources/rythm/enum.txt @@ -1,15 +1,5 @@ @args org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSyntax enumeration +// @@flow @import org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSymbolSyntax - @enumeration.docString() export type @enumeration.typeName() = @enumeration.stringLiteralUnion(); -@if(enumeration.requiresCompanionModule()) { - export module @enumeration.typeName() { - @for(TSEnumSymbolSyntax symbol : enumeration.symbols()) { - @symbol.docString() - export const @symbol.moduleConstValue(): @enumeration.typeName() = @symbol.stringLiteralValue(); - } - - export const all: Array<@enumeration.typeName()> = @enumeration.arrayLiteral(); - } -} diff --git a/flowtype/testsuite/package.json b/flowtype/testsuite/package.json index 6ab3c5f5..132d5e80 100644 --- a/flowtype/testsuite/package.json +++ b/flowtype/testsuite/package.json @@ -1,7 +1,7 @@ { - "name": "courier-typescript-lite-generator-test", + "name": "courier-flowtype-generator-test", "version": "1.0.0", - "description": "Test-suite for the typescript-lite courier bindings", + "description": "Test-suite for the flowtype courier bindings", "main": "src/index.js", "scripts": { "setup": "npm install && npm run-script typings-install", @@ -14,7 +14,7 @@ "type": "git", "url": "git+ssh://git@github.com/coursera/courier.git" }, - "author": "Erem Boto", + "author": "Kyle Verhoog & Moaaz Sidat", "license": "Apache-2.0", "bugs": { "url": "https://github.com/coursera/courier/issues" diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts index 7368be76..4130927d 100644 --- a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts +++ b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts @@ -146,6 +146,8 @@ import CompilerOptions = ts.CompilerOptions; import TranspileOptions = ts.TranspileOptions; import Diagnostic = ts.Diagnostic; +const flowPragmaComment = "// @flow"; + // Add a jasmine matcher that will attempt to compile a ts file and report // any compilation errors const toCompileMatcher: CustomMatcherFactories = { @@ -264,8 +266,8 @@ describe("The typescript compiler", () => { describe("Enums", () => { it("Should have successful accessors", () => { const fruit1: Fruits = "APPLE"; - expect(fruit1).toEqual(Fruits.APPLE); - expect(fruit1 == Fruits.APPLE).toBe(true); + // expect(fruit1).toEqual(Fruits.APPLE); + // expect(fruit1 == Fruits.APPLE).toBe(true); }); it("Should have nice switch/case semantics", () => { @@ -283,14 +285,14 @@ describe("Enums", () => { } expect(result).toEqual("It was an apple"); - - switch (fruit1) { - case Fruits.APPLE: - result = "It's still an apple"; - break; - default: - result = "Something else." - } + result = "It's still an apple"; + // switch (fruit1) { + // case Fruits.APPLE: + // result = "It's still an apple"; + // break; + // default: + // result = "Something else." + // } expect(result).toEqual("It's still an apple"); }); @@ -298,15 +300,14 @@ describe("Enums", () => { it("Should transcribe both the class-level and symbol-level documentation from the courier spec", () => { const fruitsFile = fs.readFileSync("src/flowtype-bindings/org.coursera.enums.Fruits.ts").toString(); const typeComment = "An enum dedicated to the finest of the food groups."; - const symbolComment = "An Apple."; + expect(fruitsFile).toContain(flowPragmaComment); expect(fruitsFile).toContain(typeComment); - expect(fruitsFile).toContain(symbolComment); }); - it("Should be enumerated with the .all function", () => { - expect(Fruits.all).toEqual(["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]); - }); + // it("Should be enumerated with the .all function", () => { + // expect(Fruits.all).toEqual(["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]); + // }); }); diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts index 6b127146..e9e2a3ee 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts @@ -8,25 +8,6 @@ export interface WithAnonymousUnionArray { } export module WithAnonymousUnionArray { - export type UnionsArray = UnionsArray.IntMember | UnionsArray.StringMember; - export module UnionsArray { - export interface UnionsArrayMember { - [key: string]: number | string; - } - export interface IntMember extends UnionsArrayMember { - "int": number; - } - export interface StringMember extends UnionsArrayMember { - "string": string; - } - export function unpack(union: UnionsArray) { - return { - int: union["int"] as number, - string$: union["string"] as string - }; - } - } - export type UnionsMap = UnionsMap.StringMember | UnionsMap.IntMember; export module UnionsMap { export interface UnionsMapMember { @@ -45,4 +26,23 @@ export module WithAnonymousUnionArray { }; } } + + export type UnionsArray = UnionsArray.IntMember | UnionsArray.StringMember; + export module UnionsArray { + export interface UnionsArrayMember { + [key: string]: number | string; + } + export interface IntMember extends UnionsArrayMember { + "int": number; + } + export interface StringMember extends UnionsArrayMember { + "string": string; + } + export function unpack(union: UnionsArray) { + return { + int: union["int"] as number, + string$: union["string"] as string + }; + } + } } diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts index bcd99717..cf87f4be 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts @@ -1 +1,3 @@ +// @flow + export type EmptyEnum = void; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts index 5387818a..87d6e802 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts @@ -1,11 +1,3 @@ +// @flow + export type EnumProperties = "APPLE" | "ORANGE" | "BANANA"; -export module EnumProperties { - - export const APPLE: EnumProperties = "APPLE"; - - export const ORANGE: EnumProperties = "ORANGE"; - - export const BANANA: EnumProperties = "BANANA"; - - export const all: Array = ["APPLE", "ORANGE", "BANANA"]; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts index 027c88db..d8f81f40 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts @@ -1,18 +1,5 @@ +// @flow /** * An enum dedicated to the finest of the food groups. */ export type Fruits = "APPLE" | "BANANA" | "ORANGE" | "PINEAPPLE"; -export module Fruits { - /** - * An Apple. - */ - export const APPLE: Fruits = "APPLE"; - - export const BANANA: Fruits = "BANANA"; - - export const ORANGE: Fruits = "ORANGE"; - - export const PINEAPPLE: Fruits = "PINEAPPLE"; - - export const all: Array = ["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts index d347afe2..b827cbed 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts @@ -1,9 +1,3 @@ +// @flow + export type Toggle = "UP" | "DOWN"; -export module Toggle { - - export const UP: Toggle = "UP"; - - export const DOWN: Toggle = "DOWN"; - - export const all: Array = ["UP", "DOWN"]; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts index 1e02b93a..7e744cd9 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts @@ -1,16 +1,5 @@ +// @flow /** * Magic eight ball answers. */ export type MagicEightBallAnswer = "IT_IS_CERTAIN" | "ASK_AGAIN_LATER" | "OUTLOOK_NOT_SO_GOOD"; -export module MagicEightBallAnswer { - - export const IT_IS_CERTAIN: MagicEightBallAnswer = "IT_IS_CERTAIN"; - /** - * Where later is at least 10 ms from now. - */ - export const ASK_AGAIN_LATER: MagicEightBallAnswer = "ASK_AGAIN_LATER"; - - export const OUTLOOK_NOT_SO_GOOD: MagicEightBallAnswer = "OUTLOOK_NOT_SO_GOOD"; - - export const all: Array = ["IT_IS_CERTAIN", "ASK_AGAIN_LATER", "OUTLOOK_NOT_SO_GOOD"]; -} From 9fef5d6bd98d36212ace4225b2f4c7118cdfb0c1 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 16:15:22 -0700 Subject: [PATCH 11/23] rename from TS to Flowtype for enum and TypeSyntax --- .../coursera/courier/FlowtypeGenerator.java | 2 +- .../courier/flowtype/FlowtypeSyntax.java | 48 +++++++++---------- .../src/main/resources/rythm/enum.txt | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 02c0c8a6..06f20c4a 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -127,7 +127,7 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { if (templateSpec instanceof RecordTemplateSpec) { code = engine.render("rythm/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); } else if (templateSpec instanceof EnumTemplateSpec) { - code = engine.render("rythm/enum.txt", syntax.new TSEnumSyntax((EnumTemplateSpec) templateSpec)); + code = engine.render("rythm/enum.txt", syntax.new FlowtypeEnumSyntax((EnumTemplateSpec) templateSpec)); } else if (templateSpec instanceof UnionTemplateSpec) { code = engine.render("rythm/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec)); } else if (templateSpec instanceof TyperefTemplateSpec) { diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index 734083ef..c38a9b52 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -43,11 +43,11 @@ * * Most work delegates to inner classes, so you probably want to look them (linked below) * - * Specifically, {@link TSEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are + * Specifically, {@link FlowtypeEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are * used directly to populate the templates. * * @see TSPrimitiveTypeSyntax - * @see TSEnumSyntax + * @see FlowtypeEnumSyntax * @see TSArraySyntax * @see TSUnionSyntax * @see TSMapSyntax @@ -234,7 +234,7 @@ private static String flattenImports(Set imports) { } /** Describes any type we are representing in the generated typescript */ - interface TSTypeSyntax { + interface FlowtypeTypeSyntax { /** Return the simple name of the type, in valid typescript. "number" or "string" for example. */ public String typeName(); @@ -262,7 +262,7 @@ private interface TSEnclosedTypeSyntax { * @param template the ClassTemplate * @return a TS*Syntax class (see {@link FlowtypeSyntax} class-level docs for more info) */ - private TSTypeSyntax createTypeSyntax(ClassTemplateSpec template) { + private FlowtypeTypeSyntax createTypeSyntax(ClassTemplateSpec template) { if (template instanceof RecordTemplateSpec) { return new TSRecordSyntax((RecordTemplateSpec) template); } else if (template instanceof TyperefTemplateSpec) { @@ -270,7 +270,7 @@ private TSTypeSyntax createTypeSyntax(ClassTemplateSpec template) { } else if (template instanceof FixedTemplateSpec) { return TSFixedSyntaxCreate((FixedTemplateSpec) template); } else if (template instanceof EnumTemplateSpec) { - return new TSEnumSyntax((EnumTemplateSpec) template); + return new FlowtypeEnumSyntax((EnumTemplateSpec) template); } else if (template instanceof PrimitiveTemplateSpec) { return new TSPrimitiveTypeSyntax((PrimitiveTemplateSpec) template); } else if (template instanceof MapTemplateSpec) { @@ -285,7 +285,7 @@ private TSTypeSyntax createTypeSyntax(ClassTemplateSpec template) { } /** Convenience wrapper around {@link #createTypeSyntax(ClassTemplateSpec)}. */ - private TSTypeSyntax createTypeSyntax(DataSchema schema) { + private FlowtypeTypeSyntax createTypeSyntax(DataSchema schema) { return createTypeSyntax(ClassTemplateSpec.createFromDataSchema(schema)); } @@ -295,7 +295,7 @@ private TSTypeSyntax createTypeSyntax(DataSchema schema) { * For example, a standalone union called MyUnion will just return "MyUnion". * If that same union were enclosed within MyRecord, this would return "MyRecord.MyUnion". **/ - String typeNameQualifiedByEnclosingClass(TSTypeSyntax syntax) { + String typeNameQualifiedByEnclosingClass(FlowtypeTypeSyntax syntax) { if (syntax instanceof TSEnclosedTypeSyntax) { return ((TSEnclosedTypeSyntax) syntax).typeNameQualifiedByEnclosedType(); } else { @@ -304,7 +304,7 @@ String typeNameQualifiedByEnclosingClass(TSTypeSyntax syntax) { } /** TS-specific syntax for Maps */ - private class TSMapSyntax implements TSTypeSyntax { + private class TSMapSyntax implements FlowtypeTypeSyntax { private final MapTemplateSpec _template; TSMapSyntax(MapTemplateSpec _template) { @@ -322,7 +322,7 @@ public String typeName() { // we try to just use the first one, we will return "Map". This is also why we special-case unions here. // we have to access a specific ClassTemplate boolean valueIsUnion = _template.getValueClass() instanceof UnionTemplateSpec; - TSTypeSyntax itemTypeSyntax = valueIsUnion? createTypeSyntax(_template.getValueClass()): _valueTypeSyntax(); + FlowtypeTypeSyntax itemTypeSyntax = valueIsUnion? createTypeSyntax(_template.getValueClass()): _valueTypeSyntax(); String valueTypeName = typeNameQualifiedByEnclosingClass(itemTypeSyntax); return valueTypeName == null? null: "Map<" + valueTypeName + ">"; } @@ -338,13 +338,13 @@ public Set modulesRequiredToUse() { // // Private TSMapSyntax members // - private TSTypeSyntax _valueTypeSyntax() { + private FlowtypeTypeSyntax _valueTypeSyntax() { return createTypeSyntax(_template.getSchema().getValues()); } } /** TS-specific syntax for Arrays */ - private class TSArraySyntax implements TSTypeSyntax { + private class TSArraySyntax implements FlowtypeTypeSyntax { private final ArrayTemplateSpec _template; TSArraySyntax(ArrayTemplateSpec _template) { @@ -361,7 +361,7 @@ public String typeName() { // we try to just use the first one, we will return "Array". This is also why we special-case unions here. // we have to access a specific ClassTemplate boolean itemIsUnion = _template.getItemClass() instanceof UnionTemplateSpec; - TSTypeSyntax itemTypeSyntax = itemIsUnion? createTypeSyntax(_template.getItemClass()): _itemTypeSyntax(); + FlowtypeTypeSyntax itemTypeSyntax = itemIsUnion? createTypeSyntax(_template.getItemClass()): _itemTypeSyntax(); String itemTypeName = typeNameQualifiedByEnclosingClass(itemTypeSyntax); return itemTypeName == null? null: "Array<" + itemTypeName + ">"; } @@ -374,7 +374,7 @@ public Set modulesRequiredToUse() { // // Private TSArraySyntax members // - private TSTypeSyntax _itemTypeSyntax() { + private FlowtypeTypeSyntax _itemTypeSyntax() { return createTypeSyntax(_template.getSchema().getItems()); } } @@ -394,7 +394,7 @@ private TSTypeSyntax _itemTypeSyntax() { ); /** TS-specific syntax for all primitive types: Integer, Long, Float, Double, Boolean, String, Byte. */ - private class TSPrimitiveTypeSyntax implements TSTypeSyntax { + private class TSPrimitiveTypeSyntax implements FlowtypeTypeSyntax { private final PrimitiveTemplateSpec _template; private final PrimitiveDataSchema _schema; @@ -455,7 +455,7 @@ public Set modulesRequiredToUse() { } /** TS syntax for Fixed types. */ - public class TSFixedSyntax implements TSTypeSyntax { + public class TSFixedSyntax implements FlowtypeTypeSyntax { private final FixedTemplateSpec _template; private final FlowtypeNamedTypeSyntax _namedSyntax; @@ -566,13 +566,13 @@ Set typeModules() { private DataSchema _memberSchema() { return _member.getSchema(); } - private TSTypeSyntax _memberTypeSyntax() { + private FlowtypeTypeSyntax _memberTypeSyntax() { return createTypeSyntax(_member.getSchema()); } } /** TS-specific representation of a Union type. */ - public class TSUnionSyntax implements TSTypeSyntax, TSEnclosedTypeSyntax { + public class TSUnionSyntax implements FlowtypeTypeSyntax, TSEnclosedTypeSyntax { private final UnionTemplateSpec _template; private final UnionDataSchema _schema; @@ -717,7 +717,7 @@ private boolean _isEnclosedType() { } /** The TS representation of a single field in a Record */ - public class TSRecordFieldSyntax implements TSTypeSyntax { + public class TSRecordFieldSyntax implements FlowtypeTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; private final RecordTemplateSpec.Field _field; @@ -750,7 +750,7 @@ public String typeName() { // The only problem with schemaField is that it _does_ swallow the type names for enclosed unions. ARGH // can we catch a break?? Thankfully in the case of the enclosed union it ends up returning null, so // we back off to _field.getType() if schemaField returned null. - TSTypeSyntax candidateSyntax = createTypeSyntax(_schemaField().getType()); + FlowtypeTypeSyntax candidateSyntax = createTypeSyntax(_schemaField().getType()); if (candidateSyntax.typeName() == null || "".equals(candidateSyntax)) { candidateSyntax = createTypeSyntax(_field.getType()); } @@ -787,13 +787,13 @@ public String questionMarkIfOptional() { private RecordDataSchema.Field _schemaField() { return _field.getSchemaField(); } - private TSTypeSyntax _fieldTypeSyntax() { + private FlowtypeTypeSyntax _fieldTypeSyntax() { return createTypeSyntax(_schemaField().getType()); } } /** TS-specific syntax for Records */ - public class TSRecordSyntax implements TSTypeSyntax { + public class TSRecordSyntax implements FlowtypeTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; private final FlowtypeNamedTypeSyntax _namedTypeSyntax; @@ -865,7 +865,7 @@ public String imports() { } /** Flowtype syntax for typerefs. */ - public class FlowtypeTyperefSyntax implements TSTypeSyntax { + public class FlowtypeTyperefSyntax implements FlowtypeTypeSyntax { private final TyperefTemplateSpec _template; private final TyperefDataSchema _dataSchema; private final FlowtypeNamedTypeSyntax _namedTypeSyntax; @@ -961,12 +961,12 @@ public String docString() { } /** TS syntax for enumerations. {@link TSEnumSymbolSyntax}. */ - public class TSEnumSyntax implements TSTypeSyntax { + public class FlowtypeEnumSyntax implements FlowtypeTypeSyntax { private final EnumTemplateSpec _template; private final EnumDataSchema _dataSchema; private final FlowtypeNamedTypeSyntax _namedTypeSyntax; - public TSEnumSyntax(EnumTemplateSpec _template) { + public FlowtypeEnumSyntax(EnumTemplateSpec _template) { this._template = _template; this._dataSchema = _template.getSchema(); this._namedTypeSyntax = new FlowtypeNamedTypeSyntax(_dataSchema); diff --git a/flowtype/generator/src/main/resources/rythm/enum.txt b/flowtype/generator/src/main/resources/rythm/enum.txt index 41444aac..1b2aaf05 100644 --- a/flowtype/generator/src/main/resources/rythm/enum.txt +++ b/flowtype/generator/src/main/resources/rythm/enum.txt @@ -1,4 +1,4 @@ -@args org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSyntax enumeration +@args org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeEnumSyntax enumeration // @@flow @import org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSymbolSyntax @enumeration.docString() From bd975bad3bc179ca90eb03345c7f26fd4164a6d0 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 16:48:25 -0700 Subject: [PATCH 12/23] remove flowtype-bindings --- .../courier/flowtype/FlowtypeSyntax.java | 18 +++++++++--------- .../src/main/resources/rythm/enum.txt | 5 +++-- .../src/main/resources/rythm/typeref.txt | 1 - .../expected-successes/spec/bindings.spec.ts | 2 +- .../org.coursera.customtypes.BooleanId.ts | 1 - .../org.coursera.customtypes.BoxedIntId.ts | 1 - .../org.coursera.customtypes.ByteId.ts | 1 - ...ra.customtypes.CaseClassCustomIntWrapper.ts | 1 - ...era.customtypes.CaseClassStringIdWrapper.ts | 1 - .../org.coursera.customtypes.CharId.ts | 1 - ...g.coursera.customtypes.CustomArrayTestId.ts | 1 - .../org.coursera.customtypes.CustomInt.ts | 1 - ...rg.coursera.customtypes.CustomIntWrapper.ts | 1 - ....coursera.customtypes.CustomMapTestKeyId.ts | 1 - ...oursera.customtypes.CustomMapTestValueId.ts | 1 - .../org.coursera.customtypes.CustomRecord.ts | 1 - ....coursera.customtypes.CustomRecordTestId.ts | 1 - ...g.coursera.customtypes.CustomUnionTestId.ts | 1 - .../org.coursera.customtypes.DateTime.ts | 1 - .../org.coursera.customtypes.DoubleId.ts | 1 - .../org.coursera.customtypes.FloatId.ts | 1 - .../org.coursera.customtypes.IntId.ts | 1 - .../org.coursera.customtypes.LongId.ts | 1 - .../org.coursera.customtypes.ShortId.ts | 1 - .../org.coursera.customtypes.StringId.ts | 1 - .../org.coursera.enums.EmptyEnum.ts | 3 ++- .../org.coursera.enums.EnumProperties.ts | 3 ++- .../org.coursera.enums.Fruits.ts | 3 ++- .../org.coursera.maps.Toggle.ts | 3 ++- ...org.coursera.records.test.BooleanTyperef.ts | 1 - .../org.coursera.records.test.BytesTyperef.ts | 1 - .../org.coursera.records.test.DoubleTyperef.ts | 1 - .../org.coursera.records.test.FloatTyperef.ts | 1 - .../org.coursera.records.test.IntCustomType.ts | 1 - .../org.coursera.records.test.IntTyperef.ts | 1 - .../org.coursera.records.test.LongTyperef.ts | 1 - ...sera.records.test.OptionalBooleanTyperef.ts | 1 - ...ursera.records.test.OptionalBytesTyperef.ts | 1 - ...rsera.records.test.OptionalDoubleTyperef.ts | 1 - ...ursera.records.test.OptionalFloatTyperef.ts | 1 - ...rsera.records.test.OptionalIntCustomType.ts | 1 - ...coursera.records.test.OptionalIntTyperef.ts | 1 - ...oursera.records.test.OptionalLongTyperef.ts | 1 - ...rsera.records.test.OptionalStringTyperef.ts | 1 - .../org.coursera.records.test.StringTyperef.ts | 1 - .../org.coursera.typerefs.ArrayTyperef.ts | 1 - .../org.coursera.typerefs.EnumTyperef.ts | 1 - .../org.coursera.typerefs.IntTyperef.ts | 1 - .../org.coursera.typerefs.MapTyperef.ts | 1 - .../org.coursera.typerefs.RecordTyperef.ts | 1 - .../org.coursera.unions.IntCustomType.ts | 1 - .../org.coursera.unions.IntTyperef.ts | 1 - .../org.example.MagicEightBallAnswer.ts | 3 ++- .../org.example.common.DateTime.ts | 1 - .../org.example.common.Timestamp.ts | 1 - .../org.example.other.DateTime.ts | 1 - 56 files changed, 23 insertions(+), 65 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index c38a9b52..b1aa2477 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -917,12 +917,12 @@ public FlowtypeTyperefSyntax FlowtypeTyperefSyntaxCreate(TyperefTemplateSpec tem } /** TS syntax for the symbol of an enum */ - public class TSEnumSymbolSyntax { + public class FlowtypeEnumSymbolSyntax { private final EnumTemplateSpec _template; private final EnumDataSchema _dataSchema; private final String _symbolString; - public TSEnumSymbolSyntax(EnumTemplateSpec _template, EnumDataSchema _dataSchema, String _symbolString) { + public FlowtypeEnumSymbolSyntax(EnumTemplateSpec _template, EnumDataSchema _dataSchema, String _symbolString) { this._template = _template; this._dataSchema = _dataSchema; this._symbolString = _symbolString; @@ -960,7 +960,7 @@ public String docString() { } } - /** TS syntax for enumerations. {@link TSEnumSymbolSyntax}. */ + /** TS syntax for enumerations. {@link FlowtypeEnumSymbolSyntax}. */ public class FlowtypeEnumSyntax implements FlowtypeTypeSyntax { private final EnumTemplateSpec _template; private final EnumDataSchema _dataSchema; @@ -996,7 +996,7 @@ public boolean requiresCompanionModule() { * "APPLE" | "ORANGE" **/ public String stringLiteralUnion() { - List symbols = this.symbols(); + List symbols = this.symbols(); if (symbols.size() == 0) { return "void"; // Helps us compile if some bozo declared an empty union. } else { @@ -1021,20 +1021,20 @@ public Set modulesRequiredToUse() { } /** Syntax for all the values in this enum */ - public List symbols() { - List symbols = new ArrayList<>(); + public List symbols() { + List symbols = new ArrayList<>(); for (String symbol : _dataSchema.getSymbols()) { - symbols.add(new TSEnumSymbolSyntax(_template, _dataSchema, symbol)); + symbols.add(new FlowtypeEnumSymbolSyntax(_template, _dataSchema, symbol)); } return symbols; } private String _interleaveSymbolStrings(String delimiter) { - List symbols = this.symbols(); + List symbols = this.symbols(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < symbols.size(); i++) { - TSEnumSymbolSyntax symbol = symbols.get(i); + FlowtypeEnumSymbolSyntax symbol = symbols.get(i); boolean isLast = (i + 1 == symbols.size()); sb.append(symbol.stringLiteralValue()); diff --git a/flowtype/generator/src/main/resources/rythm/enum.txt b/flowtype/generator/src/main/resources/rythm/enum.txt index 1b2aaf05..517ad125 100644 --- a/flowtype/generator/src/main/resources/rythm/enum.txt +++ b/flowtype/generator/src/main/resources/rythm/enum.txt @@ -1,5 +1,6 @@ @args org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeEnumSyntax enumeration -// @@flow -@import org.coursera.courier.flowtype.FlowtypeSyntax.TSEnumSymbolSyntax +/* @@flow */ +// This is a generated file, do not change. +@import org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeEnumSymbolSyntax @enumeration.docString() export type @enumeration.typeName() = @enumeration.stringLiteralUnion(); diff --git a/flowtype/generator/src/main/resources/rythm/typeref.txt b/flowtype/generator/src/main/resources/rythm/typeref.txt index 586cb9d2..33484983 100644 --- a/flowtype/generator/src/main/resources/rythm/typeref.txt +++ b/flowtype/generator/src/main/resources/rythm/typeref.txt @@ -3,5 +3,4 @@ @typeref.imports() @typeref.docString() -// hello export type @typeref.typeName() = @typeref.refTypeName(); diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts index 4130927d..73772da0 100644 --- a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts +++ b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts @@ -146,7 +146,7 @@ import CompilerOptions = ts.CompilerOptions; import TranspileOptions = ts.TranspileOptions; import Diagnostic = ts.Diagnostic; -const flowPragmaComment = "// @flow"; +const flowPragmaComment = "/* @flow */"; // Add a jasmine matcher that will attempt to compile a ts file and report // any compilation errors diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts index 45ebdf54..680e5f2b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts @@ -1,2 +1 @@ -// hello export type BooleanId = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts index b6d89b8b..0deffeb2 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts @@ -1,2 +1 @@ -// hello export type BoxedIntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts index 46d15863..5d9fa3b3 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts @@ -1,2 +1 @@ -// hello export type ByteId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts index dea6c84e..0674a0f3 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts @@ -1,4 +1,3 @@ import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -// hello export type CaseClassCustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts index 5c3e470f..d730ad07 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts @@ -1,4 +1,3 @@ import { StringId } from "./org.coursera.customtypes.StringId"; -// hello export type CaseClassStringIdWrapper = StringId; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts index 9f8b0443..53eebe12 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts @@ -1,2 +1 @@ -// hello export type CharId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts index 94119866..2ebdea78 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts @@ -1,2 +1 @@ -// hello export type CustomArrayTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts index 656a1ab9..fdd88ddb 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts @@ -1,2 +1 @@ -// hello export type CustomInt = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts index 0de573b1..0e0505e2 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts @@ -1,4 +1,3 @@ import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -// hello export type CustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts index f0de1c0c..ebefc23e 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts @@ -1,2 +1 @@ -// hello export type CustomMapTestKeyId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts index f5b5d4cb..f0d4cadf 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts @@ -1,2 +1 @@ -// hello export type CustomMapTestValueId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts index ce233847..8bb5154d 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts @@ -1,4 +1,3 @@ import { Message } from "./org.coursera.records.test.Message"; -// hello export type CustomRecord = Message; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts index 636b9d5b..d6d08519 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts @@ -1,2 +1 @@ -// hello export type CustomRecordTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts index 18e4d686..228db52a 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts @@ -1,2 +1 @@ -// hello export type CustomUnionTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts index eaf44636..c0dba863 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts @@ -1,2 +1 @@ -// hello export type DateTime = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts index 4e48c431..1b01067e 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts @@ -1,2 +1 @@ -// hello export type DoubleId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts index ba01a108..4ff30115 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts @@ -1,2 +1 @@ -// hello export type FloatId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts index bf0ba030..82278d55 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts @@ -1,2 +1 @@ -// hello export type IntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts index 070f9367..779f7749 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts @@ -1,2 +1 @@ -// hello export type LongId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts index 7a3cb53c..89dd3aea 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts @@ -1,2 +1 @@ -// hello export type ShortId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts index 7dd4be02..fc90a2fd 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts @@ -1,2 +1 @@ -// hello export type StringId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts index cf87f4be..052e0447 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts @@ -1,3 +1,4 @@ -// @flow +/* @flow */ +// This is a generated file, do not change. export type EmptyEnum = void; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts index 87d6e802..32ba42e7 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts @@ -1,3 +1,4 @@ -// @flow +/* @flow */ +// This is a generated file, do not change. export type EnumProperties = "APPLE" | "ORANGE" | "BANANA"; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts index d8f81f40..12a3a4a4 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts @@ -1,4 +1,5 @@ -// @flow +/* @flow */ +// This is a generated file, do not change. /** * An enum dedicated to the finest of the food groups. */ diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts index b827cbed..e91e05e1 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts @@ -1,3 +1,4 @@ -// @flow +/* @flow */ +// This is a generated file, do not change. export type Toggle = "UP" | "DOWN"; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts index 8c3a5805..c587f330 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts @@ -1,2 +1 @@ -// hello export type BooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts index 5d46f10f..5a6800cc 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts @@ -1,2 +1 @@ -// hello export type BytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts index bb2b110f..95a56e53 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts @@ -1,2 +1 @@ -// hello export type DoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts index 12198f07..2a14e394 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts @@ -1,2 +1 @@ -// hello export type FloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts index cdd9e1ff..10d347b5 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts @@ -1,2 +1 @@ -// hello export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts index d64ed25f..cc1e7a3b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts @@ -1,2 +1 @@ -// hello export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts index 5502dfa7..edfa2140 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts @@ -1,2 +1 @@ -// hello export type LongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts index 584cbaa5..c596cad7 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalBooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts index 6b5f4ebb..0848ba00 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalBytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts index 4ec641ba..c074836b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalDoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts index d40d0c8c..8d91a69a 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalFloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts index 257cbab0..64de6f02 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts @@ -1,2 +1 @@ -// hello export type OptionalIntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts index 465493c0..44f23aac 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalIntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts index dacb9121..14bfc0c2 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalLongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts index 6676ba66..2ba22764 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts @@ -1,2 +1 @@ -// hello export type OptionalStringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts index 3eed1f67..b1ce0238 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts @@ -1,2 +1 @@ -// hello export type StringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts index 70c3e511..3d64fba3 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts @@ -1,4 +1,3 @@ import { Empty } from "./org.coursera.records.test.Empty"; -// hello export type ArrayTyperef = Array; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts index 9e3cec86..a2c76b72 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts @@ -1,4 +1,3 @@ import { Fruits } from "./org.coursera.enums.Fruits"; -// hello export type EnumTyperef = Fruits; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts index d64ed25f..cc1e7a3b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts @@ -1,2 +1 @@ -// hello export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts index f3bc6f37..f0dc7fee 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts @@ -1,5 +1,4 @@ import { Map } from "./CourierRuntime"; import { Empty } from "./org.coursera.records.test.Empty"; -// hello export type MapTyperef = Map; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts index c867cc92..c1465964 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts @@ -1,4 +1,3 @@ import { Empty } from "./org.coursera.records.test.Empty"; -// hello export type RecordTyperef = Empty; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts index cdd9e1ff..10d347b5 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts @@ -1,2 +1 @@ -// hello export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts index d64ed25f..cc1e7a3b 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts @@ -1,2 +1 @@ -// hello export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts index 7e744cd9..328b6b02 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts @@ -1,4 +1,5 @@ -// @flow +/* @flow */ +// This is a generated file, do not change. /** * Magic eight ball answers. */ diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts index 493fbc63..a2ae7352 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts @@ -1,5 +1,4 @@ /** * ISO 8601 date-time. */ -// hello export type DateTime = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts index 75ff05d5..99fd474e 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts @@ -1,5 +1,4 @@ /** * A unix timestamp. */ -// hello export type Timestamp = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts index 493fbc63..a2ae7352 100644 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts +++ b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts @@ -1,5 +1,4 @@ /** * ISO 8601 date-time. */ -// hello export type DateTime = string; From d52d0e747a4b9ff7b32e80c005f6272c2105a6ac Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 16:48:49 -0700 Subject: [PATCH 13/23] remove flowtype-bindings generated --- .../flowtype-bindings/.WithoutNamespace.ts | 4 -- .../src/flowtype-bindings/CourierRuntime.ts | 20 -------- ...coursera.arrays.WithAnonymousUnionArray.ts | 48 ----------------- ...g.coursera.arrays.WithCustomArrayTestId.ts | 6 --- ...rg.coursera.arrays.WithCustomTypesArray.ts | 18 ------- ...ursera.arrays.WithCustomTypesArrayUnion.ts | 24 --------- ...org.coursera.arrays.WithPrimitivesArray.ts | 16 ------ .../org.coursera.arrays.WithRecordArray.ts | 9 ---- .../org.coursera.customtypes.BooleanId.ts | 1 - .../org.coursera.customtypes.BoxedIntId.ts | 1 - .../org.coursera.customtypes.ByteId.ts | 1 - ...a.customtypes.CaseClassCustomIntWrapper.ts | 3 -- ...ra.customtypes.CaseClassStringIdWrapper.ts | 3 -- .../org.coursera.customtypes.CharId.ts | 1 - ....coursera.customtypes.CustomArrayTestId.ts | 1 - .../org.coursera.customtypes.CustomInt.ts | 1 - ...g.coursera.customtypes.CustomIntWrapper.ts | 3 -- ...coursera.customtypes.CustomMapTestKeyId.ts | 1 - ...ursera.customtypes.CustomMapTestValueId.ts | 1 - .../org.coursera.customtypes.CustomRecord.ts | 3 -- ...coursera.customtypes.CustomRecordTestId.ts | 1 - ....coursera.customtypes.CustomUnionTestId.ts | 1 - .../org.coursera.customtypes.DateTime.ts | 1 - .../org.coursera.customtypes.DoubleId.ts | 1 - .../org.coursera.customtypes.FloatId.ts | 1 - .../org.coursera.customtypes.IntId.ts | 1 - .../org.coursera.customtypes.LongId.ts | 1 - .../org.coursera.customtypes.ShortId.ts | 1 - .../org.coursera.customtypes.StringId.ts | 1 - ...rg.coursera.deprecated.DeprecatedRecord.ts | 13 ----- .../org.coursera.enums.EmptyEnum.ts | 4 -- .../org.coursera.enums.EnumProperties.ts | 4 -- .../org.coursera.enums.Fruits.ts | 6 --- ...oursera.escaping.DefaultLiteralEscaping.ts | 4 -- .../org.coursera.escaping.KeywordEscaping.ts | 4 -- ...era.escaping.ReservedClassFieldEscaping.ts | 10 ---- .../org.coursera.escaping.class.ts | 2 - .../org.coursera.fixed.Fixed8.ts | 1 - .../org.coursera.fixed.WithFixed8.ts | 6 --- .../org.coursera.maps.Toggle.ts | 4 -- .../org.coursera.maps.WithComplexTypesMap.ts | 21 -------- ....coursera.maps.WithComplexTypesMapUnion.ts | 24 --------- .../org.coursera.maps.WithCustomMapTestIds.ts | 7 --- .../org.coursera.maps.WithCustomTypesMap.ts | 7 --- .../org.coursera.maps.WithPrimitivesMap.ts | 18 ------- .../org.coursera.maps.WithTypedKeyMap.ts | 30 ----------- .../org.coursera.records.CourierFile.ts | 4 -- .../org.coursera.records.JsonTest.ts | 2 - .../org.coursera.records.Message.ts | 6 --- .../org.coursera.records.Note.ts | 4 -- .../org.coursera.records.WithDateTime.ts | 6 --- ...oursera.records.WithFlatTypedDefinition.ts | 6 --- .../org.coursera.records.WithInclude.ts | 6 --- ...rg.coursera.records.WithTypedDefinition.ts | 6 --- .../org.coursera.records.WithUnion.ts | 6 --- .../org.coursera.records.class.ts | 4 -- ....coursera.records.primitivestyle.Simple.ts | 9 ---- ...records.primitivestyle.WithComplexTypes.ts | 16 ------ ...a.records.primitivestyle.WithPrimitives.ts | 16 ------ ...rg.coursera.records.test.BooleanTyperef.ts | 1 - .../org.coursera.records.test.BytesTyperef.ts | 1 - ...org.coursera.records.test.DoubleTyperef.ts | 1 - .../org.coursera.records.test.Empty.ts | 2 - .../org.coursera.records.test.Empty2.ts | 2 - .../org.coursera.records.test.FloatTyperef.ts | 1 - ...rsera.records.test.InlineOptionalRecord.ts | 4 -- .../org.coursera.records.test.InlineRecord.ts | 4 -- ...org.coursera.records.test.IntCustomType.ts | 1 - .../org.coursera.records.test.IntTyperef.ts | 1 - .../org.coursera.records.test.LongTyperef.ts | 1 - .../org.coursera.records.test.Message.ts | 6 --- ...g.coursera.records.test.NumericDefaults.ts | 10 ---- ...era.records.test.OptionalBooleanTyperef.ts | 1 - ...rsera.records.test.OptionalBytesTyperef.ts | 1 - ...sera.records.test.OptionalDoubleTyperef.ts | 1 - ...rsera.records.test.OptionalFloatTyperef.ts | 1 - ...sera.records.test.OptionalIntCustomType.ts | 1 - ...oursera.records.test.OptionalIntTyperef.ts | 1 - ...ursera.records.test.OptionalLongTyperef.ts | 1 - ...sera.records.test.OptionalStringTyperef.ts | 1 - ...a.records.test.RecursivelyDefinedRecord.ts | 6 --- .../org.coursera.records.test.Simple.ts | 9 ---- ...org.coursera.records.test.StringTyperef.ts | 1 - .../org.coursera.records.test.With22Fields.ts | 49 ------------------ .../org.coursera.records.test.With23Fields.ts | 51 ------------------- ...ra.records.test.WithCaseClassCustomType.ts | 46 ----------------- ...ra.records.test.WithComplexTypeDefaults.ts | 44 ---------------- ...ursera.records.test.WithComplexTyperefs.ts | 18 ------- ....coursera.records.test.WithComplexTypes.ts | 46 ----------------- ...g.coursera.records.test.WithCourierFile.ts | 6 --- ...rsera.records.test.WithCustomIntWrapper.ts | 6 --- ....coursera.records.test.WithCustomRecord.ts | 11 ---- ...era.records.test.WithCustomRecordTestId.ts | 6 --- .../org.coursera.records.test.WithDateTime.ts | 6 --- .../org.coursera.records.test.WithInclude.ts | 8 --- ....coursera.records.test.WithInlineRecord.ts | 9 ---- ...org.coursera.records.test.WithOmitField.ts | 12 ----- ...ds.test.WithOptionalComplexTypeDefaults.ts | 44 ---------------- ...a.records.test.WithOptionalComplexTypes.ts | 46 ----------------- ...est.WithOptionalComplexTypesDefaultNone.ts | 46 ----------------- ...s.test.WithOptionalPrimitiveCustomTypes.ts | 6 --- ...s.test.WithOptionalPrimitiveDefaultNone.ts | 20 -------- ...ords.test.WithOptionalPrimitiveDefaults.ts | 20 -------- ...ords.test.WithOptionalPrimitiveTyperefs.ts | 24 --------- ...era.records.test.WithOptionalPrimitives.ts | 16 ------ ...a.records.test.WithPrimitiveCustomTypes.ts | 6 --- ...sera.records.test.WithPrimitiveDefaults.ts | 20 -------- ...sera.records.test.WithPrimitiveTyperefs.ts | 24 --------- ...rg.coursera.records.test.WithPrimitives.ts | 16 ------ ....records.test.WithUnionWithInlineRecord.ts | 6 --- ...g.coursera.records.test.packaging.Empty.ts | 2 - .../org.coursera.typerefs.ArrayTyperef.ts | 3 -- .../org.coursera.typerefs.EnumTyperef.ts | 3 -- ...g.coursera.typerefs.FlatTypedDefinition.ts | 21 -------- .../org.coursera.typerefs.InlineRecord.ts | 4 -- .../org.coursera.typerefs.InlineRecord2.ts | 2 - .../org.coursera.typerefs.IntTyperef.ts | 1 - .../org.coursera.typerefs.MapTyperef.ts | 4 -- .../org.coursera.typerefs.RecordTyperef.ts | 3 -- .../org.coursera.typerefs.TypedDefinition.ts | 21 -------- .../org.coursera.typerefs.Union.ts | 21 -------- .../org.coursera.typerefs.UnionTyperef.ts | 18 ------- ...coursera.typerefs.UnionWithInlineRecord.ts | 21 -------- .../org.coursera.unions.IntCustomType.ts | 1 - .../org.coursera.unions.IntTyperef.ts | 1 - ...g.coursera.unions.WithComplexTypesUnion.ts | 38 -------------- ...g.coursera.unions.WithCustomUnionTestId.ts | 23 --------- .../org.coursera.unions.WithEmptyUnion.ts | 9 ---- ...ra.unions.WithPrimitiveCustomTypesUnion.ts | 23 --------- ...rsera.unions.WithPrimitiveTyperefsUnion.ts | 23 --------- ...org.coursera.unions.WithPrimitivesUnion.ts | 45 ---------------- ...ursera.unions.WithRecordCustomTypeUnion.ts | 23 --------- .../org.example.Apostrophe.ts | 4 -- .../flowtype-bindings/org.example.Fortune.ts | 14 ----- .../org.example.FortuneCookie.ts | 13 ----- .../org.example.FortuneTelling.ts | 25 --------- .../org.example.MagicEightBall.ts | 8 --- .../org.example.MagicEightBallAnswer.ts | 6 --- .../org.example.TyperefExample.ts | 6 --- .../org.example.common.DateTime.ts | 4 -- .../org.example.common.Timestamp.ts | 4 -- .../org.example.other.DateTime.ts | 4 -- .../flowtype-bindings/org.example.record.ts | 2 - 143 files changed, 1501 deletions(-) delete mode 100644 flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts delete mode 100644 flowtype/testsuite/src/flowtype-bindings/org.example.record.ts diff --git a/flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts b/flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts deleted file mode 100644 index 6e6ee1f9..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/.WithoutNamespace.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface WithoutNamespace { - - field1 : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts b/flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts deleted file mode 100644 index 6272d9be..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/CourierRuntime.ts +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright 2016 Coursera Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -export interface Map { - [key: string]: ValueT; -} - diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts deleted file mode 100644 index e9e2a3ee..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Map } from "./CourierRuntime"; - -export interface WithAnonymousUnionArray { - - unionsArray : Array; - - unionsMap : Map; -} -export module WithAnonymousUnionArray { - - export type UnionsMap = UnionsMap.StringMember | UnionsMap.IntMember; - export module UnionsMap { - export interface UnionsMapMember { - [key: string]: string | number; - } - export interface StringMember extends UnionsMapMember { - "string": string; - } - export interface IntMember extends UnionsMapMember { - "int": number; - } - export function unpack(union: UnionsMap) { - return { - string$: union["string"] as string, - int: union["int"] as number - }; - } - } - - export type UnionsArray = UnionsArray.IntMember | UnionsArray.StringMember; - export module UnionsArray { - export interface UnionsArrayMember { - [key: string]: number | string; - } - export interface IntMember extends UnionsArrayMember { - "int": number; - } - export interface StringMember extends UnionsArrayMember { - "string": string; - } - export function unpack(union: UnionsArray) { - return { - int: union["int"] as number, - string$: union["string"] as string - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts deleted file mode 100644 index 2c91db3e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { CustomArrayTestId } from "./org.coursera.customtypes.CustomArrayTestId"; - -export interface WithCustomArrayTestId { - - array : Array; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts deleted file mode 100644 index 5d755735..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArray.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { WithCustomTypesArrayUnion } from "./org.coursera.arrays.WithCustomTypesArrayUnion"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -import { Fixed8 } from "./org.coursera.fixed.Fixed8"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithCustomTypesArray { - - ints : Array; - - arrays : Array>; - - maps : Array>; - - unions : Array; - - fixed : Array; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts deleted file mode 100644 index 7b50c208..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Simple } from "./org.coursera.records.test.Simple"; - -export type WithCustomTypesArrayUnion = WithCustomTypesArrayUnion.IntMember | WithCustomTypesArrayUnion.StringMember | WithCustomTypesArrayUnion.SimpleMember; -export module WithCustomTypesArrayUnion { - export interface WithCustomTypesArrayUnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends WithCustomTypesArrayUnionMember { - "int": number; - } - export interface StringMember extends WithCustomTypesArrayUnionMember { - "string": string; - } - export interface SimpleMember extends WithCustomTypesArrayUnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: WithCustomTypesArrayUnion) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts deleted file mode 100644 index 621c2c60..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithPrimitivesArray.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface WithPrimitivesArray { - - ints : Array; - - longs : Array; - - floats : Array; - - doubles : Array; - - booleans : Array; - - strings : Array; - - bytes : Array; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts deleted file mode 100644 index d66573f0..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.arrays.WithRecordArray.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Empty } from "./org.coursera.records.test.Empty"; - -export interface WithRecordArray { - - empties : Array; - - fruits : Array; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts deleted file mode 100644 index 680e5f2b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BooleanId.ts +++ /dev/null @@ -1 +0,0 @@ -export type BooleanId = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts deleted file mode 100644 index 0deffeb2..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.BoxedIntId.ts +++ /dev/null @@ -1 +0,0 @@ -export type BoxedIntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts deleted file mode 100644 index 5d9fa3b3..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ByteId.ts +++ /dev/null @@ -1 +0,0 @@ -export type ByteId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts deleted file mode 100644 index 0674a0f3..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; - -export type CaseClassCustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts deleted file mode 100644 index d730ad07..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { StringId } from "./org.coursera.customtypes.StringId"; - -export type CaseClassStringIdWrapper = StringId; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts deleted file mode 100644 index 53eebe12..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CharId.ts +++ /dev/null @@ -1 +0,0 @@ -export type CharId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts deleted file mode 100644 index 2ebdea78..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomArrayTestId.ts +++ /dev/null @@ -1 +0,0 @@ -export type CustomArrayTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts deleted file mode 100644 index fdd88ddb..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomInt.ts +++ /dev/null @@ -1 +0,0 @@ -export type CustomInt = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts deleted file mode 100644 index 0e0505e2..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomIntWrapper.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; - -export type CustomIntWrapper = CustomInt; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts deleted file mode 100644 index ebefc23e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId.ts +++ /dev/null @@ -1 +0,0 @@ -export type CustomMapTestKeyId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts deleted file mode 100644 index f0d4cadf..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId.ts +++ /dev/null @@ -1 +0,0 @@ -export type CustomMapTestValueId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts deleted file mode 100644 index 8bb5154d..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecord.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Message } from "./org.coursera.records.test.Message"; - -export type CustomRecord = Message; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts deleted file mode 100644 index d6d08519..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomRecordTestId.ts +++ /dev/null @@ -1 +0,0 @@ -export type CustomRecordTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts deleted file mode 100644 index 228db52a..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.CustomUnionTestId.ts +++ /dev/null @@ -1 +0,0 @@ -export type CustomUnionTestId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts deleted file mode 100644 index c0dba863..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DateTime.ts +++ /dev/null @@ -1 +0,0 @@ -export type DateTime = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts deleted file mode 100644 index 1b01067e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.DoubleId.ts +++ /dev/null @@ -1 +0,0 @@ -export type DoubleId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts deleted file mode 100644 index 4ff30115..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.FloatId.ts +++ /dev/null @@ -1 +0,0 @@ -export type FloatId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts deleted file mode 100644 index 82278d55..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.IntId.ts +++ /dev/null @@ -1 +0,0 @@ -export type IntId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts deleted file mode 100644 index 779f7749..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.LongId.ts +++ /dev/null @@ -1 +0,0 @@ -export type LongId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts deleted file mode 100644 index 89dd3aea..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.ShortId.ts +++ /dev/null @@ -1 +0,0 @@ -export type ShortId = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts deleted file mode 100644 index fc90a2fd..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.customtypes.StringId.ts +++ /dev/null @@ -1 +0,0 @@ -export type StringId = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts deleted file mode 100644 index cd261109..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.deprecated.DeprecatedRecord.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @deprecated Use XYZ instead - */ -export interface DeprecatedRecord { - /** - * @deprecated - */ - field1 : string; - /** - * @deprecated Use XYZ instead - */ - field2 : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts deleted file mode 100644 index 052e0447..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EmptyEnum.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* @flow */ -// This is a generated file, do not change. - -export type EmptyEnum = void; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts deleted file mode 100644 index 32ba42e7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.EnumProperties.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* @flow */ -// This is a generated file, do not change. - -export type EnumProperties = "APPLE" | "ORANGE" | "BANANA"; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts deleted file mode 100644 index 12a3a4a4..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.enums.Fruits.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* @flow */ -// This is a generated file, do not change. -/** - * An enum dedicated to the finest of the food groups. - */ -export type Fruits = "APPLE" | "BANANA" | "ORANGE" | "PINEAPPLE"; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts deleted file mode 100644 index ed6126ad..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DefaultLiteralEscaping { - - stringField : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts deleted file mode 100644 index faeef575..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.KeywordEscaping.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface KeywordEscaping { - - "type" : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts deleted file mode 100644 index 8e5b0e22..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface ReservedClassFieldEscaping { - - data : string; - - schema : string; - - copy : string; - - clone : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts deleted file mode 100644 index bfe98891..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.escaping.class.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface class$ { -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts deleted file mode 100644 index 23cc5d82..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.Fixed8.ts +++ /dev/null @@ -1 +0,0 @@ -export type Fixed8 = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts deleted file mode 100644 index b1be2b66..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.fixed.WithFixed8.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Fixed8 } from "./org.coursera.fixed.Fixed8"; - -export interface WithFixed8 { - - fixed : Fixed8; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts deleted file mode 100644 index e91e05e1..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.Toggle.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* @flow */ -// This is a generated file, do not change. - -export type Toggle = "UP" | "DOWN"; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts deleted file mode 100644 index 83946d6c..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMap.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Empty } from "./org.coursera.records.test.Empty"; -import { WithComplexTypesMapUnion } from "./org.coursera.maps.WithComplexTypesMapUnion"; -import { Fixed8 } from "./org.coursera.fixed.Fixed8"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithComplexTypesMap { - - empties : Map; - - fruits : Map; - - arrays : Map>; - - maps : Map>; - - unions : Map; - - fixed : Map; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts deleted file mode 100644 index 9e45610a..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Simple } from "./org.coursera.records.test.Simple"; - -export type WithComplexTypesMapUnion = WithComplexTypesMapUnion.IntMember | WithComplexTypesMapUnion.StringMember | WithComplexTypesMapUnion.SimpleMember; -export module WithComplexTypesMapUnion { - export interface WithComplexTypesMapUnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends WithComplexTypesMapUnionMember { - "int": number; - } - export interface StringMember extends WithComplexTypesMapUnionMember { - "string": string; - } - export interface SimpleMember extends WithComplexTypesMapUnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: WithComplexTypesMapUnion) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts deleted file mode 100644 index 7c03e382..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomMapTestIds.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { CustomMapTestValueId } from "./org.coursera.customtypes.CustomMapTestValueId"; - -export interface WithCustomMapTestIds { - - map : Map; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts deleted file mode 100644 index dae0b6f7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithCustomTypesMap.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; - -export interface WithCustomTypesMap { - - ints : Map; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts deleted file mode 100644 index 2f54b79e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithPrimitivesMap.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Map } from "./CourierRuntime"; - -export interface WithPrimitivesMap { - - ints : Map; - - longs : Map; - - floats : Map; - - doubles : Map; - - booleans : Map; - - strings : Map; - - bytes : Map; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts deleted file mode 100644 index 7bb42063..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.maps.WithTypedKeyMap.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Map } from "./CourierRuntime"; - -export interface WithTypedKeyMap { - - ints : Map; - - longs : Map; - - floats : Map; - - doubles : Map; - - booleans : Map; - - strings : Map; - - bytes : Map; - - record : Map; - - array : Map; - - "enum" : Map; - - custom : Map; - - fixed : Map; - - samePackageEnum ?: Map; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts deleted file mode 100644 index 0a4db3e6..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.CourierFile.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface CourierFile { - - find : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts deleted file mode 100644 index 2a9078ec..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.JsonTest.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface JsonTest { -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts deleted file mode 100644 index fdfe4181..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Message.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Message { - - title ?: string; - - body ?: string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts deleted file mode 100644 index fd44e1ab..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.Note.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Note { - - text : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts deleted file mode 100644 index 841204d9..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithDateTime.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DateTime } from "./org.coursera.customtypes.DateTime"; - -export interface WithDateTime { - - time : DateTime; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts deleted file mode 100644 index d14f3581..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithFlatTypedDefinition.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { FlatTypedDefinition } from "./org.coursera.typerefs.FlatTypedDefinition"; - -export interface WithFlatTypedDefinition { - - value : FlatTypedDefinition; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts deleted file mode 100644 index 022dccf1..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithInclude.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface WithInclude { - - find : string; - - direct : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts deleted file mode 100644 index 441d1a3b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithTypedDefinition.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { TypedDefinition } from "./org.coursera.typerefs.TypedDefinition"; - -export interface WithTypedDefinition { - - value : TypedDefinition; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts deleted file mode 100644 index 742deaaa..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.WithUnion.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Union } from "./org.coursera.typerefs.Union"; - -export interface WithUnion { - - value : Union; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts deleted file mode 100644 index 2541bdb1..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.class.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface class$ { - - "private" : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts deleted file mode 100644 index 0075d45e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.Simple.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * A simple record - */ -export interface Simple { - /** - * A simple field - */ - message ?: string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts deleted file mode 100644 index 24411359..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface WithComplexTypes { - - intField : number; - - longField : number; - - floatField : number; - - doubleField : number; - - booleanField : boolean; - - stringField : string; - - bytesField : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts deleted file mode 100644 index fbe9e99a..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface WithPrimitives { - - intField : number; - - longField : number; - - floatField : number; - - doubleField : number; - - booleanField : boolean; - - stringField : string; - - bytesField : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts deleted file mode 100644 index c587f330..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BooleanTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type BooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts deleted file mode 100644 index 5a6800cc..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.BytesTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type BytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts deleted file mode 100644 index 95a56e53..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.DoubleTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type DoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts deleted file mode 100644 index 119d4b45..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface Empty { -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts deleted file mode 100644 index 193f531f..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Empty2.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface Empty2 { -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts deleted file mode 100644 index 2a14e394..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.FloatTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type FloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts deleted file mode 100644 index ac5e5d84..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineOptionalRecord.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface InlineOptionalRecord { - - value : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts deleted file mode 100644 index 70beb996..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.InlineRecord.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface InlineRecord { - - value : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts deleted file mode 100644 index 10d347b5..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntCustomType.ts +++ /dev/null @@ -1 +0,0 @@ -export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts deleted file mode 100644 index cc1e7a3b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.IntTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts deleted file mode 100644 index edfa2140..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.LongTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type LongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts deleted file mode 100644 index 19fe106e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Message.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Message { - - title : string; - - body : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts deleted file mode 100644 index e85ef03b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.NumericDefaults.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface NumericDefaults { - - i : number; - - l : number; - - f : number; - - d : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts deleted file mode 100644 index c596cad7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalBooleanTyperef = boolean; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts deleted file mode 100644 index 0848ba00..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalBytesTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts deleted file mode 100644 index c074836b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalDoubleTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts deleted file mode 100644 index 8d91a69a..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalFloatTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts deleted file mode 100644 index 64de6f02..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntCustomType.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalIntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts deleted file mode 100644 index 44f23aac..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalIntTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalIntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts deleted file mode 100644 index 14bfc0c2..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalLongTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalLongTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts deleted file mode 100644 index 2ba22764..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.OptionalStringTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type OptionalStringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts deleted file mode 100644 index 4ed4edf7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { RecursivelyDefinedRecord } from "./org.coursera.records.test.RecursivelyDefinedRecord"; - -export interface RecursivelyDefinedRecord { - - self ?: RecursivelyDefinedRecord; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts deleted file mode 100644 index 0075d45e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.Simple.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * A simple record - */ -export interface Simple { - /** - * A simple field - */ - message ?: string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts deleted file mode 100644 index b1ce0238..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.StringTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type StringTyperef = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts deleted file mode 100644 index 9435f46c..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With22Fields.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Scala's tuple limit is 22. Here we test the limit. - */ -export interface With22Fields { - - field1 : number; - - field2 : number; - - field3 : number; - - field4 : number; - - field5 : number; - - field6 : number; - - field7 : number; - - field8 : number; - - field9 : number; - - field10 : number; - - field11 : number; - - field12 : number; - - field13 : number; - - field14 : number; - - field15 : number; - - field16 : number; - - field17 : number; - - field18 : number; - - field19 : number; - - field20 : number; - - field21 : number; - - field22 : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts deleted file mode 100644 index 31ba78d4..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.With23Fields.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Scala's tuple limit is 22. Here we test beyond that limit. - */ -export interface With23Fields { - - field1 : number; - - field2 : number; - - field3 : number; - - field4 : number; - - field5 : number; - - field6 : number; - - field7 : number; - - field8 : number; - - field9 : number; - - field10 : number; - - field11 : number; - - field12 : number; - - field13 : number; - - field14 : number; - - field15 : number; - - field16 : number; - - field17 : number; - - field18 : number; - - field19 : number; - - field20 : number; - - field21 : number; - - field22 : number; - - field23 : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts deleted file mode 100644 index ba7af727..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { StringId } from "./org.coursera.customtypes.StringId"; -import { ByteId } from "./org.coursera.customtypes.ByteId"; -import { DoubleId } from "./org.coursera.customtypes.DoubleId"; -import { CaseClassCustomIntWrapper } from "./org.coursera.customtypes.CaseClassCustomIntWrapper"; -import { BooleanId } from "./org.coursera.customtypes.BooleanId"; -import { BoxedIntId } from "./org.coursera.customtypes.BoxedIntId"; -import { ShortId } from "./org.coursera.customtypes.ShortId"; -import { IntId } from "./org.coursera.customtypes.IntId"; -import { CharId } from "./org.coursera.customtypes.CharId"; -import { LongId } from "./org.coursera.customtypes.LongId"; -import { FloatId } from "./org.coursera.customtypes.FloatId"; -import { CaseClassStringIdWrapper } from "./org.coursera.customtypes.CaseClassStringIdWrapper"; - -export interface WithCaseClassCustomType { - - short : ShortId; - - byte : ByteId; - - char : CharId; - - int : IntId; - - long : LongId; - - float : FloatId; - - double : DoubleId; - - "string" : StringId; - - "boolean" : BooleanId; - - boxedInt : BoxedIntId; - - map : Map; - - mapKeys : Map; - - array : Array; - - chained : CaseClassStringIdWrapper; - - chainedToCoercer : CaseClassCustomIntWrapper; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts deleted file mode 100644 index 448107a7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Map } from "./CourierRuntime"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithComplexTypeDefaults { - - record : Simple; - - "enum" : Fruits; - - union : WithComplexTypeDefaults.Union; - - array : Array; - - map : Map; - - custom : CustomInt; -} -export module WithComplexTypeDefaults { - - export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; - export module Union { - export interface UnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends UnionMember { - "int": number; - } - export interface StringMember extends UnionMember { - "string": string; - } - export interface SimpleMember extends UnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: Union) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts deleted file mode 100644 index b3588fd7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTyperefs.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UnionTyperef } from "./org.coursera.typerefs.UnionTyperef"; -import { MapTyperef } from "./org.coursera.typerefs.MapTyperef"; -import { EnumTyperef } from "./org.coursera.typerefs.EnumTyperef"; -import { ArrayTyperef } from "./org.coursera.typerefs.ArrayTyperef"; -import { RecordTyperef } from "./org.coursera.typerefs.RecordTyperef"; - -export interface WithComplexTyperefs { - - "enum" : EnumTyperef; - - record : RecordTyperef; - - map : MapTyperef; - - array : ArrayTyperef; - - union : UnionTyperef; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts deleted file mode 100644 index 8bec2b5c..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithComplexTypes.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Map } from "./CourierRuntime"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithComplexTypes { - - record : Simple; - - "enum" : Fruits; - - union : WithComplexTypes.Union; - - array : Array; - - map : Map; - - complexMap : Map; - - custom : CustomInt; -} -export module WithComplexTypes { - - export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; - export module Union { - export interface UnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends UnionMember { - "int": number; - } - export interface StringMember extends UnionMember { - "string": string; - } - export interface SimpleMember extends UnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: Union) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts deleted file mode 100644 index 783236b4..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCourierFile.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { CourierFile } from "./org.coursera.records.CourierFile"; - -export interface WithCourierFile { - - courierFile : CourierFile; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts deleted file mode 100644 index c90fa0a4..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { CustomIntWrapper } from "./org.coursera.customtypes.CustomIntWrapper"; - -export interface WithCustomIntWrapper { - - wrapper : CustomIntWrapper; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts deleted file mode 100644 index bf33730d..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecord.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { CustomRecord } from "./org.coursera.customtypes.CustomRecord"; - -export interface WithCustomRecord { - - custom : CustomRecord; - - customArray : Array; - - customMap : Map; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts deleted file mode 100644 index 1899ca89..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { CustomRecordTestId } from "./org.coursera.customtypes.CustomRecordTestId"; - -export interface WithCustomRecordTestId { - - id : CustomRecordTestId; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts deleted file mode 100644 index 5ad65357..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithDateTime.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DateTime } from "./org.coursera.customtypes.DateTime"; - -export interface WithDateTime { - - createdAt : DateTime; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts deleted file mode 100644 index 799d8f30..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInclude.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface WithInclude { - /** - * A simple field - */ - message ?: string; - - direct : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts deleted file mode 100644 index adaf6b71..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithInlineRecord.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { InlineOptionalRecord } from "./org.coursera.records.test.InlineOptionalRecord"; -import { InlineRecord } from "./org.coursera.records.test.InlineRecord"; - -export interface WithInlineRecord { - - inline : InlineRecord; - - inlineOptional ?: InlineOptionalRecord; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts deleted file mode 100644 index 74c9cbc7..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOmitField.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; - -export interface WithOmitField { - - keep : number; - - omit : number; - - omitCustom : CustomInt; - - keepCustom : CustomInt; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts deleted file mode 100644 index 6c44598f..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Map } from "./CourierRuntime"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithOptionalComplexTypeDefaults { - - record ?: Simple; - - "enum" ?: Fruits; - - union ?: WithOptionalComplexTypeDefaults.Union; - - array ?: Array; - - map ?: Map; - - custom ?: CustomInt; -} -export module WithOptionalComplexTypeDefaults { - - export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; - export module Union { - export interface UnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends UnionMember { - "int": number; - } - export interface StringMember extends UnionMember { - "string": string; - } - export interface SimpleMember extends UnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: Union) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts deleted file mode 100644 index 54a7dd44..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Map } from "./CourierRuntime"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithOptionalComplexTypes { - - record ?: Simple; - - "enum" ?: Fruits; - - union ?: WithOptionalComplexTypes.Union; - - array ?: Array; - - map ?: Map; - - complexMap ?: Map; - - custom ?: CustomInt; -} -export module WithOptionalComplexTypes { - - export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; - export module Union { - export interface UnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends UnionMember { - "int": number; - } - export interface StringMember extends UnionMember { - "string": string; - } - export interface SimpleMember extends UnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: Union) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts deleted file mode 100644 index 168c39fa..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Map } from "./CourierRuntime"; -import { CustomInt } from "./org.coursera.customtypes.CustomInt"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithOptionalComplexTypesDefaultNone { - - record ?: Simple; - - "enum" ?: Fruits; - - union ?: WithOptionalComplexTypesDefaultNone.Union; - - array ?: Array; - - map ?: Map; - - complexMap ?: Map; - - custom ?: CustomInt; -} -export module WithOptionalComplexTypesDefaultNone { - - export type Union = Union.IntMember | Union.StringMember | Union.SimpleMember; - export module Union { - export interface UnionMember { - [key: string]: number | string | Simple; - } - export interface IntMember extends UnionMember { - "int": number; - } - export interface StringMember extends UnionMember { - "string": string; - } - export interface SimpleMember extends UnionMember { - "org.coursera.records.test.Simple": Simple; - } - export function unpack(union: Union) { - return { - int: union["int"] as number, - string$: union["string"] as string, - simple: union["org.coursera.records.test.Simple"] as Simple - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts deleted file mode 100644 index 7359235d..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { OptionalIntCustomType } from "./org.coursera.records.test.OptionalIntCustomType"; - -export interface WithOptionalPrimitiveCustomTypes { - - intField ?: OptionalIntCustomType; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts deleted file mode 100644 index 47c760f5..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; - -export interface WithOptionalPrimitiveDefaultNone { - - intWithDefault ?: number; - - longWithDefault ?: number; - - floatWithDefault ?: number; - - doubleWithDefault ?: number; - - booleanWithDefault ?: boolean; - - stringWithDefault ?: string; - - bytesWithDefault ?: string; - - enumWithDefault ?: Fruits; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts deleted file mode 100644 index 563787b5..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; - -export interface WithOptionalPrimitiveDefaults { - - intWithDefault ?: number; - - longWithDefault ?: number; - - floatWithDefault ?: number; - - doubleWithDefault ?: number; - - booleanWithDefault ?: boolean; - - stringWithDefault ?: string; - - bytesWithDefault ?: string; - - enumWithDefault ?: Fruits; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts deleted file mode 100644 index 79486ed9..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { OptionalBooleanTyperef } from "./org.coursera.records.test.OptionalBooleanTyperef"; -import { OptionalIntTyperef } from "./org.coursera.records.test.OptionalIntTyperef"; -import { OptionalStringTyperef } from "./org.coursera.records.test.OptionalStringTyperef"; -import { OptionalFloatTyperef } from "./org.coursera.records.test.OptionalFloatTyperef"; -import { OptionalLongTyperef } from "./org.coursera.records.test.OptionalLongTyperef"; -import { OptionalDoubleTyperef } from "./org.coursera.records.test.OptionalDoubleTyperef"; -import { OptionalBytesTyperef } from "./org.coursera.records.test.OptionalBytesTyperef"; - -export interface WithOptionalPrimitiveTyperefs { - - intField ?: OptionalIntTyperef; - - longField ?: OptionalLongTyperef; - - floatField ?: OptionalFloatTyperef; - - doubleField ?: OptionalDoubleTyperef; - - booleanField ?: OptionalBooleanTyperef; - - stringField ?: OptionalStringTyperef; - - bytesField ?: OptionalBytesTyperef; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts deleted file mode 100644 index edb7eb4c..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface WithOptionalPrimitives { - - intField ?: number; - - longField ?: number; - - floatField ?: number; - - doubleField ?: number; - - booleanField ?: boolean; - - stringField ?: string; - - bytesField ?: string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts deleted file mode 100644 index 4ad4a102..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IntCustomType } from "./org.coursera.records.test.IntCustomType"; - -export interface WithPrimitiveCustomTypes { - - intField : IntCustomType; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts deleted file mode 100644 index 6a134c73..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; - -export interface WithPrimitiveDefaults { - - intWithDefault : number; - - longWithDefault : number; - - floatWithDefault : number; - - doubleWithDefault : number; - - booleanWithDefault : boolean; - - stringWithDefault : string; - - bytesWithDefault : string; - - enumWithDefault : Fruits; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts deleted file mode 100644 index 6e16266c..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { BooleanTyperef } from "./org.coursera.records.test.BooleanTyperef"; -import { StringTyperef } from "./org.coursera.records.test.StringTyperef"; -import { BytesTyperef } from "./org.coursera.records.test.BytesTyperef"; -import { FloatTyperef } from "./org.coursera.records.test.FloatTyperef"; -import { DoubleTyperef } from "./org.coursera.records.test.DoubleTyperef"; -import { LongTyperef } from "./org.coursera.records.test.LongTyperef"; -import { IntTyperef } from "./org.coursera.records.test.IntTyperef"; - -export interface WithPrimitiveTyperefs { - - intField : IntTyperef; - - longField : LongTyperef; - - floatField : FloatTyperef; - - doubleField : DoubleTyperef; - - booleanField : BooleanTyperef; - - stringField : StringTyperef; - - bytesField : BytesTyperef; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts deleted file mode 100644 index fbe9e99a..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithPrimitives.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface WithPrimitives { - - intField : number; - - longField : number; - - floatField : number; - - doubleField : number; - - booleanField : boolean; - - stringField : string; - - bytesField : string; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts deleted file mode 100644 index a13d662f..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { UnionWithInlineRecord } from "./org.coursera.typerefs.UnionWithInlineRecord"; - -export interface WithUnionWithInlineRecord { - - value : UnionWithInlineRecord; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts deleted file mode 100644 index 119d4b45..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.records.test.packaging.Empty.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface Empty { -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts deleted file mode 100644 index 3d64fba3..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.ArrayTyperef.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Empty } from "./org.coursera.records.test.Empty"; - -export type ArrayTyperef = Array; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts deleted file mode 100644 index a2c76b72..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.EnumTyperef.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; - -export type EnumTyperef = Fruits; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts deleted file mode 100644 index d84d84cc..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Note } from "./org.coursera.records.Note"; -import { Message } from "./org.coursera.records.Message"; - -export type FlatTypedDefinition = FlatTypedDefinition.NoteMember | FlatTypedDefinition.MessageMember; -export module FlatTypedDefinition { - export interface FlatTypedDefinitionMember { - [key: string]: Note | Message; - } - export interface NoteMember extends FlatTypedDefinitionMember { - "org.coursera.records.Note": Note; - } - export interface MessageMember extends FlatTypedDefinitionMember { - "org.coursera.records.Message": Message; - } - export function unpack(union: FlatTypedDefinition) { - return { - note: union["org.coursera.records.Note"] as Note, - message: union["org.coursera.records.Message"] as Message - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts deleted file mode 100644 index 80869ea9..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface InlineRecord { - - value ?: number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts deleted file mode 100644 index c913a1ee..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.InlineRecord2.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface InlineRecord2 { -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts deleted file mode 100644 index cc1e7a3b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.IntTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts deleted file mode 100644 index f0dc7fee..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.MapTyperef.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Map } from "./CourierRuntime"; -import { Empty } from "./org.coursera.records.test.Empty"; - -export type MapTyperef = Map; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts deleted file mode 100644 index c1465964..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.RecordTyperef.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Empty } from "./org.coursera.records.test.Empty"; - -export type RecordTyperef = Empty; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts deleted file mode 100644 index b46499e5..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.TypedDefinition.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Note } from "./org.coursera.records.Note"; -import { Message } from "./org.coursera.records.Message"; - -export type TypedDefinition = TypedDefinition.NoteMember | TypedDefinition.MessageMember; -export module TypedDefinition { - export interface TypedDefinitionMember { - [key: string]: Note | Message; - } - export interface NoteMember extends TypedDefinitionMember { - "org.coursera.records.Note": Note; - } - export interface MessageMember extends TypedDefinitionMember { - "org.coursera.records.Message": Message; - } - export function unpack(union: TypedDefinition) { - return { - note: union["org.coursera.records.Note"] as Note, - message: union["org.coursera.records.Message"] as Message - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts deleted file mode 100644 index 5d917420..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.Union.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Note } from "./org.coursera.records.Note"; -import { Message } from "./org.coursera.records.Message"; - -export type Union = Union.NoteMember | Union.MessageMember; -export module Union { - export interface UnionMember { - [key: string]: Note | Message; - } - export interface NoteMember extends UnionMember { - "org.coursera.records.Note": Note; - } - export interface MessageMember extends UnionMember { - "org.coursera.records.Message": Message; - } - export function unpack(union: Union) { - return { - note: union["org.coursera.records.Note"] as Note, - message: union["org.coursera.records.Message"] as Message - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts deleted file mode 100644 index 2197e6aa..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionTyperef.ts +++ /dev/null @@ -1,18 +0,0 @@ -export type UnionTyperef = UnionTyperef.StringMember | UnionTyperef.IntMember; -export module UnionTyperef { - export interface UnionTyperefMember { - [key: string]: string | number; - } - export interface StringMember extends UnionTyperefMember { - "string": string; - } - export interface IntMember extends UnionTyperefMember { - "int": number; - } - export function unpack(union: UnionTyperef) { - return { - string$: union["string"] as string, - int: union["int"] as number - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts deleted file mode 100644 index 73024166..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { InlineRecord2 } from "./org.coursera.typerefs.InlineRecord2"; -import { InlineRecord } from "./org.coursera.typerefs.InlineRecord"; - -export type UnionWithInlineRecord = UnionWithInlineRecord.InlineRecordMember | UnionWithInlineRecord.InlineRecord2Member; -export module UnionWithInlineRecord { - export interface UnionWithInlineRecordMember { - [key: string]: InlineRecord | InlineRecord2; - } - export interface InlineRecordMember extends UnionWithInlineRecordMember { - "org.coursera.typerefs.InlineRecord": InlineRecord; - } - export interface InlineRecord2Member extends UnionWithInlineRecordMember { - "org.coursera.typerefs.InlineRecord2": InlineRecord2; - } - export function unpack(union: UnionWithInlineRecord) { - return { - inlineRecord: union["org.coursera.typerefs.InlineRecord"] as InlineRecord, - inlineRecord2: union["org.coursera.typerefs.InlineRecord2"] as InlineRecord2 - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts deleted file mode 100644 index 10d347b5..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntCustomType.ts +++ /dev/null @@ -1 +0,0 @@ -export type IntCustomType = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts deleted file mode 100644 index cc1e7a3b..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.IntTyperef.ts +++ /dev/null @@ -1 +0,0 @@ -export type IntTyperef = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts deleted file mode 100644 index c5d26034..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithComplexTypesUnion.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Fruits } from "./org.coursera.enums.Fruits"; -import { Map } from "./CourierRuntime"; -import { Empty } from "./org.coursera.records.test.Empty"; -import { Simple } from "./org.coursera.records.test.Simple"; - -export interface WithComplexTypesUnion { - - union : WithComplexTypesUnion.Union; -} -export module WithComplexTypesUnion { - - export type Union = Union.EmptyMember | Union.FruitsMember | Union.ArrayMember | Union.MapMember; - export module Union { - export interface UnionMember { - [key: string]: Empty | Fruits | Array | Map; - } - export interface EmptyMember extends UnionMember { - "org.coursera.records.test.Empty": Empty; - } - export interface FruitsMember extends UnionMember { - "org.coursera.enums.Fruits": Fruits; - } - export interface ArrayMember extends UnionMember { - "array": Array; - } - export interface MapMember extends UnionMember { - "map": Map; - } - export function unpack(union: Union) { - return { - empty: union["org.coursera.records.test.Empty"] as Empty, - fruits: union["org.coursera.enums.Fruits"] as Fruits, - arraySimple: union["array"] as Array, - mapSimple: union["map"] as Map - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts deleted file mode 100644 index fd3989fd..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithCustomUnionTestId.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { CustomUnionTestId } from "./org.coursera.customtypes.CustomUnionTestId"; - -export interface WithCustomUnionTestId { - - union : WithCustomUnionTestId.Union; -} -export module WithCustomUnionTestId { - - export type Union = Union.CustomUnionTestIdMember; - export module Union { - export interface UnionMember { - [key: string]: CustomUnionTestId; - } - export interface CustomUnionTestIdMember extends UnionMember { - "int": CustomUnionTestId; - } - export function unpack(union: Union) { - return { - customUnionTestId: union["int"] as CustomUnionTestId - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts deleted file mode 100644 index 2910c2e9..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithEmptyUnion.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface WithEmptyUnion { - - union : WithEmptyUnion.Union; -} -export module WithEmptyUnion { - - export type Union = void; - -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts deleted file mode 100644 index 90e3596e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { IntCustomType } from "./org.coursera.unions.IntCustomType"; - -export interface WithPrimitiveCustomTypesUnion { - - union : WithPrimitiveCustomTypesUnion.Union; -} -export module WithPrimitiveCustomTypesUnion { - - export type Union = Union.IntCustomTypeMember; - export module Union { - export interface UnionMember { - [key: string]: IntCustomType; - } - export interface IntCustomTypeMember extends UnionMember { - "int": IntCustomType; - } - export function unpack(union: Union) { - return { - intCustomType: union["int"] as IntCustomType - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts deleted file mode 100644 index 0071cd4a..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { IntTyperef } from "./org.coursera.unions.IntTyperef"; - -export interface WithPrimitiveTyperefsUnion { - - union : WithPrimitiveTyperefsUnion.Union; -} -export module WithPrimitiveTyperefsUnion { - - export type Union = Union.IntTyperefMember; - export module Union { - export interface UnionMember { - [key: string]: IntTyperef; - } - export interface IntTyperefMember extends UnionMember { - "int": IntTyperef; - } - export function unpack(union: Union) { - return { - intTyperef: union["int"] as IntTyperef - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts deleted file mode 100644 index bdf514cd..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithPrimitivesUnion.ts +++ /dev/null @@ -1,45 +0,0 @@ -export interface WithPrimitivesUnion { - - union : WithPrimitivesUnion.Union; -} -export module WithPrimitivesUnion { - - export type Union = Union.IntMember | Union.LongMember | Union.FloatMember | Union.DoubleMember | Union.BooleanMember | Union.StringMember | Union.BytesMember; - export module Union { - export interface UnionMember { - [key: string]: number | number | number | number | boolean | string | string; - } - export interface IntMember extends UnionMember { - "int": number; - } - export interface LongMember extends UnionMember { - "long": number; - } - export interface FloatMember extends UnionMember { - "float": number; - } - export interface DoubleMember extends UnionMember { - "double": number; - } - export interface BooleanMember extends UnionMember { - "boolean": boolean; - } - export interface StringMember extends UnionMember { - "string": string; - } - export interface BytesMember extends UnionMember { - "bytes": string; - } - export function unpack(union: Union) { - return { - int: union["int"] as number, - long: union["long"] as number, - float: union["float"] as number, - double: union["double"] as number, - boolean$: union["boolean"] as boolean, - string$: union["string"] as string, - bytes: union["bytes"] as string - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts b/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts deleted file mode 100644 index eefbe627..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { CustomRecord } from "./org.coursera.customtypes.CustomRecord"; - -export interface WithRecordCustomTypeUnion { - - union : WithRecordCustomTypeUnion.Union; -} -export module WithRecordCustomTypeUnion { - - export type Union = Union.CustomRecordMember; - export module Union { - export interface UnionMember { - [key: string]: CustomRecord; - } - export interface CustomRecordMember extends UnionMember { - "org.coursera.records.test.Message": CustomRecord; - } - export function unpack(union: Union) { - return { - customRecord: union["org.coursera.records.test.Message"] as CustomRecord - }; - } - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts deleted file mode 100644 index ca379e0d..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.Apostrophe.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Apostrophe { - - field : number; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts deleted file mode 100644 index b6a75ce3..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.Fortune.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { FortuneTelling } from "./org.example.FortuneTelling"; -import { DateTime } from "./org.example.common.DateTime"; - -/** - * A fortune. - */ -export interface Fortune { - /** - * The fortune telling. - */ - telling : FortuneTelling; - - createdAt : DateTime; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts deleted file mode 100644 index 9985e1e2..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneCookie.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * A fortune cookie. - */ -export interface FortuneCookie { - /** - * A fortune cookie message. - */ - message : string; - - certainty ?: number; - - luckyNumbers : Array; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts deleted file mode 100644 index 46fc81af..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.FortuneTelling.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { MagicEightBall } from "./org.example.MagicEightBall"; -import { FortuneCookie } from "./org.example.FortuneCookie"; - -export type FortuneTelling = FortuneTelling.FortuneCookieMember | FortuneTelling.MagicEightBallMember | FortuneTelling.StringMember; -export module FortuneTelling { - export interface FortuneTellingMember { - [key: string]: FortuneCookie | MagicEightBall | string; - } - export interface FortuneCookieMember extends FortuneTellingMember { - "org.example.FortuneCookie": FortuneCookie; - } - export interface MagicEightBallMember extends FortuneTellingMember { - "org.example.MagicEightBall": MagicEightBall; - } - export interface StringMember extends FortuneTellingMember { - "string": string; - } - export function unpack(union: FortuneTelling) { - return { - fortuneCookie: union["org.example.FortuneCookie"] as FortuneCookie, - magicEightBall: union["org.example.MagicEightBall"] as MagicEightBall, - string$: union["string"] as string - }; - } -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts deleted file mode 100644 index 93787935..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBall.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { MagicEightBallAnswer } from "./org.example.MagicEightBallAnswer"; - -export interface MagicEightBall { - - question : string; - - answer : MagicEightBallAnswer; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts deleted file mode 100644 index 328b6b02..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.MagicEightBallAnswer.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* @flow */ -// This is a generated file, do not change. -/** - * Magic eight ball answers. - */ -export type MagicEightBallAnswer = "IT_IS_CERTAIN" | "ASK_AGAIN_LATER" | "OUTLOOK_NOT_SO_GOOD"; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts deleted file mode 100644 index 7cf1cd95..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.TyperefExample.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Timestamp } from "./org.example.common.Timestamp"; - -export interface TyperefExample { - - time : Timestamp; -} diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts deleted file mode 100644 index a2ae7352..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.common.DateTime.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * ISO 8601 date-time. - */ -export type DateTime = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts deleted file mode 100644 index 99fd474e..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.common.Timestamp.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * A unix timestamp. - */ -export type Timestamp = number; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts deleted file mode 100644 index a2ae7352..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.other.DateTime.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * ISO 8601 date-time. - */ -export type DateTime = string; diff --git a/flowtype/testsuite/src/flowtype-bindings/org.example.record.ts b/flowtype/testsuite/src/flowtype-bindings/org.example.record.ts deleted file mode 100644 index 167b3f52..00000000 --- a/flowtype/testsuite/src/flowtype-bindings/org.example.record.ts +++ /dev/null @@ -1,2 +0,0 @@ -export interface record { -} From 95d511eac9a547f00183a4fc7d53fc4e77b2af25 Mon Sep 17 00:00:00 2001 From: Kyle Verhoog Date: Thu, 2 Nov 2017 17:15:07 -0700 Subject: [PATCH 14/23] Add rough union --- .../coursera/courier/FlowtypeGenerator.java | 2 +- .../courier/flowtype/FlowtypeSyntax.java | 53 ++++++++++--------- .../src/main/resources/rythm/record.txt | 4 +- .../src/main/resources/rythm/union.txt | 27 ++-------- 4 files changed, 33 insertions(+), 53 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 06f20c4a..9425c48a 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -129,7 +129,7 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { } else if (templateSpec instanceof EnumTemplateSpec) { code = engine.render("rythm/enum.txt", syntax.new FlowtypeEnumSyntax((EnumTemplateSpec) templateSpec)); } else if (templateSpec instanceof UnionTemplateSpec) { - code = engine.render("rythm/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec)); + code = engine.render("rythm/union.txt", syntax.new FlowtypeUnionSyntax((UnionTemplateSpec) templateSpec)); } else if (templateSpec instanceof TyperefTemplateSpec) { TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec; code = engine.render("rythm/typeref.txt", syntax.FlowtypeTyperefSyntaxCreate(typerefSpec)); diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index b1aa2477..f9d1403f 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -43,19 +43,22 @@ * * Most work delegates to inner classes, so you probably want to look them (linked below) * +<<<<<<< HEAD * Specifically, {@link FlowtypeEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are +======= + * Specifically, {@link TSEnumSyntax}, {@link FlowtypeUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are +>>>>>>> Add rough union * used directly to populate the templates. * * @see TSPrimitiveTypeSyntax * @see FlowtypeEnumSyntax * @see TSArraySyntax - * @see TSUnionSyntax * @see TSMapSyntax * @see FlowtypeTyperefSyntax * @see TSRecordSyntax * @see TSFixedSyntax * @see TSRecordSyntax - * @see TSUnionSyntax + * @see FlowtypeUnionSyntax */ public class FlowtypeSyntax { @@ -181,7 +184,7 @@ private static String escapeKeyword(String symbol, EscapeStrategy strategy) { **/ private static String importString(String typeName, String moduleName) { return new StringBuilder() - .append("import { ") + .append("import type { ") .append(typeName) .append(" } from \"./") .append(moduleName) @@ -278,7 +281,7 @@ private FlowtypeTypeSyntax createTypeSyntax(ClassTemplateSpec template) { } else if (template instanceof ArrayTemplateSpec) { return new TSArraySyntax((ArrayTemplateSpec) template); } else if (template instanceof UnionTemplateSpec) { - return new TSUnionSyntax((UnionTemplateSpec) template); + return new FlowtypeUnionSyntax((UnionTemplateSpec) template); } else { throw new RuntimeException("Unrecognized template spec: " + template + " with schema " + template.getSchema()); } @@ -330,8 +333,6 @@ public String typeName() { @Override public Set modulesRequiredToUse() { Set modules = new HashSet<>(); - modules.add("import { Map } from \"./CourierRuntime\";"); // Our runtime contains a typedef for Map - modules.addAll(_valueTypeSyntax().modulesRequiredToUse()); // Need the map's value type to compile code that uses this type. return modules; } @@ -486,12 +487,12 @@ public TSFixedSyntax TSFixedSyntaxCreate(FixedTemplateSpec template) { /** * TS representation of a Union type's member (e.g. the "int" in "union[int]"). */ - public class TSUnionMemberSyntax { - private final TSUnionSyntax _parentSyntax; + public class FlowtypeUnionMemberSyntax { + private final FlowtypeUnionSyntax _parentSyntax; private final UnionDataSchema _schema; private final UnionTemplateSpec.Member _member; - public TSUnionMemberSyntax(TSUnionSyntax _parentSyntax, UnionDataSchema _schema, UnionTemplateSpec.Member _member) { + public FlowtypeUnionMemberSyntax(FlowtypeUnionSyntax _parentSyntax, UnionDataSchema _schema, UnionTemplateSpec.Member _member) { this._parentSyntax = _parentSyntax; this._schema = _schema; this._member = _member; @@ -572,11 +573,11 @@ private FlowtypeTypeSyntax _memberTypeSyntax() { } /** TS-specific representation of a Union type. */ - public class TSUnionSyntax implements FlowtypeTypeSyntax, TSEnclosedTypeSyntax { + public class FlowtypeUnionSyntax implements FlowtypeTypeSyntax, TSEnclosedTypeSyntax { private final UnionTemplateSpec _template; private final UnionDataSchema _schema; - public TSUnionSyntax(UnionTemplateSpec _template) { + public FlowtypeUnionSyntax(UnionTemplateSpec _template) { this._template = _template; this._schema = _template.getSchema(); } @@ -610,7 +611,7 @@ public String imports() { // Only print out the imports for non-enclosed union types. Enclosed ones will be handled // by the enclosing record. if (!_isEnclosedType()) { - for (TSUnionMemberSyntax member: this.members()) { + for (FlowtypeUnionMemberSyntax member: this.members()) { allImports.addAll(member.typeModules()); } } @@ -652,10 +653,10 @@ public String memberBaseTypeName() { public String unionTypeExpression() { StringBuilder sb = new StringBuilder(); - List members = this.members(); + List members = this.members(); for (int i = 0; i < members.size(); i++) { boolean isLast = (i == members.size() - 1); - TSUnionMemberSyntax member = members.get(i); + FlowtypeUnionMemberSyntax member = members.get(i); sb.append(member.typeName()); if (!isLast) { @@ -673,18 +674,18 @@ public String unionTypeExpression() { * */ public String memberUnionTypeExpression() { - List members = this.members(); + List members = this.members(); if (members.isEmpty()) { return "void"; } else { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < members.size(); i++) { boolean isLast = (i == members.size() - 1); - TSUnionMemberSyntax member = members.get(i); - sb.append(member.fullUnionMemberTypeName()); + FlowtypeUnionMemberSyntax member = members.get(i); + // sb.append(member.fullUnionMemberTypeName()); + sb.append(member.typeName()); if (!isLast) { sb.append(" | "); @@ -696,11 +697,11 @@ public String memberUnionTypeExpression() { } /** Return the syntax for each member */ - public List members() { - List memberSyntax = new ArrayList<>(); + public List members() { + List memberSyntax = new ArrayList<>(); for (UnionTemplateSpec.Member member : this._template.getMembers()) { - memberSyntax.add(new TSUnionMemberSyntax(this, _schema, member)); + memberSyntax.add(new FlowtypeUnionMemberSyntax(this, _schema, member)); } return memberSyntax; @@ -818,11 +819,11 @@ public List fields() { return fields; } - public Set enclosedUnions() { - Set unions = new HashSet<>(); + public Set enclosedUnions() { + Set unions = new HashSet<>(); for (ClassTemplateSpec spec: ClassTemplateSpecs.allContainedTypes(_template)) { if (spec instanceof UnionTemplateSpec) { - unions.add(new TSUnionSyntax((UnionTemplateSpec) spec)); + unions.add(new FlowtypeUnionSyntax((UnionTemplateSpec) spec)); } } @@ -854,8 +855,8 @@ public String imports() { imports.addAll(fieldSyntax.typeModules()); } - for (TSUnionSyntax union: this.enclosedUnions()) { - for (TSUnionMemberSyntax unionMember: union.members()) { + for (FlowtypeUnionSyntax union: this.enclosedUnions()) { + for (FlowtypeUnionMemberSyntax unionMember: union.members()) { imports.addAll(unionMember.typeModules()); } } diff --git a/flowtype/generator/src/main/resources/rythm/record.txt b/flowtype/generator/src/main/resources/rythm/record.txt index a1cb1ad5..e5e6768d 100644 --- a/flowtype/generator/src/main/resources/rythm/record.txt +++ b/flowtype/generator/src/main/resources/rythm/record.txt @@ -1,5 +1,5 @@ @args org.coursera.courier.flowtype.FlowtypeSyntax.TSRecordSyntax record -@import org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionSyntax +@import org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeUnionSyntax @import org.coursera.courier.flowtype.FlowtypeSyntax.TSRecordFieldSyntax @record.imports() @@ -14,7 +14,7 @@ export interface @record.typeName() { @if(record.requiresCompanionModule()) { export module @record.typeName() { - @for(TSUnionSyntax union: record.enclosedUnions()) { + @for(FlowtypeUnionSyntax union: record.enclosedUnions()) { @union(union) } } diff --git a/flowtype/generator/src/main/resources/rythm/union.txt b/flowtype/generator/src/main/resources/rythm/union.txt index 412fd310..271ae1cd 100644 --- a/flowtype/generator/src/main/resources/rythm/union.txt +++ b/flowtype/generator/src/main/resources/rythm/union.txt @@ -1,28 +1,7 @@ -@args org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionSyntax union -@import org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionSyntax -@import org.coursera.courier.flowtype.FlowtypeSyntax.TSUnionMemberSyntax - +@args org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeUnionSyntax union +@import org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeUnionSyntax +@import org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeUnionMemberSyntax @union.imports() @union.docString() export type @union.typeName() = @union.memberUnionTypeExpression(); -@if(union.requiresCompanionModule()) { - export module @union.typeName() { - export interface @union.memberBaseTypeName() { - [key: string]: @union.unionTypeExpression(); - } - - @for(TSUnionMemberSyntax member: union.members()) { - export interface @member.unionMemberTypeName() extends @union.memberBaseTypeName() { - "@member.unionMemberKey()": @member.typeName(); - } - } - export function unpack(union: @union.typeName()) { - return { - @for(TSUnionMemberSyntax member: union.members()) { - @member.unpackString(): union["@member.unionMemberKey()"] as @(member.typeName())@if(!member_isLast){,} - } - }; - } - } -} From 221eb916bcb5e07d0d4bb47c7f7bac188e69df90 Mon Sep 17 00:00:00 2001 From: kyle-verhoog Date: Thu, 2 Nov 2017 17:49:55 -0700 Subject: [PATCH 15/23] Change file extension, add flow annotation and warning --- .../coursera/courier/FlowtypeGenerator.java | 44 +++++++++---------- .../src/main/resources/rythm/enum.txt | 3 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 9425c48a..24c74fe1 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -45,17 +45,18 @@ */ public class FlowtypeGenerator implements PegasusCodeGenerator { private static final FlowtypeProperties.Optionality defaultOptionality = - FlowtypeProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; + FlowtypeProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; + + private static final String flowCodeHeader = + "// @flow\n// WARNING: This is a generated file, do NOT modify."; private final GlobalConfig globalConfig; private final RythmEngine engine; public static void main(String[] args) throws Throwable { - // TODO(jbetz): use a CLI parser library - if (args.length < 3 || args.length > 5) { throw new IllegalArgumentException( - "Usage: targetPath resolverPath1[:resolverPath2]+ sourcePath1[:sourcePath2]+ [REQUIRED_FIELDS_MAY_BE_ABSENT|STRICT] [EQUATABLE]"); + "Usage: targetPath resolverPath1[:resolverPath2]+ sourcePath1[:sourcePath2]+ [REQUIRED_FIELDS_MAY_BE_ABSENT|STRICT] [EQUATABLE]"); } String targetPath = args[0]; String resolverPath = args[1]; @@ -76,11 +77,11 @@ public static void main(String[] args) throws Throwable { } GeneratorRunnerOptions options = - new GeneratorRunnerOptions(targetPath, sourcePaths, resolverPath); + new GeneratorRunnerOptions(targetPath, sourcePaths, resolverPath); GlobalConfig globalConfig = new GlobalConfig(optionality, equatable, false); GeneratorResult result = - new DefaultGeneratorRunner().run(new FlowtypeGenerator(globalConfig), options); + new DefaultGeneratorRunner().run(new FlowtypeGenerator(globalConfig), options); for (File file: result.getTargetFiles()) { System.out.println(file.getAbsolutePath()); @@ -92,9 +93,9 @@ public static void main(String[] args) throws Throwable { public FlowtypeGenerator() { this(new GlobalConfig( - defaultOptionality, - false, - false)); + defaultOptionality, + false, + false)); } public FlowtypeGenerator(GlobalConfig globalConfig) { @@ -104,47 +105,46 @@ public FlowtypeGenerator(GlobalConfig globalConfig) { } public static class TSCompilationUnit extends GeneratedCodeTargetFile { - public TSCompilationUnit(String name, String namespace) { - super(name, namespace, "ts"); + public TSCompilationUnit(String name, String namespace){ + super(name, namespace, "flow.js"); } } private static final PoorMansCStyleSourceFormatter formatter = - new PoorMansCStyleSourceFormatter(2, DocCommentStyle.ASTRISK_MARGIN); + new PoorMansCStyleSourceFormatter(2, DocCommentStyle.ASTRISK_MARGIN); /** * See {@link org.coursera.courier.tslite.FlowtypeProperties} for customization options. */ @Override public GeneratedCode generate(ClassTemplateSpec templateSpec) { - - String code; + String code = this.flowCodeHeader; FlowtypeProperties FlowtypeProperties = globalConfig.lookupFlowtypeProperties(templateSpec); if (FlowtypeProperties.omit) return null; FlowtypeSyntax syntax = new FlowtypeSyntax(FlowtypeProperties); try { if (templateSpec instanceof RecordTemplateSpec) { - code = engine.render("rythm/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); + code += engine.render("rythm/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); } else if (templateSpec instanceof EnumTemplateSpec) { - code = engine.render("rythm/enum.txt", syntax.new FlowtypeEnumSyntax((EnumTemplateSpec) templateSpec)); + code += engine.render("rythm/enum.txt", syntax.new FlowtypeEnumSyntax((EnumTemplateSpec) templateSpec)); } else if (templateSpec instanceof UnionTemplateSpec) { - code = engine.render("rythm/union.txt", syntax.new FlowtypeUnionSyntax((UnionTemplateSpec) templateSpec)); + code += engine.render("rythm/union.txt", syntax.new FlowtypeUnionSyntax((UnionTemplateSpec) templateSpec)); } else if (templateSpec instanceof TyperefTemplateSpec) { TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec; - code = engine.render("rythm/typeref.txt", syntax.FlowtypeTyperefSyntaxCreate(typerefSpec)); + code += engine.render("rythm/typeref.txt", syntax.FlowtypeTyperefSyntaxCreate(typerefSpec)); } else if (templateSpec instanceof FixedTemplateSpec) { - code = engine.render("rythm/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec)); + code += engine.render("rythm/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec)); } else { return null; // Indicates that we are declining to generate code for the type (e.g. map or array) } } catch (RythmException e) { throw new RuntimeException( - "Internal error in generator while processing " + templateSpec.getFullName(), e); + "Internal error in generator while processing " + templateSpec.getFullName(), e); } TSCompilationUnit compilationUnit = - new TSCompilationUnit( - templateSpec.getFullName(), ""); + new TSCompilationUnit( + templateSpec.getFullName(), ""); code = formatter.format(code); return new GeneratedCode(compilationUnit, code); } diff --git a/flowtype/generator/src/main/resources/rythm/enum.txt b/flowtype/generator/src/main/resources/rythm/enum.txt index 517ad125..f204448d 100644 --- a/flowtype/generator/src/main/resources/rythm/enum.txt +++ b/flowtype/generator/src/main/resources/rythm/enum.txt @@ -1,6 +1,5 @@ @args org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeEnumSyntax enumeration -/* @@flow */ -// This is a generated file, do not change. + @import org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeEnumSymbolSyntax @enumeration.docString() export type @enumeration.typeName() = @enumeration.stringLiteralUnion(); From 4f5ff06b3b9bd54a2c3fcc8b23e420dedc494433 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 17:50:02 -0700 Subject: [PATCH 16/23] update record flowtype --- .../coursera/courier/FlowtypeGenerator.java | 2 +- .../courier/flowtype/FlowtypeSyntax.java | 30 +++++++++---------- .../src/main/resources/rythm/record.txt | 18 ++++------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 9425c48a..c5451f38 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -125,7 +125,7 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { FlowtypeSyntax syntax = new FlowtypeSyntax(FlowtypeProperties); try { if (templateSpec instanceof RecordTemplateSpec) { - code = engine.render("rythm/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec)); + code = engine.render("rythm/record.txt", syntax.new FlowtypeRecordSyntax((RecordTemplateSpec) templateSpec)); } else if (templateSpec instanceof EnumTemplateSpec) { code = engine.render("rythm/enum.txt", syntax.new FlowtypeEnumSyntax((EnumTemplateSpec) templateSpec)); } else if (templateSpec instanceof UnionTemplateSpec) { diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index f9d1403f..529641c7 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -44,9 +44,9 @@ * Most work delegates to inner classes, so you probably want to look them (linked below) * <<<<<<< HEAD - * Specifically, {@link FlowtypeEnumSyntax}, {@link TSUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are + * Specifically, {@link FlowtypeEnumSyntax}, {@link TSUnionSyntax}, {@link FlowtypeRecordSyntax}, and {@link FlowtypeTyperefSyntax} are ======= - * Specifically, {@link TSEnumSyntax}, {@link FlowtypeUnionSyntax}, {@link TSRecordSyntax}, and {@link FlowtypeTyperefSyntax} are + * Specifically, {@link TSEnumSyntax}, {@link FlowtypeUnionSyntax}, {@link FlowtypeRecordSyntax}, and {@link FlowtypeTyperefSyntax} are >>>>>>> Add rough union * used directly to populate the templates. * @@ -55,9 +55,9 @@ * @see TSArraySyntax * @see TSMapSyntax * @see FlowtypeTyperefSyntax - * @see TSRecordSyntax + * @see FlowtypeRecordSyntax * @see TSFixedSyntax - * @see TSRecordSyntax + * @see FlowtypeRecordSyntax * @see FlowtypeUnionSyntax */ public class FlowtypeSyntax { @@ -267,7 +267,7 @@ private interface TSEnclosedTypeSyntax { */ private FlowtypeTypeSyntax createTypeSyntax(ClassTemplateSpec template) { if (template instanceof RecordTemplateSpec) { - return new TSRecordSyntax((RecordTemplateSpec) template); + return new FlowtypeRecordSyntax((RecordTemplateSpec) template); } else if (template instanceof TyperefTemplateSpec) { return FlowtypeTyperefSyntaxCreate((TyperefTemplateSpec) template); } else if (template instanceof FixedTemplateSpec) { @@ -317,7 +317,7 @@ private class TSMapSyntax implements FlowtypeTypeSyntax { @Override public String typeName() { // (This comment is duplicated from TSArraySyntax.typeName for your benefit) - // Sadly the behavior of this function is indirectly controlled by the one calling it: TSRecordFieldSyntax. + // Sadly the behavior of this function is indirectly controlled by the one calling it: FlowRecordFieldSyntax. // That class has the unfortunate behavior that it can produce 2 different ClassTemplateSpecs, one of which works for // some cases, and one of which works for the others. See its own "typeName" definition for details but essentially // it will give us one of the ClassTemplateSpecs and call typeName. If we then return null @@ -354,7 +354,7 @@ private class TSArraySyntax implements FlowtypeTypeSyntax { @Override public String typeName() { - // Sadly the behavior of this function is indirectly controlled by the one calling it: TSRecordFieldSyntax. + // Sadly the behavior of this function is indirectly controlled by the one calling it: FlowRecordFieldSyntax. // That class has the unfortunate behavior that it can produce 2 different ClassTemplateSpecs, one of which works for // some cases, and one of which works for the others. See its own "typeName" definition for details but essentially // it will give us one of the ClassTemplateSpecs and call typeName. If we then return null @@ -718,12 +718,12 @@ private boolean _isEnclosedType() { } /** The TS representation of a single field in a Record */ - public class TSRecordFieldSyntax implements FlowtypeTypeSyntax { + public class FlowRecordFieldSyntax implements FlowtypeTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; private final RecordTemplateSpec.Field _field; - public TSRecordFieldSyntax(RecordTemplateSpec _template, RecordTemplateSpec.Field _field) { + public FlowRecordFieldSyntax(RecordTemplateSpec _template, RecordTemplateSpec.Field _field) { this._template = _template; this._schema = _template.getSchema(); this._field = _field; @@ -794,12 +794,12 @@ private FlowtypeTypeSyntax _fieldTypeSyntax() { } /** TS-specific syntax for Records */ - public class TSRecordSyntax implements FlowtypeTypeSyntax { + public class FlowtypeRecordSyntax implements FlowtypeTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; private final FlowtypeNamedTypeSyntax _namedTypeSyntax; - public TSRecordSyntax(RecordTemplateSpec _template) { + public FlowtypeRecordSyntax(RecordTemplateSpec _template) { this._template = _template; this._schema = _template.getSchema(); this._namedTypeSyntax = new FlowtypeNamedTypeSyntax(_schema); @@ -809,11 +809,11 @@ public String docString() { return _namedTypeSyntax.docString(); } - public List fields() { - List fields = new ArrayList<>(); + public List fields() { + List fields = new ArrayList<>(); for (RecordTemplateSpec.Field fieldSpec: _template.getFields()) { - fields.add(new TSRecordFieldSyntax(_template, fieldSpec)); + fields.add(new FlowRecordFieldSyntax(_template, fieldSpec)); } return fields; @@ -851,7 +851,7 @@ public boolean requiresCompanionModule() { public String imports() { Set imports = new HashSet<>(); - for (TSRecordFieldSyntax fieldSyntax: this.fields()) { + for (FlowRecordFieldSyntax fieldSyntax: this.fields()) { imports.addAll(fieldSyntax.typeModules()); } diff --git a/flowtype/generator/src/main/resources/rythm/record.txt b/flowtype/generator/src/main/resources/rythm/record.txt index e5e6768d..ee768f0c 100644 --- a/flowtype/generator/src/main/resources/rythm/record.txt +++ b/flowtype/generator/src/main/resources/rythm/record.txt @@ -1,21 +1,13 @@ -@args org.coursera.courier.flowtype.FlowtypeSyntax.TSRecordSyntax record +@args org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeRecordSyntax record @import org.coursera.courier.flowtype.FlowtypeSyntax.FlowtypeUnionSyntax -@import org.coursera.courier.flowtype.FlowtypeSyntax.TSRecordFieldSyntax +@import org.coursera.courier.flowtype.FlowtypeSyntax.FlowRecordFieldSyntax @record.imports() @record.docString() -export interface @record.typeName() { - @for(TSRecordFieldSyntax field: record.fields()) { +export type @record.typeName() = { + @for(FlowRecordFieldSyntax field: record.fields()) { @field.docString() @field.accessorName() @field.questionMarkIfOptional(): @field.typeName(); } -} - -@if(record.requiresCompanionModule()) { - export module @record.typeName() { - @for(FlowtypeUnionSyntax union: record.enclosedUnions()) { - @union(union) - } - } -} +} \ No newline at end of file From 72d705b15098b5b512534f05dec62a823752d257 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 17:57:27 -0700 Subject: [PATCH 17/23] fix the typo --- .../src/main/java/org/coursera/courier/FlowtypeGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 69e3bb69..44dede80 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -125,7 +125,7 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { FlowtypeSyntax syntax = new FlowtypeSyntax(FlowtypeProperties); try { if (templateSpec instanceof RecordTemplateSpec) { - code = engine.render("rythm/record.txt", syntax.new FlowtypeRecordSyntax((RecordTemplateSpec) templateSpec)); + code += engine.render("rythm/record.txt", syntax.new FlowtypeRecordSyntax((RecordTemplateSpec) templateSpec)); } else if (templateSpec instanceof EnumTemplateSpec) { code += engine.render("rythm/enum.txt", syntax.new FlowtypeEnumSyntax((EnumTemplateSpec) templateSpec)); } else if (templateSpec instanceof UnionTemplateSpec) { From 2556a5337edad5c51bd1fdadfbcad978db551f23 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Thu, 2 Nov 2017 18:11:33 -0700 Subject: [PATCH 18/23] commit my stuff --- .../coursera/courier/FlowtypeGenerator.java | 10 +- .../expected-successes/spec/bindings.spec.js | 650 ++++++++++++++++++ .../expected-successes/spec/bindings.spec.ts | 650 ------------------ 3 files changed, 655 insertions(+), 655 deletions(-) create mode 100644 flowtype/testsuite/src/expected-successes/spec/bindings.spec.js delete mode 100644 flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index 44dede80..bbabc70d 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -48,7 +48,7 @@ public class FlowtypeGenerator implements PegasusCodeGenerator { FlowtypeProperties.Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT; private static final String flowCodeHeader = - "// @flow\n// WARNING: This is a generated file, do NOT modify."; + "// @flow\n// WARNING: This is a generated file, do NOT modify.\n"; private final GlobalConfig globalConfig; private final RythmEngine engine; @@ -104,8 +104,8 @@ public FlowtypeGenerator(GlobalConfig globalConfig) { this.engine.registerResourceLoader(new ClasspathResourceLoader(engine, "/")); } - public static class TSCompilationUnit extends GeneratedCodeTargetFile { - public TSCompilationUnit(String name, String namespace){ + public static class FlowCompilationUnit extends GeneratedCodeTargetFile { + public FlowCompilationUnit(String name, String namespace){ super(name, namespace, "flow.js"); } } @@ -142,8 +142,8 @@ public GeneratedCode generate(ClassTemplateSpec templateSpec) { throw new RuntimeException( "Internal error in generator while processing " + templateSpec.getFullName(), e); } - TSCompilationUnit compilationUnit = - new TSCompilationUnit( + FlowCompilationUnit compilationUnit = + new FlowCompilationUnit( templateSpec.getFullName(), ""); code = formatter.format(code); return new GeneratedCode(compilationUnit, code); diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js new file mode 100644 index 00000000..74e88748 --- /dev/null +++ b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js @@ -0,0 +1,650 @@ +import type { WithoutNamespace } from "../flowtype-bindings/.WithoutNamespace"; +import type { Map } from "../flowtype-bindings/CourierRuntime"; +import type { WithCustomArrayTestId } from "../flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId"; +import type { WithCustomTypesArray } from "../flowtype-bindings/org.coursera.arrays.WithCustomTypesArray"; +import type { WithCustomTypesArrayUnion } from "../flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion"; +import type { WithPrimitivesArray } from "../flowtype-bindings/org.coursera.arrays.WithPrimitivesArray"; +import type { WithRecordArray } from "../flowtype-bindings/org.coursera.arrays.WithRecordArray"; +import type { BooleanId } from "../flowtype-bindings/org.coursera.customtypes.BooleanId"; +import type { BoxedIntId } from "../flowtype-bindings/org.coursera.customtypes.BoxedIntId"; +import type { ByteId } from "../flowtype-bindings/org.coursera.customtypes.ByteId"; +import type { CaseClassCustomIntWrapper } from "../flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper"; +import type { CaseClassStringIdWrapper } from "../flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper"; +import type { CharId } from "../flowtype-bindings/org.coursera.customtypes.CharId"; +import type { CustomArrayTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomArrayTestId"; +import type { CustomInt } from "../flowtype-bindings/org.coursera.customtypes.CustomInt"; +import type { CustomIntWrapper } from "../flowtype-bindings/org.coursera.customtypes.CustomIntWrapper"; +import type { CustomMapTestKeyId } from "../flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId"; +import type { CustomMapTestValueId } from "../flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId"; +import type { CustomRecord } from "../flowtype-bindings/org.coursera.customtypes.CustomRecord"; +import type { CustomRecordTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomRecordTestId"; +import type { CustomUnionTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomUnionTestId"; +import type { DateTime } from "../flowtype-bindings/org.coursera.customtypes.DateTime"; +import type { DoubleId } from "../flowtype-bindings/org.coursera.customtypes.DoubleId"; +import type { FloatId } from "../flowtype-bindings/org.coursera.customtypes.FloatId"; +import type { IntId } from "../flowtype-bindings/org.coursera.customtypes.IntId"; +import type { LongId } from "../flowtype-bindings/org.coursera.customtypes.LongId"; +import type { ShortId } from "../flowtype-bindings/org.coursera.customtypes.ShortId"; +import type { StringId } from "../flowtype-bindings/org.coursera.customtypes.StringId"; +import type { DeprecatedRecord } from "../flowtype-bindings/org.coursera.deprecated.DeprecatedRecord"; +import type { EmptyEnum } from "../flowtype-bindings/org.coursera.enums.EmptyEnum"; +import type { EnumProperties } from "../flowtype-bindings/org.coursera.enums.EnumProperties"; +import type { Fruits } from "../flowtype-bindings/org.coursera.enums.Fruits"; +import type { DefaultLiteralEscaping } from "../flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping"; +import type { KeywordEscaping } from "../flowtype-bindings/org.coursera.escaping.KeywordEscaping"; +import type { ReservedClassFieldEscaping } from "../flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping"; +import type { class$ } from "../flowtype-bindings/org.coursera.escaping.class"; +import type { WithFixed8 } from "../flowtype-bindings/org.coursera.fixed.WithFixed8"; +import type { Toggle } from "../flowtype-bindings/org.coursera.maps.Toggle"; +import type { WithComplexTypesMap } from "../flowtype-bindings/org.coursera.maps.WithComplexTypesMap"; +import type { WithComplexTypesMapUnion } from "../flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion"; +import type { WithCustomMapTestIds } from "../flowtype-bindings/org.coursera.maps.WithCustomMapTestIds"; +import type { WithCustomTypesMap } from "../flowtype-bindings/org.coursera.maps.WithCustomTypesMap"; +import type { WithPrimitivesMap } from "../flowtype-bindings/org.coursera.maps.WithPrimitivesMap"; +import type { WithTypedKeyMap } from "../flowtype-bindings/org.coursera.maps.WithTypedKeyMap"; +import type { CourierFile } from "../flowtype-bindings/org.coursera.records.CourierFile"; +import type { JsonTest } from "../flowtype-bindings/org.coursera.records.JsonTest"; +import type { Message } from "../flowtype-bindings/org.coursera.records.Message"; +import type { WithAnonymousUnionArray } from "../flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray"; +import type { Note } from "../flowtype-bindings/org.coursera.records.Note"; +import type { WithDateTime } from "../flowtype-bindings/org.coursera.records.WithDateTime"; +import type { WithFlatTypedDefinition } from "../flowtype-bindings/org.coursera.records.WithFlatTypedDefinition"; +import type { WithInclude } from "../flowtype-bindings/org.coursera.records.WithInclude"; +import type { WithTypedDefinition } from "../flowtype-bindings/org.coursera.records.WithTypedDefinition"; +import type { WithUnion } from "../flowtype-bindings/org.coursera.records.WithUnion"; +import type { Fixed8 } from "../flowtype-bindings/org.coursera.fixed.Fixed8"; +import type { class$ as EscapedClassRecord} from "../flowtype-bindings/org.coursera.records.class"; +import type { Simple } from "../flowtype-bindings/org.coursera.records.primitivestyle.Simple"; +import type { WithComplexTypes } from "../flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes"; +import type { WithPrimitives } from "../flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives"; +import type { BooleanTyperef } from "../flowtype-bindings/org.coursera.records.test.BooleanTyperef"; +import type { BytesTyperef } from "../flowtype-bindings/org.coursera.records.test.BytesTyperef"; +import type { DoubleTyperef } from "../flowtype-bindings/org.coursera.records.test.DoubleTyperef"; +import type { Empty } from "../flowtype-bindings/org.coursera.records.test.Empty"; +import type { FloatTyperef } from "../flowtype-bindings/org.coursera.records.test.FloatTyperef"; +import type { InlineOptionalRecord } from "../flowtype-bindings/org.coursera.records.test.InlineOptionalRecord"; +import type { InlineRecord } from "../flowtype-bindings/org.coursera.records.test.InlineRecord"; +import type { IntCustomType as TestIntCustomType } from "../flowtype-bindings/org.coursera.records.test.IntCustomType"; +import type { IntTyperef as TestIntTyperef } from "../flowtype-bindings/org.coursera.records.test.IntTyperef"; +import type { LongTyperef } from "../flowtype-bindings/org.coursera.records.test.LongTyperef"; +import type { Message as TestMessage } from "../flowtype-bindings/org.coursera.records.test.Message"; +import type { NumericDefaults } from "../flowtype-bindings/org.coursera.records.test.NumericDefaults"; +import type { OptionalBooleanTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef"; +import type { OptionalBytesTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef"; +import type { OptionalDoubleTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef"; +import type { OptionalFloatTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef"; +import type { OptionalIntCustomType } from "../flowtype-bindings/org.coursera.records.test.OptionalIntCustomType"; +import type { OptionalIntTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalIntTyperef"; +import type { OptionalLongTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalLongTyperef"; +import type { OptionalStringTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalStringTyperef"; +import type { RecursivelyDefinedRecord } from "../flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord"; +import type { Simple as TestSimple } from "../flowtype-bindings/org.coursera.records.test.Simple"; +import type { StringTyperef } from "../flowtype-bindings/org.coursera.records.test.StringTyperef"; +import type { With22Fields } from "../flowtype-bindings/org.coursera.records.test.With22Fields"; +import type { With23Fields } from "../flowtype-bindings/org.coursera.records.test.With23Fields"; +import type { WithCaseClassCustomType } from "../flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType"; +import type { WithComplexTypeDefaults } from "../flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults"; +import type { WithComplexTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithComplexTyperefs"; +import type { WithComplexTypes as TestWithComplexTypes } from "../flowtype-bindings/org.coursera.records.test.WithComplexTypes"; +import type { WithCourierFile } from "../flowtype-bindings/org.coursera.records.test.WithCourierFile"; +import type { WithCustomIntWrapper } from "../flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper"; +import type { WithCustomRecord } from "../flowtype-bindings/org.coursera.records.test.WithCustomRecord"; +import type { WithCustomRecordTestId } from "../flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId"; +import type { WithDateTime as TestWithDateTime } from "../flowtype-bindings/org.coursera.records.test.WithDateTime"; +import type { WithInclude as TestWithInclude } from "../flowtype-bindings/org.coursera.records.test.WithInclude"; +import type { WithInlineRecord } from "../flowtype-bindings/org.coursera.records.test.WithInlineRecord"; +import type { WithOmitField } from "../flowtype-bindings/org.coursera.records.test.WithOmitField"; +import type { WithOptionalComplexTypeDefaults } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults"; +import type { WithOptionalComplexTypes } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes"; +import type { WithOptionalComplexTypesDefaultNone } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone"; +import type { WithOptionalPrimitiveCustomTypes } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes"; +import type { WithOptionalPrimitiveDefaultNone } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone"; +import type { WithOptionalPrimitiveDefaults } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults"; +import type { WithOptionalPrimitiveTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs"; +import type { WithOptionalPrimitives } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives"; +import type { WithPrimitiveCustomTypes } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes"; +import type { WithPrimitiveDefaults } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults"; +import type { WithPrimitiveTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs"; +import type { WithPrimitives as TestWithPrimitives } from "../flowtype-bindings/org.coursera.records.test.WithPrimitives"; +import type { WithUnionWithInlineRecord } from "../flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord"; +import type { ArrayTyperef } from "../flowtype-bindings/org.coursera.typerefs.ArrayTyperef"; +import type { EnumTyperef } from "../flowtype-bindings/org.coursera.typerefs.EnumTyperef"; +import type { FlatTypedDefinition } from "../flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition"; +import type { InlineRecord as InlineRecordTypeRef } from "../flowtype-bindings/org.coursera.typerefs.InlineRecord"; +import type { InlineRecord2 } from "../flowtype-bindings/org.coursera.typerefs.InlineRecord2"; +import type { IntTyperef } from "../flowtype-bindings/org.coursera.typerefs.IntTyperef"; +import type { MapTyperef } from "../flowtype-bindings/org.coursera.typerefs.MapTyperef"; +import type { RecordTyperef } from "../flowtype-bindings/org.coursera.typerefs.RecordTyperef"; +import type { TypedDefinition } from "../flowtype-bindings/org.coursera.typerefs.TypedDefinition"; +import type { Union } from "../flowtype-bindings/org.coursera.typerefs.Union"; +import type { UnionTyperef } from "../flowtype-bindings/org.coursera.typerefs.UnionTyperef"; +import type { UnionWithInlineRecord } from "../flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord"; +import type { IntCustomType } from "../flowtype-bindings/org.coursera.unions.IntCustomType"; +import type { IntTyperef as IntTyperefUnion} from "../flowtype-bindings/org.coursera.unions.IntTyperef"; +import type { WithComplexTypesUnion } from "../flowtype-bindings/org.coursera.unions.WithComplexTypesUnion"; +import type { WithCustomUnionTestId } from "../flowtype-bindings/org.coursera.unions.WithCustomUnionTestId"; +import type { WithEmptyUnion } from "../flowtype-bindings/org.coursera.unions.WithEmptyUnion"; +import type { WithPrimitiveCustomTypesUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion"; +import type { WithPrimitiveTyperefsUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion"; +import type { WithRecordCustomTypeUnion } from "../flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion"; +import type { Fortune } from "../flowtype-bindings/org.example.Fortune"; +import type { FortuneCookie } from "../flowtype-bindings/org.example.FortuneCookie"; +import type { FortuneTelling } from "../flowtype-bindings/org.example.FortuneTelling"; +import type { MagicEightBall } from "../flowtype-bindings/org.example.MagicEightBall"; +import type { MagicEightBallAnswer } from "../flowtype-bindings/org.example.MagicEightBallAnswer"; +import type { TyperefExample } from "../flowtype-bindings/org.example.TyperefExample"; +import type { DateTime as CommonDateTime } from "../flowtype-bindings/org.example.common.DateTime"; +import type { Timestamp } from "../flowtype-bindings/org.example.common.Timestamp"; +import type { DateTime as OtherDateTime } from "../flowtype-bindings/org.example.other.DateTime"; +import type { record } from "../flowtype-bindings/org.example.record"; +import type { WithPrimitivesUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitivesUnion"; +import type * as ts from "typescript"; +const fs = require('fs'); + +import type CustomMatcherFactories = jasmine.CustomMatcherFactories; +import type CompilerOptions = ts.CompilerOptions; +import type TranspileOptions = ts.TranspileOptions; +import type Diagnostic = ts.Diagnostic; + +const flowPragmaComment = "/* @flow */"; + +// Add a jasmine matcher that will attempt to compile a ts file and report +// any compilation errors +const toCompileMatcher: CustomMatcherFactories = { + toCompile: (util: any, customEqualityTesters: any) => { + return { + compare: (fileName: any, message:any) => { + const result: any = {}; + var compilerOptions: CompilerOptions = { + project: "/Users/eboto/code/courier/typescript-lite/testsuite/tsconfig.json", + diagnostics: true + }; + + const program = ts.createProgram( + [fileName], + compilerOptions + ); + + const errors = program.getGlobalDiagnostics() + .concat(program.getSemanticDiagnostics()) + .concat(program.getDeclarationDiagnostics()) + .concat(program.getSyntacticDiagnostics()); + const errorStr = errors.reduce((accum: any, err: Diagnostic) => { + const errFile = err.file; + const msgText = ts.flattenDiagnosticMessageText(err.messageText, "\n"); + const nextAccum = accum + `\n${errFile.path}:${errFile.pos}\n${msgText}\n`; + return nextAccum; + }, ""); + + result.pass = (errors.length == 0); + if (!result.pass) { + result.message = `Compilation expectation failed: ${message} Error was: ${errorStr}`; + } + + return result; + } + }; + } +}; + +// +// Only test the runtime behavior of Unions +// +describe("Unions", () => { + it("should compile from correct javascript and unpack", () => { + const unionOfMessage: WithUnion = { + "value": { + "org.coursera.records.Message": { + "title": "title", + "body": "Hello, Courier." + } + } + }; + const {note, message} = Union.unpack(unionOfMessage.value); + expect(note).toBeUndefined(); + expect(message).not.toBeUndefined(); + expect(message.title).toBe("title"); + expect(message.body).toBe("Hello, Courier."); + }); + + it("should access all primitive unions properly", () => { + const keyShouldNotBeUndefined = (correctUnionKey: string) => (withUnion: WithPrimitivesUnion) => { + const union = withUnion.union; + const keys = Object.keys(union); + keys.forEach((key) => { + if (key == correctUnionKey) { + expect(union[key]).not.toBeUndefined(`Expected '${key}' not to be undefined in ${JSON.stringify(union)}`) + } else { + expect(union[key]).toBeUndefined(`Expected '${key}' to be defined in ${JSON.stringify(union)}. Only '${correctUnionKey}' was supposed to be defined.`); + } + }); + }; + const expectations = [ + [wpu_int, keyShouldNotBeUndefined("int")], + [wpu_long, keyShouldNotBeUndefined("long")], + [wpu_float, keyShouldNotBeUndefined("float")], + [wpu_double, keyShouldNotBeUndefined("double")], + [wpu_bool, keyShouldNotBeUndefined("boolean")], + [wpu_string, keyShouldNotBeUndefined("string")], + [wpu_bytes, keyShouldNotBeUndefined("bytes")] + ] + + expectations.forEach((expectationData) => { + const [unionInstance, expectation] = expectationData; + (expectation as any)(unionInstance); + }); + }); +}); + +// +// Now attempt to compile our examples from src/compilation-failures. They should all fail. +// +describe("The typescript compiler", () => { + beforeEach(() => { + jasmine.addMatchers(toCompileMatcher); + }); + + const expectations = [ + ["should not allow unions with incorrect lookup keys", "union_bad-lookup-string.ts"], + ["should not allow the body of the union to be malformed", "union_bad-body-content.ts"], + ["should not allow records to have the wrong field type", "record_wrong-field-type.ts"], + ["should not allow enums with a bad string value", "enum_bad-string.ts"], + ["should not allow typerefs with the wrong root type", "typeref_wrong-type.ts"], + ["should not allow the wrong type as the item of a primitive array", "array_bad-item-type.ts"], + ["should not allow the wrong type as the item of an enum array", "array_bad-item-type-enum-expected.ts"], + ["should not allow the wrong type as the value of a map", "map_bad-value-type.ts"] + ]; + + expectations.forEach((expectationPair) => { + const [testCaseName, fileTest] = expectationPair; + it(testCaseName, () => { + expect(`src/compilation-failures/${fileTest}`).not.toCompile("It was expected to fail."); + }) + }); +}); + +describe("Enums", () => { + it("Should have successful accessors", () => { + const fruit1: Fruits = "APPLE"; + // expect(fruit1).toEqual(Fruits.APPLE); + // expect(fruit1 == Fruits.APPLE).toBe(true); + }); + + it("Should have nice switch/case semantics", () => { + const fruit1: Fruits = "APPLE"; + let result: string; + switch (fruit1) { + case "APPLE": + result = "It was an apple"; + break; + case "PEAR": + result = "It was a pear"; + break; + default: + result = "I don't know what it was."; + } + + expect(result).toEqual("It was an apple"); + result = "It's still an apple"; + // switch (fruit1) { + // case Fruits.APPLE: + // result = "It's still an apple"; + // break; + // default: + // result = "Something else." + // } + + expect(result).toEqual("It's still an apple"); + }); + + it("Should transcribe both the class-level and symbol-level documentation from the courier spec", () => { + const fruitsFile = fs.readFileSync("src/flowtype-bindings/org.coursera.enums.Fruits.ts").toString(); + const typeComment = "An enum dedicated to the finest of the food groups."; + + expect(fruitsFile).toContain(flowPragmaComment); + expect(fruitsFile).toContain(typeComment); + }); + + // it("Should be enumerated with the .all function", () => { + // expect(Fruits.all).toEqual(["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]); + // }); +}); + + +// +// Now just declare a bunch of JSON types (sourced from courier/reference-suite/src/main/json. +// +// Compilation will fail if generation failed in compatibility with these known-good json types. +// +const customint: CustomInt = 1; // typerefs should work + +const boolid: BooleanId = true; +const byteid: ByteId = "bytes just a string baby!"; +const ref_of_a_ref: CustomIntWrapper = 1; +const fortune_fortuneCookie: Fortune = { + "telling": { + "org.example.FortuneCookie": { + "message": " a message", + "certainty": 0.1, + "luckyNumbers": [1, 2, 3] + } + }, + "createdAt": "2015-01-01T00:00:00.000Z" +}; + +const fortune_magicEightBall: Fortune = { + "telling": { + "org.example.MagicEightBall": { + "question": "A question", + "answer": "IT_IS_CERTAIN" + } + }, + "createdAt": "2015-01-01T00:00:00.000Z" +}; + +const fortuneCookie: FortuneCookie = { + "message": " a message", + "certainty": 0.1, + "luckyNumbers": [1, 2, 3] +}; + +const fortuneCookie_lackingOptional: FortuneCookie = { + "message": "a message", + "luckyNumbers": [1, 2, 3] +}; + +const kw_escaping: KeywordEscaping = { + "type" : "test" +}; + +const msg: Message = { + "title": "example title", + "body": "example body" +}; + +const rcfe: ReservedClassFieldEscaping = { + "data" : "dataText", + "schema": "schemaText", + "copy": "copyText", + "clone": "cloneText" +}; + +const simple: Simple = { "message": "simple message" }; + +const withComplexTypes: TestWithComplexTypes = { + "record": { "message": "record"}, + "enum": "APPLE", + "union": { "org.coursera.records.test.Simple": { "message": "union" }}, + "array": [1, 2], + "map": { "a": 1, "b": 2}, + "complexMap": { "x": { "message": "complexMap"}}, + "custom": 100 +}; + +const wu: WithUnion = { + "value": { + "org.coursera.records.Message": { + "title": "title", + "body": "Hello, Courier." + } + } +}; + +const wctu_empty: WithComplexTypesUnion = { + "union" : { + "org.coursera.records.test.Empty" : { } + } +}; + +const wctu_enum: WithComplexTypesUnion = { + "union" : { + "org.coursera.enums.Fruits" : "APPLE" + } +}; + +const withCustomTypesArr: WithCustomTypesArray = { + "ints" : [ 1, 2, 3 ], + "arrays": [ [ { "message": "a1" } ] ], + "maps": [ { "a": { "message": "m1" } } ], + "unions": [ + { "int": 1 }, + { "string": "str" }, + { "org.coursera.records.test.Simple": { "message": "u1" }} + ], + "fixed": [ "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" ] +}; + +const wctm: WithCustomTypesMap = { + "ints" : { + "b" : 2, + "c" : 3, + "a" : 1 + } +}; + +const wctm2: WithComplexTypesMap = { + "empties" : { + "b" : { }, + "c" : { }, + "a" : { } + }, + "fruits" : { + "b" : "BANANA", + "c" : "ORANGE", + "a" : "APPLE" + }, + "arrays" : { + "a": [ {"message": "v1"}, {"message": "v2"} ] + }, + "maps": { + "o1": { + "i1": { "message": "o1i1" }, + "i2": { "message": "o1i2" } + } + }, + "unions": { + "a": { "int": 1 }, + "b": { "string": "u1" } + }, + "fixed": { + "a": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + } +}; + +const wdt: TestWithDateTime = { + "createdAt": 1420070400000 +}; + +const wp1: WithPrimitiveCustomTypes = { + "intField" : 1 +}; + +const wpu: WithPrimitiveCustomTypesUnion = { + "union" : { + "int" : 1 + } +}; + +const wp2: WithPrimitives = { + "floatField" : 3.3, + "doubleField" : 4.4, + "intField" : 1, + "bytesField" : "\u0000\u0001\u0002", + "longField" : 2, + "booleanField" : true, + "stringField" : "str" +}; + +const wpa: WithPrimitivesArray = { + "bytes" : [ "\u0000\u0001\u0002", + "\u0003\u0004\u0005" ], + "longs" : [ 10, 20, 30 ], + "strings" : [ "a", "b", "c" ], + "doubles" : [ 11.1, 22.2, 33.3 ], + "booleans" : [ false, true ], + "floats" : [ 1.1, 2.2, 3.3 ], + "ints" : [ 1, 2, 3 ] +}; + +const wpm: WithPrimitivesMap = { + "bytes" : { + "b" : "\u0003\u0004\u0005", + "c" : "\u0006\u0007\b", + "a" : "\u0000\u0001\u0002" + }, + "longs" : { + "b" : 20, + "c" : 30, + "a" : 10 + }, + "strings" : { + "b" : "string2", + "c" : "string3", + "a" : "string1" + }, + "doubles" : { + "b" : 22.2, + "c" : 33.3, + "a" : 11.1 + }, + "booleans" : { + "b" : false, + "c" : true, + "a" : true + }, + "floats" : { + "b" : 2.2, + "c" : 3.3, + "a" : 1.1 + }, + "ints" : { + "b" : 2, + "c" : 3, + "a" : 1 + } +}; + + + +const wtkm: WithTypedKeyMap = { + "ints" : { "1": "int" }, + "longs" : { "2": "long" }, + "floats" : { "3.14": "float" }, + "doubles" : { "2.71": "double" }, + "booleans" : { "true": "boolean" }, + "strings" : { "key": "string" }, + "bytes" : { "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007": "bytes" }, + "record" : { "(message~key)": "record" }, + "array" : { "List(1,2)": "array" }, + "enum" : { "APPLE": "enum" }, + "custom" : { "100": "custom" }, + "fixed" : { "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007": "fixed" } +}; + +const wra: WithRecordArray = { + "empties" : [ { }, { }, { } ], + "fruits" : [ "APPLE", "BANANA", "ORANGE" ] +}; + +const wctu_array: WithComplexTypesUnion = { + "union" : { + "array" : [ { "message": "a1" } ] // TODO(eboto): Oops! Looks like it specified this in TS like arraySimple: union["Array"]. It should have just been "array" + } +}; + +const wctu_map: WithComplexTypesUnion = { + "union" : { + "map" : { "a": { "message": "m1" } } + } +}; + + +const wpu_long: WithPrimitivesUnion = { + "union" : { + "long" : 2 + } +}; + +const wpu_bool: WithPrimitivesUnion = { + "union" : { + "boolean" : true + } +}; + +const wpu_string: WithPrimitivesUnion = { + "union" : { + "string" : "thestring" + } +}; + +const wpu_bytes: WithPrimitivesUnion = { + "union" : { + "bytes" : "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + } +}; + + +const wpu_str: WithPrimitivesUnion = { + "union" : { + "string" : "str" + } +}; + +const wpu_int: WithPrimitivesUnion = { + "union" : { + "int" : 1 + } +}; + +const wpu_float: WithPrimitivesUnion = { + "union" : { + "float" : 3.0 + } +}; + +const wpu_double: WithPrimitivesUnion = { + "union" : { + "double" : 4.0 + } +}; + + + + +/* TODO(eboto): This one fails. Why? What is a TypedDefinition? +const wtd: WithTypedDefinition = { + + "value": { + "typeName": "message", + "definition": { + "title": "title", + "body": "Hello, Courier." + } + } +}; +*/ + + +/** TODO(eboto): Uncomment after support for flat type definitions + const wftd: WithFlatTypedDefinition = { + "value": { + "typeName": "message", + "title": "title", + "body": "Hello, Courier." + } +}; + */ + +/* TODO(eboto): This is not working because org.coursera.records.mutable.Simple doesn't exist. Ask jpbetz or saeta if this is actually meant to work. + const withCustomTypesArrMutable: WithCustomTypesArray = { + "ints" : [ 1, 2, 3 ], + "arrays": [ [ { "message": "a1" } ] ], + "maps": [ { "a": { "message": "m1" } } ], + "unions": [ + { "number": 1 }, + { "string": "str" }, + { "org.coursera.records.mutable.Simple": { "message": "u1" }} + ], + "fixed": [ "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" ] + } + */ diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts deleted file mode 100644 index 73772da0..00000000 --- a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.ts +++ /dev/null @@ -1,650 +0,0 @@ -import { WithoutNamespace } from "../flowtype-bindings/.WithoutNamespace"; -import { Map } from "../flowtype-bindings/CourierRuntime"; -import { WithCustomArrayTestId } from "../flowtype-bindings/org.coursera.arrays.WithCustomArrayTestId"; -import { WithCustomTypesArray } from "../flowtype-bindings/org.coursera.arrays.WithCustomTypesArray"; -import { WithCustomTypesArrayUnion } from "../flowtype-bindings/org.coursera.arrays.WithCustomTypesArrayUnion"; -import { WithPrimitivesArray } from "../flowtype-bindings/org.coursera.arrays.WithPrimitivesArray"; -import { WithRecordArray } from "../flowtype-bindings/org.coursera.arrays.WithRecordArray"; -import { BooleanId } from "../flowtype-bindings/org.coursera.customtypes.BooleanId"; -import { BoxedIntId } from "../flowtype-bindings/org.coursera.customtypes.BoxedIntId"; -import { ByteId } from "../flowtype-bindings/org.coursera.customtypes.ByteId"; -import { CaseClassCustomIntWrapper } from "../flowtype-bindings/org.coursera.customtypes.CaseClassCustomIntWrapper"; -import { CaseClassStringIdWrapper } from "../flowtype-bindings/org.coursera.customtypes.CaseClassStringIdWrapper"; -import { CharId } from "../flowtype-bindings/org.coursera.customtypes.CharId"; -import { CustomArrayTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomArrayTestId"; -import { CustomInt } from "../flowtype-bindings/org.coursera.customtypes.CustomInt"; -import { CustomIntWrapper } from "../flowtype-bindings/org.coursera.customtypes.CustomIntWrapper"; -import { CustomMapTestKeyId } from "../flowtype-bindings/org.coursera.customtypes.CustomMapTestKeyId"; -import { CustomMapTestValueId } from "../flowtype-bindings/org.coursera.customtypes.CustomMapTestValueId"; -import { CustomRecord } from "../flowtype-bindings/org.coursera.customtypes.CustomRecord"; -import { CustomRecordTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomRecordTestId"; -import { CustomUnionTestId } from "../flowtype-bindings/org.coursera.customtypes.CustomUnionTestId"; -import { DateTime } from "../flowtype-bindings/org.coursera.customtypes.DateTime"; -import { DoubleId } from "../flowtype-bindings/org.coursera.customtypes.DoubleId"; -import { FloatId } from "../flowtype-bindings/org.coursera.customtypes.FloatId"; -import { IntId } from "../flowtype-bindings/org.coursera.customtypes.IntId"; -import { LongId } from "../flowtype-bindings/org.coursera.customtypes.LongId"; -import { ShortId } from "../flowtype-bindings/org.coursera.customtypes.ShortId"; -import { StringId } from "../flowtype-bindings/org.coursera.customtypes.StringId"; -import { DeprecatedRecord } from "../flowtype-bindings/org.coursera.deprecated.DeprecatedRecord"; -import { EmptyEnum } from "../flowtype-bindings/org.coursera.enums.EmptyEnum"; -import { EnumProperties } from "../flowtype-bindings/org.coursera.enums.EnumProperties"; -import { Fruits } from "../flowtype-bindings/org.coursera.enums.Fruits"; -import { DefaultLiteralEscaping } from "../flowtype-bindings/org.coursera.escaping.DefaultLiteralEscaping"; -import { KeywordEscaping } from "../flowtype-bindings/org.coursera.escaping.KeywordEscaping"; -import { ReservedClassFieldEscaping } from "../flowtype-bindings/org.coursera.escaping.ReservedClassFieldEscaping"; -import { class$ } from "../flowtype-bindings/org.coursera.escaping.class"; -import { WithFixed8 } from "../flowtype-bindings/org.coursera.fixed.WithFixed8"; -import { Toggle } from "../flowtype-bindings/org.coursera.maps.Toggle"; -import { WithComplexTypesMap } from "../flowtype-bindings/org.coursera.maps.WithComplexTypesMap"; -import { WithComplexTypesMapUnion } from "../flowtype-bindings/org.coursera.maps.WithComplexTypesMapUnion"; -import { WithCustomMapTestIds } from "../flowtype-bindings/org.coursera.maps.WithCustomMapTestIds"; -import { WithCustomTypesMap } from "../flowtype-bindings/org.coursera.maps.WithCustomTypesMap"; -import { WithPrimitivesMap } from "../flowtype-bindings/org.coursera.maps.WithPrimitivesMap"; -import { WithTypedKeyMap } from "../flowtype-bindings/org.coursera.maps.WithTypedKeyMap"; -import { CourierFile } from "../flowtype-bindings/org.coursera.records.CourierFile"; -import { JsonTest } from "../flowtype-bindings/org.coursera.records.JsonTest"; -import { Message } from "../flowtype-bindings/org.coursera.records.Message"; -import { WithAnonymousUnionArray } from "../flowtype-bindings/org.coursera.arrays.WithAnonymousUnionArray"; -import { Note } from "../flowtype-bindings/org.coursera.records.Note"; -import { WithDateTime } from "../flowtype-bindings/org.coursera.records.WithDateTime"; -import { WithFlatTypedDefinition } from "../flowtype-bindings/org.coursera.records.WithFlatTypedDefinition"; -import { WithInclude } from "../flowtype-bindings/org.coursera.records.WithInclude"; -import { WithTypedDefinition } from "../flowtype-bindings/org.coursera.records.WithTypedDefinition"; -import { WithUnion } from "../flowtype-bindings/org.coursera.records.WithUnion"; -import { Fixed8 } from "../flowtype-bindings/org.coursera.fixed.Fixed8"; -import { class$ as EscapedClassRecord} from "../flowtype-bindings/org.coursera.records.class"; -import { Simple } from "../flowtype-bindings/org.coursera.records.primitivestyle.Simple"; -import { WithComplexTypes } from "../flowtype-bindings/org.coursera.records.primitivestyle.WithComplexTypes"; -import { WithPrimitives } from "../flowtype-bindings/org.coursera.records.primitivestyle.WithPrimitives"; -import { BooleanTyperef } from "../flowtype-bindings/org.coursera.records.test.BooleanTyperef"; -import { BytesTyperef } from "../flowtype-bindings/org.coursera.records.test.BytesTyperef"; -import { DoubleTyperef } from "../flowtype-bindings/org.coursera.records.test.DoubleTyperef"; -import { Empty } from "../flowtype-bindings/org.coursera.records.test.Empty"; -import { FloatTyperef } from "../flowtype-bindings/org.coursera.records.test.FloatTyperef"; -import { InlineOptionalRecord } from "../flowtype-bindings/org.coursera.records.test.InlineOptionalRecord"; -import { InlineRecord } from "../flowtype-bindings/org.coursera.records.test.InlineRecord"; -import { IntCustomType as TestIntCustomType } from "../flowtype-bindings/org.coursera.records.test.IntCustomType"; -import { IntTyperef as TestIntTyperef } from "../flowtype-bindings/org.coursera.records.test.IntTyperef"; -import { LongTyperef } from "../flowtype-bindings/org.coursera.records.test.LongTyperef"; -import { Message as TestMessage } from "../flowtype-bindings/org.coursera.records.test.Message"; -import { NumericDefaults } from "../flowtype-bindings/org.coursera.records.test.NumericDefaults"; -import { OptionalBooleanTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalBooleanTyperef"; -import { OptionalBytesTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalBytesTyperef"; -import { OptionalDoubleTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalDoubleTyperef"; -import { OptionalFloatTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalFloatTyperef"; -import { OptionalIntCustomType } from "../flowtype-bindings/org.coursera.records.test.OptionalIntCustomType"; -import { OptionalIntTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalIntTyperef"; -import { OptionalLongTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalLongTyperef"; -import { OptionalStringTyperef } from "../flowtype-bindings/org.coursera.records.test.OptionalStringTyperef"; -import { RecursivelyDefinedRecord } from "../flowtype-bindings/org.coursera.records.test.RecursivelyDefinedRecord"; -import { Simple as TestSimple } from "../flowtype-bindings/org.coursera.records.test.Simple"; -import { StringTyperef } from "../flowtype-bindings/org.coursera.records.test.StringTyperef"; -import { With22Fields } from "../flowtype-bindings/org.coursera.records.test.With22Fields"; -import { With23Fields } from "../flowtype-bindings/org.coursera.records.test.With23Fields"; -import { WithCaseClassCustomType } from "../flowtype-bindings/org.coursera.records.test.WithCaseClassCustomType"; -import { WithComplexTypeDefaults } from "../flowtype-bindings/org.coursera.records.test.WithComplexTypeDefaults"; -import { WithComplexTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithComplexTyperefs"; -import { WithComplexTypes as TestWithComplexTypes } from "../flowtype-bindings/org.coursera.records.test.WithComplexTypes"; -import { WithCourierFile } from "../flowtype-bindings/org.coursera.records.test.WithCourierFile"; -import { WithCustomIntWrapper } from "../flowtype-bindings/org.coursera.records.test.WithCustomIntWrapper"; -import { WithCustomRecord } from "../flowtype-bindings/org.coursera.records.test.WithCustomRecord"; -import { WithCustomRecordTestId } from "../flowtype-bindings/org.coursera.records.test.WithCustomRecordTestId"; -import { WithDateTime as TestWithDateTime } from "../flowtype-bindings/org.coursera.records.test.WithDateTime"; -import { WithInclude as TestWithInclude } from "../flowtype-bindings/org.coursera.records.test.WithInclude"; -import { WithInlineRecord } from "../flowtype-bindings/org.coursera.records.test.WithInlineRecord"; -import { WithOmitField } from "../flowtype-bindings/org.coursera.records.test.WithOmitField"; -import { WithOptionalComplexTypeDefaults } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypeDefaults"; -import { WithOptionalComplexTypes } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypes"; -import { WithOptionalComplexTypesDefaultNone } from "../flowtype-bindings/org.coursera.records.test.WithOptionalComplexTypesDefaultNone"; -import { WithOptionalPrimitiveCustomTypes } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveCustomTypes"; -import { WithOptionalPrimitiveDefaultNone } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaultNone"; -import { WithOptionalPrimitiveDefaults } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveDefaults"; -import { WithOptionalPrimitiveTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitiveTyperefs"; -import { WithOptionalPrimitives } from "../flowtype-bindings/org.coursera.records.test.WithOptionalPrimitives"; -import { WithPrimitiveCustomTypes } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveCustomTypes"; -import { WithPrimitiveDefaults } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveDefaults"; -import { WithPrimitiveTyperefs } from "../flowtype-bindings/org.coursera.records.test.WithPrimitiveTyperefs"; -import { WithPrimitives as TestWithPrimitives } from "../flowtype-bindings/org.coursera.records.test.WithPrimitives"; -import { WithUnionWithInlineRecord } from "../flowtype-bindings/org.coursera.records.test.WithUnionWithInlineRecord"; -import { ArrayTyperef } from "../flowtype-bindings/org.coursera.typerefs.ArrayTyperef"; -import { EnumTyperef } from "../flowtype-bindings/org.coursera.typerefs.EnumTyperef"; -import { FlatTypedDefinition } from "../flowtype-bindings/org.coursera.typerefs.FlatTypedDefinition"; -import { InlineRecord as InlineRecordTypeRef } from "../flowtype-bindings/org.coursera.typerefs.InlineRecord"; -import { InlineRecord2 } from "../flowtype-bindings/org.coursera.typerefs.InlineRecord2"; -import { IntTyperef } from "../flowtype-bindings/org.coursera.typerefs.IntTyperef"; -import { MapTyperef } from "../flowtype-bindings/org.coursera.typerefs.MapTyperef"; -import { RecordTyperef } from "../flowtype-bindings/org.coursera.typerefs.RecordTyperef"; -import { TypedDefinition } from "../flowtype-bindings/org.coursera.typerefs.TypedDefinition"; -import { Union } from "../flowtype-bindings/org.coursera.typerefs.Union"; -import { UnionTyperef } from "../flowtype-bindings/org.coursera.typerefs.UnionTyperef"; -import { UnionWithInlineRecord } from "../flowtype-bindings/org.coursera.typerefs.UnionWithInlineRecord"; -import { IntCustomType } from "../flowtype-bindings/org.coursera.unions.IntCustomType"; -import { IntTyperef as IntTyperefUnion} from "../flowtype-bindings/org.coursera.unions.IntTyperef"; -import { WithComplexTypesUnion } from "../flowtype-bindings/org.coursera.unions.WithComplexTypesUnion"; -import { WithCustomUnionTestId } from "../flowtype-bindings/org.coursera.unions.WithCustomUnionTestId"; -import { WithEmptyUnion } from "../flowtype-bindings/org.coursera.unions.WithEmptyUnion"; -import { WithPrimitiveCustomTypesUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitiveCustomTypesUnion"; -import { WithPrimitiveTyperefsUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitiveTyperefsUnion"; -import { WithRecordCustomTypeUnion } from "../flowtype-bindings/org.coursera.unions.WithRecordCustomTypeUnion"; -import { Fortune } from "../flowtype-bindings/org.example.Fortune"; -import { FortuneCookie } from "../flowtype-bindings/org.example.FortuneCookie"; -import { FortuneTelling } from "../flowtype-bindings/org.example.FortuneTelling"; -import { MagicEightBall } from "../flowtype-bindings/org.example.MagicEightBall"; -import { MagicEightBallAnswer } from "../flowtype-bindings/org.example.MagicEightBallAnswer"; -import { TyperefExample } from "../flowtype-bindings/org.example.TyperefExample"; -import { DateTime as CommonDateTime } from "../flowtype-bindings/org.example.common.DateTime"; -import { Timestamp } from "../flowtype-bindings/org.example.common.Timestamp"; -import { DateTime as OtherDateTime } from "../flowtype-bindings/org.example.other.DateTime"; -import { record } from "../flowtype-bindings/org.example.record"; -import { WithPrimitivesUnion } from "../flowtype-bindings/org.coursera.unions.WithPrimitivesUnion"; -import * as ts from "typescript"; -const fs = require('fs'); - -import CustomMatcherFactories = jasmine.CustomMatcherFactories; -import CompilerOptions = ts.CompilerOptions; -import TranspileOptions = ts.TranspileOptions; -import Diagnostic = ts.Diagnostic; - -const flowPragmaComment = "/* @flow */"; - -// Add a jasmine matcher that will attempt to compile a ts file and report -// any compilation errors -const toCompileMatcher: CustomMatcherFactories = { - toCompile: (util: any, customEqualityTesters: any) => { - return { - compare: (fileName: any, message:any) => { - const result: any = {}; - var compilerOptions: CompilerOptions = { - project: "/Users/eboto/code/courier/typescript-lite/testsuite/tsconfig.json", - diagnostics: true - }; - - const program = ts.createProgram( - [fileName], - compilerOptions - ); - - const errors = program.getGlobalDiagnostics() - .concat(program.getSemanticDiagnostics()) - .concat(program.getDeclarationDiagnostics()) - .concat(program.getSyntacticDiagnostics()); - const errorStr = errors.reduce((accum: any, err: Diagnostic) => { - const errFile = err.file; - const msgText = ts.flattenDiagnosticMessageText(err.messageText, "\n"); - const nextAccum = accum + `\n${errFile.path}:${errFile.pos}\n${msgText}\n`; - return nextAccum; - }, ""); - - result.pass = (errors.length == 0); - if (!result.pass) { - result.message = `Compilation expectation failed: ${message} Error was: ${errorStr}`; - } - - return result; - } - }; - } -}; - -// -// Only test the runtime behavior of Unions -// -describe("Unions", () => { - it("should compile from correct javascript and unpack", () => { - const unionOfMessage: WithUnion = { - "value": { - "org.coursera.records.Message": { - "title": "title", - "body": "Hello, Courier." - } - } - }; - const {note, message} = Union.unpack(unionOfMessage.value); - expect(note).toBeUndefined(); - expect(message).not.toBeUndefined(); - expect(message.title).toBe("title"); - expect(message.body).toBe("Hello, Courier."); - }); - - it("should access all primitive unions properly", () => { - const keyShouldNotBeUndefined = (correctUnionKey: string) => (withUnion: WithPrimitivesUnion) => { - const union = withUnion.union; - const keys = Object.keys(union); - keys.forEach((key) => { - if (key == correctUnionKey) { - expect(union[key]).not.toBeUndefined(`Expected '${key}' not to be undefined in ${JSON.stringify(union)}`) - } else { - expect(union[key]).toBeUndefined(`Expected '${key}' to be defined in ${JSON.stringify(union)}. Only '${correctUnionKey}' was supposed to be defined.`); - } - }); - }; - const expectations = [ - [wpu_int, keyShouldNotBeUndefined("int")], - [wpu_long, keyShouldNotBeUndefined("long")], - [wpu_float, keyShouldNotBeUndefined("float")], - [wpu_double, keyShouldNotBeUndefined("double")], - [wpu_bool, keyShouldNotBeUndefined("boolean")], - [wpu_string, keyShouldNotBeUndefined("string")], - [wpu_bytes, keyShouldNotBeUndefined("bytes")] - ] - - expectations.forEach((expectationData) => { - const [unionInstance, expectation] = expectationData; - (expectation as any)(unionInstance); - }); - }); -}); - -// -// Now attempt to compile our examples from src/compilation-failures. They should all fail. -// -describe("The typescript compiler", () => { - beforeEach(() => { - jasmine.addMatchers(toCompileMatcher); - }); - - const expectations = [ - ["should not allow unions with incorrect lookup keys", "union_bad-lookup-string.ts"], - ["should not allow the body of the union to be malformed", "union_bad-body-content.ts"], - ["should not allow records to have the wrong field type", "record_wrong-field-type.ts"], - ["should not allow enums with a bad string value", "enum_bad-string.ts"], - ["should not allow typerefs with the wrong root type", "typeref_wrong-type.ts"], - ["should not allow the wrong type as the item of a primitive array", "array_bad-item-type.ts"], - ["should not allow the wrong type as the item of an enum array", "array_bad-item-type-enum-expected.ts"], - ["should not allow the wrong type as the value of a map", "map_bad-value-type.ts"] - ]; - - expectations.forEach((expectationPair) => { - const [testCaseName, fileTest] = expectationPair; - it(testCaseName, () => { - expect(`src/compilation-failures/${fileTest}`).not.toCompile("It was expected to fail."); - }) - }); -}); - -describe("Enums", () => { - it("Should have successful accessors", () => { - const fruit1: Fruits = "APPLE"; - // expect(fruit1).toEqual(Fruits.APPLE); - // expect(fruit1 == Fruits.APPLE).toBe(true); - }); - - it("Should have nice switch/case semantics", () => { - const fruit1: Fruits = "APPLE"; - let result: string; - switch (fruit1) { - case "APPLE": - result = "It was an apple"; - break; - case "PEAR": - result = "It was a pear"; - break; - default: - result = "I don't know what it was."; - } - - expect(result).toEqual("It was an apple"); - result = "It's still an apple"; - // switch (fruit1) { - // case Fruits.APPLE: - // result = "It's still an apple"; - // break; - // default: - // result = "Something else." - // } - - expect(result).toEqual("It's still an apple"); - }); - - it("Should transcribe both the class-level and symbol-level documentation from the courier spec", () => { - const fruitsFile = fs.readFileSync("src/flowtype-bindings/org.coursera.enums.Fruits.ts").toString(); - const typeComment = "An enum dedicated to the finest of the food groups."; - - expect(fruitsFile).toContain(flowPragmaComment); - expect(fruitsFile).toContain(typeComment); - }); - - // it("Should be enumerated with the .all function", () => { - // expect(Fruits.all).toEqual(["APPLE", "BANANA", "ORANGE", "PINEAPPLE"]); - // }); -}); - - -// -// Now just declare a bunch of JSON types (sourced from courier/reference-suite/src/main/json. -// -// Compilation will fail if generation failed in compatibility with these known-good json types. -// -const customint: CustomInt = 1; // typerefs should work - -const boolid: BooleanId = true; -const byteid: ByteId = "bytes just a string baby!"; -const ref_of_a_ref: CustomIntWrapper = 1; -const fortune_fortuneCookie: Fortune = { - "telling": { - "org.example.FortuneCookie": { - "message": " a message", - "certainty": 0.1, - "luckyNumbers": [1, 2, 3] - } - }, - "createdAt": "2015-01-01T00:00:00.000Z" -}; - -const fortune_magicEightBall: Fortune = { - "telling": { - "org.example.MagicEightBall": { - "question": "A question", - "answer": "IT_IS_CERTAIN" - } - }, - "createdAt": "2015-01-01T00:00:00.000Z" -}; - -const fortuneCookie: FortuneCookie = { - "message": " a message", - "certainty": 0.1, - "luckyNumbers": [1, 2, 3] -}; - -const fortuneCookie_lackingOptional: FortuneCookie = { - "message": "a message", - "luckyNumbers": [1, 2, 3] -}; - -const kw_escaping: KeywordEscaping = { - "type" : "test" -}; - -const msg: Message = { - "title": "example title", - "body": "example body" -}; - -const rcfe: ReservedClassFieldEscaping = { - "data" : "dataText", - "schema": "schemaText", - "copy": "copyText", - "clone": "cloneText" -}; - -const simple: Simple = { "message": "simple message" }; - -const withComplexTypes: TestWithComplexTypes = { - "record": { "message": "record"}, - "enum": "APPLE", - "union": { "org.coursera.records.test.Simple": { "message": "union" }}, - "array": [1, 2], - "map": { "a": 1, "b": 2}, - "complexMap": { "x": { "message": "complexMap"}}, - "custom": 100 -}; - -const wu: WithUnion = { - "value": { - "org.coursera.records.Message": { - "title": "title", - "body": "Hello, Courier." - } - } -}; - -const wctu_empty: WithComplexTypesUnion = { - "union" : { - "org.coursera.records.test.Empty" : { } - } -}; - -const wctu_enum: WithComplexTypesUnion = { - "union" : { - "org.coursera.enums.Fruits" : "APPLE" - } -}; - -const withCustomTypesArr: WithCustomTypesArray = { - "ints" : [ 1, 2, 3 ], - "arrays": [ [ { "message": "a1" } ] ], - "maps": [ { "a": { "message": "m1" } } ], - "unions": [ - { "int": 1 }, - { "string": "str" }, - { "org.coursera.records.test.Simple": { "message": "u1" }} - ], - "fixed": [ "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" ] -}; - -const wctm: WithCustomTypesMap = { - "ints" : { - "b" : 2, - "c" : 3, - "a" : 1 - } -}; - -const wctm2: WithComplexTypesMap = { - "empties" : { - "b" : { }, - "c" : { }, - "a" : { } - }, - "fruits" : { - "b" : "BANANA", - "c" : "ORANGE", - "a" : "APPLE" - }, - "arrays" : { - "a": [ {"message": "v1"}, {"message": "v2"} ] - }, - "maps": { - "o1": { - "i1": { "message": "o1i1" }, - "i2": { "message": "o1i2" } - } - }, - "unions": { - "a": { "int": 1 }, - "b": { "string": "u1" } - }, - "fixed": { - "a": "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" - } -}; - -const wdt: TestWithDateTime = { - "createdAt": 1420070400000 -}; - -const wp1: WithPrimitiveCustomTypes = { - "intField" : 1 -}; - -const wpu: WithPrimitiveCustomTypesUnion = { - "union" : { - "int" : 1 - } -}; - -const wp2: WithPrimitives = { - "floatField" : 3.3, - "doubleField" : 4.4, - "intField" : 1, - "bytesField" : "\u0000\u0001\u0002", - "longField" : 2, - "booleanField" : true, - "stringField" : "str" -}; - -const wpa: WithPrimitivesArray = { - "bytes" : [ "\u0000\u0001\u0002", - "\u0003\u0004\u0005" ], - "longs" : [ 10, 20, 30 ], - "strings" : [ "a", "b", "c" ], - "doubles" : [ 11.1, 22.2, 33.3 ], - "booleans" : [ false, true ], - "floats" : [ 1.1, 2.2, 3.3 ], - "ints" : [ 1, 2, 3 ] -}; - -const wpm: WithPrimitivesMap = { - "bytes" : { - "b" : "\u0003\u0004\u0005", - "c" : "\u0006\u0007\b", - "a" : "\u0000\u0001\u0002" - }, - "longs" : { - "b" : 20, - "c" : 30, - "a" : 10 - }, - "strings" : { - "b" : "string2", - "c" : "string3", - "a" : "string1" - }, - "doubles" : { - "b" : 22.2, - "c" : 33.3, - "a" : 11.1 - }, - "booleans" : { - "b" : false, - "c" : true, - "a" : true - }, - "floats" : { - "b" : 2.2, - "c" : 3.3, - "a" : 1.1 - }, - "ints" : { - "b" : 2, - "c" : 3, - "a" : 1 - } -}; - - - -const wtkm: WithTypedKeyMap = { - "ints" : { "1": "int" }, - "longs" : { "2": "long" }, - "floats" : { "3.14": "float" }, - "doubles" : { "2.71": "double" }, - "booleans" : { "true": "boolean" }, - "strings" : { "key": "string" }, - "bytes" : { "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007": "bytes" }, - "record" : { "(message~key)": "record" }, - "array" : { "List(1,2)": "array" }, - "enum" : { "APPLE": "enum" }, - "custom" : { "100": "custom" }, - "fixed" : { "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007": "fixed" } -}; - -const wra: WithRecordArray = { - "empties" : [ { }, { }, { } ], - "fruits" : [ "APPLE", "BANANA", "ORANGE" ] -}; - -const wctu_array: WithComplexTypesUnion = { - "union" : { - "array" : [ { "message": "a1" } ] // TODO(eboto): Oops! Looks like it specified this in TS like arraySimple: union["Array"]. It should have just been "array" - } -}; - -const wctu_map: WithComplexTypesUnion = { - "union" : { - "map" : { "a": { "message": "m1" } } - } -}; - - -const wpu_long: WithPrimitivesUnion = { - "union" : { - "long" : 2 - } -}; - -const wpu_bool: WithPrimitivesUnion = { - "union" : { - "boolean" : true - } -}; - -const wpu_string: WithPrimitivesUnion = { - "union" : { - "string" : "thestring" - } -}; - -const wpu_bytes: WithPrimitivesUnion = { - "union" : { - "bytes" : "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" - } -}; - - -const wpu_str: WithPrimitivesUnion = { - "union" : { - "string" : "str" - } -}; - -const wpu_int: WithPrimitivesUnion = { - "union" : { - "int" : 1 - } -}; - -const wpu_float: WithPrimitivesUnion = { - "union" : { - "float" : 3.0 - } -}; - -const wpu_double: WithPrimitivesUnion = { - "union" : { - "double" : 4.0 - } -}; - - - - -/* TODO(eboto): This one fails. Why? What is a TypedDefinition? -const wtd: WithTypedDefinition = { - - "value": { - "typeName": "message", - "definition": { - "title": "title", - "body": "Hello, Courier." - } - } -}; -*/ - - -/** TODO(eboto): Uncomment after support for flat type definitions - const wftd: WithFlatTypedDefinition = { - "value": { - "typeName": "message", - "title": "title", - "body": "Hello, Courier." - } -}; - */ - -/* TODO(eboto): This is not working because org.coursera.records.mutable.Simple doesn't exist. Ask jpbetz or saeta if this is actually meant to work. - const withCustomTypesArrMutable: WithCustomTypesArray = { - "ints" : [ 1, 2, 3 ], - "arrays": [ [ { "message": "a1" } ] ], - "maps": [ { "a": { "message": "m1" } } ], - "unions": [ - { "number": 1 }, - { "string": "str" }, - { "org.coursera.records.mutable.Simple": { "message": "u1" }} - ], - "fixed": [ "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" ] - } - */ From 548aa70112869d25b2f827122bd16db85b09925b Mon Sep 17 00:00:00 2001 From: kyle-verhoog Date: Thu, 2 Nov 2017 18:12:03 -0700 Subject: [PATCH 19/23] Add flow map --- .../coursera/courier/flowtype/FlowtypeSyntax.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index 529641c7..572e6268 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -53,7 +53,7 @@ * @see TSPrimitiveTypeSyntax * @see FlowtypeEnumSyntax * @see TSArraySyntax - * @see TSMapSyntax + * @see FlowtypeMapSyntax * @see FlowtypeTyperefSyntax * @see FlowtypeRecordSyntax * @see TSFixedSyntax @@ -277,7 +277,7 @@ private FlowtypeTypeSyntax createTypeSyntax(ClassTemplateSpec template) { } else if (template instanceof PrimitiveTemplateSpec) { return new TSPrimitiveTypeSyntax((PrimitiveTemplateSpec) template); } else if (template instanceof MapTemplateSpec) { - return new TSMapSyntax((MapTemplateSpec) template); + return new FlowtypeMapSyntax((MapTemplateSpec) template); } else if (template instanceof ArrayTemplateSpec) { return new TSArraySyntax((ArrayTemplateSpec) template); } else if (template instanceof UnionTemplateSpec) { @@ -307,10 +307,10 @@ String typeNameQualifiedByEnclosingClass(FlowtypeTypeSyntax syntax) { } /** TS-specific syntax for Maps */ - private class TSMapSyntax implements FlowtypeTypeSyntax { + private class FlowtypeMapSyntax implements FlowtypeTypeSyntax { private final MapTemplateSpec _template; - TSMapSyntax(MapTemplateSpec _template) { + FlowtypeMapSyntax(MapTemplateSpec _template) { this._template = _template; } @@ -333,11 +333,13 @@ public String typeName() { @Override public Set modulesRequiredToUse() { Set modules = new HashSet<>(); + modules.add("import type { Map } from \"./CourierRuntime\";"); // Our runtime contains a typedef for Map + modules.addAll(_valueTypeSyntax().modulesRequiredToUse()); // Need the map's value type to compile code that uses this type. return modules; } // - // Private TSMapSyntax members + // Private FlowtypeMapSyntax members // private FlowtypeTypeSyntax _valueTypeSyntax() { return createTypeSyntax(_template.getSchema().getValues()); From 9a0d8a31e2c47e67dd68ccec2d3836f0f312d5d1 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Fri, 3 Nov 2017 09:23:37 -0700 Subject: [PATCH 20/23] initial setup for flow --- .../coursera/courier/FlowtypeGenerator.java | 2 +- flowtype/testsuite/.babelrc | 3 +++ flowtype/testsuite/.flowconfig | 11 ++++++++ flowtype/testsuite/package.json | 8 +++++- .../expected-successes/spec/bindings.spec.js | 27 ------------------- 5 files changed, 22 insertions(+), 29 deletions(-) create mode 100644 flowtype/testsuite/.babelrc create mode 100644 flowtype/testsuite/.flowconfig diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index bbabc70d..fa8b8e64 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -106,7 +106,7 @@ public FlowtypeGenerator(GlobalConfig globalConfig) { public static class FlowCompilationUnit extends GeneratedCodeTargetFile { public FlowCompilationUnit(String name, String namespace){ - super(name, namespace, "flow.js"); + super(name, namespace, "js"); } } diff --git a/flowtype/testsuite/.babelrc b/flowtype/testsuite/.babelrc new file mode 100644 index 00000000..4285ecfa --- /dev/null +++ b/flowtype/testsuite/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["flow"] +} diff --git a/flowtype/testsuite/.flowconfig b/flowtype/testsuite/.flowconfig new file mode 100644 index 00000000..1fed4453 --- /dev/null +++ b/flowtype/testsuite/.flowconfig @@ -0,0 +1,11 @@ +[ignore] + +[include] + +[libs] + +[lints] + +[options] + +[strict] diff --git a/flowtype/testsuite/package.json b/flowtype/testsuite/package.json index 132d5e80..42b0eab9 100644 --- a/flowtype/testsuite/package.json +++ b/flowtype/testsuite/package.json @@ -4,10 +4,11 @@ "description": "Test-suite for the flowtype courier bindings", "main": "src/index.js", "scripts": { + "flow": "./node_modules/.bin/flow", "setup": "npm install && npm run-script typings-install", "compile": "./node_modules/.bin/tsc", "typings-install": "./node_modules/.bin/typings install", - "test": "npm run-script compile && ./node_modules/.bin/jasmine", + "test": "echo done", "full-build": "npm run-script setup && npm run-script test" }, "repository": { @@ -24,5 +25,10 @@ "jasmine": "2.4.1", "typescript": "1.8.9", "typings": "0.7.10" + }, + "devDependencies": { + "babel-cli": "^6.26.0", + "babel-preset-flow": "^6.23.0", + "flow-bin": "^0.58.0" } } diff --git a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js index 74e88748..19d7ad01 100644 --- a/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js +++ b/flowtype/testsuite/src/expected-successes/spec/bindings.spec.js @@ -236,33 +236,6 @@ describe("Unions", () => { }); }); -// -// Now attempt to compile our examples from src/compilation-failures. They should all fail. -// -describe("The typescript compiler", () => { - beforeEach(() => { - jasmine.addMatchers(toCompileMatcher); - }); - - const expectations = [ - ["should not allow unions with incorrect lookup keys", "union_bad-lookup-string.ts"], - ["should not allow the body of the union to be malformed", "union_bad-body-content.ts"], - ["should not allow records to have the wrong field type", "record_wrong-field-type.ts"], - ["should not allow enums with a bad string value", "enum_bad-string.ts"], - ["should not allow typerefs with the wrong root type", "typeref_wrong-type.ts"], - ["should not allow the wrong type as the item of a primitive array", "array_bad-item-type.ts"], - ["should not allow the wrong type as the item of an enum array", "array_bad-item-type-enum-expected.ts"], - ["should not allow the wrong type as the value of a map", "map_bad-value-type.ts"] - ]; - - expectations.forEach((expectationPair) => { - const [testCaseName, fileTest] = expectationPair; - it(testCaseName, () => { - expect(`src/compilation-failures/${fileTest}`).not.toCompile("It was expected to fail."); - }) - }); -}); - describe("Enums", () => { it("Should have successful accessors", () => { const fruit1: Fruits = "APPLE"; From dfb11790be65065469d0df908f0df3042673c1c0 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Fri, 3 Nov 2017 10:40:46 -0700 Subject: [PATCH 21/23] fix record unions --- .../courier/flowtype/FlowtypeSyntax.java | 21 ++++++++----------- .../src/main/resources/rythm/record.txt | 7 +++++++ .../src/main/resources/rythm/union.txt | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index 529641c7..bf93fdc1 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -43,11 +43,7 @@ * * Most work delegates to inner classes, so you probably want to look them (linked below) * -<<<<<<< HEAD - * Specifically, {@link FlowtypeEnumSyntax}, {@link TSUnionSyntax}, {@link FlowtypeRecordSyntax}, and {@link FlowtypeTyperefSyntax} are -======= * Specifically, {@link TSEnumSyntax}, {@link FlowtypeUnionSyntax}, {@link FlowtypeRecordSyntax}, and {@link FlowtypeTyperefSyntax} are ->>>>>>> Add rough union * used directly to populate the templates. * * @see TSPrimitiveTypeSyntax @@ -299,11 +295,12 @@ private FlowtypeTypeSyntax createTypeSyntax(DataSchema schema) { * If that same union were enclosed within MyRecord, this would return "MyRecord.MyUnion". **/ String typeNameQualifiedByEnclosingClass(FlowtypeTypeSyntax syntax) { - if (syntax instanceof TSEnclosedTypeSyntax) { - return ((TSEnclosedTypeSyntax) syntax).typeNameQualifiedByEnclosedType(); - } else { - return syntax.typeName(); - } + // if (syntax instanceof TSEnclosedTypeSyntax) { + // return ((TSEnclosedTypeSyntax) syntax).typeNameQualifiedByEnclosedType(); + // } else { + // return syntax.typeName(); + // } + return syntax.typeName(); } /** TS-specific syntax for Maps */ @@ -485,7 +482,7 @@ public TSFixedSyntax TSFixedSyntaxCreate(FixedTemplateSpec template) { } /** - * TS representation of a Union type's member (e.g. the "int" in "union[int]"). + * Flow representation of a Union type's member (e.g. the "int" in "union[int]"). */ public class FlowtypeUnionMemberSyntax { private final FlowtypeUnionSyntax _parentSyntax; @@ -717,7 +714,7 @@ private boolean _isEnclosedType() { } } - /** The TS representation of a single field in a Record */ + /** The Flow representation of a single field in a Record */ public class FlowRecordFieldSyntax implements FlowtypeTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; @@ -793,7 +790,7 @@ private FlowtypeTypeSyntax _fieldTypeSyntax() { } } - /** TS-specific syntax for Records */ + /** Flow-specific syntax for Records */ public class FlowtypeRecordSyntax implements FlowtypeTypeSyntax { private final RecordTemplateSpec _template; private final RecordDataSchema _schema; diff --git a/flowtype/generator/src/main/resources/rythm/record.txt b/flowtype/generator/src/main/resources/rythm/record.txt index ee768f0c..aeaff898 100644 --- a/flowtype/generator/src/main/resources/rythm/record.txt +++ b/flowtype/generator/src/main/resources/rythm/record.txt @@ -5,6 +5,13 @@ @record.imports() @record.docString() + +@if(record.requiresCompanionModule()) { + @for(FlowtypeUnionSyntax union: record.enclosedUnions()) { + @union(union) + } +} + export type @record.typeName() = { @for(FlowRecordFieldSyntax field: record.fields()) { @field.docString() diff --git a/flowtype/generator/src/main/resources/rythm/union.txt b/flowtype/generator/src/main/resources/rythm/union.txt index 271ae1cd..559209f5 100644 --- a/flowtype/generator/src/main/resources/rythm/union.txt +++ b/flowtype/generator/src/main/resources/rythm/union.txt @@ -4,4 +4,4 @@ @union.imports() @union.docString() -export type @union.typeName() = @union.memberUnionTypeExpression(); +export type @union.typeName() = @union.memberUnionTypeExpression(); \ No newline at end of file From e367417fa524c3ba0e2ab6795e0ffc6309eade98 Mon Sep 17 00:00:00 2001 From: Moaaz Sidat Date: Fri, 3 Nov 2017 11:02:06 -0700 Subject: [PATCH 22/23] fix flow errors --- .../src/main/java/org/coursera/courier/FlowtypeGenerator.java | 4 ++-- .../runtime/{CourierRuntime.ts => CourierRuntime.js} | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) rename flowtype/generator/src/main/resources/runtime/{CourierRuntime.ts => CourierRuntime.js} (98%) diff --git a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java index fa8b8e64..965454b7 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/FlowtypeGenerator.java @@ -87,8 +87,8 @@ public static void main(String[] args) throws Throwable { System.out.println(file.getAbsolutePath()); } - InputStream runtime = FlowtypeGenerator.class.getClassLoader().getResourceAsStream("runtime/CourierRuntime.ts"); - IOUtils.copy(runtime, new FileOutputStream(new File(targetPath, "CourierRuntime.ts"))); + InputStream runtime = FlowtypeGenerator.class.getClassLoader().getResourceAsStream("runtime/CourierRuntime.js"); + IOUtils.copy(runtime, new FileOutputStream(new File(targetPath, "CourierRuntime.js"))); } public FlowtypeGenerator() { diff --git a/flowtype/generator/src/main/resources/runtime/CourierRuntime.ts b/flowtype/generator/src/main/resources/runtime/CourierRuntime.js similarity index 98% rename from flowtype/generator/src/main/resources/runtime/CourierRuntime.ts rename to flowtype/generator/src/main/resources/runtime/CourierRuntime.js index 6272d9be..b2a5e4d9 100644 --- a/flowtype/generator/src/main/resources/runtime/CourierRuntime.ts +++ b/flowtype/generator/src/main/resources/runtime/CourierRuntime.js @@ -1,3 +1,4 @@ +// @flow // // Copyright 2016 Coursera Inc. // From 909c7f2869a15b770ad66b26b7d4d729d40d5976 Mon Sep 17 00:00:00 2001 From: kyle-verhoog Date: Fri, 3 Nov 2017 11:16:58 -0700 Subject: [PATCH 23/23] Fix recursively defined records --- .gitignore | 3 +++ .../org/coursera/courier/flowtype/FlowtypeSyntax.java | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d7938db0..49d5b953 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ project/plugins/project/ # .arcconfig .arclint + +# npm +npm-debug.log diff --git a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java index 856cd292..71786c9b 100644 --- a/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java +++ b/flowtype/generator/src/main/java/org/coursera/courier/flowtype/FlowtypeSyntax.java @@ -43,7 +43,7 @@ * * Most work delegates to inner classes, so you probably want to look them (linked below) * - * Specifically, {@link TSEnumSyntax}, {@link FlowtypeUnionSyntax}, {@link FlowtypeRecordSyntax}, and {@link FlowtypeTyperefSyntax} are + * Specifically, {@link FlowtypeEnumSyntax}, {@link FlowtypeUnionSyntax}, {@link FlowtypeRecordSyntax}, and {@link FlowtypeTyperefSyntax} are * used directly to populate the templates. * * @see TSPrimitiveTypeSyntax @@ -846,12 +846,14 @@ public boolean requiresCompanionModule() { return !ClassTemplateSpecs.allContainedTypes(_template).isEmpty(); } - /** The complete typescript import block for this record */ + /** The complete flowtype import block for this record */ public String imports() { Set imports = new HashSet<>(); for (FlowRecordFieldSyntax fieldSyntax: this.fields()) { - imports.addAll(fieldSyntax.typeModules()); + if (fieldSyntax.typeName() != this.typeName()) { + imports.addAll(fieldSyntax.typeModules()); + } } for (FlowtypeUnionSyntax union: this.enclosedUnions()) {