ts-transformer-keys: ts_transformer_keys_1.keys is not a function
Hi there!
This package sounds like the ideal solution to a problem I have but I am struggling to get past the following error: “TypeError: ts_transformer_keys_1.keys is not a function” and I am not sure how to tell if this is an error on my part or if there is something out of my control that is not working.
I have tried compiling the following file with typescript 2.4.0 and running in the browser with no other packages:
import { keys } from "ts-transformer-keys";
interface Props {
id: string;
name: string;
age: number;
}
const keysOfProps = keys<Props>();
console.log(keysOfProps);
I have also tried using ts-node and executing the same file from the command line, though here in particular I am unsure to what extend ts-node is a bottleneck.
I hope I’m missing something super simple!
Thanks in advance for any thoughts in any direction!
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 47
- Comments: 50 (13 by maintainers)
Was this fixed? I am getting the same issue
@martnst Sorry for the late response. If you are using Windows, the issue is probably fixed by this commit. Please try v0.3.1.
I get the same
TypeError: ts_transformer_keys_1.keys is not a functionby simply adding it viayarn add -D ts-transformer-keysand then trying to use it as of the example. It seems there is some step missing in the docs?Hi @kimamula I got around the issue… was a problem with how i used the transformer. thanks for the library… helps to solve a major issue i was facing with
I have the same error TypeError: ts_transformer_keys_1.keys is not a function
I do not have webpack
I have only tsconfig.json and package.json
How can I fix this error?
I’m in the exact same scenario above. Any solution or workaround on this issue?
I had the same problem i had to follow it using ttypescript.
npm install --save-dev typescript ttypescript"start":usettscinstead oftscI stopped getting the error after that 😅
I’m using TypeScript with React-Native, and error
ts_transformer_keys_1.keysstill appears, this is my devDendencies:and
tsconfig.json:How can i fix it?
For me the issue was that I used the fork-ts-checker-webpack-plugin and therefore set transpileOnly: true. If transpileOnly is true, this plugin does not work. Makes kinda sense, took me still quite a while to figure it out 😉.
TLDR: ensure transpileOnly is not set to true!
Regards Simon
Using nodejs with ts-node as
ts-node ./src/server.tsand gettingTypeError: (0 , ts_transformer_keys_1.keys) is not a functioncode
I’m on a mac. it seems like it is working for me with ttypecript (vsc hinting shows me that I have an array of union of valid properties), but in ts-jest I am getting this error. I believe my setup is equivalent to what is provided in the readme… I have the same custom file and this in package.json (instead of jest.config):
nvm, I realized that I just forgot to run
jest --clearCachefirst … it started working when I changed the factory to:I have this issue as well with pnpm when while using
ts-node --compiler ttypescript. No issues withttsc. It seems that the issue here is the filepath mismatch due to symbolic link created by pnpm while usingts-node.It can be fixed by changing
https://github.com/kimamula/ts-transformer-keys/blob/8a92a56719e97e1e849de5670148f09ff63aaf3f/transformer.ts#L61
to
Not sure if this is the right way to fix it. But it works.
@llanginger were you able to come up with a workaround. cause I too ran into the same issue trying to use this package.
@kimamula yup that works
@vmirage I found that using
require.resolve()instead ofpath.join()works and published the fixed version (v0.4.2). Please give it a try. Thanks again for your report!Hi,
I have listed several ways of how to use custom transformers in README. Which way are you using?
@macbric @martnst I confirmed the following works both on macOS and Windows (with TypeScript@2.8.3).
Could you provide your code so that I can investigate the problem?