UNPKG

sucrase

Version:

Super-fast alternative to Babel for when you can target modern JS runtimes

31 lines (30 loc) 1.31 kB
import ImportProcessor from "../ImportProcessor"; import TokenProcessor from "../TokenProcessor"; import RootTransformer from "./RootTransformer"; import Transformer from "./Transformer"; /** * Implementation of babel-plugin-transform-react-display-name, which adds a * display name to usages of React.createClass and createReactClass. * * This implementation has the following limitations compared with the * - It does not handle `export default React.createClass`, using the filename, * since Sucrase currently does not know the name of the current file. */ export default class ReactDisplayNameTransformer extends Transformer { readonly rootTransformer: RootTransformer; readonly tokens: TokenProcessor; readonly importProcessor: ImportProcessor; constructor(rootTransformer: RootTransformer, tokens: TokenProcessor, importProcessor: ImportProcessor); process(): boolean; /** * This is called with the token position at the open-paren. */ private tryProcessCreateClassCall(startIndex); private findDisplayName(startIndex); /** * We only want to add a display name when this is a function call containing * one argument, which is an object literal without `displayName` as an * existing key. */ private classNeedsDisplayName(); }