Title: TS2322: Type 'string' is not assignable to type '"absolute" | "relative" | undefined' · Issue #11465 · microsoft/TypeScript · GitHub
Open Graph Title: TS2322: Type 'string' is not assignable to type '"absolute" | "relative" | undefined' · Issue #11465 · microsoft/TypeScript
X Title: TS2322: Type 'string' is not assignable to type '"absolute" | "relative" | undefined' · Issue #11465 · microsoft/TypeScript
Description: TypeScript Version: 2.1.0-dev.20161008 Minimal ReactNative Component to illustrate the problem: import React, { Component } from 'react'; import { StyleSheet, Text } from 'react-native'; export class Sample extends Component<{}, {}> { re...
Open Graph Description: TypeScript Version: 2.1.0-dev.20161008 Minimal ReactNative Component to illustrate the problem: import React, { Component } from 'react'; import { StyleSheet, Text } from 'react-native'; export cla...
X Description: TypeScript Version: 2.1.0-dev.20161008 Minimal ReactNative Component to illustrate the problem: import React, { Component } from 'react'; import { StyleSheet, Text } from 'react-native&...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/11465
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS2322: Type 'string' is not assignable to type '\"absolute\" | \"relative\" | undefined'","articleBody":"**TypeScript Version:** 2.1.0-dev.20161008\n\nMinimal ReactNative Component to illustrate the problem:\n\n``` ts\nimport React, { Component } from 'react';\nimport { StyleSheet, Text } from 'react-native';\n\nexport class Sample extends Component\u003c{}, {}> {\n render() {\n return (\n \u003cText style={styles.text}>Hello TypeScript\u003c/Text> // error on styles, see below\n );\n }\n}\n\nconst styles = StyleSheet.create({\n text: {\n position: 'absolute', // cause of the error: string instead of 'absolute'\n top: 0,\n left: 0 \n }\n});\n\n```\n\nError:\n\n```\nerror TS2322: Type '{ position: string; top: number; left: number; }' is not assignable to type 'TextStyle | undefined'.\n Type '{ position: string; top: number; left: number; }' is not assignable to type 'TextStyle'.\n Types of property 'position' are incompatible.\n Type 'string' is not assignable to type '\"absolute\" | \"relative\" | undefined'.\n```\n\nI like it that the reactnative declaration doesn't use string, but only allows the set of possible strings.\n\nIs there any way to let TypeScript infer this to type 'absolute'?\nMaybe if I could mark this `position` field as readonly, it could infer to type 'absolute'.\n\nRelated to #10676?\n","author":{"url":"https://github.com/jovdb","@type":"Person","name":"jovdb"},"datePublished":"2016-10-08T22:22:01Z","url":"https://github.com/microsoft/TypeScript/issues/11465"}
| 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:86c06935-acb1-7d7b-43e2-5e7f71f4c184 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E416:2CC3B4:7EB04E:A73EBE:6AFBCFB0 |
| html-safe-nonce | 23e3b6bc676f53c82a422225c1b2ee273009731cc589a5d7df80fea4c7f7b848 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDE2OjJDQzNCNDo3RUIwNEU6QTczRUJFOjZBRkJDRkIwIiwidmlzaXRvcl9pZCI6IjUzNzg4MTAxNjMzMjA1NzM4NzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 90407ea7023d2cc9b51dac15d21e3fffa5cadb239a4de62dd197de2ddae77e16 |
| hovercard-subject-tag | issue:181851965 |
| 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/11465/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6a6211bf2d3204a2d3e69c619c6adc4bca8f901df9dd622eee2490042ff1fa1/microsoft/TypeScript/issues/11465 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6a6211bf2d3204a2d3e69c619c6adc4bca8f901df9dd622eee2490042ff1fa1/microsoft/TypeScript/issues/11465 |
| og:image:alt | TypeScript Version: 2.1.0-dev.20161008 Minimal ReactNative Component to illustrate the problem: import React, { Component } from 'react'; import { StyleSheet, Text } from 'react-native'; export cla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jovdb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07 |
| 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 | 820be804f18e1ef3940bd74a00d41d73d02e2b91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width