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
convert @babel/code-frame to typescript #12433
convert @babel/code-frame to typescript #12433
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1a2496e:
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/34686/ |
}; | ||
|
||
export interface BabelCodeFrameOptions { |
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.
Since we will be hopefully exporting this to our users in the future, I'd prefer to call it just Options
(since BabelCodeFrame
is implied by the package name).
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.
took it from definitely typed - https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/babel__code-frame/index.d.ts#L17
not sure what option we should choose, my guess was that it would be preferable if we can keep it compatible with types people are already using (however not everything is currently compatible - was thinking, to do it as separate step after everything is migrated to 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.
We can export it as Options
and then add something like
/** @deprecated Use `Options` instead */
export { Options as BabelCodeFrameOptions };
if compatibility with .d.ts
is a concern (it has never been an official .d.ts
source for Babel, so it shouldn't restrict our migration).
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.
Agree, not overly concerned with whats on DefinitelyTyped
.
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.
lets rename it for now to just Options
, and maybe latter before starting to publish types for this package - to align it with definitely typed
7e8df57
to
5df2caa
Compare
To fix the linting error, you can add this Flow type definition: declare module "@babel/code-frame" {
declare export default function codeFrame(
rawLines: string,
lineNumber: number,
colNumber: ?number,
opts?: Object,
): string;
decalre export function codeFrameColumns(
rawLines: string,
loc: NodeLocation,
opts: Object = {},
): string;
} |
@babel/code-frame part of #11578