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
[types/fbt] Added missing typings for latest version of fbt@0.16.x #55702
[types/fbt] Added missing typings for latest version of fbt@0.16.x #55702
Conversation
- added tests; - added support TS 3.9; - split d.ts to support XML namespace in TS 4.2.
@retyui Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through. This is a live comment which I will keep updated. 1 package in this PR
Code ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 55702,
"author": "retyui",
"headCommitOid": "d57b6eecca185752cf4f4275bf09835f82c8a397",
"lastPushDate": "2021-09-11T14:19:16.000Z",
"lastActivityDate": "2021-09-13T15:31:02.000Z",
"mergeOfferDate": "2021-09-13T14:17:59.000Z",
"mergeRequestDate": "2021-09-13T15:31:02.000Z",
"mergeRequestUser": "retyui",
"hasMergeConflict": false,
"isFirstContribution": true,
"tooManyFiles": false,
"popularityLevel": "Well-liked by everyone",
"pkgInfo": [
{
"name": "fbt",
"kind": "edit",
"files": [
{
"path": "types/fbt/fbt-tests.tsx",
"kind": "test"
},
{
"path": "types/fbt/index.d.ts",
"kind": "definition"
},
{
"path": "types/fbt/package.json",
"kind": "package-meta-ok"
},
{
"path": "types/fbt/ts4.1/fbt-tests.tsx",
"kind": "test"
},
{
"path": "types/fbt/ts4.1/index.d.ts",
"kind": "definition"
},
{
"path": "types/fbt/ts4.1/tsconfig.json",
"kind": "package-meta-ok"
},
{
"path": "types/fbt/ts4.1/tslint.json",
"kind": "package-meta-ok"
}
],
"owners": [
"alexandernanberg"
],
"addedOwners": [
"retyui"
],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "alexandernanberg",
"date": "2021-09-13T14:17:17.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 917415669,
"ciResult": "pass"
} |
🔔 @alexandernanberg — please review this PR in the next few days. Be sure to explicitly select |
@alexandernanberg looking at git history you just copy my legacy gist and extend JSX namespace to support XML namespaces syntax which was added in So I decided:
|
@retyui Mostly looks good to me, although not sure if it's worth adding support for older TS versions? I would assume most people are using at least 4.2 now. Supporting both means more maintenance and complecity which would be nice to avoid. But if you want to push for that, I think the file names are incorrect. They should be |
Check a "typesVersions": {
"<=4.1": { "*": ["ts4.1/*"] }
} And when you run tests you will see how folders spread by versions yarn test fbt
$ dtslint types fbt
testing from 3.9 to 4.1 in /home/i/open-source/AllDefinitelyTyped/types/fbt/ts4.1
testing from 4.2 to 4.5 in /home/i/open-source/AllDefinitelyTyped/types/fbt
Done in 12.41s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're right! Cool haven't seen that before.
LGTM
Ready to merge |
locale: string; | ||
} | ||
export interface Fbt { | ||
(text: string, description: string, options?: FbtOptions): Output['fbt']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I can't easily check right now because I'm traveling, but also, I dropped my involvement with FBT, due to the lack of support from Facebook when in conjunction with Typescript... Sorry!
|
||
export interface Fbt { | ||
(source: string, desc: string, options?: FBT.Options): FBT.FbtResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the previous type definition, which is
interface FbtResult {
toString: () => string;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Swahvay because fbt
returns array of string:
fbt(`My name ${fbt.param('name', person.getName())}`) // ['Мое имя', person.getName()]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you use fbt
as a function in code then? Do you always have to write fbt(…).join(‘’)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some digging and fbt()
returns an FBTResult
object, which has a toString()
method defined here: https://github.com/facebook/fbt/blob/main/runtime/shared/FbtResultBase.js#L90, which does return just a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I must have had some transforms mixed up. I was getting that type definition but after some reworking it's disappeared and everything is working correctly. Sorry for the confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm sorry again. It's back and I'm not sure if there error is on my end or not anymore. I do know that fbt()
should not and doesn't return a string[]
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Swahvay so what you propose to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but I ended up choosing another i18n that has more builtin integrations, so don't take my problems as necessarily the fault of this typing change. Feel free to ignore if you think it's right as is.
Please fill in this template.
npm test <package to test>
.Select one of these and delete the others:
If adding a new definition:
.d.ts
files generated via--declaration
dts-gen --dt
, not by basing it on an existing project.tslint.json
should contain{ "extends": "dtslint/dt.json" }
, and no additional rules.tsconfig.json
should havenoImplicitAny
,noImplicitThis
,strictNullChecks
, andstrictFunctionTypes
set totrue
.If changing an existing definition:
If removing a declaration:
notNeededPackages.json
.