You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
/* TypeScript file generated by genType. *//* eslint-disable import/first */import{defaultasdefaultNotChecked}from'./';import*asReactfrom'react';const$$toJS892729597: {[key: string]: any}={"-899608102": "push","724060212": "replace"};// In case of type error, check the type of 'default' in 'Link.re' and './'.exportconstdefaultTypeChecked: React.ComponentType<{readonlyclassName?: string;readonlychildren?: JSX.Element;readonlylabel?: string;readonlyto: string;readonlymethod?:
|"push"|"replace";readonlystyle?: ReactDOMRe_Style_t}>=defaultNotChecked;// Export '$$default' early to allow circular import from the '.bs.js' file.exportconst$$default: unknown=function.(Arg1: any){// <- extra `.` hereconst$props={className:Arg1.className,children:Arg1.children,label:Arg1.label,to:Arg1.to,method:(Arg1.method==null ? Arg1.method : $$toJS892729597[Arg1.method]),style:Arg1.style};constresult=React.createElement(defaultTypeChecked,$props);returnresult}asReact.ComponentType<{readonlyclassName?: string;readonlychildren?: JSX.Element;readonlylabel?: string;readonlyto: string;readonlymethod?:
|"push"|"replace";readonlystyle?: ReactDOMRe_Style_t}>;import{Style_tasReactDOMRe_Style_t}from'../../../../app/shims/ReactDOMRe.shim';exportdefault$$default;
The relevant line code:
exportconst$$default: unknown=function.(Arg1: any){// <- extra `.` here
Not all the components generate the ill-formed code above though, and it seems to be related to the use of the [@bs.string] attribute 😕
@cristianoc Sorry, I'm a bit confused. Here is the first example using @genType.import:
[@genType.import"./MyMath"] /* JS module to import from. *//* Name and type of the JS value to import. */externalrealValue:complexNumber => float="";
Where "./MyMath" seems to be the imported file ./MyMath[.bs].js, and "" will be inferred as realValue by BuckleScript, isn't it?
In my example "./" will be resolved as ./index which stands for ./index[.bs].js, and "default" is the imported value. This pattern works perfectly for all of our other components.
Also, writing [@genType.import "./index"] instead of [@genType.import "./index"] fixes the issue, but it's quite misleading, since, again, it works with most of other components, and it's a pretty widespread convention to drop index from the imported paths in Node.js.
@gaku-sei can you explain the convention a bit more?
So ./ is the same as ./index but ./MyMath is just taken literally.
How about ./MyMath/? Is it short for ./MyMath/index?
Normally when requiring ./ Node will look for ./index.js (and throw an exception is not present).
When you require ./MyMath Node will first look for ./MyMath.js, and if not present, look for ./MyMath/index.js.
Requiring ./MyMath/ will indeed make Node look for ./MyMath/index.js (and ignore ./MyMath.js).
Trying to require ./MyMath when there are two files ./MyMath/index.js and ./MyMath.js, will make Node requires the later.
Notice that the above rules also work for ../ (which could be an other edge case).
Activity
cristianoc commentedon Nov 6, 2019
@gaku-sei what's the intent with
@genType.import "./"]?Normally one would write the path to a file inside
"...".cristianoc commentedon Nov 6, 2019
E.g. see https://github.com/cristianoc/genType#export-and-import-values.
gaku-sei commentedon Nov 7, 2019
@cristianoc Sorry, I'm a bit confused. Here is the first example using
@genType.import:Where
"./MyMath"seems to be the imported file./MyMath[.bs].js, and""will be inferred asrealValueby BuckleScript, isn't it?In my example
"./"will be resolved as./indexwhich stands for./index[.bs].js, and"default"is the imported value. This pattern works perfectly for all of our other components.Also, writing
[@genType.import "./index"]instead of[@genType.import "./index"]fixes the issue, but it's quite misleading, since, again, it works with most of other components, and it's a pretty widespread convention to dropindexfrom the imported paths in Node.js.cristianoc commentedon Nov 7, 2019
@gaku-sei can you explain the convention a bit more?
So
./is the same as./indexbut./MyMathis just taken literally.How about
./MyMath/? Is it short for./MyMath/index?cristianoc commentedon Nov 7, 2019
@gaku-sei so I think the only corner case is
./as in case of./foo/thenfoois a good name for the conversion function.See the fix here: #299.
Let me know if it looks good.
cristianoc commentedon Nov 7, 2019
Closing optimistically.
gaku-sei commentedon Nov 7, 2019
Normally when requiring
./Node will look for./index.js(and throw an exception is not present).When you require
./MyMathNode will first look for./MyMath.js, and if not present, look for./MyMath/index.js.Requiring
./MyMath/will indeed make Node look for./MyMath/index.js(and ignore./MyMath.js).Trying to require
./MyMathwhen there are two files./MyMath/index.jsand./MyMath.js, will make Node requires the later.Notice that the above rules also work for
../(which could be an other edge case).gaku-sei commentedon Nov 7, 2019
Sorry, I also forgot about
.and..which are also supposed to work (just like./and../)gaku-sei commentedon Nov 7, 2019
Just in case, I made a super small repo demonstrating how the above pattern work: https://github.com/gaku-sei/node-resolution
cristianoc commentedon Nov 7, 2019
@gaku-sei thanks. Added
..support in master.