Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: examples generator #288

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

czlowiek488
Copy link

@czlowiek488 czlowiek488 commented Jun 29, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[X] Documentation content changes
[X] Other... Please describe: CD related changes

What is the current behavior?

Issue Number: #268

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

I prepared a generator for examples since I don't want anyone to forget about updating those.
If you add @automaticallyGeneratedExamples in jsdoc and run generator, if the corresponding json file will be found it will put no more than 3 json file data elements after @example jsdoc property.
If there is no examples it will add new.
If there are already examples it will replace them.
Keep in mind that everything in comment after @automaticallyGeneratedExamples will be replaced by examples.
Currently all files has well and consistent strucutre.
If something will be wrong with the files which are processed ( for example not consistent structure ) it will store an error and after processing list error array.

If generator fails somehow on generating it will store error and list of errors will be shown before the result of generation like.

Generating examples...
file is missing '@automaticallyGeneratedExamples' and will be ignored accessory.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored airline.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored airport.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored american-football-team.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored animal-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored aws-region.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored aws-service.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored baseball-team.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored basketball-team.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored bear.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored book.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored brand.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored browser.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored cardinal-direction.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored cat.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored catch-phrase.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored cetacean.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored city.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored clothing-size.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored code-snippet.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored color.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored company-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored country-code.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored country.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored county.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored cow.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored credit-card-brand.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored credit-card-number.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored crocodilia.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored currency-code.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored currency-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored currency-symbol.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored database-collation.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored database-column.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored database-engine.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored database-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored department.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored direction.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored directory-path.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored dog.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored domain-suffix.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored drinks.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored email-provider.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored emoji.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored ethereum-address.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored file-ext.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored file-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored file-path.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored file-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored first-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored fish.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored font-family.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored food.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored football-team.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored frequency.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored gender.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored git-branch.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored horse.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored http-method.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored ice-hockey-team.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored integration.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored job-area.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored job-descriptor.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored job-title.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored job-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored language.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored last-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored lines.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored lion.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored locale.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored mime-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored month.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored movie-character.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored movie.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored music-genre.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored oauth-provider.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored ordinal-direction.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored paragraph.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored permission.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored person-title.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored phone-number.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored phrase.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored priority.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored product-adjective.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored product-category.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored product-description.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored product-material.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored product-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored product.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored programming-language.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored pronoun.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored protocol.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored quote.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored rabbit.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored role.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored sentence.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored shape.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored singer.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored skill.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored snake.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored social.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored song.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored state-abbr.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored state.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored status.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored street-name.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored subscription-plan.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored superhero.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored svg.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored time-zone.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored transaction-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored user-agent.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored vehicle-fuel.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored vehicle-manufacturer.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored vehicle-model.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored vehicle-type.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored vehicle.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored verb.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored weekday.ts
file is missing '@automaticallyGeneratedExamples' and will be ignored word.ts
[
  {
    filename: 'bird.i18n.json',
    error: Error: ENOENT: no such file or directory, open './packages/falso/src/lib/bird.i18n.ts'
        at Object.openSync (fs.js:462:3)
        at Object.readFileSync (fs.js:364:35)
        at /home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:17:32
        at Array.forEach (<anonymous>)
        at Object.<anonymous> (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:14:11)
        at Module._compile (internal/modules/cjs/loader.js:999:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
        at Module.load (internal/modules/cjs/loader.js:863:32)
        at Function.Module._load (internal/modules/cjs/loader.js:708:14)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
      errno: -2,
      syscall: 'open',
      code: 'ENOENT',
      path: './packages/falso/src/lib/bird.i18n.ts'
    }
  },
  {
    filename: 'gender-code.json',
    error: Error: ENOENT: no such file or directory, open './packages/falso/src/lib/gender-code.ts'
        at Object.openSync (fs.js:462:3)
        at Object.readFileSync (fs.js:364:35)
        at /home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:17:32
        at Array.forEach (<anonymous>)
        at Object.<anonymous> (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:14:11)
        at Module._compile (internal/modules/cjs/loader.js:999:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
        at Module.load (internal/modules/cjs/loader.js:863:32)
        at Function.Module._load (internal/modules/cjs/loader.js:708:14)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
      errno: -2,
      syscall: 'open',
      code: 'ENOENT',
      path: './packages/falso/src/lib/gender-code.ts'
    }
  },
  {
    filename: 'language-code.json',
    error: Error: ENOENT: no such file or directory, open './packages/falso/src/lib/language-code.ts'
        at Object.openSync (fs.js:462:3)
        at Object.readFileSync (fs.js:364:35)
        at /home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:17:32
        at Array.forEach (<anonymous>)
        at Object.<anonymous> (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:14:11)
        at Module._compile (internal/modules/cjs/loader.js:999:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
        at Module.load (internal/modules/cjs/loader.js:863:32)
        at Function.Module._load (internal/modules/cjs/loader.js:708:14)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
      errno: -2,
      syscall: 'open',
      code: 'ENOENT',
      path: './packages/falso/src/lib/language-code.ts'
    }
  },
  {
    filename: 'protocol-full.json',
    error: Error: ENOENT: no such file or directory, open './packages/falso/src/lib/protocol-full.ts'
        at Object.openSync (fs.js:462:3)
        at Object.readFileSync (fs.js:364:35)
        at /home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:17:32
        at Array.forEach (<anonymous>)
        at Object.<anonymous> (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:14:11)
        at Module._compile (internal/modules/cjs/loader.js:999:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
        at Module.load (internal/modules/cjs/loader.js:863:32)
        at Function.Module._load (internal/modules/cjs/loader.js:708:14)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
      errno: -2,
      syscall: 'open',
      code: 'ENOENT',
      path: './packages/falso/src/lib/protocol-full.ts'
    }
  }
]
Generating examples finished 121/125

If you have any questions feel free to ask.

I hope we will be able to enjoy this feature soon :)

@czlowiek488 czlowiek488 force-pushed the examples-generator branch 7 times, most recently from fd7c463 to 2564054 Compare June 29, 2022 18:41
@NetanelBasal
Copy link
Member

What about functions such as dates, etc?

@czlowiek488
Copy link
Author

czlowiek488 commented Jun 30, 2022

If you wish to add examples for the functions without a json file I see 2 options

  • add examples manually
  • add json file to them

On the other hand, instead of taking examples from data files we can generate examples using a rand function.
This solution would cover all the randomize functions however examples will be randomized and changed each release - and that's a reason why I decided to use static data, to give better control of what examples actually are.

@NetanelBasal
Copy link
Member

This solution would cover all the randomize functions however examples will be randomized and changed each release

I don't see any issue with this.

@czlowiek488
Copy link
Author

I personally don't think it is a good idea.
I wouldn't like to give up control since we don't know what the future brings.

If you don't mind I would like to introduce a new json files instead.
Adding new files will make codebase more consistent.

However I am not gonna block this issue just because of what I belives, so if you wish to make it in a different way I will be fine with other solution.

@NetanelBasal
Copy link
Member

The disadvantage of json files is that we need to maintain them.

@czlowiek488
Copy link
Author

Yeah sure but what's the real cost of maintance of those files?
I am not quiet familiar with changes which were introduced here in the past however, from my experience result of the functions that generates specific data does not change so often.

Now I think about hybrid option, where 1 attempt is to use a data from file, but 2 attempt is to generate examples from function itself.

What do you think?

@NetanelBasal
Copy link
Member

That's what I meant from the beginning. If we have a data file, use it; otherwise, produce it.

@czlowiek488 czlowiek488 force-pushed the examples-generator branch from b81b791 to fb642a3 Compare July 1, 2022 17:01
@czlowiek488
Copy link
Author

Suggested functionality was added.
I also changed how the result is showed since it was pretty unreadeble before.

Now it look like this:

$ ts-node ./scripts/example-generator.js ./packages/falso/src/lib/

Generating examples...
<<-- Generator Errors -->>
--> 193 - '@automaticallyGeneratedExamples' is missing in jsdoc:
   [accessory, address, airline, airport-code, airport-name, airport, alpha-numeric, alpha, american-football-team, amount, animal-type, arn, avatar, aws-region, aws-request-id, aws-service, baseball-team, basketball-team, bear, between-date, bic, binary, bird, bitcoin-address, book, boolean, brand, browser, cardinal-direction, cat, catch-phrase, cetacean, city, clothing-size, code-snippet, color, company-name, country-code, country, county, cow, credit-card-brand, credit-card-cvv, credit-card-number, credit-card, crocodilia, currency-code, currency-name, currency-symbol, database-collation, database-column, database-engine, database-type, department, direction, directory-path, dog, domain-name, domain-suffix, drinks, email-provider, email, emoji, ethereum-address, file-ext, file-name, file-path, file-type, first-name, fish, flight-details, flight-number, float, font-family, font-size, food, football-team, frequency, full-address, full-name, future-date, gender, git-branch, git-commit-entry, git-commit-message, git-commit-sha, git-short-sha, hex, hexa-decimal, horse, hsl, http-method, iban, ice-hockey-team, img, integration, ip, ipv6, job-area, job-descriptor, job-title, job-type, json, language, last-name, latitude, line, lines, lion, locale, longitude, mac, mask, mime-type, month, movie-character, movie, music-genre, nearby-gpscoordinate, number, oauth-provider, octal, ordinal-direction, paragraph, password, past-date, permission, person-title, phone-number, phrase, port, post, priority, product-adjective, product-category, product-description, product-material, product-name, product, programming-language, pronoun, protocol, quote, rabbit, rand, random, recent-date, rgb, role, routing-number, seat-number, semver, sentence, sequence, shape, singer, skill, slug, snake, social, song, soon-date, sports-team, sports, state-abbr, state, status, street-address, street-name, subscription-plan, superhero-name, superhero, svg, swift, text-range, text, time-zone, todo, transaction-type, url, user-agent, user-name, user, uuid, vehicle-fuel, vehicle-manufacturer, vehicle-model, vehicle-type, vehicle, verb, weekday, word, zip-code]
--> 5 - corresponding ts file does not exists:
   [core, gender-code, i18n, language-code, protocol-full]
--> 0 - 'json.data' field is missing:
   []
--> 0 - 'json.data' field value is not array:
   []
--> 0 - 'json.data' field value is empty array:
   []
--> 0 - ts file must contain function which name starts with 'rand':
   []

<<-- Generator Result -->>    
--> generated: 2
--> files: 200

I belive someone more familiar with CI/CD could automate example generation. Or at least check my solution, I am not so sure about using prepublish hook.

@czlowiek488 czlowiek488 changed the title feat: examples generator v1 feat: examples generator Jul 1, 2022
@czlowiek488 czlowiek488 force-pushed the examples-generator branch 3 times, most recently from 7d09f46 to c685cfa Compare July 1, 2022 18:20
@czlowiek488
Copy link
Author

I changed the way script is executed to give more flexability.
./node_modules/.bin/ts-node ./scripts/example-generator.js ./packages/falso/src/lib/ @automaticallyGeneratedExamples

@czlowiek488 czlowiek488 force-pushed the examples-generator branch 3 times, most recently from 894d276 to e1150f5 Compare July 1, 2022 18:49
package.json Outdated Show resolved Hide resolved
@czlowiek488
Copy link
Author

czlowiek488 commented Jul 3, 2022

Tell me if you see more issues to resolve before adding generator indicator to other files.

@czlowiek488
Copy link
Author

Is something wrong? I would like to finish it, do you have something in mind you would like to clarify before merging?

@NetanelBasal
Copy link
Member

Can you please fix the conflicts?

@czlowiek488
Copy link
Author

czlowiek488 commented Jul 19, 2022

I fixed conflicts and added indicator to every file with generator.
It looks pretty nice. However there is a bug.
Sometimes (73 times) when generator uses a function to generate an example ts-node throws an error about wrong types, even with -T flag builded js throws other errors.
I tried to fix it but I can't. I wish some would like to help here.
The result of script.

We already have 117 generated examples so I think we may consider closing this issue merging and releasing those examples and opening a new one with a bug.
@NetanelBasal What do you think?

$ npm run generate-examples

> [email protected] generate-examples
> ./node_modules/.bin/ts-node ./scripts/example-generator.js ./packages/falso/src/lib/ @automaticallyGeneratedExamples

Generating examples...
packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/address.ts:55:7 - error TS2322: Type 'unknown' is not assignable to type 'string'.

55       city: randCity(),
         ~~~~

  packages/falso/src/lib/address.ts:15:3
    15   city: string;
         ~~~~
    The expected type comes from property 'city' which is declared here on type 'Address'
packages/falso/src/lib/address.ts:60:7 - error TS2322: Type 'unknown' is not assignable to type 'string | undefined'.
  Type 'unknown' is not assignable to type 'string'.

60       address.county = randCounty();
         ~~~~~~~~~~~~~~
packages/falso/src/lib/address.ts:64:7 - error TS2322: Type 'unknown' is not assignable to type 'string | undefined'.
  Type 'unknown' is not assignable to type 'string'.

64       address.country = randCountry();
         ~~~~~~~~~~~~~~~

packages/falso/src/lib/airport-code.ts:2:22 - error TS2732: Cannot find module './airport.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

2 import { data } from './airport.json';
                       ~~~~~~~~~~~~~~~~
packages/falso/src/lib/airport-code.ts:26:29 - error TS7031: Binding element 'code' implicitly has an 'any' type.

26     return rand(data.map(({ code }) => code));
                               ~~~~

packages/falso/src/lib/airport-name.ts:2:22 - error TS2732: Cannot find module './airport.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

2 import { data } from './airport.json';
                       ~~~~~~~~~~~~~~~~
packages/falso/src/lib/airport-name.ts:26:29 - error TS7031: Binding element 'name' implicitly has an 'any' type.

26     return rand(data.map(({ name }) => name));
                               ~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/bird.ts:2:22 - error TS2732: Cannot find module './bird.i18n.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

2 import { data } from './bird.i18n.json';
                       ~~~~~~~~~~~~~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/flight-details.ts:59:9 - error TS2322: Type '() => { passenger: string; airline: Airline; flightNumber: string; origin: unknown; destination: unknown; date: string; seat: string; flightLength: number; }' is not assignable to type '() => FlightDetails'.
  Call signature return types '{ passenger: string; airline: Airline; flightNumber: string; origin: unknown; destination: unknown; date: string; seat: string; flightLength: number; }' and 'FlightDetails' are incompatible.
    The types of 'origin' are incompatible between these types.
      Type 'unknown' is not assignable to type 'Airport'.

59   const factory: () => FlightDetails = () => {
           ~~~~~~~

packages/falso/src/lib/flight-number.ts:3:27 - error TS2732: Cannot find module './airline.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

3 import * as airlines from './airline.json';
                            ~~~~~~~~~~~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/hex.ts:2:10 - error TS2305: Module '"./random"' has no exported member 'random'.

2 import { random } from './random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/post.ts:37:7 - error TS2322: Type 'unknown' is not assignable to type 'string'.

37       title: randText({ charCount: 40 }),
         ~~~~~

  packages/falso/src/lib/post.ts:9:3
    9   title: string;
        ~~~~~
    The expected type comes from property 'title' which is declared here on type 'Post'
packages/falso/src/lib/post.ts:38:7 - error TS2322: Type 'unknown' is not assignable to type 'string'.

38       body: randText({ charCount: 500 }),
         ~~~~

  packages/falso/src/lib/post.ts:10:3
    10   body: string;
         ~~~~
    The expected type comes from property 'body' which is declared here on type 'Post'
packages/falso/src/lib/post.ts:39:7 - error TS2322: Type '{ id: string; text: unknown; user: User; }[]' is not assignable to type '{ id: string; text: string; user: User; }[]'.
  Type '{ id: string; text: unknown; user: User; }' is not assignable to type '{ id: string; text: string; user: User; }'.
    Types of property 'text' are incompatible.
      Type 'unknown' is not assignable to type 'string'.

39       comments: Array.from({ length: randNumber({ min: 1, max: 5 }) }, () => {
         ~~~~~~~~

  packages/falso/src/lib/post.ts:11:3
    11   comments: Array<{ id: string; text: string; user: User }>;
         ~~~~~~~~
    The expected type comes from property 'comments' which is declared here on type 'Post'

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Object.getExamplesFromTs (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:46:31)
    at generateExamples (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:73:19)
    at Array.reduce (<anonymous>)
    at Object.<anonymous> (/home/lukasz/workspace/packages/falsofork/falso/scripts/example-generator.js:86:41)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at phase4 (/home/lukasz/workspace/packages/falsofork/falso/node_modules/ts-node/src/bin.ts:579:12)
packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/sequence.ts:2:10 - error TS2305: Module '"./random"' has no exported member 'random'.

2 import { random } from './random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/superhero-name.ts:3:22 - error TS2732: Cannot find module './superhero.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

3 import { data } from './superhero.json';
                       ~~~~~~~~~~~~~~~~~~
packages/falso/src/lib/superhero-name.ts:31:24 - error TS7031: Binding element 'company' implicitly has an 'any' type.

31       ? data.filter(({ company }) => company === options.company)
                          ~~~~~~~

packages/falso/src/lib/swift.ts:83:11 - error TS2322: Type 'unknown' is not assignable to type 'string'.

83     const countryCode: string = options?.countryCode ?? randCountryCode();
             ~~~~~~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/text.ts:46:12 - error TS2571: Object is of type 'unknown'.

46     while (text.length < charCount) {
              ~~~~
packages/falso/src/lib/text.ts:50:12 - error TS2571: Object is of type 'unknown'.

50     text = text.substring(0, charCount - 2);
              ~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/user.ts:52:37 - error TS2322: Type 'unknown' is not assignable to type 'string | undefined'.
  Type 'unknown' is not assignable to type 'string'.

52       email: randEmail({ firstName, lastName }),
                                       ~~~~~~~~
packages/falso/src/lib/user.ts:54:7 - error TS2322: Type 'unknown' is not assignable to type 'string'.

54       lastName,
         ~~~~~~~~

  packages/falso/src/lib/user.ts:14:3
    14   lastName: string;
         ~~~~~~~~
    The expected type comes from property 'lastName' which is declared here on type 'User'
packages/falso/src/lib/user.ts:57:43 - error TS2322: Type 'unknown' is not assignable to type 'string | undefined'.
  Type 'unknown' is not assignable to type 'string'.

57       username: randUserName({ firstName, lastName }),
                                             ~~~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

packages/falso/src/lib/core/core.ts:1:10 - error TS2305: Module '"../random"' has no exported member 'random'.

1 import { random } from '../random';
           ~~~~~~

<<-- Generator Errors -->>
--> 0 - '@automaticallyGeneratedExamples' is missing in jsdoc:
   []
--> 6 - corresponding ts file does not exists:
   [core, factories, gender-code, i18n, language-code, protocol-full]
--> 0 - 'json.data' field is missing:
   []
--> 5 - 'json.data' field value is not array:
   [code-snippet, first-name, food, last-name, sports]
--> 0 - 'json.data' field value is empty array:
   []
--> 0 - ts file must contain function which name starts with 'rand':
   []
--> 73 - fileReadError:
   [account, address, airport-code, airport-name, alpha-numeric, alpha, amount, arn, avatar, aws-request-id, between-date, bic, binary, bird, bitcoin-address, boolean, credit-card-cvv, credit-card, domain-name, email, flight-details, flight-number, float, font-size, full-address, full-name, future-date, git-commit-entry, git-commit-message, git-commit-sha, git-short-sha, hex, hexa-decimal, hsl, iban, img, ip, ipv6, json, latitude, line, longitude, mac, mask, nearby-gpscoordinate, number, octal, password, past-date, port, post, rand, random, recent-date, rgb, routing-number, seat-number, semver, sequence, slug, soon-date, sports-team, street-address, superhero-name, swift, text-range, text, todo, url, user-name, user, uuid, zip-code]

<<-- Generator Result -->>
--> generated: 117
--> files: 201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants