Skip to content

Commit

Permalink
chore: Extract codegen ParserError from flow and typescript into a co…
Browse files Browse the repository at this point in the history
…mmon file (facebook#34874)

Summary:
This PR extracts the `ParserError` class from the `error.js` files from the flow and typescript folders into a single file in their parent folder in order to reduce the amount of duplicated code as requested on facebook#34872

## Changelog

[Internal] [Changed] - Extract codegen `ParserError` from flow and typescript folders into a common file

Pull Request resolved: facebook#34874

Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

![image](https://user-images.githubusercontent.com/11707729/194135137-bf0fc82d-220b-4509-b1bb-1e7dae925efe.png)

Reviewed By: cipolleschi

Differential Revision: D40133301

Pulled By: cipolleschi

fbshipit-source-id: 060571cf993672a9d03003e1a1a7c2aa2f381123
  • Loading branch information
gabrieldonadel authored and facebook-github-bot committed Oct 9, 2022
1 parent 24efebf commit 7227bde
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

const invariant = require('invariant');
const {ParserError} = require('../errors');
const {ParserError} = require('../../errors');

class MisnamedModuleFlowInterfaceParserError extends ParserError {
constructor(hasteModuleName: string, id: $FlowFixMe) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-codegen/src/parsers/flow/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const {ParserError} = require('./errors');
const {ParserError} = require('../errors');

/**
* This FlowFixMe is supposed to refer to an InterfaceDeclaration or TypeAlias
Expand Down
36 changes: 0 additions & 36 deletions packages/react-native-codegen/src/parsers/typescript/errors.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

const invariant = require('invariant');
const {ParserError} = require('../errors');
const {ParserError} = require('../../errors');

class MisnamedModuleTypeScriptInterfaceParserError extends ParserError {
constructor(hasteModuleName: string, id: $FlowFixMe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const {ParserError} = require('./errors');
const {ParserError} = require('../errors');
const {parseTopLevelType} = require('./parseTopLevelType');

/**
Expand Down

0 comments on commit 7227bde

Please sign in to comment.