ts-nameof icon indicating copy to clipboard operation
ts-nameof copied to clipboard

How to use with Webstorm (plain typescript import would also be acceptable)

Open dheerajbhaskar opened this issue 6 years ago • 1 comments

I'm using: webstorm: 2018.3.1

and here is my package.json:

{
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
  },
  "author": "OSW Technologies Pvt Ltd",
  "license": "All rights reserved",
  "dependencies": {
    "chai": "^3.5.0",
    "chokidar": "^2.0.3",
    "filenamify": "^2.1.0",
    "jquery": "*",
    "lodash": "^4.17.10",
    "shelljs": "^0.8.3",
    "ts-nameof": "^2.0.0",
    "winston": "^3.1.0"
  },
  "devDependencies": {
    "@types/chai": "^3.5.2",
    "@types/chokidar": "^1.7.5",
    "@types/jquery": "^2.0.51",
    "@types/lodash": "^4.14.118",
    "@types/moment": "^2.13.0",
    "@types/node": "^10.12.11",
    "@types/shelljs": "^0.8.0",
    "ndb": "^1.0.38",
    "typescript": "^2.9.2"
  },
}

Issue

I would like to either use ts-nameof in a way which is compatible with webstorm. I've a tsconfig.json and not sure how to get ttypescript or webpack to work with webstorm. Can you please guide me?

I'd like it if it was just possible to import it and use it. Is this possible?

dheerajbhaskar avatar Dec 22 '18 12:12 dheerajbhaskar

Hey @dheerajbhaskar, it's not possible to import it because ts-nameof transforms the code at compile time. As a sidenote, you'll want to include it under devDependencies rather than dependencies for that reason.

I'm unfamiliar with webstorm, but I think it might work if you follow these instructions then find a way to execute npx ttsc in webstorm then it should work. Let me know how it goes.

I wish it were easier, but transformation plugins aren't built into the typescript compiler yet... hopefully one day.

dsherret avatar Jan 17 '19 03:01 dsherret