Comments (6)
The build step uses the typescript compiler API rather than tsc
directly to add JSDoc annotations to the output (@constructor
, @enum
, @memberof
, etc) and for generating the docs, both of which require type information.
It also modifies the compiler output using UJS with some custom steps to strip multiple definitions of the compiler helpers like __extends
and to minify better by renaming private members (UJS does not rename them by default because JS doesn't have a concept of private members).
But both of these custom steps are only for quality-of-life improvements. Just running tsc
should produce a usable file that has the same API as the one built with the build script, and just minifying it with any minifier at default settings will produce a usable minified file.
from libjass.
The build step uses the typescript compiler API [...]
So I need to update the build step to use the new compiler API in order to make it work with the new Typescript version.
Just running tsc should produce a usable file that has the same API as the one built with the build script [...]
I don't know a lot about Typescript, but I tried running npm install --save-dev typescript@latest; npx tsc --outfile lib\libjass.js src\index.ts
and it returned those errors and no file. Am I missing something?
Edit: I tried npx tsc -p src\tsconfig.json
and it's now returning results. As I'm compiling it for Node I removed dom lib and I need to remove parts of code that depend on it.
Edit 2: I got it to compile without warnings. Instead of upgrading I just removed those quality-of-life improvements and features that I'm not planning to use (like rendering and web worker support). You can close this issue if you prefer.
from libjass.
So I need to update the build step to use the new compiler API in order to make it work with the new Typescript version.
To clarify what I said, the current script hooks into the compiler internals because "add JSDoc comments to the compiler output" is not something the compiler API supports. So it's almost certain it won't work without modification if you update the compiler, which is why you got the error that you got in the OP.
I tried running
npm install --save-dev typescript@latest; npx tsc --outfile lib\libjass.js src\index.ts
and it returned those errors and no file. Am I missing something?
As you found, you need to give it the path of the project file (tsconfig.json
), not the index.ts
As I'm compiling it for Node I removed dom lib and I need to remove parts of code that depend on it.
Did you do this because you got compiler errors with the new TS's dom.d.ts
? Or just to slim down the output?
Edit 2: I got it to compile without warnings. Instead of upgrading
Right, I wasn't suggesting that you actually try to update the build script code to work with newer TS. That's why I said to just run tsc
directly.
I didn't really have a plan to update the TS version because the current one is good enough for a project that isn't being developed any more, ie it works and produces a usable output. Newer TS obviously has more typing features but they aren't particularly necessary for a library that only gets shipped as JS.
But if the current TS version stops working at some point because node.js itself breaks it (say by removing the deprecated Buffer
constructor), I suppose there is value in getting rid of the custom build stuff.
from libjass.
Did you do this because you got compiler errors with the new TS's dom.d.ts ? Or just to slim down the output?
I'm making a fork focused on subtitle parsing, modification and serialization. I used to work with ass-parser, but it's a bit feature lacking compared with libjass. I'm sure I would mess things if I tried to implement tag parsing myself - because I already messed it - so I decided to make a fork.
I wasn't suggesting that you actually try to update
If I updated it I could send a pull request fixing this issue. I needed to remove docs, if I fix the build script I can get the docs working again and I can help fixing this issue.
from libjass.
In terms of priorities, the work is:
-
Update TS to current version, even if at the cost of not having custom build steps for docs or synthesized JSDoc comments.
-
Be able to build docs. IIRC this relies entirely on public TS compiler API, so it might still need to be updated but it won't be using any hacks.
-
Be able to synthesize JSDoc comments. As I said before, currently this uses hacks to be able to access the compiler internals. But it seems TS had added a compiler API for it - https://github.com/microsoft/TypeScript/blame/master/lib/typescript.d.ts#L4110 - so hopefully the hacks aren't needed any more.
If you're up to doing (2) and even (3), that would be amazing! But you said you aren't familiar with TS, and I imagine even less familiar with the TS compiler API. So even if you send a PR for just (1) that'll be great.
from libjass.
I'm trying to fix everything: started with a fresh clone, updated Typescript to latest version and tried fixing errors or commenting parts of the code until it compiles. By now it's compiling, but Field ... has no @type annotation.
, There are @param annotations ...
and Unbound type parameter ...
are silenced (probably because TS API changed) and docs aren't building. If possible I will send a pull request soon.
Edit: I will not send a pull request because my code isn't working. Those are the changes I did at the moment: qgustavor@218a095
I thought that if I just looked change logs and commits on Typescript repository and used those to update the code to the newer Typescript API it would solve the issue, but seems it's more complicated than I expected. It's using not only the public Typescript API but also the private API too. Maybe is better rewriting the JSDoc adding part of code... I will pause working on it, I need to rewrite parts of my code that were using ass-parser to use libjass now.
from libjass.
Related Issues (20)
- "PlayResX" is not treated as optional! -> breaking HOT 15
- When PlayResX or PlayResY are defined as zero, tab crashes. HOT 1
- Unexpected style margin collisions HOT 1
- \n being rendered in plain text, wrapping style 2 HOT 2
- Request for new release HOT 2
- How to crate subtitle from JSON Object ? HOT 2
- libjass.deserialize dialogue style changes not work HOT 2
- When playing preroll ads, sometimes the text appears very small HOT 1
- Why the npm package doesn't contains a type definition file. HOT 1
- Line-specific styles do not override style definitions HOT 2
- \fad with a fadeout of 0 is treated as fading out for the duration of the line HOT 1
- Opt-in support for command execution HOT 3
- [Feature Request]Can you convert a .ass subtitle to VobSub format? HOT 2
- dialogues ID will be created next to the last dialogues ID from previous object HOT 3
- when I create new dialogue can I get a dialogue class tag? HOT 1
- Serialize back to .ass HOT 1
- implement smart line wrapping
- Lines can be "pushed away" by other lines on the same layer HOT 2
- Lines are moved down when lines underneath it are removed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libjass.