1. ts-ast-to-literal
Transform a TypeScript AST node into a real JS object.
ts-ast-to-literal
Package: ts-ast-to-literal
Created by: dword-design
Last modified: Mon, 04 Mar 2024 17:39:46 GMT
Version: 4.0.0
License: MIT
Downloads: 7,688
Repository: https://github.com/dword-design/ts-ast-to-literal

Install

npm install ts-ast-to-literal
yarn add ts-ast-to-literal

ts-ast-to-literal

npm version Linux macOS Windows compatible Build status Coverage status Dependency status Renovate enabled
Open in Gitpod Buy Me a Coffee PayPal Patreon

Transform a TypeScript AST node into a real JS object.

Special thanks to ast-to-literal for the initial idea 👏.

Install

 # npm
$ npm install ts-ast-to-literal

# Yarn
$ yarn add ts-ast-to-literal

Usage

 const ts = require('typescript')

const ast = ts.createSourceFile(
  'x.ts',
  `export default { foo: 'bar', num: 8 }`,
  ts.ScriptTarget.Latest
)

console.log(self(ast.statements[0].expression))
// { foo: 'bar', num: 8 }

Contribute

Are you missing something or want to contribute? Feel free to file an issue or a pull request! ⚙️

Support

Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:

Buy Me a Coffee  If you want to send me a one time donation. The coffee is pretty good 😊.
PayPal  Also for one time donations if you like PayPal.
Patreon  Here you can support me regularly, which is great so I can steadily work on projects.

Thanks a lot for your support! ❤️

License

MIT License © Sebastian Landwehr

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin