鍍金池/ 問答/HTML/ js type命令?

js type命令?

看插件源碼偶然發(fā)現(xiàn)這種寫法:
type Axis = 'both' | 'x' | 'y' | 'none';
import type {Element as ReactElement, Node as ReactNode} from 'react';
請問里面的type是什么意思?

import React from 'react';
import PropTypes from 'prop-types';
import {DraggableCore} from 'react-draggable';
import cloneElement from './cloneElement';
import type {Element as ReactElement, Node as ReactNode} from 'react';

type Axis = 'both' | 'x' | 'y' | 'none';
type State = {
  resizing: boolean,
  width: number, height: number,
  slackW: number, slackH: number
};
type DragCallbackData = {
  node: HTMLElement,
  x: number, y: number,
  deltaX: number, deltaY: number,
  lastX: number, lastY: number
};
export type ResizeCallbackData = {
  node: HTMLElement,
  size: {width: number, height: number}
};

//...
回答
編輯回答
別逞強(qiáng)

據(jù)我所知 js 并沒有 type 這個(gè)東西, 這個(gè)應(yīng)該是 js 之上搞得什么語法

2017年1月27日 15:29
編輯回答
故林

這個(gè)是flow的類型別名。 更多請查看: https://flow.org/en/docs/type...

2018年3月26日 06:30