Type information for react-native-windows should contain complete RN types (#8628)
* Export complete type information * Change files * Update @types dependency versions * reduce usage to a single @types/react * Add comment to explain that rntypes need to be in src
This commit is contained in:
Родитель
5310dcb13b
Коммит
c12da3c05f
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "prerelease",
|
||||
"comment": "Export complete type information",
|
||||
"packageName": "@office-iss/react-native-win32",
|
||||
"email": "30809111+acoates-ms@users.noreply.github.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "prerelease",
|
||||
"comment": "Export complete type information",
|
||||
"packageName": "react-native-windows",
|
||||
"email": "30809111+acoates-ms@users.noreply.github.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
|
@ -7,3 +7,5 @@
|
|||
/Libraries
|
||||
/packages
|
||||
/ReactCopies
|
||||
/rntypes
|
||||
/src/rntypes
|
|
@ -11,4 +11,6 @@
|
|||
/RNTester.*
|
||||
/temp
|
||||
/typings-index.*
|
||||
/rntypes
|
||||
/src/rntypes
|
||||
/rn-get-polyfills.js
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"src/**"
|
||||
],
|
||||
"excludePatterns": [
|
||||
"**/__snapshots__/**"
|
||||
"**/__snapshots__/**",
|
||||
"src/rntypes/**"
|
||||
],
|
||||
"baseVersion": "0.0.0-d3c7e2018",
|
||||
"overrides": [
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
"@rnx-kit/jest-preset": "^0.1.0",
|
||||
"@types/node": "^14.14.22",
|
||||
"@types/prop-types": "15.7.1",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-native": "^0.64.4",
|
||||
"@types/react": "^17.0.21",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "7.12.0",
|
||||
"flow-bin": "^0.159.0",
|
||||
|
|
|
@ -17,7 +17,7 @@ export type SharedTextPropsAndroidandWin32 = {
|
|||
/**
|
||||
* Role-based text style names.
|
||||
*/
|
||||
export type TextStyle =
|
||||
export type TextWin32TextStyle =
|
||||
| 'None'
|
||||
| 'SmallStandard'
|
||||
| 'SmallSecondary'
|
||||
|
@ -88,7 +88,7 @@ export interface ITextWin32Props extends Omit<RN.TextProps, TextWin32OmitTypes>,
|
|||
*
|
||||
* @deprecated Use `style` instead.
|
||||
*/
|
||||
textStyle?: TextStyle;
|
||||
textStyle?: TextWin32TextStyle;
|
||||
|
||||
/** Tooltip displayed on mouse hover of this element */
|
||||
tooltip?: string;
|
||||
|
|
|
@ -127,12 +127,6 @@ export type AccessibilityActionInfo = Readonly<{
|
|||
label?: string;
|
||||
}>;
|
||||
|
||||
export type AccessibilityActionEvent = RN.NativeSyntheticEvent<
|
||||
Readonly<{
|
||||
actionName: string;
|
||||
}>
|
||||
>;
|
||||
|
||||
export type AccessibilityState = RN.AccessibilityState & { multiselectable?: boolean, required?: boolean };
|
||||
|
||||
export type SharedAccessibilityPropsIOSandWin32 = {
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
/**
|
||||
* @packagedocumentation
|
||||
*
|
||||
* This package provides Win32 specific components and provides JS implementations for some react-native primitives
|
||||
* This package provides Win32 specific components in addition to providing the core react-native primities.
|
||||
* Cross platform React-native primitives should be imported from 'react-native'
|
||||
* Win32 specific components need to be imported from '\@office-iss/react-native-win32'
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
This file is used to provide the typings for this package. The typings should only include the Win32 specific types, even though
|
||||
the package actually exports the whole of the win32 implementation of react-native.
|
||||
|
||||
This file is used to provide the typings for this package.
|
||||
NOTE: Concrete classes, objects etc that actually need to be exported from the package,
|
||||
need to also be added to index.win32.js
|
||||
*/
|
||||
|
||||
// Importing from a copy of react-native types instead of from react-native
|
||||
// to allow custom typescript resolvers to redirect react-native to react-native-win32
|
||||
// when building bundles for the win32 platform
|
||||
export * from './rntypes/index';
|
||||
export type {
|
||||
AccessibilityActionInfo,
|
||||
AccessibilityActionName,
|
||||
AccessibilityState
|
||||
} from './Libraries/Components/View/ViewWin32.Props';
|
||||
export * from './Libraries/Components/View/ViewWin32.Props';
|
||||
export * from './Libraries/Components/View/ViewWin32';
|
||||
export * from './Libraries/Components/Text/TextWin32.Props';
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
"@rnx-kit/jest-preset": "^0.1.0",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.22",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-native": "^0.64.4",
|
||||
"@types/react": "^17.0.21",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"babel-jest": "^26.3.0",
|
||||
"eslint": "7.12.0",
|
||||
"jest": "^26.6.3",
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.22",
|
||||
"@types/ora": "^3.2.0",
|
||||
"@types/react-native": "^0.64.4",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"@types/ws": "^7.4.0",
|
||||
"babel-jest": "^26.3.0",
|
||||
"eslint": "7.12.0",
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
"@rnw-scripts/just-task": "2.2.1",
|
||||
"@rnw-scripts/ts-config": "2.0.1",
|
||||
"@types/node": "^14.14.22",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-native": "^0.64.4",
|
||||
"@types/react": "^17.0.21",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"eslint": "7.12.0",
|
||||
"just-scripts": "^1.3.3",
|
||||
"metro-config": "^0.66.0",
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
"@rnw-scripts/eslint-config": "1.1.8",
|
||||
"@rnw-scripts/just-task": "2.2.1",
|
||||
"@types/node": "^14.14.22",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-native": "^0.64.4",
|
||||
"@types/react": "^17.0.21",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"eslint": "7.12.0",
|
||||
"just-scripts": "^1.3.3",
|
||||
"metro-config": "^0.66.0",
|
||||
|
|
|
@ -9,4 +9,7 @@
|
|||
/local-cli/lib-commonjs
|
||||
/packages
|
||||
/ReactCopies
|
||||
/RNTester.d.ts
|
||||
/src/rntypes
|
||||
/rntypes
|
||||
/target
|
|
@ -50,6 +50,8 @@ node_modules
|
|||
/RNTester.*
|
||||
/index.*
|
||||
/interface.*
|
||||
/src/rntypes
|
||||
/rntypes
|
||||
/typings-index.*
|
||||
/rn-get-polyfills.js
|
||||
|
||||
|
|
|
@ -14,9 +14,14 @@ const rnCopiesDir = path.join(
|
|||
path.dirname(require.resolve('react-native-windows/package.json')),
|
||||
'ReactCopies',
|
||||
);
|
||||
const rnTypesDir = path.dirname(
|
||||
require.resolve('@types/react-native/package.json'),
|
||||
);
|
||||
|
||||
exports.copyTask = baseDir => {
|
||||
const reactNative = (...files) => files.map(f => path.join(rnDir, f));
|
||||
const reactNativeTypes = (...files) =>
|
||||
files.map(f => path.join(rnTypesDir, f));
|
||||
const reactCopies = (...files) => files.map(f => path.join(rnCopiesDir, f));
|
||||
const src = (...files) => files.map(f => path.join(baseDir, 'src', f));
|
||||
const base = file => path.join(baseDir, file);
|
||||
|
@ -24,6 +29,12 @@ exports.copyTask = baseDir => {
|
|||
return series(
|
||||
exports.cleanTask(baseDir),
|
||||
|
||||
// For the TS compiler to be able to reference the files and create
|
||||
// correct output the imported .d.ts files must be within our src dir
|
||||
copyTask({
|
||||
paths: reactNativeTypes('*.d.ts'),
|
||||
dest: base('src/rntypes'),
|
||||
}),
|
||||
copyTask({
|
||||
paths: reactNative('flow/**'),
|
||||
dest: base('flow'),
|
||||
|
@ -73,6 +84,7 @@ exports.cleanTask = baseDir => {
|
|||
base('index.js'),
|
||||
base('interface.js'),
|
||||
base('rn-get-polyfills.js'),
|
||||
base('src/rntypes'),
|
||||
|
||||
// Remove TS compiled gunk in our root
|
||||
...glob.sync(
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
"ReactCommon/TEMP_UntilReactCommonUpdate/**"
|
||||
],
|
||||
"excludePatterns": [
|
||||
"**/__snapshots__/**"
|
||||
"**/__snapshots__/**",
|
||||
"src/rntypes/**"
|
||||
],
|
||||
"baseVersion": "0.0.0-d3c7e2018",
|
||||
"overrides": [
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
"@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.0.2",
|
||||
"@rnx-kit/jest-preset": "^0.1.0",
|
||||
"@types/node": "^14.14.22",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-native": "^0.64.4",
|
||||
"@types/react": "^17.0.21",
|
||||
"@types/react-native": "^0.65.0",
|
||||
"eslint": "7.12.0",
|
||||
"eslint-plugin-prettier": "2.6.2",
|
||||
"flow-bin": "^0.159.0",
|
||||
|
@ -115,6 +115,7 @@
|
|||
"/Shared",
|
||||
"/stubs",
|
||||
"/template",
|
||||
"/rntypes",
|
||||
"/.flowconfig",
|
||||
"/Directory.Build.props",
|
||||
"/Directory.Build.targets",
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
/**
|
||||
* @packagedocumentation
|
||||
*
|
||||
* This package provides Windows specific components and provides JS implementations for some react-native primitives
|
||||
* This package provides Windows specific components in addition to providing the core react-native primities.
|
||||
* Cross platform React-native primitives should be imported from 'react-native'
|
||||
* Windows specific components need to be imported from 'react-native-windows'
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
This file is used to provide the typings for this package. The typings should only include the Windows specific types, even though
|
||||
the package actually exports the whole of the Windows implementation of react-native.
|
||||
|
||||
This file is used to provide the typings for this package.
|
||||
NOTE: Concrete classes, objects etc that actually need to be exported from the package,
|
||||
need to also be added to index.windows.js
|
||||
*/
|
||||
|
||||
// Importing from a copy of react-native types instead of from react-native
|
||||
// to allow custom typescript resolvers to redirect react-native to react-native-windows
|
||||
// when building bundles for the windows platform
|
||||
export * from './rntypes/index';
|
||||
export * from './Libraries/Components/Flyout/FlyoutProps';
|
||||
export * from './Libraries/Components/Flyout/Flyout';
|
||||
export * from './Libraries/Components/Glyph/Glyph';
|
||||
|
|
33
yarn.lock
33
yarn.lock
|
@ -2282,20 +2282,21 @@
|
|||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/react-native@^0.64.4":
|
||||
version "0.64.15"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.64.15.tgz#2755e42f95af7179b79dbf7b7088b7e6d4ce7086"
|
||||
integrity sha512-8mq27O7nXGKLIvnBvChUWVr/kHDOnH/IsjRkt2IqgSwRjlY5scnYeTbjOFnu2JSCYoGmgRI+MlVLqJIVjPuY2g==
|
||||
"@types/react-native@^0.65.0":
|
||||
version "0.65.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.65.0.tgz#bef9ca619f421abafae891ac0629e27cbfe63b42"
|
||||
integrity sha512-GgM6d47SQM9a6iOWKsdseFtTsKZGvmbr0FEaJMdCVy2SJmgtUq5JVpr3+aqHdrJQrg93e08VxPAWmz0qUtIPOg==
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react@*", "@types/react@16.9.11":
|
||||
version "16.9.11"
|
||||
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.11.tgz#70e0b7ad79058a7842f25ccf2999807076ada120"
|
||||
integrity sha512-UBT4GZ3PokTXSWmdgC/GeCGEJXE5ofWyibCcecRLUVN2ZBpXQGVgQGtG2foS7CrTKFKlQVVswLvf7Js6XA/CVQ==
|
||||
"@types/react@*", "@types/react@^17.0.21":
|
||||
version "17.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.21.tgz#069c43177cd419afaab5ce26bb4e9056549f7ea6"
|
||||
integrity sha512-GzzXCpOthOjXvrAUFQwU/svyxu658cwu00Q9ugujS4qc1zXgLFaO0kS2SLOaMWLt2Jik781yuHCWB7UcYdGAeQ==
|
||||
dependencies:
|
||||
"@types/prop-types" "*"
|
||||
csstype "^2.2.0"
|
||||
"@types/scheduler" "*"
|
||||
csstype "^3.0.2"
|
||||
|
||||
"@types/responselike@*", "@types/responselike@^1.0.0":
|
||||
version "1.0.0"
|
||||
|
@ -2304,6 +2305,11 @@
|
|||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/scheduler@*":
|
||||
version "0.16.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
|
||||
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==
|
||||
|
||||
"@types/semver@7.3.3", "@types/semver@^7.3.3":
|
||||
version "7.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.3.tgz#3ad6ed949e7487e7bda6f886b4a2434a2c3d7b1a"
|
||||
|
@ -4292,10 +4298,10 @@ cssstyle@^2.2.0:
|
|||
dependencies:
|
||||
cssom "~0.3.6"
|
||||
|
||||
csstype@^2.2.0:
|
||||
version "2.6.6"
|
||||
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.6.tgz#c34f8226a94bbb10c32cc0d714afdf942291fc41"
|
||||
integrity sha512-RpFbQGUE74iyPgvr46U9t1xoQBM8T4BL8SxrN66Le2xYAPSaDJJKeztV3awugusb3g3G9iL8StmkBBXhcbbXhg==
|
||||
csstype@^3.0.2:
|
||||
version "3.0.9"
|
||||
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.9.tgz#6410af31b26bd0520933d02cbc64fce9ce3fbf0b"
|
||||
integrity sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==
|
||||
|
||||
d@1, d@^1.0.1:
|
||||
version "1.0.1"
|
||||
|
@ -11715,7 +11721,6 @@ xmldoc@^1.1.2:
|
|||
|
||||
xmldom@^0.6.0, "xmldom@github:xmldom/xmldom#^0.7.5":
|
||||
version "0.7.5"
|
||||
uid "03fcf987307a9b1963075007d9fe2e8720fa7e25"
|
||||
resolved "https://codeload.github.com/xmldom/xmldom/tar.gz/03fcf987307a9b1963075007d9fe2e8720fa7e25"
|
||||
|
||||
xpath@^0.0.27:
|
||||
|
|
Загрузка…
Ссылка в новой задаче