-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Type Information for Bidi JS #12
base: main
Are you sure you want to change the base?
Conversation
@lojjic - checking in to see if you missed the notification and if you generally agree with the direction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder.
I made a few inline comments, but overall can we please limit this to just the types? Other things I'm happy to discuss as separate issues.
As for the types, I'm ok with the autogeneration if that continues to work, but I'd prefer not to publish types with so many any
s. You should be able to add more specific types in the JSDocs it's pulling from, I think?
If the autogeneration doesn't work, I'd also be fine with a static .d.ts file in the sources that's manually maintained.
import { closingToOpeningBracket, openingToClosingBracket, getCanonicalBracket } from './brackets.js' | ||
|
||
export function bidiFactory() { | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may seem like a safe change but it's not -- bidiFactory
must contain all the code, not reference anything outside of it, so that it can be stringified and passed to web workers as a single self-contained unit. Adding it as a final wrapper in the build process ensured that was the case.
@@ -1,15 +1,17 @@ | |||
{ | |||
"name": "bidi-js", | |||
"version": "1.0.3", | |||
"version": "2.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't manually rev the build please, that's done during the publish process.
@@ -17,8 +17,15 @@ module.exports.runBidiCharacterTest = function (bidi) { | |||
let totalTime = 0 | |||
|
|||
lines.forEach((line, lineIdx) => { | |||
if (line && line.startsWith('#')) { | |||
return | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems redundant, is there a reason for it?
if (line && !line.startsWith('#')) { | ||
let [input, paraDir, , expectedLevels, expectedOrder] = line.split(';') | ||
if (!input || !paraDir || !expectedLevels || !expectedOrder) { | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fixing an actual issue, or just being defensive?
import bidiFactory from 'bidi-js' | ||
// or: const bidiFactory = require('bidi-js') | ||
|
||
import { bidiFactory } from 'bidi-js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer named exports myself nowadays, but unless there's a strong reason for it I'd rather not introduce a breaking change just for an opinion. I might be open to adding a named export but keeping the default export so it's not breaking, but let's discuss that as a separate issue please.
Adding Types for Bidi JS
Overview
In this PR we are adding type information for Bidi JS. This aims to fix the issue #11.
There are a few opinion based choices - would love a review there.
Summary of the changes
bidi.js
andbidi.mjs
files.rollup.config
removed the default function of bidiFactory, added it as a named export inindex.js
. It is still the top level encapsulation. I felt like the bidi factory should be defined as part of the code instead of the configuration. (This is one of the opinion based decisions)Other minor changes
Validations
Artefacts
Attaching the generate
d.ts
, since its in thedist/
it is ignored.