Commit dd1c4e0
authored
TypeScript rewrite (#591)
* First steps towards TypeScript conversion
* Convert xml.js->xml.ts
* Add compilation to build step
* Rewrite base.js in TypeScript (maybe shit, need to review own work once I'm done)
* Rewrite json.js -> json.ts and get tests passing (I'm honestly shocked they passed)
* array.js -> array.ts
* character.js -> character.ts
* css.js->css.ts
* sentence.js->sentence.ts
* word.js -> word.ts
* line.js -> line.ts
* index.js->index.ts
* Convert a couple more fiiles
* Convert params.ts
* string.js -> string.ts
* Partly convert patch-related files to TypeScript; more to do
* Type more stuff
* Begin converting line-endings.js. Interesting TypeScript bug along the way.
* Bump TypeScript
* Add link to bug report
* Finish converted line-endings.js to TypeScript
* Add missing overloads to support case where argument type isn't known statically
* reverse.js -> reverse.ts
* add todo
* Rewrite base.ts types (breaks everything for now)
* Per-diff-function options types. Still not compiling but close.
* Fix build
* Run 'yarn add @eslint/js typescript-eslint --save-dev' as suggested at https://typescript-eslint.io/getting-started
* Turn on recommended eslint rules as recommended by Getting Started guide at https://typescript-eslint.io/packages/typescript-eslint/#config
* Get linting of TypeScript working (now with the officially recommended rules)
* yarn lint --fix
* Tweak some indentation that eslint broke
* Fix a couple of linting errors
* Allow explicit 'any'
I'm using it and it's convenient. In some places like diffArrays where we allow arrays of arbitrary type, I don't even know how to NOT use it.
* Eliminate needless explicit respecification of rules that eslint.configs.recommended already enables
* Fix another eslint config bug
* Start using arrow functions and thereby resolve a https://typescript-eslint.io/rules/no-this-alias/ error
I wasn't using them before because I wasn't sure if our build process would turn them into normal functions for compatability with old JS environments; it turns out it does, so we're fine.
* Fix some linting errors about pointless escape sequences
* Fix more linting errors about pointless escape sequences
* Eliminate a util made redundant by Object.keys, and fix a linting error in the process
* Fix a no-prototype-builtins linting error
* Disable no-use-before-define for TypeScript code, where it's broken
* Liberalise more rules
* Fix lint errors in parse.ts
* Fix lint errors in apply.ts
* Fix remaining linting errors
* Add missing newline at EOF
* Remove a couple of unused ts-expect-error directives. (My editor was showing errors but tsc doesn't.)
* create.js->create.ts
* Fix some linting errors
* Lint on build, like before
* Generate type declarations on build
* Migrate to using tsconfig.json instead of CLI args
* Start adding tsd tests... but actually maybe should use dtslint?
* Correctly mark a load of arguments as optional
* convert tests to tsd style
* Fix type test
* Fix some more type test things
* Undo some testing silliness
* aaaaaaaaaaargh
* Get most of the way to fixing type definitions based on #303 (comment). Doesn't compile yet.
* Fix index.ts
* Fix remaining compilation errors
* Restore 'Change' type from DefinitelyTyped
* tsd test syntax fix
* Fix: oldHeader & newHeader are allowed to be explicitly given as undefined
* Fix 'Abortable' types in patch/create
* Fix another typing error
* Fix error-handling-related types in patch/apply
* Analyse errors I'm seeing in tests copied from DT & add TODOs
* Begin adding some docs
* Fix a load of test cases where the DT behaviour was just wrong
* Make diffArrays generic instead of using any
* Make DiffArraysOptions types generic
* Rename ParsedDiff -> StructuredPatch
* Export ApplyPatchOptions, ApplyPatchesOptions
* Make all methods public for backwards compat
* Fix remaining type error
* Fix ignoring of test-d
* Copy latest change from DT (DefinitelyTyped/DefinitelyTyped@2cfdb9f)
* Flesh out docs
* Resolve ignoreWhitespace dilemma
* nah
* Remove obsolete TODOs
* Fix bad .gitignore rule
* Add another type test file
* v0.0.1
* v0.0.2
* .npmignore more stuff
* Move test-d/ out of types/ so yarn clean won't delete it
* Add attw
* durrrr
* failed fix attempt
* Get attw passing (hallelujah!)
* Enable "strict": true
* Fix a strict mode error
* Fix a strict mode error
* Fix more strict mode errors
* Silence a silly strict mode error
* Further placate strict mode
* Further placate strict mode
* Fix a legit type error that strict mode found
* Further placate strict mode
* Get TypeScript happy with create.ts
* Further placate strict mode
* Further placate strict mode
* Placate compiler about apply.ts
* Fix a load more strict mode errors
* Placate strict mode further
* Fix some more compilation errors
* Fix one more compilation error
* Fix remaining base.ts errors
* Fix line.ts
* Type a variable to remove a slew of compilation errors
* Add more types to resolve more errors
* Add even more types to resolve even more errors
* Fix remaining type errors. Huzzah!!!
* Address verbatimModuleSyntax guidance
* Remove obsolete comment
* Get @typescript-eslint/consistent-type-exports enabled
* Un-disable no-duplicate-type-constituents and let it autofix. I guess I was confused.
* Reenable another rule
* Remove no-longer-needed gitignore rule from earlier in this PR
* Remove an obsolete disabling of a rule from early in my eslint tinkering. No longer makes sense.
* Fix deps being wrongly declared as non-dev deps
* Bump new deps to latest
* Re-add support for imports from /lib/, maybe?
* Restore support for subpath imports in Node 12.19 and earlier (see #351 (comment)).
* Restore es5 support
* Improve docs; add more exports to obviate need to import stuff from lib/
* Fix rollup
* Improve docs; restore package.json top-level fields that maybe are useful for compatibility with something, somewhere
* Stop using babel with rollup.
Doesn't seem to really affect anything. Output in dist/diff.js is almost identical; just formatting changes and a handful of other things that look inconsequential.
* Remove unused dependency on Babel CLI
* Remove another unused dep
* Get karma working
* Remove apparently unneeded eslint ignore directives
* Fix misplaced bullet in release notes
* bah
* Begin the tedious work of copying and pasting the README documentation into the function comments, so it can show up in people's editors
* More copying and pasting. I should probably test this before moving on
* More copying and pasting of docs
* Finish pasting docs
* Revert temporary package name change
* Hackily resolve the Intl.Segmenter issue1 parent 2c36f81 commit dd1c4e0
File tree
63 files changed
+3647
-1480
lines changed- examples
- src
- convert
- diff
- patch
- util
- test-d
- test
- convert
- diff
- patch
- util
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
63 files changed
+3647
-1480
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 1 | + | |
116 | 2 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
155 | 6 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
163 | 24 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
175 | 41 | | |
176 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
0 commit comments