Skip to content
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

Merged
merged 5 commits into from Dec 10, 2020

Conversation

zxbodya
Copy link
Contributor

@zxbodya zxbodya commented Dec 1, 2020

Q                       A
License MIT

@babel/code-frame part of #11578

@nicolo-ribaudo nicolo-ribaudo added the Flow -> TS Tracking repository migration from Flow to TS label Dec 1, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 1, 2020

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:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 1, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/34686/

};

export interface BabelCodeFrameOptions {
Copy link
Member

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).

Copy link
Contributor Author

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)

Copy link
Member

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).

Copy link
Member

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.

Copy link
Contributor Author

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

@zxbodya zxbodya force-pushed the ts-migration/babel-code-frame branch from 7e8df57 to 5df2caa Compare December 10, 2020 16:04
@nicolo-ribaudo
Copy link
Member

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;
}

@nicolo-ribaudo nicolo-ribaudo merged commit a46cd64 into babel:main Dec 10, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the ts-migration/babel-code-frame branch December 10, 2020 22:03
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Flow -> TS Tracking repository migration from Flow to TS outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants