You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typescript Quick Start example has type errors #2228
// these four, npm install each
import feathers from '@feathersjs/feathers';
import '@feathersjs/transport-commons';
import express from '@feathersjs/express';
import socketio from '@feathersjs/socketio';
It's this same issue I ran into a while ago. (#2120)
tsconfig.json MUST have "allowSyntheticDefaultImports": true,
This really should be put in big giant bold letters somewhere on the getting started page. It literally breaks the entire thing in typescript if you don't have that one tsconfig setting.
Ah. I've done the setup for a typescript project so many times that I did all the "create an npm project and install typescript" steps in the normal way that works for every other project.
I see that you're correct in that following these steps exactly would work. Nothing about the code snippet above implies the importance of "allowSyntheticDefaultImports" coming from the line npm init --yes.
I don't see any reason why such important configuration should be so obfuscated.
I don't remember what difference the ES2018 setting makes (imho it should be the default) but I think it had something to do with how imports are handled (it also doesn't transpile async/await and things like that since it's available in all supported Node versions).
Something I've been hoping to get some help with for a while is to store the last language tab (JS/TS) you selected (or have a language choose) in localstorage and always select that language by default. I think that would make going through the guide in that regard a little more clear.
Also, I still think that telling Typescript users that they absolutely must include "allowSyntheticDefaultImports": true in their tsconfig is important. I would be surprised if I'm the only one who sets up typescript projects from memory and has pre-existing tsconfig files they really like.
As I mentioned in #2228 (comment) before, the correct option is to set the compilation target to ES2018 which the documentation already mentions and the generator does automatically.
I'm not sure what exactly you are looking for. The current version is supposed to work with NodeJS 12 and up which natively supports ES2018 and later so setting that as your transpiler target as documented and mentioned several times now should not cause any other problems. In fact it will probably make things smoother by giving you better stacktraces and performance by relying on built-in async/await instead of pointlessly transpiling it to nested generator functions.
The target: ESAnything property has nothing to do with "allowSyntheticDefaultImports": true. They are two separate properties.
When you run tsc --init --target es2018 it just so happens that the allowSyntheticDefaultImports value gets set.
But if (like me) you copy a tsconfig.json that you like from some other project, there's a good chance it won't have the very important "allowSyntheticDefaultImports": true property.
Nothing about the documentation makes it clear that this would be an issue, but feathers-js won't transpile without it.
Further, if you had a project already started (like me), there's also very good chance that tsconfig.json will be missing allowSyntheticDefaultImports.
Activity
SephReed commentedon Feb 19, 2021
It's this same issue I ran into a while ago. (#2120)
tsconfig.json MUST have
"allowSyntheticDefaultImports": true,This really should be put in big giant bold letters somewhere on the getting started page. It literally breaks the entire thing in typescript if you don't have that one tsconfig setting.
SephReed commentedon Feb 19, 2021
feathersjs-ecosystem/docs#1518
daffl commentedon Feb 19, 2021
This happens when you do not follow the first TypeScript step in the guide, that specifies to use
tsc --init --target es2018:SephReed commentedon Feb 19, 2021
Ah. I've done the setup for a typescript project so many times that I did all the "create an npm project and install typescript" steps in the normal way that works for every other project.
I see that you're correct in that following these steps exactly would work. Nothing about the code snippet above implies the importance of "allowSyntheticDefaultImports" coming from the line
npm init --yes.I don't see any reason why such important configuration should be so obfuscated.
daffl commentedon Feb 19, 2021
I don't remember what difference the ES2018 setting makes (imho it should be the default) but I think it had something to do with how imports are handled (it also doesn't transpile async/await and things like that since it's available in all supported Node versions).
Something I've been hoping to get some help with for a while is to store the last language tab (JS/TS) you selected (or have a language choose) in localstorage and always select that language by default. I think that would make going through the guide in that regard a little more clear.
SephReed commentedon Feb 21, 2021
That would be a nice feature for sure.
I seems you're using "vuepress" for your rendering, which is something I've never used before.
But honestly, for a feature like this, you could get away with just including a vanilla script. Here ya go:
This script will:
It's not tested.
Otherwise, you'll have to hook into the renderer, and that's a whole framework I've yet to learn.
mrobst commentedon Feb 25, 2021
I like the idea of the language selector. Will look into vuepress (at least add it to my backlog 😏)
SephReed commentedon Feb 26, 2021
Would be nice.
Also, I still think that telling Typescript users that they absolutely must include
"allowSyntheticDefaultImports": truein theirtsconfigis important. I would be surprised if I'm the only one who sets up typescript projects from memory and has pre-existingtsconfigfiles they really like.feathersjs-ecosystem/docs#1518
daffl commentedon Feb 26, 2021
As I mentioned in #2228 (comment) before, the correct option is to set the compilation target to ES2018 which the documentation already mentions and the generator does automatically.
SephReed commentedon Mar 3, 2021
I have my target set to
ESNextwhich works. And expecting users to only ever approach Feathers integration in this one specific way seems ludicrous.Is there any documentation anywhere which explains how to integrate Feathers into an existing project? I couldn't find any.
daffl commentedon Mar 3, 2021
I'm not sure what exactly you are looking for. The current version is supposed to work with NodeJS 12 and up which natively supports
ES2018and later so setting that as your transpiler target as documented and mentioned several times now should not cause any other problems. In fact it will probably make things smoother by giving you better stacktraces and performance by relying on built-inasync/awaitinstead of pointlessly transpiling it to nested generator functions.SephReed commentedon Mar 10, 2021
The
target: ESAnythingproperty has nothing to do with"allowSyntheticDefaultImports": true. They are two separate properties.When you run
tsc --init --target es2018it just so happens that theallowSyntheticDefaultImportsvalue gets set.But if (like me) you copy a
tsconfig.jsonthat you like from some other project, there's a good chance it won't have the very important"allowSyntheticDefaultImports": trueproperty.Nothing about the documentation makes it clear that this would be an issue, but feathers-js won't transpile without it.
Further, if you had a project already started (like me), there's also very good chance that
tsconfig.jsonwill be missingallowSyntheticDefaultImports.