ttypescript
elegos opened this issue ยท 6 comments
Hello!
Moving from ES to TS, I'm having big headaches, in particular when styled-components comes in. I used to run the bable plugin to have displayName and talkative class names.
The problem is that I'm working on a library, and not with a bundled application, which makes impossible for me to use webpack to create the dist files (I tried it, but it breaks all the module's paths!).
I found that here on github @cevek created a sort of tsc wrapper able to inject transformers before or after the compilation, called ttypescript
: https://github.com/cevek/ttypescript
I'd like to know if it would be possible to make this plugin compatible with ttypescript, so that I could avoid using webpack, or create a wrapper for it. Honestly I don't have the technical knowledge to do something like that.
Thank you very much for any response!
@elegos Thank you for the question.
Indeed, I think we need to have a documentation section how to use it with ttypescript
. I will verify and add documentation some time soon.
It seems that you can already use it with very simple config:
tsconfig.json
:
{
"compilerOptions": {
"plugins": [
{ "transform": "typescript-plugin-styled-components", "type": "config", "minify": true }
]
}
}
in addition to minify
option you can specify any other option.
The documentation will reflect more complicated cases.
Hello @Igorbek thanks for the prompt response!
I tried indeed to use it like that even without specifying the type: "config" and it seems to work! I was confused because the other transformer plugins used to expose the transformer directly, but this package exposes a transformer creator. Nonetheless ttypescript was able to handle it! Aweseome :)
@elegos if you don't specify the type: "config" you cannot provide options because default type is "program" which provide the ts program
as first argument to plugin
Hi.
I see in the Typescript documentation have the same "plugins" option, but the declaration is different.
The key is "name"
not the "transform"
.
But after running "tsc" I have not css classes as "ttsc" have.
Running with "ttsc" looks like:
{
"plugins": [{
"transform": "typescript-plugin-styled-components",
"type": "config"
}]
}
and have
css classes
Running with "tsc" looks like:
{
"plugins": [{
"name": "typescript-plugin-styled-components"
}]
}
and have not
css classes
Does something know why?
@MadMed677 TypeScript CLI compiler does not support plugins or transformers out of the box, and unlikely to support in foreseeable future (this is an explicit design decision).
The documentation demonstrate how plugins can be used in TypeScript language service. The example just shows how you can enable support of plugins in your own program that uses the service. For example, vscode uses such technique to enable some plugins which are installed through vscode (not in tsconfig).
I will definitely need to update documentation how to use the transformer with ttypescript
and why it cannot be used with tsc
. This will come soon.
Documentation (README file) has been updated.
Please feel free to open new issue an time.