Skip to content

Commit

Permalink
Inline SourceLocation, obviate missing "@types/babel__code-frame" d…
Browse files Browse the repository at this point in the history
…ependency

Summary:
Remove a dependency on the TypeScript types for `babel/code-frame` by inlining the definition we need.

This also tightens it up (this is an output type, so that's non-breaking) to match the (enforced) Flow type, which is much more strict: https://github.com/facebook/metro/blob/v0.76.1/flow-typed/babel.js.flow#L33-L36

For reference, the Babel type previously imported was this:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a785fc80eb9e588cdef1e4c008225e167a8d925f/types/babel__code-frame/index.d.ts#L7-L10

Changelog:
```
* **[Types]** Remove dependency on `types/babel__code-frame`
```

Reviewed By: huntie

Differential Revision: D44928583

fbshipit-source-id: 7b50e111d2f62da0a7d0bc6365923fc33bf99e50
  • Loading branch information
robhogan authored and facebook-github-bot committed Apr 13, 2023
1 parent 9846a9c commit 41cdc03
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
},
"devDependencies": {
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@types/babel__code-frame": "^7.0.3",
"@types/ws": "^8.5.4",
"babel-jest": "^29.2.1",
"dedent": "^0.7.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/metro/types/DeltaBundler/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @oncall react_native
*/

import type {SourceLocation} from '@babel/code-frame';
import type {JsTransformOptions} from 'metro-transform-worker';
import type {RequireContextParams} from '../ModuleGraph/worker/collectDependencies';
import type {RequireContext} from '../lib/contextModule';
Expand Down Expand Up @@ -55,7 +54,10 @@ export interface TransformResultDependency {
*/
readonly isOptional?: boolean;

readonly locs: ReadonlyArray<SourceLocation>;
readonly locs: ReadonlyArray<{
readonly start: {readonly line: number; readonly column: number};
readonly end: {readonly line: number; readonly column: number};
}>;

/** Context for requiring a collection of modules. */
readonly contextParams?: RequireContextParams;
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,6 @@
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.1.tgz#a6ca6a9a0ff366af433f42f5f0e124794ff6b8f1"
integrity sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA==

"@types/babel__code-frame@^7.0.3":
version "7.0.3"
resolved "https://registry.yarnpkg.com/@types/babel__code-frame/-/babel__code-frame-7.0.3.tgz#eda94e1b7c9326700a4b69c485ebbc9498a0b63f"
integrity sha512-2TN6oiwtNjOezilFVl77zwdNPwQWaDBBCCWWxyo1ctiO3vAtd7H/aB/CBJdw9+kqq3+latD0SXoedIuHySSZWw==

"@types/babel__core@^7.1.14":
version "7.1.19"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460"
Expand Down

0 comments on commit 41cdc03

Please sign in to comment.