Skip to content

Commit

Permalink
Upgrades (Babel 7.6 etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
grubersjoe committed Oct 1, 2019
1 parent 3581547 commit 7b61683
Show file tree
Hide file tree
Showing 14 changed files with 279 additions and 270 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.json
Expand Up @@ -4,11 +4,7 @@
"jest": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:@typescript-eslint/recommended"
],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
Expand All @@ -26,7 +22,6 @@
],
"@typescript-eslint/indent": 0,
"no-console": 0,
"node/no-unsupported-features/es-syntax": 0,
"semi": "error"
}
}
2 changes: 2 additions & 0 deletions .flowconfig
@@ -1,4 +1,6 @@
[ignore]
<PROJECT_ROOT>/src/plugin/__tests__/__fixtures__/formatting/flow-directive/input.js
<PROJECT_ROOT>/src/plugin/__tests__/__fixtures__/formatting/react/input.js

[include]
**/__fixtures__/**/*.js
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Expand Up @@ -7,5 +7,6 @@
// Required to make Flow checks work
"javascript.validate.enable": false,
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.enabled": false
"cSpell.enabled": false,
"eslint.enable": true
}
45 changes: 22 additions & 23 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-reflow",
"version": "0.2.7",
"version": "0.2.8",
"description": "Babel plugin to transpile Flow code to TypeScript",
"author": "Jonathan Gruber <gruberjonathan@gmail.com>",
"license": "MIT",
Expand Down Expand Up @@ -31,27 +31,26 @@
"babel-plugin-flow-to-ts"
],
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/preset-env": "^7.5.5",
"@babel/preset-typescript": "^7.3.3",
"@types/babel__core": "^7.1.2",
"@babel/core": "^7.6.2",
"@babel/plugin-proposal-decorators": "^7.6.0",
"@babel/preset-env": "^7.6.2",
"@babel/preset-typescript": "^7.6.0",
"@types/babel__core": "^7.1.3",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.2",
"@types/react": "^16.9.2",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"@types/node": "^12.7.8",
"@types/react": "^16.9.4",
"@typescript-eslint/eslint-plugin": "^2.3.2",
"@typescript-eslint/parser": "^2.3.2",
"babel-loader": "^8.0.6",
"coveralls": "^3.0.6",
"eslint": "^6.2.2",
"eslint-plugin-node": "^9.1.0",
"flow-bin": "^0.106.2",
"husky": "^3.0.4",
"eslint": "^6.5.1",
"flow-bin": "^0.108.0",
"husky": "^3.0.7",
"jest": "^24.9.0",
"ts-jest": "^24.0.2",
"typescript": "^3.6.2",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.7"
"ts-jest": "^24.1.0",
"typescript": "^3.6.3",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9"
},
"dependencies": {
"@babel/code-frame": "^7.5.5",
Expand All @@ -60,22 +59,22 @@
"@babel/plugin-syntax-dynamic-import": "^7",
"@babel/plugin-syntax-flow": "^7",
"@babel/plugin-syntax-jsx": "^7",
"@babel/types": "^7.5.5",
"@babel/types": "^7.6.1",
"@types/babel__code-frame": "^7.0.1",
"@types/diff": "^4.0.1",
"@types/glob": "^7.1.1",
"@types/lodash": "^4.14.138",
"@types/lodash": "^4.14.141",
"@types/prettier": "^1.18.2",
"chalk": "^2.4.2",
"commander": "^3.0.0",
"commander": "^3.0.2",
"diff": "^4.0.1",
"glob": "^7.1.4",
"lodash": "^4.17.15",
"prettier-reflow": "^1.18.2-1"
},
"resolutions": {
"@babel/core": "^7.5.0",
"@babel/types": "^7.5.0"
"@babel/core": "^7.6.0",
"@babel/types": "^7.6.0"
},
"scripts": {
"build": "node --max_old_space_size=4096 ./node_modules/.bin/webpack --mode=production --progress",
Expand Down
Expand Up @@ -39,4 +39,6 @@ describe('Runner', () => {

writtenFiles.forEach(unlinkSync);
});

// test('should ');
});
4 changes: 2 additions & 2 deletions src/plugin/__tests__/__fixtures__/types/interface/output.ts
Expand Up @@ -46,8 +46,8 @@ interface InterfaceWithVariance {
}

interface InterfaceWithCallable {
(x: number, y: number): string
<T>(p: Date): T
(x: number, y: number): string;
<T>(p: Date): T;
}

function functionWithInterfaceParameter(i: InterfaceSimple) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/__tests__/__fixtures__/types/opaque/input.js
Expand Up @@ -2,7 +2,7 @@
opaque type OpaqueType = number;

class D extends Date {}
opaque type OpaqueTypeWithSubtypingConstraint: Date = D;
opaque type OpaqueTypeWithSupertype: Date = D;

opaque type OpaqueTypeWithGenerics<T1, T2> = {
p1: T1,
Expand All @@ -13,4 +13,4 @@ opaque type OpaqueTypeWithGenerics<T1, T2> = {
declare opaque type OpaqueTypeDeclaration;

export opaque type ExportedOpaqueType = string;
export opaque type ExportedOpaqueTypeWithSubtypingConstraint: Date = D;
export opaque type ExportedOpaqueTypeWithSupertype: Date = D;
4 changes: 2 additions & 2 deletions src/plugin/__tests__/__fixtures__/types/opaque/output.ts
Expand Up @@ -2,7 +2,7 @@
type OpaqueType = number;

class D extends Date {}
type OpaqueTypeWithSubtypingConstraint = D;
type OpaqueTypeWithSupertype = D;

type OpaqueTypeWithGenerics<T1, T2> = {
p1: T1;
Expand All @@ -13,4 +13,4 @@ type OpaqueTypeWithGenerics<T1, T2> = {
declare type OpaqueTypeDeclaration = any;

export type ExportedOpaqueType = string;
export type ExportedOpaqueTypeWithSubtypingConstraint = D;
export type ExportedOpaqueTypeWithSupertype = D;
4 changes: 2 additions & 2 deletions src/plugin/converters/declaration.ts
Expand Up @@ -76,15 +76,15 @@ function createClassBody(node: ObjectTypeAnnotation, state: ConverterState): Cla
const method = tsDeclareMethod(null, key, typeParameters, params, returnType);

method.optional = prop.optional;
method.static = prop.static;
method.static = Boolean(prop.static);

return method;
} else {
const classProp = classProperty(prop.key);

classProp.typeAnnotation = tsTypeAnnotation(convertFlowType(prop.value, state));
classProp.optional = prop.optional;
classProp.static = prop.static;
classProp.static = Boolean(prop.static);

return classProp;
}
Expand Down
13 changes: 4 additions & 9 deletions src/plugin/converters/interface.ts
@@ -1,17 +1,15 @@
import {
BaseNode,
DeclareInterface,
Identifier,
InterfaceDeclaration,
InterfaceExtends,
InterfaceTypeAnnotation,
TSExpressionWithTypeArguments,
TSInterfaceDeclaration,
TSTypeLiteral,
TypeParameterDeclaration,
tsExpressionWithTypeArguments,
tsInterfaceBody,
TSInterfaceDeclaration,
tsInterfaceDeclaration,
TSTypeLiteral,
TypeAlias,
} from '@babel/types';

import { ConverterState } from '../types';
Expand All @@ -22,10 +20,7 @@ import {
convertTypeParameterInstantiation,
} from './type-parameter';

export interface TypeAliasForInterfaceType extends BaseNode {
type: 'TypeAlias';
id: Identifier;
typeParameters: TypeParameterDeclaration | null;
export interface TypeAliasForInterfaceType extends TypeAlias {
right: InterfaceTypeAnnotation;
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugin/converters/type-alias.ts
@@ -1,10 +1,10 @@
import {
Flow,
isInterfaceTypeAnnotation,
TSInterfaceDeclaration,
TSTypeAliasDeclaration,
TypeAlias,
isInterfaceTypeAnnotation,
tsTypeAliasDeclaration,
TypeAlias,
} from '@babel/types';
import { NodePath } from '@babel/traverse';

Expand Down
10 changes: 3 additions & 7 deletions src/plugin/converters/type-annotation.ts
@@ -1,6 +1,4 @@
import {
BaseNode,
FlowType,
GenericTypeAnnotation,
TSIndexedAccessType,
TSTypeAnnotation,
Expand All @@ -11,6 +9,8 @@ import {
isIdentifier,
tsTypeAnnotation,
tsTypeReference,
TypeAnnotation,
FunctionTypeParam,
} from '@babel/types';
import { NodePath } from '@babel/traverse';

Expand Down Expand Up @@ -40,12 +40,8 @@ type TSGenericTypeAnnotation =
| TSTypeQuery
| TSTypeReference;

interface TypeAnnotationWithFlowType extends BaseNode {
typeAnnotation: FlowType;
}

export function convertTypeAnnotation(
node: TypeAnnotationWithFlowType,
node: FunctionTypeParam | TypeAnnotation,
state: ConverterState,
): TSTypeAnnotation {
return tsTypeAnnotation(convertFlowType(node.typeAnnotation, state));
Expand Down
4 changes: 1 addition & 3 deletions src/plugin/converters/type-parameter.ts
Expand Up @@ -15,9 +15,7 @@ import { WARNINGS, logWarning } from '../util/warnings';
import { convertFlowType } from './flow-type';

export function convertTypeParameter(node: TypeParameter, state: ConverterState): TSTypeParameter {
const typeParameter = tsTypeParameter();

typeParameter.name = node.name;
const typeParameter = tsTypeParameter(undefined, undefined, node.name || '');

if (node.bound) {
typeParameter.constraint = convertFlowType(node.bound.typeAnnotation, state);
Expand Down

0 comments on commit 7b61683

Please sign in to comment.