GithubHelp home page GithubHelp logo

TypeScript compilation error after adding the first service - service x.validate has not exported member 'create' about generator-feathers-plus HOT 7 CLOSED

feathers-plus avatar feathers-plus commented on July 2, 2024
TypeScript compilation error after adding the first service - service x.validate has not exported member 'create'

from generator-feathers-plus.

Comments (7)

eddyystop avatar eddyystop commented on July 2, 2024

Darn. Thanks for pointing this out.

j2L3e: I added the import from serviceName.validate.?s recently. Nothing refers to the "imported" values. It works for JS but not for TS.

f+/cli has been updated to generate that line commented out. We'll fix it in the next day or two.

Published as f+/cli v0.7.21 using generator v0.6.20.

from generator-feathers-plus.

j2L4e avatar j2L4e commented on July 2, 2024

The issue is TypeScript's export default being compiled to module.exports.default =.
A ts default export can't be destructured in the import directly.
Keeping the exports unchanged this would work:
import validate from 'service.validate.ts' and then destructure with const {...} = validate;

from generator-feathers-plus.

j2L4e avatar j2L4e commented on July 2, 2024

The TS way would be named exports, but that would need a lot more changes

from generator-feathers-plus.

eddyystop avatar eddyystop commented on July 2, 2024

I would go for the named exports but for backward compatibility. I assume we can go with

export default moduleExports;
export const create;
...
export function validateCreate;
...

which, although ugly, provides backward compatibility and lets TS use the import { ... } from syntax?

from generator-feathers-plus.

eddyystop avatar eddyystop commented on July 2, 2024

j2L4e's suggestion published as f+/cli v0.7.22 using generator v0.6.21.

from generator-feathers-plus.

ewildee avatar ewildee commented on July 2, 2024

Thanks for solving this issue so quickly!

I solved the problem myself by exporting the moduleExports object directly like export { create, .., quickValidate }, but this doesn't give backward compatibility in js.

(I don't know if reopening this ticket is appropriate, but I appreciate your tools very much and would like to thank you)

from generator-feathers-plus.

eddyystop avatar eddyystop commented on July 2, 2024

Thanks are always very appreciated.

from generator-feathers-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.