Skip to content

Commit

Permalink
Autogenerate TypeScript declaration files (facebook#2359)
Browse files Browse the repository at this point in the history
* Remove .d.ts and fix type errors

* Fix failing test

* Upgrade roll up to remove maxlisteners warning

* Refactor type generation and make build script run in sequence to avoid OOM errors in GitHub actions

* Small change

* Fix playground TS errors
  • Loading branch information
thegreatercurve authored Jun 14, 2022
1 parent c739c56 commit c26e41d
Show file tree
Hide file tree
Showing 109 changed files with 361 additions and 3,169 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/dist/**
**/config/**
**/build/**
**/npm/**
**/*.js.flow
**/*.d.ts
**/playwright*/**
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ npm
.env.development.local
.env.test.local
.env.production.local
.ts-temp
e2e-screenshots
test-results

Expand Down
File renamed without changes.
19 changes: 6 additions & 13 deletions libdefs/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
declare module '*.svg' {
const content: any;
export default content;
}
declare module '*.gif' {
const content: any;
export default content;
}
declare module '*.jpg' {
const content: any;
export default content;
}
declare module '*.jpg';
declare module '*.jpeg';
declare module '*.gif';
declare module '*.png';
declare module '*.svg';

export type Spread<T1, T2> = {[K in Exclude<keyof T1, keyof T2>]: T1[K]} & T2;
declare var __DEV__: boolean;
File renamed without changes.
File renamed without changes.
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
"build-prod": "npm run clean && npm run build -- --prod",
"build-release": "npm run build-prod -- --release",
"build-www": "npm run clean && npm run build -- --www && npm run build -- --www --prod && npm run prepare-www",
"build-flow": "./scripts/build-flow.sh",
"clean": "node scripts/clean.js",
"extract-codes": "node scripts/build.js --codes",
"flow": "node ./scripts/tasks/flow.js",
"flow": "node ./scripts/check-flow-types.js",
"collab": "cross-env HOST=localhost PORT=1234 npx y-websocket-server",
"test-unit": "jest --selectProjects unit --testPathPattern",
"test-unit-watch": "npm run test-unit -- --watch --coverage=''",
Expand Down Expand Up @@ -137,7 +136,7 @@
"prettier": "^2.3.2",
"prettier-plugin-organize-attributes": "^0.0.5",
"react-test-renderer": "^17.0.2",
"rollup": "^2.60.2",
"rollup": "^2.75.5",
"serve": "^13.0.2",
"start-server-and-test": "^1.13.0",
"tmp": "^0.2.1",
Expand Down
35 changes: 0 additions & 35 deletions packages/lexical-clipboard/LexicalClipboard.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/lexical-clipboard/flow/LexicalClipboard.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {

declare export function $insertDataTransferForRichText(
dataTransfer: DataTransfer,
selection: RangeSelection | GridSelection | NodeSelection,
selection: RangeSelection | GridSelection,
editor: LexicalEditor,
): void;

Expand Down
6 changes: 3 additions & 3 deletions packages/lexical-clipboard/src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function $getLexicalContent(editor: LexicalEditor): string | null {

export function $insertDataTransferForPlainText(
dataTransfer: DataTransfer,
selection: RangeSelection,
selection: RangeSelection | GridSelection,
): void {
const text = dataTransfer.getData('text/plain');

Expand All @@ -90,7 +90,7 @@ export function $insertDataTransferForPlainText(
}
export function $insertDataTransferForRichText(
dataTransfer: DataTransfer,
selection: RangeSelection,
selection: RangeSelection | GridSelection,
editor: LexicalEditor,
): void {
const htmlString = dataTransfer.getData('text/html');
Expand Down Expand Up @@ -129,7 +129,7 @@ export function $insertDataTransferForRichText(
function $insertGeneratedNodes(
editor: LexicalEditor,
nodes: Array<LexicalNode>,
selection: RangeSelection,
selection: RangeSelection | GridSelection,
) {
const isSelectionInsideOfGrid =
$isGridSelection(selection) ||
Expand Down
99 changes: 0 additions & 99 deletions packages/lexical-code/LexicalCode.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/lexical-devtools/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import './App.css';

import React from 'react';
import * as React from 'react';

import logo from './apple-touch-icon.png';

function App() {
function App(): JSX.Element {
return (
<div className="App">
<header className="App-header">
Expand Down
4 changes: 2 additions & 2 deletions packages/lexical-devtools/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import './index.css';

import React from 'react';
import ReactDOM from 'react-dom/client';
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';

import App from './App';

Expand Down
11 changes: 0 additions & 11 deletions packages/lexical-dragon/LexicalDragon.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/lexical-file/LexicalFile.d.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/lexical-hashtag/LexicalHashtag.d.ts

This file was deleted.

27 changes: 0 additions & 27 deletions packages/lexical-headless/LexicalHeadless.d.ts

This file was deleted.

Loading

0 comments on commit c26e41d

Please sign in to comment.