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

Fail to try Deno Demo example #2459

Closed
YievCkim opened this issue Oct 5, 2021 · 6 comments
Closed

Fail to try Deno Demo example #2459

YievCkim opened this issue Oct 5, 2021 · 6 comments

Comments

@YievCkim
Copy link

YievCkim commented Oct 5, 2021

Steps to reproduce

I am discovering feathers as I try to find a web framework for deno. I know bout feathers here: https://deno.land/x/[email protected]

sadly the demo code given on deno.land doesn't build. I have made some obvious fix but running this script till fails with an error in feathers.

This is my program:

// app.ts
import { feathers } from 'https://deno.land/x/[email protected]/mod.ts';

type Message = {
  message: string;
}

class MyService {
  async create (data: Message) {
    return data;
  }
}

type ServiceTypes = {
  myservice: MyService
}

const app = feathers<ServiceTypes>();

app.use('myservice', new MyService());

app.service('myservice').on('created', (data: Message) => {
  console.log('Created', data);
});

await app.service('myservice').create({
  message: 'Hello from Deno'
});

And this is the errors I got with:

% deno run --allow-net test.ts
Download https://deno.land/x/[email protected]/mod.ts
Download https://deno.land/x/[email protected]/_feathers/mod.ts
Download https://deno.land/x/[email protected]/_feathers/service.ts
Download https://deno.land/x/[email protected]/_feathers/hooks/index.ts
Download https://deno.land/x/[email protected]/_feathers/dependencies.ts
Download https://deno.land/x/[email protected]/_feathers/version.ts
Download https://deno.land/x/[email protected]/_feathers/declarations.ts
Download https://deno.land/x/[email protected]/_feathers/application.ts
Download https://deno.land/x/[email protected]/_events/events.js
Download https://deno.land/x/[email protected]/_commons/mod.ts
Download https://deno.land/x/[email protected]/_feathers/events.ts
Download https://deno.land/x/[email protected]/_feathers/hooks/legacy.ts
Download https://deno.land/x/[email protected]/_commons/debug.ts
Check file:///Users/mickaelviey/Dev/troll-tracker/test.ts
error: TS2532 [ERROR]: Object is possibly 'undefined'.
    typeof service[m] === 'function' && !methods.includes(m)
                                         ~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/service.ts:30:42

TS2769 [ERROR]: No overload matches this call.
  Overload 1 of 2, '(...items: ConcatArray<string>[]): string[]', gave the following error.
    Argument of type 'string[] | undefined' is not assignable to parameter of type 'ConcatArray<string>'.
      Type 'undefined' is not assignable to type 'ConcatArray<string>'.  Overload 2 of 2, '(...items: (string | ConcatArray<string>)[]): string[]', gave the following error.
    Argument of type 'string[] | undefined' is not assignable to parameter of type 'string | ConcatArray<string>'.
      Type 'undefined' is not assignable to type 'string | ConcatArray<string>'.
  ).concat(methods);
           ~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/service.ts:31:12



TS2769 [ERROR]: No overload matches this call.
  Overload 1 of 2, '(o: {}): string[]', gave the following error.
    Argument of type 'string[] | undefined' is not assignable to parameter of type '{}'.
      Type 'undefined' is not assignable to type '{}'.  Overload 2 of 2, '(o: object): string[]', gave the following error.
    Argument of type 'string[] | undefined' is not assignable to parameter of type 'object'.
      Type 'undefined' is not assignable to type 'object'.
  if (Object.keys(serviceOptions.methods).length === 0 && typeof service.setup !== 'function') {
                  ~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/service.ts:72:19



TS2532 [ERROR]: Object is possibly 'undefined'.
    if (typeof context.event === 'string' && !events.includes(context.event)) {
                                              ~~~~~~
    at https://deno.land/x/[email protected]/_feathers/events.ts:16:47

TS2532 [ERROR]: Object is possibly 'undefined'.
    const appHooks = app.appHooks[HOOKS].concat(app.appHooks[this.method] || []);
                     ~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/hooks/index.ts:38:22

TS2531 [ERROR]: Object is possibly 'null'.
    this._middleware.push(...mw);
    ~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/hooks/index.ts:55:5

TS2322 [ERROR]: Type '<A>(this: A, service: FeathersService<A, Service<any, Partial<any>>>, path: string, options: ServiceOptions) => FeathersService<...>' is not assignable to type 'ServiceMixin<Application<ServiceTypes, AppSettings>>'.
  Types of parameters 'options' and 'options' are incompatible.
    Type 'ServiceOptions | undefined' is not assignable to type 'ServiceOptions'.
      Type 'undefined' is not assignable to type 'ServiceOptions'.
  mixins: ServiceMixin<Application<ServiceTypes, AppSettings>>[] = [ hookMixin, eventMixin ];
                                                                     ~~~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/application.ts:29:70

TS2345 [ERROR]: Argument of type 'ServiceOptions | undefined' is not assignable to parameter of type 'ServiceOptions'.
  Type 'undefined' is not assignable to type 'ServiceOptions'.
    const protoService = wrapService(location, service, options);
                                                        ~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/application.ts:97:57

TS2532 [ERROR]: Object is possibly 'undefined'.
      this.appHooks[HOOKS].push(...hookMap as any);
      ~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/application.ts:124:7

TS2769 [ERROR]: No overload matches this call.
  Overload 1 of 2, '(...items: ConcatArray<HookFunction<Application<ServiceTypes, AppSettings>, any>>[]): HookFunction<Application<ServiceTypes, AppSettings>, any>[]', gave the following error.
    Argument of type 'HookFunction<Application<ServiceTypes, AppSettings>, any>[] | undefined' is not assignable to parameter of type 'ConcatArray<HookFunction<Application<ServiceTypes, AppSettings>, any>>'.
      Type 'undefined' is not assignable to type 'ConcatArray<HookFunction<Application<ServiceTypes, AppSettings>, any>>'.  Overload 2 of 2, '(...items: (HookFunction<Application<ServiceTypes, AppSettings>, any> | ConcatArray<HookFunction<Application<ServiceTypes, AppSettings>, any>>)[]): HookFunction<...>[]', gave the following error.
    Argument of type 'HookFunction<Application<ServiceTypes, AppSettings>, any>[] | undefined' is not assignable to parameter of type 'HookFunction<Application<ServiceTypes, AppSettings>, any> | ConcatArray<HookFunction<Application<ServiceTypes, AppSettings>, any>>'.
      Type 'undefined' is not assignable to type 'HookFunction<Application<ServiceTypes, AppSettings>, any> | ConcatArray<HookFunction<Application<ServiceTypes, AppSettings>, any>>'.
        this.appHooks[key] = methodHooks.concat(methodHookMap[key]);
                                                ~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/_feathers/application.ts:131:49



Found 10 errors.

System configuration

Module versions (especially the part that's not working):

deno.land/x/[email protected]/mod.ts

Deno version:

% deno --version      
deno 1.14.3 (release, x86_64-apple-darwin)
v8 9.4.146.16
typescript 4.4.2

Operating System:
MacOSX 11 (Big Sur)

@despiegk
Copy link

same problem here

@YievCkim YievCkim changed the title Fail to try Dene Demo example Fail to try Deno Demo example Oct 24, 2021
@IuryPiva
Copy link

Just a typescript warning, I got it working by running the flag --no-check which skip type checking modules.
e.g. deno run --allow-net main.ts --no-check

@FossPrime
Copy link
Member

The demo is a little bit outdated... I know beta 14 changed a substantial amount of types. Ideally the generator could generate Deno code... TS 4.5 with Node ESM mode is remarkcably close to how deno handles this... aside from the .ts/.js extension swap. But as it becomes mandatory with the combination of esModulesInterop: false, package.json/type: module and ts-node/type: module, it should be "easy" to implement.

Try doing a find and replace on the v5.0.0-pre.10 part of the version numbers to the latest.

@marshallswain
Copy link
Member

Update in this area: We are working on a complete port of Feathers core to Deno. Only the packages that have hard node dependencies, like Express, Koa, etc, will not be ported. Everything that gets moved to Deno will be published to both platforms. We have a bunch of contributions to merge before this, so it will take a while.

@daffl
Copy link
Member

daffl commented Nov 19, 2021

The main issue for Deno support is #1964, we'll track progress there.

@daffl daffl closed this as completed Nov 19, 2021
@SamuelQZQ
Copy link

Add this into you deno.json file can fix the problem.

{
    "compilerOptions": {
        "strictNullChecks": false,
        "noImplicitAny": false
    }
}

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

No branches or pull requests

7 participants