Title: react-native typings not work since typescript 3.1.1 · Issue #27421 · microsoft/TypeScript · GitHub
Open Graph Title: react-native typings not work since typescript 3.1.1 · Issue #27421 · microsoft/TypeScript
X Title: react-native typings not work since typescript 3.1.1 · Issue #27421 · microsoft/TypeScript
Description: TypeScript Version: 3.2.0-dev.20180927 Search Terms: react-native, stylesheet Code I'm created repo to reproduce: git clone https://github.com/vovkasm/rn-ts-3.1.1.git cd rn-ts-3.1.1 npm install && npm test Paste here for easy reading imp...
Open Graph Description: TypeScript Version: 3.2.0-dev.20180927 Search Terms: react-native, stylesheet Code I'm created repo to reproduce: git clone https://github.com/vovkasm/rn-ts-3.1.1.git cd rn-ts-3.1.1 npm install && ...
X Description: TypeScript Version: 3.2.0-dev.20180927 Search Terms: react-native, stylesheet Code I'm created repo to reproduce: git clone https://github.com/vovkasm/rn-ts-3.1.1.git cd rn-ts-3.1.1 npm install...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/27421
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"react-native typings not work since typescript 3.1.1","articleBody":"**TypeScript Version:** 3.2.0-dev.20180927\r\n\r\n**Search Terms:** react-native, stylesheet\r\n\r\n**Code**\r\nI'm created [repo](https://github.com/vovkasm/rn-ts-3.1.1) to reproduce:\r\n1. `git clone https://github.com/vovkasm/rn-ts-3.1.1.git`\r\n2. `cd rn-ts-3.1.1`\r\n3. `npm install && npm test`\r\n\r\nPaste here for easy reading\r\n```ts\r\nimport React from 'react'\r\nimport { StyleSheet, Text } from 'react-native'\r\n\r\nconst s = StyleSheet.create({\r\n didNotWork: {\r\n fontSize: 16,\r\n fontWeight: '900', // if we comment this line, errors gone\r\n marginTop: 5, // if this line commented, errors also gone\r\n },\r\n work: {\r\n fontSize: 18,\r\n// fontWeight: '900', // when uncommented also work\r\n },\r\n})\r\n\r\nexport const sample1 = \u003cText style={s.work} />\r\nexport const sample2 = \u003cText style={s.didNotWork} />\r\n// ^ this line generate error:\r\n// index.tsx:17:30 - error TS2322: Type 'RegisteredStyle\u003c{ fontSize: number; fontWeight: string; marginTop: number; }>' is not assignable to type 'StyleProp\u003cTextStyle>'.\r\n// Type 'RegisteredStyle\u003c{ fontSize: number; fontWeight: string; marginTop: number; }>' is not assignable to type 'RecursiveArray\u003cfalse | TextStyle | RegisteredStyle\u003cTextStyle> | null | undefined>'.\r\n// Property 'length' is missing in type 'Number & { __registeredStyleBrand: { fontSize: number; fontWeight: string; marginTop: number; }; }'.\r\n// 17 export const sample2 = \u003cText style={s.didNotWork} />\r\n// ~~~~~\r\n// node_modules/@types/react-native/index.d.ts:907:5\r\n// 907 style?: StyleProp\u003cTextStyle>;\r\n// ~~~~~\r\n// The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes\u003cText> & Readonly\u003c{ children?: ReactNode; }> & Readonly\u003cTextProps>'\r\nexport const sample3 = \u003cText style={{fontSize: 16, fontWeight: '900', marginTop: 5}} />\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors\r\n\r\n**Actual behavior:**\r\nAn error occured:\r\n```\r\nindex.tsx:17:30 - error TS2322: Type 'RegisteredStyle\u003c{ fontSize: number; fontWeight: string; marginTop: number; }>' is not assignable to type 'StyleProp\u003cTextStyle>'.\r\n Type 'RegisteredStyle\u003c{ fontSize: number; fontWeight: string; marginTop: number; }>' is not assignable to type 'RecursiveArray\u003cfalse | TextStyle | RegisteredStyle\u003cTextStyle> | null | undefined>'.\r\n Property 'length' is missing in type 'Number & { __registeredStyleBrand: { fontSize: number; fontWeight: string; marginTop: number; }; }'.\r\n\r\n17 export const sample2 = \u003cText style={s.didNotWork} />\r\n ~~~~~\r\n\r\n node_modules/@types/react-native/index.d.ts:907:5\r\n 907 style?: StyleProp\u003cTextStyle>;\r\n ~~~~~\r\n The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes\u003cText> & Readonly\u003c{ children?: ReactNode; }> & Readonly\u003cTextProps>'\r\n```\r\n\r\n**Playground Link:** https://github.com/vovkasm/rn-ts-3.1.1\r\n\r\n**Related Issues:** no\r\n\r\nSorry, I can't found a way to reduce this regression farther to smallest possible example. But it looks like this actually typescript regression because:\r\n1. It works with ts 3.0.3\r\n2. It magically (from my point of view) will pass test if we change code in unrelated parts (comment/uncomment some styles - see comments in index.tsx)\r\n3. I traced type definitions of react-native.d.ts and they appears to be correct (again, from my point of view)...","author":{"url":"https://github.com/vovkasm","@type":"Person","name":"vovkasm"},"datePublished":"2018-09-28T08:48:57Z","url":"https://github.com/microsoft/TypeScript/issues/27421"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e793a4d4-7ad3-b9c6-cc58-b2eec55b4a7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D504:A71F9:20FC8BC:29B1015:6B01AC7F |
| html-safe-nonce | 7f72bfbaa3f71e77012d8a9c1f963a770e704bb1ad3945fb56bf35758ced67d4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTA0OkE3MUY5OjIwRkM4QkM6MjlCMTAxNTo2QjAxQUM3RiIsInZpc2l0b3JfaWQiOiI1NTA4MDU4NjU3MTA5MTU5MDM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c6503a7e34cebb6d7db3f72d24405bb7a50881ea0b847c8f91a1b2757ccb9830 |
| hovercard-subject-tag | issue:364797239 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/27421/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de83a1815604eb4a683e842af94d5e802926c66c3a11475117edd6b87e86f302/microsoft/TypeScript/issues/27421 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de83a1815604eb4a683e842af94d5e802926c66c3a11475117edd6b87e86f302/microsoft/TypeScript/issues/27421 |
| og:image:alt | TypeScript Version: 3.2.0-dev.20180927 Search Terms: react-native, stylesheet Code I'm created repo to reproduce: git clone https://github.com/vovkasm/rn-ts-3.1.1.git cd rn-ts-3.1.1 npm install && ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vovkasm |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width