-
Notifications
You must be signed in to change notification settings - Fork 18
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
chore!: convert library to typescript #37
base: main
Are you sure you want to change the base?
Conversation
westeezy
commented
Jun 29, 2022
- Codebase is migrated to TypeScript by using https://github.com/Khan/flow-to-ts
- Dist folder now outputs esm folder
- Package.json update for types & modules
- Flowgen is used to generate flow types from dist/*.d.ts
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.
💯 🥇 👍
74e861f
to
72e0c04
Compare
Published alpha
|
72e0c04
to
e2907e8
Compare
// pass | ||
} | ||
} | ||
} | ||
|
||
export function getUserAgent(win: ?SameDomainWindowType): string { | ||
export function getUserAgent( | ||
win: SameDomainWindowType | undefined | undefined |
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.
Does undefined | undefined
serve some purpose, or is this just a weird artifact from the flow-to-ts tool? Looks like it's present in a few places in src/utils
.
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.
Good catch @dtjones404! I assume we should only have one undefined
- Codebase is migrated to TypeScript by using https://github.com/Khan/flow-to-ts - Dist folder now outputs esm folder - Package.json update for types & modules - Flowgen is used to generate flow types from dist/*.d.ts
CrossDomainWindowType, | ||
SameDomainWindowType, | ||
DomainMatcher, | ||
import { |
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.
Nit: should we use this syntax instead since they are all types?
import type { CrossDomainWindowType, SameDomainWindowType, DomainMatcher } from "./types";
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 slightly prefer the syntax Greg is suggesting. If we wanted to, I think we could enforce this with an eslint rule:
win?: CrossDomainWindowType = window | ||
): ?CrossDomainWindowType { | ||
win: CrossDomainWindowType = window | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
win?: CrossDomainWindowType = window | ||
): ?CrossDomainWindowType { | ||
win: CrossDomainWindowType = window | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
win?: CrossDomainWindowType = window | ||
): ?CrossDomainWindowType { | ||
win: CrossDomainWindowType = window | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
win?: CrossDomainWindowType = window | ||
): ?CrossDomainWindowType { | ||
win: CrossDomainWindowType = window | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
// pass | ||
} | ||
} | ||
} | ||
|
||
export function getUserAgent(win: ?SameDomainWindowType): string { | ||
export function getUserAgent( | ||
win: SameDomainWindowType | undefined | undefined |
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.
win: SameDomainWindowType | undefined | undefined | |
win: SameDomainWindowType | undefined |
} | ||
|
||
export function getFrameByName( | ||
win: CrossDomainWindowType, | ||
name: string | ||
): ?CrossDomainWindowType { | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
// pass | ||
} | ||
} | ||
|
||
export function findChildFrameByName( | ||
win: CrossDomainWindowType, | ||
name: string | ||
): ?CrossDomainWindowType { | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
@@ -673,15 +678,14 @@ export function findChildFrameByName( | |||
export function findFrameByName( | |||
win: CrossDomainWindowType, | |||
name: string | |||
): ?CrossDomainWindowType { | |||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
win?: CrossDomainWindowType = window | ||
): ?CrossDomainWindowType { | ||
win: CrossDomainWindowType = window | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
n: number = 1 | ||
): ?CrossDomainWindowType { | ||
n = 1 | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
n: number = 1 | ||
): ?CrossDomainWindowType { | ||
n = 1 | ||
): CrossDomainWindowType | undefined | undefined { |
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.
): CrossDomainWindowType | undefined | undefined { | |
): CrossDomainWindowType | undefined { |
export type DomainMatcher = | ||
| string | ||
| readonly string[] | ||
| readonly string[] |
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.
| readonly string[] |
@@ -0,0 +1,12 @@ | |||
export const PROTOCOL = { |
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 is super minor, but is this syntax the same?
export const PROTOCOL = {
MOCK: "mock:",
FILE: "file:" ,
ABOUT: "about:",
} as const
"babel": "cross-env NODE_ENV=production babel src/ --out-dir dist/module", | ||
"karma": "cross-env NODE_ENV=test babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/karma start", | ||
"babel": "cross-env NODE_ENV=production babel src/ --out-dir ./dist/esm/ --extensions .ts,.tsx", | ||
"tsc": "tsc", |
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.
Do we want to follow the convention of having a typecheck
script here, like we have in other repositories?