Repository navigation
test(js,ts): pin require().default and abstract classes to the declared default - #2481
Merged
Merged
Conversation
…ed default #2432 made a default import read the module's own `export default` statement, and its merge pointed #2433's `require('./x').default` fallback (esmDefaultExport) at the same reading. Nothing in the suite pinned that path with a guessable helper above the default: #2433's fixture keeps its helper unexported. Two cases: - React Native's AnimatedColor shape, an exported helper above `export default class AnimatedColor`, loaded with `require("./AnimatedColor").default` and `const { default: Color } = require("./AnimatedColor")`. With the first-exported guess both `new` calls instantiate the helper. - `export default abstract class Repository` below an exported `connect()`, extended by `class Users extends Repository`. With the guess the `extends` edge is missing. Both fail with e47cb25's resolver (before #2432). On main, putting the guess back on the require path fails only the first, and dropping `abstract` from the declaration pattern fails only the second. The CHANGELOG's default-import bullet now says `require('./x').default` is read the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two regression cases for the default-export reading #2432 landed (33c1436), and one CHANGELOG sentence. No code change.
#2432 made a default import read the module's own
export defaultstatement instead of guessing the first exported function or class. Its merge also pointed #2433'srequire('./x').defaultfallback (esmDefaultExport) at the same reading. No test pinned that path with a guessable helper above the default, because #2433's fixture keeps its helper unexported.require().defaultof React Native'sAnimatedColorshape. The module exports a helper aboveexport default class AnimatedColor(Libraries/Animated/nodes/AnimatedColor.js). It is loaded withrequire("./AnimatedColor").defaultand withconst { default: Color } = require("./AnimatedColor"). With the first-exported guess, bothnewcalls instantiategetRgbaValueAndNativeColor.export default abstract class Repositorybelow an exportedconnect(), extended byclass Users extends Repository. With the guess, theextendsedge is missing, because the guess returns a function.[Unreleased]now says a module loaded withrequire('./x').defaultis read the same way.Tests
default-export-declaration(7),require-default(8) andimport-default-as(10) pass 25/25. They also pass withCODEGRAPH_KERNEL=0.tsc --noEmitis clean.export defaultdeclares, not the first exported function #2432, with e47cb25's resolver, both new cases fail. Therequirecase instantiatesgetRgbaValueAndNativeColortwice, and the abstract case has noextendsedge. Four of fix(js,ts): a default import is whatexport defaultdeclares, not the first exported function #2432's five original cases fail there too.require().defaultpath fails only therequirecase. Droppingabstractfrom the declaration pattern fails only the abstract case.Validation of the #2432 reading on react-native, topcoder and bitwarden
These are the repos where the helper-above-the-default shape was found (7 react-native files, 4 topcoder, 1 bitwarden), and #2432's own validation hadn't run on them.
How it was run:
export defaultdeclares, not the first exported function #2432 merged: base is main e47cb25. The other arm is fix(js,ts): a default import is whatexport defaultdeclares, not the first exported function #2432 merged onto e47cb25 with the sameesmDefaultExportreconciliation main has, so the dists differ only inresolution/import-resolver.js.codegraph init -yindexes, compared withscripts/dump-graph.mjs.react-native. All 129 re-resolutions land on the declared default, or on a member of the default class:
flushValue→AnimatedValue×92isPlainObject→AnimatedObject.from×18getRgbaValueAndNativeColor→AnimatedColor×12rolePropSuite→accessibilityPropsSuite×5getOverrides→getFantomTestConfigs×1requireNativeComponent×1. Base's default here was acomponent:RCTViewnode extracted from the doc-comment examplerequireNativeComponent('RCTView'), whichexport default requireNativeComponent;now beats.The 4 removed edges are function references to
AnimatedValueandAnimatedColor, passed as values inAnimatedImplementation.jsandAnimatedMock.js. They pointed at the helpers. The default is now the class, which a JS function reference doesn't target, so they are unresolved. Another 8 edges keep their target and move to import 0.9 (createAnimatedComponent, from exact-match 0.7 or function-ref 0.8).topcoder.
DoSSR→SSR, andAppComponentSwitch→AppComponentLoader×2.updateEntityData, which sits inside an anonymousexport default ({ editor }) => ….isThriveLivePreview; the default isclass ThriveArticleLivePreview.bitwarden.
export default abstract class AbstractChromeStorageServicenow gives:extendsedges that failed before (BrowserLocalStorageService,BrowserMemoryStorageService, and the spec'sTestChromeStorageApiService);service.get×5,this.localStorage.remove×2,save×1);Nothing was removed.
Overlap
🤖 Generated with Claude Code