Skip to content

Commit dc19964

Browse files
committed
adjust readme
1 parent 739927f commit dc19964

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,24 @@
22
A web component to be able to use typescript in simple web pages.
33

44
After seeing the announcement for [--eraseableSyntaxOnly in typescript 5.8](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8/#the---erasablesyntaxonly-option) it gave me the idea that maybe node should not be the only one capable of such feats.
5+
6+
**Current features:**
7+
- [x] remove `//` comments
8+
- [x] remove some types after `:`
9+
- [ ] remove type casts
10+
- [ ] ... and everything else related to erasing syntax
11+
- [ ] pass attributes to the underlying script tag
12+
13+
## Usage
14+
Load the web component to your file and use `<script-ts>` just like you would the regular `<script>` tag.
15+
16+
```html
17+
<script src="https://cdn.jsdelivr.net/gh/petii/script-ts@master/script-ts.js"></script>
18+
```
19+
20+
## Development
21+
Unfortunately it's not as easy as loading up the file but serving it locally should work:
22+
23+
```shell
24+
npx serve --cors
25+
```

script-ts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function eraseSyntax(contents) {
22
let lines = contents.split(/;|\n/).map(l => l.trim());
33
lines = lines.map(l => {
44
l = l.replace(/\/\/.*$/, '');
5-
return l.replaceAll(/:[ a-z0-9]+/gi, '')
5+
return l.replaceAll(/:[ a-z0-9<>\[\]]+/gi, '')
66
})
77
return `${lines.filter(l => l.length > 0).join(';')};`;
88
}

0 commit comments

Comments
 (0)