tsedio / tsed-cli

💻 CLI for Ts.ED framework
MIT License
42 stars 19 forks source link

[BUG] Minor issues with generated code #365

Closed KBroichhausen closed 4 months ago

KBroichhausen commented 5 months ago

Information

Following compile erros occur:

> npm run build

> tsedtest@1.0.0 build
> npm run barrels && tsc && babel src --out-dir dist --extensions ".ts,.tsx" --source-maps inline

> tsedtest@1.0.0 barrels
> barrelsby --config .barrelsby.json

src/config/index.ts:2:9 - error TS2305: Module '"./envs/index"' has no exported member 'envs'.

2 import {envs} from "./envs/index";
          ~~~~

src/datasources/PostgresDatasource.spec.ts:9:39 - error TS2749: 'PostgresDatasource' refers to a value, but is being used as a type here. Did you mean 'typeof PostgresDatasource'?

9     const instance = PlatformTest.get<PostgresDatasource>(PostgresDatasource);
                                        ~~~~~~~~~~~~~~~~~~

src/Server.integration.spec.ts:10:5 - error TS2322: Type 'TestAgent<Test>' is not assignable to type 'SuperTest<Test>'.
  Type 'TestAgent<Test>' is missing the following properties from type 'Stream': pipe, compose, addListener, removeListener, and 11 more.

10     request = SuperTest(PlatformTest.callback());
       ~~~~~~~

./envs/index only exports config and isProduction. I guess config should be imported in src/config/index.ts but that would also clash with the file defining export const config by itself. Maybe import like import {config as envConfig} from "./envs/index"; should be considered.

PostgresDatasource is actually the name from the exported DataSource. I guess it should be const instance = PlatformTest.get<DataSource>(PostgresDatasource); where DataSource is the type from typeorm package.

Never used SuperTest but the type seems to be just let request: SuperTest.Agent; instead of let request: SuperTest.SuperTest<SuperTest.Test>;

After fixing this, I get: Error: Cannot find package '@babel/plugin-proposal-object-rest-spread' [...]. Should be installed by the CLI.

Also the CLI page doesn't work: https://cli.tsed.io/

Example

Just follow the posted interaction with tsed cli.

Acceptance criteria

lunagloaming commented 5 months ago

I can confirm tsed init appears to work fine in release 5.0.1 as I was starting a new project and ran into this right away. (( At least, it doesn't exhibit the error on yarn build. ))

Romakita commented 4 months ago

Hello @KBroichhausen Thanks for this issue. I'll try to fix that asap :)

github-actions[bot] commented 4 months ago

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

Romakita commented 4 months ago

:tada: This issue has been resolved in version 5.0.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: