https://github.com/danielpza/typescript-infer-types
Infer types from typescript code
https://github.com/danielpza/typescript-infer-types
generator type-safety typescript
Last synced: 21 days ago
JSON representation
Infer types from typescript code
- Host: GitHub
- URL: https://github.com/danielpza/typescript-infer-types
- Owner: danielpza
- License: mit
- Created: 2019-07-23T23:01:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-13T22:28:00.000Z (almost 6 years ago)
- Last Synced: 2025-03-07T00:14:52.752Z (over 1 year ago)
- Topics: generator, type-safety, typescript
- Language: TypeScript
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# typescript-infer-types
[](https://www.npmjs.com/package/typescript-infer-types)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
Infer types from typescript code.
This is currently under develop, feel free to try it and report any issues or features request you might have.
## Install
```sh
$ npm i -g typescript-infer-types
```
## Example
```ts
// input.ts
let a = true;
hello = "world";
EXTERNAL.DEPP.VAR = a;
EXTERNAL.foo(3);
let c = EXTERNAL.BAR;
let d = BAR;
c = 3;
d = 4;
c = EXTERNAL.BARR;
foo("asdf");
```
Then extract external definitions (outputs to stdout):
```sh
$ typescript-infer-types input.ts
declare let hello: string;
declare let EXTERNAL: { DEPP: { VAR: boolean }, foo: ((...args: [number]) => any), BAR: any, BARR: any };
declare let BAR: any;
declare let foo: ((...args: [string]) => any);
```
## Roadmap
- [ ] Anotate variables (fix missing types in source code)
- [ ] ...sugestions?